ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::SubtractedVolumeBounds Class Referencefinal

Bounds for a generic subtracted volume, the decomposeToSurfaces method creates a vector of n surfaces (n1+n2-n_subtracted): More...

#include <SubtractedVolumeBounds.h>

Inheritance diagram for Trk::SubtractedVolumeBounds:
Collaboration diagram for Trk::SubtractedVolumeBounds:

Public Member Functions

 SubtractedVolumeBounds ()
 Default Constructor.
 SubtractedVolumeBounds (std::unique_ptr< Volume > outerVol, std::unique_ptr< Volume > innerVol)
 Constructor - the box boundaries.
 SubtractedVolumeBounds (const SubtractedVolumeBounds &bobo)
 Copy Constructor.
virtual ~SubtractedVolumeBounds ()
 Destructor.
SubtractedVolumeBounds & operator= (const SubtractedVolumeBounds &bobo)
 Assignment operator.
SubtractedVolumeBounds * clone () const override final
 Virtual constructor.
bool inside (const Amg::Vector3D &, double tol=0.) const override final
 This method checks if position in the 3D volume frame is inside the cylinder.
virtual std::vector< std::unique_ptr< Trk::Surface > > decomposeToSurfaces (const Amg::Transform3D &transform) override final
 Method to decompose the Bounds into boundarySurfaces.
ObjectAccessor boundarySurfaceAccessor (const Amg::Vector3D &gp, const Amg::Vector3D &dir, bool forceInside=false) const override final
 Provide accessor for BoundarySurfaces.
const Volume * outer () const
 This method returns the outer Volume.
Volume * outer ()
const Volume * inner () const
 This method returns the inner Volume.
Volume * inner ()
const std::vector< bool > & boundsOrientation () const
 This method returns bounds orientation.
MsgStream & dump (MsgStream &sl) const override
 Output Method for MsgStream.
std::ostream & dump (std::ostream &sl) const override final
 Output Method for std::ostream.

Static Private Member Functions

static Trk::Volume * createSubtractedVolume (const Amg::Transform3D &transf, Trk::Volume *subtrVol)

Private Attributes

std::unique_ptr< Volume > m_outer {}
std::unique_ptr< Volume > m_inner {}
EightObjectsAccessor m_objectAccessor {}
 There's only one single object Acessor for the moment has to be implemented if Subtracteds are used more widely.
std::vector< bool > m_boundsOrientation {}

Detailed Description

Bounds for a generic subtracted volume, the decomposeToSurfaces method creates a vector of n surfaces (n1+n2-n_subtracted):

BoundarySurfaceFace [index]: [n1] surfaces from 'outer' volume [n1+n2-n_subtr] remaining surfaces (after subtraction) from 'inner' volume

Author
Sarka.nosp@m..Tod.nosp@m.orova.nosp@m.@cer.nosp@m.n.ch

Definition at line 40 of file SubtractedVolumeBounds.h.

Constructor & Destructor Documentation

◆ SubtractedVolumeBounds() [1/3]

Trk::SubtractedVolumeBounds::SubtractedVolumeBounds ( )
default

Default Constructor.

◆ SubtractedVolumeBounds() [2/3]

Trk::SubtractedVolumeBounds::SubtractedVolumeBounds ( std::unique_ptr< Volume > outerVol,
std::unique_ptr< Volume > innerVol )

Constructor - the box boundaries.

Definition at line 35 of file SubtractedVolumeBounds.cxx.

36 : VolumeBounds()
37 , m_outer(std::move(vol1))
38 , m_inner(std::move(vol2))
41{}
EightObjectsAccessor m_objectAccessor
There's only one single object Acessor for the moment has to be implemented if Subtracteds are used m...
std::unique_ptr< Volume > m_inner
std::unique_ptr< Volume > m_outer
std::vector< bool > m_boundsOrientation
VolumeBounds()
Default Constructor.

◆ SubtractedVolumeBounds() [3/3]

Trk::SubtractedVolumeBounds::SubtractedVolumeBounds ( const SubtractedVolumeBounds & bobo)

Copy Constructor.

Definition at line 43 of file SubtractedVolumeBounds.cxx.

45 : VolumeBounds()
46 , m_outer{bobo.m_outer->clone()}
47 , m_inner{bobo.m_inner->clone()}
48 , m_objectAccessor(bobo.m_objectAccessor)
49 , m_boundsOrientation(bobo.m_boundsOrientation)
50{}

◆ ~SubtractedVolumeBounds()

Trk::SubtractedVolumeBounds::~SubtractedVolumeBounds ( )
virtualdefault

Destructor.

Member Function Documentation

◆ boundarySurfaceAccessor()

ObjectAccessor Trk::SubtractedVolumeBounds::boundarySurfaceAccessor ( const Amg::Vector3D & gp,
const Amg::Vector3D & dir,
bool forceInside = false ) const
inlinefinaloverridevirtual

Provide accessor for BoundarySurfaces.

Implements Trk::VolumeBounds.

Definition at line 117 of file SubtractedVolumeBounds.h.

118 {
119 return Trk::ObjectAccessor(m_objectAccessor);
120}

◆ boundsOrientation()

const std::vector< bool > & Trk::SubtractedVolumeBounds::boundsOrientation ( ) const
inline

This method returns bounds orientation.

Definition at line 122 of file SubtractedVolumeBounds.h.

122 {
123 return (m_boundsOrientation);
124}

◆ clone()

SubtractedVolumeBounds * Trk::SubtractedVolumeBounds::clone ( ) const
inlinefinaloverridevirtual

Virtual constructor.

Implements Trk::VolumeBounds.

Definition at line 102 of file SubtractedVolumeBounds.h.

102 {
103 return new SubtractedVolumeBounds(*this);
104}
SubtractedVolumeBounds()
Default Constructor.

◆ createSubtractedVolume()

Trk::Volume * Trk::SubtractedVolumeBounds::createSubtractedVolume ( const Amg::Transform3D & transf,
Trk::Volume * subtrVol )
staticprivate

Definition at line 307 of file SubtractedVolumeBounds.cxx.

310{
311 if (!subtrVol){
312 return nullptr;
313 }
314 return new Trk::Volume(*subtrVol, transf);
315}

◆ decomposeToSurfaces()

std::vector< std::unique_ptr< Trk::Surface > > Trk::SubtractedVolumeBounds::decomposeToSurfaces ( const Amg::Transform3D & transform)
finaloverridevirtual

Method to decompose the Bounds into boundarySurfaces.

Implements Trk::VolumeBounds.

Definition at line 67 of file SubtractedVolumeBounds.cxx.

68 {
69 // double tol=0.001;
70 // get surfaces for outer boundaries
71 std::vector<std::unique_ptr<Trk::Surface>> outerSurfaces =
72 m_outer->volumeBounds().decomposeToSurfaces(transf * m_outer->transform());
73 // get surfaces for inner boundaries
74 std::vector<std::unique_ptr<Trk::Surface>> innerSurfaces =
75 m_inner->volumeBounds().decomposeToSurfaces(transf * m_inner->transform());
76 std::vector<unsigned int> subtrInner;
77
78
79 auto retsf = std::vector<std::unique_ptr<Trk::Surface>>();
80
81 unsigned int nSurf = outerSurfaces.size() + innerSurfaces.size();
82 m_boundsOrientation.resize(nSurf);
83
84 const Trk::CylinderVolumeBounds* cylVol = dynamic_cast<const Trk::CylinderVolumeBounds*>(&(m_outer->volumeBounds()));
85 const Trk::SimplePolygonBrepVolumeBounds* spbVol = dynamic_cast<const Trk::SimplePolygonBrepVolumeBounds*>(&(m_outer->volumeBounds()));
86 const Trk::CombinedVolumeBounds* comVol = dynamic_cast<const Trk::CombinedVolumeBounds*>(&(m_outer->volumeBounds()));
87 const Trk::SubtractedVolumeBounds* subVol = dynamic_cast<const Trk::SubtractedVolumeBounds*>(&(m_outer->volumeBounds()));
88
89 // loop over 'outer' boundary surfaces; modified by subtracted volume
90 for (unsigned int out = 0; out < outerSurfaces.size(); out++) {
91 const SubtractedPlaneSurface* splo = dynamic_cast<const SubtractedPlaneSurface*>(outerSurfaces[out].get());
92 const PlaneSurface* plo = dynamic_cast<const PlaneSurface*>(outerSurfaces[out].get());
93 const SubtractedCylinderSurface* sclo = dynamic_cast<const SubtractedCylinderSurface*>(outerSurfaces[out].get());
94 const CylinderSurface* clo = dynamic_cast<const CylinderSurface*>(outerSurfaces[out].get());
95 const DiscSurface* dlo = dynamic_cast<const DiscSurface*>(outerSurfaces[out].get());
96
97 if (!(splo || plo || sclo || clo || dlo)) {
98 throw std::runtime_error("Unhandled surface.");
99 }
100 // resolve bounds orientation : copy from combined/subtracted, swap inner
101 // cyl, swap bottom spb
102 if (comVol){
104 }
105 else if (subVol){
107 }
108 else if (cylVol && clo && out == 3){
109 m_boundsOrientation[out] = false;
110 }
111 else if (spbVol && out == 0){
112 m_boundsOrientation[out] = false;
113 }
114 else{
115 m_boundsOrientation[out] = true;
116 }
117 //
118 auto innerSub = std::unique_ptr<Trk::Volume>(createSubtractedVolume(
119 outerSurfaces[out]->transform().inverse() * transf, m_inner.get()));
120
121 if (splo || sclo) { // multiple subtraction
122 const Trk::AreaExcluder* vEx;
123 bool shared = false;
124 if (splo) {
125 vEx = splo->subtractedVolume();
126 shared = splo->shared();
127 }
128 if (sclo) {
129 vEx = sclo->subtractedVolume();
130 shared = sclo->shared();
131 }
132 const Trk::VolumeExcluder* volExcl = dynamic_cast<const Trk::VolumeExcluder*>(vEx);
133 if (!volExcl){
134 throw std::logic_error("Not a VolumeExcluder");
135 }
136
137 auto outerSub = std::make_unique<Trk::Volume>(*volExcl->volume());
138 std::unique_ptr<Trk::Volume> comb_sub;
139 if (!shared){
140 comb_sub = std::make_unique<Trk::Volume>(
141 nullptr,
142 std::make_shared<Trk::CombinedVolumeBounds>(std::move(innerSub), std::move(outerSub), false));
143 } else {
144 comb_sub = std::make_unique<Trk::Volume>(
145 nullptr,
146 std::make_shared<Trk::SubtractedVolumeBounds>(std::move(outerSub), std::move(innerSub)));
147 }
148 auto volEx = std::make_shared<const Trk::VolumeExcluder>(std::move(comb_sub));
149 if (splo){
150 retsf.push_back(std::make_unique<Trk::SubtractedPlaneSurface>(*splo, std::move(volEx), shared));
151 }
152 else if (sclo){
153 retsf.push_back(
154 std::make_unique<Trk::SubtractedCylinderSurface>(*sclo, std::move(volEx), shared));
155 }
156 } else {
157 auto volEx = std::make_shared<const Trk::VolumeExcluder>(std::move(innerSub));
158 if (plo){
159 retsf.push_back(std::make_unique<Trk::SubtractedPlaneSurface>(*plo, std::move(volEx), false));
160 }
161 else if (clo){
162 retsf.push_back(std::make_unique<Trk::SubtractedCylinderSurface>(*clo, std::move(volEx), false));
163 }
164 else if (dlo) {
165 // turn disc into ellipse for simplification
166 const DiscBounds* db = dynamic_cast<const DiscBounds*>(&(dlo->bounds()));
167 if (!db){
168 throw std::logic_error("Not DiscBounds");
169 }
170 auto eb = std::make_shared<EllipseBounds>(db->rMin(), db->rMin(), db->rMax(), db->rMax(), db->halfPhiSector());
171 auto ploA = PlaneSurface(Amg::Transform3D(dlo->transform()), eb);
172 retsf.push_back(std::make_unique<Trk::SubtractedPlaneSurface>(ploA, std::move(volEx), false));
173 }
174 }
175 }
176
177 // loop over 'inner' boundary surfaces; include only if represent a new
178 // surface change: include allways otherwise orientation messed up bonus :
179 // solves 'double boundary' problem
180 cylVol = dynamic_cast<const Trk::CylinderVolumeBounds*>(&(m_inner->volumeBounds()));
181 spbVol = dynamic_cast<const Trk::SimplePolygonBrepVolumeBounds*>(&(m_inner->volumeBounds()));
182 comVol = dynamic_cast<const Trk::CombinedVolumeBounds*>(&(m_inner->volumeBounds()));
183 subVol = dynamic_cast<const Trk::SubtractedVolumeBounds*>(&(m_inner->volumeBounds()));
184 unsigned int nOut = outerSurfaces.size();
185
186 for (unsigned int in = 0; in < innerSurfaces.size(); in++) {
187 const SubtractedPlaneSurface* spli = dynamic_cast<const SubtractedPlaneSurface*>(innerSurfaces[in].get());
188 const PlaneSurface* pli = dynamic_cast<const PlaneSurface*>(innerSurfaces[in].get());
189 const SubtractedCylinderSurface* scli = dynamic_cast<const SubtractedCylinderSurface*>(innerSurfaces[in].get());
190 const CylinderSurface* cli = dynamic_cast<const CylinderSurface*>(innerSurfaces[in].get());
191 const DiscSurface* dli = dynamic_cast<const DiscSurface*>(innerSurfaces[in].get());
192 // resolve bounds orientation : copy from combined/subtracted, swap inner
193 // cyl, swap bottom spb, swap all
194 if (comVol){
195 m_boundsOrientation[nOut + in] = !comVol->boundsOrientation()[in];
196 }
197 else if (subVol){
198 m_boundsOrientation[nOut + in] = !subVol->boundsOrientation()[in];
199 }
200 else if (cylVol && cli && in == 3){
201 m_boundsOrientation[nOut + in] = true;
202 }
203 else if (spbVol && in == 0){
204 m_boundsOrientation[nOut + in] = true;
205 }
206 else{
207 m_boundsOrientation[nOut + in] = false;
208 }
209 //
210 auto outerSub = std::unique_ptr<Trk::Volume>(createSubtractedVolume(
211 innerSurfaces[in]->transform().inverse() * transf, m_outer.get()));
212
213 if (spli || scli) {
214 bool shared = false;
215 const Trk::AreaExcluder* vEx;
216 if (spli) {
217 vEx = spli->subtractedVolume();
218 shared = spli->shared();
219 }
220 if (scli) {
221 vEx = scli->subtractedVolume();
222 shared = scli->shared();
223 }
224 const Trk::VolumeExcluder* volExcl = dynamic_cast<const Trk::VolumeExcluder*>(vEx);
225 if (!volExcl){
226 throw std::logic_error("Not a VolumeExcluder");
227 }
228
229 auto innerSub = std::make_unique<Trk::Volume>(*volExcl->volume());
230 // combined volume
231 std::unique_ptr<Trk::Volume> comb_sub;
232 if (!shared){
233 comb_sub = std::make_unique<Trk::Volume>(
234 nullptr,
235 std::make_shared<Trk::SubtractedVolumeBounds>(std::move(outerSub), std::move(innerSub)));
236 }
237 else{
238 comb_sub = std::make_unique<Trk::Volume>(
239 nullptr,
240 std::make_shared<Trk::CombinedVolumeBounds>(std::move(innerSub), std::move(outerSub), true));
241 }
242 auto volEx = std::make_shared<const Trk::VolumeExcluder>(std::move(comb_sub));
243 if (spli){
244 retsf.push_back(std::make_unique<Trk::SubtractedPlaneSurface>(*spli, std::move(volEx), true));
245 }
246 else if (scli){
247 retsf.push_back(std::make_unique<Trk::SubtractedCylinderSurface>(*scli, std::move(volEx), true));
248 }
249
250 } else if (pli || cli) {
251 auto volEx = std::make_shared<const Trk::VolumeExcluder>(std::move(outerSub));
252 if (pli){
253 retsf.push_back(std::make_unique<Trk::SubtractedPlaneSurface>(*pli, std::move(volEx), true));
254 }
255 else if (cli){
256 retsf.push_back(std::make_unique<Trk::SubtractedCylinderSurface>(*cli, std::move(volEx), true));
257 }
258 } else if (dli) {
259 // turn disc into ellipse for simplification
260 const DiscBounds* db = dynamic_cast<const DiscBounds*>(&(dli->bounds()));
261 if (!db){
262 throw std::logic_error("Not DiscBounds");
263 }
264 auto eb = std::make_shared<EllipseBounds>(db->rMin(), db->rMin(), db->rMax(), db->rMax(), db->halfPhiSector());
265 PlaneSurface pla(Amg::Transform3D(dli->transform()), eb);
266 auto volEx = std::make_shared<const Trk::VolumeExcluder>(std::move(outerSub));
267 retsf.push_back(std::make_unique<Trk::SubtractedPlaneSurface>(pla, std::move(volEx), true));
268 } else {
269 throw std::runtime_error(
270 "Unhandled surface in "
271 "Trk::SubtractedVolumeBounds::decomposeToSurfaces.");
272 }
273 }
274
275 return retsf;
276}
const std::vector< bool > & boundsOrientation() const
This method returns bounds orientation.
const std::vector< bool > & boundsOrientation() const
This method returns bounds orientation.
static Trk::Volume * createSubtractedVolume(const Amg::Transform3D &transf, Trk::Volume *subtrVol)
const Volume * volume() const
Acces the subtracted volume.
Eigen::Affine3d Transform3D
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.

◆ dump() [1/2]

MsgStream & Trk::SubtractedVolumeBounds::dump ( MsgStream & sl) const
overridevirtual

Output Method for MsgStream.

Implements Trk::VolumeBounds.

Definition at line 281 of file SubtractedVolumeBounds.cxx.

282{
283 std::stringstream temp_sl;
284 temp_sl << std::setiosflags(std::ios::fixed);
285 temp_sl << std::setprecision(7);
286 temp_sl << "Trk::SubtractedVolumeBounds: outer,inner ";
287 sl << temp_sl.str();
288 std::as_const(*m_outer).volumeBounds().dump(sl);
289 std::as_const(*m_inner).volumeBounds().dump(sl);
290 return sl;
291}

◆ dump() [2/2]

std::ostream & Trk::SubtractedVolumeBounds::dump ( std::ostream & sl) const
finaloverridevirtual

Output Method for std::ostream.

Implements Trk::VolumeBounds.

Definition at line 294 of file SubtractedVolumeBounds.cxx.

295{
296 std::stringstream temp_sl;
297 temp_sl << std::setiosflags(std::ios::fixed);
298 temp_sl << std::setprecision(7);
299 temp_sl << "Trk::SubtractedVolumeBounds: outer,inner ";
300 sl << temp_sl.str();
301 std::as_const(*m_outer).volumeBounds().dump(sl);
302 std::as_const(*m_inner).volumeBounds().dump(sl);
303 return sl;
304}

◆ inner() [1/2]

Volume * Trk::SubtractedVolumeBounds::inner ( )
inline

Definition at line 115 of file SubtractedVolumeBounds.h.

115{ return m_inner.get(); }

◆ inner() [2/2]

const Volume * Trk::SubtractedVolumeBounds::inner ( ) const
inline

This method returns the inner Volume.

Definition at line 114 of file SubtractedVolumeBounds.h.

114{ return m_inner.get(); }

◆ inside()

bool Trk::SubtractedVolumeBounds::inside ( const Amg::Vector3D & pos,
double tol = 0. ) const
inlinefinaloverridevirtual

This method checks if position in the 3D volume frame is inside the cylinder.

Implements Trk::VolumeBounds.

Definition at line 106 of file SubtractedVolumeBounds.h.

107 {
108 return (m_outer->inside(pos, tol) && !m_inner->inside(pos, -tol));
109}

◆ operator=()

Trk::SubtractedVolumeBounds & Trk::SubtractedVolumeBounds::operator= ( const SubtractedVolumeBounds & bobo)

Assignment operator.

Definition at line 55 of file SubtractedVolumeBounds.cxx.

56{
57 if (this != &bobo) {
58 m_outer.reset(bobo.m_outer->clone());
59 m_inner.reset(bobo.m_inner->clone());
60 m_objectAccessor = bobo.m_objectAccessor;
61 m_boundsOrientation = bobo.m_boundsOrientation;
62 }
63 return *this;
64}

◆ outer() [1/2]

Volume * Trk::SubtractedVolumeBounds::outer ( )
inline

Definition at line 112 of file SubtractedVolumeBounds.h.

112{ return m_outer.get(); }

◆ outer() [2/2]

const Volume * Trk::SubtractedVolumeBounds::outer ( ) const
inline

This method returns the outer Volume.

Definition at line 111 of file SubtractedVolumeBounds.h.

111{ return m_outer.get(); }

Member Data Documentation

◆ m_boundsOrientation

std::vector<bool> Trk::SubtractedVolumeBounds::m_boundsOrientation {}
private

Definition at line 99 of file SubtractedVolumeBounds.h.

99{};

◆ m_inner

std::unique_ptr<Volume> Trk::SubtractedVolumeBounds::m_inner {}
private

Definition at line 95 of file SubtractedVolumeBounds.h.

95{};

◆ m_objectAccessor

EightObjectsAccessor Trk::SubtractedVolumeBounds::m_objectAccessor {}
private

There's only one single object Acessor for the moment has to be implemented if Subtracteds are used more widely.

Definition at line 98 of file SubtractedVolumeBounds.h.

98{};

◆ m_outer

std::unique_ptr<Volume> Trk::SubtractedVolumeBounds::m_outer {}
private

Definition at line 94 of file SubtractedVolumeBounds.h.

94{};

The documentation for this class was generated from the following files: