ATLAS Offline Software
Loading...
Searching...
No Matches
GeoVisitVolumes.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
4 */
13
14
15#ifndef GEOMODELUTILITIES_GEOVISITVOLUMES_H
16#define GEOMODELUTILITIES_GEOVISITVOLUMES_H
17
20
21#include "GeoModelKernel/GeoNodeAction.h"
22#include "GeoModelKernel/GeoDefinitions.h"
23#include <vector>
24#include <variant>
25
26
27class GeoVPhysVol;
28class GeoTransform;
29class GeoVAlignmentStore;
30
31
38{
39public:
40 virtual ~IGeoVisitVolumesAction() = default;
41 virtual void operator() (GeoNodeAction& action,
42 int id,
43 const std::string& name,
44 const GeoVPhysVol* volume,
45 const GeoTrf::Transform3D& transform,
46 const GeoTrf::Transform3D& defTransform) = 0;
47};
48
49
57{
58public:
59 virtual ~IGeoVisitVolumesNoXformAction() = default;
60 virtual void operator() (GeoNodeAction& action,
61 int id,
62 const std::string& name,
63 const GeoVPhysVol* volume) = 0;
64};
65
66
76class GeoVisitVolumes : public GeoNodeAction
77{
78public:
80 GeoVisitVolumes (IGeoVisitVolumesAction& action, int depthLimit = 1);
81
83 GeoVisitVolumes (IGeoVisitVolumesNoXformAction& action, int depthLimit = 1);
84
86 virtual void handleTransform (const GeoTransform *xform) override;
87
89 virtual void handlePhysVol (const GeoPhysVol *vol) override;
90
92 virtual void handleFullPhysVol (const GeoFullPhysVol *vol) override;
93
95 virtual void handleNameTag (const GeoNameTag *nameTag) override;
96
98 virtual void handleSerialDenominator (const GeoSerialDenominator *sD) override;
99
101 virtual void handleSerialTransformer (const GeoSerialTransformer *sT) override;
102
104 virtual void handleIdentifierTag (const GeoIdentifierTag *idTag) override;
105
107 virtual void handleSerialIdentifier(const GeoSerialIdentifier *sI) override;
108
109
110private:
111 GeoVisitVolumes (const GeoVisitVolumes &right) = delete;
112 GeoVisitVolumes & operator=(const GeoVisitVolumes &right) = delete;
113
114 void handleVol (const GeoVPhysVol *vol);
115
117 std::variant<IGeoVisitVolumesAction*,
119
121 const GeoNameTag *m_nameTag;
122
124 const GeoSerialDenominator *m_serialDenominator;
125
127 const GeoIdentifierTag *m_idTag;
128
130 std::vector<const GeoTransform *> m_pendingTransformList;
131
132 const GeoSerialIdentifier *m_serialIdentifier;
133};
134
135
139template <class FUNCTION>
142{
143public:
144 GeoVisitVolumesAction (FUNCTION f) : m_f (f) {}
145 virtual void operator() (GeoNodeAction& /*action*/,
146 int id,
147 const std::string& name,
148 const GeoVPhysVol* volume,
149 const GeoTrf::Transform3D& transform,
150 const GeoTrf::Transform3D& defTransform) override
151 {
152 m_f (id, name, volume, transform, defTransform);
153 }
154 FUNCTION m_f;
155};
156
157
163template <class FUNCTION>
166{
167public:
168 GeoVisitVolumesNoXformAction (FUNCTION f) : m_f (f) {}
169 virtual void operator() (GeoNodeAction& /*action*/,
170 int id,
171 const std::string& name,
172 const GeoVPhysVol* volume) override
173 {
174 m_f (id, name, volume);
175 }
176 FUNCTION m_f;
177};
178
179
180
184template <class FUNCTION>
185void geoVisitVolumes (FUNCTION f, const GeoGraphNode* node, int depthLimit = 1)
186{
188 GeoVisitVolumes visitor (act, depthLimit);
189 node->exec (&visitor);
190}
191
192
198template <class FUNCTION>
199void geoVisitVolumesNoXform (FUNCTION f, const GeoGraphNode* node, int depthLimit = 1)
200{
202 GeoVisitVolumes visitor (act, depthLimit);
203 node->exec (&visitor);
204}
205
206
218typedef std::vector<std::pair<const GeoVPhysVol*, GeoTrf::Transform3D> >
220GeoVolumeVec_t geoGetVolumes (const GeoGraphNode* node,
221 int depthLimit = 1,
222 int sizeHint = 20);
223
224
235std::vector<const GeoVPhysVol*>
236geoGetVolumesNoXform (const GeoGraphNode* node,
237 int depthLimit = 1,
238 int sizeHint = 20);
239
240
241#endif // not GEOMODELUTILITIES_GEOVISITVOLUMES_H
GeoVolumeVec_t geoGetVolumes(const GeoGraphNode *node, int depthLimit=1, int sizeHint=20)
Return the child volumes and associated transforms.
std::vector< const GeoVPhysVol * > geoGetVolumesNoXform(const GeoGraphNode *node, int depthLimit=1, int sizeHint=20)
Return the child volumes.
void geoVisitVolumesNoXform(FUNCTION f, const GeoGraphNode *node, int depthLimit=1)
Template helper for running the visitor.
std::vector< std::pair< const GeoVPhysVol *, GeoTrf::Transform3D > > GeoVolumeVec_t
Return the child volumes and associated transforms.
void geoVisitVolumes(FUNCTION f, const GeoGraphNode *node, int depthLimit=1)
Template helper for running the visitor.
Callback object calling a templated functional.
virtual void operator()(GeoNodeAction &, int id, const std::string &name, const GeoVPhysVol *volume, const GeoTrf::Transform3D &transform, const GeoTrf::Transform3D &defTransform) override
GeoVisitVolumesAction(FUNCTION f)
Callback object calling a templated functional.
virtual void operator()(GeoNodeAction &, int id, const std::string &name, const GeoVPhysVol *volume) override
Visitor to process all volumes under a GeoModel node.
virtual void handleNameTag(const GeoNameTag *nameTag) override
Handles a Name Tag.
virtual void handleSerialTransformer(const GeoSerialTransformer *sT) override
Handles a Serial Transformer.
std::vector< const GeoTransform * > m_pendingTransformList
List of Pending Transformations.
virtual void handlePhysVol(const GeoPhysVol *vol) override
Handles a physical volume.
GeoVisitVolumes(IGeoVisitVolumesAction &action, int depthLimit=1)
Initialize to visit volumes keeping track of transformations.
const GeoIdentifierTag * m_idTag
A pointer to an identifier tag. If the volume is identified.
virtual void handleTransform(const GeoTransform *xform) override
Handles a Transform.
const GeoNameTag * m_nameTag
A pointer to a name tag. If the volume is named.
const GeoSerialDenominator * m_serialDenominator
A pointer to a serial denominator. If one exists.
const GeoSerialIdentifier * m_serialIdentifier
std::variant< IGeoVisitVolumesAction *, IGeoVisitVolumesNoXformAction * > m_action
Callback.
virtual void handleIdentifierTag(const GeoIdentifierTag *idTag) override
Handles an Identifier Tag.
virtual void handleSerialDenominator(const GeoSerialDenominator *sD) override
Handles a Serial Denominator.
virtual void handleFullPhysVol(const GeoFullPhysVol *vol) override
Handles a physical volume.
GeoVisitVolumes(const GeoVisitVolumes &right)=delete
virtual void handleSerialIdentifier(const GeoSerialIdentifier *sI) override
Handles an Serial Identifier.
GeoVisitVolumes & operator=(const GeoVisitVolumes &right)=delete
void handleVol(const GeoVPhysVol *vol)
Define a simple callback for each volume found.
virtual void operator()(GeoNodeAction &action, int id, const std::string &name, const GeoVPhysVol *volume, const GeoTrf::Transform3D &transform, const GeoTrf::Transform3D &defTransform)=0
virtual ~IGeoVisitVolumesAction()=default
Define a simple callback for each volume found, without keeping track of geometrical transforms.
virtual void operator()(GeoNodeAction &action, int id, const std::string &name, const GeoVPhysVol *volume)=0
virtual ~IGeoVisitVolumesNoXformAction()=default
Definition node.h:24