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 7.1)


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