|
| 1 | +// This file is part of the ACTS project. |
| 2 | +// |
| 3 | +// Copyright (C) 2016 CERN for the benefit of the ACTS project |
| 4 | +// |
| 5 | +// This Source Code Form is subject to the terms of the Mozilla Public |
| 6 | +// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 | +// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 8 | + |
| 9 | +#pragma once |
| 10 | + |
| 11 | +#include "Acts/Geometry/BlueprintNode.hpp" |
| 12 | +#include "Acts/Geometry/CuboidVolumeBounds.hpp" |
| 13 | +#include "Acts/Geometry/CylinderVolumeBounds.hpp" |
| 14 | + |
| 15 | +namespace Acts { |
| 16 | + |
| 17 | +namespace Experimental { |
| 18 | + |
| 19 | +namespace detail { |
| 20 | +class PortalDesignatorBlueprintNodeImpl; |
| 21 | +} |
| 22 | + |
| 23 | +/// This node type assigns string tags to specific portal faces of its child |
| 24 | +/// volume during the blueprint construction. The tags can be used to look up |
| 25 | +/// the corresponding portals from the final @ref Acts::TrackingGeometry, e.g. |
| 26 | +/// "the portal connecting the tracker and the calorimeter". |
| 27 | +/// |
| 28 | +/// Tagging happens in the *finalize* phase, after all portal merging and |
| 29 | +/// fusing has completed, so the tagged portal is the final, shared portal that |
| 30 | +/// ends up in the geometry. The position of this node in the blueprint tree |
| 31 | +/// determines which face is meant, which makes the lookup robust against volume |
| 32 | +/// subdivision and portal ordering. |
| 33 | +/// @note This node can only have a single child. This is not an error during |
| 34 | +/// tree building, but during geometry construction. |
| 35 | +class PortalDesignatorBlueprintNode final : public BlueprintNode { |
| 36 | + public: |
| 37 | + /// Main constructor for the portal designator node. |
| 38 | + /// @param name The name of the node (for debug only) |
| 39 | + explicit PortalDesignatorBlueprintNode(const std::string& name); |
| 40 | + |
| 41 | + ~PortalDesignatorBlueprintNode() override; |
| 42 | + |
| 43 | + /// @copydoc BlueprintNode::name |
| 44 | + const std::string& name() const override; |
| 45 | + |
| 46 | + /// @copydoc BlueprintNode::toStream |
| 47 | + void toStream(std::ostream& os) const override; |
| 48 | + |
| 49 | + /// This method participates in the geometry construction. |
| 50 | + /// It checks that this node only has a single child and forwards the call. |
| 51 | + /// @param options The global blueprint options |
| 52 | + /// @param gctx The geometry context (nominal usually) |
| 53 | + /// @param logger The logger to use |
| 54 | + /// @return The child volume |
| 55 | + Volume& build(const BlueprintOptions& options, const GeometryContext& gctx, |
| 56 | + const Logger& logger = Acts::getDummyLogger()) override; |
| 57 | + |
| 58 | + /// This method participates in the geometry construction. |
| 59 | + /// It captures the populated portal shell from its only child so the tags can |
| 60 | + /// be applied in the finalize phase (after all merging/fusing), and forwards |
| 61 | + /// the call. |
| 62 | + /// @param options The global blueprint options |
| 63 | + /// @param gctx The geometry context (nominal usually) |
| 64 | + /// @param logger The logger to use |
| 65 | + /// @return The portal shell of the child |
| 66 | + PortalShellBase& connect( |
| 67 | + const BlueprintOptions& options, const GeometryContext& gctx, |
| 68 | + const Logger& logger = Acts::getDummyLogger()) override; |
| 69 | + |
| 70 | + /// This method participates in the geometry construction. |
| 71 | + /// It applies the configured tags to the (now final) portals of the captured |
| 72 | + /// shell, then passes the call through to its only child. |
| 73 | + /// @param options The global blueprint options |
| 74 | + /// @param gctx The geometry context (nominal usually) |
| 75 | + /// @param parent The parent volume |
| 76 | + /// @param logger The logger to use during construction |
| 77 | + void finalize(const BlueprintOptions& options, const GeometryContext& gctx, |
| 78 | + TrackingVolume& parent, const Logger& logger) override; |
| 79 | + |
| 80 | + /// Tag a cylinder face with a string label. |
| 81 | + /// @note This method can be called multiple times to tag different faces. |
| 82 | + /// @param face The face of the cylinder to tag |
| 83 | + /// @param label The tag to assign to the portal at that face |
| 84 | + /// @return The portal designator node |
| 85 | + /// @note If this node has previously been configured with a different volume |
| 86 | + /// shape, this will throw an exception during geometry construction. |
| 87 | + PortalDesignatorBlueprintNode& tagFace(CylinderVolumeBounds::Face face, |
| 88 | + const std::string& label); |
| 89 | + |
| 90 | + /// Tag a cuboid face with a string label. |
| 91 | + /// @note This method can be called multiple times to tag different faces. |
| 92 | + /// @param face The face of the cuboid to tag |
| 93 | + /// @param label The tag to assign to the portal at that face |
| 94 | + /// @return The portal designator node |
| 95 | + /// @note If this node has previously been configured with a different volume |
| 96 | + /// shape, this will throw an exception during geometry construction. |
| 97 | + PortalDesignatorBlueprintNode& tagFace(CuboidVolumeBounds::Face face, |
| 98 | + const std::string& label); |
| 99 | + |
| 100 | + private: |
| 101 | + /// @copydoc BlueprintNode::addToGraphviz |
| 102 | + void addToGraphviz(std::ostream& os) const override; |
| 103 | + |
| 104 | + detail::PortalDesignatorBlueprintNodeImpl& impl(); |
| 105 | + const detail::PortalDesignatorBlueprintNodeImpl& impl() const; |
| 106 | + |
| 107 | + std::unique_ptr<detail::PortalDesignatorBlueprintNodeImpl> m_impl; |
| 108 | +}; |
| 109 | + |
| 110 | +} // namespace Experimental |
| 111 | +} // namespace Acts |
0 commit comments