Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenInventor/src/G4OpenInventorSceneHandler.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/G4OpenInventorSceneHandler.cc (Version 11.3.0) and /visualization/OpenInventor/src/G4OpenInventorSceneHandler.cc (Version 9.3.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4OpenInventorSceneHandler.cc,v 1.55 2009/02/18 14:21:38 lgarnier Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-03-patch-02 $
 27 //                                                 29 //
 28 //                                                 30 // 
 29 // Jeff Kallenbach 01 Aug 1996                     31 // Jeff Kallenbach 01 Aug 1996
 30 // OpenInventor stored scene - creates OpenInv     32 // OpenInventor stored scene - creates OpenInventor display lists.
                                                   >>  33 #ifdef G4VIS_BUILD_OI_DRIVER
 31                                                    34 
 32 // this :                                          35 // this :
 33 #include "G4OpenInventorSceneHandler.hh"           36 #include "G4OpenInventorSceneHandler.hh"
 34                                                    37 
 35 #include <Inventor/SoPath.h>                       38 #include <Inventor/SoPath.h>
 36 #include <Inventor/SoNodeKitPath.h>                39 #include <Inventor/SoNodeKitPath.h>
 37 #include <Inventor/nodes/SoCoordinate3.h>          40 #include <Inventor/nodes/SoCoordinate3.h>
 38 #include <Inventor/nodes/SoCoordinate4.h>          41 #include <Inventor/nodes/SoCoordinate4.h>
 39 #include <Inventor/nodes/SoSeparator.h>            42 #include <Inventor/nodes/SoSeparator.h>
 40 #include <Inventor/nodes/SoDrawStyle.h>            43 #include <Inventor/nodes/SoDrawStyle.h>
 41 #include <Inventor/nodes/SoLightModel.h>           44 #include <Inventor/nodes/SoLightModel.h>
 42 #include <Inventor/nodes/SoMaterial.h>             45 #include <Inventor/nodes/SoMaterial.h>
 43 #include <Inventor/nodes/SoLineSet.h>              46 #include <Inventor/nodes/SoLineSet.h>
 44 #include <Inventor/nodes/SoCube.h>                 47 #include <Inventor/nodes/SoCube.h>
 45 #include <Inventor/nodes/SoFont.h>                 48 #include <Inventor/nodes/SoFont.h>
 46 #include <Inventor/nodes/SoText2.h>                49 #include <Inventor/nodes/SoText2.h>
 47 #include <Inventor/nodes/SoFaceSet.h>              50 #include <Inventor/nodes/SoFaceSet.h>
 48 #include <Inventor/nodes/SoNormal.h>               51 #include <Inventor/nodes/SoNormal.h>
 49 #include <Inventor/nodes/SoNormalBinding.h>        52 #include <Inventor/nodes/SoNormalBinding.h>
 50 #include <Inventor/nodes/SoComplexity.h>           53 #include <Inventor/nodes/SoComplexity.h>
                                                   >>  54 #include <Inventor/nodes/SoNurbsSurface.h>
 51 #include <Inventor/nodes/SoTranslation.h>          55 #include <Inventor/nodes/SoTranslation.h>
 52 #include <Inventor/nodes/SoTransform.h>            56 #include <Inventor/nodes/SoTransform.h>
 53 #include <Inventor/nodes/SoResetTransform.h>       57 #include <Inventor/nodes/SoResetTransform.h>
 54 #include <Inventor/nodes/SoMatrixTransform.h>      58 #include <Inventor/nodes/SoMatrixTransform.h>
 55                                                    59 
 56 #define USE_SOPOLYHEDRON                           60 #define USE_SOPOLYHEDRON
 57                                                    61 
 58 #ifndef USE_SOPOLYHEDRON                           62 #ifndef USE_SOPOLYHEDRON
 59 #include "HEPVis/nodes/SoBox.h"                    63 #include "HEPVis/nodes/SoBox.h"
 60 #include "HEPVis/nodes/SoTubs.h"                   64 #include "HEPVis/nodes/SoTubs.h"
 61 #include "HEPVis/nodes/SoCons.h"                   65 #include "HEPVis/nodes/SoCons.h"
 62 #include "HEPVis/nodes/SoTrd.h"                    66 #include "HEPVis/nodes/SoTrd.h"
 63 #include "HEPVis/nodes/SoTrap.h"                   67 #include "HEPVis/nodes/SoTrap.h"
 64 #endif                                             68 #endif
 65 #include "HEPVis/nodes/SoMarkerSet.h"              69 #include "HEPVis/nodes/SoMarkerSet.h"
 66                                                <<  70 typedef HEPVis_SoMarkerSet SoMarkerSet;
 67 using SoMarkerSet = HEPVis_SoMarkerSet;        << 
 68                                                << 
 69 #include "HEPVis/nodekits/SoDetectorTreeKit.h"     71 #include "HEPVis/nodekits/SoDetectorTreeKit.h"
 70 #include "HEPVis/misc/SoStyleCache.h"              72 #include "HEPVis/misc/SoStyleCache.h"
 71                                                    73 
 72 #include "SoG4Polyhedron.h"                        74 #include "SoG4Polyhedron.h"
 73 #include "SoG4LineSet.h"                           75 #include "SoG4LineSet.h"
 74 #include "SoG4MarkerSet.h"                         76 #include "SoG4MarkerSet.h"
 75                                                    77 
 76 #include "G4Scene.hh"                              78 #include "G4Scene.hh"
                                                   >>  79 #include "G4NURBS.hh"
 77 #include "G4OpenInventor.hh"                       80 #include "G4OpenInventor.hh"
 78 #include "G4OpenInventorTransform3D.hh"            81 #include "G4OpenInventorTransform3D.hh"
 79 #include "G4ThreeVector.hh"                        82 #include "G4ThreeVector.hh"
 80 #include "G4Point3D.hh"                            83 #include "G4Point3D.hh"
 81 #include "G4Normal3D.hh"                           84 #include "G4Normal3D.hh"
 82 #include "G4Transform3D.hh"                        85 #include "G4Transform3D.hh"
 83 #include "G4Polyline.hh"                           86 #include "G4Polyline.hh"
 84 #include "G4Text.hh"                               87 #include "G4Text.hh"
 85 #include "G4Circle.hh"                             88 #include "G4Circle.hh"
 86 #include "G4Square.hh"                             89 #include "G4Square.hh"
 87 #include "G4Polymarker.hh"                         90 #include "G4Polymarker.hh"
 88 #include "G4Polyhedron.hh"                         91 #include "G4Polyhedron.hh"
 89 #include "G4Box.hh"                                92 #include "G4Box.hh"
 90 #include "G4Tubs.hh"                               93 #include "G4Tubs.hh"
 91 #include "G4Cons.hh"                               94 #include "G4Cons.hh"
 92 #include "G4Trap.hh"                               95 #include "G4Trap.hh"
 93 #include "G4Trd.hh"                                96 #include "G4Trd.hh"
 94 #include "G4ModelingParameters.hh"                 97 #include "G4ModelingParameters.hh"
 95 #include "G4VPhysicalVolume.hh"                    98 #include "G4VPhysicalVolume.hh"
 96 #include "G4LogicalVolume.hh"                      99 #include "G4LogicalVolume.hh"
 97 #include "G4Material.hh"                          100 #include "G4Material.hh"
 98 #include "G4VisAttributes.hh"                     101 #include "G4VisAttributes.hh"
 99                                                   102 
100 #define G4warn G4cout                          << 
101                                                << 
102 G4int G4OpenInventorSceneHandler::fSceneIdCoun    103 G4int G4OpenInventorSceneHandler::fSceneIdCount = 0;
103                                                   104 
104 G4OpenInventorSceneHandler::G4OpenInventorScen    105 G4OpenInventorSceneHandler::G4OpenInventorSceneHandler (G4OpenInventor& system,
105                                           cons    106                                           const G4String& name)
106 :G4VSceneHandler (system, fSceneIdCount++, nam    107 :G4VSceneHandler (system, fSceneIdCount++, name)
107 ,fRoot(0)                                         108 ,fRoot(0)
108 ,fDetectorRoot(0)                                 109 ,fDetectorRoot(0)
109 ,fTransientRoot(0)                                110 ,fTransientRoot(0)
110 ,fCurrentSeparator(0)                             111 ,fCurrentSeparator(0)
111 ,fModelingSolid(false)                            112 ,fModelingSolid(false)
112 ,fReducedWireFrame(true)                          113 ,fReducedWireFrame(true)
113 ,fStyleCache(0)                                   114 ,fStyleCache(0)
114 ,fPreviewAndFull(true)                         << 115 ,fPreviewAndFull(false)
115 {                                                 116 {
116   fStyleCache = new SoStyleCache;                 117   fStyleCache = new SoStyleCache;
117   fStyleCache->ref();                             118   fStyleCache->ref();
118                                                   119 
119   fRoot = new SoSeparator;                        120   fRoot = new SoSeparator;
120   fRoot->ref();                                   121   fRoot->ref();
121   fRoot->setName("Root");                         122   fRoot->setName("Root");
122                                                   123   
123   fDetectorRoot = new SoSeparator;                124   fDetectorRoot = new SoSeparator;
124   fDetectorRoot->setName("StaticRoot");           125   fDetectorRoot->setName("StaticRoot");
125   fRoot->addChild(fDetectorRoot);                 126   fRoot->addChild(fDetectorRoot);
126                                                   127   
127   fTransientRoot = new SoSeparator;               128   fTransientRoot = new SoSeparator;
128   fTransientRoot->setName("TransientRoot");       129   fTransientRoot->setName("TransientRoot");
129   fRoot->addChild(fTransientRoot);                130   fRoot->addChild(fTransientRoot);
130                                                   131   
131   fCurrentSeparator = fTransientRoot;             132   fCurrentSeparator = fTransientRoot;
132 }                                                 133 }
133                                                   134 
134 G4OpenInventorSceneHandler::~G4OpenInventorSce    135 G4OpenInventorSceneHandler::~G4OpenInventorSceneHandler ()
135 {                                                 136 {
136   fRoot->unref();                                 137   fRoot->unref();
137   fStyleCache->unref();                           138   fStyleCache->unref();
138 }                                                 139 }
139                                                   140 
140 void G4OpenInventorSceneHandler::ClearStore () << 141 void G4OpenInventorSceneHandler::ClearStore () {
141 {                                              << 142   G4VSceneHandler::ClearStore();
                                                   >> 143 
142   fDetectorRoot->removeAllChildren();             144   fDetectorRoot->removeAllChildren();
143   fSeparatorMap.clear();                          145   fSeparatorMap.clear();
144                                                   146 
145   fTransientRoot->removeAllChildren();            147   fTransientRoot->removeAllChildren();
146 }                                                 148 }
147                                                   149 
148 void G4OpenInventorSceneHandler::ClearTransien << 150 void G4OpenInventorSceneHandler::ClearTransientStore () {
149 {                                              << 151   G4VSceneHandler::ClearTransientStore ();
                                                   >> 152 
150   fTransientRoot->removeAllChildren();            153   fTransientRoot->removeAllChildren();
151 }                                                 154 }
152                                                   155 
153 //                                                156 //
154 // Generates prerequisites for solids             157 // Generates prerequisites for solids
155 //                                                158 //  
156 void G4OpenInventorSceneHandler::PreAddSolid      159 void G4OpenInventorSceneHandler::PreAddSolid
157 (const G4Transform3D& objectTransformation,       160 (const G4Transform3D& objectTransformation,
158  const G4VisAttributes& visAttribs)               161  const G4VisAttributes& visAttribs)
159 {                                                 162 {
160   G4VSceneHandler::PreAddSolid (objectTransfor    163   G4VSceneHandler::PreAddSolid (objectTransformation, visAttribs);
161   // Stores arguments away for future use, e.g    164   // Stores arguments away for future use, e.g., AddPrimitives.
162                                                   165 
163   GeneratePrerequisites();                        166   GeneratePrerequisites();
164 }                                                 167 }
165                                                   168 
166 //                                                169 //
167 // Generates prerequisites for primitives         170 // Generates prerequisites for primitives
168 //                                                171 //  
169 void G4OpenInventorSceneHandler::BeginPrimitiv    172 void G4OpenInventorSceneHandler::BeginPrimitives
170 (const G4Transform3D& objectTransformation) {     173 (const G4Transform3D& objectTransformation) {
171                                                   174 
172   G4VSceneHandler::BeginPrimitives (objectTran    175   G4VSceneHandler::BeginPrimitives (objectTransformation);
173                                                   176 
174   // If thread of control has already passed t    177   // If thread of control has already passed through PreAddSolid,
175   // avoid opening a graphical data base compo    178   // avoid opening a graphical data base component again.
176   if (!fProcessingSolid) {                        179   if (!fProcessingSolid) {
177     GeneratePrerequisites();                      180     GeneratePrerequisites();
178   }                                               181   }
179 }                                                 182 }
180                                                   183 
181 //                                                184 //
182 // Method for handling G4Polyline objects (fro    185 // Method for handling G4Polyline objects (from tracking).
183 //                                                186 //
184 void G4OpenInventorSceneHandler::AddPrimitive     187 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyline& line)
185 {                                                 188 {
186   if (fProcessing2D) {                         << 189   AddProperties(line.GetVisAttributes());  // Transformation, colour, etc.
187     static G4bool warned = false;              << 
188     if (!warned) {                             << 
189       warned = true;                           << 
190       G4Exception                              << 
191   ("G4OpenInventorSceneHandler::AddPrimitive ( << 
192    "OpenInventor-0001", JustWarning,           << 
193    "2D polylines not implemented.  Ignored."); << 
194     }                                          << 
195     return;                                    << 
196   }                                            << 
197                                                << 
198   // Get vis attributes - pick up defaults if  << 
199   const G4VisAttributes* pVA =                 << 
200   fpViewer -> GetApplicableVisAttributes (line << 
201                                                << 
202   AddProperties(pVA);  // Colour, etc.         << 
203   AddTransform();      // Transformation       << 
204                                                   190 
205   G4int nPoints = (G4int)line.size();          << 191   G4int nPoints = line.size();
206   SbVec3f* pCoords = new SbVec3f[nPoints];        192   SbVec3f* pCoords = new SbVec3f[nPoints];
207                                                   193 
208   for (G4int iPoint = 0; iPoint < nPoints ; ++ << 194   for (G4int iPoint = 0; iPoint < nPoints ; iPoint++) {
209     pCoords[iPoint].setValue((G4float)line[iPo << 195     pCoords[iPoint].setValue((float)line[iPoint].x(),
210                              (G4float)line[iPo << 196                              (float)line[iPoint].y(),
211                              (G4float)line[iPo << 197                              (float)line[iPoint].z());
212   }                                               198   }
213                                                   199 
214   //                                              200   //
215   // Point Set                                    201   // Point Set
216   //                                              202   // 
217   SoCoordinate3 *polyCoords = new SoCoordinate    203   SoCoordinate3 *polyCoords = new SoCoordinate3;
218   polyCoords->point.setValues(0,nPoints,pCoord    204   polyCoords->point.setValues(0,nPoints,pCoords);
219   fCurrentSeparator->addChild(polyCoords);        205   fCurrentSeparator->addChild(polyCoords);
220                                                   206   
221   //                                              207   //
222   // Wireframe                                    208   // Wireframe
223   //                                              209   // 
224   SoDrawStyle* drawStyle = fStyleCache->getLin    210   SoDrawStyle* drawStyle = fStyleCache->getLineStyle();
225   fCurrentSeparator->addChild(drawStyle);         211   fCurrentSeparator->addChild(drawStyle);
226                                                   212 
227   SoG4LineSet *pLine = new SoG4LineSet;           213   SoG4LineSet *pLine = new SoG4LineSet;
228                                                   214 
229   // Loads G4Atts for picking...                  215   // Loads G4Atts for picking...
230   if (fpViewer->GetViewParameters().IsPicking(    216   if (fpViewer->GetViewParameters().IsPicking()) LoadAtts(line, pLine);
231                                                   217 
232 #ifdef INVENTOR2_0                                218 #ifdef INVENTOR2_0
233   pLine->numVertices.setValues(0,1,(const G4lo << 219   pLine->numVertices.setValues(0,1,(const long *)&nPoints);
234 #else                                             220 #else 
235   pLine->numVertices.setValues(0,1,&nPoints);     221   pLine->numVertices.setValues(0,1,&nPoints);
236 #endif                                            222 #endif
237                                                   223 
238   fCurrentSeparator->addChild(pLine);             224   fCurrentSeparator->addChild(pLine);
239                                                   225 
240   delete [] pCoords;                              226   delete [] pCoords;
241 }                                                 227 }
242                                                   228 
243 void G4OpenInventorSceneHandler::AddPrimitive     229 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
244 {                                                 230 {
245   if (fProcessing2D) {                         << 231   AddProperties(polymarker.GetVisAttributes()); // Transformation, colour, etc.
246     static G4bool warned = false;              << 
247     if (!warned) {                             << 
248       warned = true;                           << 
249       G4Exception                              << 
250   ("G4OpenInventorSceneHandler::AddPrimitive ( << 
251    "OpenInventor-0002", JustWarning,           << 
252    "2D polymarkers not implemented.  Ignored." << 
253     }                                          << 
254     return;                                    << 
255   }                                            << 
256                                                   232 
257   // Get vis attributes - pick up defaults if  << 233   G4int pointn = polymarker.size();
258   const G4VisAttributes* pVA =                 << 
259   fpViewer -> GetApplicableVisAttributes (poly << 
260                                                << 
261   AddProperties(pVA);  // Colour, etc.         << 
262   AddTransform();      // Transformation       << 
263                                                << 
264   G4int pointn = (G4int)polymarker.size();     << 
265   if(pointn<=0) return;                           234   if(pointn<=0) return;
266                                                   235 
267   SbVec3f* points = new SbVec3f[pointn];          236   SbVec3f* points = new SbVec3f[pointn];
268   for (G4int iPoint = 0; iPoint < pointn ; ++i << 237   for (G4int iPoint = 0; iPoint < pointn ; iPoint++) {
269     points[iPoint].setValue((G4float)polymarke << 238     points[iPoint].setValue((float)polymarker[iPoint].x(),
270                             (G4float)polymarke << 239                             (float)polymarker[iPoint].y(),
271                             (G4float)polymarke << 240                             (float)polymarker[iPoint].z());
272   }                                               241   }
273                                                   242 
274   SoCoordinate3* coordinate3 = new SoCoordinat    243   SoCoordinate3* coordinate3 = new SoCoordinate3;
275   coordinate3->point.setValues(0,pointn,points    244   coordinate3->point.setValues(0,pointn,points);
276   fCurrentSeparator->addChild(coordinate3);       245   fCurrentSeparator->addChild(coordinate3);
277                                                   246 
278   MarkerSizeType sizeType;                        247   MarkerSizeType sizeType;
279   G4double screenSize = GetMarkerSize (polymar    248   G4double screenSize = GetMarkerSize (polymarker, sizeType);
280   switch (sizeType) {                             249   switch (sizeType) {
281   default:                                        250   default:
282   case screen:                                    251   case screen:
283     // Draw in screen coordinates.  OK.           252     // Draw in screen coordinates.  OK.
284     break;                                        253     break;
285   case world:                                     254   case world:
286     // Draw in world coordinates.   Not implem    255     // Draw in world coordinates.   Not implemented.  Use screenSize = 10.
287     screenSize = 10.;                             256     screenSize = 10.;
288     break;                                        257     break;
289   }                                               258   }
290                                                   259   
291   SoG4MarkerSet* markerSet = new SoG4MarkerSet    260   SoG4MarkerSet* markerSet = new SoG4MarkerSet;
292   markerSet->numPoints = pointn;                  261   markerSet->numPoints = pointn;
293                                                   262 
294   // Loads G4Atts for picking...                  263   // Loads G4Atts for picking...
295   if (fpViewer->GetViewParameters().IsPicking(    264   if (fpViewer->GetViewParameters().IsPicking())
296     LoadAtts(polymarker, markerSet);              265     LoadAtts(polymarker, markerSet);
297                                                   266 
298   G4VMarker::FillStyle style = polymarker.GetF    267   G4VMarker::FillStyle style = polymarker.GetFillStyle();
299   switch (polymarker.GetMarkerType()) {           268   switch (polymarker.GetMarkerType()) {
300   default:                                        269   default:
301     // Are available 5_5, 7_7 and 9_9             270     // Are available 5_5, 7_7 and 9_9
302   case G4Polymarker::dots:                        271   case G4Polymarker::dots:
303     if (screenSize <= 5.) {                       272     if (screenSize <= 5.) {
304       markerSet->markerIndex = SoMarkerSet::CI    273       markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_5_5;
305     } else if (screenSize <= 7.) {                274     } else if (screenSize <= 7.) {
306       markerSet->markerIndex = SoMarkerSet::CI    275       markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
307     } else {                                      276     } else {
308       markerSet->markerIndex = SoMarkerSet::CI    277       markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_9_9;
309     }                                             278     }
310     break;                                        279     break;
311   case G4Polymarker::circles:                     280   case G4Polymarker::circles:
312     if (screenSize <= 5.) {                       281     if (screenSize <= 5.) {
313       if (style == G4VMarker::filled) {           282       if (style == G4VMarker::filled) {
314   markerSet->markerIndex = SoMarkerSet::CIRCLE    283   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_5_5;
315       } else {                                    284       } else {
316   markerSet->markerIndex = SoMarkerSet::CIRCLE    285   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_5_5;
317       }                                           286       }
318     } else if (screenSize <= 7.) {                287     } else if (screenSize <= 7.) {
319       if (style == G4VMarker::filled) {           288       if (style == G4VMarker::filled) {
320   markerSet->markerIndex = SoMarkerSet::CIRCLE    289   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
321       } else {                                    290       } else {
322   markerSet->markerIndex = SoMarkerSet::CIRCLE    291   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_7_7;
323       }                                           292       }
324     } else {                                      293     } else {
325       if (style == G4VMarker::filled) {           294       if (style == G4VMarker::filled) {
326   markerSet->markerIndex = SoMarkerSet::CIRCLE    295   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_9_9;
327       } else {                                    296       } else {
328   markerSet->markerIndex = SoMarkerSet::CIRCLE    297   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_9_9;
329       }                                           298       }
330     }                                             299     }
331     break;                                        300     break;
332   case G4Polymarker::squares:                     301   case G4Polymarker::squares:
333     if (screenSize <= 5.) {                       302     if (screenSize <= 5.) {
334       if (style == G4VMarker::filled) {           303       if (style == G4VMarker::filled) {
335   markerSet->markerIndex = SoMarkerSet::SQUARE    304   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_5_5;
336       } else {                                    305       } else {
337   markerSet->markerIndex = SoMarkerSet::SQUARE    306   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_5_5;
338       }                                           307       }
339     } else if (screenSize <= 7.) {                308     } else if (screenSize <= 7.) {
340       if (style == G4VMarker::filled) {           309       if (style == G4VMarker::filled) {
341   markerSet->markerIndex = SoMarkerSet::SQUARE    310   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_7_7;
342       } else {                                    311       } else {
343   markerSet->markerIndex = SoMarkerSet::SQUARE    312   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_7_7;
344       }                                           313       }
345     } else {                                      314     } else {
346       if (style == G4VMarker::filled) {           315       if (style == G4VMarker::filled) {
347   markerSet->markerIndex = SoMarkerSet::SQUARE    316   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_9_9;
348       } else {                                    317       } else {
349   markerSet->markerIndex = SoMarkerSet::SQUARE    318   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_9_9;
350       }                                           319       }
351     }                                             320     }
352   }                                               321   }
353   fCurrentSeparator->addChild(markerSet);         322   fCurrentSeparator->addChild(markerSet);
354                                                   323 
355   delete [] points;                               324   delete [] points;
356 }                                                 325 }
357                                                   326 
                                                   >> 327 // ********* NOTE ********* NOTE ********* NOTE ********* NOTE *********
                                                   >> 328 //
                                                   >> 329 //  This method (Text) has not been tested, as it is 
                                                   >> 330 //  innaccessible from the menu in the current configuration
                                                   >> 331 //
                                                   >> 332 //  Currently draws at the origin!  How do I get it to draw at
                                                   >> 333 //  text.GetPosition()?  JA
                                                   >> 334 //
                                                   >> 335 // ********* NOTE ********* NOTE ********* NOTE ********* NOTE *********
                                                   >> 336 //
358 // Method for handling G4Text objects             337 // Method for handling G4Text objects
359 //                                                338 //
360 void G4OpenInventorSceneHandler::AddPrimitive     339 void G4OpenInventorSceneHandler::AddPrimitive (const G4Text& text)
361 {                                                 340 {
362   if (fProcessing2D) {                         << 341   AddProperties(text.GetVisAttributes());  // Transformation, colour, etc.
363     static G4bool warned = false;              << 
364     if (!warned) {                             << 
365       warned = true;                           << 
366       G4Exception                              << 
367   ("G4OpenInventorSceneHandler::AddPrimitive ( << 
368    "OpenInventor-0003", JustWarning,           << 
369    "2D text not implemented.  Ignored.");      << 
370     }                                          << 
371     return;                                    << 
372   }                                            << 
373                                                << 
374   AddProperties(text.GetVisAttributes());  //  << 
375   AddTransform(text.GetPosition());        //  << 
376                                                   342 
377   //                                              343   //
378   // Color.  Note: text colour is worked out d    344   // Color.  Note: text colour is worked out differently.  This
379   // over-rides the colour added in AddPropert    345   // over-rides the colour added in AddProperties...
380   //                                              346   //
381   const G4Colour& c = GetTextColour (text);       347   const G4Colour& c = GetTextColour (text);
382   SoMaterial* material =                          348   SoMaterial* material = 
383     fStyleCache->getMaterial((G4float)c.GetRed << 349     fStyleCache->getMaterial((float)c.GetRed(),
384                              (G4float)c.GetGre << 350                              (float)c.GetGreen(),
385                              (G4float)c.GetBlu << 351                              (float)c.GetBlue(),
386                              (G4float)(1-c.Get << 352                              (float)(1-c.GetAlpha()));
387   fCurrentSeparator->addChild(material);          353   fCurrentSeparator->addChild(material);
388                                                   354 
389   MarkerSizeType sizeType;                        355   MarkerSizeType sizeType;
390   G4double size = GetMarkerSize (text, sizeTyp    356   G4double size = GetMarkerSize (text, sizeType);
391   switch (sizeType) {                             357   switch (sizeType) {
392   default:                                        358   default:
393   case screen:                                    359   case screen:
394     // Draw in screen coordinates.  OK.           360     // Draw in screen coordinates.  OK.
395     break;                                        361     break;
396   case world:                                     362   case world:
397     // Draw in world coordinates.   Not implem    363     // Draw in world coordinates.   Not implemented.  Use size = 20.
398     size = 20.;                                   364     size = 20.;
399     break;                                        365     break;
400   }                                               366   }
401                                                   367 
402   //                                              368   //
403   // Font                                         369   // Font
404   //                                              370   // 
405   SoFont *g4Font = new SoFont();                  371   SoFont *g4Font = new SoFont();
406   g4Font->size = size;                            372   g4Font->size = size;
407   fCurrentSeparator->addChild(g4Font);            373   fCurrentSeparator->addChild(g4Font);
408                                                   374 
409   //                                              375   //
410   // Text                                         376   // Text
411   //                                              377   // 
412   SoText2 *g4String = new SoText2();              378   SoText2 *g4String = new SoText2();
413   g4String->string.setValue(text.GetText());      379   g4String->string.setValue(text.GetText());
414   g4String->spacing = 2.0;                        380   g4String->spacing = 2.0;
415   switch (text.GetLayout()) {                     381   switch (text.GetLayout()) {
416   default:                                        382   default:
417   case G4Text::left:                              383   case G4Text::left:
418     g4String->justification = SoText2::LEFT; b    384     g4String->justification = SoText2::LEFT; break;
419   case G4Text::centre:                            385   case G4Text::centre:
420     g4String->justification = SoText2::CENTER;    386     g4String->justification = SoText2::CENTER; break;
421   case G4Text::right:                             387   case G4Text::right:
422     g4String->justification = SoText2::RIGHT;     388     g4String->justification = SoText2::RIGHT; break;
423   }                                               389   }
424   fCurrentSeparator->addChild(g4String);          390   fCurrentSeparator->addChild(g4String);
425 }                                                 391 }
426                                                   392 
427 //                                                393 //
428 // Method for handling G4Circle objects           394 // Method for handling G4Circle objects
429 //                                                395 //
430 void G4OpenInventorSceneHandler::AddPrimitive     396 void G4OpenInventorSceneHandler::AddPrimitive (const G4Circle& circle) {
431   AddCircleSquare(G4OICircle, circle);            397   AddCircleSquare(G4OICircle, circle);
432 }                                                 398 }
433                                                   399 
434 //                                                400 //
435 // Method for handling G4Square objects - defa    401 // Method for handling G4Square objects - defaults to wireframe
436 //                                                402 //
437 void G4OpenInventorSceneHandler::AddPrimitive     403 void G4OpenInventorSceneHandler::AddPrimitive (const G4Square& square) {
438   AddCircleSquare(G4OISquare, square);            404   AddCircleSquare(G4OISquare, square);
439 }                                                 405 }
440                                                   406 
441 void G4OpenInventorSceneHandler::AddCircleSqua    407 void G4OpenInventorSceneHandler::AddCircleSquare
442 (G4OIMarker markerType, const G4VMarker& marke    408 (G4OIMarker markerType, const G4VMarker& marker)
443 {                                                 409 {
444   if (fProcessing2D) {                         << 410   AddProperties(marker.GetVisAttributes());  // Transformation, colour, etc.
445     static G4bool warned = false;              << 
446     if (!warned) {                             << 
447       warned = true;                           << 
448       G4Exception                              << 
449   ("G4OpenInventorSceneHandler::AddCircleSquar << 
450    "OpenInventor-0004", JustWarning,           << 
451    "2D circles and squares not implemented.  I << 
452     }                                          << 
453     return;                                    << 
454   }                                            << 
455                                                << 
456   // Get vis attributes - pick up defaults if  << 
457   const G4VisAttributes* pVA =                 << 
458   fpViewer -> GetApplicableVisAttributes (mark << 
459                                                << 
460   AddProperties(pVA);  // Colour, etc.         << 
461   AddTransform();      // Transformation       << 
462                                                   411 
463   MarkerSizeType sizeType;                        412   MarkerSizeType sizeType;
464   G4double screenSize = GetMarkerSize (marker,    413   G4double screenSize = GetMarkerSize (marker, sizeType);
465   switch (sizeType) {                             414   switch (sizeType) {
466   default:                                        415   default:
467   case screen:                                    416   case screen:
468     // Draw in screen coordinates.  OK.           417     // Draw in screen coordinates.  OK.
469     break;                                        418     break;
470   case world:                                     419   case world:
471     // Draw in world coordinates.   Not implem    420     // Draw in world coordinates.   Not implemented.  Use size = 10.
472     screenSize = 10.;                             421     screenSize = 10.;
473     break;                                        422     break;
474   }                                               423   }
475                                                   424 
476   G4Point3D centre = marker.GetPosition();        425   G4Point3D centre = marker.GetPosition();
477                                                   426 
478   // Borrowed from AddPrimitive(G4Polymarker)     427   // Borrowed from AddPrimitive(G4Polymarker) - inefficient? JA
479   SbVec3f* points = new SbVec3f[1];               428   SbVec3f* points = new SbVec3f[1];
480   points[0].setValue((G4float)centre.x(),      << 429   points[0].setValue((float)centre.x(),
481          (G4float)centre.y(),                  << 430          (float)centre.y(),
482          (G4float)centre.z());                 << 431          (float)centre.z());
483   SoCoordinate3* coordinate3 = new SoCoordinat    432   SoCoordinate3* coordinate3 = new SoCoordinate3;
484   coordinate3->point.setValues(0,1,points);       433   coordinate3->point.setValues(0,1,points);
485   fCurrentSeparator->addChild(coordinate3);       434   fCurrentSeparator->addChild(coordinate3);
486                                                   435 
487   SoG4MarkerSet* markerSet = new SoG4MarkerSet    436   SoG4MarkerSet* markerSet = new SoG4MarkerSet;
488   markerSet->numPoints = 1;                       437   markerSet->numPoints = 1;
489                                                   438 
490   // Loads G4Atts for picking...                  439   // Loads G4Atts for picking...
491   if (fpViewer->GetViewParameters().IsPicking(    440   if (fpViewer->GetViewParameters().IsPicking()) LoadAtts(marker, markerSet);
492                                                   441 
493   G4VMarker::FillStyle style = marker.GetFillS    442   G4VMarker::FillStyle style = marker.GetFillStyle();
494   switch (markerType) {                           443   switch (markerType) {
495   case G4OICircle:                                444   case G4OICircle:
496     if (screenSize <= 5.) {                       445     if (screenSize <= 5.) {
497       if (style == G4VMarker::filled) {           446       if (style == G4VMarker::filled) {
498   markerSet->markerIndex = SoMarkerSet::CIRCLE    447   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_5_5;
499       } else {                                    448       } else {
500   markerSet->markerIndex = SoMarkerSet::CIRCLE    449   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_5_5;
501       }                                           450       }
502     } else if (screenSize <= 7.) {                451     } else if (screenSize <= 7.) {
503       if (style == G4VMarker::filled) {           452       if (style == G4VMarker::filled) {
504   markerSet->markerIndex = SoMarkerSet::CIRCLE    453   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_7_7;
505       } else {                                    454       } else {
506   markerSet->markerIndex = SoMarkerSet::CIRCLE    455   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_7_7;
507       }                                           456       }
508     } else {                                      457     } else {
509       if (style == G4VMarker::filled) {           458       if (style == G4VMarker::filled) {
510   markerSet->markerIndex = SoMarkerSet::CIRCLE    459   markerSet->markerIndex = SoMarkerSet::CIRCLE_FILLED_9_9;
511       } else {                                    460       } else {
512   markerSet->markerIndex = SoMarkerSet::CIRCLE    461   markerSet->markerIndex = SoMarkerSet::CIRCLE_LINE_9_9;
513       }                                           462       }
514     }                                             463     }
515     break;                                        464     break;
516   case G4OISquare:                                465   case G4OISquare:
517     if (screenSize <= 5.) {                       466     if (screenSize <= 5.) {
518       if (style == G4VMarker::filled) {           467       if (style == G4VMarker::filled) {
519   markerSet->markerIndex = SoMarkerSet::SQUARE    468   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_5_5;
520       } else {                                    469       } else {
521   markerSet->markerIndex = SoMarkerSet::SQUARE    470   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_5_5;
522       }                                           471       }
523     } else if (screenSize <= 7.) {                472     } else if (screenSize <= 7.) {
524       if (style == G4VMarker::filled) {           473       if (style == G4VMarker::filled) {
525   markerSet->markerIndex = SoMarkerSet::SQUARE    474   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_7_7;
526       } else {                                    475       } else {
527   markerSet->markerIndex = SoMarkerSet::SQUARE    476   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_7_7;
528       }                                           477       }
529     } else {                                      478     } else {
530       if (style == G4VMarker::filled) {           479       if (style == G4VMarker::filled) {
531   markerSet->markerIndex = SoMarkerSet::SQUARE    480   markerSet->markerIndex = SoMarkerSet::SQUARE_FILLED_9_9;
532       } else {                                    481       } else {
533   markerSet->markerIndex = SoMarkerSet::SQUARE    482   markerSet->markerIndex = SoMarkerSet::SQUARE_LINE_9_9;
534       }                                           483       }
535     }                                             484     }
536   break;                                          485   break;
537   }                                               486   }
538   fCurrentSeparator->addChild(markerSet);         487   fCurrentSeparator->addChild(markerSet);
539                                                   488 
540   delete [] points;                               489   delete [] points;
541 }                                                 490 }
542                                                   491 
543 //                                                492 //
544 // Method for handling G4Polyhedron objects fo    493 // Method for handling G4Polyhedron objects for drawing solids.
545 //                                                494 //
546 void G4OpenInventorSceneHandler::AddPrimitive     495 void G4OpenInventorSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron)
547 {                                                 496 {
548   if (polyhedron.GetNoFacets() == 0) return;      497   if (polyhedron.GetNoFacets() == 0) return;
549                                                   498 
550   if (fProcessing2D) {                         << 499   AddProperties(polyhedron.GetVisAttributes()); // Transformation, colour, etc.
551     static G4bool warned = false;              << 
552     if (!warned) {                             << 
553       warned = true;                           << 
554       G4Exception                              << 
555   ("G4OpenInventorSceneHandler::AddPrimitive ( << 
556    "OpenInventor-0005", JustWarning,           << 
557    "2D polyhedra not implemented.  Ignored."); << 
558     }                                          << 
559     return;                                    << 
560   }                                            << 
561                                                << 
562   // Get vis attributes - pick up defaults if  << 
563   const G4VisAttributes* pVA =                 << 
564   fpViewer -> GetApplicableVisAttributes (poly << 
565                                                << 
566   AddProperties(pVA);  // Colour, etc.         << 
567   AddTransform();      // Transformation       << 
568                                                   500 
569   SoG4Polyhedron* soPolyhedron = new SoG4Polyh    501   SoG4Polyhedron* soPolyhedron = new SoG4Polyhedron(polyhedron);
570                                                   502 
571   // Loads G4Atts for picking...                  503   // Loads G4Atts for picking...
572   if (fpViewer->GetViewParameters().IsPicking(    504   if (fpViewer->GetViewParameters().IsPicking())
573     LoadAtts(polyhedron, soPolyhedron);           505     LoadAtts(polyhedron, soPolyhedron);
574                                                   506 
575   SbString name = "Non-geometry";                 507   SbString name = "Non-geometry";
576   G4PhysicalVolumeModel* pPVModel =               508   G4PhysicalVolumeModel* pPVModel =
577     dynamic_cast<G4PhysicalVolumeModel*>(fpMod    509     dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
578   if (pPVModel) {                                 510   if (pPVModel) {
579     name = pPVModel->GetCurrentLV()->GetName()    511     name = pPVModel->GetCurrentLV()->GetName().c_str();
580   }                                               512   }
581   SbName sbName(name);                            513   SbName sbName(name);
582   soPolyhedron->setName(sbName);                  514   soPolyhedron->setName(sbName);
583   soPolyhedron->solid.setValue(fModelingSolid)    515   soPolyhedron->solid.setValue(fModelingSolid);
584   soPolyhedron->reducedWireFrame.setValue(fRed    516   soPolyhedron->reducedWireFrame.setValue(fReducedWireFrame?TRUE:FALSE);
585   fCurrentSeparator->addChild(soPolyhedron);      517   fCurrentSeparator->addChild(soPolyhedron);  
586 }                                                 518 }
587                                                   519 
588 void G4OpenInventorSceneHandler::AddCompound(c << 520 //
589   StandardSpecialMeshRendering(mesh);          << 521 // Method for handling G4NURBS objects for drawing solids.
                                                   >> 522 // Knots and Ctrl Pnts MUST be arrays of GLfloats.
                                                   >> 523 //
                                                   >> 524 void G4OpenInventorSceneHandler::AddPrimitive (const G4NURBS& nurb) {
                                                   >> 525 
                                                   >> 526   AddProperties(nurb.GetVisAttributes()); // Transformation, colour, etc.
                                                   >> 527 
                                                   >> 528   G4float *u_knot_array, *u_knot_array_ptr;
                                                   >> 529   u_knot_array = u_knot_array_ptr = new G4float [nurb.GetnbrKnots(G4NURBS::U)];
                                                   >> 530   G4NURBS::KnotsIterator u_iterator (nurb, G4NURBS::U);
                                                   >> 531   while (u_iterator.pick (u_knot_array_ptr++)){}
                                                   >> 532 
                                                   >> 533   G4float *v_knot_array, *v_knot_array_ptr;
                                                   >> 534   v_knot_array = v_knot_array_ptr = new G4float [nurb.GetnbrKnots(G4NURBS::V)];
                                                   >> 535   G4NURBS::KnotsIterator v_iterator (nurb, G4NURBS::V);
                                                   >> 536   while (v_iterator.pick (v_knot_array_ptr++)){}
                                                   >> 537 
                                                   >> 538   G4float *ctrl_pnt_array, *ctrl_pnt_array_ptr;
                                                   >> 539   ctrl_pnt_array = ctrl_pnt_array_ptr =
                                                   >> 540     new G4float [nurb.GettotalnbrCtrlPts () * G4NURBS::NofC*sizeof(G4float)];
                                                   >> 541   G4NURBS::CtrlPtsCoordsIterator c_p_iterator (nurb);
                                                   >> 542   while (c_p_iterator.pick (ctrl_pnt_array_ptr++)){}
                                                   >> 543   
                                                   >> 544   SoSeparator *surfSep = new SoSeparator();
                                                   >> 545 
                                                   >> 546   //
                                                   >> 547   // Set up NURBS
                                                   >> 548   //
                                                   >> 549   SoComplexity *complexity = new SoComplexity;
                                                   >> 550   SoCoordinate4 *ctlPts = new SoCoordinate4;
                                                   >> 551   SoNurbsSurface *oi_nurb = new SoNurbsSurface;
                                                   >> 552   
                                                   >> 553   complexity->value = (float)0.6;
                                                   >> 554   G4int    nPoints = nurb.GettotalnbrCtrlPts ();
                                                   >> 555   SbVec4f* points  = new SbVec4f[nPoints];
                                                   >> 556   for (G4int iPoint = 0; iPoint < nPoints ; iPoint++) {
                                                   >> 557     points[iPoint].setValue(
                                                   >> 558                             ctrl_pnt_array[iPoint*4 + 0],
                                                   >> 559                             ctrl_pnt_array[iPoint*4 + 1],
                                                   >> 560                             ctrl_pnt_array[iPoint*4 + 2],
                                                   >> 561                             ctrl_pnt_array[iPoint*4 + 3]);
                                                   >> 562   }
                                                   >> 563   ctlPts->point.setValues (0,nPoints,points);
                                                   >> 564   oi_nurb->numUControlPoints = nurb.GetnbrCtrlPts(G4NURBS::U);
                                                   >> 565   oi_nurb->numVControlPoints = nurb.GetnbrCtrlPts(G4NURBS::V);
                                                   >> 566   oi_nurb->uKnotVector.setValues(0,nurb.GetnbrKnots(G4NURBS::U),u_knot_array);
                                                   >> 567   oi_nurb->vKnotVector.setValues(0,nurb.GetnbrKnots(G4NURBS::V),v_knot_array);
                                                   >> 568 
                                                   >> 569   surfSep->addChild(complexity);
                                                   >> 570   surfSep->addChild(ctlPts);
                                                   >> 571   surfSep->addChild(oi_nurb);
                                                   >> 572   
                                                   >> 573   fCurrentSeparator->addChild(surfSep);
                                                   >> 574 
                                                   >> 575   //
                                                   >> 576   // Clean-up
                                                   >> 577   //
                                                   >> 578   delete [] u_knot_array;
                                                   >> 579   delete [] v_knot_array;
                                                   >> 580   delete [] ctrl_pnt_array;
                                                   >> 581   delete [] points;
590 }                                                 582 }
591                                                   583 
592 void G4OpenInventorSceneHandler::GeneratePrere    584 void G4OpenInventorSceneHandler::GeneratePrerequisites()
593 {                                                 585 {
594   // Utility for PreAddSolid and BeginPrimitiv    586   // Utility for PreAddSolid and BeginPrimitives.
595                                                   587 
596   // This routines prepares for adding items t    588   // This routines prepares for adding items to the scene database.  We
597   // are expecting two kinds of solids: leaf p    589   // are expecting two kinds of solids: leaf parts and non-leaf parts.
598   // For non-leaf parts, we create a detector     590   // For non-leaf parts, we create a detector tree kit.  This has two
599   // separators.  The solid itself goes in the    591   // separators.  The solid itself goes in the preview separator, the
600   // full separator is forseen for daughters.     592   // full separator is forseen for daughters.  This separator is not
601   // only created--it is also put in a diction    593   // only created--it is also put in a dictionary for future use by
602   // the leaf part.                               594   // the leaf part.
603                                                   595 
604   // For leaf parts, we first locate the mothe    596   // For leaf parts, we first locate the mother volume and find its
605   // separator through the dictionary.            597   // separator through the dictionary.
606                                                   598 
607   // The private member fCurrentSeparator is s    599   // The private member fCurrentSeparator is set to the proper
608   // location on in the scene database so that    600   // location on in the scene database so that when the solid is
609   // actually added (in addthis), it is put in    601   // actually added (in addthis), it is put in the right place.
610                                                   602 
611   G4PhysicalVolumeModel* pPVModel =               603   G4PhysicalVolumeModel* pPVModel =
612     dynamic_cast<G4PhysicalVolumeModel*>(fpMod    604     dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
613                                                   605   
614   if (pPVModel) {                                 606   if (pPVModel) {
615                                                   607 
616     // This call comes from a G4PhysicalVolume    608     // This call comes from a G4PhysicalVolumeModel.  drawnPVPath is
617     // the path of the current drawn (non-cull    609     // the path of the current drawn (non-culled) volume in terms of
618     // drawn (non-culled) ancestors.  Each nod << 610     // drawn (non-culled) ancesters.  Each node is identified by a
619     // PVNodeID object, which is a physical vo    611     // PVNodeID object, which is a physical volume and copy number.  It
620     // is a vector of PVNodeIDs corresponding     612     // is a vector of PVNodeIDs corresponding to the geometry hierarchy
621     // actually selected, i.e., not culled.       613     // actually selected, i.e., not culled.
622     using PVNodeID = G4PhysicalVolumeModel::G4 << 614     typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
623     using PVPath = std::vector<PVNodeID>;      << 615     typedef std::vector<PVNodeID> PVPath;
624     const PVPath& drawnPVPath = pPVModel->GetD    616     const PVPath& drawnPVPath = pPVModel->GetDrawnPVPath();
625     //G4int currentDepth = pPVModel->GetCurren    617     //G4int currentDepth = pPVModel->GetCurrentDepth();
626     G4VPhysicalVolume* pCurrentPV = pPVModel->    618     G4VPhysicalVolume* pCurrentPV = pPVModel->GetCurrentPV();
627     G4LogicalVolume* pCurrentLV = pPVModel->Ge    619     G4LogicalVolume* pCurrentLV = pPVModel->GetCurrentLV();
628     //G4Material* pCurrentMaterial = pPVModel-    620     //G4Material* pCurrentMaterial = pPVModel->GetCurrentMaterial();
629     // Note: pCurrentMaterial may be zero (par    621     // Note: pCurrentMaterial may be zero (parallel world).
630                                                   622 
631     // The simplest algorithm, used by the Ope    623     // The simplest algorithm, used by the Open Inventor Driver
632     // developers, is to rely on the fact the     624     // developers, is to rely on the fact the G4PhysicalVolumeModel
633     // traverses the geometry hierarchy in an     625     // traverses the geometry hierarchy in an orderly manner.  The last
634     // mother, if any, will be the node to whi    626     // mother, if any, will be the node to which the volume should be
635     // added.  So it is enough to keep a map o    627     // added.  So it is enough to keep a map of scene graph nodes keyed
636     // on the volume path ID.  Actually, it is    628     // on the volume path ID.  Actually, it is enough to use the logical
637     // volume as the key.  (An alternative wou    629     // volume as the key.  (An alternative would be to keep the PVNodeID
638     // in the tree and match the PVPath from t    630     // in the tree and match the PVPath from the root down.)
639                                                   631 
640     // Find mother.  ri points to mother, if a    632     // Find mother.  ri points to mother, if any...
641     PVPath::const_reverse_iterator ri;            633     PVPath::const_reverse_iterator ri;
642     G4LogicalVolume* MotherVolume = 0;            634     G4LogicalVolume* MotherVolume = 0;
643     ri = ++drawnPVPath.rbegin();                  635     ri = ++drawnPVPath.rbegin();
644     if (ri != drawnPVPath.rend()) {               636     if (ri != drawnPVPath.rend()) {
645       // This volume has a mother.                637       // This volume has a mother.
646       MotherVolume = ri->GetPhysicalVolume()->    638       MotherVolume = ri->GetPhysicalVolume()->GetLogicalVolume();
647     }                                             639     }
648                                                   640 
649     if (pCurrentLV->GetNoDaughters()!=0 ||        641     if (pCurrentLV->GetNoDaughters()!=0 ||
650   pCurrentPV->IsReplicated()) {  //????Don't u    642   pCurrentPV->IsReplicated()) {  //????Don't understand this???? JA
651       // This block of code is executed for no    643       // This block of code is executed for non-leaf parts:
652                                                   644 
653       // Make the detector tree kit:              645       // Make the detector tree kit:
654       SoDetectorTreeKit* detectorTreeKit = new    646       SoDetectorTreeKit* detectorTreeKit = new SoDetectorTreeKit();  
655                                                   647 
656       SoSeparator* previewSeparator   =           648       SoSeparator* previewSeparator   =  
657   (SoSeparator*) detectorTreeKit->getPart("pre    649   (SoSeparator*) detectorTreeKit->getPart("previewSeparator",TRUE);
658       previewSeparator->renderCaching = SoSepa    650       previewSeparator->renderCaching = SoSeparator::OFF;
659                                                   651 
660       SoSeparator* fullSeparator =                652       SoSeparator* fullSeparator =  
661   (SoSeparator*) detectorTreeKit->getPart("ful    653   (SoSeparator*) detectorTreeKit->getPart("fullSeparator",   TRUE);
662       fullSeparator->renderCaching = SoSeparat    654       fullSeparator->renderCaching = SoSeparator::OFF;
663                                                   655 
664       if(fPreviewAndFull) detectorTreeKit->set    656       if(fPreviewAndFull) detectorTreeKit->setPreviewAndFull();
665       else detectorTreeKit->setPreview(TRUE);     657       else detectorTreeKit->setPreview(TRUE);
666                                                   658 
667       // Colour, etc., for SoDetectorTreeKit.     659       // Colour, etc., for SoDetectorTreeKit.  Treated differently to
668       // othere SoNodes(?).  Use fpVisAttribs     660       // othere SoNodes(?).  Use fpVisAttribs stored away in
669       // PreAddSolid...                           661       // PreAddSolid...
670       const G4VisAttributes* pApplicableVisAtt    662       const G4VisAttributes* pApplicableVisAttribs =
671   fpViewer->GetApplicableVisAttributes (fpVisA    663   fpViewer->GetApplicableVisAttributes (fpVisAttribs);
672                                                   664 
673       // First find the color attributes...       665       // First find the color attributes...
674       const G4Colour& g4Col =  pApplicableVisA    666       const G4Colour& g4Col =  pApplicableVisAttribs->GetColour ();
675       const G4double red = g4Col.GetRed ();    << 667       const double red = g4Col.GetRed ();
676       const G4double green = g4Col.GetGreen () << 668       const double green = g4Col.GetGreen ();
677       const G4double blue = g4Col.GetBlue ();  << 669       const double blue = g4Col.GetBlue ();
678       G4double transparency = 1 - g4Col.GetAlp << 670       double transparency = 1 - g4Col.GetAlpha();
679                                                   671 
680       // Drawing style...                         672       // Drawing style...
681       G4ViewParameters::DrawingStyle drawing_s    673       G4ViewParameters::DrawingStyle drawing_style =
682   GetDrawingStyle(pApplicableVisAttribs);         674   GetDrawingStyle(pApplicableVisAttribs);
683       switch (drawing_style) {                    675       switch (drawing_style) {
684       case (G4ViewParameters::wireframe):         676       case (G4ViewParameters::wireframe):    
685   fModelingSolid = false;                         677   fModelingSolid = false;
686   break;                                          678   break;
687       case (G4ViewParameters::hlr):               679       case (G4ViewParameters::hlr):
688       case (G4ViewParameters::hsr):               680       case (G4ViewParameters::hsr):
689       case (G4ViewParameters::hlhsr):             681       case (G4ViewParameters::hlhsr):
690   fModelingSolid = true;                          682   fModelingSolid = true;
691   break;                                          683   break;
692       case (G4ViewParameters::cloud):          << 
693         fModelingSolid = false;                << 
694         break;                                 << 
695       }                                           684       }
696                                                   685 
697       SoMaterial* material =                      686       SoMaterial* material = 
698   fStyleCache->getMaterial((G4float)red,       << 687   fStyleCache->getMaterial((float)red,
699          (G4float)green,                       << 688          (float)green,
700          (G4float)blue,                        << 689          (float)blue,
701          (G4float)transparency);               << 690          (float)transparency);
702       detectorTreeKit->setPart("appearance.mat    691       detectorTreeKit->setPart("appearance.material",material);
703                                                   692 
704       SoLightModel* lightModel =                  693       SoLightModel* lightModel = 
705   fModelingSolid ? fStyleCache->getLightModelP    694   fModelingSolid ? fStyleCache->getLightModelPhong() : 
706   fStyleCache->getLightModelBaseColor();          695   fStyleCache->getLightModelBaseColor();
707       detectorTreeKit->setPart("appearance.lig    696       detectorTreeKit->setPart("appearance.lightModel",lightModel);
708                                                   697 
709       // Add the full separator to the diction    698       // Add the full separator to the dictionary; it is indexed by the 
710       // address of the logical volume!           699       // address of the logical volume!
711       fSeparatorMap[pCurrentLV] = fullSeparato    700       fSeparatorMap[pCurrentLV] = fullSeparator;
712                                                   701 
713       // Find out where to add this volume.       702       // Find out where to add this volume.
714       // If no mother can be found, it goes un    703       // If no mother can be found, it goes under root.
715       if (MotherVolume) {                         704       if (MotherVolume) {
716   if (fSeparatorMap.find(MotherVolume) != fSep    705   if (fSeparatorMap.find(MotherVolume) != fSeparatorMap.end()) {
717     //printf("debug : PreAddSolid : mother %s     706     //printf("debug : PreAddSolid : mother %s found in map\n",
718     //     MotherVolume->GetName().c_str());      707     //     MotherVolume->GetName().c_str());
719     fSeparatorMap[MotherVolume]->addChild(dete    708     fSeparatorMap[MotherVolume]->addChild(detectorTreeKit);
720   } else {                                        709   } else {
721     // Mother not previously encountered.  Sho    710     // Mother not previously encountered.  Shouldn't happen, since
722     // G4PhysicalVolumeModel sends volumes as     711     // G4PhysicalVolumeModel sends volumes as it encounters them,
723     // i.e., mothers before daughters, in its     712     // i.e., mothers before daughters, in its descent of the
724     // geometry tree.  Error!                     713     // geometry tree.  Error!
725     G4warn <<                                  << 714     G4cout <<
726       "ERROR: G4OpenInventorSceneHandler::Gene    715       "ERROR: G4OpenInventorSceneHandler::GeneratePrerequisites: Mother "
727      << ri->GetPhysicalVolume()->GetName()        716      << ri->GetPhysicalVolume()->GetName()
728      << ':' << ri->GetCopyNo()                    717      << ':' << ri->GetCopyNo()
729      << " not previously encountered."            718      << " not previously encountered."
730       "\nShouldn't happen!  Please report to v    719       "\nShouldn't happen!  Please report to visualization coordinator."
731      << G4endl;                                   720      << G4endl;
732     // Continue anyway.  Add to root of scene     721     // Continue anyway.  Add to root of scene graph tree...
733     //printf("debug : PreAddSolid : mother %s     722     //printf("debug : PreAddSolid : mother %s not found in map !!!\n",
734     //     MotherVolume->GetName().c_str());      723     //     MotherVolume->GetName().c_str());
735     fDetectorRoot->addChild(detectorTreeKit);     724     fDetectorRoot->addChild(detectorTreeKit);
736   }                                               725   }
737       } else {                                    726       } else {
738   //printf("debug : PreAddSolid : has no mothe    727   //printf("debug : PreAddSolid : has no mother\n");
739   fDetectorRoot->addChild(detectorTreeKit);       728   fDetectorRoot->addChild(detectorTreeKit);
740       }                                           729       }
741                                                   730 
742       fCurrentSeparator = previewSeparator;       731       fCurrentSeparator = previewSeparator;
743                                                   732 
744     } else {                                      733     } else {
745       // This block of code is executed for le    734       // This block of code is executed for leaf parts.
746                                                   735 
747       if (MotherVolume) {                         736       if (MotherVolume) {
748   if (fSeparatorMap.find(MotherVolume) != fSep    737   if (fSeparatorMap.find(MotherVolume) != fSeparatorMap.end()) {
749     fCurrentSeparator = fSeparatorMap[MotherVo    738     fCurrentSeparator = fSeparatorMap[MotherVolume];
750   } else {                                        739   } else {
751     // Mother not previously encountered.  Sho    740     // Mother not previously encountered.  Shouldn't happen, since
752     // G4PhysicalVolumeModel sends volumes as     741     // G4PhysicalVolumeModel sends volumes as it encounters them,
753     // i.e., mothers before daughters, in its     742     // i.e., mothers before daughters, in its descent of the
754     // geometry tree.  Error!                     743     // geometry tree.  Error!
755     G4warn << "ERROR: G4OpenInventorSceneHandl << 744     G4cout << "ERROR: G4OpenInventorSceneHandler::PreAddSolid: Mother "
756      << ri->GetPhysicalVolume()->GetName()        745      << ri->GetPhysicalVolume()->GetName()
757      << ':' << ri->GetCopyNo()                    746      << ':' << ri->GetCopyNo()
758      << " not previously encountered."            747      << " not previously encountered."
759       "\nShouldn't happen!  Please report to v    748       "\nShouldn't happen!  Please report to visualization coordinator."
760      << G4endl;                                   749      << G4endl;
761     // Continue anyway.  Add to root of scene     750     // Continue anyway.  Add to root of scene graph tree...
762     fCurrentSeparator = fDetectorRoot;            751     fCurrentSeparator = fDetectorRoot;
763   }                                               752   }
764       } else {                                    753       } else {
765   fCurrentSeparator = fDetectorRoot;              754   fCurrentSeparator = fDetectorRoot;
766       }                                           755       }
767     }                                             756     }
768                                                   757 
769   } else {                                        758   } else {
770     // Not from G4PhysicalVolumeModel, so add     759     // Not from G4PhysicalVolumeModel, so add to root as leaf part...
771                                                   760 
772     if (fReadyForTransients) {                    761     if (fReadyForTransients) {
773       fCurrentSeparator = fTransientRoot;         762       fCurrentSeparator = fTransientRoot;
774     } else {                                      763     } else {
775       fCurrentSeparator = fDetectorRoot;          764       fCurrentSeparator = fDetectorRoot;
776     }                                             765     }
777   }                                               766   }
778 }                                                 767 }
779                                                   768 
780 void G4OpenInventorSceneHandler::AddProperties    769 void G4OpenInventorSceneHandler::AddProperties(const G4VisAttributes* visAtts)
781 {                                                 770 {
782   // Use the applicable vis attributes...         771   // Use the applicable vis attributes...
783   const G4VisAttributes* pApplicableVisAttribs    772   const G4VisAttributes* pApplicableVisAttribs =
784     fpViewer->GetApplicableVisAttributes (visA    773     fpViewer->GetApplicableVisAttributes (visAtts);
785                                                   774 
786   // First find the color attributes...           775   // First find the color attributes...
787   const G4Colour& g4Col =  pApplicableVisAttri    776   const G4Colour& g4Col =  pApplicableVisAttribs->GetColour ();
788   const G4double red = g4Col.GetRed ();        << 777   const double red = g4Col.GetRed ();
789   const G4double green = g4Col.GetGreen ();    << 778   const double green = g4Col.GetGreen ();
790   const G4double blue = g4Col.GetBlue ();      << 779   const double blue = g4Col.GetBlue ();
791   G4double transparency = 1 - g4Col.GetAlpha() << 780   double transparency = 1 - g4Col.GetAlpha();
792                                                   781 
793   // Drawing style...                             782   // Drawing style...
794   G4ViewParameters::DrawingStyle drawing_style    783   G4ViewParameters::DrawingStyle drawing_style =
795     GetDrawingStyle(pApplicableVisAttribs);       784     GetDrawingStyle(pApplicableVisAttribs);
796   switch (drawing_style) {                        785   switch (drawing_style) {
797   case (G4ViewParameters::wireframe):             786   case (G4ViewParameters::wireframe):    
798     fModelingSolid = false;                       787     fModelingSolid = false;
799     break;                                        788     break;
800   case (G4ViewParameters::hlr):                   789   case (G4ViewParameters::hlr):
801   case (G4ViewParameters::hsr):                   790   case (G4ViewParameters::hsr):
802   case (G4ViewParameters::hlhsr):                 791   case (G4ViewParameters::hlhsr):
803     fModelingSolid = true;                        792     fModelingSolid = true;
804     break;                                        793     break;
805   case (G4ViewParameters::cloud):              << 
806     fModelingSolid = false;                    << 
807     break;                                     << 
808   }                                               794   }
809                                                   795 
810   // Edge visibility...                           796   // Edge visibility...
811   G4bool isAuxEdgeVisible = GetAuxEdgeVisible     797   G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pApplicableVisAttribs);
812   fReducedWireFrame = !isAuxEdgeVisible;          798   fReducedWireFrame = !isAuxEdgeVisible;
813                                                   799 
814   SoMaterial* material =                          800   SoMaterial* material = 
815     fStyleCache->getMaterial((G4float)red,     << 801     fStyleCache->getMaterial((float)red,
816            (G4float)green,                     << 802            (float)green,
817            (G4float)blue,                      << 803            (float)blue,
818            (G4float)transparency);             << 804            (float)transparency);
819   fCurrentSeparator->addChild(material);          805   fCurrentSeparator->addChild(material);
820                                                   806 
821   SoLightModel* lightModel =                      807   SoLightModel* lightModel = 
822     fModelingSolid ? fStyleCache->getLightMode    808     fModelingSolid ? fStyleCache->getLightModelPhong() : 
823     fStyleCache->getLightModelBaseColor();        809     fStyleCache->getLightModelBaseColor();
824   fCurrentSeparator->addChild(lightModel);        810   fCurrentSeparator->addChild(lightModel);
825 }                                              << 
826                                                   811 
827 void G4OpenInventorSceneHandler::AddTransform( << 812   // Set up the geometrical transformation for the coming 
828 {                                              << 
829   // AddTransform takes fObjectTransformation  << 
830   // Set up the geometrical transformation for << 
831   fCurrentSeparator->addChild(fStyleCache->get    813   fCurrentSeparator->addChild(fStyleCache->getResetTransform());
832                                                   814 
833   SoMatrixTransform* matrixTransform = new SoM    815   SoMatrixTransform* matrixTransform = new SoMatrixTransform;
834   G4OpenInventorTransform3D oiTran             << 816   G4OpenInventorTransform3D oiTran(*fpObjectTransformation);
835   (fObjectTransformation * G4Translate3D(trans << 
836   SbMatrix* sbMatrix = oiTran.GetSbMatrix();      817   SbMatrix* sbMatrix = oiTran.GetSbMatrix();
837                                                   818 
838   const G4Vector3D scale = fpViewer->GetViewPa    819   const G4Vector3D scale = fpViewer->GetViewParameters().GetScaleFactor();
839   SbMatrix sbScale;                               820   SbMatrix sbScale;
840   sbScale.setScale                                821   sbScale.setScale
841     (SbVec3f((G4float)scale.x(),(G4float)scale << 822     (SbVec3f((float)scale.x(),(float)scale.y(),(float)scale.z()));
842   sbMatrix->multRight(sbScale);                   823   sbMatrix->multRight(sbScale);
843                                                   824 
844   matrixTransform->matrix.setValue(*sbMatrix);    825   matrixTransform->matrix.setValue(*sbMatrix);
845   delete sbMatrix;                                826   delete sbMatrix;
846   fCurrentSeparator->addChild(matrixTransform)    827   fCurrentSeparator->addChild(matrixTransform);
847 }                                                 828 }
                                                   >> 829 #endif
848                                                   830