Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenInventor/src/SoCons.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenInventor/src/SoCons.cc (Version 11.3.0) and /visualization/OpenInventor/src/SoCons.cc (Version 6.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //                                                 23 //
                                                   >>  24 // $Id: SoCons.cc,v 1.2 2004/06/14 09:27:39 gcosmo Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-06-02 $
 27 //                                                 26 //
 28 //                                             <<  27 /*-----------------------------Hepvis---------------------------------------*/
 29 /*-----------------------------HEPVis--------- << 
 30 /*                                                 28 /*                                                                          */
 31 /* Node:             SoCons                        29 /* Node:             SoCons                                                 */
 32 /* Description:      Represents the G4Cons Gea     30 /* Description:      Represents the G4Cons Geant Geometry entity            */
 33 /* Author:           Joe Boudreau Nov 11 1996      31 /* Author:           Joe Boudreau Nov 11 1996                               */
 34 /*                                                 32 /*                                                                          */
 35 /*--------------------------------------------     33 /*--------------------------------------------------------------------------*/
 36                                                << 
 37 // this :                                      << 
 38 #include "HEPVis/nodes/SoCons.h"               << 
 39                                                << 
 40 #include <assert.h>                                34 #include <assert.h>
 41 #include <cmath>                               <<  35 #include <math.h>
 42 #include <Inventor/SbBox.h>                        36 #include <Inventor/SbBox.h>
 43 #include <Inventor/actions/SoAction.h>             37 #include <Inventor/actions/SoAction.h>
 44 #include <Inventor/fields/SoSFFloat.h>             38 #include <Inventor/fields/SoSFFloat.h>
 45 #include <Inventor/misc/SoChildList.h>             39 #include <Inventor/misc/SoChildList.h>
 46 #include <Inventor/nodes/SoSeparator.h>            40 #include <Inventor/nodes/SoSeparator.h>
 47 #include <Inventor/nodes/SoIndexedFaceSet.h>       41 #include <Inventor/nodes/SoIndexedFaceSet.h>
 48 #include <Inventor/nodes/SoNormal.h>               42 #include <Inventor/nodes/SoNormal.h>
 49 #include <Inventor/nodes/SoCoordinate3.h>          43 #include <Inventor/nodes/SoCoordinate3.h>
 50 #include <Inventor/nodes/SoNormalBinding.h>        44 #include <Inventor/nodes/SoNormalBinding.h>
 51 #include <Inventor/SoPrimitiveVertex.h>            45 #include <Inventor/SoPrimitiveVertex.h>
 52 #include <Inventor/elements/SoTextureCoordinat     46 #include <Inventor/elements/SoTextureCoordinateElement.h>
 53                                                    47 
 54 #include "HEPVis/SbMath.h"                         48 #include "HEPVis/SbMath.h"
                                                   >>  49 #include "HEPVis/nodes/SoCons.h"
 55                                                    50 
 56 // This statement is required                      51 // This statement is required
 57 SO_NODE_SOURCE(SoCons)                             52 SO_NODE_SOURCE(SoCons)
 58                                                    53 
 59 // Constructor                                     54 // Constructor
 60 SoCons::SoCons() {                                 55 SoCons::SoCons() {
 61   // This statement is required                    56   // This statement is required
 62   SO_NODE_CONSTRUCTOR(SoCons);                     57   SO_NODE_CONSTRUCTOR(SoCons);
 63                                                    58 
 64   // Data fields are initialized like this:        59   // Data fields are initialized like this:
 65   SO_NODE_ADD_FIELD(fRmin1,               (0.0     60   SO_NODE_ADD_FIELD(fRmin1,               (0.0));
 66   SO_NODE_ADD_FIELD(fRmin2,               (0.0     61   SO_NODE_ADD_FIELD(fRmin2,               (0.0));
 67   SO_NODE_ADD_FIELD(fRmax1,               (1.0     62   SO_NODE_ADD_FIELD(fRmax1,               (1.0));
 68   SO_NODE_ADD_FIELD(fRmax2,               (1.0     63   SO_NODE_ADD_FIELD(fRmax2,               (1.0));
 69   SO_NODE_ADD_FIELD(fDz,                 (10.0     64   SO_NODE_ADD_FIELD(fDz,                 (10.0));
 70   SO_NODE_ADD_FIELD(fSPhi,                (0.0     65   SO_NODE_ADD_FIELD(fSPhi,                (0.0));
 71   SO_NODE_ADD_FIELD(fDPhi,             ((float     66   SO_NODE_ADD_FIELD(fDPhi,             ((float)(2*M_PI)));
 72   SO_NODE_ADD_FIELD(smoothDraw,          (TRUE     67   SO_NODE_ADD_FIELD(smoothDraw,          (TRUE));
 73   SO_NODE_ADD_FIELD(alternateRep,        (NULL     68   SO_NODE_ADD_FIELD(alternateRep,        (NULL));
 74   children = new SoChildList(this);                69   children = new SoChildList(this);
 75 }                                                  70 }
 76                                                    71 
 77 // Destructor                                      72 // Destructor
 78 SoCons::~SoCons() {                                73 SoCons::~SoCons() {
 79   delete children;                                 74   delete children;
 80 }                                                  75 }
 81                                                    76 
 82                                                    77 
 83 // initClass                                       78 // initClass
 84 void SoCons::initClass(){                          79 void SoCons::initClass(){
 85   // This statement is required.                   80   // This statement is required.
 86   static bool first = true;                    <<  81   SO_NODE_INIT_CLASS(SoCons,SoShape,"Shape");
 87   if (first) {                                 << 
 88     first = false;                             << 
 89     SO_NODE_INIT_CLASS(SoCons,SoShape,"Shape") << 
 90   }                                            << 
 91 }                                                  82 }
 92                                                    83 
 93                                                    84 
 94 // generatePrimitives                              85 // generatePrimitives
 95 void SoCons::generatePrimitives(SoAction *acti     86 void SoCons::generatePrimitives(SoAction *action) {
 96   // This variable is used to store each verte     87   // This variable is used to store each vertex
 97   SoPrimitiveVertex pv;                            88   SoPrimitiveVertex pv;
 98                                                    89 
 99   // Access the stat from the action               90   // Access the stat from the action
100   SoState *state = action->getState();             91   SoState *state = action->getState();
101                                                    92 
102   // See if we have to use a texture coordinat     93   // See if we have to use a texture coordinate function,
103   // rather than generating explicit texture c     94   // rather than generating explicit texture coordinates.
104   SbBool useTexFunction=                           95   SbBool useTexFunction=
105     (SoTextureCoordinateElement::getType(state     96     (SoTextureCoordinateElement::getType(state) == 
106      SoTextureCoordinateElement::FUNCTION);        97      SoTextureCoordinateElement::FUNCTION);
107                                                    98 
108   // If we need to generate texture coordinate     99   // If we need to generate texture coordinates with a function,
109   // we'll need an SoGLTextureCoordinateElemen    100   // we'll need an SoGLTextureCoordinateElement.  Otherwise, we'll
110   // set up the coordinates directly.             101   // set up the coordinates directly.
111   const SoTextureCoordinateElement *tce = NULL    102   const SoTextureCoordinateElement *tce = NULL;
112   SbVec4f texCoord;                               103   SbVec4f texCoord;
113   if (useTexFunction) {                           104   if (useTexFunction) {
114     tce = SoTextureCoordinateElement::getInsta    105     tce = SoTextureCoordinateElement::getInstance(state);
115   } else {                                        106   } else {
116     texCoord[2] = 0.0;                            107     texCoord[2] = 0.0;
117     texCoord[3] = 1.0;                            108     texCoord[3] = 1.0;
118   }                                               109   }
119   SbVec3f point, normal;                          110   SbVec3f point, normal;
120                                                   111 
121   ////////////////////////////////////////////    112   ///////////////////////////////////////////////////////
122   //------------------------------------------    113   //-----------------------------------------------------
123 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz)         114 #define GEN_VERTEX(pv,x,y,z,s,t,nx,ny,nz)               \
124   point.setValue((float)(x),(float)(y),(float)    115   point.setValue((float)(x),(float)(y),(float)(z));     \
125   normal.setValue((float)(nx),(float)(ny),(flo    116   normal.setValue((float)(nx),(float)(ny),(float)(nz)); \
126   if (useTexFunction) {                           117   if (useTexFunction) {                                 \
127     texCoord=tce->get(point,normal);              118     texCoord=tce->get(point,normal);                    \
128   } else {                                        119   } else {                                              \
129     texCoord[0]=(float)(s);                       120     texCoord[0]=(float)(s);                             \
130     texCoord[1]=(float)(t);                       121     texCoord[1]=(float)(t);                             \
131   }                                               122   }                                                     \
132   pv.setPoint(point);                             123   pv.setPoint(point);                                   \
133   pv.setNormal(normal);                           124   pv.setNormal(normal);                                 \
134   pv.setTextureCoords(texCoord);                  125   pv.setTextureCoords(texCoord);                        \
135   shapeVertex(&pv);                               126   shapeVertex(&pv);
136   //------------------------------------------    127   //-----------------------------------------------------
137   ////////////////////////////////////////////    128   ///////////////////////////////////////////////////////
138                                                   129 
139                                                   130 
140   int NPHI = (int)(2+22*std::fabs(fDPhi.getVal << 131   int NPHI = (int)(2+22*fabs(fDPhi.getValue()/(2.0*M_PI)));
141   double deltaPhi = fDPhi.getValue()/NPHI;        132   double deltaPhi = fDPhi.getValue()/NPHI;
142   double phi0     = fSPhi.getValue();             133   double phi0     = fSPhi.getValue();
143   double phi1     = phi0 + fDPhi.getValue();      134   double phi1     = phi0 + fDPhi.getValue();
144   double rMax1    = fRmax1.getValue();            135   double rMax1    = fRmax1.getValue();
145   double rMin1    = fRmin1.getValue();            136   double rMin1    = fRmin1.getValue();
146   double rMax2    = fRmax2.getValue();            137   double rMax2    = fRmax2.getValue();
147   double rMin2    = fRmin2.getValue();            138   double rMin2    = fRmin2.getValue();
148   double zMax     = fDz.getValue();               139   double zMax     = fDz.getValue();
149   double zMin     = -zMax;                        140   double zMin     = -zMax;
150   double cosPhi0  = std::cos(phi0);            << 141   double cosPhi0  = cos(phi0);
151   double sinPhi0  = std::sin(phi0);            << 142   double sinPhi0  = sin(phi0);
152   double cosPhi1  = std::cos(phi1);            << 143   double cosPhi1  = cos(phi1);
153   double sinPhi1  = std::sin(phi1);            << 144   double sinPhi1  = sin(phi1);
154   double cosDeltaPhi = std::cos(deltaPhi);     << 145   double cosDeltaPhi = cos(deltaPhi);
155   double sinDeltaPhi = std::sin(deltaPhi);     << 146   double sinDeltaPhi = sin(deltaPhi);
156   //                                              147   //
157   // The outer surface!                           148   // The outer surface!
158   //                                              149   //
159   beginShape(action,TRIANGLE_STRIP);              150   beginShape(action,TRIANGLE_STRIP);
160   int    i;                                       151   int    i;
161   double sinPhi=sinPhi0;                          152   double sinPhi=sinPhi0;
162   double cosPhi=cosPhi0;                          153   double cosPhi=cosPhi0;
163   for (i = 0; i<=NPHI; i++) {                     154   for (i = 0; i<=NPHI; i++) {
164     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zM    155     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,cosPhi,sinPhi,0);   
165     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zM    156     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,cosPhi,sinPhi,0);   
166     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaP    157     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);    
167   }                                               158   }
168   endShape();                                     159   endShape();
169   //                                              160   //
170   // The inner surface!                           161   // The inner surface!
171   //                                              162   //
172   beginShape(action,TRIANGLE_STRIP);              163   beginShape(action,TRIANGLE_STRIP);
173   sinPhi=sinPhi0;                                 164   sinPhi=sinPhi0;
174   cosPhi=cosPhi0;                                 165   cosPhi=cosPhi0;
175   for (i = 0; i<=NPHI; i++) {                     166   for (i = 0; i<=NPHI; i++) {
176     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zM    167     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,-cosPhi,-sinPhi,0);   
177     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zM    168     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,1.0,1.0,-cosPhi,-sinPhi,0);   
178     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaP    169     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);    
179   }                                               170   } 
180   endShape();                                     171   endShape();
181   if (std::fabs(deltaPhi)<2.0*M_PI) {          << 172   if (fabs(deltaPhi)<2.0*M_PI) { 
182     //                                            173     //
183     // The end                                    174     // The end 
184     //                                            175     //
185     beginShape(action,TRIANGLE_STRIP);            176     beginShape(action,TRIANGLE_STRIP);
186     sinPhi=sinPhi0;                               177     sinPhi=sinPhi0;
187     cosPhi=cosPhi0;                               178     cosPhi=cosPhi0;
188     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zM    179     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,0.0,0.0,sinPhi,-cosPhi,0);   
189     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zM    180     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,sinPhi,-cosPhi,0);   
190     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zM    181     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,1.0,0.0,sinPhi,-cosPhi,0);   
191     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zM    182     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,1.0,sinPhi,-cosPhi,0);   
192     endShape();                                   183     endShape();
193     //                                            184     //
194     // The other end                              185     // The other end 
195     //                                            186     //
196     beginShape(action,TRIANGLE_STRIP);            187     beginShape(action,TRIANGLE_STRIP);
197     sinPhi=sinPhi1;                               188     sinPhi=sinPhi1;
198     cosPhi=cosPhi1;                               189     cosPhi=cosPhi1;
199     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi, z    190     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi, zMax,0.0,0.0,-sinPhi,+cosPhi,0);  
200     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi, z    191     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi, zMin,1.0,1.0,-sinPhi,+cosPhi,0);  
201     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi, z    192     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi, zMax,1.0,0.0,-sinPhi,+cosPhi,0);  
202     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi, z    193     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi, zMin,0.0,1.0,-sinPhi,+cosPhi,0);  
203     endShape();                                   194     endShape();
204   }                                               195   }
205                                                   196 
206   //                                              197   //
207   // The outer surface at z=+PDZ                  198   // The outer surface at z=+PDZ
208   //                                              199   //
209   beginShape(action,TRIANGLE_STRIP);              200   beginShape(action,TRIANGLE_STRIP);
210   sinPhi=sinPhi0;                                 201   sinPhi=sinPhi0;
211   cosPhi=cosPhi0;                                 202   cosPhi=cosPhi0;
212   for (i = 0; i<=NPHI; i++) {                     203   for (i = 0; i<=NPHI; i++) {
213     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zM    204     GEN_VERTEX(pv,rMin2*cosPhi,rMin2*sinPhi,zMax,0.0,0.0,0,0,1);   
214     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zM    205     GEN_VERTEX(pv,rMax2*cosPhi,rMax2*sinPhi,zMax,1.0,1.0,0,0,1);   
215     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaP    206     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);    
216   }                                               207   }
217   endShape();                                     208   endShape();
218   //                                              209   //
219   // The outer surface at z=-PDZ                  210   // The outer surface at z=-PDZ
220   //                                              211   //
221   beginShape(action,TRIANGLE_STRIP);              212   beginShape(action,TRIANGLE_STRIP);
222   sinPhi=sinPhi0;                                 213   sinPhi=sinPhi0;
223   cosPhi=cosPhi0;                                 214   cosPhi=cosPhi0;
224   for (i = 0; i<=NPHI; i++) {                     215   for (i = 0; i<=NPHI; i++) {
225     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zM    216     GEN_VERTEX(pv,rMin1*cosPhi,rMin1*sinPhi,zMin,0.0,0.0,0,0,-1);   
226     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zM    217     GEN_VERTEX(pv,rMax1*cosPhi,rMax1*sinPhi,zMin,1.0,1.0,0,0,-1);   
227     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaP    218     inc(sinPhi, cosPhi, sinDeltaPhi, cosDeltaPhi);    
228   }                                               219   }
229   endShape();                                     220   endShape();
230                                                   221 
231 }                                                 222 }
232                                                   223 
233 // getChildren                                    224 // getChildren
234 SoChildList *SoCons::getChildren() const {        225 SoChildList *SoCons::getChildren() const {
235   return children;                                226   return children;
236 }                                                 227 }
237                                                   228 
238                                                   229 
239 // computeBBox                                    230 // computeBBox
240 void SoCons::computeBBox(SoAction *, SbBox3f &    231 void SoCons::computeBBox(SoAction *, SbBox3f &box, SbVec3f &center ){
241   float fRmax= fRmax1.getValue();                 232   float fRmax= fRmax1.getValue();  
242   if (fRmax2.getValue() > fRmax) fRmax = fRmax    233   if (fRmax2.getValue() > fRmax) fRmax = fRmax2.getValue(); 
243                                                   234 
244   SbVec3f vmin(-fRmax,-fRmax,-fDz.getValue()),    235   SbVec3f vmin(-fRmax,-fRmax,-fDz.getValue()), 
245           vmax( fRmax, fRmax, fDz.getValue());    236           vmax( fRmax, fRmax, fDz.getValue());
246   center.setValue(0,0,0);                         237   center.setValue(0,0,0);
247   box.setBounds(vmin,vmax);                       238   box.setBounds(vmin,vmax);
248 }                                                 239 }
249                                                   240 
250                                                   241 
251                                                   242 
252                                                   243 
253 // updateChildren                                 244 // updateChildren
254 void SoCons::updateChildren() {                   245 void SoCons::updateChildren() {
255                                                   246 
256                                                   247 
257   // Redraw the G4Cons....                        248   // Redraw the G4Cons....
258                                                   249 
259   assert(children->getLength()==1);               250   assert(children->getLength()==1);
260   SoSeparator       *sep                = (SoS    251   SoSeparator       *sep                = (SoSeparator *)  ( *children)[0];
261   SoCoordinate3     *theCoordinates     = (SoC    252   SoCoordinate3     *theCoordinates     = (SoCoordinate3 *)      ( sep->getChild(0));
262   SoNormal          *theNormals         = (SoN    253   SoNormal          *theNormals         = (SoNormal *)           ( sep->getChild(1)); 
263   SoNormalBinding   *theNormalBinding   = (SoN    254   SoNormalBinding   *theNormalBinding   = (SoNormalBinding *)    ( sep->getChild(2));
264   SoIndexedFaceSet  *theFaceSet         = (SoI    255   SoIndexedFaceSet  *theFaceSet         = (SoIndexedFaceSet *)   ( sep->getChild(3));
265                                                   256 
266   const int NPHI=24, NPOINTS=2*(2*NPHI+2), NFA    257   const int NPHI=24, NPOINTS=2*(2*NPHI+2), NFACES=4*NPHI+2, NINDICES = NFACES*5;
267   float points[NPOINTS][3], normals[NFACES][3]    258   float points[NPOINTS][3], normals[NFACES][3];
268 #ifdef INVENTOR2_0                                259 #ifdef INVENTOR2_0
269   static long     indices[NINDICES];              260   static long     indices[NINDICES];
270 #else                                             261 #else
271   static int32_t  indices[NINDICES];              262   static int32_t  indices[NINDICES];
272 #endif                                            263 #endif
273   static int init=0;                              264   static int init=0;
274   double phi, pp, DeltaPhi;                       265   double phi, pp, DeltaPhi;
275                                                   266 
276   // Indices need to be generated once! This i    267   // Indices need to be generated once! This is here to keep it close to the point
277   // generation, since otherwise it will be co    268   // generation, since otherwise it will be confusing.
278                                                   269 
279   int i;                                          270   int i;
280   if (!init) {                                    271   if (!init) {
281     init = 1;                                     272     init = 1;
282     // Outer face                                 273     // Outer face
283     for (i = 0; i< NPHI; i++) {                   274     for (i = 0; i< NPHI; i++) {
284       // 0 1 3 2;                                 275       // 0 1 3 2;
285       indices[5*i+0] =  2*i+0;                    276       indices[5*i+0] =  2*i+0;
286       indices[5*i+1] =  2*i+1;                    277       indices[5*i+1] =  2*i+1;
287       indices[5*i+2] =  2*i+3;                    278       indices[5*i+2] =  2*i+3;
288       indices[5*i+3] =  2*i+2;                    279       indices[5*i+3] =  2*i+2;
289       indices[5*i+4] = SO_END_FACE_INDEX;         280       indices[5*i+4] = SO_END_FACE_INDEX;
290     }                                             281     }
291     // the inner face                             282     // the inner face
292     for (i=0;i<NPHI;i++) {                        283     for (i=0;i<NPHI;i++) {
293       indices[5*1*NPHI + 5*i+0] = 2*NPHI+2 + 2    284       indices[5*1*NPHI + 5*i+0] = 2*NPHI+2 + 2*i+0;  
294       indices[5*1*NPHI + 5*i+1] = 2*NPHI+2 + 2    285       indices[5*1*NPHI + 5*i+1] = 2*NPHI+2 + 2*i+1;
295       indices[5*1*NPHI + 5*i+2] = 2*NPHI+2 + 2    286       indices[5*1*NPHI + 5*i+2] = 2*NPHI+2 + 2*i+3;
296       indices[5*1*NPHI + 5*i+3] = 2*NPHI+2 + 2    287       indices[5*1*NPHI + 5*i+3] = 2*NPHI+2 + 2*i+2;
297       indices[5*1*NPHI + 5*i+4] = SO_END_FACE_    288       indices[5*1*NPHI + 5*i+4] = SO_END_FACE_INDEX;
298     }                                             289     }
299     // the top side                               290     // the top side
300     for (i=0;i<NPHI;i++) {                        291     for (i=0;i<NPHI;i++) {
301       indices[5*2*NPHI + 5*i+0] = 2*i+0;          292       indices[5*2*NPHI + 5*i+0] = 2*i+0;
302       indices[5*2*NPHI + 5*i+1] = 2*i+2;          293       indices[5*2*NPHI + 5*i+1] = 2*i+2;
303       indices[5*2*NPHI + 5*i+2] = NPOINTS - (2    294       indices[5*2*NPHI + 5*i+2] = NPOINTS - (2*i+4);
304       indices[5*2*NPHI + 5*i+3] = NPOINTS - (2    295       indices[5*2*NPHI + 5*i+3] = NPOINTS - (2*i+2);
305       indices[5*2*NPHI + 5*i+4] = SO_END_FACE_    296       indices[5*2*NPHI + 5*i+4] = SO_END_FACE_INDEX;
306     }                                             297     }
307     // the bottom side                            298     // the bottom side
308     for (i=0;i<NPHI;i++) {                        299     for (i=0;i<NPHI;i++) {
309       indices[5*3*NPHI + 5*i+0] = 2*i+1;          300       indices[5*3*NPHI + 5*i+0] = 2*i+1;
310       indices[5*3*NPHI + 5*i+1] = NPOINTS - (2    301       indices[5*3*NPHI + 5*i+1] = NPOINTS - (2*i+1);
311       indices[5*3*NPHI + 5*i+2] = NPOINTS - (2    302       indices[5*3*NPHI + 5*i+2] = NPOINTS - (2*i+3);
312       indices[5*3*NPHI + 5*i+3] = 2*i+3;          303       indices[5*3*NPHI + 5*i+3] = 2*i+3;
313       indices[5*3*NPHI + 5*i+4] = SO_END_FACE_    304       indices[5*3*NPHI + 5*i+4] = SO_END_FACE_INDEX;
314     }                                             305     }
315     // the odd side                               306     // the odd side
316     indices[5*4*NPHI +0] = 2*NPHI;                307     indices[5*4*NPHI +0] = 2*NPHI;
317     indices[5*4*NPHI +1] = 2*NPHI+1;              308     indices[5*4*NPHI +1] = 2*NPHI+1;
318     indices[5*4*NPHI +2] = 2*NPHI+3;              309     indices[5*4*NPHI +2] = 2*NPHI+3;
319     indices[5*4*NPHI +3] = 2*NPHI+2;              310     indices[5*4*NPHI +3] = 2*NPHI+2;
320     indices[5*4*NPHI +4] = SO_END_FACE_INDEX;     311     indices[5*4*NPHI +4] = SO_END_FACE_INDEX;
321     // aother odd side                            312     // aother odd side
322     indices[5*4*NPHI +5 +0] = 0;                  313     indices[5*4*NPHI +5 +0] = 0;
323     indices[5*4*NPHI +5 +1] = NPOINTS-2;          314     indices[5*4*NPHI +5 +1] = NPOINTS-2;
324     indices[5*4*NPHI +5 +2] = NPOINTS-1;          315     indices[5*4*NPHI +5 +2] = NPOINTS-1;
325     indices[5*4*NPHI +5 +3] = 1;                  316     indices[5*4*NPHI +5 +3] = 1;
326     indices[5*4*NPHI +5 +4] = SO_END_FACE_INDE    317     indices[5*4*NPHI +5 +4] = SO_END_FACE_INDEX;
327   }                                               318   }
328   // Points need to be generated each time:       319   // Points need to be generated each time:
329   // The outer surface                            320   // The outer surface
330   DeltaPhi = fDPhi.getValue()/NPHI, phi = fSPh    321   DeltaPhi = fDPhi.getValue()/NPHI, phi = fSPhi.getValue();
331   float  t,st,ct;                                 322   float  t,st,ct;
332   t = FATAN((fRmax2.getValue()-fRmax1.getValue    323   t = FATAN((fRmax2.getValue()-fRmax1.getValue())/(2*fDz.getValue()));
333   st = FSIN(t);                                   324   st = FSIN(t);
334   ct = FCOS(t);                                   325   ct = FCOS(t);
335   for (i = 0; i<=NPHI; i++) {                     326   for (i = 0; i<=NPHI; i++) {
336     points[2*i+0][0] = fRmax2.getValue()*FCOS(    327     points[2*i+0][0] = fRmax2.getValue()*FCOS(phi); 
337     points[2*i+0][1] = fRmax2.getValue()*FSIN(    328     points[2*i+0][1] = fRmax2.getValue()*FSIN(phi); 
338     points[2*i+0][2] = +fDz.getValue();           329     points[2*i+0][2] = +fDz.getValue();
339     points[2*i+1][0] = fRmax1.getValue()*FCOS(    330     points[2*i+1][0] = fRmax1.getValue()*FCOS(phi); 
340     points[2*i+1][1] = fRmax1.getValue()*FSIN(    331     points[2*i+1][1] = fRmax1.getValue()*FSIN(phi); 
341     points[2*i+1][2] = -fDz.getValue();           332     points[2*i+1][2] = -fDz.getValue();
342     pp = phi+DeltaPhi/2.0;                        333     pp = phi+DeltaPhi/2.0;
343     if (i!=NPHI) {                                334     if (i!=NPHI) {
344       normals[i][0] = ct * FCOS(pp);              335       normals[i][0] = ct * FCOS(pp); 
345       normals[i][1] = ct * FSIN(pp);              336       normals[i][1] = ct * FSIN(pp); 
346       normals[i][2] = -st;                        337       normals[i][2] = -st;
347     }                                             338     }
348     phi+=DeltaPhi;                                339     phi+=DeltaPhi;
349   }                                               340   }
350   // The inner surface                            341   // The inner surface
351   phi = fSPhi.getValue() + fDPhi.getValue();      342   phi = fSPhi.getValue() + fDPhi.getValue();
352   t = FATAN((fRmin2.getValue()-fRmin1.getValue    343   t = FATAN((fRmin2.getValue()-fRmin1.getValue())/(2*fDz.getValue()));
353   st = FSIN(t);                                   344   st = FSIN(t);
354   ct = FCOS(t);                                   345   ct = FCOS(t);
355   for (i = 0; i<=NPHI; i++) {                     346   for (i = 0; i<=NPHI; i++) {
356     points[2*NPHI+2+2*i+0][0] = fRmin2.getValu    347     points[2*NPHI+2+2*i+0][0] = fRmin2.getValue()*FCOS(phi); 
357     points[2*NPHI+2+2*i+0][1] = fRmin2.getValu    348     points[2*NPHI+2+2*i+0][1] = fRmin2.getValue()*FSIN(phi); 
358     points[2*NPHI+2+2*i+0][2] = +fDz.getValue(    349     points[2*NPHI+2+2*i+0][2] = +fDz.getValue();
359     points[2*NPHI+2+2*i+1][0] = fRmin1.getValu    350     points[2*NPHI+2+2*i+1][0] = fRmin1.getValue()*FCOS(phi); 
360     points[2*NPHI+2+2*i+1][1] = fRmin1.getValu    351     points[2*NPHI+2+2*i+1][1] = fRmin1.getValue()*FSIN(phi); 
361     points[2*NPHI+2+2*i+1][2] = -fDz.getValue(    352     points[2*NPHI+2+2*i+1][2] = -fDz.getValue();
362     pp = phi-DeltaPhi/2.0;                        353     pp = phi-DeltaPhi/2.0;
363     if (i!=NPHI) {                                354     if (i!=NPHI) {
364       normals[NPHI+i][0] = -ct*FCOS(pp);          355       normals[NPHI+i][0] = -ct*FCOS(pp); 
365       normals[NPHI+i][1] = -ct*FSIN(pp);          356       normals[NPHI+i][1] = -ct*FSIN(pp); 
366       normals[NPHI+i][2] = st;                    357       normals[NPHI+i][2] = st;
367     }                                             358     }
368     phi-=DeltaPhi;                                359     phi-=DeltaPhi;
369   }                                               360   }
370   // The top side                                 361   // The top side
371   for (i=0;i<NPHI;i++) {                          362   for (i=0;i<NPHI;i++) {
372     normals[2*NPHI+i][0]=normals[2*NPHI+i][1]=    363     normals[2*NPHI+i][0]=normals[2*NPHI+i][1]=0; 
373     normals[2*NPHI+i][2]=  1.0;                   364     normals[2*NPHI+i][2]=  1.0;
374   }                                               365   } 
375   // The bottom side                              366   // The bottom side
376   for (i=0;i<NPHI;i++) {                          367   for (i=0;i<NPHI;i++) {
377     normals[3*NPHI+i][0]=normals[3*NPHI+i][1]=    368     normals[3*NPHI+i][0]=normals[3*NPHI+i][1]=0; 
378     normals[3*NPHI+i][2]= -1.0;                   369     normals[3*NPHI+i][2]= -1.0;
379   }                                               370   } 
380   // The odd side                                 371   // The odd side
381   phi = fSPhi.getValue();                         372   phi = fSPhi.getValue(); 
382   normals[4*NPHI+0][0]=  FSIN(phi);               373   normals[4*NPHI+0][0]=  FSIN(phi); 
383   normals[4*NPHI+0][1]= -FCOS(phi);               374   normals[4*NPHI+0][1]= -FCOS(phi); 
384   normals[4*NPHI+0][2]= 0;                        375   normals[4*NPHI+0][2]= 0;
385                                                   376 
386   // Another odd side                             377   // Another odd side
387   phi = fSPhi.getValue()+fDPhi.getValue();        378   phi = fSPhi.getValue()+fDPhi.getValue(); 
388   normals[4*NPHI+1][0]= -FSIN(phi);               379   normals[4*NPHI+1][0]= -FSIN(phi); 
389   normals[4*NPHI+1][1]= +FCOS(phi);               380   normals[4*NPHI+1][1]= +FCOS(phi); 
390   normals[4*NPHI+1][2]=0;                         381   normals[4*NPHI+1][2]=0;
391                                                   382 
392   for (int np=0;np<NPOINTS;np++) theCoordinate    383   for (int np=0;np<NPOINTS;np++) theCoordinates->point.set1Value(np,points[np][0],points[np][1],points[np][2]);
393   theFaceSet->coordIndex.setValues(0,NINDICES,    384   theFaceSet->coordIndex.setValues(0,NINDICES,indices);
394   if (smoothDraw.getValue()) {                    385   if (smoothDraw.getValue()) {
395     //    This Line is replaced by the next on    386     //    This Line is replaced by the next one because of an apparent Bug in Inventor (mem. leak).
396     //    theNormals->vector.deleteValues(0);     387     //    theNormals->vector.deleteValues(0);
397     for (int nf=0;nf<NFACES;nf++) theNormals->    388     for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
398     theNormalBinding->value=SoNormalBinding::P    389     theNormalBinding->value=SoNormalBinding::PER_FACE;
399   }                                               390   }
400   else {                                          391   else {
401     for (int nf=0;nf<NFACES;nf++) theNormals->    392     for (int nf=0;nf<NFACES;nf++) theNormals->vector.set1Value(nf,normals[nf][0],normals[nf][1],normals[nf][2]);
402     theNormalBinding->value=SoNormalBinding::P    393     theNormalBinding->value=SoNormalBinding::PER_FACE;
403   }                                               394   }
404 }                                                 395 }
405                                                   396 
406 // generateChildren                               397 // generateChildren
407 void SoCons::generateChildren() {                 398 void SoCons::generateChildren() {
408                                                   399 
409   // This routines creates one SoSeparator, on    400   // This routines creates one SoSeparator, one SoCoordinate3, and
410   // one SoLineSet, and puts it in the child l    401   // one SoLineSet, and puts it in the child list.  This is done only
411   // once, whereas redrawing the position of t    402   // once, whereas redrawing the position of the coordinates occurs each
412   // time an update is necessary, in the updat    403   // time an update is necessary, in the updateChildren routine. 
413                                                   404 
414   assert(children->getLength() ==0);              405   assert(children->getLength() ==0);
415   SoSeparator      *sep              = new SoS    406   SoSeparator      *sep              = new SoSeparator(); 
416   SoCoordinate3    *theCoordinates   = new SoC    407   SoCoordinate3    *theCoordinates   = new SoCoordinate3();
417   SoNormal         *theNormals       = new SoN    408   SoNormal         *theNormals       = new SoNormal(); 
418   SoNormalBinding  *theNormalBinding = new SoN    409   SoNormalBinding  *theNormalBinding = new SoNormalBinding();
419   SoIndexedFaceSet *theFaceSet       = new SoI    410   SoIndexedFaceSet *theFaceSet       = new SoIndexedFaceSet();
420   //                                              411   // 
421   // This line costs some in render quality! b    412   // This line costs some in render quality! but gives speed.
422   //                                              413   // 
423   sep->addChild(theCoordinates);                  414   sep->addChild(theCoordinates);
424   sep->addChild(theNormals);                      415   sep->addChild(theNormals);
425   sep->addChild(theNormalBinding);                416   sep->addChild(theNormalBinding);
426   sep->addChild(theFaceSet);                      417   sep->addChild(theFaceSet);
427   children->append(sep);                          418   children->append(sep);
428 }                                                 419 }
429                                                   420 
430 // generateAlternateRep                           421 // generateAlternateRep
431 void SoCons::generateAlternateRep() {             422 void SoCons::generateAlternateRep() {
432                                                   423 
433   // This routine sets the alternate represent    424   // This routine sets the alternate representation to the child
434   // list of this mode.                           425   // list of this mode.  
435                                                   426 
436   if (children->getLength() == 0) generateChil    427   if (children->getLength() == 0) generateChildren();
437   updateChildren();                               428   updateChildren();
438   alternateRep.setValue((SoSeparator *)  ( *ch    429   alternateRep.setValue((SoSeparator *)  ( *children)[0]);
439 }                                                 430 }
440                                                   431 
441 // clearAlternateRep                              432 // clearAlternateRep
442 void SoCons::clearAlternateRep() {                433 void SoCons::clearAlternateRep() {
443   alternateRep.setValue(NULL);                    434   alternateRep.setValue(NULL);
444 }                                                 435 }
                                                   >> 436 
445                                                   437