Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
SoCons Class Reference

#include <SoCons.h>

+ Inheritance diagram for SoCons:

Public Member Functions

 SoCons ()
 Constructor, required.
 
virtual void generateAlternateRep ()
 
virtual void clearAlternateRep ()
 We better be able to clear it, too!
 

Static Public Member Functions

static void initClass ()
 Class Initializer, required.
 

Public Attributes

SoSFFloat fRmin1
 Inside radius at -fDz.
 
SoSFFloat fRmin2
 Inside radius at +fDz.
 
SoSFFloat fRmax1
 Outside radius at -fDz.
 
SoSFFloat fRmax2
 Outside radius at +fDz.
 
SoSFFloat fDz
 Half-length along Z.
 
SoSFFloat fSPhi
 Starting angle, in radians.
 
SoSFFloat fDPhi
 Delta-angle, in radians.
 
SoSFBool smoothDraw
 An Inventor option - slightly better render, worse performance.
 
SoSFNode alternateRep
 Alternate rep required - for use by users without HEPVis shared objects.
 

Protected Member Functions

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

Detailed Description

Definition at line 71 of file SoCons.h.

Constructor & Destructor Documentation

◆ SoCons()

SoCons::SoCons ( )

Constructor, required.

Definition at line 60 of file SoCons.cc.

60 {
61 // This statement is required
62 SO_NODE_CONSTRUCTOR(SoCons);
63
64 // Data fields are initialized like this:
65 SO_NODE_ADD_FIELD(fRmin1, (0.0));
66 SO_NODE_ADD_FIELD(fRmin2, (0.0));
67 SO_NODE_ADD_FIELD(fRmax1, (1.0));
68 SO_NODE_ADD_FIELD(fRmax2, (1.0));
69 SO_NODE_ADD_FIELD(fDz, (10.0));
70 SO_NODE_ADD_FIELD(fSPhi, (0.0));
71 SO_NODE_ADD_FIELD(fDPhi, ((float)(2*M_PI)));
72 SO_NODE_ADD_FIELD(smoothDraw, (TRUE));
73 SO_NODE_ADD_FIELD(alternateRep, (NULL));
74 children = new SoChildList(this);
75}
#define M_PI
Definition SbMath.h:33
#define TRUE
Definition globals.hh:41

◆ ~SoCons()

SoCons::~SoCons ( )
protectedvirtual

Destructor, required.

Definition at line 78 of file SoCons.cc.

78 {
79 delete children;
80}

Referenced by ~SoCons().

Member Function Documentation

◆ clearAlternateRep()

void SoCons::clearAlternateRep ( )
virtual

We better be able to clear it, too!

Definition at line 442 of file SoCons.cc.

442 {
443 alternateRep.setValue(NULL);
444}
SoSFNode alternateRep
Alternate rep required - for use by users without HEPVis shared objects.
Definition SoCons.h:113

Referenced by clearAlternateRep().

◆ computeBBox()

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

compute bounding Box, required

Definition at line 240 of file SoCons.cc.

240 {
241 float fRmax= fRmax1.getValue();
242 if (fRmax2.getValue() > fRmax) fRmax = fRmax2.getValue();
243
244 SbVec3f vmin(-fRmax,-fRmax,-fDz.getValue()),
245 vmax( fRmax, fRmax, fDz.getValue());
246 center.setValue(0,0,0);
247 box.setBounds(vmin,vmax);
248}
SoSFFloat fRmax2
Outside radius at +fDz.
Definition SoCons.h:93
SoSFFloat fRmax1
Outside radius at -fDz.
Definition SoCons.h:89
SoSFFloat fDz
Half-length along Z.
Definition SoCons.h:97

Referenced by computeBBox().

◆ generateAlternateRep()

void SoCons::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 431 of file SoCons.cc.

431 {
432
433 // This routine sets the alternate representation to the child
434 // list of this mode.
435
436 if (children->getLength() == 0) generateChildren();
437 updateChildren();
438 alternateRep.setValue((SoSeparator *) ( *children)[0]);
439}

Referenced by generateAlternateRep().

◆ generatePrimitives()

void SoCons::generatePrimitives ( SoAction * action)
protectedvirtual

Generate Primitives, required.

Definition at line 95 of file SoCons.cc.

95 {
96 // This variable is used to store each vertex
97 SoPrimitiveVertex pv;
98
99 // Access the stat from the action
100 SoState *state = action->getState();
101
102 // See if we have to use a texture coordinate function,
103 // rather than generating explicit texture coordinates.
104 SbBool useTexFunction=
105 (SoTextureCoordinateElement::getType(state) ==
106 SoTextureCoordinateElement::FUNCTION);
107
108 // If we need to generate texture coordinates with a function,
109 // we'll need an SoGLTextureCoordinateElement. Otherwise, we'll
110 // set up the coordinates directly.
111 const SoTextureCoordinateElement *tce = NULL;
112 SbVec4f texCoord;
113 if (useTexFunction) {
114 tce = SoTextureCoordinateElement::getInstance(state);
115 } else {
116 texCoord[2] = 0.0;
117 texCoord[3] = 1.0;
118 }
119 SbVec3f point, normal;
120
121 ///////////////////////////////////////////////////////
122 //-----------------------------------------------------
123#define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz) \
124 point.setValue((float)(x),(float)(y),(float)(z)); \
125 normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
126 if (useTexFunction) { \
127 texCoord=tce->get(point,normal); \
128 } else { \
129 texCoord[0]=(float)(s); \
130 texCoord[1]=(float)(t); \
131 } \
132 pv.setPoint(point); \
133 pv.setNormal(normal); \
134 pv.setTextureCoords(texCoord); \
135 shapeVertex(&pv);
136 //-----------------------------------------------------
137 ///////////////////////////////////////////////////////
138
139
140 int NPHI = (int)(2+22*std::fabs(fDPhi.getValue()/(2.0*M_PI)));
141 double deltaPhi = fDPhi.getValue()/NPHI;
142 double phi0 = fSPhi.getValue();
143 double phi1 = phi0 + fDPhi.getValue();
144 double rMax1 = fRmax1.getValue();
145 double rMin1 = fRmin1.getValue();
146 double rMax2 = fRmax2.getValue();
147 double rMin2 = fRmin2.getValue();
148 double zMax = fDz.getValue();
149 double zMin = -zMax;
150 double cosPhi0 = std::cos(phi0);
151 double sinPhi0 = std::sin(phi0);
152 double cosPhi1 = std::cos(phi1);
153 double sinPhi1 = std::sin(phi1);
154 double cosDeltaPhi = std::cos(deltaPhi);
155 double sinDeltaPhi = std::sin(deltaPhi);
156 //
157 // The outer surface!
158 //
159 beginShape(action,TRIANGLE_STRIP);
160 int i;
161 double sinPhi=sinPhi0;
162 double cosPhi=cosPhi0;
163 for (i = 0; i<=NPHI; i++) {
164 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);
165 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);
166 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
167 }
168 endShape();
169 //
170 // The inner surface!
171 //
172 beginShape(action,TRIANGLE_STRIP);
173 sinPhi=sinPhi0;
174 cosPhi=cosPhi0;
175 for (i = 0; i<=NPHI; i++) {
176 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);
177 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);
178 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
179 }
180 endShape();
181 if (std::fabs(deltaPhi)<2.0*M_PI) {
182 //
183 // The end
184 //
185 beginShape(action,TRIANGLE_STRIP);
186 sinPhi=sinPhi0;
187 cosPhi=cosPhi0;
188 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);
189 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);
190 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);
191 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);
192 endShape();
193 //
194 // The other end
195 //
196 beginShape(action,TRIANGLE_STRIP);
197 sinPhi=sinPhi1;
198 cosPhi=cosPhi1;
199 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);
200 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);
201 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);
202 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);
203 endShape();
204 }
205
206 //
207 // The outer surface at z=+PDZ
208 //
209 beginShape(action,TRIANGLE_STRIP);
210 sinPhi=sinPhi0;
211 cosPhi=cosPhi0;
212 for (i = 0; i<=NPHI; i++) {
213 GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,0,0,1);
214 GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,1.0,1.0,0,0,1);
215 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
216 }
217 endShape();
218 //
219 // The outer surface at z=-PDZ
220 //
221 beginShape(action,TRIANGLE_STRIP);
222 sinPhi=sinPhi0;
223 cosPhi=cosPhi0;
224 for (i = 0; i<=NPHI; i++) {
225 GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,0.0,0,0,-1);
226 GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,0,0,-1);
227 inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);
228 }
229 endShape();
230
231}
#define GEN_VERTEX(pv, x, y, z, s, t, nx, ny, nz)
SoSFFloat fDPhi
Delta-angle, in radians.
Definition SoCons.h:105
SoSFFloat fSPhi
Starting angle, in radians.
Definition SoCons.h:101
SoSFFloat fRmin1
Inside radius at -fDz.
Definition SoCons.h:81
SoSFFloat fRmin2
Inside radius at +fDz.
Definition SoCons.h:85

Referenced by generatePrimitives().

◆ getChildren()

SoChildList * SoCons::getChildren ( ) const
protectedvirtual

GetChildList, required whenever the class has hidden children.

Definition at line 234 of file SoCons.cc.

234 {
235 return children;
236}

Referenced by getChildren().

◆ initClass()

void SoCons::initClass ( )
static

Class Initializer, required.

Definition at line 84 of file SoCons.cc.

84 {
85 // This statement is required.
86 static bool first = true;
87 if (first) {
88 first = false;
89 SO_NODE_INIT_CLASS(SoCons,SoShape,"Shape");
90 }
91}

Referenced by initClass().

Member Data Documentation

◆ alternateRep

SoSFNode SoCons::alternateRep

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

Definition at line 113 of file SoCons.h.

Referenced by clearAlternateRep(), and generateAlternateRep().

◆ fDPhi

SoSFFloat SoCons::fDPhi

Delta-angle, in radians.

Definition at line 105 of file SoCons.h.

Referenced by generatePrimitives().

◆ fDz

SoSFFloat SoCons::fDz

Half-length along Z.

Definition at line 97 of file SoCons.h.

Referenced by computeBBox(), and generatePrimitives().

◆ fRmax1

SoSFFloat SoCons::fRmax1

Outside radius at -fDz.

Definition at line 89 of file SoCons.h.

Referenced by computeBBox(), and generatePrimitives().

◆ fRmax2

SoSFFloat SoCons::fRmax2

Outside radius at +fDz.

Definition at line 93 of file SoCons.h.

Referenced by computeBBox(), and generatePrimitives().

◆ fRmin1

SoSFFloat SoCons::fRmin1

Inside radius at -fDz.

Definition at line 81 of file SoCons.h.

Referenced by generatePrimitives().

◆ fRmin2

SoSFFloat SoCons::fRmin2

Inside radius at +fDz.

Definition at line 85 of file SoCons.h.

Referenced by generatePrimitives().

◆ fSPhi

SoSFFloat SoCons::fSPhi

Starting angle, in radians.

Definition at line 101 of file SoCons.h.

Referenced by generatePrimitives().

◆ smoothDraw

SoSFBool SoCons::smoothDraw

An Inventor option - slightly better render, worse performance.

Definition at line 109 of file SoCons.h.


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