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

SoPcons - Inventor version of the G4Cons Geant Geometry entity. More...

#include <SoPcons.h>

Inheritance diagram for SoPcons:
Collaboration diagram for SoPcons:

Public Member Functions

 SoPcons ()
 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

SoMFFloat fRmin
 Inside radii. More...
 
SoMFFloat fRmax
 Outside radii. More...
 
SoMFFloat fDz
 Z Positions. More...
 
SoSFFloat fSPhi
 Starting angle, in radians. More...
 
SoSFFloat fDPhi
 Delta-angle, in radians. More...
 
SoSFBool smoothDraw
 An Inventor option - slightly better render, worse performance. More...
 
SoSFInt32 pOverrideNPhi
 Override number of phi subdivision used for rendering shape (i.e. More...
 
SoSFNode alternateRep
 Alternate rep required - for use by users without HEPVis shared objects. 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 ~SoPcons ()
 Destructor, required. More...
 

Private Member Functions

 SO_NODE_HEADER (SoPcons)
 
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

SoPcons - Inventor version of the G4Cons Geant Geometry entity.

Node: SoPcons

Description: The Inventor version of the G4Cons Geant Geometry entity

Author: Joe Boudreau Nov 2004

Definition at line 39 of file SoPcons.h.

Constructor & Destructor Documentation

◆ SoPcons()

SoPcons::SoPcons ( )

Constructor, required.

Definition at line 38 of file SoPcons.cxx.

38  {
39  // This statement is required
40  SO_NODE_CONSTRUCTOR(SoPcons);
41 
42  // Data fields are initialized like this:
43  SO_NODE_ADD_FIELD(fRmin, (0.0));
44  SO_NODE_ADD_FIELD(fRmax, (0.0));
45  SO_NODE_ADD_FIELD(fDz, (0.0));
46  SO_NODE_ADD_FIELD(fSPhi, (0.0));
47  SO_NODE_ADD_FIELD(fDPhi, ((float)(2*M_PI)));
48  SO_NODE_ADD_FIELD(smoothDraw, (TRUE));
49  SO_NODE_ADD_FIELD(pOverrideNPhi, (0));
50  SO_NODE_ADD_FIELD(alternateRep, (NULL));
51  SO_NODE_ADD_FIELD(drawEdgeLines, (false));
52 
53  m_children = new SoChildList(this);
54 
55  float rMinDef[]={10.0, 15.0, 10.0};
56  float rMaxDef[]={11.0, 17.0, 12.0};
57  float zDef []={-10.0, 0.0, 10.0};
58 
59  fRmin.setValues(0,2,rMinDef);
60  fRmax.setValues(0,2,rMaxDef);
61  fDz.setValues(0,2,zDef);
62  setNodeType(EXTENSION);
63 }

◆ ~SoPcons()

SoPcons::~SoPcons ( )
protectedvirtual

Destructor, required.

Definition at line 66 of file SoPcons.cxx.

66  {
67  delete m_children;
68 }

Member Function Documentation

◆ clearAlternateRep()

void SoPcons::clearAlternateRep ( )
virtual

We better be able to clear it, too!

Definition at line 833 of file SoPcons.cxx.

833  {
834  alternateRep.setValue(NULL);
835 }

◆ computeBBox()

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

compute bounding Box, required

Definition at line 355 of file SoPcons.cxx.

355  {
356  if (fRmax.getNum()< 2) return;
357  if (fRmin.getNum()< 2) return;
358  if (fDz.getNum() < 2) return;
359 
360  double MinMin = fRmin[0];
361  double MaxMax = fRmax[0];
362 
363  double ZMin = fDz[0];
364  double ZMax = fDz[0];
365 
366 
367  for (int i=1;i<fRmin.getNum();++i) {
368  if (fRmin[i]<MinMin) MinMin=fRmin[i];
369  }
370 
371  for (int i=1;i<fRmax.getNum();++i) {
372  if (fRmax[i]>MaxMax) MaxMax=fRmax[i];
373  }
374 
375  for (int i=1;i<fDz.getNum();++i) {
376  if (fDz[i]>ZMax) ZMax=fDz[i];
377  if (fDz[i]<ZMin) ZMin=fDz[i];
378  }
379 
380  RevolutionSurfaceUtil::setBBoxPars(fSPhi.getValue(), fDPhi.getValue(),
381  MinMin, MaxMax,
382  ZMin,ZMax,
383  box, center );
384 }

◆ generateAlternateRep()

void SoPcons::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 581 of file SoPcons.cxx.

581  {
582 
583  // This routine sets the alternate representation to the child
584  // list of this mode.
585 
586  //if (m_children->getLength() == 0) generateChildren();
587  //updateChildren();
588  // alternateRep.setValue((SoSeparator *) ( *m_children)[0]);
589 
590 
591  /* updated for generate fullfill alternaterep
592  ***********************************************
593  As First we collect point and triangle strip
594  bounds same as in draw function.
595  there is copied draw function contents and
596  replased unused part;
597 
598  Source code was taked from render part, and modified
599  for collect nessesary information, and build alternate
600  geometry.
601  **********************************************
602  */
603  const int NPHI = 96;
604 
605  // This variable is used to store each vertex
606  SoPrimitiveVertex pv;
607 
608  //For collect points in Pcon geometry chunk
609  std::vector<SoPrimitiveVertex> vls; //Vertex List
610 
611  //For collect all triangles
612  std::vector<SoPrimitiveVertex> fls; //Face list. face here is qudrangle
613 
614  // See if we have to use a texture coordinate function,
615  // rather than generating explicit texture coordinates.
616 
617  SbVec4f texCoord;
618  texCoord[2] = 0.0;
619  texCoord[3] = 1.0;
620  SbVec3f point, normal;
621 
623  //-----------------------------------------------------
624 #define N_GEN_VERTEX(ls, pv,x,y,z,s,t,nx,ny,nz) \
625  point.setValue((float)(x),(float)(y),(float)(z)); \
626  normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
627  texCoord[0]=(float)(s); \
628  texCoord[1]=(float)(t); \
629  pv.setPoint(point); \
630  pv.setNormal(normal); \
631  pv.setTextureCoords(texCoord); \
632  ls.push_back(pv);
633  //-----------------------------------------------------
635  if (fRmin.getNum()!=fRmax.getNum() || fRmax.getNum() != fDz.getNum()) {
636  return;
637  }
638 
639  int nSeg = fRmin.getNum()-1;
640  if (nSeg<1) {
641  return;
642  }
643 
644  for (int p=0;p<nSeg;p++) {
645 
646  double rMin1= fRmin[p];
647  double rMin2= fRmin[p+1];
648 
649  double rMax1= fRmax[p];
650  double rMax2= fRmax[p+1];
651 
652  double zMin = fDz[p];
653  double zMax= fDz[p+1];
654 
655  double deltaPhi = fDPhi.getValue()/NPHI;
656  double phi0 = fSPhi.getValue();
657  double phi1 = phi0 + fDPhi.getValue();
658  double cosPhi0 = cos(phi0);
659  double sinPhi0 = sin(phi0);
660  double cosPhi1 = cos(phi1);
661  double sinPhi1 = sin(phi1);
662  double cosDeltaPhi = cos(deltaPhi);
663  double sinDeltaPhi = sin(deltaPhi);
664 
665  int i;
666  double sinPhi;
667  double cosPhi;
668 
669  const bool noPhiCutout=fabs(fDPhi.getValue())==0.F || fabs(fabs(fDPhi.getValue())-2.0*M_PI)<0.01; // FIXME - better way to do this?
670 
671  //
672  // The outer surface!
673  //
674  double dR =rMax2-rMax1;
675  double dZ =zMax-zMin;
676  double cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
677  double sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
678 
679  sinPhi=sinPhi0;
680  cosPhi=cosPhi0;
681  for (i = 0; i<=NPHI; i++) {
682  N_GEN_VERTEX(vls,pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
683  N_GEN_VERTEX(vls,pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinTheta*cosPhi,sinTheta*sinPhi,cosTheta);
684  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
685  }
686 
687  for(i = 0; i < ((int)vls.size() - 2); i += 2){
688  fls.push_back(vls[i + 0]);
689  fls.push_back(vls[i + 1]);
690  fls.push_back(vls[i + 3]);
691  fls.push_back(vls[i + 2]);
692  }
693  vls.clear();
694 
695  //
696  // The inner surface!
697  //
698  sinPhi=sinPhi0;
699  cosPhi=cosPhi0;
700 
701  dR =rMin2-rMin1;
702  dZ =zMax-zMin;
703  cosTheta = -dR/sqrt(dR*dR+dZ*dZ);
704  sinTheta = dZ/sqrt(dR*dR+dZ*dZ);
705 
706  for (i = 0; i<=NPHI; i++) {
707  N_GEN_VERTEX(vls,pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,-cosPhi*sinTheta,-sinPhi*sinTheta,-cosTheta);
708  N_GEN_VERTEX(vls,pv,rMin1*cosPhi,rMin1*sinPhi,zMin,1.0,1.0,-cosPhi*sinTheta,-sinPhi*sinTheta,-cosTheta);
709  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
710  }
711  for(i = 0; i < ((int)vls.size() - 2); i += 2){
712  fls.push_back(vls[i + 1]);
713  fls.push_back(vls[i + 0]);
714  fls.push_back(vls[i + 2]);
715  fls.push_back(vls[i + 3]);
716  }
717  vls.clear();
718 
719 
720  if (!noPhiCutout) {
721  //
722  // The end
723  //
724  sinPhi=sinPhi0;
725  cosPhi=cosPhi0;
726  N_GEN_VERTEX(vls, pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
727  N_GEN_VERTEX(vls, pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
728  N_GEN_VERTEX(vls, pv,rMin2*cosPhi,rMin2*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
729  N_GEN_VERTEX(vls, pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
730  fls.push_back(vls[1]);
731  fls.push_back(vls[0]);
732  fls.push_back(vls[2]);
733  fls.push_back(vls[3]);
734  vls.clear();
735 
736  //
737  // The other end
738  //
739  sinPhi=sinPhi1;
740  cosPhi=cosPhi1;
741  N_GEN_VERTEX(vls, pv,rMax2*cosPhi,rMax2*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
742  N_GEN_VERTEX(vls, pv,rMax1*cosPhi,rMax1*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
743  N_GEN_VERTEX(vls, pv,rMin2*cosPhi,rMin2*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
744  N_GEN_VERTEX(vls, pv,rMin1*cosPhi,rMin1*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
745  fls.push_back(vls[0]);
746  fls.push_back(vls[1]);
747  fls.push_back(vls[3]);
748  fls.push_back(vls[2]);
749  vls.clear();
750  }
751  if (p==(nSeg-1)) {
752  //
753  // The outer surface at z=+PDZ
754  //
755  sinPhi=sinPhi0;
756  cosPhi=cosPhi0;
757  for (i = 0; i<=NPHI; i++) {
758  N_GEN_VERTEX(vls, pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,0,0,1);
759  N_GEN_VERTEX(vls, pv,rMax2*cosPhi,rMax2*sinPhi,zMax,1.0,1.0,0,0,1);
760  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
761  }
762  for(i = 0; i < ((int)vls.size() - 2); i += 2){
763  fls.push_back(vls[i + 0]);
764  fls.push_back(vls[i + 1]);
765  fls.push_back(vls[i + 3]);
766  fls.push_back(vls[i + 2]);
767  }
768  vls.clear();
769  }
770  if (p==0) {
771  //
772  // The outer surface at z=-PDZ
773  //
774  sinPhi=sinPhi0;
775  cosPhi=cosPhi0;
776  for (i = 0; i<=NPHI; i++) {
777  N_GEN_VERTEX(vls, pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,0.0,0,0,-1);
778  N_GEN_VERTEX(vls, pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,0,0,-1);
779  inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
780  }
781  for(i = 0; i < ((int)vls.size() - 2); i += 2){
782  fls.push_back(vls[i + 1]);
783  fls.push_back(vls[i + 0]);
784  fls.push_back(vls[i + 2]);
785  fls.push_back(vls[i + 3]);
786  }
787  vls.clear();
788  }
789  }
790  /*
791  *********************************************
792  After finish colecting points of quadrangles,
793  must be builded one monolit geometry,
794  with indexed triangles
795  *********************************************
796  */
797  int numFaces = fls.size() / 4; //Becouse used quadrangular primitives
798  if(numFaces < 0)
799  numFaces = 0;
800 
801  SoVertexProperty *vertices = new SoVertexProperty();
802  for(int i = 0; i < (int)fls.size(); i++){
803  vertices->vertex.set1Value (i, fls[i].getPoint()[0],
804  fls[i].getPoint()[1],
805  fls[i].getPoint()[2]);
806  }
807  fls.clear(); //clearing collected vertices
808 
809  int* faces = new int[5 * numFaces];
810  fprintf(stderr, "\nallocate Faces: %i", numFaces);
811  for(int i = 0; i < numFaces; i++){
812  faces[5 * i] = 4 * i;
813  faces[5 * i + 1] = 4 * i + 1;
814  faces[5 * i + 2] = 4 * i + 2;
815  faces[5 * i + 3] = 4 * i + 3;
816  faces[5 * i + 4] = -1;
817  }
818 
819  SoIndexedFaceSet * faceset = new SoIndexedFaceSet;
820  faceset->coordIndex.setValues(0, 5 * numFaces, faces);
821  delete [] faces;
822  faceset->vertexProperty = vertices;
823  alternateRep.setValue(faceset);
824  fprintf(stderr, "\n");
825  /*
826  *********************************************
827  Finish
828  *********************************************
829  */
830 }

◆ generateChildren()

void SoPcons::generateChildren ( )
private

Generate Children.

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

Definition at line 551 of file SoPcons.cxx.

551  {
552 #ifdef IMPLEMENTED
553  // (Not implemented so you do not get an alternate rep. Too bad.)
554 
555 
556  // This routines creates one SoSeparator, one SoCoordinate3, and
557  // one SoLineSet, and puts it in the child list. This is done only
558  // once, whereas redrawing the position of the coordinates occurs each
559  // time an update is necessary, in the updateChildren routine.
560 
561  assert(m_children->getLength() ==0);
562  SoSeparator *sep = new SoSeparator();
563  SoCoordinate3 *theCoordinates = new SoCoordinate3();
564  SoNormal *theNormals = new SoNormal();
565  SoNormalBinding *theNormalBinding = new SoNormalBinding();
566  SoIndexedFaceSet *theFaceSet = new SoIndexedFaceSet();
567  //
568  // This line costs some in render quality! but gives speed.
569  //
570  sep->addChild(theCoordinates);
571  sep->addChild(theNormals);
572  sep->addChild(theNormalBinding);
573  sep->addChild(theFaceSet);
574  m_children->append(sep);
575 #endif
576 }

◆ generatePrimitives()

void SoPcons::generatePrimitives ( SoAction *  action)
protectedvirtual

Generate Primitives, required.

Definition at line 81 of file SoPcons.cxx.

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

◆ getChildren()

SoChildList * SoPcons::getChildren ( ) const
protectedvirtual

GetChildList, required whenever the class has hidden children.

Definition at line 349 of file SoPcons.cxx.

349  {
350  return m_children;
351 }

◆ inc()

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

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

Definition at line 152 of file SoPcons.h.

152  {
153  double oldSin=sinPhi,oldCos=cosPhi;
154  sinPhi = oldSin*cosDeltaPhi+oldCos*sinDeltaPhi;
155  cosPhi = oldCos*cosDeltaPhi-oldSin*sinDeltaPhi;
156  }

◆ initClass()

void SoPcons::initClass ( )
static

Class Initializer, required.

Definition at line 72 of file SoPcons.cxx.

73 {
74  [[maybe_unused]] static const bool didInit = [&]() {
75  SO_NODE_INIT_CLASS(SoPcons,SoShape,"Shape");
76  return true;
77  }();
78 }

◆ SO_NODE_HEADER()

SoPcons::SO_NODE_HEADER ( SoPcons  )
private

◆ updateChildren()

void SoPcons::updateChildren ( )
private

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

Required whenever the class has hidden children.

Definition at line 390 of file SoPcons.cxx.

390  {
391 
392 #ifdef IMPLEMENTED
393 
394  // (Not implemented so you do not get an alternate rep. Too bad.)
395 
396  // Redraw the G4Pcons....
397 
398  assert(m_children->getLength()==1);
399  SoSeparator *sep = (SoSeparator *) ( *m_children)[0];
400  SoCoordinate3 *theCoordinates = (SoCoordinate3 *) ( sep->getChild(0));
401  SoNormal *theNormals = (SoNormal *) ( sep->getChild(1));
402  SoNormalBinding *theNormalBinding = (SoNormalBinding *) ( sep->getChild(2));
403  SoIndexedFaceSet *theFaceSet = (SoIndexedFaceSet *) ( sep->getChild(3));
404 
405  const int NPHI=96, NPOINTS=2*(2*NPHI+2), NFACES=4*NPHI+2, NINDICES = NFACES*5;
406  float points[NPOINTS][3], normals[NFACES][3];
407 #ifdef INVENTOR2_0
408  static long indices[NINDICES];
409 #else
410  static int32_t indices[NINDICES];
411 #endif
412  static int init=0;
413  double phi, pp, DeltaPhi;
414 
415  double fRmax1,
416  fRmax2,
417  fRMin1,
418  fRmin2;
419  // Indices need to be generated once! This is here to keep it close to the point
420  // generation, since otherwise it will be confusing.
421 
422  int i;
423  if (!init) {
424  init = 1;
425  // Outer face
426  for (i = 0; i< NPHI; i++) {
427  // 0 1 3 2;
428  indices[5*i+0] = 2*i+0;
429  indices[5*i+1] = 2*i+1;
430  indices[5*i+2] = 2*i+3;
431  indices[5*i+3] = 2*i+2;
432  indices[5*i+4] = SO_END_FACE_INDEX;
433  }
434  // the inner face
435  for (i=0;i<NPHI;i++) {
436  indices[5*1*NPHI + 5*i+0] = 2*NPHI+2 + 2*i+0;
437  indices[5*1*NPHI + 5*i+1] = 2*NPHI+2 + 2*i+1;
438  indices[5*1*NPHI + 5*i+2] = 2*NPHI+2 + 2*i+3;
439  indices[5*1*NPHI + 5*i+3] = 2*NPHI+2 + 2*i+2;
440  indices[5*1*NPHI + 5*i+4] = SO_END_FACE_INDEX;
441  }
442  // the top side
443  for (i=0;i<NPHI;i++) {
444  indices[5*2*NPHI + 5*i+0] = 2*i+0;
445  indices[5*2*NPHI + 5*i+1] = 2*i+2;
446  indices[5*2*NPHI + 5*i+2] = NPOINTS - (2*i+4);
447  indices[5*2*NPHI + 5*i+3] = NPOINTS - (2*i+2);
448  indices[5*2*NPHI + 5*i+4] = SO_END_FACE_INDEX;
449  }
450  // the bottom side
451  for (i=0;i<NPHI;i++) {
452  indices[5*3*NPHI + 5*i+0] = 2*i+1;
453  indices[5*3*NPHI + 5*i+1] = NPOINTS - (2*i+1);
454  indices[5*3*NPHI + 5*i+2] = NPOINTS - (2*i+3);
455  indices[5*3*NPHI + 5*i+3] = 2*i+3;
456  indices[5*3*NPHI + 5*i+4] = SO_END_FACE_INDEX;
457  }
458  // the odd side
459  indices[5*4*NPHI +0] = 2*NPHI;
460  indices[5*4*NPHI +1] = 2*NPHI+1;
461  indices[5*4*NPHI +2] = 2*NPHI+3;
462  indices[5*4*NPHI +3] = 2*NPHI+2;
463  indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
464  // aother odd side
465  indices[5*4*NPHI +5 +0] = 0;
466  indices[5*4*NPHI +5 +1] = NPOINTS-2;
467  indices[5*4*NPHI +5 +2] = NPOINTS-1;
468  indices[5*4*NPHI +5 +3] = 1;
469  indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
470  }
471  // Points need to be generated each time:
472  // The outer surface
473  DeltaPhi = fDPhi.getValue()/NPHI, phi = fSPhi.getValue();
474  float t,st,ct;
475  t = FATAN((fRmax2.getValue()-fRmax1.getValue())/(2*fDz.getValue()));
476  st = FSIN(t);
477  ct = FCOS(t);
478  for (i = 0; i<=NPHI; i++) {
479  points[2*i+0][0] = fRmax2.getValue()*FCOS(phi);
480  points[2*i+0][1] = fRmax2.getValue()*FSIN(phi);
481  points[2*i+0][2] = +fDz.getValue();
482  points[2*i+1][0] = fRmax1.getValue()*FCOS(phi);
483  points[2*i+1][1] = fRmax1.getValue()*FSIN(phi);
484  points[2*i+1][2] = -fDz.getValue();
485  pp = phi+DeltaPhi/2.0;
486  if (i!=NPHI) {
487  normals[i][0] = ct * FCOS(pp);
488  normals[i][1] = ct * FSIN(pp);
489  normals[i][2] = -st;
490  }
491  phi+=DeltaPhi;
492  }
493  // The inner surface
494  phi = fSPhi.getValue() + fDPhi.getValue();
495  t = FATAN((fRmin2.getValue()-fRmin1.getValue())/(2*fDz.getValue()));
496  st = FSIN(t);
497  ct = FCOS(t);
498  for (i = 0; i<=NPHI; i++) {
499  points[2*NPHI+2+2*i+0][0] = fRmin2.getValue()*FCOS(phi);
500  points[2*NPHI+2+2*i+0][1] = fRmin2.getValue()*FSIN(phi);
501  points[2*NPHI+2+2*i+0][2] = +fDz.getValue();
502  points[2*NPHI+2+2*i+1][0] = fRmin1.getValue()*FCOS(phi);
503  points[2*NPHI+2+2*i+1][1] = fRmin1.getValue()*FSIN(phi);
504  points[2*NPHI+2+2*i+1][2] = -fDz.getValue();
505  pp = phi-DeltaPhi/2.0;
506  if (i!=NPHI) {
507  normals[NPHI+i][0] = -ct*FCOS(pp);
508  normals[NPHI+i][1] = -ct*FSIN(pp);
509  normals[NPHI+i][2] = st;
510  }
511  phi-=DeltaPhi;
512  }
513  // The top side
514  for (i=0;i<NPHI;i++) {
515  normals[2*NPHI+i][0]=normals[2*NPHI+i][1]=0;
516  normals[2*NPHI+i][2]= 1.0;
517  }
518  // The bottom side
519  for (i=0;i<NPHI;i++) {
520  normals[3*NPHI+i][0]=normals[3*NPHI+i][1]=0;
521  normals[3*NPHI+i][2]= -1.0;
522  }
523  // The odd side
524  phi = fSPhi.getValue();
525  normals[4*NPHI+0][0]= FSIN(phi);
526  normals[4*NPHI+0][1]= -FCOS(phi);
527  normals[4*NPHI+0][2]= 0;
528 
529  // Another odd side
530  phi = fSPhi.getValue()+fDPhi.getValue();
531  normals[4*NPHI+1][0]= -FSIN(phi);
532  normals[4*NPHI+1][1]= +FCOS(phi);
533  normals[4*NPHI+1][2]=0;
534 
535  for (int np=0;np<NPOINTS;np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
536  theFaceSet->coordIndex.setValues(0,NINDICES,indices);
537  if (smoothDraw.getValue()) {
538  // This Line is replaced by the next one because of an apparent Bug in Inventor (mem. leak).
539  // theNormals->vector.deleteValues(0);
540  for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
541  theNormalBinding->value=SoNormalBinding::PER_FACE;
542  }
543  else {
544  for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
545  theNormalBinding->value=SoNormalBinding::PER_FACE;
546  }
547 #endif
548 }

Member Data Documentation

◆ alternateRep

SoSFNode SoPcons::alternateRep

Alternate rep required - for use by users without HEPVis shared objects.

Definition at line 78 of file SoPcons.h.

◆ drawEdgeLines

SoSFBool SoPcons::drawEdgeLines

Definition at line 80 of file SoPcons.h.

◆ fDPhi

SoSFFloat SoPcons::fDPhi

Delta-angle, in radians.

Definition at line 65 of file SoPcons.h.

◆ fDz

SoMFFloat SoPcons::fDz

Z Positions.

Definition at line 57 of file SoPcons.h.

◆ fRmax

SoMFFloat SoPcons::fRmax

Outside radii.

Definition at line 53 of file SoPcons.h.

◆ fRmin

SoMFFloat SoPcons::fRmin

Inside radii.

Definition at line 49 of file SoPcons.h.

◆ fSPhi

SoSFFloat SoPcons::fSPhi

Starting angle, in radians.

Definition at line 61 of file SoPcons.h.

◆ m_children

SoChildList* SoPcons::m_children
private

ChildList. Required whenever the class has hidden children.

Definition at line 147 of file SoPcons.h.

◆ pOverrideNPhi

SoSFInt32 SoPcons::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 74 of file SoPcons.h.

◆ smoothDraw

SoSFBool SoPcons::smoothDraw

An Inventor option - slightly better render, worse performance.

Definition at line 69 of file SoPcons.h.


The documentation for this class was generated from the following files:
FATAN
#define FATAN(x)
Definition: SbMath.h:18
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SoPcons
SoPcons - Inventor version of the G4Cons Geant Geometry entity.
Definition: SoPcons.h:39
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
FCOS
#define FCOS(x)
Definition: SbMath.h:13
SoPcons::smoothDraw
SoSFBool smoothDraw
An Inventor option - slightly better render, worse performance.
Definition: SoPcons.h:69
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
SoPcons::inc
void inc(double &sinPhi, double &cosPhi, double sinDeltaPhi, double cosDeltaPhi) const
help with trigonometry. increments sines an cosines by an angle.
Definition: SoPcons.h:152
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
InDetAccessor::phi0
@ phi0
Definition: InDetAccessor.h:33
M_PI
#define M_PI
Definition: ActiveFraction.h:11
SoPcons::m_children
SoChildList * m_children
ChildList. Required whenever the class has hidden children.
Definition: SoPcons.h:147
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
SoPcons::fSPhi
SoSFFloat fSPhi
Starting angle, in radians.
Definition: SoPcons.h:61
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
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
SoPcons::fDz
SoMFFloat fDz
Z Positions.
Definition: SoPcons.h:57
SoPcons::fRmax
SoMFFloat fRmax
Outside radii.
Definition: SoPcons.h:53
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
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
python.Constants.TRUE
bool TRUE
for job options legacy (TODO: get rid of these!) ----------------------—
Definition: Control/AthenaCommon/python/Constants.py:22
SoPcons::fRmin
SoMFFloat fRmin
Inside radii.
Definition: SoPcons.h:49
SoPcons::alternateRep
SoSFNode alternateRep
Alternate rep required - for use by users without HEPVis shared objects.
Definition: SoPcons.h:78
SoPcons::drawEdgeLines
SoSFBool drawEdgeLines
Definition: SoPcons.h:80
calibdata.ct
ct
Definition: calibdata.py:418
grepfile.sep
sep
Definition: grepfile.py:38
FSIN
#define FSIN(x)
Definition: SbMath.h:14
GEN_VERTEX
#define GEN_VERTEX(pv, x, y, z, s, t, nx, ny, nz)
SoPcons::pOverrideNPhi
SoSFInt32 pOverrideNPhi
Override number of phi subdivision used for rendering shape (i.e.
Definition: SoPcons.h:74
N_GEN_VERTEX
#define N_GEN_VERTEX(ls, pv, x, y, z, s, t, nx, ny, nz)
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
SoPcons::fDPhi
SoSFFloat fDPhi
Delta-angle, in radians.
Definition: SoPcons.h:65
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
python.changerun.pv
pv
Definition: changerun.py:81
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
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