ATLAS Offline Software
SoTubs.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*-----------------------------HEPVis---------------------------------------*/
6 /* */
7 /* Node: SoTubs */
8 /* Description: Represents the G4Tubs Geant Geometry entity */
9 /* Author: Joe Boudreau Nov 11 1996 */
10 /* */
11 /*--------------------------------------------------------------------------*/
12 
13 #include <VP1HEPVis/nodes/SoTubs.h>
14 #include "RevolutionSurfaceUtil.h"
15 
16 #include <cassert>
17 #include <cmath>
18 
19 #include <Inventor/SbBox.h>
20 #include <Inventor/actions/SoGLRenderAction.h>
21 // #include <Inventor/fields/SoSFFloat.h>
22 #include <Inventor/misc/SoChildList.h>
23 #include <Inventor/nodes/SoSeparator.h>
24 #include <Inventor/nodes/SoIndexedFaceSet.h>
25 #include <Inventor/nodes/SoNormal.h>
26 #include <Inventor/nodes/SoCoordinate3.h>
27 #include <Inventor/nodes/SoNormalBinding.h>
28 #include <Inventor/SoPrimitiveVertex.h>
29 #include <Inventor/elements/SoTextureCoordinateElement.h>
30 #include <Inventor/elements/SoGLCacheContextElement.h>
31 #include <Inventor/C/glue/gl.h>
32 
33 #include "SbMath.h"
34 #include <iostream>
35 
36 // This statement is required
37 SO_NODE_SOURCE(SoTubs)
38 
39 // Constructor
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 }
60 
61 // Destructor
63  delete m_children;
64 }
65 
66 
67 //____________________________________________________________________
69 {
70  [[maybe_unused]] static const bool didInit = [&]() {
71  SO_NODE_INIT_CLASS(SoTubs,SoShape,"Shape");
72  return true;
73  }();
74 }
75 
76 // generatePrimitives
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 }
352 
353 // getChildren
354 SoChildList *SoTubs::getChildren() const {
355  return m_children;
356 }
357 
358 
359 // computeBBox
360 void SoTubs::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
361  RevolutionSurfaceUtil::setBBoxPars(pSPhi.getValue(), pDPhi.getValue(),
362  pRMin.getValue(), pRMax.getValue(),
363  -pDz.getValue(),pDz.getValue(),
364  box, center );
365 }
366 
367 
368 // updateChildren
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 }
536 
537 // generateChildren
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 }
560 
561 // generateAlternateRep
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 }
571 
572 // clearAlternateRep
574  alternateRep.setValue(NULL);
575 }
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
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::getChildren
virtual SoChildList * getChildren() const
GetChildList, required whenever the class has hidden children.
Definition: SoTubs.cxx:354
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::clearAlternateRep
virtual void clearAlternateRep()
We better be able to clear it, too!
Definition: SoTubs.cxx:573
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
SbMath.h
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
SoTubs::generatePrimitives
virtual void generatePrimitives(SoAction *action)
Generate Primitives, required.
Definition: SoTubs.cxx:77
RevolutionSurfaceUtil::nphiDivisions
static int nphiDivisions(const float &dphi, const float &complexity, int OverrideNPhi=0)
Definition: RevolutionSurfaceUtil.h:21
SoTubs::computeBBox
virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
compute bounding Box, required
Definition: SoTubs.cxx:360
SoTubs::alternateRep
SoSFNode alternateRep
Alternate rep - required.
Definition: SoTubs.h:85
lumiFormat.i
int i
Definition: lumiFormat.py:92
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::~SoTubs
virtual ~SoTubs()
Destructor, required.
Definition: SoTubs.cxx:62
SoTubs::initClass
static void initClass()
Class Initializer, required.
Definition: SoTubs.cxx:68
SoTubs::drawEdgeLines
SoSFBool drawEdgeLines
Definition: SoTubs.h:87
SoTubs::generateAlternateRep
virtual void generateAlternateRep()
Generate AlternateRep, required.
Definition: SoTubs.cxx:562
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
compileRPVLLRates.nf
nf
Definition: compileRPVLLRates.py:89
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
RevolutionSurfaceUtil.h
F
#define F(x, y, z)
Definition: MD5.cxx:112
python.changerun.pv
pv
Definition: changerun.py:81
SoTubs.h
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:
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