Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SoTubs.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 = std::make_unique<SoChildList>(this);
57 
58  setNodeType(EXTENSION);
59 }
60 
61 
62 //____________________________________________________________________
64 {
65  [[maybe_unused]] static const bool didInit = [&]() {
66  SO_NODE_INIT_CLASS(SoTubs,SoShape,"Shape");
67  return true;
68  }();
69 }
70 
71 // generatePrimitives
73  // This variable is used to store each vertex
74  SoPrimitiveVertex pv;
75 
76  // Access the stat from the action
77  SoState *state = action->getState();
78  if (!state)
79  return;
80 
81  // See if we have to use a texture coordinate function,
82  // rather than generating explicit texture coordinates.
83  SbBool useTexFunction=
85  SoTextureCoordinateElement::FUNCTION);
86 
87  // If we need to generate texture coordinates with a function,
88  // we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
89  // set up the coordinates directly.
90  const SoTextureCoordinateElement* tce = NULL;
91  SbVec4f texCoord;
92  if (useTexFunction) {
93  tce = SoTextureCoordinateElement::getInstance(state);
94  }
95  else {
96  texCoord[2] = 0.0;
97  texCoord[3] = 1.0;
98  }
99  SbVec3f point, normal;
100 
101 
103  //-----------------------------------------------------
104 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
105  point.setValue((float)(x),(float)(y),(float)(z)); \
106  normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
107  if (useTexFunction) { \
108  texCoord=tce->get(point,normal); \
109  } else { \
110  texCoord[0]=(float)(s); \
111  texCoord[1]=(float)(t); \
112  } \
113  pv.setPoint(point); \
114  pv.setNormal(normal); \
115  pv.setTextureCoords(texCoord); \
116  shapeVertex(&pv);
117  //-----------------------------------------------------
119 
120  int NPHI = RevolutionSurfaceUtil::nphiDivisions( pDPhi.getValue(), this->getComplexityValue(action), pOverrideNPhi.getValue() );
121 
122  double deltaPhi = pDPhi.getValue()/NPHI, phi0 = pSPhi.getValue(),phi1=phi0+pDPhi.getValue();
123  double rMax=pRMax.getValue(),rMin=pRMin.getValue();
124  double zMax=pDz.getValue(),zMin=-zMax;
125  double cosPhi0=cos(phi0), sinPhi0=sin(phi0);
126  double cosPhi1=cos(phi1), sinPhi1=sin(phi1);
127  double cosDeltaPhi=cos(deltaPhi),sinDeltaPhi=sin(deltaPhi);
128  const bool noPhiCutout=fabs(pDPhi.getValue())==0.F || fabs(fabs(pDPhi.getValue())-2.0*M_PI)<0.01; // FIXME - better way to do this?
129  const bool disableLighting(glIsEnabled(GL_LIGHTING));
130  const bool transparencyOn(glIsEnabled(GL_BLEND));
131 
132  //
133  // The outer surface!
134  //
135  int i;
136  double sinPhi,cosPhi;
137  beginShape(action,TRIANGLE_STRIP);
138  sinPhi=sinPhi0;
139  cosPhi=cosPhi0;
140  for (i = 0; i<=NPHI; i++) {
141  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);
142  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);
143  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
144  }
145  endShape();
146  //
147  // The inner surface!
148  //
149  if(rMin!=0.F) {
150  beginShape(action,TRIANGLE_STRIP);
151  sinPhi=sinPhi0;
152  cosPhi=cosPhi0;
153  for (i = 0; i<=NPHI; i++) {
154  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);
155  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);
156  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
157  }
158  endShape();
159  }
160 // if (fabs(deltaPhi)<2.0*M_PI) { // Old value - probably responsible for the funny internal stuff.
161  if (!noPhiCutout) {
162 
163  //
164  // The end - inner part of wedge
165  //
166 
167  // FIXME - Use GL_POLYGON? Tried it - no change when selecting and seemed to mess up phong-type shading.
168  // Try again, to see if it's faster?
169 
170  beginShape(action,TRIANGLE_STRIP);
171  sinPhi=sinPhi0;
172  cosPhi=cosPhi0;
173  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
174  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
175  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
176  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
177  endShape();
178  //
179  // The other end
180  //
181  beginShape(action,TRIANGLE_STRIP);
182  sinPhi=sinPhi1;
183  cosPhi=cosPhi1;
184  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
185  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
186  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
187  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
188  endShape();
189 
190  if (drawEdgeLines.getValue()) {
191  if (disableLighting) glDisable(GL_LIGHTING);
192  if (transparencyOn) glDisable(GL_BLEND);
193 
194  glBegin(GL_LINES);
195  glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMax);
196  glVertex3f(rMax*cosPhi0,rMax*sinPhi0, zMin);
197  glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMax);
198  glVertex3f(rMin*cosPhi0,rMin*sinPhi0, zMin);
199  glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMax);
200  glVertex3f(rMax*cosPhi1,rMax*sinPhi1, zMin);
201  glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMax);
202  glVertex3f(rMin*cosPhi1,rMin*sinPhi1, zMin);
203  glEnd();
204  if (disableLighting) glEnable(GL_LIGHTING);
205  if (transparencyOn) glEnable(GL_BLEND);
206  }
207 
208  }
209  //
210  // The outer surface at z=+PDZ
211  //
212  if(rMin==0.F) {
213  beginShape(action,TRIANGLE_FAN);
214  sinPhi=sinPhi0;
215  cosPhi=cosPhi0;
216  GEN_VERTEX(pv,0,0,zMax,0.0,0.0,0,0,1);
217  for (i = 0; i<=NPHI; i++) {
218  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
219  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
220  }
221  endShape();
222  //
223  // The outer surface at z=-PDZ
224  //
225  beginShape(action,TRIANGLE_FAN);
226  sinPhi=sinPhi0;
227  cosPhi=cosPhi0;
228  GEN_VERTEX(pv,0,0,zMin,0.0,0.0,0,0,-1);
229  for (i = 0; i<=NPHI; i++) {
230  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
231  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
232  }
233  endShape();
234 
235 
236  if (drawEdgeLines.getValue()) {
237  if (disableLighting) glDisable(GL_LIGHTING);
238  if (transparencyOn) glDisable(GL_BLEND);
239  glBegin(GL_LINE_STRIP);
240  sinPhi=sinPhi0;
241  cosPhi=cosPhi0;
242  if (!noPhiCutout) glVertex3f(0,0,zMax); // only draw if phi range
243  for (i = 0; i<=NPHI; i++) {
244  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
245  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
246  }
247  if (!noPhiCutout) glVertex3f(0,0,zMax);
248 
249  glEnd();
250 
251  glBegin(GL_LINE_STRIP);
252  sinPhi=sinPhi0;
253  cosPhi=cosPhi0;
254  if (!noPhiCutout) glVertex3f(0,0,zMin); // only draw if phi range
255  for (i = 0; i<=NPHI; i++) {
256  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
257  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
258  }
259  if (!noPhiCutout) glVertex3f(0,0,zMin);
260 
261  glEnd();
262 
263  if (disableLighting) glEnable(GL_LIGHTING);
264  if (transparencyOn) glEnable(GL_BLEND);
265  }
266 
267  } else {
268  beginShape(action,TRIANGLE_STRIP);
269  sinPhi=sinPhi0;
270  cosPhi=cosPhi0;
271  for (i = 0; i<=NPHI; i++) {
272  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMax,0.0,0.0,0,0,1);
273  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMax,1.0,1.0,0,0,1);
274  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
275  }
276  endShape();
277  //
278  // The outer surface at z=-PDZ
279  //
280  beginShape(action,TRIANGLE_STRIP);
281  sinPhi=sinPhi0;
282  cosPhi=cosPhi0;
283  for (i = 0; i<=NPHI; i++) {
284  GEN_VERTEX(pv,rMin*cosPhi,rMin*sinPhi,zMin,0.0,0.0,0,0,-1);
285  GEN_VERTEX(pv,rMax*cosPhi,rMax*sinPhi,zMin,1.0,1.0,0,0,-1);
286  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
287  }
288  endShape();
289 
290  if (drawEdgeLines.getValue()) {
291  if (disableLighting) glDisable(GL_LIGHTING);
292  if (transparencyOn) glDisable(GL_BLEND);
293  glBegin(GL_LINE_STRIP);
294  sinPhi=sinPhi0;
295  cosPhi=cosPhi0;
296  if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax); // only draw if phi range
297  for (i = 0; i<=NPHI; i++) {
298  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMax);
299  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
300  }
301  if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMax); // only draw if phi range
302  glEnd();
303 
304  glBegin(GL_LINE_STRIP);
305  sinPhi=sinPhi0;
306  cosPhi=cosPhi0;
307  for (i = 0; i<=NPHI; i++) {
308  glVertex3f(rMin*cosPhi,rMin*sinPhi,zMax);
309  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
310  }
311  glEnd();
312 
313  glBegin(GL_LINE_STRIP);
314  sinPhi=sinPhi0;
315  cosPhi=cosPhi0;
316  if (!noPhiCutout) glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin); // only draw if phi range
317  for (i = 0; i<=NPHI; i++) {
318  glVertex3f(rMax*cosPhi,rMax*sinPhi,zMin);
319  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
320  }
321  if (!noPhiCutout) glVertex3f(rMin*cosPhi1,rMin*sinPhi1,zMin); // only draw if phi range
322  glEnd();
323 
324  glBegin(GL_LINE_STRIP);
325  sinPhi=sinPhi0;
326  cosPhi=cosPhi0;
327  for (i = 0; i<=NPHI; i++) {
328  glVertex3f(rMin*cosPhi,rMin*sinPhi,zMin);
329  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
330  }
331  glEnd();
332 
333  if (disableLighting) glEnable(GL_LIGHTING);
334  if (transparencyOn) glEnable(GL_BLEND);
335  }
336 
337  }
338 
339  if (state&&state->isElementEnabled(SoGLCacheContextElement::getClassStackIndex())) {
340  //Encourage auto caching
341  SoGLCacheContextElement::shouldAutoCache(state, SoGLCacheContextElement::DO_AUTO_CACHE);
342 #if ((COIN_MAJOR_VERSION>=3)||((COIN_MAJOR_VERSION==2)&&(COIN_MINOR_VERSION>=5)))
343  SoGLCacheContextElement::incNumShapes(state);
344 #endif
345  }
346 }
347 
348 // getChildren
349 SoChildList *SoTubs::getChildren() const {
350  return m_children.get();
351 }
352 
353 
354 // computeBBox
355 void SoTubs::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
356  RevolutionSurfaceUtil::setBBoxPars(pSPhi.getValue(), pDPhi.getValue(),
357  pRMin.getValue(), pRMax.getValue(),
358  -pDz.getValue(),pDz.getValue(),
359  box, center );
360 }
361 
362 
363 // updateChildren
365 
366  // Redraw the G4Tubs....
367 
368  assert(m_children->getLength()==1);
369  SoSeparator *sep = (SoSeparator *) ( *m_children)[0];
370  SoCoordinate3 *theCoordinates = (SoCoordinate3 *) ( sep->getChild(0));
371  SoNormal *theNormals = (SoNormal *) ( sep->getChild(1));
372  SoNormalBinding *theNormalBinding = (SoNormalBinding *) ( sep->getChild(2));
373  SoIndexedFaceSet *theFaceSet = (SoIndexedFaceSet *) ( sep->getChild(3));
374 
375 
376  const int NPHI=96, NPOINTS=2*(2*NPHI+2), NFACES=4*NPHI+2, NINDICES = NFACES*5;
377  float points[NPOINTS][3],normals[NFACES][3];
378 #ifdef INVENTOR2_0
379  static long indices[NINDICES];
380 #else
381  static int32_t indices[NINDICES];
382 #endif
383 
384  static int init=0;
385  double phi, pp, DeltaPhi;
386 
387  // Indices need to be generated once! This is here to keep it close to the point
388  // generation, since otherwise it will be confusing.
389 
390  int i;
391  if (!init) {
392  init = 1;
393  // Outer face
394  for (i = 0; i< NPHI; i++) {
395  // 0 1 3 2;
396  indices[5*i+0] = 2*i+0;
397  indices[5*i+1] = 2*i+1;
398  indices[5*i+2] = 2*i+3;
399  indices[5*i+3] = 2*i+2;
400  indices[5*i+4] = SO_END_FACE_INDEX;
401  }
402  // the inner face
403  for (i=0;i<NPHI;i++) {
404  indices[5*1*NPHI + 5*i+0] = 2*NPHI+2 + 2*i+0;
405  indices[5*1*NPHI + 5*i+1] = 2*NPHI+2 + 2*i+1;
406  indices[5*1*NPHI + 5*i+2] = 2*NPHI+2 + 2*i+3;
407  indices[5*1*NPHI + 5*i+3] = 2*NPHI+2 + 2*i+2;
408  indices[5*1*NPHI + 5*i+4] = SO_END_FACE_INDEX;
409  }
410  // the top side
411  for (i=0;i<NPHI;i++) {
412  indices[5*2*NPHI + 5*i+0] = 2*i+0;
413  indices[5*2*NPHI + 5*i+1] = 2*i+2;
414  indices[5*2*NPHI + 5*i+2] = NPOINTS - (2*i+4);
415  indices[5*2*NPHI + 5*i+3] = NPOINTS - (2*i+2);
416  indices[5*2*NPHI + 5*i+4] = SO_END_FACE_INDEX;
417  }
418  // the bottom side
419  for (i=0;i<NPHI;i++) {
420  indices[5*3*NPHI + 5*i+0] = 2*i+1;
421  indices[5*3*NPHI + 5*i+1] = NPOINTS - (2*i+1);
422  indices[5*3*NPHI + 5*i+2] = NPOINTS - (2*i+3);
423  indices[5*3*NPHI + 5*i+3] = 2*i+3;
424  indices[5*3*NPHI + 5*i+4] = SO_END_FACE_INDEX;
425  }
426  // the odd side
427  indices[5*4*NPHI +0] = 2*NPHI;
428  indices[5*4*NPHI +1] = 2*NPHI+1;
429  indices[5*4*NPHI +2] = 2*NPHI+3;
430  indices[5*4*NPHI +3] = 2*NPHI+2;
431  indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
432  // aother odd side
433  indices[5*4*NPHI +5 +0] = 0;
434  indices[5*4*NPHI +5 +1] = NPOINTS-2;
435  indices[5*4*NPHI +5 +2] = NPOINTS-1;
436  indices[5*4*NPHI +5 +3] = 1;
437  indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
438  }
439  // Points need to be generated each time:
440  if (pDPhi.getValue()<2*M_PI) {
441  // the odd side
442  indices[5*4*NPHI +0] = 2*NPHI;
443  indices[5*4*NPHI +1] = 2*NPHI+1;
444  indices[5*4*NPHI +2] = 2*NPHI+3;
445  indices[5*4*NPHI +3] = 2*NPHI+2;
446  indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
447  // aother odd side
448  indices[5*4*NPHI +5 +0] = 0;
449  indices[5*4*NPHI +5 +1] = NPOINTS-2;
450  indices[5*4*NPHI +5 +2] = NPOINTS-1;
451  indices[5*4*NPHI +5 +3] = 1;
452  indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
453  }
454  else {
455  // the odd side
456  indices[5*4*NPHI +0] = SO_END_FACE_INDEX;
457  indices[5*4*NPHI +1] = SO_END_FACE_INDEX;
458  indices[5*4*NPHI +2] = SO_END_FACE_INDEX;
459  indices[5*4*NPHI +3] = SO_END_FACE_INDEX;
460  indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
461  // aother odd side
462  indices[5*4*NPHI +5 +0] = SO_END_FACE_INDEX;
463  indices[5*4*NPHI +5 +1] = SO_END_FACE_INDEX;
464  indices[5*4*NPHI +5 +2] = SO_END_FACE_INDEX;
465  indices[5*4*NPHI +5 +3] = SO_END_FACE_INDEX;
466  indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
467  }
468  // The outer surface
469  DeltaPhi = pDPhi.getValue()/NPHI, phi = pSPhi.getValue();
470  for (i = 0; i<=NPHI; i++) {
471  points[2*i+0][0] = pRMax.getValue()*FCOS(phi);
472  points[2*i+0][1]= pRMax.getValue()*FSIN(phi);
473  points[2*i+0][2] = +pDz.getValue();
474 
475  points[2*i+1][0] = pRMax.getValue()*FCOS(phi);
476  points[2*i+1][1]= pRMax.getValue()*FSIN(phi);
477  points[2*i+1][2] = -pDz.getValue();
478 
479  pp = phi+DeltaPhi/2.0;
480  if (i!=NPHI) {
481  normals[i][0] = FCOS(pp);
482  normals[i][1] = FSIN(pp);
483  normals[i][2] = 0;
484  }
485  phi+=DeltaPhi;
486  }
487  // The inner surface
488  phi = pSPhi.getValue() + pDPhi.getValue();
489  for (i = 0; i<=NPHI; i++) {
490  points[2*NPHI+2+2*i+0][0] = pRMin.getValue()*FCOS(phi);
491  points[2*NPHI+2+2*i+0][1] = pRMin.getValue()*FSIN(phi);
492  points[2*NPHI+2+2*i+0][2] = +pDz.getValue();
493  points[2*NPHI+2+2*i+1][0] = pRMin.getValue()*FCOS(phi);
494  points[2*NPHI+2+2*i+1][1] = pRMin.getValue()*FSIN(phi);
495  points[2*NPHI+2+2*i+1][2] = -pDz.getValue();
496  pp = phi-DeltaPhi/2.0;
497  if (i!=NPHI) {
498  normals[NPHI+i][0] = -FCOS(pp);
499  normals[NPHI+i][1] = -FSIN(pp);
500  normals[NPHI+i][2] = 0;
501  }
502  phi-=DeltaPhi;
503  }
504  // The top side
505  for (i=0;i<NPHI;i++) {
506  normals[2*NPHI+i][0]=normals[2*NPHI+i][1]=0;
507  normals[2*NPHI+i][2]= 1.0;
508  }
509  // The bottom side
510  for (i=0;i<NPHI;i++) {
511  normals[3*NPHI+i][0]=normals[3*NPHI+i][1]=0;
512  normals[3*NPHI+i][2]= -1.0;
513  }
514  // The odd side
515  phi = pSPhi.getValue();
516  normals[4*NPHI+0][0]= FSIN(phi);
517  normals[4*NPHI+0][1]= -FCOS(phi);
518  normals[4*NPHI+0][2]=0;
519 
520  // Another odd side
521  phi = pSPhi.getValue()+pDPhi.getValue();
522  normals[4*NPHI+1][0]= -FSIN(phi);
523  normals[4*NPHI+1][1]= +FCOS(phi);
524  normals[4*NPHI+1][2]=0;
525 
526  for (int np=0;np<NPOINTS; np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
527  for (int ni=0;ni<NINDICES;ni++) theFaceSet->coordIndex.set1Value(ni,indices[ni]);
528  for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
529  theNormalBinding->value=SoNormalBinding::PER_FACE;
530 }
531 
532 // generateChildren
534 
535  // This routines creates one SoSeparator, one SoCoordinate3, and
536  // one SoLineSet, and puts it in the child list. This is done only
537  // once, whereas redrawing the position of the coordinates occurs each
538  // time an update is necessary, in the updateChildren routine.
539 
540  assert(m_children->getLength() ==0);
541  SoSeparator *sep = new SoSeparator();
542  SoCoordinate3 *theCoordinates = new SoCoordinate3();
543  SoNormal *theNormals = new SoNormal();
544  SoNormalBinding *theNormalBinding = new SoNormalBinding();
545  SoIndexedFaceSet *theFaceSet = new SoIndexedFaceSet();
546  //
547  // This line costs some in render quality! but gives speed.
548  //
549  sep->addChild(theCoordinates);
550  sep->addChild(theNormals);
551  sep->addChild(theNormalBinding);
552  sep->addChild(theFaceSet);
553  m_children->append(sep);
554 }
555 
556 // generateAlternateRep
558 
559  // This routine sets the alternate representation to the child
560  // list of this mode.
561 
562  if (m_children->getLength() == 0) generateChildren();
563  updateChildren();
564  alternateRep.setValue((SoSeparator *) ( *m_children)[0]);
565 }
566 
567 // clearAlternateRep
569  alternateRep.setValue(NULL);
570 }
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:364
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:349
SoTubs
SoTubs - Inventor version of the G4Tubs Geant Geometry entity.
Definition: SoTubs.h:52
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:568
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:154
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::m_children
std::unique_ptr< SoChildList > m_children
ChildList. Required whenever the class has hidden children.
Definition: SoTubs.h:149
SoTubs::generatePrimitives
virtual void generatePrimitives(SoAction *action)
Generate Primitives, required.
Definition: SoTubs.cxx:72
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:355
SoTubs::alternateRep
SoSFNode alternateRep
Alternate rep - required.
Definition: SoTubs.h:87
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::initClass
static void initClass()
Class Initializer, required.
Definition: SoTubs.cxx:63
SoTubs::drawEdgeLines
SoSFBool drawEdgeLines
Definition: SoTubs.h:89
SoTubs::generateAlternateRep
virtual void generateAlternateRep()
Generate AlternateRep, required.
Definition: SoTubs.cxx:557
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:78
SoTubs::pOverrideNPhi
SoSFInt32 pOverrideNPhi
Override number of phi subdivision used for rendering shape (i.e.
Definition: SoTubs.h:83
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
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:70
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::generateChildren
void generateChildren()
Generate Children.
Definition: SoTubs.cxx:533
SoTubs::pRMin
SoSFFloat pRMin
Inside radius of the tube.
Definition: SoTubs.h:62
SoTubs::pRMax
SoSFFloat pRMax
Outside radius of the tube.
Definition: SoTubs.h:66
SoTubs::pSPhi
SoSFFloat pSPhi
Starting angle, in radians.
Definition: SoTubs.h:74