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

#include <SurfaceToSoNode.h>

Collaboration diagram for SurfaceToSoNode:

Public Member Functions

 SurfaceToSoNode ()
virtual ~SurfaceToSoNode ()
SoNode * translateSurface (const Trk::Surface &sf, const bool &simple=false) const
SoNode * translatePlaneSurface (const Trk::PlaneSurface &psf) const
SoNode * translateCylinderSurface (const Trk::CylinderSurface &csf) const
SoNode * translateDiscSurface (const Trk::DiscSurface &dsf) const
SoNode * translateStraightLineSurface (const Trk::StraightLineSurface &slsf, const bool &simple=false) const
SoNode * translatePerigeeSurface (const Trk::PerigeeSurface &persf) const

Static Public Attributes

static const double surfaceThickness = 0.1

Detailed Description

Definition at line 30 of file SurfaceToSoNode.h.

Constructor & Destructor Documentation

◆ SurfaceToSoNode()

SurfaceToSoNode::SurfaceToSoNode ( )

Definition at line 49 of file SurfaceToSoNode.cxx.

50{
53}
static void initClass()
static void initClass()
Class Initializer, required.
Definition SoTubs.cxx:63

◆ ~SurfaceToSoNode()

SurfaceToSoNode::~SurfaceToSoNode ( )
virtual

Definition at line 55 of file SurfaceToSoNode.cxx.

55{}

Member Function Documentation

◆ translateCylinderSurface()

SoNode * SurfaceToSoNode::translateCylinderSurface ( const Trk::CylinderSurface & csf) const

Definition at line 175 of file SurfaceToSoNode.cxx.

176{
177 //std::cout<<"translateCylinderSurface"<<std::endl;
178
179 double radius = csf.bounds().r();
180 double hlength = csf.bounds().halflengthZ();
181
182 SoTubs* cylinderSurface = new SoTubs();
183 (*cylinderSurface).pRMin = radius-0.25;
184 (*cylinderSurface).pRMax = radius+0.25;
185 (*cylinderSurface).pDz = hlength;
186
187 return cylinderSurface;
188
189}
virtual double r() const override final
This method returns the radius.
double halflengthZ() const
This method returns the halflengthZ.
virtual const CylinderBounds & bounds() const override final
This method returns the CylinderBounds by reference (NoBounds is not possible for cylinder)

◆ translateDiscSurface()

SoNode * SurfaceToSoNode::translateDiscSurface ( const Trk::DiscSurface & dsf) const

Definition at line 191 of file SurfaceToSoNode.cxx.

192{
193 //std::cout<<"translateDiscSurface"<<std::endl;
194 const Trk::DiscBounds* cdbo = dynamic_cast<const Trk::DiscBounds*>(&(dsf.bounds()));
195 if (cdbo){
196 double iradius = cdbo->rMin();
197 double oradius = cdbo->rMax();
198 double halfphisec = cdbo->halfPhiSector();
199
200 SoTubs* discSurface = new SoTubs();
201 (*discSurface).pRMin = iradius;
202 (*discSurface).pRMax = oradius;
203 (*discSurface).pDz = 0.25;
204
205 if (fabs(halfphisec-M_PI)>10e-5){
206 // sweep back the rotation as the sweepangle starts from x-axis
207 (*discSurface).pSPhi = -halfphisec;
208 (*discSurface).pDPhi = 2.* halfphisec;
209 }
210
211 return discSurface;
212 }
213 return 0;
214}
#define M_PI
double rMax() const
This method returns outer radius.
double rMin() const
This method returns inner radius.
double halfPhiSector() const
This method returns the halfPhiSector which is covered by the disc.
const SurfaceBounds & bounds() const override final
This method returns the bounds by reference.

◆ translatePerigeeSurface()

SoNode * SurfaceToSoNode::translatePerigeeSurface ( const Trk::PerigeeSurface & persf) const

Definition at line 243 of file SurfaceToSoNode.cxx.

244{
245 //TK: Why do we need depend on the input???? FIXME
246 //std::cout<<"translatePerigeeSurface"<<std::endl;
247 SoTubs* perigeeSurface = new SoTubs();
248 (*perigeeSurface).pRMin = 0.;
249 (*perigeeSurface).pRMax = 5.;
250 (*perigeeSurface).pDz = 4000.;
251 return perigeeSurface;
252}

◆ translatePlaneSurface()

SoNode * SurfaceToSoNode::translatePlaneSurface ( const Trk::PlaneSurface & psf) const

Definition at line 101 of file SurfaceToSoNode.cxx.

102{
103 const Trk::RectangleBounds* crecbo = dynamic_cast<const Trk::RectangleBounds*>(&(psf.bounds()));
104 if (crecbo){
105 SoGenericBox * gb = new SoGenericBox;
107 gb->drawEdgeLines.setValue(true);
108 return gb;
109 }
110
111 const Trk::TrapezoidBounds* ctrabo = dynamic_cast<const Trk::TrapezoidBounds*>(&(psf.bounds()));
112 if (ctrabo){
113 SoGenericBox * gb = new SoGenericBox;
114 const double hminphi = ctrabo->minHalflengthPhi();
115 const double hmaxphi = ctrabo->maxHalflengthPhi();
116 const double heta = ctrabo->halflengthEta();
117 gb->setParametersForTrapezoid( 0.5*surfaceThickness/*dz*/, 0/*theta*/, 0/*phi*/, heta/*dy1*/,
118 hminphi/*dx1*/, hmaxphi/*dx2*/, heta/*dy2*/, hminphi/*dx3*/,
119 hmaxphi/*dx4*/, 0/*alp1*/, 0/*alp2*/ );
120 gb->drawEdgeLines.setValue(true);
121 return gb;
122 }
123 const Trk::RotatedTrapezoidBounds* crottrabo = dynamic_cast<const Trk::RotatedTrapezoidBounds*>(&(psf.bounds()));
124 if (crottrabo){
125 SoGenericBox * gb = new SoGenericBox;
126 const double hminphi = crottrabo->minHalflengthY();
127 const double hmaxphi = crottrabo->maxHalflengthY();
128 const double heta = crottrabo->halflengthX();
129 gb->setParametersForTrapezoid( 0.5*surfaceThickness/*dz*/, 0/*theta*/, 0/*phi*/, heta/*dy1*/,
130 hminphi/*dx1*/, hmaxphi/*dx2*/, heta/*dy2*/, hminphi/*dx3*/,
131 hmaxphi/*dx4*/, 0/*alp1*/, 0/*alp2*/ );
132 gb->drawEdgeLines.setValue(true);
133 return gb;
134 }
135 const Trk::DiamondBounds* cdiabo = dynamic_cast<const Trk::DiamondBounds*>(&(psf.bounds()));
136 if (cdiabo){
137 double dz=0.25;
138 std::vector<double> x,y;
139 x.push_back(cdiabo->minHalflengthX());y.push_back( -2*cdiabo->halflengthY1());
140 x.push_back(cdiabo->medHalflengthX());y.push_back( 0.);
141 if (cdiabo->halflengthY2()>0.) {
142 x.push_back(cdiabo->maxHalflengthX()); y.push_back( 2*cdiabo->halflengthY2());
143 x.push_back(-cdiabo->maxHalflengthX());y.push_back( 2*cdiabo->halflengthY2());
144 }
145 x.push_back(-cdiabo->medHalflengthX());y.push_back( 0.);
146 x.push_back(-cdiabo->minHalflengthX());y.push_back( -2*cdiabo->halflengthY1());
147
148 SbPolyhedronPolygonXSect sbPoly(x,y,dz);
149 return new SoPolyhedron(sbPoly);
150 }
151
152 const Trk::AnnulusBounds* cannulus = dynamic_cast<const Trk::AnnulusBounds*>(&(psf.bounds()));
153 if (cannulus){
154 SoGenericBox * gb = new SoGenericBox;
155 const double hminphi = 0.5*cannulus->minR()*cannulus->phi();
156 const double hmaxphi = 0.5*cannulus->maxR()*cannulus->phi();
157 const double heta = 0.5 * (cannulus->maxR() - cannulus->minR());
158 gb->setParametersForTrapezoid( 0.5*surfaceThickness/*dz*/, 0/*theta*/, 0/*phi*/, heta/*dy1*/,
159 hminphi/*dx1*/, hmaxphi/*dx2*/, heta/*dy2*/, hminphi/*dx3*/,
160 hmaxphi/*dx4*/, 0/*alp1*/, 0/*alp2*/ );
161 gb->drawEdgeLines.setValue(true);
162 return gb;
163 }
164 const Trk::NoBounds* nobo = dynamic_cast<const Trk::NoBounds*>(&(psf.bounds()));
165 if (nobo){
166 SoGenericBox * gb = new SoGenericBox;
167 gb->setParametersForBox(50.0,50.0,0.5*surfaceThickness);
168 gb->drawEdgeLines.setValue(false);
169 return gb;
170 }
171
172 return 0;
173}
#define y
#define x
void setParametersForBox(float dx, float dy, float dz, float xcenter=0.0, float ycenter=0.0, float zcenter=0.0)
void setParametersForTrapezoid(float dz, float theta, float phi, float dy1, float dx1, float dx2, float dy2, float dx3, float dx4, float alp1, float alp2)
SoSFBool drawEdgeLines
static const double surfaceThickness
double minR() const
This method returns the smaller radius.
double maxR() const
This method returns the bigger radius.
double phi() const
This method returns the opening angle.
double minHalflengthX() const
This method returns the halflength in X at minimal Y (first coordinate of local surface frame)
double maxHalflengthX() const
This method returns the halflength in X at maximal Y (first coordinate of local surface frame)
double medHalflengthX() const
This method returns the (maximal) halflength in X (first coordinate of local surface frame)
double halflengthY1() const
This method returns the halflength in Y of trapezoid at negative/positive Y (second coordinate)
double halflengthY2() const
virtual const SurfaceBounds & bounds() const override final
This method returns the bounds by reference, static NoBounds in case of no boundaries.
double halflengthPhi() const
This method returns the halflength in phi (first coordinate of local surface frame)
double halflengthEta() const
This method returns the halflength in Eta (second coordinate of local surface frame)
double halflengthX() const
This method returns the minimal halflength in X (first coordinate of local surface frame)
double maxHalflengthY() const
This method returns the halflength in Y (second coordinate of local surface frame)
double minHalflengthY() const
This method returns the maximal halflength in X (first coordinate of local surface frame)
double maxHalflengthPhi() const
This method returns the maximal halflength in phi (first coordinate of local surface frame)
double minHalflengthPhi() const
This method returns the minimal halflength in phi (first coordinate of local surface frame)
double halflengthEta() const
This method returns the halflength in eta (second coordinate of local surface frame)

◆ translateStraightLineSurface()

SoNode * SurfaceToSoNode::translateStraightLineSurface ( const Trk::StraightLineSurface & slsf,
const bool & simple = false ) const

Definition at line 216 of file SurfaceToSoNode.cxx.

217{
218 //std::cout<<"translateStraightLineSurface"<<std::endl;
219 const Trk::CylinderBounds* ccbo = dynamic_cast<const Trk::CylinderBounds*>(&(slsf.bounds()));
220 if (ccbo){
221 double hlength = ccbo->halflengthZ();
222 if ( simple )
223 {
224 SoVertexProperty * scatVtxProperty = new SoVertexProperty();
225 scatVtxProperty->vertex.set1Value(0, 0.0,0.0,-hlength);
226 scatVtxProperty->vertex.set1Value(1, 0.0,0.0, hlength);
227 SoLineSet * lineSurface = new SoLineSet();
228 lineSurface->numVertices = 2;
229 lineSurface->vertexProperty = scatVtxProperty;
230 return lineSurface;
231 }
232
233 double radius = ccbo->r();
234 SoTubs* lineSurface = new SoTubs();
235 (*lineSurface).pRMin = 0.;
236 (*lineSurface).pRMax = radius;
237 (*lineSurface).pDz = hlength;
238 return lineSurface;
239 }
240 return 0;
241}
virtual const SurfaceBounds & bounds() const override final
This method returns the bounds of the Surface by reference.

◆ translateSurface()

SoNode * SurfaceToSoNode::translateSurface ( const Trk::Surface & sf,
const bool & simple = false ) const

Definition at line 57 of file SurfaceToSoNode.cxx.

58{
59
60 SoNode* sono =0;
61 const Trk::CylinderSurface* ccsf = dynamic_cast<const Trk::CylinderSurface*>(&sf);
62 if (ccsf) sono = this->translateCylinderSurface(*ccsf);
63
64 const Trk::DiscSurface* cdsf = sono ? 0 : dynamic_cast<const Trk::DiscSurface*>(&sf);
65 if (cdsf) sono = this->translateDiscSurface(*cdsf);
66
67 const Trk::PlaneSurface* cpsf = sono ? 0 : dynamic_cast<const Trk::PlaneSurface*>(&sf);
68 if (cpsf) sono = this->translatePlaneSurface(*cpsf);
69
70 const Trk::StraightLineSurface* cssf = sono ? 0 : dynamic_cast<const Trk::StraightLineSurface*>(&sf);
71 if (cssf) sono = this->translateStraightLineSurface(*cssf, simple);
72
73 const Trk::PerigeeSurface* cpersf = sono ? 0 : dynamic_cast<const Trk::PerigeeSurface*>(&sf);
74 if (cpersf) sono = this->translatePerigeeSurface(*cpersf);
75
76 if (!sono) {
77 std::cout<<"ERROR! Surface unknown!"<<std::endl;
78 return 0;
79 }
80
81 // place and transform them
82 SoSeparator* sosep = new SoSeparator();
83
84 // Horrible hack for ITK annulus bounds. What should really happen is we draw the surface where the bounds are. But this was never done before.
85 Amg::Transform3D transform = sf.transform();
86 if (cpsf) {
87 const Trk::AnnulusBounds* cannulus = dynamic_cast<const Trk::AnnulusBounds*>(&(cpsf->bounds()));
88 if (cannulus){
89 Amg::Vector3D vec(0.0,0.5*(cannulus->maxR()+cannulus->minR()),0.0);
90 transform.translate(vec);
91 }
92 }
93
94 SoTransform* sotra = VP1LinAlgUtils::toSoTransform(transform);
95 sosep->addChild(sotra);
96 sosep->addChild(sono);
97
98 return sosep;
99}
std::vector< size_t > vec
SoNode * translateCylinderSurface(const Trk::CylinderSurface &csf) const
SoNode * translatePerigeeSurface(const Trk::PerigeeSurface &persf) const
SoNode * translateStraightLineSurface(const Trk::StraightLineSurface &slsf, const bool &simple=false) const
SoNode * translatePlaneSurface(const Trk::PlaneSurface &psf) const
SoNode * translateDiscSurface(const Trk::DiscSurface &dsf) const
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
Eigen::Affine3d Transform3D
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Eigen::Matrix< double, 3, 1 > Vector3D

Member Data Documentation

◆ surfaceThickness

const double SurfaceToSoNode::surfaceThickness = 0.1
static

Definition at line 55 of file SurfaceToSoNode.h.


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