ATLAS Offline Software
Loading...
Searching...
No Matches
SbPolyhedrizeAction Class Reference

#include <SbPolyhedrizeAction.h>

Inheritance diagram for SbPolyhedrizeAction:
Collaboration diagram for SbPolyhedrizeAction:

Public Member Functions

 SbPolyhedrizeAction ()
virtual ~SbPolyhedrizeAction ()
virtual void handleShift (const GeoShapeShift *shift)
virtual void handleUnion (const GeoShapeUnion *unio)
virtual void handleIntersection (const GeoShapeIntersection *isect)
virtual void handleSubtraction (const GeoShapeSubtraction *subtract)
virtual void handleBox (const GeoBox *box)
virtual void handleCons (const GeoCons *cons)
virtual void handlePara (const GeoPara *para)
virtual void handlePcon (const GeoPcon *pcon)
virtual void handlePgon (const GeoPgon *pgon)
virtual void handleTrap (const GeoTrap *trap)
virtual void handleTrd (const GeoTrd *trd)
virtual void handleTube (const GeoTube *tube)
virtual void handleTubs (const GeoTubs *tubs)
virtual void handleSimplePolygonBrep (const GeoSimplePolygonBrep *brep)
virtual void handleTessellatedSolid (const GeoTessellatedSolid *tessellated)
virtual void handleGenericTrap (const GeoGenericTrap *gentrap)
SbPolyhedrongetPolyhedron ()

Private Member Functions

 SbPolyhedrizeAction (const SbPolyhedrizeAction &right)
const SbPolyhedrizeActionoperator= (const SbPolyhedrizeAction &right)

Private Attributes

std::unique_ptr< SbPolyhedronm_polyhedron

Detailed Description

Definition at line 17 of file SbPolyhedrizeAction.h.

Constructor & Destructor Documentation

◆ SbPolyhedrizeAction() [1/2]

SbPolyhedrizeAction::SbPolyhedrizeAction ( )

Definition at line 30 of file SbPolyhedrizeAction.cxx.

31 : m_polyhedron(nullptr)
32{
33 setDepthLimit(0);
34}
std::unique_ptr< SbPolyhedron > m_polyhedron

◆ ~SbPolyhedrizeAction()

SbPolyhedrizeAction::~SbPolyhedrizeAction ( )
virtual

Definition at line 37 of file SbPolyhedrizeAction.cxx.

38{
39
40}

◆ SbPolyhedrizeAction() [2/2]

SbPolyhedrizeAction::SbPolyhedrizeAction ( const SbPolyhedrizeAction & right)
private

Member Function Documentation

◆ getPolyhedron()

SbPolyhedron * SbPolyhedrizeAction::getPolyhedron ( )

Definition at line 280 of file SbPolyhedrizeAction.cxx.

281{
282 //transfer ownership via raw ptr
283 return m_polyhedron.release();
284}

◆ handleBox()

void SbPolyhedrizeAction::handleBox ( const GeoBox * box)
virtual

Definition at line 89 of file SbPolyhedrizeAction.cxx.

90{
91 m_polyhedron=std::make_unique<SbPolyhedronBox> (box->getXHalfLength(),
92 box->getYHalfLength(),
93 box->getZHalfLength());
94}

◆ handleCons()

void SbPolyhedrizeAction::handleCons ( const GeoCons * cons)
virtual

Definition at line 96 of file SbPolyhedrizeAction.cxx.

97{
98 m_polyhedron = std::make_unique<SbPolyhedronCons> (cons->getRMin1(),
99 cons->getRMax1(),
100 cons->getRMin2(),
101 cons->getRMax2(),
102 cons->getDZ(),
103 cons->getSPhi(),
104 cons->getDPhi());
105}

◆ handleGenericTrap()

void SbPolyhedrizeAction::handleGenericTrap ( const GeoGenericTrap * gentrap)
virtual

Definition at line 271 of file SbPolyhedrizeAction.cxx.

272{
273 std::vector<std::pair<double,double> > vertices;
274 vertices.reserve(8);
275 for(size_t i=0; i<8; ++i)
276 vertices.push_back(std::pair<double,double>(gentrap->getVertices()[i].x(),gentrap->getVertices()[i].y()));
277 m_polyhedron = std::make_unique<SbPolyhedronGenericTrap>(gentrap->getZHalfLength(),vertices);
278}

◆ handleIntersection()

void SbPolyhedrizeAction::handleIntersection ( const GeoShapeIntersection * isect)
virtual

Definition at line 73 of file SbPolyhedrizeAction.cxx.

74{
75 SbPolyhedrizeAction auxA,auxB;
76 isect->getOpA()->exec(&auxA);
77 isect->getOpB()->exec(&auxB);
78 m_polyhedron=std::make_unique<SbPolyhedron>(auxA.getPolyhedron()->intersect(*auxB.getPolyhedron()));
79}
SbPolyhedron * getPolyhedron()
SbPolyhedron intersect(const SbPolyhedron &p) const

◆ handlePara()

void SbPolyhedrizeAction::handlePara ( const GeoPara * para)
virtual

Definition at line 107 of file SbPolyhedrizeAction.cxx.

108{
109 m_polyhedron=std::make_unique<SbPolyhedronPara>(para->getXHalfLength(),
110 para->getYHalfLength(),
111 para->getZHalfLength(),
112 para->getAlpha(),
113 para->getTheta(),
114 para->getPhi());
115}

◆ handlePcon()

void SbPolyhedrizeAction::handlePcon ( const GeoPcon * pcon)
virtual

Definition at line 117 of file SbPolyhedrizeAction.cxx.

118{
119 double *z = new double[pcon->getNPlanes ()];
120 double *rmn = new double[pcon->getNPlanes ()];
121 double *rmx = new double[pcon->getNPlanes ()];
122
123 for (unsigned s = 0; s < pcon->getNPlanes (); s++) {
124 z[s] = pcon->getZPlane (s);
125 rmn[s] = pcon->getRMinPlane (s);
126 rmx[s] = pcon->getRMaxPlane (s);
127 }
128 m_polyhedron = std::make_unique<SbPolyhedronPcon> (pcon->getSPhi(), pcon->getDPhi(), pcon->getNPlanes (), z, rmn, rmx);
129
130 delete[]z;
131 delete[]rmn;
132 delete[]rmx;
133}
#define z

◆ handlePgon()

void SbPolyhedrizeAction::handlePgon ( const GeoPgon * pgon)
virtual

Definition at line 135 of file SbPolyhedrizeAction.cxx.

136{
137 double *z = new double[pgon->getNPlanes ()];
138 double *rmn = new double[pgon->getNPlanes ()];
139 double *rmx = new double[pgon->getNPlanes ()];
140
141 for (unsigned s = 0; s < pgon->getNPlanes (); s++) {
142 z[s] = pgon->getZPlane (s);
143 rmn[s] = pgon->getRMinPlane (s);
144 rmx[s] = pgon->getRMaxPlane (s);
145 }
146 m_polyhedron = std::make_unique<SbPolyhedronPgon> (pgon->getSPhi(), pgon->getDPhi(), pgon->getNSides(), pgon->getNPlanes (), z, rmn, rmx);
147
148 delete[]z;
149 delete[]rmn;
150 delete[]rmx;
151}

◆ handleShift()

void SbPolyhedrizeAction::handleShift ( const GeoShapeShift * shift)
virtual

Definition at line 42 of file SbPolyhedrizeAction.cxx.

43{
44 shift->getOp()->exec(this);
45 GeoTrf::RotationMatrix3D rotation=shift->getX().rotation();
46 GeoTrf::Vector3D translation = shift->getX().translation();
47
48 // rbianchi - 14.12.2012
49// SbVec3f trx(translation.x(),translation.y(),translation.z());
50// SbRotation rot(SbMatrix(rotation.xx(),rotation.yx(),rotation.zx(),0,
51// rotation.xy(),rotation.yy(),rotation.zy(),0,
52// rotation.xz(),rotation.yz(),rotation.zz(),0,
53// 0,0,0,1));
54 SbVec3d trx(translation.x(),translation.y(),translation.z());
55 #include <VP1HEPVis/SbRotation.h> //using doubles instead of floats.
56 HEPVis::SbRotation rot(rotation(0,0),rotation(1,0),rotation(2,0),0,
57 rotation(0,1),rotation(1,1),rotation(2,1),0,
58 rotation(0,2),rotation(1,2),rotation(2,2),0,
59 0,0,0,1);
60 //---
61
62 m_polyhedron->Transform (rot, trx);
63}

◆ handleSimplePolygonBrep()

void SbPolyhedrizeAction::handleSimplePolygonBrep ( const GeoSimplePolygonBrep * brep)
virtual

Definition at line 189 of file SbPolyhedrizeAction.cxx.

190{
191 double dz = brep->getDZ();
192 std::vector<double> x, y;
193 for(unsigned int i=0; i<brep->getNVertices(); i++)
194 {
195 x.push_back(brep->getXVertex(i));
196 y.push_back(brep->getYVertex(i));
197 }
198
199 m_polyhedron = std::make_unique<SbPolyhedronPolygonXSect>(x,y,dz);
200}
#define y
#define x

◆ handleSubtraction()

void SbPolyhedrizeAction::handleSubtraction ( const GeoShapeSubtraction * subtract)
virtual

Definition at line 81 of file SbPolyhedrizeAction.cxx.

82{
83 SbPolyhedrizeAction auxA,auxB;
84 subtract->getOpA()->exec(&auxA);
85 subtract->getOpB()->exec(&auxB);
86 m_polyhedron=std::make_unique<SbPolyhedron>(auxA.getPolyhedron()->subtract(*auxB.getPolyhedron()));
87}
SbPolyhedron subtract(const SbPolyhedron &p) const

◆ handleTessellatedSolid()

void SbPolyhedrizeAction::handleTessellatedSolid ( const GeoTessellatedSolid * tessellated)
virtual

Definition at line 202 of file SbPolyhedrizeAction.cxx.

203{
204 // ______ Perform actions a la SetSolidClosed ________
205 double vertTolerance = 1E-15; // kCarTolerance ??
206 std::vector<GeoFacetVertex> vertexList;
207 std::map<GeoFacet*,std::vector<size_t> > facetVertIndInSolid; // Vacet vertex indices in the vertexList
208
209 // Loop over facets in the solid
210 for(size_t facetIndInSolid = 0; facetIndInSolid<tessellated->getNumberOfFacets(); ++facetIndInSolid) {
211 GeoFacet* facet = tessellated->getFacet(facetIndInSolid);
212
213 facetVertIndInSolid[facet] = std::vector<size_t>();
214 std::vector<size_t>& current = facetVertIndInSolid[facet];
215 if(facet->getNumberOfVertices()==3)
216 current.resize(3,0);
217 else
218 current.resize(4,0);
219
220 size_t vertexListSize = vertexList.size();
221 GeoFacetVertex vertex(0.,0.,0.);
222
223 // Loop over vertices in the current facet
224 for(size_t vertexIndInFacet=0; vertexIndInFacet<facet->getNumberOfVertices(); ++vertexIndInFacet) {
225 vertex = facet->getVertex(vertexIndInFacet);
226
227 // Check if we already have this vertex in our vertexList
228 bool found = false;
229 size_t j=0;
230 while(j<vertexListSize && !found) {
231 GeoFacetVertex vertexToCheck = vertexList[j];
232 found = (vertexToCheck-vertex).mag() < vertTolerance;
233 if(!found) j++;
234 }
235
236 if(found) {
237 current[vertexIndInFacet] = j;
238 }
239 else {
240 vertexList.push_back(vertex);
241 current[vertexIndInFacet] = vertexList.size()-1;
242 }
243 }
244 }
245
246 // ______ Create Polyhedron itself ______
247 SbPolyhedronArbitrary* polyhedron= new SbPolyhedronArbitrary(vertexList.size(),tessellated->getNumberOfFacets());
248
249 // add vertices from the list
250 for(size_t vertexInd=0; vertexInd<vertexList.size(); ++vertexInd) {
251 GeoFacetVertex vertex = vertexList[vertexInd];
252 polyhedron->AddVertex(vertex.x(),vertex.y(),vertex.z());
253 }
254
255 // add facets
256 for(size_t facetIndInSolid = 0; facetIndInSolid<tessellated->getNumberOfFacets(); ++facetIndInSolid) {
257 GeoFacet* facet = tessellated->getFacet(facetIndInSolid);
258 std::vector<size_t>& current = facetVertIndInSolid[facet];
259
260 size_t v[4];
261 for (size_t j=0; j<4; j++)
262 v[j] = (j<current.size() ? current[j]+1 : 0);
263
264 polyhedron->AddFacet(v[0],v[1],v[2],v[3]);
265 }
266
267 polyhedron->Finalize();
268 m_polyhedron.reset(polyhedron);
269}
Scalar mag() const
mag method
void AddFacet(const int iv1, const int iv2, const int iv3, const int iv4=0)
void AddVertex(const double v1, const double v2, const double v3)

◆ handleTrap()

void SbPolyhedrizeAction::handleTrap ( const GeoTrap * trap)
virtual

Definition at line 153 of file SbPolyhedrizeAction.cxx.

154{
155 m_polyhedron = std::make_unique<SbPolyhedronTrap> (trap->getZHalfLength(),
156 trap->getTheta(),
157 trap->getPhi(),
158 trap->getDydzn(),
159 trap->getDxdyndzn(),
160 trap->getDxdypdzn(), 0,
161 trap->getDydzp(),
162 trap->getDxdyndzp(),
163 trap->getDxdypdzp(),0);
164}

◆ handleTrd()

void SbPolyhedrizeAction::handleTrd ( const GeoTrd * trd)
virtual

Definition at line 166 of file SbPolyhedrizeAction.cxx.

167{
168 m_polyhedron = std::make_unique<SbPolyhedronTrd2> (trd->getXHalfLength1(),
169 trd->getXHalfLength2(),
170 trd->getYHalfLength1(),
171 trd->getYHalfLength2(),
172 trd->getZHalfLength());
173}

◆ handleTube()

void SbPolyhedrizeAction::handleTube ( const GeoTube * tube)
virtual

Definition at line 175 of file SbPolyhedrizeAction.cxx.

176{
177 m_polyhedron = std::make_unique<SbPolyhedronTube> (tube->getRMin(),tube->getRMax(),tube->getZHalfLength());
178}

◆ handleTubs()

void SbPolyhedrizeAction::handleTubs ( const GeoTubs * tubs)
virtual

Definition at line 180 of file SbPolyhedrizeAction.cxx.

181{
182 m_polyhedron= std::make_unique<SbPolyhedronTubs> (tubs->getRMin(),
183 tubs->getRMax(),
184 tubs->getZHalfLength(),
185 tubs->getSPhi(),
186 tubs->getDPhi());
187}

◆ handleUnion()

void SbPolyhedrizeAction::handleUnion ( const GeoShapeUnion * unio)
virtual

Definition at line 65 of file SbPolyhedrizeAction.cxx.

66{
67 SbPolyhedrizeAction auxA,auxB;
68 unio->getOpA()->exec(&auxA);
69 unio->getOpB()->exec(&auxB);
70 m_polyhedron = std::make_unique<SbPolyhedron>(auxA.getPolyhedron()->add(*auxB.getPolyhedron()));
71}
SbPolyhedron add(const SbPolyhedron &p) const

◆ operator=()

const SbPolyhedrizeAction & SbPolyhedrizeAction::operator= ( const SbPolyhedrizeAction & right)
private

Member Data Documentation

◆ m_polyhedron

std::unique_ptr<SbPolyhedron> SbPolyhedrizeAction::m_polyhedron
private

Definition at line 67 of file SbPolyhedrizeAction.h.


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