Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/OpenGL/src/G4OpenGLSceneHandler.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/OpenGL/src/G4OpenGLSceneHandler.cc (Version 11.3.0) and /visualization/OpenGL/src/G4OpenGLSceneHandler.cc (Version 9.4.p4)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4OpenGLSceneHandler.cc,v 1.59 2010-05-30 09:53:05 allison Exp $
                                                   >>  28 // GEANT4 tag $Name: not supported by cvs2svn $
 27 //                                                 29 //
 28 //                                             <<  30 // 
 29 // Andrew Walkden  27th March 1996                 31 // Andrew Walkden  27th March 1996
 30 // OpenGL stored scene - creates OpenGL displa     32 // OpenGL stored scene - creates OpenGL display lists.
 31 // OpenGL immediate scene - draws immediately      33 // OpenGL immediate scene - draws immediately to buffer
 32 //                           (saving space on      34 //                           (saving space on server).
 33                                                    35 
                                                   >>  36 #ifdef G4VIS_BUILD_OPENGL_DRIVER
                                                   >>  37 
                                                   >>  38 // Included here - problems with HP compiler if not before other includes?
                                                   >>  39 #include "G4NURBS.hh"
                                                   >>  40 
                                                   >>  41 // Here follows a special for Mesa, the OpenGL emulator.  Does not affect
                                                   >>  42 // other OpenGL's, as far as I'm aware.   John Allison 18/9/96.
                                                   >>  43 #define CENTERLINE_CLPP  /* CenterLine C++ workaround: */
                                                   >>  44 // Also seems to be required for HP's CC and AIX xlC, at least.
                                                   >>  45 
                                                   >>  46 #include "G4OpenGLSceneHandler.hh"
                                                   >>  47 #include "G4OpenGLViewer.hh"
                                                   >>  48 #include "G4OpenGLFontBaseStore.hh"
                                                   >>  49 #include "G4OpenGLTransform3D.hh"
                                                   >>  50 #include "G4Point3D.hh"
                                                   >>  51 #include "G4Normal3D.hh"
                                                   >>  52 #include "G4Transform3D.hh"
                                                   >>  53 #include "G4Polyline.hh"
                                                   >>  54 #include "G4Polymarker.hh"
                                                   >>  55 #include "G4Text.hh"
                                                   >>  56 #include "G4Circle.hh"
                                                   >>  57 #include "G4Square.hh"
                                                   >>  58 #include "G4VMarker.hh"
                                                   >>  59 #include "G4Polyhedron.hh"
                                                   >>  60 #include "G4VisAttributes.hh"
                                                   >>  61 #include "G4PhysicalVolumeModel.hh"
                                                   >>  62 #include "G4VPhysicalVolume.hh"
                                                   >>  63 #include "G4LogicalVolume.hh"
                                                   >>  64 #include "G4VSolid.hh"
                                                   >>  65 #include "G4Scene.hh"
                                                   >>  66 #include "G4VisExtent.hh"
                                                   >>  67 #include "G4AttHolder.hh"
 34                                                    68 
 35 #  include "G4OpenGLSceneHandler.hh"           <<  69 G4OpenGLSceneHandler::G4OpenGLSceneHandler (G4VGraphicsSystem& system,
 36 #  include "G4OpenGLViewer.hh"                 <<  70             G4int id,
 37 #  include "G4OpenGLTransform3D.hh"            <<  71             const G4String& name):
 38 #  include "G4Point3D.hh"                      <<  72   G4VSceneHandler (system, id, name),
 39 #  include "G4Normal3D.hh"                     <<  73   fPickName(0),
 40 #  include "G4Transform3D.hh"                  <<  74   fProcessing2D (false),
 41 #  include "G4Polyline.hh"                     <<  75   fProcessingPolymarker(false)
 42 #  include "G4Polymarker.hh"                   <<  76 {}
 43 #  include "G4Text.hh"                         <<  77 
 44 #  include "G4Circle.hh"                       <<  78 G4OpenGLSceneHandler::~G4OpenGLSceneHandler ()
 45 #  include "G4Square.hh"                       <<  79 {
 46 #  include "G4VMarker.hh"                      <<  80   ClearStore ();
 47 #  include "G4Polyhedron.hh"                   <<  81 }
 48 #  include "G4VisAttributes.hh"                << 
 49 #  include "G4PhysicalVolumeModel.hh"          << 
 50 #  include "G4VPhysicalVolume.hh"              << 
 51 #  include "G4LogicalVolume.hh"                << 
 52 #  include "G4VSolid.hh"                       << 
 53 #  include "G4Scene.hh"                        << 
 54 #  include "G4VisExtent.hh"                    << 
 55 #  include "G4AttHolder.hh"                    << 
 56 #  include "G4PhysicalConstants.hh"            << 
 57 #  include "G4RunManager.hh"                   << 
 58 #  include "G4Run.hh"                          << 
 59 #  include "G4RunManagerFactory.hh"            << 
 60 #  include "G4Mesh.hh"                         << 
 61 #  include "G4PseudoScene.hh"                  << 
 62 #  include "G4VisManager.hh"                   << 
 63                                                    82 
 64 const GLubyte G4OpenGLSceneHandler::fStippleMa     83 const GLubyte G4OpenGLSceneHandler::fStippleMaskHashed [128] = {
 65   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         84   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 66   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         85   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 67   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         86   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 68   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         87   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 69   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         88   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 70   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         89   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 71   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         90   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 72   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         91   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 73   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         92   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 74   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         93   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 75   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         94   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 76   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         95   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 77   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         96   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 78   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         97   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 79   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,         98   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
 80   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55          99   0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55
 81 };                                                100 };
 82                                                   101 
 83 G4OpenGLSceneHandler::G4OpenGLSceneHandler (G4 << 
 84                                             G4 << 
 85                                             co << 
 86 G4VSceneHandler (system, id, name),            << 
 87 fPickName(0),                                  << 
 88 fThreePassCapable(false),                      << 
 89 fSecondPassForTransparencyRequested(false),    << 
 90 fSecondPassForTransparency(false),             << 
 91 fThirdPassForNonHiddenMarkersRequested(false), << 
 92 fThirdPassForNonHiddenMarkers(false),          << 
 93 fEdgeFlag(true)                                << 
 94 {                                              << 
 95 }                                              << 
 96                                                << 
 97 G4OpenGLSceneHandler::~G4OpenGLSceneHandler () << 
 98 {                                              << 
 99   ClearStore ();                               << 
100 }                                              << 
101                                                << 
102 void G4OpenGLSceneHandler::ClearAndDestroyAtts    102 void G4OpenGLSceneHandler::ClearAndDestroyAtts()
103 {                                                 103 {
104   std::map<GLuint, G4AttHolder*>::iterator i;     104   std::map<GLuint, G4AttHolder*>::iterator i;
105   for (i = fPickMap.begin(); i != fPickMap.end    105   for (i = fPickMap.begin(); i != fPickMap.end(); ++i) delete i->second;
106   fPickMap.clear();                               106   fPickMap.clear();
107 }                                                 107 }
108                                                   108 
109 G4int G4OpenGLSceneHandler::fEntitiesFlushInte << 
110 G4OpenGLSceneHandler::FlushAction              << 
111 G4OpenGLSceneHandler::fFlushAction = G4OpenGLS << 
112                                                << 
113 void G4OpenGLSceneHandler::ScaledFlush()       << 
114 {                                              << 
115   if (fReadyForTransients) {                   << 
116                                                << 
117     // Drawing transients, e.g., trajectories. << 
118                                                << 
119     if (!fpScene) {                            << 
120       // No scene - shouldn't happen           << 
121       glFlush();                               << 
122       return;                                  << 
123     }                                          << 
124     // Get event from modeling parameters      << 
125     if (!fpModel) {                            << 
126       // No model - shouldn't happen           << 
127       glFlush();                               << 
128       return;                                  << 
129     }                                          << 
130     const G4ModelingParameters* modelingParame << 
131     fpModel->GetModelingParameters();          << 
132     if (!modelingParameters) {                 << 
133       // No modeling parameters - shouldn't ha << 
134       glFlush();                               << 
135       return;                                  << 
136     }                                          << 
137     const G4Event* thisEvent = modelingParamet << 
138     if (!thisEvent) {                          << 
139       // No event, so not in event loop.       << 
140       if (fFlushAction == endOfEvent) {        << 
141         fFlushAction = endOfRun;               << 
142       } else if (fFlushAction == NthEvent) {   << 
143         fFlushAction = NthPrimitive;           << 
144       }                                        << 
145     }                                          << 
146     G4RunManager* runMan = G4RunManagerFactory << 
147     if (!runMan) {                             << 
148       // No run manager - shouldn't happen     << 
149       glFlush();                               << 
150       return;                                  << 
151     }                                          << 
152     const G4Run* thisRun = runMan->GetCurrentR << 
153     if (!thisRun) {                            << 
154       // No run, so not in event loop.         << 
155       if (fFlushAction == endOfRun) {          << 
156         fFlushAction = NthPrimitive;           << 
157       } else if (fFlushAction == NthEvent) {   << 
158         fFlushAction = NthPrimitive;           << 
159       }                                        << 
160     }                                          << 
161                                                << 
162     switch (fFlushAction) {                    << 
163       case endOfEvent:                         << 
164         // If "/vis/scene/endOfEventAction ref << 
165         // end of run anyway, so only scale if << 
166         if (!fpScene->GetRefreshAtEndOfEvent() << 
167           // But if "/vis/scene/endOfEventActi << 
168           // called until end of run, so we ha << 
169           // Get event from modeling parameter << 
170           G4int thisEventID = thisEvent->GetEv << 
171           static G4int lastEventID = 0;        << 
172           if (thisEventID != lastEventID) {    << 
173             glFlush();                         << 
174             lastEventID = thisEventID;         << 
175           }                                    << 
176         }                                      << 
177         break;                                 << 
178       case endOfRun:                           << 
179         // If "/vis/scene/endOfRunAction refre << 
180         // end of run anyway, so only scale if << 
181         if (!fpScene->GetRefreshAtEndOfRun())  << 
182           // If "/vis/scene/endOfRunAction acc << 
183           // so we have to watch for a new run << 
184           G4int thisRunID = thisRun->GetRunID( << 
185           static G4int lastRunID = 0;          << 
186           if (thisRunID != lastRunID) {        << 
187             glFlush();                         << 
188             lastRunID = thisRunID;             << 
189           }                                    << 
190         }                                      << 
191         break;                                 << 
192       case eachPrimitive:                      << 
193         // This is equivalent to numeric with  << 
194         fEntitiesFlushInterval = 1;            << 
195   [[fallthrough]];  // Fall through to NthPrim << 
196       case NthPrimitive:                       << 
197       { // Encapsulate in scope {} brackets to << 
198         static G4int primitivesWaitingToBeFlus << 
199         primitivesWaitingToBeFlushed++;        << 
200         if (primitivesWaitingToBeFlushed < fEn << 
201         glFlush();                             << 
202         primitivesWaitingToBeFlushed = 0;      << 
203         break;                                 << 
204       }                                        << 
205       case NthEvent:                           << 
206         // If "/vis/scene/endOfEventAction ref << 
207         // end of event anyway, so only scale  << 
208         if (!fpScene->GetRefreshAtEndOfEvent() << 
209           G4int thisEventID = thisEvent->GetEv << 
210           static G4int lastEventID = 0;        << 
211           if (thisEventID != lastEventID) {    << 
212             static G4int eventsWaitingToBeFlus << 
213             eventsWaitingToBeFlushed++;        << 
214             if (eventsWaitingToBeFlushed < fEn << 
215             glFlush();                         << 
216             eventsWaitingToBeFlushed = 0;      << 
217             lastEventID = thisEventID;         << 
218           }                                    << 
219         }                                      << 
220         break;                                 << 
221       case never:                              << 
222         break;                                 << 
223       default:                                 << 
224         break;                                 << 
225     }                                          << 
226                                                << 
227   }                                            << 
228                                                << 
229   else                                         << 
230                                                << 
231   {                                            << 
232                                                << 
233     // For run duration model drawing (detecto << 
234     // Immediate mode: a huge speed up is obta << 
235     // Stored mode: no discernable difference  << 
236     //   back buffer and then swapped.         << 
237     // So eachPrimitive and NthPrimitive make  << 
238     // endOfRun are treated as "no action", i. << 
239     // as happens anyway, when drawing is comp << 
240                                                << 
241     switch (fFlushAction) {                    << 
242       case endOfEvent:                         << 
243         break;                                 << 
244       case endOfRun:                           << 
245         break;                                 << 
246       case eachPrimitive:                      << 
247         // This is equivalent to NthPrimitive  << 
248         fEntitiesFlushInterval = 1;            << 
249   [[fallthrough]];  // Fall through to NthPrim << 
250       case NthPrimitive:                       << 
251       { // Encapsulate in scope {} brackets to << 
252         static G4int primitivesWaitingToBeFlus << 
253         primitivesWaitingToBeFlushed++;        << 
254         if (primitivesWaitingToBeFlushed < fEn << 
255         glFlush();                             << 
256         primitivesWaitingToBeFlushed = 0;      << 
257         break;                                 << 
258       }                                        << 
259       case NthEvent:                           << 
260         break;                                 << 
261       case never:                              << 
262         break;                                 << 
263       default:                                 << 
264         break;                                 << 
265     }                                          << 
266                                                << 
267   }                                            << 
268 }                                              << 
269                                                << 
270 void G4OpenGLSceneHandler::ProcessScene()      << 
271 {                                              << 
272   fThreePassCapable = true;                    << 
273                                                << 
274   G4VSceneHandler::ProcessScene();             << 
275                                                << 
276   // Repeat if required...                     << 
277   if (fSecondPassForTransparencyRequested) {   << 
278     fSecondPassForTransparency = true;         << 
279     G4VSceneHandler::ProcessScene();           << 
280     fSecondPassForTransparency = false;        << 
281     fSecondPassForTransparencyRequested = fals << 
282   }                                            << 
283                                                << 
284   // And again if required...                  << 
285   if (fThirdPassForNonHiddenMarkersRequested)  << 
286     fThirdPassForNonHiddenMarkers = true;      << 
287     G4VSceneHandler::ProcessScene();           << 
288     fThirdPassForNonHiddenMarkers = false;     << 
289     fThirdPassForNonHiddenMarkersRequested = f << 
290   }                                            << 
291                                                << 
292   fThreePassCapable = false;                   << 
293 }                                              << 
294                                                << 
295 void G4OpenGLSceneHandler::PreAddSolid            109 void G4OpenGLSceneHandler::PreAddSolid
296 (const G4Transform3D& objectTransformation,       110 (const G4Transform3D& objectTransformation,
297  const G4VisAttributes& visAttribs)               111  const G4VisAttributes& visAttribs)
298 {                                                 112 {
299   G4VSceneHandler::PreAddSolid (objectTransfor    113   G4VSceneHandler::PreAddSolid (objectTransformation, visAttribs);
300 }                                                 114 }
301                                                   115 
302 void G4OpenGLSceneHandler::BeginPrimitives        116 void G4OpenGLSceneHandler::BeginPrimitives
303 (const G4Transform3D& objectTransformation)       117 (const G4Transform3D& objectTransformation)
304 {                                                 118 {
305   G4VSceneHandler::BeginPrimitives (objectTran    119   G4VSceneHandler::BeginPrimitives (objectTransformation);
306 }                                                 120 }
307                                                   121 
308 void G4OpenGLSceneHandler::EndPrimitives ()       122 void G4OpenGLSceneHandler::EndPrimitives ()
309 {                                                 123 {
310   G4VSceneHandler::EndPrimitives ();              124   G4VSceneHandler::EndPrimitives ();
311 }                                                 125 }
312                                                   126 
313 void G4OpenGLSceneHandler::BeginPrimitives2D      127 void G4OpenGLSceneHandler::BeginPrimitives2D
314 (const G4Transform3D& objectTransformation)       128 (const G4Transform3D& objectTransformation)
315 {                                                 129 {
316   G4VSceneHandler::BeginPrimitives2D (objectTr    130   G4VSceneHandler::BeginPrimitives2D (objectTransformation);
                                                   >> 131   fProcessing2D = true;
317 }                                                 132 }
318                                                   133 
319 void G4OpenGLSceneHandler::EndPrimitives2D ()     134 void G4OpenGLSceneHandler::EndPrimitives2D ()
320 {                                                 135 {
                                                   >> 136   fProcessing2D = false;
321   G4VSceneHandler::EndPrimitives2D ();            137   G4VSceneHandler::EndPrimitives2D ();
322 }                                                 138 }
323                                                   139 
324 G4DisplacedSolid* G4OpenGLSceneHandler::Create << 140 G4VSolid* G4OpenGLSceneHandler::CreateSectionSolid ()
325 {                                                 141 {
326   return G4VSceneHandler::CreateSectionSolid() << 142   // Clipping done in G4OpenGLViewer::SetView.
327   // If clipping done in G4OpenGLViewer::SetVi << 
328   // return 0;                                    143   // return 0;
329   // Note: if you change this, you must also c << 144 
330   // G4OpenGLStoredViewer::CompareForKernelVis << 145   // But...OpenGL no longer seems to reconstruct clipped edges, so,
                                                   >> 146   // when the BooleanProcessor is up to it, abandon this and use
                                                   >> 147   // generic clipping in G4VSceneHandler::CreateSectionSolid...
                                                   >> 148   return G4VSceneHandler::CreateSectionSolid();
331 }                                                 149 }
332                                                   150 
333 G4DisplacedSolid* G4OpenGLSceneHandler::Create << 151 G4VSolid* G4OpenGLSceneHandler::CreateCutawaySolid ()
334 {                                                 152 {
335   // return G4VSceneHandler::CreateCutawaySoli << 153   // Cutaway done in G4OpenGLViewer::SetView.
336   // If cutaway done in G4OpenGLViewer::SetVie << 154   // return 0;
337   return 0;                                    << 155 
338   // Note: if you change this, you must also c << 156   // But...if not, when the BooleanProcessor is up to it...
339   // G4OpenGLStoredViewer::CompareForKernelVis << 157   return G4VSceneHandler::CreateCutawaySolid();
340 }                                                 158 }
341                                                   159 
342 void G4OpenGLSceneHandler::AddPrimitive (const    160 void G4OpenGLSceneHandler::AddPrimitive (const G4Polyline& line)
343 {                                                 161 {
344   std::size_t nPoints = line.size ();          << 162   G4int nPoints = line.size ();
345   if (nPoints <= 0) return;                       163   if (nPoints <= 0) return;
346                                                   164 
347   // Note: colour and depth test treated in su << 165   // Loads G4Atts for picking...
                                                   >> 166   if (fpViewer->GetViewParameters().IsPicking()) {
                                                   >> 167     G4AttHolder* holder = new G4AttHolder;
                                                   >> 168     LoadAtts(line, holder);
                                                   >> 169     fPickMap[fPickName] = holder;
                                                   >> 170   }
                                                   >> 171 
                                                   >> 172   // Note: colour treated in sub-class.
                                                   >> 173 
                                                   >> 174   if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ())
                                                   >> 175     glDisable (GL_DEPTH_TEST);
                                                   >> 176   else {glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);}
348                                                   177 
349   glDisable (GL_LIGHTING);                        178   glDisable (GL_LIGHTING);
350                                                << 
351   G4double lineWidth = GetLineWidth(fpVisAttri << 
352   // Need access to method in G4OpenGLViewer.  << 
353   // work with a virtual base class, so use dy << 
354   // test the outcome since viewer is guarante << 
355   // G4OpenGLViewer, but test it anyway to kee << 
356   G4OpenGLViewer* pGLViewer = dynamic_cast<G4O << 
357   if (pGLViewer) pGLViewer->ChangeLineWidth(li << 
358                                                   179 
359   fEdgeFlag = true;                            << 180   // Get vis attributes - pick up defaults if none.
                                                   >> 181   const G4VisAttributes* pVA =
                                                   >> 182     fpViewer -> GetApplicableVisAttributes (line.GetVisAttributes ());
                                                   >> 183 
                                                   >> 184   G4double lineWidth = GetLineWidth(pVA);
                                                   >> 185   glLineWidth(lineWidth);
                                                   >> 186 
360   glBegin (GL_LINE_STRIP);                        187   glBegin (GL_LINE_STRIP);
361   // No ned glEdgeFlag for lines :             << 188   for (G4int iPoint = 0; iPoint < nPoints; iPoint++) {
362   // Boundary and nonboundary edge flags on ve << 
363                                                << 
364   //  glEdgeFlag (GL_TRUE);                    << 
365   for (std::size_t iPoint = 0; iPoint < nPoint << 
366   G4double x, y, z;                               189   G4double x, y, z;
367     x = line[iPoint].x();                         190     x = line[iPoint].x(); 
368     y = line[iPoint].y();                         191     y = line[iPoint].y();
369     z = line[iPoint].z();                         192     z = line[iPoint].z();
370     glVertex3d (x, y, z);                         193     glVertex3d (x, y, z);
371   }                                               194   }
372   glEnd ();                                       195   glEnd ();
373 }                                                 196 }
374                                                   197 
375 void G4OpenGLSceneHandler::AddPrimitive (const    198 void G4OpenGLSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
376 {                                                 199 {
377   if (polymarker.size() == 0) {                << 200   G4int nPoints = polymarker.size ();
                                                   >> 201   if (nPoints <= 0) return;
                                                   >> 202 
                                                   >> 203   fProcessingPolymarker = true;
                                                   >> 204 
                                                   >> 205   // Loads G4Atts for picking...
                                                   >> 206   if (fpViewer->GetViewParameters().IsPicking()) {
                                                   >> 207     G4AttHolder* holder = new G4AttHolder;
                                                   >> 208     LoadAtts(polymarker, holder);
                                                   >> 209     fPickMap[fPickName] = holder;
                                                   >> 210   }
                                                   >> 211 
                                                   >> 212   switch (polymarker.GetMarkerType()) {
                                                   >> 213   default:
                                                   >> 214   case G4Polymarker::dots:
                                                   >> 215     {
                                                   >> 216       for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
                                                   >> 217         G4Circle dot (polymarker);
                                                   >> 218         dot.SetPosition (polymarker[iPoint]);
                                                   >> 219         dot.SetWorldSize  (0.);
                                                   >> 220         dot.SetScreenSize (0.1);  // Very small circle.
                                                   >> 221         G4OpenGLSceneHandler::AddPrimitive (dot);
                                                   >> 222       }
                                                   >> 223     }
                                                   >> 224     break;
                                                   >> 225   case G4Polymarker::circles:
                                                   >> 226     {
                                                   >> 227       std::vector <G4VMarker> circleV; 
                                                   >> 228       for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
                                                   >> 229         G4Circle circle (polymarker);
                                                   >> 230         // If not already drawn
                                                   >> 231         circle.SetPosition (polymarker[iPoint]);
                                                   >> 232         circleV.push_back(circle);
                                                   >> 233         //      G4OpenGLSceneHandler::AddPrimitive (circle);
                                                   >> 234       }
                                                   >> 235       G4OpenGLSceneHandler::AddPrimitives (circleV);
                                                   >> 236     }
                                                   >> 237     break;
                                                   >> 238   case G4Polymarker::squares:
                                                   >> 239     {
                                                   >> 240       std::vector <G4VMarker> squareV; 
                                                   >> 241       for (size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
                                                   >> 242         G4Square square (polymarker);
                                                   >> 243         square.SetPosition (polymarker[iPoint]);
                                                   >> 244         squareV.push_back(square);
                                                   >> 245         //      G4OpenGLSceneHandler::AddPrimitive (square);
                                                   >> 246       }
                                                   >> 247       G4OpenGLSceneHandler::AddPrimitives (squareV);
                                                   >> 248     }
                                                   >> 249     break;
                                                   >> 250   }
                                                   >> 251 
                                                   >> 252   fProcessingPolymarker = false;
                                                   >> 253 }
                                                   >> 254 
                                                   >> 255 void G4OpenGLSceneHandler::AddPrimitive (const G4Text& text) {
                                                   >> 256 
                                                   >> 257   // Loads G4Atts for picking...
                                                   >> 258   if (fpViewer->GetViewParameters().IsPicking()) {
                                                   >> 259     G4AttHolder* holder = new G4AttHolder;
                                                   >> 260     LoadAtts(text, holder);
                                                   >> 261     fPickMap[fPickName] = holder;
                                                   >> 262   }
                                                   >> 263 
                                                   >> 264   const G4Colour& c = GetTextColour (text);  // Picks up default if none.
                                                   >> 265   MarkerSizeType sizeType;
                                                   >> 266   G4double size = GetMarkerSize (text, sizeType);
                                                   >> 267   G4ThreeVector position (text.GetPosition ());
                                                   >> 268   G4String textString = text.GetText();
                                                   >> 269 
                                                   >> 270   G4int font_base = G4OpenGLFontBaseStore::GetFontBase(fpViewer,size);
                                                   >> 271   if (font_base < 0) {
                                                   >> 272     static G4int callCount = 0;
                                                   >> 273     ++callCount;
                                                   >> 274     if (callCount <= 10 || callCount%100 == 0) {
                                                   >> 275       G4cout <<
                                                   >> 276   "G4OpenGLSceneHandler::AddPrimitive (const G4Text&) call count "
                                                   >> 277        << callCount <<
                                                   >> 278   "\n  No fonts available."
                                                   >> 279   "\n  Called with text \""
                                                   >> 280        << text.GetText ()
                                                   >> 281        << "\"\n  at " << position
                                                   >> 282        << ", size " << size
                                                   >> 283        << ", offsets " << text.GetXOffset () << ", " << text.GetYOffset ()
                                                   >> 284        << ", type " << G4int(sizeType)
                                                   >> 285        << ", colour " << c
                                                   >> 286        << G4endl;
                                                   >> 287     }
                                                   >> 288     return;
                                                   >> 289   }
                                                   >> 290   const char* textCString = textString.c_str();
                                                   >> 291   glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());
                                                   >> 292   glDisable (GL_DEPTH_TEST);
                                                   >> 293   glDisable (GL_LIGHTING);
                                                   >> 294   
                                                   >> 295   glRasterPos3d(position.x(),position.y(),position.z());
                                                   >> 296   // No action on offset or layout at present.
                                                   >> 297    glPushAttrib(GL_LIST_BIT);
                                                   >> 298    glListBase(font_base);
                                                   >> 299    glCallLists(strlen(textCString), GL_UNSIGNED_BYTE, (GLubyte *)textCString);
                                                   >> 300    glPopAttrib();
                                                   >> 301 }
                                                   >> 302 
                                                   >> 303 void G4OpenGLSceneHandler::AddPrimitive (const G4Circle& circle) {
                                                   >> 304   glEnable (GL_POINT_SMOOTH);
                                                   >> 305   AddCircleSquare (circle, G4OpenGLBitMapStore::circle);
                                                   >> 306 }
                                                   >> 307 
                                                   >> 308 void G4OpenGLSceneHandler::AddPrimitive (const G4Square& square) {
                                                   >> 309   glDisable (GL_POINT_SMOOTH);
                                                   >> 310   AddCircleSquare (square, G4OpenGLBitMapStore::square);
                                                   >> 311 }
                                                   >> 312 
                                                   >> 313 void G4OpenGLSceneHandler::AddPrimitives (std::vector <G4VMarker> square) {
                                                   >> 314   glDisable (GL_POINT_SMOOTH);
                                                   >> 315   AddCircleSquareVector (square, G4OpenGLBitMapStore::square);
                                                   >> 316 }
                                                   >> 317 
                                                   >> 318 void G4OpenGLSceneHandler::AddCircleSquare
                                                   >> 319 (const G4VMarker& marker,
                                                   >> 320  G4OpenGLBitMapStore::Shape shape) {
                                                   >> 321 
                                                   >> 322   std::vector <G4VMarker> circleVector;
                                                   >> 323   circleVector.push_back(marker);
                                                   >> 324   AddCircleSquareVector(circleVector,shape);
                                                   >> 325 }
                                                   >> 326  
                                                   >> 327 void G4OpenGLSceneHandler::AddCircleSquareVector
                                                   >> 328 (std::vector <G4VMarker> marker,
                                                   >> 329  G4OpenGLBitMapStore::Shape shape) {
                                                   >> 330 
                                                   >> 331   if (marker.size() == 0) {
378     return;                                       332     return;
379   }                                               333   }
380                                                   334 
381   // Note: colour and depth test treated in su << 335   if (!fProcessingPolymarker) {  // Polymarker has already loaded atts.
                                                   >> 336     // Loads G4Atts for picking...
                                                   >> 337     if (fpViewer->GetViewParameters().IsPicking()) {
                                                   >> 338       G4AttHolder* holder = new G4AttHolder;
                                                   >> 339       LoadAtts(marker[0], holder);
                                                   >> 340       fPickMap[fPickName] = holder;
                                                   >> 341     }
                                                   >> 342   }
                                                   >> 343 
                                                   >> 344   // Note: colour treated in sub-class.
382                                                   345 
                                                   >> 346   if (fpViewer -> GetViewParameters ().IsMarkerNotHidden ()) {
                                                   >> 347     glDisable (GL_DEPTH_TEST);
                                                   >> 348   } else {
                                                   >> 349     glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS);
                                                   >> 350   }
                                                   >> 351   
383   glDisable (GL_LIGHTING);                        352   glDisable (GL_LIGHTING);
384                                                   353   
385   MarkerSizeType sizeType;                     << 354   // Get vis attributes - pick up defaults if none.
386   G4double size = GetMarkerSize(polymarker, si << 355   const G4VisAttributes* pVA =
                                                   >> 356     fpViewer -> GetApplicableVisAttributes (marker[0].GetVisAttributes ());
                                                   >> 357 
                                                   >> 358   G4double lineWidth = GetLineWidth(pVA);
                                                   >> 359   glLineWidth(lineWidth);
387                                                   360 
388   // Need access to method in G4OpenGLViewer.  << 361   G4VMarker::FillStyle style = marker[0].GetFillStyle();
389   // work with a virtual base class, so use dy << 362 
390   // test the outcome since viewer is guarante << 363   G4bool filled = false;
391   // G4OpenGLViewer, but test it anyway to kee << 364   static G4bool hashedWarned = false;
392   G4OpenGLViewer* pGLViewer = dynamic_cast<G4O << 
393   if (!pGLViewer) return;                      << 
394                                                << 
395   if (sizeType == world) {  // Size specified  << 
396     G4double lineWidth = GetLineWidth(fpVisAtt << 
397     pGLViewer->ChangeLineWidth(lineWidth);     << 
398                                                   365   
399     G4VMarker::FillStyle style = polymarker.Ge << 366   switch (style) {
                                                   >> 367   case G4VMarker::noFill: 
                                                   >> 368     glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
                                                   >> 369     filled = false;
                                                   >> 370     break;
400                                                   371     
401     // G4bool filled = false;  Not actually us << 372   case G4VMarker::hashed:
402     static G4bool hashedWarned = false;        << 373     if (!hashedWarned) {
                                                   >> 374       G4cout << "Hashed fill style in G4OpenGLSceneHandler."
                                                   >> 375        << "\n  Not implemented.  Using G4VMarker::filled."
                                                   >> 376        << G4endl;
                                                   >> 377       hashedWarned = true;
                                                   >> 378     }
                                                   >> 379     // Maybe use
                                                   >> 380     //glPolygonStipple (fStippleMaskHashed);
                                                   >> 381     // Drop through to filled...
                                                   >> 382     
                                                   >> 383   case G4VMarker::filled:
                                                   >> 384     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
                                                   >> 385     filled = true;
                                                   >> 386     break;
403                                                   387     
404     switch (style) {                           << 
405       case G4VMarker::noFill:                  << 
406         glPolygonMode (GL_FRONT_AND_BACK, GL_L << 
407         glEdgeFlag (GL_TRUE);                  << 
408         //filled = false;                      << 
409         break;                                 << 
410       case G4VMarker::hashed:                  << 
411         if (!hashedWarned) {                   << 
412           G4cout << "Hashed fill style in G4Op << 
413           << "\n  Not implemented.  Using G4VM << 
414           << G4endl;                           << 
415           hashedWarned = true;                 << 
416         }                                      << 
417         // Maybe use                           << 
418         //glPolygonStipple (fStippleMaskHashed << 
419   [[fallthrough]];   // Drop through to filled << 
420       case G4VMarker::filled:                  << 
421         glPolygonMode (GL_FRONT_AND_BACK, GL_F << 
422         //filled = true;                       << 
423         break;                                 << 
424     }                                          << 
425   }                                               388   }
426                                                << 
427   // Draw...                                   << 
428   if (sizeType == world) {  // Size specified  << 
429                                                   389 
430     G4int nSides;                              << 
431     G4double startPhi;                         << 
432     switch (polymarker.GetMarkerType()) {      << 
433     default:                                   << 
434     case G4Polymarker::dots:                   << 
435         size = 1.;                             << 
436   [[fallthrough]];  // Fall through to circles << 
437     case G4Polymarker::circles:                << 
438       nSides = GetNoOfSides(fpVisAttribs);     << 
439       startPhi = 0.;                           << 
440       break;                                   << 
441     case G4Polymarker::squares:                << 
442       nSides = 4;                              << 
443       startPhi = -pi / 4.;                     << 
444       break;                                   << 
445     }                                          << 
446                                                   390 
447     const G4Vector3D& viewpointDirection =     << 
448       fpViewer -> GetViewParameters().GetViewp << 
449     const G4Vector3D& up = fpViewer->GetViewPa << 
450     const G4double dPhi = twopi / nSides;      << 
451     const G4double radius = size / 2.;         << 
452     G4Vector3D start = radius * (up.cross(view << 
453     G4double phi;                              << 
454     G4int i;                                   << 
455     for (size_t iPoint = 0; iPoint < polymarke << 
456       fEdgeFlag = true;                        << 
457       glBegin (GL_POLYGON);                    << 
458       for (i = 0, phi = startPhi; i < nSides;  << 
459   G4Vector3D r = start; r.rotate(phi, viewpoin << 
460   G4Vector3D p = polymarker[iPoint] + r;       << 
461   glVertex3d (p.x(), p.y(), p.z());            << 
462       }                                        << 
463       glEnd ();                                << 
464     }                                          << 
465                                                   391 
466   } else { // Size specified in screen (window << 392   MarkerSizeType sizeType;
                                                   >> 393   G4double size = GetMarkerSize(marker[0], sizeType);
467                                                   394 
468     pGLViewer->ChangePointSize(size);          << 395   // Draw...
                                                   >> 396    if (sizeType == world) {  // Size specified in world coordinates.
469                                                   397 
470     //Antialiasing only for circles            << 398      for (unsigned int a=0;a<marker.size();a++) {
471     switch (polymarker.GetMarkerType()) {      << 399        G4Point3D centre = marker[a].GetPosition();
472     default:                                   << 400        // A few useful quantities...
473     case G4Polymarker::dots:                   << 401        DrawXYPolygon (shape, size, centre, pVA);
474     case G4Polymarker::circles:                << 402      }
475       glEnable (GL_POINT_SMOOTH); break;       << 403    } else { // Size specified in screen (window) coordinates.
476     case G4Polymarker::squares:                << 404      // A few useful quantities...
477       glDisable (GL_POINT_SMOOTH); break;      << 405      glPointSize (size);
478     }                                          << 406      glBegin (GL_POINTS);
479     glBegin (GL_POINTS);                       << 407      for (unsigned int a=0;a<marker.size();a++) {
480     for (size_t iPoint = 0; iPoint < polymarke << 408        G4Point3D centre = marker[a].GetPosition();
481       G4Point3D centre = polymarker[iPoint];   << 409        glVertex3f(centre.x(),centre.y(),centre.z());
482       glVertex3d(centre.x(),centre.y(),centre. << 410      }
483     }                                          << 411      glEnd();
484     glEnd();                                   << 412      //Antialiasing
                                                   >> 413      glEnable (GL_POINT_SMOOTH);
                                                   >> 414      //Transparency
                                                   >> 415      glEnable(GL_BLEND);
                                                   >> 416      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                                                   >> 417 
                                                   >> 418      // L. GARNIER 1 March 2009
                                                   >> 419      // Old method, we draw a bitmap instead of a GL_POINT. 
                                                   >> 420      // I remove it because it cost in term of computing performances
                                                   >> 421      // and gl2ps can't draw bitmaps
                                                   >> 422 
                                                   >> 423      //      glRasterPos3d(centre.x(),centre.y(),centre.z());
                                                   >> 424      //      const GLubyte* marker =
                                                   >> 425      //        G4OpenGLBitMapStore::GetBitMap(shape, size, filled);
                                                   >> 426      //      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
                                                   >> 427      //      glBitmap(GLsizei(size), GLsizei(size), size/2., size/2., 0., 0., marker);
                                                   >> 428    }
                                                   >> 429 }
                                                   >> 430 
                                                   >> 431 void G4OpenGLSceneHandler::DrawXYPolygon
                                                   >> 432 (G4OpenGLBitMapStore::Shape shape,
                                                   >> 433  G4double size,
                                                   >> 434  const G4Point3D& centre,
                                                   >> 435  const G4VisAttributes* pApplicableVisAtts)
                                                   >> 436 {
                                                   >> 437   G4int nSides;
                                                   >> 438   G4double startPhi;
                                                   >> 439   if (shape == G4OpenGLBitMapStore::circle) {
                                                   >> 440     nSides = GetNoOfSides(pApplicableVisAtts);
                                                   >> 441     startPhi = 0.;
                                                   >> 442   } else {
                                                   >> 443     nSides = 4;
                                                   >> 444     startPhi = -pi / 4.;
                                                   >> 445   }
                                                   >> 446 
                                                   >> 447   const G4Vector3D& viewpointDirection =
                                                   >> 448     fpViewer -> GetViewParameters().GetViewpointDirection();
                                                   >> 449   const G4Vector3D& up = fpViewer->GetViewParameters().GetUpVector();
                                                   >> 450   const G4double dPhi = twopi / nSides;
                                                   >> 451   const G4double radius = size / 2.;
                                                   >> 452   G4Vector3D start = radius * (up.cross(viewpointDirection)).unit();
                                                   >> 453   G4double phi;
                                                   >> 454   G4int i;
                                                   >> 455 
                                                   >> 456   glBegin (GL_POLYGON);
                                                   >> 457   for (i = 0, phi = startPhi; i < nSides; i++, phi += dPhi) {
                                                   >> 458     G4Vector3D r = start; r.rotate(phi, viewpointDirection);
                                                   >> 459     G4Vector3D p = centre + r;
                                                   >> 460     glVertex3d (p.x(), p.y(), p.z());
485   }                                               461   }
                                                   >> 462   glEnd ();
486 }                                                 463 }
487                                                   464 
488 void G4OpenGLSceneHandler::AddPrimitive (const << 465 void G4OpenGLSceneHandler::AddPrimitive (const G4Scale& scale)
489   // Pass to specific viewer via virtual funct << 466 {
490   G4OpenGLViewer* pGLViewer = dynamic_cast<G4O << 467   G4VSceneHandler::AddPrimitive(scale);
491   if (pGLViewer) pGLViewer->DrawText(text);    << 
492 }                                              << 
493                                                << 
494 void G4OpenGLSceneHandler::AddPrimitive (const << 
495   G4Polymarker oneCircle(circle);              << 
496   oneCircle.push_back(circle.GetPosition());   << 
497   oneCircle.SetMarkerType(G4Polymarker::circle << 
498   // Call this AddPrimitive to avoid re-doing  << 
499   G4OpenGLSceneHandler::AddPrimitive(oneCircle << 
500 }                                              << 
501                                                << 
502 void G4OpenGLSceneHandler::AddPrimitive (const << 
503   G4Polymarker oneSquare(square);              << 
504   oneSquare.push_back(square.GetPosition());   << 
505   oneSquare.SetMarkerType(G4Polymarker::square << 
506   // Call this AddPrimitive to avoid re-doing  << 
507   G4OpenGLSceneHandler::AddPrimitive(oneSquare << 
508 }                                                 468 }
509                                                   469 
510 //Method for handling G4Polyhedron objects for    470 //Method for handling G4Polyhedron objects for drawing solids.
511 void G4OpenGLSceneHandler::AddPrimitive (const    471 void G4OpenGLSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron) {
512                                                   472 
513   // Assume all facets are planar convex quadr    473   // Assume all facets are planar convex quadrilaterals.
514   // Draw each facet individually                 474   // Draw each facet individually
515                                                   475   
516   if (polyhedron.GetNoFacets() == 0) return;      476   if (polyhedron.GetNoFacets() == 0) return;
517                                                   477 
518   // Need access to data in G4OpenGLViewer.  s << 478   // Loads G4Atts for picking...
519   // with a virtual base class, so use dynamic << 479   if (fpViewer->GetViewParameters().IsPicking()) {
520   G4OpenGLViewer* pGLViewer = dynamic_cast<G4O << 480     G4AttHolder* holder = new G4AttHolder;
521   if (!pGLViewer) return;                      << 481     LoadAtts(polyhedron, holder);
522                                                << 482     fPickMap[fPickName] = holder;
                                                   >> 483   }
                                                   >> 484 
                                                   >> 485   // Get vis attributes - pick up defaults if none.
                                                   >> 486   const G4VisAttributes* pVA =
                                                   >> 487     fpViewer -> GetApplicableVisAttributes (polyhedron.GetVisAttributes ());
                                                   >> 488 
523   // Get view parameters that the user can for    489   // Get view parameters that the user can force through the vis
524   // attributes, thereby over-riding the curre    490   // attributes, thereby over-riding the current view parameter.
525   G4ViewParameters::DrawingStyle drawing_style << 491   G4ViewParameters::DrawingStyle drawing_style = GetDrawingStyle (pVA);
526                                                   492 
527   // Note that in stored mode, because this ca << 493   //Get colour, etc...
528   //  list, it is the colour _at the time of_  << 494   G4bool transparency_enabled = true;
529   //  even if the colour is changed, for examp << 495   G4OpenGLViewer* pViewer = dynamic_cast<G4OpenGLViewer*>(fpViewer);
530   //  window, current_colour does not change.  << 496   if (pViewer) transparency_enabled = pViewer->transparency_enabled;
531   GLfloat* painting_colour;                    << 497   const G4Colour& c = pVA->GetColour();
532   GLfloat clear_colour[4];                     << 498   GLfloat materialColour [4];
533   GLfloat current_colour[4];                   << 499   materialColour [0] = c.GetRed ();
534   glGetFloatv (GL_CURRENT_COLOR, current_colou << 500   materialColour [1] = c.GetGreen ();
535                                                << 501   materialColour [2] = c.GetBlue ();
536   G4bool isTransparent = false;                << 502   if (transparency_enabled) {
537   if (current_colour[3] < 1.) {  // This objec << 503     materialColour [3] = c.GetAlpha ();
538     isTransparent = true;                      << 504   } else {
                                                   >> 505     materialColour [3] = 1.;
539   }                                               506   }
540                                                   507 
541   if  (drawing_style == G4ViewParameters::hlr) << 508   G4double lineWidth = GetLineWidth(pVA);
542     // This is the colour used to paint surfac << 509   glLineWidth(lineWidth);
543     glGetFloatv (GL_COLOR_CLEAR_VALUE, clear_c << 
544     painting_colour = clear_colour;            << 
545   } else {  // drawing_style == G4ViewParamete << 
546     painting_colour = current_colour;          << 
547   }                                            << 
548                                                   510 
549   G4double lineWidth = GetLineWidth(fpVisAttri << 511   GLfloat clear_colour[4];
550   pGLViewer->ChangeLineWidth(lineWidth);       << 512   glGetFloatv (GL_COLOR_CLEAR_VALUE, clear_colour);
551                                                   513 
552   G4bool isAuxEdgeVisible = GetAuxEdgeVisible  << 514   G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA);
553                                                   515 
554   G4bool clipping = pGLViewer->fVP.IsSection() << 516   G4bool clipping = pViewer->fVP.IsSection() || pViewer->fVP.IsCutaway();
555                                                   517 
556   // Lighting disabled unless otherwise reques    518   // Lighting disabled unless otherwise requested
557   glDisable (GL_LIGHTING);                        519   glDisable (GL_LIGHTING);
558                                                   520 
559   switch (drawing_style) {                        521   switch (drawing_style) {
560   case (G4ViewParameters::hlhsr):                 522   case (G4ViewParameters::hlhsr):
561     // Set up as for hidden line removal but p    523     // Set up as for hidden line removal but paint polygon faces later...
562   case (G4ViewParameters::hlr):                   524   case (G4ViewParameters::hlr):
563     glEnable (GL_STENCIL_TEST);                   525     glEnable (GL_STENCIL_TEST);
564     // The stencil buffer is cleared in G4Open    526     // The stencil buffer is cleared in G4OpenGLViewer::ClearView.
565     // The procedure below leaves it clear.       527     // The procedure below leaves it clear.
566     glStencilFunc (GL_ALWAYS, 0, 1);              528     glStencilFunc (GL_ALWAYS, 0, 1);
567     glStencilOp (GL_INVERT, GL_INVERT, GL_INVE    529     glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
568     glEnable (GL_DEPTH_TEST);                     530     glEnable (GL_DEPTH_TEST);
569     glDepthFunc (GL_LEQUAL);                      531     glDepthFunc (GL_LEQUAL);
570     if (isTransparent) {                       << 532     if (materialColour[3] < 1.) {
571       // Transparent...                           533       // Transparent...
572       glColorMaterial(GL_FRONT_AND_BACK, GL_AM << 534       glDisable (GL_CULL_FACE);
573       glEnable(GL_COLOR_MATERIAL);             << 
574       //glDisable (GL_CULL_FACE);              << 
575       glPolygonMode (GL_FRONT_AND_BACK, GL_LIN    535       glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
576     } else {                                      536     } else {
577       // Opaque...                                537       // Opaque...
578       if (clipping) {                             538       if (clipping) {
579         glColorMaterial(GL_FRONT_AND_BACK, GL_ << 539   glDisable (GL_CULL_FACE);
580         glEnable(GL_COLOR_MATERIAL);           << 
581   //glDisable (GL_CULL_FACE);                  << 
582   glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);     540   glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
583       } else {                                    541       } else {
584         glColorMaterial(GL_FRONT, GL_AMBIENT_A << 542   glEnable (GL_CULL_FACE);
585         glEnable(GL_COLOR_MATERIAL);           << 543   glCullFace (GL_BACK);
586   //glEnable (GL_CULL_FACE);                   << 
587   //glCullFace (GL_BACK);                      << 
588   glPolygonMode (GL_FRONT, GL_LINE);              544   glPolygonMode (GL_FRONT, GL_LINE);
589       }                                           545       }
590     }                                             546     }
                                                   >> 547     glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());
591     break;                                        548     break;
592   case (G4ViewParameters::hsr):                   549   case (G4ViewParameters::hsr):
593     glEnable (GL_DEPTH_TEST);                     550     glEnable (GL_DEPTH_TEST);
594     glDepthFunc (GL_LEQUAL);                      551     glDepthFunc (GL_LEQUAL);    
595     if (isTransparent) {                       << 552     if (materialColour[3] < 1.) {
596       // Transparent...                           553       // Transparent...
597       glDepthMask (GL_FALSE);  // Make depth b << 554       glDepthMask (0);  // Make depth buffer read-only.
598       glColorMaterial(GL_FRONT_AND_BACK, GL_AM << 555       glDisable (GL_CULL_FACE);
599       glEnable(GL_COLOR_MATERIAL);             << 
600       //glDisable (GL_CULL_FACE);              << 
601       glPolygonMode (GL_FRONT_AND_BACK, GL_FIL    556       glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
                                                   >> 557       glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, materialColour);
602     } else {                                      558     } else {
603       // Opaque...                                559       // Opaque...
604       glDepthMask (GL_TRUE);  // Make depth bu << 560       glDepthMask (1);  // Make depth buffer writable (default).
605       if (clipping) {                             561       if (clipping) {
606         glColorMaterial(GL_FRONT_AND_BACK, GL_ << 562   glDisable (GL_CULL_FACE);
607         glEnable(GL_COLOR_MATERIAL);           << 
608   //glDisable (GL_CULL_FACE);                  << 
609   glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);     563   glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
610       } else {                                    564       } else {
611         glColorMaterial(GL_FRONT, GL_AMBIENT_A << 565   glEnable (GL_CULL_FACE);
612         glEnable(GL_COLOR_MATERIAL);           << 566   glCullFace (GL_BACK);
613         //glEnable (GL_CULL_FACE);             << 
614   //glCullFace (GL_BACK);                      << 
615   glPolygonMode (GL_FRONT, GL_FILL);              567   glPolygonMode (GL_FRONT, GL_FILL);
616       }                                           568       }
                                                   >> 569       glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColour);
617     }                                             570     }
618     if (!fProcessing2D) glEnable (GL_LIGHTING)    571     if (!fProcessing2D) glEnable (GL_LIGHTING);
619       break;                                   << 572     break;
620   case (G4ViewParameters::wireframe):             573   case (G4ViewParameters::wireframe):
621   default:                                        574   default:
622     glEnable (GL_DEPTH_TEST);                     575     glEnable (GL_DEPTH_TEST);
623     glDepthFunc (GL_LEQUAL);    //??? was GL_A    576     glDepthFunc (GL_LEQUAL);    //??? was GL_ALWAYS
624     //glDisable (GL_CULL_FACE);                << 577     glDisable (GL_CULL_FACE);
625     glPolygonMode (GL_FRONT_AND_BACK, GL_LINE)    578     glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
                                                   >> 579     glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());
626     break;                                        580     break;
627   }                                               581   }
628                                                   582 
629   //Loop through all the facets...                583   //Loop through all the facets...
630   fEdgeFlag = true;                            << 
631   glBegin (GL_QUADS);                             584   glBegin (GL_QUADS);
632   glEdgeFlag (GL_TRUE);                        << 
633   G4bool notLastFace;                             585   G4bool notLastFace;
634   do {                                            586   do {
635                                                   587 
636     //First, find vertices, edgeflags and norm    588     //First, find vertices, edgeflags and normals and note "not last facet"...
637     G4Point3D vertex[4];                          589     G4Point3D vertex[4];
638     G4int edgeFlag[4];                            590     G4int edgeFlag[4];
639     G4Normal3D normals[4];                        591     G4Normal3D normals[4];
640     G4int nEdges;                              << 592     G4int n;
641     notLastFace = polyhedron.GetNextFacet(nEdg << 593     notLastFace = polyhedron.GetNextFacet(n, vertex, edgeFlag, normals);
642                                                   594 
643     //Loop through the four edges of each G4Fa    595     //Loop through the four edges of each G4Facet...
644     for(G4int edgeCount = 0; edgeCount < nEdge << 596     G4int edgeCount = 0;
                                                   >> 597     for(edgeCount = 0; edgeCount < n; ++edgeCount) {
645       // Check to see if edge is visible or no    598       // Check to see if edge is visible or not...
646       if (isAuxEdgeVisible) {                     599       if (isAuxEdgeVisible) {
647   edgeFlag[edgeCount] = 1;                        600   edgeFlag[edgeCount] = 1;
648       }                                           601       }
649       if (edgeFlag[edgeCount] > 0) {              602       if (edgeFlag[edgeCount] > 0) {
650         if (fEdgeFlag != true) {               << 603   glEdgeFlag (GL_TRUE);
651           glEdgeFlag (GL_TRUE);                << 
652           fEdgeFlag = true;                    << 
653         }                                      << 
654       } else {                                    604       } else {
655         if (fEdgeFlag != false) {              << 605   glEdgeFlag (GL_FALSE);
656           glEdgeFlag (GL_FALSE);               << 
657           fEdgeFlag = false;                   << 
658         }                                      << 
659       }                                           606       }
660       glNormal3d (normals[edgeCount].x(),      << 607       glNormal3d (normals[edgeCount].x(), 
661       normals[edgeCount].y(),                     608       normals[edgeCount].y(),
662       normals[edgeCount].z());                    609       normals[edgeCount].z());
663       glVertex3d (vertex[edgeCount].x(),          610       glVertex3d (vertex[edgeCount].x(), 
664       vertex[edgeCount].y(),                      611       vertex[edgeCount].y(),
665       vertex[edgeCount].z());                     612       vertex[edgeCount].z());
666     }                                             613     }
667                                                << 
668     // HepPolyhedron produces triangles too; i    614     // HepPolyhedron produces triangles too; in that case add an extra
669     // vertex identical to first...               615     // vertex identical to first...
670     if (nEdges == 3) {                         << 616     if (n == 3) {
671       G4int edgeCount = 3;                     << 617       edgeCount = 3;
672       normals[edgeCount] = normals[0];            618       normals[edgeCount] = normals[0];
673       vertex[edgeCount] = vertex[0];              619       vertex[edgeCount] = vertex[0];
674       edgeFlag[edgeCount] = -1;                   620       edgeFlag[edgeCount] = -1;
675       if (fEdgeFlag != false) {                << 621       glEdgeFlag (GL_FALSE);
676         glEdgeFlag (GL_FALSE);                 << 
677         fEdgeFlag = false;                     << 
678       }                                        << 
679                                                << 
680       glNormal3d (normals[edgeCount].x(),         622       glNormal3d (normals[edgeCount].x(),
681       normals[edgeCount].y(),                     623       normals[edgeCount].y(), 
682       normals[edgeCount].z());                    624       normals[edgeCount].z());
683       glVertex3d (vertex[edgeCount].x(),          625       glVertex3d (vertex[edgeCount].x(),
684       vertex[edgeCount].y(),                      626       vertex[edgeCount].y(), 
685       vertex[edgeCount].z());                     627       vertex[edgeCount].z());
686     }                                             628     }
687     // Trap situation where number of edges is    629     // Trap situation where number of edges is > 4...
688     if (nEdges > 4) {                          << 630     if (n > 4) {
689       G4cerr <<                                   631       G4cerr <<
690   "G4OpenGLSceneHandler::AddPrimitive(G4Polyhe << 632   "G4OpenGLSceneHandler::AddPrimitive(G4Polyhedron): WARNING";
691   "\n   G4Polyhedron facet with " << nEdges << << 633       G4PhysicalVolumeModel* pPVModel =
                                                   >> 634   dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
                                                   >> 635       if (pPVModel) {
                                                   >> 636   G4VPhysicalVolume* pCurrentPV = pPVModel->GetCurrentPV();
                                                   >> 637   G4LogicalVolume* pCurrentLV = pPVModel->GetCurrentLV();
                                                   >> 638   G4cerr <<
                                                   >> 639   "\n  Volume " << pCurrentPV->GetName() <<
                                                   >> 640   ", Solid " << pCurrentLV->GetSolid()->GetName() <<
                                                   >> 641     " (" << pCurrentLV->GetSolid()->GetEntityType();
                                                   >> 642       }
                                                   >> 643       G4cerr<<
                                                   >> 644   "\n   G4Polyhedron facet with " << n << " edges" << G4endl;
692     }                                             645     }
693                                                   646 
694                                                << 
695     // Do it all over again (twice) for hlr...    647     // Do it all over again (twice) for hlr...
696     if  (drawing_style == G4ViewParameters::hl    648     if  (drawing_style == G4ViewParameters::hlr ||
697    drawing_style == G4ViewParameters::hlhsr) {    649    drawing_style == G4ViewParameters::hlhsr) {
698                                                   650 
699       glDisable(GL_COLOR_MATERIAL); // Revert  << 
700       glEnd ();  // Placed here to balance glB    651       glEnd ();  // Placed here to balance glBegin above, allowing GL
701                                                << 652      // state changes below, then glBegin again.  Avoids
702       // state changes below, then glBegin aga << 
703      // having glBegin/End pairs *inside* loop    653      // having glBegin/End pairs *inside* loop in the more
704      // usual case of no hidden line removal.     654      // usual case of no hidden line removal.
705                                                   655 
706       // Lighting disabled unless otherwise re    656       // Lighting disabled unless otherwise requested
707       glDisable (GL_LIGHTING);                    657       glDisable (GL_LIGHTING);
708                                                   658 
709       // Draw through stencil...                  659       // Draw through stencil...
710       glStencilFunc (GL_EQUAL, 0, 1);             660       glStencilFunc (GL_EQUAL, 0, 1);
711       glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);    661       glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
712       if (drawing_style == G4ViewParameters::h    662       if (drawing_style == G4ViewParameters::hlhsr) {
713   if (!fProcessing2D) glEnable (GL_LIGHTING);     663   if (!fProcessing2D) glEnable (GL_LIGHTING);
714       }                                           664       }
715       glEnable (GL_DEPTH_TEST);                   665       glEnable (GL_DEPTH_TEST);
716       glDepthFunc (GL_LEQUAL);                    666       glDepthFunc (GL_LEQUAL);    
717       if (isTransparent) {                     << 667       if (materialColour[3] < 1.) {
718   // Transparent...                               668   // Transparent...
719   glDepthMask (GL_FALSE);  // Make depth buffe << 669   glDepthMask (0);  // Make depth buffer read-only.
720   //glDisable (GL_CULL_FACE);                  << 670   glDisable (GL_CULL_FACE);
721   glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);     671   glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
722       } else {                                    672       } else {
723   // Opaque...                                    673   // Opaque...
724   glDepthMask (GL_TRUE);  // Make depth buffer << 674   glDepthMask (1);  // Make depth buffer writable (default).
725   if (clipping) {                                 675   if (clipping) {
726     //glDisable (GL_CULL_FACE);                << 676     glDisable (GL_CULL_FACE);
727     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL)    677     glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
728   } else {                                        678   } else {
729     //glEnable (GL_CULL_FACE);                 << 679     glEnable (GL_CULL_FACE);
730     //glCullFace (GL_BACK);                    << 680     glCullFace (GL_BACK);
731     glPolygonMode (GL_FRONT, GL_FILL);            681     glPolygonMode (GL_FRONT, GL_FILL);
732   }                                               682   }
733       }                                           683       }
                                                   >> 684       GLfloat* painting_colour;
734       if  (drawing_style == G4ViewParameters::    685       if  (drawing_style == G4ViewParameters::hlr) {
735   if (isTransparent) {                         << 686   if (materialColour[3] < 1.) {
736     // Transparent - don't paint...               687     // Transparent - don't paint...
737     goto end_of_drawing_through_stencil;          688     goto end_of_drawing_through_stencil;
738   }                                               689   }
                                                   >> 690   painting_colour = clear_colour;
                                                   >> 691       } else {  // drawing_style == G4ViewParameters::hlhsr
                                                   >> 692   painting_colour = materialColour;
739       }                                           693       }
740       if (isTransparent) {                     << 694       if (materialColour[3] < 1.) {
741   // Transparent...                               695   // Transparent...
742   glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_    696   glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, painting_colour);
743       } else {                                    697       } else {
744   // Opaque...                                    698   // Opaque...
745   glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFU    699   glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, painting_colour);
746       }                                           700       }
747       glColor4fv (painting_colour);               701       glColor4fv (painting_colour);
748       glBegin (GL_QUADS);                         702       glBegin (GL_QUADS);
749       glEdgeFlag (GL_TRUE);                    << 
750       fEdgeFlag = true;                        << 
751                                                << 
752       for (int edgeCount = 0; edgeCount < 4; +    703       for (int edgeCount = 0; edgeCount < 4; ++edgeCount) {
753         if (edgeFlag[edgeCount] > 0) {         << 704   if (edgeFlag[edgeCount] > 0) {
754           if (fEdgeFlag != true) {             << 705     glEdgeFlag (GL_TRUE);
755             glEdgeFlag (GL_TRUE);              << 706   } else {
756             fEdgeFlag = true;                  << 707     glEdgeFlag (GL_FALSE);
757           }                                    << 708   }
758         } else {                               << 709   glNormal3d (normals[edgeCount].x(), 
759           if (fEdgeFlag != false) {            << 710         normals[edgeCount].y(),
760             glEdgeFlag (GL_FALSE);             << 711         normals[edgeCount].z());
761             fEdgeFlag = false;                 << 712   glVertex3d (vertex[edgeCount].x(), 
762           }                                    << 713         vertex[edgeCount].y(),
763         }                                      << 714         vertex[edgeCount].z());
764         glNormal3d (normals[edgeCount].x(),    << 
765                     normals[edgeCount].y(),    << 
766                     normals[edgeCount].z());   << 
767         glVertex3d (vertex[edgeCount].x(),     << 
768                     vertex[edgeCount].y(),     << 
769                     vertex[edgeCount].z());    << 
770       }                                           715       }
771       glEnd ();                                   716       glEnd ();
772     end_of_drawing_through_stencil:               717     end_of_drawing_through_stencil:
773                                                   718 
774       // and once more to reset the stencil bi    719       // and once more to reset the stencil bits...
775       glStencilFunc (GL_ALWAYS, 0, 1);            720       glStencilFunc (GL_ALWAYS, 0, 1);
776       glStencilOp (GL_INVERT, GL_INVERT, GL_IN    721       glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
777       glDepthFunc (GL_LEQUAL);  // to make sur    722       glDepthFunc (GL_LEQUAL);  // to make sure line gets drawn.  
778       if (isTransparent) {                     << 723       if (materialColour[3] < 1.) {
779   // Transparent...                               724   // Transparent...
780   //glDisable (GL_CULL_FACE);                  << 725   glDisable (GL_CULL_FACE);
781   glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);     726   glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
782       } else {                                    727       } else {
783   // Opaque...                                    728   // Opaque...
784   if (clipping) {                                 729   if (clipping) {
785     //glDisable (GL_CULL_FACE);                << 730     glDisable (GL_CULL_FACE);
786     glPolygonMode (GL_FRONT_AND_BACK, GL_LINE)    731     glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
787   } else {                                        732   } else {
788     //glEnable (GL_CULL_FACE);                 << 733     glEnable (GL_CULL_FACE);
789     //glCullFace (GL_BACK);                    << 734     glCullFace (GL_BACK);
790     glPolygonMode (GL_FRONT, GL_LINE);            735     glPolygonMode (GL_FRONT, GL_LINE);
791   }                                               736   }
792       }                                           737       }
793       glDisable (GL_LIGHTING);                    738       glDisable (GL_LIGHTING);
794       glColor4fv (current_colour);             << 739       glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());
795       fEdgeFlag = true;                        << 
796       glBegin (GL_QUADS);                         740       glBegin (GL_QUADS);
797       glEdgeFlag (GL_TRUE);                    << 
798       fEdgeFlag = true;                        << 
799       for (int edgeCount = 0; edgeCount < 4; +    741       for (int edgeCount = 0; edgeCount < 4; ++edgeCount) {
800         if (edgeFlag[edgeCount] > 0) {         << 742   if (edgeFlag[edgeCount] > 0) {
801           if (fEdgeFlag != true) {             << 743     glEdgeFlag (GL_TRUE);
802             glEdgeFlag (GL_TRUE);              << 744   } else {
803             fEdgeFlag = true;                  << 745     glEdgeFlag (GL_FALSE);
804           }                                    << 746   }
805         } else {                               << 747   glNormal3d (normals[edgeCount].x(), 
806           if (fEdgeFlag != false) {            << 748         normals[edgeCount].y(),
807             glEdgeFlag (GL_FALSE);             << 749         normals[edgeCount].z());
808             fEdgeFlag = false;                 << 750   glVertex3d (vertex[edgeCount].x(), 
809           }                                    << 751         vertex[edgeCount].y(),
810         }                                      << 752         vertex[edgeCount].z());
811         glNormal3d (normals[edgeCount].x(),    << 
812                     normals[edgeCount].y(),    << 
813                     normals[edgeCount].z());   << 
814         glVertex3d (vertex[edgeCount].x(),     << 
815                     vertex[edgeCount].y(),     << 
816                     vertex[edgeCount].z());    << 
817       }                                           753       }
818       glEnd ();                                   754       glEnd ();
819                                                << 
820       glDepthFunc (GL_LEQUAL);   // Revert for    755       glDepthFunc (GL_LEQUAL);   // Revert for next facet.
821       fEdgeFlag = true;                        << 
822       glBegin (GL_QUADS);      // Ready for ne    756       glBegin (GL_QUADS);      // Ready for next facet.  GL
823       glEdgeFlag (GL_TRUE);                    << 757              // says it ignores incomplete
824       fEdgeFlag = true;                        << 758              // quadrilaterals, so final empty
825       // says it ignores incomplete            << 759              // glBegin/End sequence should be OK.
826       // quadrilaterals, so final empty        << 
827       // glBegin/End sequence should be OK.    << 
828     }                                             760     }
829   } while (notLastFace);                          761   } while (notLastFace);  
830                                                   762   
831   glEnd ();                                       763   glEnd ();
832   glDisable (GL_STENCIL_TEST);  // Revert to d    764   glDisable (GL_STENCIL_TEST);  // Revert to default for next primitive.
833   glDepthMask (GL_TRUE);        // Revert to d << 765   glDepthMask (1);              // Revert to default for next primitive.
834   glDisable (GL_LIGHTING);      // Revert to d    766   glDisable (GL_LIGHTING);      // Revert to default for next primitive.
835 }                                                 767 }
836                                                   768 
                                                   >> 769 //Method for handling G4NURBS objects for drawing solids.
                                                   >> 770 //Knots and Ctrl Pnts MUST be arrays of GLfloats.
                                                   >> 771 void G4OpenGLSceneHandler::AddPrimitive (const G4NURBS& nurb) {
                                                   >> 772 
                                                   >> 773   // Loads G4Atts for picking...
                                                   >> 774   if (fpViewer->GetViewParameters().IsPicking()) {
                                                   >> 775     G4AttHolder* holder = new G4AttHolder;
                                                   >> 776     LoadAtts(nurb, holder);
                                                   >> 777     fPickMap[fPickName] = holder;
                                                   >> 778   }
                                                   >> 779 
                                                   >> 780   GLUnurbsObj *gl_nurb;
                                                   >> 781   gl_nurb = gluNewNurbsRenderer ();
                                                   >> 782 
                                                   >> 783   GLfloat *u_knot_array, *u_knot_array_ptr;
                                                   >> 784   u_knot_array = u_knot_array_ptr = new GLfloat [nurb.GetnbrKnots(G4NURBS::U)];
                                                   >> 785   G4NURBS::KnotsIterator u_iterator (nurb, G4NURBS::U);
                                                   >> 786   while (u_iterator.pick (u_knot_array_ptr++)){}
                                                   >> 787 
                                                   >> 788   GLfloat *v_knot_array, *v_knot_array_ptr;
                                                   >> 789   v_knot_array = v_knot_array_ptr = new GLfloat [nurb.GetnbrKnots(G4NURBS::V)];
                                                   >> 790   G4NURBS::KnotsIterator v_iterator (nurb, G4NURBS::V);
                                                   >> 791   while (v_iterator.pick (v_knot_array_ptr++)){}
                                                   >> 792 
                                                   >> 793   GLfloat *ctrl_pnt_array, *ctrl_pnt_array_ptr;
                                                   >> 794   ctrl_pnt_array = ctrl_pnt_array_ptr =
                                                   >> 795     new GLfloat [nurb.GettotalnbrCtrlPts () * G4NURBS::NofC];
                                                   >> 796   G4NURBS::CtrlPtsCoordsIterator c_p_iterator (nurb);
                                                   >> 797   while (c_p_iterator.pick (ctrl_pnt_array_ptr++)){}
                                                   >> 798 
                                                   >> 799   // Get vis attributes - pick up defaults if none.
                                                   >> 800   const G4VisAttributes* pVA =
                                                   >> 801     fpViewer -> GetApplicableVisAttributes (nurb.GetVisAttributes ());
                                                   >> 802 
                                                   >> 803   // Get view parameters that the user can force through the vis
                                                   >> 804   // attributes, thereby over-riding the current view parameter.
                                                   >> 805   G4ViewParameters::DrawingStyle drawing_style = GetDrawingStyle (pVA);
                                                   >> 806   //G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA);
                                                   >> 807   
                                                   >> 808   //Get colour, etc..
                                                   >> 809   const G4Colour& c = pVA -> GetColour ();
                                                   >> 810 
                                                   >> 811   switch (drawing_style) {
                                                   >> 812 
                                                   >> 813   case (G4ViewParameters::hlhsr):
                                                   >> 814     //    G4cout << "Hidden line removal not implememented in G4OpenGL.\n"
                                                   >> 815     // << "Using hidden surface removal." << G4endl;
                                                   >> 816   case (G4ViewParameters::hsr):
                                                   >> 817     {
                                                   >> 818       if (!fProcessing2D) glEnable (GL_LIGHTING);
                                                   >> 819       glEnable (GL_DEPTH_TEST);
                                                   >> 820       glEnable (GL_AUTO_NORMAL);
                                                   >> 821       glEnable (GL_NORMALIZE);
                                                   >> 822       gluNurbsProperty (gl_nurb, GLU_DISPLAY_MODE, GLU_FILL);
                                                   >> 823       gluNurbsProperty (gl_nurb, GLU_SAMPLING_TOLERANCE, 50.0);
                                                   >> 824       GLfloat materialColour [4];
                                                   >> 825       materialColour [0] = c.GetRed ();
                                                   >> 826       materialColour [1] = c.GetGreen ();
                                                   >> 827       materialColour [2] = c.GetBlue ();
                                                   >> 828       materialColour [3] = 1.0;  // = c.GetAlpha () for transparency -
                                                   >> 829          // but see complication in
                                                   >> 830          // AddPrimitive(const G4Polyhedron&).
                                                   >> 831       glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, materialColour);
                                                   >> 832       break;
                                                   >> 833     }
                                                   >> 834   case (G4ViewParameters::hlr):
                                                   >> 835     //    G4cout << "Hidden line removal not implememented in G4OpenGL.\n"
                                                   >> 836     // << "Using wireframe." << G4endl;
                                                   >> 837   case (G4ViewParameters::wireframe):
                                                   >> 838   default:
                                                   >> 839     glDisable (GL_LIGHTING);
                                                   >> 840 //    glDisable (GL_DEPTH_TEST);
                                                   >> 841     glEnable (GL_DEPTH_TEST);
                                                   >> 842     glDisable (GL_AUTO_NORMAL);
                                                   >> 843     glDisable (GL_NORMALIZE);
                                                   >> 844     gluNurbsProperty (gl_nurb, GLU_DISPLAY_MODE, GLU_OUTLINE_POLYGON);
                                                   >> 845     gluNurbsProperty (gl_nurb, GLU_SAMPLING_TOLERANCE, 50.0);
                                                   >> 846     glColor3d (c.GetRed (), c.GetGreen (), c.GetBlue ());
                                                   >> 847     break;
                                                   >> 848   } 
                                                   >> 849 
                                                   >> 850   gluBeginSurface (gl_nurb);
                                                   >> 851   G4int u_stride = 4;
                                                   >> 852   G4int v_stride = nurb.GetnbrCtrlPts(G4NURBS::U) * 4;
                                                   >> 853 
                                                   >> 854   gluNurbsSurface (gl_nurb, 
                                                   >> 855        nurb.GetnbrKnots (G4NURBS::U), (GLfloat*)u_knot_array, 
                                                   >> 856        nurb.GetnbrKnots (G4NURBS::V), (GLfloat*)v_knot_array,
                                                   >> 857        u_stride,
                                                   >> 858        v_stride,  
                                                   >> 859        ctrl_pnt_array,
                                                   >> 860        nurb.GetUorder (),
                                                   >> 861        nurb.GetVorder (), 
                                                   >> 862        GL_MAP2_VERTEX_4);
                                                   >> 863   
                                                   >> 864   gluEndSurface (gl_nurb);
                                                   >> 865 
                                                   >> 866   delete [] u_knot_array;  // These should be allocated with smart allocators
                                                   >> 867   delete [] v_knot_array;  // to avoid memory explosion.
                                                   >> 868   delete [] ctrl_pnt_array;
                                                   >> 869 
                                                   >> 870   gluDeleteNurbsRenderer (gl_nurb);
                                                   >> 871 }
                                                   >> 872 
837 void G4OpenGLSceneHandler::AddCompound(const G    873 void G4OpenGLSceneHandler::AddCompound(const G4VTrajectory& traj) {
838   G4VSceneHandler::AddCompound(traj);  // For     874   G4VSceneHandler::AddCompound(traj);  // For now.
839 }                                                 875 }
840                                                   876 
841 void G4OpenGLSceneHandler::AddCompound(const G    877 void G4OpenGLSceneHandler::AddCompound(const G4VHit& hit) {
842   G4VSceneHandler::AddCompound(hit);  // For n    878   G4VSceneHandler::AddCompound(hit);  // For now.
843 }                                                 879 }
844                                                   880 
845 void G4OpenGLSceneHandler::AddCompound(const G    881 void G4OpenGLSceneHandler::AddCompound(const G4VDigi& digi) {
846   G4VSceneHandler::AddCompound(digi);  // For     882   G4VSceneHandler::AddCompound(digi);  // For now.
847 }                                                 883 }
848                                                   884 
849 void G4OpenGLSceneHandler::AddCompound(const G    885 void G4OpenGLSceneHandler::AddCompound(const G4THitsMap<G4double>& hits) {
850   G4VSceneHandler::AddCompound(hits);  // For     886   G4VSceneHandler::AddCompound(hits);  // For now.
851 }                                                 887 }
852                                                   888 
853 void G4OpenGLSceneHandler::AddCompound(const G << 889 #endif
854   G4VSceneHandler::AddCompound(hits);  // For  << 
855 }                                              << 
856                                                << 
857 void G4OpenGLSceneHandler::AddCompound(const G << 
858   StandardSpecialMeshRendering(mesh);          << 
859 }                                              << 
860                                                   890