ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
SoTubs Class Reference

SoTubs - Inventor version of the G4Tubs Geant Geometry entity. More...

#include <SoTubs.h>

Inheritance diagram for SoTubs:
Collaboration diagram for SoTubs:

Public Member Functions

 SoTubs ()
 Constructor, required. More...
 
virtual void generateAlternateRep ()
 Generate AlternateRep, required. More...
 
virtual void clearAlternateRep ()
 We better be able to clear it, too! More...
 

Static Public Member Functions

static void initClass ()
 Class Initializer, required. More...
 

Public Attributes

SoSFFloat pRMin
 Inside radius of the tube. More...
 
SoSFFloat pRMax
 Outside radius of the tube. More...
 
SoSFFloat pDz
 Half-length in Z. More...
 
SoSFFloat pSPhi
 Starting angle, in radians. More...
 
SoSFFloat pDPhi
 Delta-angle, in radians. More...
 
SoSFInt32 pOverrideNPhi
 Override number of phi subdivision used for rendering shape (i.e. More...
 
SoSFNode alternateRep
 Alternate rep - required. More...
 
SoSFBool drawEdgeLines
 

Protected Member Functions

virtual void computeBBox (SoAction *action, SbBox3f &box, SbVec3f &center)
 compute bounding Box, required More...
 
virtual void generatePrimitives (SoAction *action)
 Generate Primitives, required. More...
 
virtual SoChildList * getChildren () const
 GetChildList, required whenever the class has hidden children. More...
 
virtual ~SoTubs ()
 Destructor, required. More...
 

Private Member Functions

 SO_NODE_HEADER (SoTubs)
 
void generateChildren ()
 Generate Children. More...
 
void updateChildren ()
 Used to modify hidden children when a data field is changed. More...
 
void inc (double &sinPhi, double &cosPhi, double sinDeltaPhi, double cosDeltaPhi) const
 help with trigonometry. increments sines an cosines by an angle. More...
 

Private Attributes

SoChildList * m_children
 ChildList. Required whenever the class has hidden children. More...
 

Detailed Description

SoTubs - Inventor version of the G4Tubs Geant Geometry entity.

Node: SoTubs

Description: The Inventor version of the G4Tubs Geant Geometry entity

Author: Joe Boudreau Nov 11 1996

The documentation from Geant says:

class G4Tubs

A tube or tube segment with curved sides parallel to the z-axis. The tube has a specified half-length along the z axis, about which it is centred, and a given minimum and maximum radius. A minimum radius of 0 signifies a filled tube /cylinder. The tube segment is specified by starting and delta angles for phi, with 0 being the +x axis, PI/2 the +y axis. A delta angle of 2PI signifies a complete, unsegmented tube/cylinder

Always use Inventor Fields. This allows Inventor to detect a change to the data field and take the appropriate action; e.g., redraw the scene.

Definition at line 50 of file SoTubs.h.

Constructor & Destructor Documentation

◆ SoTubs()

SoTubs::SoTubs ( )

Constructor, required.

Definition at line 40 of file SoTubs.cxx.

40  {
41 
42 
43  // This statement is required
44  SO_NODE_CONSTRUCTOR(SoTubs);
45 
46  // Data fields are initialized like this:
47  SO_NODE_ADD_FIELD(pRMin, (0));
48  SO_NODE_ADD_FIELD(pRMax, (1));
49  SO_NODE_ADD_FIELD(pDz, (10));
50  SO_NODE_ADD_FIELD(pSPhi, (0));
51  SO_NODE_ADD_FIELD(pDPhi, ((float)(2*M_PI)));
52  SO_NODE_ADD_FIELD(pOverrideNPhi, (0));
53  SO_NODE_ADD_FIELD(alternateRep, (NULL));
54  SO_NODE_ADD_FIELD(drawEdgeLines, (false));
55 
56  m_children = new SoChildList(this);
57 
58  setNodeType(EXTENSION);
59 }

◆ ~SoTubs()

SoTubs::~SoTubs ( )
protectedvirtual

Destructor, required.

Definition at line 62 of file SoTubs.cxx.

62  {
63  delete m_children;
64 }

Member Function Documentation

◆ clearAlternateRep()

void SoTubs::clearAlternateRep ( )
virtual

We better be able to clear it, too!

Definition at line 573 of file SoTubs.cxx.

573  {
574  alternateRep.setValue(NULL);
575 }

◆ computeBBox()

void SoTubs::computeBBox ( SoAction *  action,
SbBox3f &  box,
SbVec3f &  center 
)
protectedvirtual

compute bounding Box, required

Definition at line 360 of file SoTubs.cxx.

360  {
361  RevolutionSurfaceUtil::setBBoxPars(pSPhi.getValue(), pDPhi.getValue(),
362  pRMin.getValue(), pRMax.getValue(),
363  -pDz.getValue(),pDz.getValue(),
364  box, center );
365 }

◆ generateAlternateRep()

void SoTubs::generateAlternateRep ( )
virtual

Generate AlternateRep, required.

Generating an alternate representation must be done upon users request. It allows an Inventor program to read back the file without requiring this code to be dynamically linked. If the users expects that this code will be dynamically linked, he need not invoke this method.

Definition at line 562 of file SoTubs.cxx.

562  {
563 
564  // This routine sets the alternate representation to the child
565  // list of this mode.
566 
567  if (m_children->getLength() == 0) generateChildren();
568  updateChildren();
569  alternateRep.setValue((SoSeparator *) ( *m_children)[0]);
570 }

◆ generateChildren()

void SoTubs::generateChildren ( )
private

Generate Children.

Used to create the hidden children. Required whenever the node has hidden children.

Definition at line 538 of file SoTubs.cxx.

538  {
539 
540  // This routines creates one SoSeparator, one SoCoordinate3, and
541  // one SoLineSet, and puts it in the child list. This is done only
542  // once, whereas redrawing the position of the coordinates occurs each
543  // time an update is necessary, in the updateChildren routine.
544 
545  assert(m_children->getLength() ==0);
546  SoSeparator *sep = new SoSeparator();
547  SoCoordinate3 *theCoordinates = new SoCoordinate3();
548  SoNormal *theNormals = new SoNormal();
549  SoNormalBinding *theNormalBinding = new SoNormalBinding();
550  SoIndexedFaceSet *theFaceSet = new SoIndexedFaceSet();
551  //
552  // This line costs some in render quality! but gives speed.
553  //
554  sep->addChild(theCoordinates);
555  sep->addChild(theNormals);
556  sep->addChild(theNormalBinding);
557  sep->addChild(theFaceSet);
558  m_children->append(sep);
559 }

◆ generatePrimitives()

void SoTubs::generatePrimitives ( SoAction *  action)
protectedvirtual

Generate Primitives, required.

Definition at line 77 of file SoTubs.cxx.

77  {
78  // This variable is used to store each vertex
79  SoPrimitiveVertex pv;
80 
81  // Access the stat from the action
82  SoState *state = action->getState();
83  if (!state)
84  return;
85 
86  // See if we have to use a texture coordinate function,
87  // rather than generating explicit texture coordinates.
88  SbBool useTexFunction=
90  SoTextureCoordinateElement::FUNCTION);
91 
92  // If we need to generate texture coordinates with a function,
93  // we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
94  // set up the coordinates directly.
95  const SoTextureCoordinateElement* tce = NULL;
96  SbVec4f texCoord;
97  if (useTexFunction) {
98  tce = SoTextureCoordinateElement::getInstance(state);
99  }
100  else {
101  texCoord[2] = 0.0;
102  texCoord[3] = 1.0;
103  }
104  SbVec3f point, normal;
105 
106 
108  //-----------------------------------------------------
109 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
110  point.setValue((float)(x),(float)(y),(float)(z)); \
111  normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
112  if (useTexFunction) { \
113  texCoord=tce->get(point,normal); \
114  } else { \
115  texCoord[0]=(float)(s); \
116  texCoord[1]=(float)(t); \
117  } \
118  pv.setPoint(point); \
119  pv.setNormal(normal); \
120  pv.setTextureCoords(texCoord); \
121  shapeVertex(&pv);
122  //-----------------------------------------------------
124 
125  int NPHI = RevolutionSurfaceUtil::nphiDivisions( pDPhi.getValue(), this->getComplexityValue(action), pOverrideNPhi.getValue() );
126 
127  double deltaPhi = pDPhi.getValue()/NPHI, phi0 = pSPhi.getValue(),phi1=phi0+pDPhi.getValue();
128  double rMax=pRMax.getValue(),rMin=pRMin.getValue();
129  double zMax=pDz.getValue(),zMin=-zMax;
130  double cosPhi0=cos(phi0), sinPhi0=sin(phi0);
131  double cosPhi1=cos(phi1), sinPhi1=sin(phi1);
132  double cosDeltaPhi=cos(deltaPhi),sinDeltaPhi=sin(deltaPhi);
133  const bool noPhiCutout=fabs(pDPhi.getValue())==0.F || fabs(fabs(pDPhi.getValue())-2.0*M_PI)<0.01; // FIXME - better way to do this?
134  const bool disableLighting(glIsEnabled(GL_LIGHTING));
135  const bool transparencyOn(glIsEnabled(GL_BLEND));
136 
137  //
138  // The outer surface!
139  //
140  int i;
141  double sinPhi,cosPhi;
142  beginShape(action,TRIANGLE_STRIP);
143  sinPhi=sinPhi0;
144  cosPhi=cosPhi0;
145  for (i = 0; i<=NPHI; i++) {
146  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);
147  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);
148  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
149  }
150  endShape();
151  //
152  // The inner surface!
153  //
154  if(rMin!=0.F) {
155  beginShape(action,TRIANGLE_STRIP);
156  sinPhi=sinPhi0;
157  cosPhi=cosPhi0;
158  for (i = 0; i<=NPHI; i++) {
159  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);
160  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);
161  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
162  }
163  endShape();
164  }
165 // if (fabs(deltaPhi)<2.0*M_PI) { // Old value - probably responsible for the funny internal stuff.
166  if (!noPhiCutout) {
167 
168  //
169  // The end - inner part of wedge
170  //
171 
172  // FIXME - Use GL_POLYGON? Tried it - no change when selecting and seemed to mess up phong-type shading.
173  // Try again, to see if it's faster?
174 
175  beginShape(action,TRIANGLE_STRIP);
176  sinPhi=sinPhi0;
177  cosPhi=cosPhi0;
178  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
179  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
180  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
181  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
182  endShape();
183  //
184  // The other end
185  //
186  beginShape(action,TRIANGLE_STRIP);
187  sinPhi=sinPhi1;
188  cosPhi=cosPhi1;
189  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
190  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
191  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
192  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
193  endShape();
194 
195  if (drawEdgeLines.getValue()) {
196  if (disableLighting) glDisable(GL_LIGHTING);
197  if (transparencyOn) glDisable(GL_BLEND);
198 
199  glBegin(GL_LINES);
200  glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMax);
201  glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMin);
202  glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMax);
203  glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMin);
204  glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMax);
205  glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMin);
206  glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMax);
207  glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMin);
208  glEnd();
209  if (disableLighting) glEnable(GL_LIGHTING);
210  if (transparencyOn) glEnable(GL_BLEND);
211  }
212 
213  }
214  //
215  // The outer surface at z=+PDZ
216  //
217  if(rMin==0.F) {
218  beginShape(action,TRIANGLE_FAN);
219  sinPhi=sinPhi0;
220  cosPhi=cosPhi0;
221  GEN_VERTEX(pv,0,0,zMax,0.0,0.0,0,0,1);
222  for (i = 0; i<=NPHI; i++) {
223  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
224  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
225  }
226  endShape();
227  //
228  // The outer surface at z=-PDZ
229  //
230  beginShape(action,TRIANGLE_FAN);
231  sinPhi=sinPhi0;
232  cosPhi=cosPhi0;
233  GEN_VERTEX(pv,0,0,zMin,0.0,0.0,0,0,-1);
234  for (i = 0; i<=NPHI; i++) {
235  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
236  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
237  }
238  endShape();
239 
240 
241  if (drawEdgeLines.getValue()) {
242  if (disableLighting) glDisable(GL_LIGHTING);
243  if (transparencyOn) glDisable(GL_BLEND);
244  glBegin(GL_LINE_STRIP);
245  sinPhi=sinPhi0;
246  cosPhi=cosPhi0;
247  if (!noPhiCutout) glVertex3f(0,0,zMax); // only draw if phi range
248  for (i = 0; i<=NPHI; i++) {
249  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
250  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
251  }
252  if (!noPhiCutout) glVertex3f(0,0,zMax);
253 
254  glEnd();
255 
256  glBegin(GL_LINE_STRIP);
257  sinPhi=sinPhi0;
258  cosPhi=cosPhi0;
259  if (!noPhiCutout) glVertex3f(0,0,zMin); // only draw if phi range
260  for (i = 0; i<=NPHI; i++) {
261  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
262  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
263  }
264  if (!noPhiCutout) glVertex3f(0,0,zMin);
265 
266  glEnd();
267 
268  if (disableLighting) glEnable(GL_LIGHTING);
269  if (transparencyOn) glEnable(GL_BLEND);
270  }
271 
272  } else {
273  beginShape(action,TRIANGLE_STRIP);
274  sinPhi=sinPhi0;
275  cosPhi=cosPhi0;
276  for (i = 0; i<=NPHI; i++) {
277  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,0,0,1);
278  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
279  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
280  }
281  endShape();
282  //
283  // The outer surface at z=-PDZ
284  //
285  beginShape(action,TRIANGLE_STRIP);
286  sinPhi=sinPhi0;
287  cosPhi=cosPhi0;
288  for (i = 0; i<=NPHI; i++) {
289  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,0.0,0,0,-1);
290  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
291  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
292  }
293  endShape();
294 
295  if (drawEdgeLines.getValue()) {
296  if (disableLighting) glDisable(GL_LIGHTING);
297  if (transparencyOn) glDisable(GL_BLEND);
298  glBegin(GL_LINE_STRIP);
299  sinPhi=sinPhi0;
300  cosPhi=cosPhi0;
301  if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax); // only draw if phi range
302  for (i = 0; i<=NPHI; i++) {
303  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
304  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
305  }
306  if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMax); // only draw if phi range
307  glEnd();
308 
309  glBegin(GL_LINE_STRIP);
310  sinPhi=sinPhi0;
311  cosPhi=cosPhi0;
312  for (i = 0; i<=NPHI; i++) {
313  glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax);
314  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
315  }
316  glEnd();
317 
318  glBegin(GL_LINE_STRIP);
319  sinPhi=sinPhi0;
320  cosPhi=cosPhi0;
321  if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin); // only draw if phi range
322  for (i = 0; i<=NPHI; i++) {
323  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
324  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
325  }
326  if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMin); // only draw if phi range
327  glEnd();
328 
329  glBegin(GL_LINE_STRIP);
330  sinPhi=sinPhi0;
331  cosPhi=cosPhi0;
332  for (i = 0; i<=NPHI; i++) {
333  glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin);
334  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
335  }
336  glEnd();
337 
338  if (disableLighting) glEnable(GL_LIGHTING);
339  if (transparencyOn) glEnable(GL_BLEND);
340  }
341 
342  }
343 
344  if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
345  //Encourage auto caching
346  SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
347 #if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
348  SoGLCacheContextElement::incNumShapes(state);
349 #endif
350  }
351 }

◆ getChildren()

SoChildList * SoTubs::getChildren ( ) const
protectedvirtual

GetChildList, required whenever the class has hidden children.

Definition at line 354 of file SoTubs.cxx.

354  {
355  return m_children;
356 }

◆ inc()

void SoTubs::inc ( double &  sinPhi,
double &  cosPhi,
double  sinDeltaPhi,
double  cosDeltaPhi 
) const
inlineprivate

help with trigonometry. increments sines an cosines by an angle.

Definition at line 158 of file SoTubs.h.

158  {
159  double oldSin=sinPhi,oldCos=cosPhi;
160  sinPhi = oldSin*cosDeltaPhi+oldCos*sinDeltaPhi;
161  cosPhi = oldCos*cosDeltaPhi-oldSin*sinDeltaPhi;
162  }

◆ initClass()

void SoTubs::initClass ( )
static

Class Initializer, required.

Definition at line 68 of file SoTubs.cxx.

69 {
70  [[maybe_unused]] static const bool didInit = [&]() {
71  SO_NODE_INIT_CLASS(SoTubs,SoShape,"Shape");
72  return true;
73  }();
74 }

◆ SO_NODE_HEADER()

SoTubs::SO_NODE_HEADER ( SoTubs  )
private

◆ updateChildren()

void SoTubs::updateChildren ( )
private

Used to modify hidden children when a data field is changed.

Required whenever the class has hidden children.

Definition at line 369 of file SoTubs.cxx.

369  {
370 
371  // Redraw the G4Tubs....
372 
373  assert(m_children->getLength()==1);
374  SoSeparator *sep = (SoSeparator *) ( *m_children)[0];
375  SoCoordinate3 *theCoordinates = (SoCoordinate3 *) ( sep->getChild(0));
376  SoNormal *theNormals = (SoNormal *) ( sep->getChild(1));
377  SoNormalBinding *theNormalBinding = (SoNormalBinding *) ( sep->getChild(2));
378  SoIndexedFaceSet *theFaceSet = (SoIndexedFaceSet *) ( sep->getChild(3));
379 
380 
381  const int NPHI=96, NPOINTS=2*(2*NPHI+2), NFACES=4*NPHI+2, NINDICES = NFACES*5;
382  float points[NPOINTS][3],normals[NFACES][3];
383 #ifdef INVENTOR2_0
384  static long indices[NINDICES];
385 #else
386  static int32_t indices[NINDICES];
387 #endif
388 
389  static int init=0;
390  double phi, pp, DeltaPhi;
391 
392  // Indices need to be generated once! This is here to keep it close to the point
393  // generation, since otherwise it will be confusing.
394 
395  int i;
396  if (!init) {
397  init = 1;
398  // Outer face
399  for (i = 0; i< NPHI; i++) {
400  // 0 1 3 2;
401  indices[5*i+0] = 2*i+0;
402  indices[5*i+1] = 2*i+1;
403  indices[5*i+2] = 2*i+3;
404  indices[5*i+3] = 2*i+2;
405  indices[5*i+4] = SO_END_FACE_INDEX;
406  }
407  // the inner face
408  for (i=0;i<NPHI;i++) {
409  indices[5*1*NPHI + 5*i+0] = 2*NPHI+2 + 2*i+0;
410  indices[5*1*NPHI + 5*i+1] = 2*NPHI+2 + 2*i+1;
411  indices[5*1*NPHI + 5*i+2] = 2*NPHI+2 + 2*i+3;
412  indices[5*1*NPHI + 5*i+3] = 2*NPHI+2 + 2*i+2;
413  indices[5*1*NPHI + 5*i+4] = SO_END_FACE_INDEX;
414  }
415  // the top side
416  for (i=0;i<NPHI;i++) {
417  indices[5*2*NPHI + 5*i+0] = 2*i+0;
418  indices[5*2*NPHI + 5*i+1] = 2*i+2;
419  indices[5*2*NPHI + 5*i+2] = NPOINTS - (2*i+4);
420  indices[5*2*NPHI + 5*i+3] = NPOINTS - (2*i+2);
421  indices[5*2*NPHI + 5*i+4] = SO_END_FACE_INDEX;
422  }
423  // the bottom side
424  for (i=0;i<NPHI;i++) {
425  indices[5*3*NPHI + 5*i+0] = 2*i+1;
426  indices[5*3*NPHI + 5*i+1] = NPOINTS - (2*i+1);
427  indices[5*3*NPHI + 5*i+2] = NPOINTS - (2*i+3);
428  indices[5*3*NPHI + 5*i+3] = 2*i+3;
429  indices[5*3*NPHI + 5*i+4] = SO_END_FACE_INDEX;
430  }
431  // the odd side
432  indices[5*4*NPHI +0] = 2*NPHI;
433  indices[5*4*NPHI +1] = 2*NPHI+1;
434  indices[5*4*NPHI +2] = 2*NPHI+3;
435  indices[5*4*NPHI +3] = 2*NPHI+2;
436  indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
437  // aother odd side
438  indices[5*4*NPHI +5 +0] = 0;
439  indices[5*4*NPHI +5 +1] = NPOINTS-2;
440  indices[5*4*NPHI +5 +2] = NPOINTS-1;
441  indices[5*4*NPHI +5 +3] = 1;
442  indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
443  }
444  // Points need to be generated each time:
445  if (pDPhi.getValue()<2*M_PI) {
446  // the odd side
447  indices[5*4*NPHI +0] = 2*NPHI;
448  indices[5*4*NPHI +1] = 2*NPHI+1;
449  indices[5*4*NPHI +2] = 2*NPHI+3;
450  indices[5*4*NPHI +3] = 2*NPHI+2;
451  indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
452  // aother odd side
453  indices[5*4*NPHI +5 +0] = 0;
454  indices[5*4*NPHI +5 +1] = NPOINTS-2;
455  indices[5*4*NPHI +5 +2] = NPOINTS-1;
456  indices[5*4*NPHI +5 +3] = 1;
457  indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
458  }
459  else {
460  // the odd side
461  indices[5*4*NPHI +0] = SO_END_FACE_INDEX;
462  indices[5*4*NPHI +1] = SO_END_FACE_INDEX;
463  indices[5*4*NPHI +2] = SO_END_FACE_INDEX;
464  indices[5*4*NPHI +3] = SO_END_FACE_INDEX;
465  indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
466  // aother odd side
467  indices[5*4*NPHI +5 +0] = SO_END_FACE_INDEX;
468  indices[5*4*NPHI +5 +1] = SO_END_FACE_INDEX;
469  indices[5*4*NPHI +5 +2] = SO_END_FACE_INDEX;
470  indices[5*4*NPHI +5 +3] = SO_END_FACE_INDEX;
471  indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
472  }
473  // The outer surface
474  DeltaPhi = pDPhi.getValue()/NPHI, phi = pSPhi.getValue();
475  for (i = 0; i<=NPHI; i++) {
476  points[2*i+0][0] = pRMax.getValue()*FCOS(phi);
477  points[2*i+0][1]= pRMax.getValue()*FSIN(phi);
478  points[2*i+0][2] = +pDz.getValue();
479 
480  points[2*i+1][0] = pRMax.getValue()*FCOS(phi);
481  points[2*i+1][1]= pRMax.getValue()*FSIN(phi);
482  points[2*i+1][2] = -pDz.getValue();
483 
484  pp = phi+DeltaPhi/2.0;
485  if (i!=NPHI) {
486  normals[i][0] = FCOS(pp);
487  normals[i][1] = FSIN(pp);
488  normals[i][2] = 0;
489  }
490  phi+=DeltaPhi;
491  }
492  // The inner surface
493  phi = pSPhi.getValue() + pDPhi.getValue();
494  for (i = 0; i<=NPHI; i++) {
495  points[2*NPHI+2+2*i+0][0] = pRMin.getValue()*FCOS(phi);
496  points[2*NPHI+2+2*i+0][1] = pRMin.getValue()*FSIN(phi);
497  points[2*NPHI+2+2*i+0][2] = +pDz.getValue();
498  points[2*NPHI+2+2*i+1][0] = pRMin.getValue()*FCOS(phi);
499  points[2*NPHI+2+2*i+1][1] = pRMin.getValue()*FSIN(phi);
500  points[2*NPHI+2+2*i+1][2] = -pDz.getValue();
501  pp = phi-DeltaPhi/2.0;
502  if (i!=NPHI) {
503  normals[NPHI+i][0] = -FCOS(pp);
504  normals[NPHI+i][1] = -FSIN(pp);
505  normals[NPHI+i][2] = 0;
506  }
507  phi-=DeltaPhi;
508  }
509  // The top side
510  for (i=0;i<NPHI;i++) {
511  normals[2*NPHI+i][0]=normals[2*NPHI+i][1]=0;
512  normals[2*NPHI+i][2]= 1.0;
513  }
514  // The bottom side
515  for (i=0;i<NPHI;i++) {
516  normals[3*NPHI+i][0]=normals[3*NPHI+i][1]=0;
517  normals[3*NPHI+i][2]= -1.0;
518  }
519  // The odd side
520  phi = pSPhi.getValue();
521  normals[4*NPHI+0][0]= FSIN(phi);
522  normals[4*NPHI+0][1]= -FCOS(phi);
523  normals[4*NPHI+0][2]=0;
524 
525  // Another odd side
526  phi = pSPhi.getValue()+pDPhi.getValue();
527  normals[4*NPHI+1][0]= -FSIN(phi);
528  normals[4*NPHI+1][1]= +FCOS(phi);
529  normals[4*NPHI+1][2]=0;
530 
531  for (int np=0;np<NPOINTS; np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
532  for (int ni=0;ni<NINDICES;ni++) theFaceSet->coordIndex.set1Value(ni,indices[ni]);
533  for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
534  theNormalBinding->value=SoNormalBinding::PER_FACE;
535 }

Member Data Documentation

◆ alternateRep

SoSFNode SoTubs::alternateRep

Alternate rep - required.

Definition at line 85 of file SoTubs.h.

◆ drawEdgeLines

SoSFBool SoTubs::drawEdgeLines

Definition at line 87 of file SoTubs.h.

◆ m_children

SoChildList* SoTubs::m_children
private

ChildList. Required whenever the class has hidden children.

Definition at line 153 of file SoTubs.h.

◆ pDPhi

SoSFFloat SoTubs::pDPhi

Delta-angle, in radians.

Definition at line 76 of file SoTubs.h.

◆ pDz

SoSFFloat SoTubs::pDz

Half-length in Z.

Definition at line 68 of file SoTubs.h.

◆ pOverrideNPhi

SoSFInt32 SoTubs::pOverrideNPhi

Override number of phi subdivision used for rendering shape (i.e.

ignore e.g. complexity value). Put field to 0 (the default) to ignore it.

Definition at line 81 of file SoTubs.h.

◆ pRMax

SoSFFloat SoTubs::pRMax

Outside radius of the tube.

Definition at line 64 of file SoTubs.h.

◆ pRMin

SoSFFloat SoTubs::pRMin

Inside radius of the tube.

Definition at line 60 of file SoTubs.h.

◆ pSPhi

SoSFFloat SoTubs::pSPhi

Starting angle, in radians.

Definition at line 72 of file SoTubs.h.


The documentation for this class was generated from the following files:
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SoTubs::updateChildren
void updateChildren()
Used to modify hidden children when a data field is changed.
Definition: SoTubs.cxx:369
FCOS
#define FCOS(x)
Definition: SbMath.h:13
SoTubs
SoTubs - Inventor version of the G4Tubs Geant Geometry entity.
Definition: SoTubs.h:50
GEN_VERTEX
#define GEN_VERTEX(pv, x, y, z, s, t, nx, ny, nz)
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
SoTubs::inc
void inc(double &sinPhi, double &cosPhi, double sinDeltaPhi, double cosDeltaPhi) const
help with trigonometry. increments sines an cosines by an angle.
Definition: SoTubs.h:158
M_PI
#define M_PI
Definition: ActiveFraction.h:11
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
RevolutionSurfaceUtil::nphiDivisions
static int nphiDivisions(const float &dphi, const float &complexity, int OverrideNPhi=0)
Definition: RevolutionSurfaceUtil.h:21
SoTubs::alternateRep
SoSFNode alternateRep
Alternate rep - required.
Definition: SoTubs.h:85
lumiFormat.i
int i
Definition: lumiFormat.py:85
RevolutionSurfaceUtil::setBBoxPars
static void setBBoxPars(const float &sphi, const float &dphi, const float &rmin, const float &rmax, const float &zmin, const float &zmax, SbBox3f &box, SbVec3f &center)
Definition: RevolutionSurfaceUtil.h:40
SoTubs::drawEdgeLines
SoSFBool drawEdgeLines
Definition: SoTubs.h:87
grepfile.sep
sep
Definition: grepfile.py:38
FSIN
#define FSIN(x)
Definition: SbMath.h:14
SoTubs::pDPhi
SoSFFloat pDPhi
Delta-angle, in radians.
Definition: SoTubs.h:76
SoTubs::pOverrideNPhi
SoSFInt32 pOverrideNPhi
Override number of phi subdivision used for rendering shape (i.e.
Definition: SoTubs.h:81
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
F
#define F(x, y, z)
Definition: MD5.cxx:112
python.changerun.pv
pv
Definition: changerun.py:81
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
SoTubs::pDz
SoSFFloat pDz
Half-length in Z.
Definition: SoTubs.h:68
Ringer::getType
T getType(const char *cStr)
Return Ringer enumeration of type T identifying string type:
jobOptions.points
points
Definition: jobOptions.GenevaPy8_Zmumu.py:97
SoTubs::m_children
SoChildList * m_children
ChildList. Required whenever the class has hidden children.
Definition: SoTubs.h:153
SoTubs::generateChildren
void generateChildren()
Generate Children.
Definition: SoTubs.cxx:538
SoTubs::pRMin
SoSFFloat pRMin
Inside radius of the tube.
Definition: SoTubs.h:60
SoTubs::pRMax
SoSFFloat pRMax
Outside radius of the tube.
Definition: SoTubs.h:64
SoTubs::pSPhi
SoSFFloat pSPhi
Starting angle, in radians.
Definition: SoTubs.h:72