Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/HepRep/src/G4HepRepFileSceneHandler.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/HepRep/src/G4HepRepFileSceneHandler.cc (Version 11.3.0) and /visualization/HepRep/src/G4HepRepFileSceneHandler.cc (Version 10.4)


  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 // $Id: G4HepRepFileSceneHandler.cc 101714 2016-11-22 08:53:13Z gcosmo $
 26 //                                                 27 //
 27 //                                                 28 //
 28 // Joseph Perl  27th January 2002                  29 // Joseph Perl  27th January 2002
 29 // A base class for a scene handler to export      30 // A base class for a scene handler to export geometry and trajectories
 30 // to the HepRep xml file format.                  31 // to the HepRep xml file format.
 31                                                    32 
 32 #include "G4HepRepFileSceneHandler.hh"             33 #include "G4HepRepFileSceneHandler.hh"
 33 #include "G4HepRepFile.hh"                         34 #include "G4HepRepFile.hh"
 34 #include "G4HepRepMessenger.hh"                    35 #include "G4HepRepMessenger.hh"
 35 #include "G4UIcommand.hh"                          36 #include "G4UIcommand.hh"
 36                                                    37 
 37 #include "G4PhysicalConstants.hh"                  38 #include "G4PhysicalConstants.hh"
 38 #include "G4SystemOfUnits.hh"                      39 #include "G4SystemOfUnits.hh"
 39 #include "G4Version.hh"                            40 #include "G4Version.hh"
 40 #include "G4VSolid.hh"                             41 #include "G4VSolid.hh"
 41 #include "G4PhysicalVolumeModel.hh"                42 #include "G4PhysicalVolumeModel.hh"
 42 #include "G4VPhysicalVolume.hh"                    43 #include "G4VPhysicalVolume.hh"
 43 #include "G4LogicalVolume.hh"                      44 #include "G4LogicalVolume.hh"
 44 #include "G4RotationMatrix.hh"                     45 #include "G4RotationMatrix.hh"
 45 #include "G4Material.hh"                           46 #include "G4Material.hh"
 46 #include "G4Polymarker.hh"                         47 #include "G4Polymarker.hh"
 47 #include "G4Polyline.hh"                           48 #include "G4Polyline.hh"
 48 #include "G4Text.hh"                               49 #include "G4Text.hh"
 49 #include "G4Circle.hh"                             50 #include "G4Circle.hh"
 50 #include "G4Square.hh"                             51 #include "G4Square.hh"
 51 #include "G4Polyhedron.hh"                         52 #include "G4Polyhedron.hh"
 52 #include "G4VTrajectory.hh"                        53 #include "G4VTrajectory.hh"
 53 #include "G4VTrajectoryPoint.hh"                   54 #include "G4VTrajectoryPoint.hh"
 54 #include "G4TrajectoriesModel.hh"                  55 #include "G4TrajectoriesModel.hh"
 55 #include "G4VHit.hh"                               56 #include "G4VHit.hh"
 56 #include "G4AttDef.hh"                             57 #include "G4AttDef.hh"
 57 #include "G4AttValue.hh"                           58 #include "G4AttValue.hh"
 58 #include "G4AttCheck.hh"                           59 #include "G4AttCheck.hh"
 59 #include "G4VisManager.hh"                         60 #include "G4VisManager.hh"
 60 #include "G4VisTrajContext.hh"                     61 #include "G4VisTrajContext.hh"
 61 #include "G4VTrajectoryModel.hh"                   62 #include "G4VTrajectoryModel.hh"
 62                                                    63 
 63 // HepRep                                      <<  64 //HepRep
 64 #include "G4HepRepFileXMLWriter.hh"                65 #include "G4HepRepFileXMLWriter.hh"
 65                                                    66 
 66 G4int G4HepRepFileSceneHandler::fSceneIdCount      67 G4int G4HepRepFileSceneHandler::fSceneIdCount = 0;
 67 // Counter for HepRep scene handlers.              68 // Counter for HepRep scene handlers.
 68                                                    69 
 69 G4HepRepFileSceneHandler::G4HepRepFileSceneHan     70 G4HepRepFileSceneHandler::G4HepRepFileSceneHandler(G4VGraphicsSystem& system,
 70                                                <<  71                            const G4String& name):
 71   : G4VSceneHandler(system, fSceneIdCount++, n <<  72 G4VSceneHandler(system, fSceneIdCount++, name)
 72 {                                                  73 {
 73   hepRepXMLWriter = ((G4HepRepFile*) (&system) <<  74   hepRepXMLWriter = ((G4HepRepFile*)(&system))->GetHepRepXMLWriter();
 74   fileCounter     = 0;                         <<  75   fileCounter = 0;
 75                                                <<  76   
 76   inPrimitives2D       = false;                <<  77   inPrimitives2D = false;
 77   warnedAbout3DText    = false;                <<  78   warnedAbout3DText = false;
 78   warnedAbout2DMarkers = false;                <<  79   warnedAbout2DMarkers = false;
 79   haveVisible          = false;                <<  80   haveVisible = false;
 80   drawingTraj          = false;                <<  81   drawingTraj = false;
 81   doneInitTraj         = false;                <<  82   doneInitTraj = false;
 82   drawingHit           = false;                <<  83   drawingHit = false;
 83   doneInitHit          = false;                <<  84   doneInitHit = false;
 84   trajContext          = 0;                    <<  85         trajContext = 0;
 85   trajAttValues        = 0;                    <<  86         trajAttValues = 0;
 86   trajAttDefs          = 0;                    <<  87         trajAttDefs = 0;
 87   hitAttValues         = 0;                    <<  88         hitAttValues = 0;
 88   hitAttDefs           = 0;                    <<  89         hitAttDefs = 0;
 89 }                                              << 
 90                                                << 
 91 G4HepRepFileSceneHandler::~G4HepRepFileSceneHa << 
 92                                                << 
 93 void G4HepRepFileSceneHandler::BeginModeling() << 
 94 {                                              << 
 95   G4VisManager* visManager        = G4VisManag << 
 96   const G4VTrajectoryModel* model = visManager << 
 97   trajContext                     = &model->Ge << 
 98                                                << 
 99   G4VSceneHandler::BeginModeling();  // Requir << 
100 }                                              << 
101                                                << 
102 void G4HepRepFileSceneHandler::EndModeling()   << 
103 {                                              << 
104   G4VSceneHandler::EndModeling();  // Required << 
105 }                                              << 
106                                                << 
107 void G4HepRepFileSceneHandler::BeginPrimitives << 
108   const G4Transform3D& objectTransformation)   << 
109 {                                              << 
110 #ifdef G4HEPREPFILEDEBUG                       << 
111   G4cout << "G4HepRepFileSceneHandler::BeginPr << 
112 #endif                                         << 
113   inPrimitives2D = true;                       << 
114   G4VSceneHandler::BeginPrimitives2D(objectTra << 
115 }                                              << 
116                                                << 
117 void G4HepRepFileSceneHandler::EndPrimitives2D << 
118 {                                              << 
119 #ifdef G4HEPREPFILEDEBUG                       << 
120   G4cout << "G4HepRepFileSceneHandler::EndPrim << 
121 #endif                                         << 
122   G4VSceneHandler::EndPrimitives2D();          << 
123   inPrimitives2D = false;                      << 
124 }                                              << 
125                                                << 
126 #ifdef G4HEPREPFILEDEBUG                       << 
127 void G4HepRepFileSceneHandler::PrintThings()   << 
128 {                                              << 
129   G4cout << "  with transformation " << fObjec << 
130   G4PhysicalVolumeModel* pPVModel =            << 
131     dynamic_cast<G4PhysicalVolumeModel*>(fpMod << 
132   if(pPVModel)                                 << 
133   {                                            << 
134     G4VPhysicalVolume* pCurrentPV = pPVModel-> << 
135     G4LogicalVolume* pCurrentLV   = pPVModel-> << 
136     G4int currentDepth            = pPVModel-> << 
137     G4cout << "\n  current physical volume: "  << 
138            << "\n  current logical volume: " < << 
139            << "\n  current depth of geometry t << 
140   }                                            << 
141   G4cout << G4endl;                            << 
142 }                                              << 
143 #endif                                         << 
144                                                << 
145 void G4HepRepFileSceneHandler::AddSolid(const  << 
146 {                                              << 
147 #ifdef G4HEPREPFILEDEBUG                       << 
148   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
149          << box.GetName() << G4endl;           << 
150   PrintThings();                               << 
151 #endif                                         << 
152                                                << 
153   if(drawingTraj)                              << 
154     return;                                    << 
155                                                << 
156   if(drawingHit)                               << 
157     InitHit();                                 << 
158                                                << 
159   haveVisible = false;                         << 
160   AddHepRepInstance("Prism", NULL);            << 
161                                                << 
162   G4HepRepMessenger* messenger = G4HepRepMesse << 
163                                                << 
164   // Get and check applicable vis attributes.  << 
165   fpVisAttribs = fpViewer->GetApplicableVisAtt << 
166   if(fpVisAttribs && (fpVisAttribs->IsVisible( << 
167      messenger->getCullInvisibles())           << 
168     return;                                    << 
169                                                << 
170   hepRepXMLWriter->addPrimitive();             << 
171                                                << 
172   G4double dx = box.GetXHalfLength();          << 
173   G4double dy = box.GetYHalfLength();          << 
174   G4double dz = box.GetZHalfLength();          << 
175                                                << 
176   G4Point3D vertex1(G4Point3D(dx, dy, -dz));   << 
177   G4Point3D vertex2(G4Point3D(dx, -dy, -dz));  << 
178   G4Point3D vertex3(G4Point3D(-dx, -dy, -dz)); << 
179   G4Point3D vertex4(G4Point3D(-dx, dy, -dz));  << 
180   G4Point3D vertex5(G4Point3D(dx, dy, dz));    << 
181   G4Point3D vertex6(G4Point3D(dx, -dy, dz));   << 
182   G4Point3D vertex7(G4Point3D(-dx, -dy, dz));  << 
183   G4Point3D vertex8(G4Point3D(-dx, dy, dz));   << 
184                                                << 
185   vertex1 = (fObjectTransformation) *vertex1;  << 
186   vertex2 = (fObjectTransformation) *vertex2;  << 
187   vertex3 = (fObjectTransformation) *vertex3;  << 
188   vertex4 = (fObjectTransformation) *vertex4;  << 
189   vertex5 = (fObjectTransformation) *vertex5;  << 
190   vertex6 = (fObjectTransformation) *vertex6;  << 
191   vertex7 = (fObjectTransformation) *vertex7;  << 
192   vertex8 = (fObjectTransformation) *vertex8;  << 
193                                                << 
194   hepRepXMLWriter->addPoint(vertex1.x(), verte << 
195   hepRepXMLWriter->addPoint(vertex2.x(), verte << 
196   hepRepXMLWriter->addPoint(vertex3.x(), verte << 
197   hepRepXMLWriter->addPoint(vertex4.x(), verte << 
198   hepRepXMLWriter->addPoint(vertex5.x(), verte << 
199   hepRepXMLWriter->addPoint(vertex6.x(), verte << 
200   hepRepXMLWriter->addPoint(vertex7.x(), verte << 
201   hepRepXMLWriter->addPoint(vertex8.x(), verte << 
202 }                                                  90 }
203                                                    91 
204 void G4HepRepFileSceneHandler::AddSolid(const  << 
205 {                                              << 
206 #ifdef G4HEPREPFILEDEBUG                       << 
207   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
208          << cons.GetName() << G4endl;          << 
209   PrintThings();                               << 
210 #endif                                         << 
211                                                << 
212   // HepRApp does not correctly represent the  << 
213   // non-standard angles, let the base class c << 
214   G4RotationMatrix r = fObjectTransformation.g << 
215   G4bool linedUpWithAnAxis =                   << 
216     (std::fabs(r.phiX()) <= .001 || std::fabs( << 
217      std::fabs(r.phiZ()) <= .001 || std::fabs( << 
218      std::fabs(r.phiY() - pi) <= .001 || std:: << 
219   // G4cout << "Angle X:" << r.phiX() << ", An << 
220   // Z:" << r.phiZ() << G4endl; G4cout << "lin << 
221   // linedUpWithAnAxis << G4endl;              << 
222                                                << 
223   // HepRep does not have a primitive for a cu << 
224   // so if this cone is cut, let the base clas << 
225   // solid to polygons.                        << 
226   G4HepRepMessenger* messenger = G4HepRepMesse << 
227   if(cons.GetDeltaPhiAngle() < twopi || !lined << 
228      messenger->renderCylAsPolygons())         << 
229   {                                            << 
230     G4VSceneHandler::AddSolid(cons);  // Invok << 
231   }                                            << 
232   else                                         << 
233   {                                            << 
234     if(drawingTraj)                            << 
235       return;                                  << 
236                                                << 
237     if(drawingHit)                             << 
238       InitHit();                               << 
239                                                << 
240     haveVisible = false;                       << 
241     AddHepRepInstance("Cylinder", NULL);       << 
242                                                << 
243     // Get and check applicable vis attributes << 
244     fpVisAttribs = fpViewer->GetApplicableVisA << 
245     if(fpVisAttribs && (fpVisAttribs->IsVisibl << 
246        messenger->getCullInvisibles())         << 
247       return;                                  << 
248                                                << 
249     G4Point3D vertex1(G4Point3D(0., 0., -cons. << 
250     G4Point3D vertex2(G4Point3D(0., 0., cons.G << 
251                                                << 
252     vertex1 = (fObjectTransformation) *vertex1 << 
253     vertex2 = (fObjectTransformation) *vertex2 << 
254                                                << 
255     // Outer cylinder.                         << 
256     hepRepXMLWriter->addPrimitive();           << 
257     hepRepXMLWriter->addAttValue("Radius1", me << 
258                                                << 
259     hepRepXMLWriter->addAttValue("Radius2", me << 
260                                                << 
261     hepRepXMLWriter->addPoint(vertex1.x(), ver << 
262     hepRepXMLWriter->addPoint(vertex2.x(), ver << 
263                                                << 
264     // Inner cylinder.                         << 
265     hepRepXMLWriter->addPrimitive();           << 
266     hepRepXMLWriter->addAttValue("Radius1", me << 
267                                                << 
268     hepRepXMLWriter->addAttValue("Radius2", me << 
269                                                << 
270     hepRepXMLWriter->addPoint(vertex1.x(), ver << 
271     hepRepXMLWriter->addPoint(vertex2.x(), ver << 
272   }                                            << 
273 }                                              << 
274                                                << 
275 void G4HepRepFileSceneHandler::AddSolid(const  << 
276 {                                              << 
277 #ifdef G4HEPREPFILEDEBUG                       << 
278   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
279          << tubs.GetName() << G4endl;          << 
280   PrintThings();                               << 
281 #endif                                         << 
282                                                << 
283   // HepRApp does not correctly represent the  << 
284   // non-standard angles, let the base class c << 
285   G4RotationMatrix r = fObjectTransformation.g << 
286   G4bool linedUpWithAnAxis =                   << 
287     (std::fabs(r.phiX()) <= .001 || std::fabs( << 
288      std::fabs(r.phiZ()) <= .001 || std::fabs( << 
289      std::fabs(r.phiY() - pi) <= .001 || std:: << 
290   // G4cout << "Angle X:" << r.phiX() << ", An << 
291   // Z:" << r.phiZ() << G4endl; G4cout << "lin << 
292   // linedUpWithAnAxis << G4endl;              << 
293                                                << 
294   // HepRep does not have a primitive for a cu << 
295   // so if this cylinder is cut, let the base  << 
296   // solid to polygons.                        << 
297   G4HepRepMessenger* messenger = G4HepRepMesse << 
298   if(tubs.GetDeltaPhiAngle() < twopi || !lined << 
299      messenger->renderCylAsPolygons())         << 
300   {                                            << 
301     G4VSceneHandler::AddSolid(tubs);  // Invok << 
302   }                                            << 
303   else                                         << 
304   {                                            << 
305     if(drawingTraj)                            << 
306       return;                                  << 
307                                                << 
308     if(drawingHit)                             << 
309       InitHit();                               << 
310                                                << 
311     haveVisible = false;                       << 
312     AddHepRepInstance("Cylinder", NULL);       << 
313                                                << 
314     // Get and check applicable vis attributes << 
315     fpVisAttribs = fpViewer->GetApplicableVisA << 
316     if(fpVisAttribs && (fpVisAttribs->IsVisibl << 
317        messenger->getCullInvisibles())         << 
318       return;                                  << 
319                                                << 
320     G4Point3D vertex1(G4Point3D(0., 0., -tubs. << 
321     G4Point3D vertex2(G4Point3D(0., 0., tubs.G << 
322                                                << 
323     vertex1 = (fObjectTransformation) *vertex1 << 
324     vertex2 = (fObjectTransformation) *vertex2 << 
325                                                << 
326     // Outer cylinder.                         << 
327     hepRepXMLWriter->addPrimitive();           << 
328     hepRepXMLWriter->addAttValue("Radius1",    << 
329                                  messenger->ge << 
330     hepRepXMLWriter->addAttValue("Radius2",    << 
331                                  messenger->ge << 
332     hepRepXMLWriter->addPoint(vertex1.x(), ver << 
333     hepRepXMLWriter->addPoint(vertex2.x(), ver << 
334                                                << 
335     // Inner cylinder.                         << 
336     if(tubs.GetInnerRadius() != 0.)            << 
337     {                                          << 
338       hepRepXMLWriter->addPrimitive();         << 
339       hepRepXMLWriter->addAttValue("Radius1",  << 
340                                                << 
341       hepRepXMLWriter->addAttValue("Radius2",  << 
342                                                << 
343       hepRepXMLWriter->addPoint(vertex1.x(), v << 
344       hepRepXMLWriter->addPoint(vertex2.x(), v << 
345     }                                          << 
346   }                                            << 
347 }                                              << 
348                                                << 
349 void G4HepRepFileSceneHandler::AddSolid(const  << 
350 {                                              << 
351 #ifdef G4HEPREPFILEDEBUG                       << 
352   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
353          << trd.GetName() << G4endl;           << 
354   PrintThings();                               << 
355 #endif                                         << 
356                                                << 
357   if(drawingTraj)                              << 
358     return;                                    << 
359                                                << 
360   if(drawingHit)                               << 
361     InitHit();                                 << 
362                                                << 
363   haveVisible = false;                         << 
364   AddHepRepInstance("Prism", NULL);            << 
365                                                << 
366   G4HepRepMessenger* messenger = G4HepRepMesse << 
367                                                << 
368   // Get and check applicable vis attributes.  << 
369   fpVisAttribs = fpViewer->GetApplicableVisAtt << 
370   if(fpVisAttribs && (fpVisAttribs->IsVisible( << 
371      messenger->getCullInvisibles())           << 
372     return;                                    << 
373                                                << 
374   hepRepXMLWriter->addPrimitive();             << 
375                                                << 
376   G4double dx1 = trd.GetXHalfLength1();        << 
377   G4double dy1 = trd.GetYHalfLength1();        << 
378   G4double dx2 = trd.GetXHalfLength2();        << 
379   G4double dy2 = trd.GetYHalfLength2();        << 
380   G4double dz  = trd.GetZHalfLength();         << 
381                                                << 
382   G4Point3D vertex1(G4Point3D(dx1, dy1, -dz)); << 
383   G4Point3D vertex2(G4Point3D(dx1, -dy1, -dz)) << 
384   G4Point3D vertex3(G4Point3D(-dx1, -dy1, -dz) << 
385   G4Point3D vertex4(G4Point3D(-dx1, dy1, -dz)) << 
386   G4Point3D vertex5(G4Point3D(dx2, dy2, dz));  << 
387   G4Point3D vertex6(G4Point3D(dx2, -dy2, dz)); << 
388   G4Point3D vertex7(G4Point3D(-dx2, -dy2, dz)) << 
389   G4Point3D vertex8(G4Point3D(-dx2, dy2, dz)); << 
390                                                << 
391   vertex1 = (fObjectTransformation) *vertex1;  << 
392   vertex2 = (fObjectTransformation) *vertex2;  << 
393   vertex3 = (fObjectTransformation) *vertex3;  << 
394   vertex4 = (fObjectTransformation) *vertex4;  << 
395   vertex5 = (fObjectTransformation) *vertex5;  << 
396   vertex6 = (fObjectTransformation) *vertex6;  << 
397   vertex7 = (fObjectTransformation) *vertex7;  << 
398   vertex8 = (fObjectTransformation) *vertex8;  << 
399                                                << 
400   hepRepXMLWriter->addPoint(vertex1.x(), verte << 
401   hepRepXMLWriter->addPoint(vertex2.x(), verte << 
402   hepRepXMLWriter->addPoint(vertex3.x(), verte << 
403   hepRepXMLWriter->addPoint(vertex4.x(), verte << 
404   hepRepXMLWriter->addPoint(vertex5.x(), verte << 
405   hepRepXMLWriter->addPoint(vertex6.x(), verte << 
406   hepRepXMLWriter->addPoint(vertex7.x(), verte << 
407   hepRepXMLWriter->addPoint(vertex8.x(), verte << 
408 }                                              << 
409                                                << 
410 void G4HepRepFileSceneHandler::AddSolid(const  << 
411 {                                              << 
412 #ifdef G4HEPREPFILEDEBUG                       << 
413   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
414          << trap.GetName() << G4endl;          << 
415   PrintThings();                               << 
416 #endif                                         << 
417   G4VSceneHandler::AddSolid(trap);  // Invoke  << 
418 }                                              << 
419                                                << 
420 void G4HepRepFileSceneHandler::AddSolid(const  << 
421 {                                              << 
422 #ifdef G4HEPREPFILEDEBUG                       << 
423   G4cout                                       << 
424     << "G4HepRepFileSceneHandler::AddSolid(con << 
425     << sphere.GetName() << G4endl;             << 
426   PrintThings();                               << 
427 #endif                                         << 
428   G4VSceneHandler::AddSolid(sphere);  // Invok << 
429 }                                              << 
430                                                    92 
431 void G4HepRepFileSceneHandler::AddSolid(const  <<  93 G4HepRepFileSceneHandler::~G4HepRepFileSceneHandler() {}
432 {                                              << 
433 #ifdef G4HEPREPFILEDEBUG                       << 
434   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
435          << para.GetName() << G4endl;          << 
436   PrintThings();                               << 
437 #endif                                         << 
438   G4VSceneHandler::AddSolid(para);  // Invoke  << 
439 }                                              << 
440                                                    94 
441 void G4HepRepFileSceneHandler::AddSolid(const  << 
442 {                                              << 
443 #ifdef G4HEPREPFILEDEBUG                       << 
444   G4cout                                       << 
445     << "G4HepRepFileSceneHandler::AddSolid(con << 
446     << torus.GetName() << G4endl;              << 
447   PrintThings();                               << 
448 #endif                                         << 
449   G4VSceneHandler::AddSolid(torus);  // Invoke << 
450 }                                              << 
451                                                    95 
452 void G4HepRepFileSceneHandler::AddSolid(const  <<  96 void G4HepRepFileSceneHandler::BeginModeling() {
453 {                                              <<  97     G4VisManager* visManager = G4VisManager::GetInstance();
454 #ifdef G4HEPREPFILEDEBUG                       <<  98     const G4VTrajectoryModel* model = visManager->CurrentTrajDrawModel();
455   G4cout << "G4HepRepFileSceneHandler::AddSoli <<  99     trajContext = & model->GetContext();
456             "called for "                      << 100   
457          << polycone.GetName() << G4endl;      << 101   G4VSceneHandler::BeginModeling();  // Required: see G4VSceneHandler.hh.
                                                   >> 102 }
                                                   >> 103 
                                                   >> 104 
                                                   >> 105 void G4HepRepFileSceneHandler::EndModeling() {
                                                   >> 106   G4VSceneHandler::EndModeling();  // Required: see G4VSceneHandler.hh.
                                                   >> 107 }
                                                   >> 108 
                                                   >> 109 void G4HepRepFileSceneHandler::BeginPrimitives2D
                                                   >> 110 (const G4Transform3D& objectTransformation) {
                                                   >> 111 #ifdef G4HEPREPFILEDEBUG
                                                   >> 112   G4cout << "G4HepRepFileSceneHandler::BeginPrimitives2D() " << G4endl;
                                                   >> 113 #endif
                                                   >> 114   inPrimitives2D = true;
                                                   >> 115   G4VSceneHandler::BeginPrimitives2D(objectTransformation);
                                                   >> 116 }
                                                   >> 117 
                                                   >> 118 void G4HepRepFileSceneHandler::EndPrimitives2D () {
                                                   >> 119 #ifdef G4HEPREPFILEDEBUG
                                                   >> 120   G4cout << "G4HepRepFileSceneHandler::EndPrimitives2D() " << G4endl;
                                                   >> 121 #endif
                                                   >> 122   G4VSceneHandler::EndPrimitives2D();
                                                   >> 123   inPrimitives2D = false;
                                                   >> 124 }
                                                   >> 125 
                                                   >> 126 
                                                   >> 127 #ifdef G4HEPREPFILEDEBUG
                                                   >> 128 void G4HepRepFileSceneHandler::PrintThings() {
                                                   >> 129   G4cout <<
                                                   >> 130     "  with transformation "
                                                   >> 131   << fObjectTransformation;
                                                   >> 132   G4PhysicalVolumeModel* pPVModel =
                                                   >> 133     dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
                                                   >> 134   if (pPVModel) {
                                                   >> 135     G4VPhysicalVolume* pCurrentPV = pPVModel->GetCurrentPV();
                                                   >> 136     G4LogicalVolume* pCurrentLV = pPVModel->GetCurrentLV();
                                                   >> 137     G4int currentDepth = pPVModel->GetCurrentDepth();
                                                   >> 138     G4cout <<
                                                   >> 139       "\n  current physical volume: "
                                                   >> 140       << pCurrentPV->GetName() <<
                                                   >> 141       "\n  current logical volume: "
                                                   >> 142       << pCurrentLV->GetName() <<
                                                   >> 143       "\n  current depth of geometry tree: "
                                                   >> 144       << currentDepth;
                                                   >> 145   }
                                                   >> 146   G4cout << G4endl;
                                                   >> 147 }
                                                   >> 148 #endif
                                                   >> 149 
                                                   >> 150 
                                                   >> 151 void G4HepRepFileSceneHandler::AddSolid(const G4Box& box) {
                                                   >> 152 #ifdef G4HEPREPFILEDEBUG
                                                   >> 153   G4cout <<
                                                   >> 154     "G4HepRepFileSceneHandler::AddSolid(const G4Box& box) called for "
                                                   >> 155   << box.GetName()
                                                   >> 156   << G4endl;
                                                   >> 157   PrintThings();
                                                   >> 158 #endif
                                                   >> 159   
                                                   >> 160   if (drawingTraj)
                                                   >> 161     return;
                                                   >> 162   
                                                   >> 163   if (drawingHit)
                                                   >> 164     InitHit();
                                                   >> 165   
                                                   >> 166   haveVisible = false;
                                                   >> 167   AddHepRepInstance("Prism", NULL);
                                                   >> 168   
                                                   >> 169   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 170   
                                                   >> 171   // Get and check applicable vis attributes.
                                                   >> 172   fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
                                                   >> 173   if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 174     return;
                                                   >> 175   
                                                   >> 176   hepRepXMLWriter->addPrimitive();
                                                   >> 177   
                                                   >> 178   G4double dx = box.GetXHalfLength();
                                                   >> 179   G4double dy = box.GetYHalfLength();
                                                   >> 180   G4double dz = box.GetZHalfLength();
                                                   >> 181   
                                                   >> 182   G4Point3D vertex1(G4Point3D( dx, dy,-dz));
                                                   >> 183   G4Point3D vertex2(G4Point3D( dx,-dy,-dz));
                                                   >> 184   G4Point3D vertex3(G4Point3D(-dx,-dy,-dz));
                                                   >> 185   G4Point3D vertex4(G4Point3D(-dx, dy,-dz));
                                                   >> 186   G4Point3D vertex5(G4Point3D( dx, dy, dz));
                                                   >> 187   G4Point3D vertex6(G4Point3D( dx,-dy, dz));
                                                   >> 188   G4Point3D vertex7(G4Point3D(-dx,-dy, dz));
                                                   >> 189   G4Point3D vertex8(G4Point3D(-dx, dy, dz));
                                                   >> 190   
                                                   >> 191   vertex1 = (fObjectTransformation) * vertex1;
                                                   >> 192   vertex2 = (fObjectTransformation) * vertex2;
                                                   >> 193   vertex3 = (fObjectTransformation) * vertex3;
                                                   >> 194   vertex4 = (fObjectTransformation) * vertex4;
                                                   >> 195   vertex5 = (fObjectTransformation) * vertex5;
                                                   >> 196   vertex6 = (fObjectTransformation) * vertex6;
                                                   >> 197   vertex7 = (fObjectTransformation) * vertex7;
                                                   >> 198   vertex8 = (fObjectTransformation) * vertex8;
                                                   >> 199   
                                                   >> 200   hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
                                                   >> 201   hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
                                                   >> 202   hepRepXMLWriter->addPoint(vertex3.x(), vertex3.y(), vertex3.z());
                                                   >> 203   hepRepXMLWriter->addPoint(vertex4.x(), vertex4.y(), vertex4.z());
                                                   >> 204   hepRepXMLWriter->addPoint(vertex5.x(), vertex5.y(), vertex5.z());
                                                   >> 205   hepRepXMLWriter->addPoint(vertex6.x(), vertex6.y(), vertex6.z());
                                                   >> 206   hepRepXMLWriter->addPoint(vertex7.x(), vertex7.y(), vertex7.z());
                                                   >> 207   hepRepXMLWriter->addPoint(vertex8.x(), vertex8.y(), vertex8.z());
                                                   >> 208 }
                                                   >> 209 
                                                   >> 210 
                                                   >> 211 void G4HepRepFileSceneHandler::AddSolid(const G4Cons& cons) {
                                                   >> 212 #ifdef G4HEPREPFILEDEBUG
                                                   >> 213   G4cout <<
                                                   >> 214     "G4HepRepFileSceneHandler::AddSolid(const G4Cons& cons) called for "
                                                   >> 215   << cons.GetName()
                                                   >> 216   << G4endl;
                                                   >> 217   PrintThings();
                                                   >> 218 #endif
                                                   >> 219   
                                                   >> 220   // HepRApp does not correctly represent the end faces of cones at
                                                   >> 221   // non-standard angles, let the base class convert these solids to polygons.  
                                                   >> 222   G4RotationMatrix r = fObjectTransformation.getRotation(); 
                                                   >> 223   G4bool linedUpWithAnAxis = (std::fabs(r.phiX())<=.001 ||  
                                                   >> 224                 std::fabs(r.phiY())<=.001 || 
                                                   >> 225                 std::fabs(r.phiZ())<=.001 ||
                                                   >> 226                 std::fabs(r.phiX()-pi)<=.001 ||
                                                   >> 227                 std::fabs(r.phiY()-pi)<=.001 ||
                                                   >> 228                 std::fabs(r.phiZ()-pi)<=.001);  
                                                   >> 229   //G4cout << "Angle X:" << r.phiX() << ", Angle Y:" << r.phiY() << ", Angle Z:" << r.phiZ() << G4endl;
                                                   >> 230   //G4cout << "linedUpWithAnAxis:" << linedUpWithAnAxis << G4endl;
                                                   >> 231   
                                                   >> 232   // HepRep does not have a primitive for a cut cone,
                                                   >> 233   // so if this cone is cut, let the base class convert this
                                                   >> 234   // solid to polygons.
                                                   >> 235   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 236   if (cons.GetDeltaPhiAngle() < twopi || !linedUpWithAnAxis || messenger->renderCylAsPolygons())
                                                   >> 237   {
                                                   >> 238     G4VSceneHandler::AddSolid(cons);  // Invoke default action.
                                                   >> 239   } else {
                                                   >> 240   
                                                   >> 241     if (drawingTraj)
                                                   >> 242       return;
                                                   >> 243     
                                                   >> 244     if (drawingHit)
                                                   >> 245       InitHit();
                                                   >> 246 
                                                   >> 247     haveVisible = false;
                                                   >> 248     AddHepRepInstance("Cylinder", NULL);
                                                   >> 249     
                                                   >> 250     // Get and check applicable vis attributes.
                                                   >> 251     fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
                                                   >> 252     if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 253       return;
                                                   >> 254     
                                                   >> 255     G4Point3D vertex1(G4Point3D( 0., 0., -cons.GetZHalfLength()));
                                                   >> 256     G4Point3D vertex2(G4Point3D( 0., 0.,  cons.GetZHalfLength()));
                                                   >> 257     
                                                   >> 258     vertex1 = (fObjectTransformation) * vertex1;
                                                   >> 259     vertex2 = (fObjectTransformation) * vertex2;
                                                   >> 260         
                                                   >> 261     // Outer cylinder.
                                                   >> 262     hepRepXMLWriter->addPrimitive();
                                                   >> 263     hepRepXMLWriter->addAttValue("Radius1",messenger->getScale() * cons.GetOuterRadiusMinusZ());
                                                   >> 264     hepRepXMLWriter->addAttValue("Radius2",messenger->getScale() * cons.GetOuterRadiusPlusZ());
                                                   >> 265     hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
                                                   >> 266     hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
                                                   >> 267     
                                                   >> 268     // Inner cylinder.
                                                   >> 269     hepRepXMLWriter->addPrimitive();
                                                   >> 270     hepRepXMLWriter->addAttValue("Radius1",messenger->getScale() * cons.GetInnerRadiusMinusZ());
                                                   >> 271     hepRepXMLWriter->addAttValue("Radius2",messenger->getScale() * cons.GetInnerRadiusPlusZ());
                                                   >> 272     hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
                                                   >> 273     hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
                                                   >> 274   }
                                                   >> 275 }
                                                   >> 276 
                                                   >> 277 
                                                   >> 278 void G4HepRepFileSceneHandler::AddSolid(const G4Tubs& tubs) {
                                                   >> 279 #ifdef G4HEPREPFILEDEBUG
                                                   >> 280   G4cout <<
                                                   >> 281     "G4HepRepFileSceneHandler::AddSolid(const G4Tubs& tubs) called for "
                                                   >> 282   << tubs.GetName()
                                                   >> 283   << G4endl;
                                                   >> 284   PrintThings();
                                                   >> 285 #endif
                                                   >> 286   
                                                   >> 287   // HepRApp does not correctly represent the end faces of cylinders at
                                                   >> 288   // non-standard angles, let the base class convert these solids to polygons.  
                                                   >> 289   G4RotationMatrix r = fObjectTransformation.getRotation(); 
                                                   >> 290   G4bool linedUpWithAnAxis = (std::fabs(r.phiX())<=.001 ||  
                                                   >> 291                 std::fabs(r.phiY())<=.001 || 
                                                   >> 292                 std::fabs(r.phiZ())<=.001 ||
                                                   >> 293                 std::fabs(r.phiX()-pi)<=.001 ||
                                                   >> 294                 std::fabs(r.phiY()-pi)<=.001 ||
                                                   >> 295                 std::fabs(r.phiZ()-pi)<=.001);  
                                                   >> 296   //G4cout << "Angle X:" << r.phiX() << ", Angle Y:" << r.phiY() << ", Angle Z:" << r.phiZ() << G4endl;
                                                   >> 297   //G4cout << "linedUpWithAnAxis:" << linedUpWithAnAxis << G4endl;
                                                   >> 298   
                                                   >> 299   // HepRep does not have a primitive for a cut cylinder,
                                                   >> 300   // so if this cylinder is cut, let the base class convert this
                                                   >> 301   // solid to polygons.
                                                   >> 302   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 303   if (tubs.GetDeltaPhiAngle() < twopi || !linedUpWithAnAxis || messenger->renderCylAsPolygons())
                                                   >> 304   {
                                                   >> 305     G4VSceneHandler::AddSolid(tubs);  // Invoke default action.
                                                   >> 306   } else {
                                                   >> 307   
                                                   >> 308     if (drawingTraj)
                                                   >> 309       return;
                                                   >> 310     
                                                   >> 311     if (drawingHit)
                                                   >> 312       InitHit();
                                                   >> 313 
                                                   >> 314     haveVisible = false;
                                                   >> 315     AddHepRepInstance("Cylinder", NULL);
                                                   >> 316     
                                                   >> 317     // Get and check applicable vis attributes.
                                                   >> 318     fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
                                                   >> 319     if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 320       return;
                                                   >> 321     
                                                   >> 322     G4Point3D vertex1(G4Point3D( 0., 0., -tubs.GetZHalfLength()));
                                                   >> 323     G4Point3D vertex2(G4Point3D( 0., 0.,  tubs.GetZHalfLength()));
                                                   >> 324     
                                                   >> 325     vertex1 = (fObjectTransformation) * vertex1;
                                                   >> 326     vertex2 = (fObjectTransformation) * vertex2;
                                                   >> 327     
                                                   >> 328     // Outer cylinder.
                                                   >> 329     hepRepXMLWriter->addPrimitive();
                                                   >> 330     hepRepXMLWriter->addAttValue("Radius1", messenger->getScale() * tubs.GetOuterRadius());
                                                   >> 331     hepRepXMLWriter->addAttValue("Radius2", messenger->getScale() * tubs.GetOuterRadius());
                                                   >> 332     hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
                                                   >> 333     hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
                                                   >> 334     
                                                   >> 335     // Inner cylinder.
                                                   >> 336     if (tubs.GetInnerRadius() != 0.) {
                                                   >> 337       hepRepXMLWriter->addPrimitive();
                                                   >> 338       hepRepXMLWriter->addAttValue("Radius1", messenger->getScale() * tubs.GetInnerRadius());
                                                   >> 339       hepRepXMLWriter->addAttValue("Radius2", messenger->getScale() * tubs.GetInnerRadius());
                                                   >> 340       hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
                                                   >> 341       hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
                                                   >> 342     }
                                                   >> 343   }
                                                   >> 344 }
                                                   >> 345 
                                                   >> 346 
                                                   >> 347 void G4HepRepFileSceneHandler::AddSolid(const G4Trd& trd) {
                                                   >> 348 #ifdef G4HEPREPFILEDEBUG
                                                   >> 349   G4cout <<
                                                   >> 350     "G4HepRepFileSceneHandler::AddSolid(const G4Trd& trd) called for "
                                                   >> 351   << trd.GetName()
                                                   >> 352   << G4endl;
                                                   >> 353   PrintThings();
                                                   >> 354 #endif
                                                   >> 355   
                                                   >> 356   if (drawingTraj)
                                                   >> 357     return;
                                                   >> 358   
                                                   >> 359   if (drawingHit)
                                                   >> 360     InitHit();
                                                   >> 361   
                                                   >> 362   haveVisible = false;
                                                   >> 363   AddHepRepInstance("Prism", NULL);
                                                   >> 364   
                                                   >> 365   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 366   
                                                   >> 367   // Get and check applicable vis attributes.
                                                   >> 368   fpVisAttribs = fpViewer->GetApplicableVisAttributes(fpVisAttribs);
                                                   >> 369   if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 370     return;
                                                   >> 371   
                                                   >> 372   hepRepXMLWriter->addPrimitive();
                                                   >> 373   
                                                   >> 374   G4double dx1 = trd.GetXHalfLength1();
                                                   >> 375   G4double dy1 = trd.GetYHalfLength1();
                                                   >> 376   G4double dx2 = trd.GetXHalfLength2();
                                                   >> 377   G4double dy2 = trd.GetYHalfLength2();
                                                   >> 378   G4double dz = trd.GetZHalfLength();
                                                   >> 379   
                                                   >> 380   G4Point3D vertex1(G4Point3D( dx1, dy1,-dz));
                                                   >> 381   G4Point3D vertex2(G4Point3D( dx1,-dy1,-dz));
                                                   >> 382   G4Point3D vertex3(G4Point3D(-dx1,-dy1,-dz));
                                                   >> 383   G4Point3D vertex4(G4Point3D(-dx1, dy1,-dz));
                                                   >> 384   G4Point3D vertex5(G4Point3D( dx2, dy2, dz));
                                                   >> 385   G4Point3D vertex6(G4Point3D( dx2,-dy2, dz));
                                                   >> 386   G4Point3D vertex7(G4Point3D(-dx2,-dy2, dz));
                                                   >> 387   G4Point3D vertex8(G4Point3D(-dx2, dy2, dz));
                                                   >> 388   
                                                   >> 389   vertex1 = (fObjectTransformation) * vertex1;
                                                   >> 390   vertex2 = (fObjectTransformation) * vertex2;
                                                   >> 391   vertex3 = (fObjectTransformation) * vertex3;
                                                   >> 392   vertex4 = (fObjectTransformation) * vertex4;
                                                   >> 393   vertex5 = (fObjectTransformation) * vertex5;
                                                   >> 394   vertex6 = (fObjectTransformation) * vertex6;
                                                   >> 395   vertex7 = (fObjectTransformation) * vertex7;
                                                   >> 396   vertex8 = (fObjectTransformation) * vertex8;
                                                   >> 397   
                                                   >> 398   hepRepXMLWriter->addPoint(vertex1.x(), vertex1.y(), vertex1.z());
                                                   >> 399   hepRepXMLWriter->addPoint(vertex2.x(), vertex2.y(), vertex2.z());
                                                   >> 400   hepRepXMLWriter->addPoint(vertex3.x(), vertex3.y(), vertex3.z());
                                                   >> 401   hepRepXMLWriter->addPoint(vertex4.x(), vertex4.y(), vertex4.z());
                                                   >> 402   hepRepXMLWriter->addPoint(vertex5.x(), vertex5.y(), vertex5.z());
                                                   >> 403   hepRepXMLWriter->addPoint(vertex6.x(), vertex6.y(), vertex6.z());
                                                   >> 404   hepRepXMLWriter->addPoint(vertex7.x(), vertex7.y(), vertex7.z());
                                                   >> 405   hepRepXMLWriter->addPoint(vertex8.x(), vertex8.y(), vertex8.z());
                                                   >> 406 }
                                                   >> 407 
                                                   >> 408 
                                                   >> 409 void G4HepRepFileSceneHandler::AddSolid(const G4Trap& trap) {
                                                   >> 410 #ifdef G4HEPREPFILEDEBUG
                                                   >> 411   G4cout <<
                                                   >> 412     "G4HepRepFileSceneHandler::AddSolid(const G4Trap& trap) called for "
                                                   >> 413   << trap.GetName()
                                                   >> 414   << G4endl;
                                                   >> 415   PrintThings();
                                                   >> 416 #endif
                                                   >> 417   G4VSceneHandler::AddSolid(trap);  // Invoke default action.
                                                   >> 418 }
                                                   >> 419 
                                                   >> 420 
                                                   >> 421 void G4HepRepFileSceneHandler::AddSolid(const G4Sphere& sphere) {
                                                   >> 422 #ifdef G4HEPREPFILEDEBUG
                                                   >> 423   G4cout <<
                                                   >> 424     "G4HepRepFileSceneHandler::AddSolid(const G4Sphere& sphere) called for "
                                                   >> 425   << sphere.GetName()
                                                   >> 426   << G4endl;
                                                   >> 427   PrintThings();
                                                   >> 428 #endif
                                                   >> 429   G4VSceneHandler::AddSolid(sphere);  // Invoke default action.
                                                   >> 430 }
                                                   >> 431 
                                                   >> 432 
                                                   >> 433 void G4HepRepFileSceneHandler::AddSolid(const G4Para& para) {
                                                   >> 434 #ifdef G4HEPREPFILEDEBUG
                                                   >> 435   G4cout <<
                                                   >> 436     "G4HepRepFileSceneHandler::AddSolid(const G4Para& para) called for "
                                                   >> 437   << para.GetName()
                                                   >> 438   << G4endl;
                                                   >> 439   PrintThings();
                                                   >> 440 #endif
                                                   >> 441   G4VSceneHandler::AddSolid(para);  // Invoke default action.
                                                   >> 442 }
                                                   >> 443 
                                                   >> 444 
                                                   >> 445 void G4HepRepFileSceneHandler::AddSolid(const G4Torus& torus) {
                                                   >> 446 #ifdef G4HEPREPFILEDEBUG
                                                   >> 447   G4cout <<
                                                   >> 448     "G4HepRepFileSceneHandler::AddSolid(const G4Torus& torus) called for "
                                                   >> 449   << torus.GetName()
                                                   >> 450   << G4endl;
                                                   >> 451   PrintThings();
                                                   >> 452 #endif
                                                   >> 453   G4VSceneHandler::AddSolid(torus);  // Invoke default action.
                                                   >> 454 }
                                                   >> 455 
                                                   >> 456 
                                                   >> 457 void G4HepRepFileSceneHandler::AddSolid(const G4Polycone& polycone) {
                                                   >> 458 #ifdef G4HEPREPFILEDEBUG
                                                   >> 459   G4cout <<
                                                   >> 460   "G4HepRepFileSceneHandler::AddSolid(const G4Polycone& polycone) called for "
                                                   >> 461   << polycone.GetName()
                                                   >> 462   << G4endl;
458   PrintThings();                                  463   PrintThings();
459 #endif                                            464 #endif
460   G4VSceneHandler::AddSolid(polycone);  // Inv    465   G4VSceneHandler::AddSolid(polycone);  // Invoke default action.
461 }                                                 466 }
462                                                   467 
463 void G4HepRepFileSceneHandler::AddSolid(const  << 
464 {                                              << 
465 #ifdef G4HEPREPFILEDEBUG                       << 
466   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
467             "called for "                      << 
468          << polyhedra.GetName() << G4endl;     << 
469   PrintThings();                               << 
470 #endif                                         << 
471   G4VSceneHandler::AddSolid(polyhedra);  // In << 
472 }                                              << 
473                                                   468 
474 void G4HepRepFileSceneHandler::AddSolid(const  << 469 void G4HepRepFileSceneHandler::AddSolid(const G4Polyhedra& polyhedra) {
475 {                                              << 
476 #ifdef G4HEPREPFILEDEBUG                          470 #ifdef G4HEPREPFILEDEBUG
477   G4cout << "G4HepRepFileSceneHandler::AddSoli << 471   G4cout <<
478          << orb.GetName() << G4endl;           << 472   "G4HepRepFileSceneHandler::AddSolid(const G4Polyhedra& polyhedra) called for "
                                                   >> 473   << polyhedra.GetName()
                                                   >> 474   << G4endl;
479   PrintThings();                                  475   PrintThings();
480 #endif                                            476 #endif
481   G4VSceneHandler::AddSolid(orb);  // Invoke d << 477   G4VSceneHandler::AddSolid(polyhedra);  // Invoke default action.
482 }                                              << 
483                                                << 
484 void G4HepRepFileSceneHandler::AddSolid(const  << 
485 {                                              << 
486 #ifdef G4HEPREPFILEDEBUG                       << 
487   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
488             "called for "                      << 
489          << ellipsoid.GetName() << G4endl;     << 
490   PrintThings();                               << 
491 #endif                                         << 
492   G4VSceneHandler::AddSolid(ellipsoid);  // In << 
493 }                                              << 
494                                                << 
495 void G4HepRepFileSceneHandler::AddSolid(const  << 
496 {                                              << 
497 #ifdef G4HEPREPFILEDEBUG                       << 
498   G4cout << "G4HepRepFileSceneHandler::AddSoli << 
499             "called for "                      << 
500          << tess.GetName() << G4endl;          << 
501   PrintThings();                               << 
502 #endif                                         << 
503   G4VSceneHandler::AddSolid(tess);  // Invoke  << 
504 }                                              << 
505                                                << 
506 void G4HepRepFileSceneHandler::AddSolid(const  << 
507 {                                              << 
508 #ifdef G4HEPREPFILEDEBUG                       << 
509   G4cout                                       << 
510     << "G4HepRepFileSceneHandler::AddSolid(con << 
511     << solid.GetName() << G4endl;              << 
512   PrintThings();                               << 
513 #endif                                         << 
514   G4VSceneHandler::AddSolid(solid);  // Invoke << 
515 }                                              << 
516                                                << 
517 void G4HepRepFileSceneHandler::AddCompound(con << 
518 {                                              << 
519 #ifdef G4HEPREPFILEDEBUG                       << 
520   G4cout << "G4HepRepFileSceneHandler::AddComp << 
521          << G4endl;                            << 
522 #endif                                         << 
523                                                << 
524   G4TrajectoriesModel* pTrModel = dynamic_cast << 
525   if(!pTrModel)                                << 
526     G4Exception("G4HepRepFileSceneHandler::Add << 
527                 "vis-HepRep0001", FatalExcepti << 
528                                                << 
529   // Pointers to hold trajectory attribute val << 
530   std::vector<G4AttValue>* rawTrajAttValues =  << 
531   trajAttValues                             =  << 
532   trajAttDefs                               =  << 
533                                                << 
534   // Iterators to use with attribute values an << 
535   std::vector<G4AttValue>::iterator iAttVal;   << 
536   std::map<G4String, G4AttDef>::const_iterator << 
537   G4int i;                                     << 
538                                                << 
539   // Get trajectory attributes and definitions << 
540   // (uniform units, 3Vectors decomposed).     << 
541   if(rawTrajAttValues)                         << 
542   {                                            << 
543     G4bool error = G4AttCheck(rawTrajAttValues << 
544                      .Standard(trajAttValues,  << 
545     if(error)                                  << 
546     {                                          << 
547       G4cout                                   << 
548         << "G4HepRepFileSceneHandler::AddCompo << 
549            "\nERROR found during conversion to << 
550         << G4endl;                             << 
551     }                                          << 
552 #ifdef G4HEPREPFILEDEBUG                       << 
553     G4cout << "G4HepRepFileSceneHandler::AddCo << 
554               "attributes:\n"                  << 
555            << G4AttCheck(trajAttValues, trajAt << 
556 #endif                                         << 
557     delete rawTrajAttValues;                   << 
558   }                                            << 
559                                                << 
560   // Open the HepRep output file if it is not  << 
561   CheckFileOpen();                             << 
562                                                << 
563   // Add the Event Data Type if it hasn't alre << 
564   if(strcmp("Event Data", hepRepXMLWriter->pre << 
565   {                                            << 
566     hepRepXMLWriter->addType("Event Data", 0); << 
567     hepRepXMLWriter->addInstance();            << 
568   }                                            << 
569                                                << 
570   // Add the Trajectories Type.                << 
571   G4String previousName = hepRepXMLWriter->pre << 
572   hepRepXMLWriter->addType("Trajectories", 1); << 
573                                                << 
574   // If this is the first trajectory of this e << 
575   // specify attribute values common to all tr << 
576   if(strcmp("Trajectories", previousName) != 0 << 
577   {                                            << 
578     hepRepXMLWriter->addAttValue("Layer", 100) << 
579                                                << 
580     // Take all Trajectory attDefs from first  << 
581     // Would rather be able to get these attDe << 
582     // from any particular trajectory, but don << 
583     // trajectory attribute definitions.       << 
584     if(trajAttValues && trajAttDefs)           << 
585     {                                          << 
586       for(iAttVal = trajAttValues->begin(); iA << 
587           ++iAttVal)                           << 
588       {                                        << 
589         iAttDef = trajAttDefs->find(iAttVal->G << 
590         if(iAttDef != trajAttDefs->end())      << 
591         {                                      << 
592           // Protect against incorrect use of  << 
593           // than the standard ones will be co << 
594           // category.                         << 
595           G4String category = iAttDef->second. << 
596           if(strcmp(category, "Draw") != 0 &&  << 
597              strcmp(category, "Physics") != 0  << 
598              strcmp(category, "Association") ! << 
599              strcmp(category, "PickAction") != << 
600             category = "Physics";              << 
601           hepRepXMLWriter->addAttDef(iAttVal-> << 
602                                      iAttDef-> << 
603                                      iAttDef-> << 
604         }                                      << 
605       }                                        << 
606     }                                          << 
607                                                << 
608     // Take all TrajectoryPoint attDefs from f << 
609     // Would rather be able to get these attDe << 
610     // from any particular point, but don't kn << 
611     if((trajContext->GetDrawStepPts() || trajC << 
612        traj.GetPointEntries() > 0)             << 
613     {                                          << 
614       G4VTrajectoryPoint* aTrajectoryPoint = t << 
615                                                << 
616       // Pointers to hold trajectory point att << 
617       std::vector<G4AttValue>* rawPointAttValu << 
618         aTrajectoryPoint->CreateAttValues();   << 
619       std::vector<G4AttValue>* pointAttValues  << 
620       std::map<G4String, G4AttDef>* pointAttDe << 
621         new std::map<G4String, G4AttDef>;      << 
622                                                << 
623       // Get first trajectory point's attribut << 
624       // HepRep style (uniform units, 3Vectors << 
625       if(rawPointAttValues)                    << 
626       {                                        << 
627         G4bool error =                         << 
628           G4AttCheck(rawPointAttValues, aTraje << 
629             .Standard(pointAttValues, pointAtt << 
630         if(error)                              << 
631         {                                      << 
632           G4cout << "G4HepRepFileSceneHandler: << 
633                     "\nERROR found during conv << 
634                     "attributes."              << 
635                  << G4endl;                    << 
636         }                                      << 
637                                                << 
638         // Write out point attribute definitio << 
639         if(pointAttValues && pointAttDefs)     << 
640         {                                      << 
641           for(iAttVal = pointAttValues->begin( << 
642               iAttVal != pointAttValues->end() << 
643           {                                    << 
644             iAttDef = pointAttDefs->find(iAttV << 
645             if(iAttDef != pointAttDefs->end()) << 
646             {                                  << 
647               // Protect against incorrect use << 
648               // other than the standard ones  << 
649               // physics category.             << 
650               G4String category = iAttDef->sec << 
651               if(strcmp(category, "Draw") != 0 << 
652                  strcmp(category, "Physics") ! << 
653                  strcmp(category, "Association << 
654                  strcmp(category, "PickAction" << 
655                 category = "Physics";          << 
656               // Do not write out the Aux or P << 
657               // conform to the HepRep rule th << 
658               // instance of a given AttValue. << 
659               // redundant to actual position  << 
660               if(strcmp(iAttVal->GetName(), "A << 
661                  strcmp(iAttVal->GetName(), "A << 
662                  strcmp(iAttVal->GetName(), "A << 
663                  strcmp(iAttVal->GetName(), "P << 
664                  strcmp(iAttVal->GetName(), "P << 
665                  strcmp(iAttVal->GetName(), "P << 
666                 hepRepXMLWriter->addAttDef(iAt << 
667                                            iAt << 
668                                            iAt << 
669             }                                  << 
670           }                                    << 
671         }                                      << 
672         delete rawPointAttValues;              << 
673       }                                        << 
674                                                << 
675       // Clean up point attributes.            << 
676       if(pointAttValues)                       << 
677         delete pointAttValues;                 << 
678       if(pointAttDefs)                         << 
679         delete pointAttDefs;                   << 
680     }                                          << 
681   }  // end of special treatment for when this << 
682                                                << 
683   // Now that we have written out all of the a << 
684   // trajectory's particulars, call base class << 
685   // polyline and/or points (or nothing if tra << 
686   // base class calls for drawing points, no p << 
687   // since we instead need to do point drawing << 
688   // points attributes, not available from Add << 
689   // such a call will just serve to set the fl << 
690   // drawing was requested for this trajectory << 
691   // including trajContext and filtering).     << 
692   drawingTraj  = true;                         << 
693   doneInitTraj = false;                        << 
694   G4VSceneHandler::AddCompound(traj);          << 
695   drawingTraj = false;                         << 
696                                                << 
697   // Draw step points.                         << 
698   if(trajContext->GetDrawStepPts())            << 
699   {                                            << 
700     if(!doneInitTraj)                          << 
701       InitTrajectory();                        << 
702     // Create Trajectory Points as a subType o << 
703     // Note that we should create this heprep  << 
704     // points. This allows the user to tell th << 
705     // odd) rather than that they were omitted << 
706     previousName = hepRepXMLWriter->prevTypeNa << 
707     hepRepXMLWriter->addType("Trajectory Step  << 
708                                                << 
709     float redness;                             << 
710     float greenness;                           << 
711     float blueness;                            << 
712     G4int markSize;                            << 
713     G4bool visible;                            << 
714     G4bool square;                             << 
715     G4Colour colour = trajContext->GetStepPtsC << 
716     redness         = colour.GetRed();         << 
717     greenness       = colour.GetGreen();       << 
718     blueness        = colour.GetBlue();        << 
719     markSize        = (G4int) trajContext->Get << 
720     visible         = (G4int) trajContext->Get << 
721     square          = (trajContext->GetStepPts << 
722                                                << 
723     // Avoiding drawing anything black on blac << 
724     if(redness == 0. && greenness == 0. && blu << 
725     {                                          << 
726       redness   = 1.;                          << 
727       greenness = 1.;                          << 
728       blueness  = 1.;                          << 
729     }                                          << 
730                                                << 
731     // Specify attributes common to all trajec << 
732     if(strcmp("Trajectory Step Points", previo << 
733     {                                          << 
734       hepRepXMLWriter->addAttValue("DrawAs", " << 
735       hepRepXMLWriter->addAttValue("MarkColor" << 
736       hepRepXMLWriter->addAttValue("MarkSize", << 
737       hepRepXMLWriter->addAttValue("Layer", 11 << 
738       hepRepXMLWriter->addAttValue("Visibility << 
739       if(square)                               << 
740         hepRepXMLWriter->addAttValue("MarkName << 
741       else                                     << 
742         hepRepXMLWriter->addAttValue("MarkName << 
743     }                                          << 
744                                                << 
745     // Loop over all points on this trajectory << 
746     for(i = 0; i < traj.GetPointEntries(); i++ << 
747     {                                          << 
748       G4VTrajectoryPoint* aTrajectoryPoint = t << 
749                                                << 
750       // Each point is a separate instance of  << 
751       hepRepXMLWriter->addInstance();          << 
752                                                << 
753       // Pointers to hold trajectory point att << 
754       std::vector<G4AttValue>* rawPointAttValu << 
755         aTrajectoryPoint->CreateAttValues();   << 
756       std::vector<G4AttValue>* pointAttValues  << 
757       std::map<G4String, G4AttDef>* pointAttDe << 
758         new std::map<G4String, G4AttDef>;      << 
759                                                << 
760       // Get trajectory point attributes and d << 
761       // style (uniform units, 3Vectors decomp << 
762       if(rawPointAttValues)                    << 
763       {                                        << 
764         G4bool error =                         << 
765           G4AttCheck(rawPointAttValues, aTraje << 
766             .Standard(pointAttValues, pointAtt << 
767         if(error)                              << 
768         {                                      << 
769           G4cout                               << 
770             << "G4HepRepFileSceneHandler::AddC << 
771                "\nERROR found during conversio << 
772             << G4endl;                         << 
773         }                                      << 
774                                                << 
775         // Write out point attribute values.   << 
776         if(pointAttValues)                     << 
777         {                                      << 
778           for(iAttVal = pointAttValues->begin( << 
779               iAttVal != pointAttValues->end() << 
780             // Do not write out the Aux or Pos << 
781             // to the HepRep rule that each ob << 
782             // a given AttValue. Both of these << 
783             // actual position information of  << 
784             if(strcmp(iAttVal->GetName(), "Aux << 
785                strcmp(iAttVal->GetName(), "Aux << 
786                strcmp(iAttVal->GetName(), "Aux << 
787                strcmp(iAttVal->GetName(), "Pos << 
788                strcmp(iAttVal->GetName(), "Pos << 
789                strcmp(iAttVal->GetName(), "Pos << 
790               hepRepXMLWriter->addAttValue(iAt << 
791                                            iAt << 
792         }                                      << 
793       }                                        << 
794                                                << 
795       // Clean up point attributes.            << 
796       delete pointAttDefs;                     << 
797       delete pointAttValues;                   << 
798       delete rawPointAttValues;                << 
799                                                << 
800       // Each trajectory point is made of a si << 
801       hepRepXMLWriter->addPrimitive();         << 
802       G4Point3D vertex = aTrajectoryPoint->Get << 
803       hepRepXMLWriter->addPoint(vertex.x(), ve << 
804     }                                          << 
805   }                                            << 
806                                                << 
807   // Draw Auxiliary Points                     << 
808   if(trajContext->GetDrawAuxPts())             << 
809   {                                            << 
810     if(!doneInitTraj)                          << 
811       InitTrajectory();                        << 
812     // Create Trajectory Points as a subType o << 
813     // Note that we should create this heprep  << 
814     // points. This allows the user to tell th << 
815     // odd) rather than that they were omitted << 
816     previousName = hepRepXMLWriter->prevTypeNa << 
817     hepRepXMLWriter->addType("Trajectory Auxil << 
818                                                << 
819     float redness;                             << 
820     float greenness;                           << 
821     float blueness;                            << 
822     G4int markSize;                            << 
823     G4bool visible;                            << 
824     G4bool square;                             << 
825     G4Colour colour = trajContext->GetAuxPtsCo << 
826     redness         = colour.GetRed();         << 
827     greenness       = colour.GetGreen();       << 
828     blueness        = colour.GetBlue();        << 
829     markSize        = (G4int) trajContext->Get << 
830     visible         = (G4int) trajContext->Get << 
831     square          = (trajContext->GetAuxPtsT << 
832                                                << 
833     // Avoiding drawing anything black on blac << 
834     if(redness == 0. && greenness == 0. && blu << 
835     {                                          << 
836       redness   = 1.;                          << 
837       greenness = 1.;                          << 
838       blueness  = 1.;                          << 
839     }                                          << 
840                                                << 
841     // Specify attributes common to all trajec << 
842     if(strcmp("Trajectory Auxiliary Points", p << 
843     {                                          << 
844       hepRepXMLWriter->addAttValue("DrawAs", " << 
845       hepRepXMLWriter->addAttValue("MarkColor" << 
846       hepRepXMLWriter->addAttValue("MarkSize", << 
847       hepRepXMLWriter->addAttValue("Layer", 11 << 
848       hepRepXMLWriter->addAttValue("Visibility << 
849       if(square)                               << 
850         hepRepXMLWriter->addAttValue("MarkName << 
851       else                                     << 
852         hepRepXMLWriter->addAttValue("MarkName << 
853     }                                          << 
854                                                << 
855     // Loop over all points on this trajectory << 
856     for(i = 0; i < traj.GetPointEntries(); i++ << 
857     {                                          << 
858       G4VTrajectoryPoint* aTrajectoryPoint = t << 
859                                                << 
860       // Each point is a separate instance of  << 
861       hepRepXMLWriter->addInstance();          << 
862                                                << 
863       // Pointers to hold trajectory point att << 
864       std::vector<G4AttValue>* rawPointAttValu << 
865         aTrajectoryPoint->CreateAttValues();   << 
866       std::vector<G4AttValue>* pointAttValues  << 
867       std::map<G4String, G4AttDef>* pointAttDe << 
868         new std::map<G4String, G4AttDef>;      << 
869                                                << 
870       // Get trajectory point attributes and d << 
871       // style (uniform units, 3Vectors decomp << 
872       if(rawPointAttValues)                    << 
873       {                                        << 
874         G4bool error =                         << 
875           G4AttCheck(rawPointAttValues, aTraje << 
876             .Standard(pointAttValues, pointAtt << 
877         if(error)                              << 
878         {                                      << 
879           G4cout                               << 
880             << "G4HepRepFileSceneHandler::AddC << 
881                "\nERROR found during conversio << 
882             << G4endl;                         << 
883         }                                      << 
884                                                << 
885         // Write out point attribute values.   << 
886         if(pointAttValues)                     << 
887         {                                      << 
888           for(iAttVal = pointAttValues->begin( << 
889               iAttVal != pointAttValues->end() << 
890             // Do not write out the Aux or Pos << 
891             // to the HepRep rule that each ob << 
892             // a given AttValue. Both of these << 
893             // actual position information of  << 
894             if(strcmp(iAttVal->GetName(), "Aux << 
895                strcmp(iAttVal->GetName(), "Aux << 
896                strcmp(iAttVal->GetName(), "Aux << 
897                strcmp(iAttVal->GetName(), "Pos << 
898                strcmp(iAttVal->GetName(), "Pos << 
899                strcmp(iAttVal->GetName(), "Pos << 
900               hepRepXMLWriter->addAttValue(iAt << 
901                                            iAt << 
902         }                                      << 
903       }                                        << 
904                                                << 
905       // Clean up point attributes.            << 
906       delete pointAttDefs;                     << 
907       delete pointAttValues;                   << 
908       delete rawPointAttValues;                << 
909                                                << 
910       // Each trajectory point is made of a si << 
911       G4Point3D vertex = aTrajectoryPoint->Get << 
912                                                << 
913       // Loop over auxiliary points associated << 
914       const std::vector<G4ThreeVector>* auxili << 
915         aTrajectoryPoint->GetAuxiliaryPoints() << 
916       if(0 != auxiliaries)                     << 
917       {                                        << 
918         for(size_t iAux = 0; iAux < auxiliarie << 
919         {                                      << 
920           const G4ThreeVector auxPos((*auxilia << 
921           hepRepXMLWriter->addPrimitive();     << 
922           hepRepXMLWriter->addPoint(auxPos.x() << 
923         }                                      << 
924       }                                        << 
925     }                                          << 
926   }                                            << 
927 }                                              << 
928                                                << 
929 void G4HepRepFileSceneHandler::AddCompound(con << 
930 {                                              << 
931 #ifdef G4HEPREPFILEDEBUG                       << 
932   G4cout << "G4HepRepFileSceneHandler::AddComp << 
933 #endif                                         << 
934                                                << 
935   // Pointers to hold hit attribute values and << 
936   std::vector<G4AttValue>* rawHitAttValues = h << 
937   hitAttValues                             = n << 
938   hitAttDefs                               = n << 
939                                                << 
940   // Iterators to use with attribute values an << 
941   std::vector<G4AttValue>::iterator iAttVal;   << 
942   std::map<G4String, G4AttDef>::const_iterator << 
943                                                << 
944   // Get hit attributes and definitions in sta << 
945   // (uniform units, 3Vectors decomposed).     << 
946   if(rawHitAttValues)                          << 
947   {                                            << 
948     G4bool error = G4AttCheck(rawHitAttValues, << 
949                      .Standard(hitAttValues, h << 
950     if(error)                                  << 
951     {                                          << 
952       G4cout << "G4HepRepFileSceneHandler::Add << 
953                 "\nERROR found during conversi << 
954              << G4endl;                        << 
955     }                                          << 
956 #ifdef G4HEPREPFILEDEBUG                       << 
957     G4cout << "G4HepRepFileSceneHandler::AddCo << 
958               "attributes:\n"                  << 
959            << G4AttCheck(hitAttValues, hitAttD << 
960 #endif                                         << 
961     delete rawHitAttValues;                    << 
962   }                                            << 
963                                                << 
964   // Open the HepRep output file if it is not  << 
965   CheckFileOpen();                             << 
966                                                << 
967   // Add the Event Data Type if it hasn't alre << 
968   if(strcmp("Event Data", hepRepXMLWriter->pre << 
969   {                                            << 
970     hepRepXMLWriter->addType("Event Data", 0); << 
971     hepRepXMLWriter->addInstance();            << 
972   }                                            << 
973                                                << 
974   // Find out the current HitType.             << 
975   G4String hitType = "Hits";                   << 
976   if(hitAttValues)                             << 
977   {                                            << 
978     G4bool found = false;                      << 
979     for(iAttVal = hitAttValues->begin();       << 
980         iAttVal != hitAttValues->end() && !fou << 
981     {                                          << 
982       if(strcmp(iAttVal->GetName(), "HitType") << 
983       {                                        << 
984         hitType = iAttVal->GetValue();         << 
985         found   = true;                        << 
986       }                                        << 
987     }                                          << 
988   }                                            << 
989                                                << 
990   // Add the Hits Type.                        << 
991   G4String previousName = hepRepXMLWriter->pre << 
992   hepRepXMLWriter->addType(hitType, 1);        << 
993                                                << 
994   // If this is the first hit of this event,   << 
995   // specify attribute values common to all hi << 
996   if(strcmp(hitType, previousName) != 0)       << 
997   {                                            << 
998     hepRepXMLWriter->addAttValue("Layer", 130) << 
999                                                << 
1000     // Take all Hit attDefs from first hit.   << 
1001     // Would rather be able to get these attD << 
1002     // from any particular hit, but don't kno << 
1003     // attribute definitions.                 << 
1004     if(hitAttValues && hitAttDefs)            << 
1005     {                                         << 
1006       for(iAttVal = hitAttValues->begin(); iA << 
1007           ++iAttVal)                          << 
1008       {                                       << 
1009         iAttDef = hitAttDefs->find(iAttVal->G << 
1010         if(iAttDef != hitAttDefs->end())      << 
1011         {                                     << 
1012           // Protect against incorrect use of << 
1013           // than the standard ones will be c << 
1014           // category.                        << 
1015           G4String category = iAttDef->second << 
1016           if(strcmp(category, "Draw") != 0 && << 
1017              strcmp(category, "Physics") != 0 << 
1018              strcmp(category, "Association")  << 
1019              strcmp(category, "PickAction") ! << 
1020             category = "Physics";             << 
1021           hepRepXMLWriter->addAttDef(iAttVal- << 
1022                                      iAttDef- << 
1023                                      iAttDef- << 
1024         }                                     << 
1025       }                                       << 
1026     }                                         << 
1027   }  // end of special treatment for when thi << 
1028                                               << 
1029   // Now that we have written out all of the  << 
1030   // hit's particulars, call base class to de << 
1031   drawingHit  = true;                         << 
1032   doneInitHit = false;                        << 
1033   G4VSceneHandler::AddCompound(hit);  // Invo << 
1034   drawingHit = false;                         << 
1035 }                                             << 
1036                                               << 
1037 void G4HepRepFileSceneHandler::InitTrajectory << 
1038 {                                             << 
1039   if(!doneInitTraj)                           << 
1040   {                                           << 
1041     // For every trajectory, add an instance  << 
1042     hepRepXMLWriter->addInstance();           << 
1043                                               << 
1044     // Write out the trajectory's attribute v << 
1045     if(trajAttValues)                         << 
1046     {                                         << 
1047       std::vector<G4AttValue>::iterator iAttV << 
1048       for(iAttVal = trajAttValues->begin(); i << 
1049           ++iAttVal)                          << 
1050         hepRepXMLWriter->addAttValue(iAttVal- << 
1051       delete trajAttValues;                   << 
1052     }                                         << 
1053                                               << 
1054     // Clean up trajectory attributes.        << 
1055     if(trajAttDefs)                           << 
1056       delete trajAttDefs;                     << 
1057                                               << 
1058     doneInitTraj = true;                      << 
1059   }                                           << 
1060 }                                                478 }
1061                                                  479 
1062 void G4HepRepFileSceneHandler::InitHit()      << 
1063 {                                             << 
1064   if(!doneInitHit)                            << 
1065   {                                           << 
1066     // For every hit, add an instance of Type << 
1067     hepRepXMLWriter->addInstance();           << 
1068                                               << 
1069     // Write out the hit's attribute values.  << 
1070     if(hitAttValues)                          << 
1071     {                                         << 
1072       std::vector<G4AttValue>::iterator iAttV << 
1073       for(iAttVal = hitAttValues->begin(); iA << 
1074           ++iAttVal)                          << 
1075         hepRepXMLWriter->addAttValue(iAttVal- << 
1076       delete hitAttValues;                    << 
1077     }                                         << 
1078                                               << 
1079     // Clean up hit attributes.               << 
1080     if(hitAttDefs)                            << 
1081       delete hitAttDefs;                      << 
1082                                                  480 
1083     doneInitHit = true;                       << 481 void G4HepRepFileSceneHandler::AddSolid(const G4Orb& orb) {
1084   }                                           << 
1085 }                                             << 
1086                                               << 
1087 void G4HepRepFileSceneHandler::AddPrimitive(c << 
1088 {                                             << 
1089 #ifdef G4HEPREPFILEDEBUG                         482 #ifdef G4HEPREPFILEDEBUG
1090   G4cout << "G4HepRepFileSceneHandler::AddPri << 483   G4cout <<
1091             "polyline) called:"               << 484   "G4HepRepFileSceneHandler::AddSolid(const G4Orb& orb) called for "
1092             "\n  polyline: "                  << 485   << orb.GetName()
1093          << polyline << G4endl;               << 486   << G4endl;
1094   PrintThings();                                 487   PrintThings();
1095 #endif                                           488 #endif
1096                                               << 489   G4VSceneHandler::AddSolid(orb);  // Invoke default action.
1097   G4HepRepMessenger* messenger = G4HepRepMess << 
1098                                               << 
1099   if(fpVisAttribs && (fpVisAttribs->IsVisible << 
1100      messenger->getCullInvisibles())          << 
1101     return;                                   << 
1102                                               << 
1103   if(inPrimitives2D)                          << 
1104   {                                           << 
1105     if(!warnedAbout2DMarkers)                 << 
1106     {                                         << 
1107       G4cout << "HepRepFile does not currentl << 
1108       warnedAbout2DMarkers = true;            << 
1109     }                                         << 
1110     return;                                   << 
1111   }                                           << 
1112                                               << 
1113   if(drawingTraj)                             << 
1114     InitTrajectory();                         << 
1115                                               << 
1116   if(drawingHit)                              << 
1117     InitHit();                                << 
1118                                               << 
1119   haveVisible = true;                         << 
1120   AddHepRepInstance("Line", polyline);        << 
1121                                               << 
1122   hepRepXMLWriter->addPrimitive();            << 
1123                                               << 
1124   for(size_t i = 0; i < polyline.size(); i++) << 
1125   {                                           << 
1126     G4Point3D vertex = (fObjectTransformation << 
1127     hepRepXMLWriter->addPoint(vertex.x(), ver << 
1128   }                                           << 
1129 }                                                490 }
1130                                                  491 
1131 void G4HepRepFileSceneHandler::AddPrimitive(c << 
1132 {                                             << 
1133 #ifdef G4HEPREPFILEDEBUG                      << 
1134   G4cout                                      << 
1135     << "G4HepRepFileSceneHandler::AddPrimitiv << 
1136     << G4endl;                                << 
1137   PrintThings();                              << 
1138 #endif                                        << 
1139                                               << 
1140   G4HepRepMessenger* messenger = G4HepRepMess << 
1141                                                  492 
1142   if(fpVisAttribs && (fpVisAttribs->IsVisible << 493 void G4HepRepFileSceneHandler::AddSolid(const G4Ellipsoid& ellipsoid) {
1143      messenger->getCullInvisibles())          << 
1144     return;                                   << 
1145                                               << 
1146   if(inPrimitives2D)                          << 
1147   {                                           << 
1148     if(!warnedAbout2DMarkers)                 << 
1149     {                                         << 
1150       G4cout << "HepRepFile does not currentl << 
1151       warnedAbout2DMarkers = true;            << 
1152     }                                         << 
1153     return;                                   << 
1154   }                                           << 
1155                                               << 
1156   MarkerSizeType sizeType;                    << 
1157   G4double size = GetMarkerSize(line, sizeTyp << 
1158   if(sizeType == world)                       << 
1159     size = 4.;                                << 
1160                                               << 
1161   if(drawingTraj)                             << 
1162     return;                                   << 
1163                                               << 
1164   if(drawingHit)                              << 
1165     InitHit();                                << 
1166                                               << 
1167   haveVisible = true;                         << 
1168   AddHepRepInstance("Point", line);           << 
1169                                               << 
1170   hepRepXMLWriter->addAttValue("MarkName", "D << 
1171   hepRepXMLWriter->addAttValue("MarkSize", (G << 
1172                                               << 
1173   hepRepXMLWriter->addPrimitive();            << 
1174                                               << 
1175   for(size_t i = 0; i < line.size(); i++)     << 
1176   {                                           << 
1177     G4Point3D vertex = (fObjectTransformation << 
1178     hepRepXMLWriter->addPoint(vertex.x(), ver << 
1179   }                                           << 
1180 }                                             << 
1181                                               << 
1182 void G4HepRepFileSceneHandler::AddPrimitive(c << 
1183 {                                             << 
1184 #ifdef G4HEPREPFILEDEBUG                         494 #ifdef G4HEPREPFILEDEBUG
1185   G4cout << "G4HepRepFileSceneHandler::AddPri << 495   G4cout <<
1186             "\n  text: "                      << 496   "G4HepRepFileSceneHandler::AddSolid(const G4Ellipsoid& ellipsoid) called for "
1187          << text.GetText() << G4endl;         << 497   << ellipsoid.GetName()
                                                   >> 498   << G4endl;
1188   PrintThings();                                 499   PrintThings();
1189 #endif                                           500 #endif
1190                                               << 501   G4VSceneHandler::AddSolid(ellipsoid);  // Invoke default action.
1191   if(!inPrimitives2D)                         << 
1192   {                                           << 
1193     if(!warnedAbout3DText)                    << 
1194     {                                         << 
1195       G4cout << "HepRepFile does not currentl << 
1196       G4cout                                  << 
1197         << "HepRep browsers can directly disp << 
1198         << G4endl;                            << 
1199       G4cout << "See Application Developers G << 
1200                 "to viewable objects."        << 
1201              << G4endl;                       << 
1202       warnedAbout3DText = true;               << 
1203     }                                         << 
1204     return;                                   << 
1205   }                                           << 
1206                                               << 
1207   MarkerSizeType sizeType;                    << 
1208   G4double size = GetMarkerSize(text, sizeTyp << 
1209   if(sizeType == world)                       << 
1210     size = 12.;                               << 
1211                                               << 
1212   haveVisible = true;                         << 
1213   AddHepRepInstance("Text", text);            << 
1214                                               << 
1215   hepRepXMLWriter->addAttValue("VAlign", "Top << 
1216   hepRepXMLWriter->addAttValue("HAlign", "Lef << 
1217   hepRepXMLWriter->addAttValue("FontName", "A << 
1218   hepRepXMLWriter->addAttValue("FontStyle", " << 
1219   hepRepXMLWriter->addAttValue("FontSize", (G << 
1220   hepRepXMLWriter->addAttValue("FontHasBanner << 
1221   hepRepXMLWriter->addAttValue("FontBannerCol << 
1222                                               << 
1223   const G4Colour& colour = GetTextColour(text << 
1224   float redness          = colour.GetRed();   << 
1225   float greenness        = colour.GetGreen(); << 
1226   float blueness         = colour.GetBlue();  << 
1227                                               << 
1228   // Avoiding drawing anything black on black << 
1229   if(redness == 0. && greenness == 0. && blue << 
1230   {                                           << 
1231     redness   = 1.;                           << 
1232     greenness = 1.;                           << 
1233     blueness  = 1.;                           << 
1234   }                                           << 
1235   hepRepXMLWriter->addAttValue("FontColor", r << 
1236                                               << 
1237   hepRepXMLWriter->addPrimitive();            << 
1238                                               << 
1239   hepRepXMLWriter->addAttValue("Text", text.G << 
1240   hepRepXMLWriter->addAttValue("VPos", .99 -  << 
1241   hepRepXMLWriter->addAttValue("HPos", text.G << 
1242 }                                                502 }
1243                                                  503 
1244 void G4HepRepFileSceneHandler::AddPrimitive(c << 
1245 {                                             << 
1246 #ifdef G4HEPREPFILEDEBUG                      << 
1247   G4cout                                      << 
1248     << "G4HepRepFileSceneHandler::AddPrimitiv << 
1249        "\n  radius: "                         << 
1250     << circle.GetWorldRadius() << G4endl;     << 
1251   PrintThings();                              << 
1252 #endif                                        << 
1253                                               << 
1254   G4HepRepMessenger* messenger = G4HepRepMess << 
1255                                               << 
1256   if(fpVisAttribs && (fpVisAttribs->IsVisible << 
1257      messenger->getCullInvisibles())          << 
1258     return;                                   << 
1259                                               << 
1260   if(inPrimitives2D)                          << 
1261   {                                           << 
1262     if(!warnedAbout2DMarkers)                 << 
1263     {                                         << 
1264       G4cout << "HepRepFile does not currentl << 
1265       warnedAbout2DMarkers = true;            << 
1266     }                                         << 
1267     return;                                   << 
1268   }                                           << 
1269                                               << 
1270   MarkerSizeType sizeType;                    << 
1271   G4double size = GetMarkerSize(circle, sizeT << 
1272   if(sizeType == world)                       << 
1273     size = 4.;                                << 
1274                                               << 
1275   if(drawingTraj)                             << 
1276     return;                                   << 
1277                                               << 
1278   if(drawingHit)                              << 
1279     InitHit();                                << 
1280                                               << 
1281   haveVisible = true;                         << 
1282   AddHepRepInstance("Point", circle);         << 
1283                                                  504 
1284   hepRepXMLWriter->addAttValue("MarkName", "D << 505 void G4HepRepFileSceneHandler::AddSolid(const G4VSolid& solid) {
1285   hepRepXMLWriter->addAttValue("MarkSize", (G << 
1286                                               << 
1287   hepRepXMLWriter->addPrimitive();            << 
1288                                               << 
1289   G4Point3D center = (fObjectTransformation)  << 
1290   hepRepXMLWriter->addPoint(center.x(), cente << 
1291 }                                             << 
1292                                               << 
1293 void G4HepRepFileSceneHandler::AddPrimitive(c << 
1294 {                                             << 
1295 #ifdef G4HEPREPFILEDEBUG                         506 #ifdef G4HEPREPFILEDEBUG
1296   G4cout                                      << 507   G4cout <<
1297     << "G4HepRepFileSceneHandler::AddPrimitiv << 508     "G4HepRepFileSceneHandler::AddSolid(const G4Solid& solid) called for "
1298        "\n  side: "                           << 509   << solid.GetName()
1299     << square.GetWorldRadius() << G4endl;     << 510   << G4endl;
1300   PrintThings();                              << 511   PrintThings();
1301 #endif                                        << 512 #endif
1302                                               << 513   G4VSceneHandler::AddSolid(solid);  // Invoke default action.
1303   G4HepRepMessenger* messenger = G4HepRepMess << 514 }
1304                                               << 515 
1305   if(fpVisAttribs && (fpVisAttribs->IsVisible << 516 
1306      messenger->getCullInvisibles())          << 517 void G4HepRepFileSceneHandler::AddCompound (const G4VTrajectory& traj) {
1307     return;                                   << 518 #ifdef G4HEPREPFILEDEBUG
1308                                               << 519   G4cout << "G4HepRepFileSceneHandler::AddCompound(const G4VTrajectory&) " << G4endl;
1309   if(inPrimitives2D)                          << 520 #endif
1310   {                                           << 521   
1311     if(!warnedAbout2DMarkers)                 << 522   G4TrajectoriesModel* pTrModel =
1312     {                                         << 523     dynamic_cast<G4TrajectoriesModel*>(fpModel);
1313       G4cout << "HepRepFile does not currentl << 524   if (!pTrModel) G4Exception
1314       warnedAbout2DMarkers = true;            << 525     ("G4HepRepFileSceneHandler::AddCompound(const G4VTrajectory&)",
1315     }                                         << 526      "vis-HepRep0001", FatalException, "Not a G4TrajectoriesModel.");
1316     return;                                   << 527   
1317   }                                           << 528   // Pointers to hold trajectory attribute values and definitions.
1318                                               << 529   std::vector<G4AttValue>* rawTrajAttValues = traj.CreateAttValues();
1319   MarkerSizeType sizeType;                    << 530   trajAttValues =
1320   G4double size = GetMarkerSize(square, sizeT << 531     new std::vector<G4AttValue>;
1321   if(sizeType == world)                       << 532   trajAttDefs =
1322     size = 4.;                                << 533     new std::map<G4String,G4AttDef>;
1323                                               << 534   
1324   if(drawingTraj)                             << 535   // Iterators to use with attribute values and definitions.
1325     return;                                   << 536   std::vector<G4AttValue>::iterator iAttVal;
1326                                               << 537   std::map<G4String,G4AttDef>::const_iterator iAttDef;
1327   if(drawingHit)                              << 538   G4int i;
1328     InitHit();                                << 539   
1329                                               << 540   // Get trajectory attributes and definitions in standard HepRep style
1330   haveVisible = true;                         << 541   // (uniform units, 3Vectors decomposed).
1331   AddHepRepInstance("Point", square);         << 542   if (rawTrajAttValues) {
1332                                               << 543     G4bool error = G4AttCheck(rawTrajAttValues,
1333   hepRepXMLWriter->addAttValue("MarkName", "S << 544                   traj.GetAttDefs()).Standard(trajAttValues,trajAttDefs);
1334   hepRepXMLWriter->addAttValue("MarkSize", (G << 545     if (error) {
1335                                               << 546       G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
1336   hepRepXMLWriter->addPrimitive();            << 547       "\nERROR found during conversion to standard trajectory attributes."
1337                                               << 548       << G4endl;
1338   G4Point3D center = (fObjectTransformation)  << 549     }
1339   hepRepXMLWriter->addPoint(center.x(), cente << 550 #ifdef G4HEPREPFILEDEBUG 
                                                   >> 551     G4cout <<
                                                   >> 552       "G4HepRepFileSceneHandler::AddCompound(traj): standardised attributes:\n"
                                                   >> 553       << G4AttCheck(trajAttValues,trajAttDefs) << G4endl;
                                                   >> 554 #endif
                                                   >> 555     delete rawTrajAttValues;
                                                   >> 556   }
                                                   >> 557   
                                                   >> 558   // Open the HepRep output file if it is not already open.
                                                   >> 559   CheckFileOpen();
                                                   >> 560   
                                                   >> 561   // Add the Event Data Type if it hasn't already been added.
                                                   >> 562   if (strcmp("Event Data",hepRepXMLWriter->prevTypeName[0])!=0) {
                                                   >> 563     hepRepXMLWriter->addType("Event Data",0);
                                                   >> 564     hepRepXMLWriter->addInstance();
                                                   >> 565   }
                                                   >> 566   
                                                   >> 567   // Add the Trajectories Type.
                                                   >> 568   G4String previousName = hepRepXMLWriter->prevTypeName[1];
                                                   >> 569   hepRepXMLWriter->addType("Trajectories",1);
                                                   >> 570   
                                                   >> 571   // If this is the first trajectory of this event,
                                                   >> 572   // specify attribute values common to all trajectories.
                                                   >> 573   if (strcmp("Trajectories",previousName)!=0) {
                                                   >> 574     hepRepXMLWriter->addAttValue("Layer",100);
                                                   >> 575     
                                                   >> 576     // Take all Trajectory attDefs from first trajectory.
                                                   >> 577     // Would rather be able to get these attDefs without needing a reference from any
                                                   >> 578     // particular trajectory, but don't know how to do that.
                                                   >> 579     // Write out trajectory attribute definitions.
                                                   >> 580     if (trajAttValues && trajAttDefs) {
                                                   >> 581       for (iAttVal = trajAttValues->begin();
                                                   >> 582          iAttVal != trajAttValues->end(); ++iAttVal) {
                                                   >> 583         iAttDef = trajAttDefs->find(iAttVal->GetName());
                                                   >> 584         if (iAttDef != trajAttDefs->end()) {
                                                   >> 585           // Protect against incorrect use of Category.  Anything value other than the
                                                   >> 586           // standard ones will be considered to be in the physics category.
                                                   >> 587           G4String category = iAttDef->second.GetCategory();
                                                   >> 588           if (strcmp(category,"Draw")!=0 &&
                                                   >> 589             strcmp(category,"Physics")!=0 &&
                                                   >> 590             strcmp(category,"Association")!=0 &&
                                                   >> 591             strcmp(category,"PickAction")!=0)
                                                   >> 592             category = "Physics";
                                                   >> 593           hepRepXMLWriter->addAttDef(iAttVal->GetName(), iAttDef->second.GetDesc(),
                                                   >> 594                          category, iAttDef->second.GetExtra());
                                                   >> 595         }
                                                   >> 596       } 
                                                   >> 597     }
                                                   >> 598     
                                                   >> 599     // Take all TrajectoryPoint attDefs from first point of first trajectory.
                                                   >> 600     // Would rather be able to get these attDefs without needing a reference from any
                                                   >> 601     // particular point, but don't know how to do that.
                                                   >> 602     if ((trajContext->GetDrawStepPts() || trajContext->GetDrawAuxPts())
                                                   >> 603       && traj.GetPointEntries()>0) {
                                                   >> 604       G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(0);
                                                   >> 605       
                                                   >> 606       // Pointers to hold trajectory point attribute values and definitions.
                                                   >> 607       std::vector<G4AttValue>* rawPointAttValues = aTrajectoryPoint->CreateAttValues();
                                                   >> 608       std::vector<G4AttValue>* pointAttValues =
                                                   >> 609       new std::vector<G4AttValue>;
                                                   >> 610       std::map<G4String,G4AttDef>* pointAttDefs =
                                                   >> 611       new std::map<G4String,G4AttDef>;
                                                   >> 612       
                                                   >> 613       // Get first trajectory point's attributes and definitions in standard HepRep style
                                                   >> 614       // (uniform units, 3Vectors decomposed).
                                                   >> 615       if (rawPointAttValues) {
                                                   >> 616         G4bool error = G4AttCheck(rawPointAttValues,
                                                   >> 617                       aTrajectoryPoint->GetAttDefs()).Standard(pointAttValues,pointAttDefs);
                                                   >> 618         if (error) {
                                                   >> 619           G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
                                                   >> 620           "\nERROR found during conversion to standard first point attributes." << G4endl;
                                                   >> 621         }
                                                   >> 622         
                                                   >> 623         // Write out point attribute definitions.
                                                   >> 624         if (pointAttValues && pointAttDefs) {
                                                   >> 625           for (iAttVal = pointAttValues->begin();
                                                   >> 626              iAttVal != pointAttValues->end(); ++iAttVal) {
                                                   >> 627             iAttDef =
                                                   >> 628             pointAttDefs->find(iAttVal->GetName());
                                                   >> 629             if (iAttDef != pointAttDefs->end()) {
                                                   >> 630               // Protect against incorrect use of Category.  Anything value other than the
                                                   >> 631               // standard ones will be considered to be in the physics category.
                                                   >> 632               G4String category = iAttDef->second.GetCategory();
                                                   >> 633               if (strcmp(category,"Draw")!=0 &&
                                                   >> 634                 strcmp(category,"Physics")!=0 &&
                                                   >> 635                 strcmp(category,"Association")!=0 &&
                                                   >> 636                 strcmp(category,"PickAction")!=0)
                                                   >> 637                 category = "Physics";
                                                   >> 638               // Do not write out the Aux or Pos attribute.  Aux does not conform to the HepRep rule
                                                   >> 639               // that each object can have only one instance of a given AttValue.
                                                   >> 640               // Both of these attributes are redundant to actual position information of the point.
                                                   >> 641               if (strcmp(iAttVal->GetName(),"Aux-X")!=0 &&
                                                   >> 642                 strcmp(iAttVal->GetName(),"Aux-Y")!=0 &&
                                                   >> 643                 strcmp(iAttVal->GetName(),"Aux-Z")!=0 &&
                                                   >> 644                 strcmp(iAttVal->GetName(),"Pos-X")!=0 &&
                                                   >> 645                 strcmp(iAttVal->GetName(),"Pos-Y")!=0 &&
                                                   >> 646                 strcmp(iAttVal->GetName(),"Pos-Z")!=0)
                                                   >> 647                 hepRepXMLWriter->addAttDef(iAttVal->GetName(), iAttDef->second.GetDesc(),
                                                   >> 648                             category, iAttDef->second.GetExtra());
                                                   >> 649             }
                                                   >> 650           }
                                                   >> 651         }
                                                   >> 652         delete rawPointAttValues;
                                                   >> 653       }
                                                   >> 654       
                                                   >> 655       // Clean up point attributes.
                                                   >> 656       if (pointAttValues)
                                                   >> 657         delete pointAttValues;
                                                   >> 658       if (pointAttDefs)
                                                   >> 659         delete pointAttDefs;
                                                   >> 660     }
                                                   >> 661   } // end of special treatment for when this is the first trajectory.
                                                   >> 662   
                                                   >> 663   // Now that we have written out all of the attributes that are based on the
                                                   >> 664   // trajectory's particulars, call base class to deconstruct trajectory into polyline and/or points
                                                   >> 665   // (or nothing if trajectory is to be filtered out).
                                                   >> 666   // If base class calls for drawing points, no points will actually be drawn there since we
                                                   >> 667   // instead need to do point drawing from here (in order to obtain the points attributes,
                                                   >> 668   // not available from AddPrimitive(...point).  Instead, such a call will just serve to set the
                                                   >> 669   // flag that tells us that point drawing was requested for this trajectory (depends on several
                                                   >> 670   // factors including trajContext and filtering).
                                                   >> 671   drawingTraj = true;
                                                   >> 672   doneInitTraj = false;
                                                   >> 673   G4VSceneHandler::AddCompound(traj);
                                                   >> 674   drawingTraj = false;
                                                   >> 675   
                                                   >> 676   // Draw step points.
                                                   >> 677   if (trajContext->GetDrawStepPts()) {
                                                   >> 678     if (!doneInitTraj)
                                                   >> 679       InitTrajectory();
                                                   >> 680     // Create Trajectory Points as a subType of Trajectories.
                                                   >> 681     // Note that we should create this heprep type even if there are no actual points.
                                                   >> 682     // This allows the user to tell that points don't exist (admittedly odd) rather
                                                   >> 683     // than that they were omitted by the drawing mode.
                                                   >> 684     previousName = hepRepXMLWriter->prevTypeName[2];
                                                   >> 685     hepRepXMLWriter->addType("Trajectory Step Points",2);
                                                   >> 686 
                                                   >> 687     float redness;
                                                   >> 688     float greenness;
                                                   >> 689     float blueness;     
                                                   >> 690     G4int markSize;
                                                   >> 691     G4bool visible;
                                                   >> 692     G4bool square;
                                                   >> 693     G4Colour colour = trajContext->GetStepPtsColour();
                                                   >> 694     redness = colour.GetRed();
                                                   >> 695     greenness = colour.GetGreen();
                                                   >> 696     blueness = colour.GetBlue();
                                                   >> 697     markSize = (G4int) trajContext->GetStepPtsSize();
                                                   >> 698     visible = (G4int) trajContext->GetStepPtsVisible();
                                                   >> 699     square = (trajContext->GetStepPtsType()==G4Polymarker::squares);
                                                   >> 700 
                                                   >> 701     // Avoiding drawing anything black on black.  
                                                   >> 702     if (redness==0. && greenness==0. && blueness==0.) {
                                                   >> 703       redness = 1.;
                                                   >> 704       greenness = 1.;
                                                   >> 705       blueness = 1.;
                                                   >> 706     }
                                                   >> 707     
                                                   >> 708     // Specify attributes common to all trajectory points.
                                                   >> 709     if (strcmp("Trajectory Step Points",previousName)!=0) {
                                                   >> 710       hepRepXMLWriter->addAttValue("DrawAs","Point");
                                                   >> 711       hepRepXMLWriter->addAttValue("MarkColor", redness, greenness, blueness);
                                                   >> 712       hepRepXMLWriter->addAttValue("MarkSize",markSize);
                                                   >> 713       hepRepXMLWriter->addAttValue("Layer",110);
                                                   >> 714       hepRepXMLWriter->addAttValue("Visibility",visible);
                                                   >> 715       if (square)
                                                   >> 716         hepRepXMLWriter->addAttValue("MarkName","square");
                                                   >> 717       else
                                                   >> 718         hepRepXMLWriter->addAttValue("MarkName","dot");
                                                   >> 719     }
                                                   >> 720     
                                                   >> 721     // Loop over all points on this trajectory.
                                                   >> 722     for (i = 0; i < traj.GetPointEntries(); i++) {
                                                   >> 723       G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(i);
                                                   >> 724       
                                                   >> 725       // Each point is a separate instance of the type Trajectory Points.
                                                   >> 726       hepRepXMLWriter->addInstance();
                                                   >> 727       
                                                   >> 728       // Pointers to hold trajectory point attribute values and definitions.
                                                   >> 729       std::vector<G4AttValue>* rawPointAttValues = aTrajectoryPoint->CreateAttValues();
                                                   >> 730       std::vector<G4AttValue>* pointAttValues =
                                                   >> 731         new std::vector<G4AttValue>;
                                                   >> 732       std::map<G4String,G4AttDef>* pointAttDefs =
                                                   >> 733         new std::map<G4String,G4AttDef>;
                                                   >> 734       
                                                   >> 735       // Get trajectory point attributes and definitions in standard HepRep style
                                                   >> 736       // (uniform units, 3Vectors decomposed).
                                                   >> 737       if (rawPointAttValues) {
                                                   >> 738         G4bool error = G4AttCheck(rawPointAttValues,
                                                   >> 739                       aTrajectoryPoint->GetAttDefs()).Standard(pointAttValues,pointAttDefs);
                                                   >> 740         if (error) {
                                                   >> 741           G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
                                                   >> 742           "\nERROR found during conversion to standard point attributes." << G4endl;
                                                   >> 743         }
                                                   >> 744         
                                                   >> 745         // Write out point attribute values.
                                                   >> 746         if (pointAttValues) {
                                                   >> 747           for (iAttVal = pointAttValues->begin();
                                                   >> 748              iAttVal != pointAttValues->end(); ++iAttVal)
                                                   >> 749             // Do not write out the Aux or Pos attribute.  Aux does not conform to the HepRep rule
                                                   >> 750             // that each object can have only one instance of a given AttValue.
                                                   >> 751             // Both of these attributes are redundant to actual position information of the point.
                                                   >> 752             if (strcmp(iAttVal->GetName(),"Aux-X")!=0 &&
                                                   >> 753               strcmp(iAttVal->GetName(),"Aux-Y")!=0 &&
                                                   >> 754               strcmp(iAttVal->GetName(),"Aux-Z")!=0 &&
                                                   >> 755               strcmp(iAttVal->GetName(),"Pos-X")!=0 &&
                                                   >> 756               strcmp(iAttVal->GetName(),"Pos-Y")!=0 &&
                                                   >> 757               strcmp(iAttVal->GetName(),"Pos-Z")!=0)
                                                   >> 758               hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
                                                   >> 759         }
                                                   >> 760       }
                                                   >> 761       
                                                   >> 762       // Clean up point attributes.
                                                   >> 763                         delete pointAttDefs;
                                                   >> 764                         delete pointAttValues;
                                                   >> 765                         delete rawPointAttValues;
                                                   >> 766 
                                                   >> 767       // Each trajectory point is made of a single primitive, a point.
                                                   >> 768       hepRepXMLWriter->addPrimitive();
                                                   >> 769       G4Point3D vertex = aTrajectoryPoint->GetPosition();
                                                   >> 770       hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
                                                   >> 771     }
                                                   >> 772   }
                                                   >> 773   
                                                   >> 774   // Draw Auxiliary Points
                                                   >> 775   if (trajContext->GetDrawAuxPts()) {
                                                   >> 776     if (!doneInitTraj)
                                                   >> 777       InitTrajectory();
                                                   >> 778     // Create Trajectory Points as a subType of Trajectories.
                                                   >> 779     // Note that we should create this heprep type even if there are no actual points.
                                                   >> 780     // This allows the user to tell that points don't exist (admittedly odd) rather
                                                   >> 781     // than that they were omitted by the drawing mode.
                                                   >> 782     previousName = hepRepXMLWriter->prevTypeName[2];
                                                   >> 783     hepRepXMLWriter->addType("Trajectory Auxiliary Points",2);
                                                   >> 784 
                                                   >> 785     float redness;
                                                   >> 786     float greenness;
                                                   >> 787     float blueness;     
                                                   >> 788     G4int markSize;
                                                   >> 789     G4bool visible;
                                                   >> 790     G4bool square;
                                                   >> 791     G4Colour colour = trajContext->GetAuxPtsColour();
                                                   >> 792     redness = colour.GetRed();
                                                   >> 793     greenness = colour.GetGreen();
                                                   >> 794     blueness = colour.GetBlue();
                                                   >> 795     markSize = (G4int) trajContext->GetAuxPtsSize();
                                                   >> 796     visible = (G4int) trajContext->GetAuxPtsVisible();
                                                   >> 797     square = (trajContext->GetAuxPtsType()==G4Polymarker::squares);
                                                   >> 798 
                                                   >> 799     // Avoiding drawing anything black on black.  
                                                   >> 800     if (redness==0. && greenness==0. && blueness==0.) {
                                                   >> 801       redness = 1.;
                                                   >> 802       greenness = 1.;
                                                   >> 803       blueness = 1.;
                                                   >> 804     }
                                                   >> 805     
                                                   >> 806     // Specify attributes common to all trajectory points.
                                                   >> 807     if (strcmp("Trajectory Auxiliary Points",previousName)!=0) {
                                                   >> 808       hepRepXMLWriter->addAttValue("DrawAs","Point");
                                                   >> 809       hepRepXMLWriter->addAttValue("MarkColor", redness, greenness, blueness);
                                                   >> 810       hepRepXMLWriter->addAttValue("MarkSize",markSize);
                                                   >> 811       hepRepXMLWriter->addAttValue("Layer",110);
                                                   >> 812       hepRepXMLWriter->addAttValue("Visibility",visible);
                                                   >> 813       if (square)
                                                   >> 814         hepRepXMLWriter->addAttValue("MarkName","Square");
                                                   >> 815       else
                                                   >> 816         hepRepXMLWriter->addAttValue("MarkName","Dot");
                                                   >> 817     }
                                                   >> 818     
                                                   >> 819     // Loop over all points on this trajectory.
                                                   >> 820     for (i = 0; i < traj.GetPointEntries(); i++) {
                                                   >> 821       G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(i);
                                                   >> 822       
                                                   >> 823       // Each point is a separate instance of the type Trajectory Points.
                                                   >> 824       hepRepXMLWriter->addInstance();
                                                   >> 825       
                                                   >> 826       // Pointers to hold trajectory point attribute values and definitions.
                                                   >> 827       std::vector<G4AttValue>* rawPointAttValues = aTrajectoryPoint->CreateAttValues();
                                                   >> 828       std::vector<G4AttValue>* pointAttValues =
                                                   >> 829         new std::vector<G4AttValue>;
                                                   >> 830       std::map<G4String,G4AttDef>* pointAttDefs =
                                                   >> 831         new std::map<G4String,G4AttDef>;
                                                   >> 832       
                                                   >> 833       // Get trajectory point attributes and definitions in standard HepRep style
                                                   >> 834       // (uniform units, 3Vectors decomposed).
                                                   >> 835       if (rawPointAttValues) {
                                                   >> 836         G4bool error = G4AttCheck(rawPointAttValues,
                                                   >> 837                       aTrajectoryPoint->GetAttDefs()).Standard(pointAttValues,pointAttDefs);
                                                   >> 838         if (error) {
                                                   >> 839           G4cout << "G4HepRepFileSceneHandler::AddCompound(traj):"
                                                   >> 840           "\nERROR found during conversion to standard point attributes." << G4endl;
                                                   >> 841         }
                                                   >> 842         
                                                   >> 843         // Write out point attribute values.
                                                   >> 844         if (pointAttValues) {
                                                   >> 845           for (iAttVal = pointAttValues->begin();
                                                   >> 846              iAttVal != pointAttValues->end(); ++iAttVal)
                                                   >> 847             // Do not write out the Aux or Pos attribute.  Aux does not conform to the HepRep rule
                                                   >> 848             // that each object can have only one instance of a given AttValue.
                                                   >> 849             // Both of these attributes are redundant to actual position information of the point.
                                                   >> 850             if (strcmp(iAttVal->GetName(),"Aux-X")!=0 &&
                                                   >> 851               strcmp(iAttVal->GetName(),"Aux-Y")!=0 &&
                                                   >> 852               strcmp(iAttVal->GetName(),"Aux-Z")!=0 &&
                                                   >> 853               strcmp(iAttVal->GetName(),"Pos-X")!=0 &&
                                                   >> 854               strcmp(iAttVal->GetName(),"Pos-Y")!=0 &&
                                                   >> 855               strcmp(iAttVal->GetName(),"Pos-Z")!=0)
                                                   >> 856               hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
                                                   >> 857         }
                                                   >> 858       }
                                                   >> 859       
                                                   >> 860       // Clean up point attributes.
                                                   >> 861       delete pointAttDefs;
                                                   >> 862                         delete pointAttValues;
                                                   >> 863                         delete rawPointAttValues;
                                                   >> 864 
                                                   >> 865       // Each trajectory point is made of a single primitive, a point.
                                                   >> 866       G4Point3D vertex = aTrajectoryPoint->GetPosition();
                                                   >> 867       
                                                   >> 868       // Loop over auxiliary points associated with this Trajectory Point.
                                                   >> 869       const std::vector<G4ThreeVector>* auxiliaries = aTrajectoryPoint->GetAuxiliaryPoints();
                                                   >> 870       if (0 != auxiliaries) {
                                                   >> 871         for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
                                                   >> 872           const G4ThreeVector auxPos((*auxiliaries)[iAux]);
                                                   >> 873           hepRepXMLWriter->addPrimitive();
                                                   >> 874           hepRepXMLWriter->addPoint(auxPos.x(), auxPos.y(), auxPos.z());
                                                   >> 875         }
                                                   >> 876       }
                                                   >> 877     }
                                                   >> 878   }
                                                   >> 879 }
                                                   >> 880 
                                                   >> 881 
                                                   >> 882 void G4HepRepFileSceneHandler::AddCompound (const G4VHit& hit) {
                                                   >> 883 #ifdef G4HEPREPFILEDEBUG
                                                   >> 884   G4cout << "G4HepRepFileSceneHandler::AddCompound(G4VHit&) " << G4endl;
                                                   >> 885 #endif
                                                   >> 886   
                                                   >> 887   // Pointers to hold hit attribute values and definitions.
                                                   >> 888   std::vector<G4AttValue>* rawHitAttValues = hit.CreateAttValues();
                                                   >> 889   hitAttValues =
                                                   >> 890     new std::vector<G4AttValue>;
                                                   >> 891   hitAttDefs =
                                                   >> 892     new std::map<G4String,G4AttDef>;
                                                   >> 893   
                                                   >> 894   // Iterators to use with attribute values and definitions.
                                                   >> 895   std::vector<G4AttValue>::iterator iAttVal;
                                                   >> 896   std::map<G4String,G4AttDef>::const_iterator iAttDef;
                                                   >> 897   
                                                   >> 898   // Get hit attributes and definitions in standard HepRep style
                                                   >> 899   // (uniform units, 3Vectors decomposed).
                                                   >> 900   if (rawHitAttValues) {
                                                   >> 901     G4bool error = G4AttCheck(rawHitAttValues,
                                                   >> 902                   hit.GetAttDefs()).Standard(hitAttValues,hitAttDefs);
                                                   >> 903     if (error) {
                                                   >> 904       G4cout << "G4HepRepFileSceneHandler::AddCompound(hit):"
                                                   >> 905       "\nERROR found during conversion to standard hit attributes."
                                                   >> 906       << G4endl;
                                                   >> 907     }
                                                   >> 908 #ifdef G4HEPREPFILEDEBUG 
                                                   >> 909     G4cout <<
                                                   >> 910       "G4HepRepFileSceneHandler::AddCompound(hit): standardised attributes:\n"
                                                   >> 911       << G4AttCheck(hitAttValues,hitAttDefs) << G4endl;
                                                   >> 912 #endif
                                                   >> 913     delete rawHitAttValues;
                                                   >> 914   }
                                                   >> 915   
                                                   >> 916   // Open the HepRep output file if it is not already open.
                                                   >> 917   CheckFileOpen();
                                                   >> 918   
                                                   >> 919   // Add the Event Data Type if it hasn't already been added.
                                                   >> 920   if (strcmp("Event Data",hepRepXMLWriter->prevTypeName[0])!=0) {
                                                   >> 921     hepRepXMLWriter->addType("Event Data",0);
                                                   >> 922     hepRepXMLWriter->addInstance();
                                                   >> 923   }
                                                   >> 924   
                                                   >> 925   // Find out the current HitType.
                                                   >> 926   G4String hitType = "Hits";
                                                   >> 927   if (hitAttValues) {
                                                   >> 928     G4bool found = false;
                                                   >> 929     for (iAttVal = hitAttValues->begin();
                                                   >> 930        iAttVal != hitAttValues->end() && !found; ++iAttVal) {
                                                   >> 931       if (strcmp(iAttVal->GetName(),"HitType")==0) {
                                                   >> 932         hitType = iAttVal->GetValue();
                                                   >> 933         found = true;
                                                   >> 934       }
                                                   >> 935     }
                                                   >> 936   }
                                                   >> 937   
                                                   >> 938   // Add the Hits Type.
                                                   >> 939   G4String previousName = hepRepXMLWriter->prevTypeName[1];
                                                   >> 940   hepRepXMLWriter->addType(hitType,1);
                                                   >> 941   
                                                   >> 942   // If this is the first hit of this event,
                                                   >> 943   // specify attribute values common to all hits.
                                                   >> 944   if (strcmp(hitType,previousName)!=0) {
                                                   >> 945     hepRepXMLWriter->addAttValue("Layer",130);
                                                   >> 946     
                                                   >> 947     // Take all Hit attDefs from first hit.
                                                   >> 948     // Would rather be able to get these attDefs without needing a reference from any
                                                   >> 949     // particular hit, but don't know how to do that.
                                                   >> 950     // Write out hit attribute definitions.
                                                   >> 951     if (hitAttValues && hitAttDefs) {
                                                   >> 952       for (iAttVal = hitAttValues->begin();
                                                   >> 953          iAttVal != hitAttValues->end(); ++iAttVal) {
                                                   >> 954         iAttDef = hitAttDefs->find(iAttVal->GetName());
                                                   >> 955         if (iAttDef != hitAttDefs->end()) {
                                                   >> 956           // Protect against incorrect use of Category.  Anything value other than the
                                                   >> 957           // standard ones will be considered to be in the physics category.
                                                   >> 958           G4String category = iAttDef->second.GetCategory();
                                                   >> 959           if (strcmp(category,"Draw")!=0 &&
                                                   >> 960             strcmp(category,"Physics")!=0 &&
                                                   >> 961             strcmp(category,"Association")!=0 &&
                                                   >> 962             strcmp(category,"PickAction")!=0)
                                                   >> 963             category = "Physics";
                                                   >> 964           hepRepXMLWriter->addAttDef(iAttVal->GetName(), iAttDef->second.GetDesc(),
                                                   >> 965                          category, iAttDef->second.GetExtra());
                                                   >> 966         }
                                                   >> 967       }
                                                   >> 968     }
                                                   >> 969   } // end of special treatment for when this is the first hit.
                                                   >> 970   
                                                   >> 971   // Now that we have written out all of the attributes that are based on the
                                                   >> 972   // hit's particulars, call base class to deconstruct hit into a primitives.
                                                   >> 973   drawingHit = true;
                                                   >> 974   doneInitHit = false;
                                                   >> 975   G4VSceneHandler::AddCompound(hit);  // Invoke default action.
                                                   >> 976   drawingHit = false;
                                                   >> 977 }
                                                   >> 978 
                                                   >> 979 
                                                   >> 980 void G4HepRepFileSceneHandler::InitTrajectory() {
                                                   >> 981   if (!doneInitTraj) {
                                                   >> 982     // For every trajectory, add an instance of Type Trajectory.
                                                   >> 983     hepRepXMLWriter->addInstance();
                                                   >> 984     
                                                   >> 985     // Write out the trajectory's attribute values.
                                                   >> 986     if (trajAttValues) {
                                                   >> 987       std::vector<G4AttValue>::iterator iAttVal;
                                                   >> 988       for (iAttVal = trajAttValues->begin();
                                                   >> 989          iAttVal != trajAttValues->end(); ++iAttVal)
                                                   >> 990         hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
                                                   >> 991       delete trajAttValues; 
                                                   >> 992     }
                                                   >> 993     
                                                   >> 994     // Clean up trajectory attributes.
                                                   >> 995     if (trajAttDefs)
                                                   >> 996       delete trajAttDefs;
                                                   >> 997     
                                                   >> 998     doneInitTraj = true;
                                                   >> 999   }
                                                   >> 1000 }
                                                   >> 1001 
                                                   >> 1002 
                                                   >> 1003 void G4HepRepFileSceneHandler::InitHit() {
                                                   >> 1004   if (!doneInitHit) {
                                                   >> 1005     // For every hit, add an instance of Type Hit.
                                                   >> 1006     hepRepXMLWriter->addInstance();
                                                   >> 1007     
                                                   >> 1008     // Write out the hit's attribute values.
                                                   >> 1009     if (hitAttValues) {
                                                   >> 1010       std::vector<G4AttValue>::iterator iAttVal;
                                                   >> 1011       for (iAttVal = hitAttValues->begin();
                                                   >> 1012          iAttVal != hitAttValues->end(); ++iAttVal)
                                                   >> 1013         hepRepXMLWriter->addAttValue(iAttVal->GetName(), iAttVal->GetValue());
                                                   >> 1014       delete hitAttValues;
                                                   >> 1015     }
                                                   >> 1016     
                                                   >> 1017     // Clean up hit attributes.
                                                   >> 1018     if (hitAttDefs)
                                                   >> 1019       delete hitAttDefs;
                                                   >> 1020     
                                                   >> 1021     doneInitHit = true;
                                                   >> 1022   }
                                                   >> 1023 }
                                                   >> 1024 
                                                   >> 1025 
                                                   >> 1026 void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyline& polyline) {
                                                   >> 1027 #ifdef G4HEPREPFILEDEBUG
                                                   >> 1028   G4cout <<
                                                   >> 1029     "G4HepRepFileSceneHandler::AddPrimitive(const G4Polyline& polyline) called:"
                                                   >> 1030     "\n  polyline: " << polyline
                                                   >> 1031   << G4endl;
                                                   >> 1032   PrintThings();
                                                   >> 1033 #endif
                                                   >> 1034   
                                                   >> 1035   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 1036   
                                                   >> 1037   if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 1038     return;
                                                   >> 1039   
                                                   >> 1040   if (inPrimitives2D) {
                                                   >> 1041     if (!warnedAbout2DMarkers) {
                                                   >> 1042       G4cout << "HepRepFile does not currently support 2D lines." << G4endl;
                                                   >> 1043       warnedAbout2DMarkers = true;
                                                   >> 1044     }
                                                   >> 1045     return;
                                                   >> 1046     }
                                                   >> 1047   
                                                   >> 1048   if (drawingTraj)
                                                   >> 1049     InitTrajectory();
                                                   >> 1050     
                                                   >> 1051   if (drawingHit)
                                                   >> 1052     InitHit();
                                                   >> 1053   
                                                   >> 1054   haveVisible = true;
                                                   >> 1055   AddHepRepInstance("Line", polyline);
                                                   >> 1056   
                                                   >> 1057   hepRepXMLWriter->addPrimitive();
                                                   >> 1058   
                                                   >> 1059   for (size_t i=0; i < polyline.size(); i++) {
                                                   >> 1060     G4Point3D vertex = (fObjectTransformation) * polyline[i];
                                                   >> 1061     hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
                                                   >> 1062   }
                                                   >> 1063 }
                                                   >> 1064 
                                                   >> 1065 
                                                   >> 1066 
                                                   >> 1067 void G4HepRepFileSceneHandler::AddPrimitive (const G4Polymarker& line) {
                                                   >> 1068 #ifdef G4HEPREPFILEDEBUG
                                                   >> 1069   G4cout <<
                                                   >> 1070     "G4HepRepFileSceneHandler::AddPrimitive(const G4Polymarker& line) called"
                                                   >> 1071   << G4endl;
                                                   >> 1072   PrintThings();
                                                   >> 1073 #endif
                                                   >> 1074   
                                                   >> 1075   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 1076   
                                                   >> 1077   if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 1078     return;
                                                   >> 1079   
                                                   >> 1080   if (inPrimitives2D) {
                                                   >> 1081     if (!warnedAbout2DMarkers) {
                                                   >> 1082       G4cout << "HepRepFile does not currently support 2D lines." << G4endl;
                                                   >> 1083       warnedAbout2DMarkers = true;
                                                   >> 1084     }
                                                   >> 1085     return;
                                                   >> 1086     }
                                                   >> 1087   
                                                   >> 1088   MarkerSizeType sizeType;
                                                   >> 1089   G4double size = GetMarkerSize (line, sizeType);
                                                   >> 1090   if (sizeType==world)
                                                   >> 1091     size = 4.;
                                                   >> 1092   
                                                   >> 1093   if (drawingTraj)
                                                   >> 1094     return;
                                                   >> 1095   
                                                   >> 1096   if (drawingHit)
                                                   >> 1097     InitHit();
                                                   >> 1098   
                                                   >> 1099   haveVisible = true;
                                                   >> 1100   AddHepRepInstance("Point", line);
                                                   >> 1101   
                                                   >> 1102   hepRepXMLWriter->addAttValue("MarkName", "Dot");
                                                   >> 1103   hepRepXMLWriter->addAttValue("MarkSize", (G4int) size);
                                                   >> 1104   
                                                   >> 1105   hepRepXMLWriter->addPrimitive();
                                                   >> 1106   
                                                   >> 1107   for (size_t i=0; i < line.size(); i++) {
                                                   >> 1108     G4Point3D vertex = (fObjectTransformation) * line[i];
                                                   >> 1109     hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
                                                   >> 1110   }
                                                   >> 1111 }
                                                   >> 1112 
                                                   >> 1113 
                                                   >> 1114 void G4HepRepFileSceneHandler::AddPrimitive(const G4Text& text) {
                                                   >> 1115 #ifdef G4HEPREPFILEDEBUG
                                                   >> 1116   G4cout <<
                                                   >> 1117     "G4HepRepFileSceneHandler::AddPrimitive(const G4Text& text) called:"
                                                   >> 1118     "\n  text: " << text.GetText()
                                                   >> 1119   << G4endl;
                                                   >> 1120   PrintThings();
                                                   >> 1121 #endif
                                                   >> 1122   
                                                   >> 1123   if (!inPrimitives2D) {
                                                   >> 1124     if (!warnedAbout3DText) {
                                                   >> 1125       G4cout << "HepRepFile does not currently support 3D text." << G4endl;
                                                   >> 1126       G4cout << "HepRep browsers can directly display text attributes on request." << G4endl;
                                                   >> 1127       G4cout << "See Application Developers Guide for how to attach attributes to viewable objects." << G4endl;
                                                   >> 1128       warnedAbout3DText = true;
                                                   >> 1129     }
                                                   >> 1130     return;
                                                   >> 1131     }
                                                   >> 1132   
                                                   >> 1133   MarkerSizeType sizeType;
                                                   >> 1134   G4double size = GetMarkerSize (text, sizeType);
                                                   >> 1135   if (sizeType==world)
                                                   >> 1136     size = 12.;
                                                   >> 1137   
                                                   >> 1138   haveVisible = true;
                                                   >> 1139   AddHepRepInstance("Text", text);
                                                   >> 1140   
                                                   >> 1141   hepRepXMLWriter->addAttValue("VAlign", "Top");
                                                   >> 1142   hepRepXMLWriter->addAttValue("HAlign", "Left");
                                                   >> 1143   hepRepXMLWriter->addAttValue("FontName", "Arial");
                                                   >> 1144   hepRepXMLWriter->addAttValue("FontStyle", "Plain");
                                                   >> 1145   hepRepXMLWriter->addAttValue("FontSize", (G4int) size);
                                                   >> 1146   hepRepXMLWriter->addAttValue("FontHasBanner", "TRUE");
                                                   >> 1147   hepRepXMLWriter->addAttValue("FontBannerColor", "0,0,0");
                                                   >> 1148   
                                                   >> 1149   const G4Colour& colour = GetTextColour(text);
                                                   >> 1150   float redness = colour.GetRed();
                                                   >> 1151   float greenness = colour.GetGreen();
                                                   >> 1152   float blueness = colour.GetBlue();
                                                   >> 1153     
                                                   >> 1154   // Avoiding drawing anything black on black.  
                                                   >> 1155   if (redness==0. && greenness==0. && blueness==0.) {
                                                   >> 1156     redness = 1.;
                                                   >> 1157     greenness = 1.;
                                                   >> 1158     blueness = 1.;
                                                   >> 1159   }
                                                   >> 1160   hepRepXMLWriter->addAttValue("FontColor",redness,greenness,blueness);
                                                   >> 1161   
                                                   >> 1162   hepRepXMLWriter->addPrimitive();
                                                   >> 1163   
                                                   >> 1164   hepRepXMLWriter->addAttValue("Text", text.GetText());
                                                   >> 1165   hepRepXMLWriter->addAttValue("VPos", .99-text.GetYOffset());
                                                   >> 1166   hepRepXMLWriter->addAttValue("HPos", text.GetXOffset());
                                                   >> 1167 }
                                                   >> 1168 
                                                   >> 1169 
                                                   >> 1170 void G4HepRepFileSceneHandler::AddPrimitive(const G4Circle& circle) {
                                                   >> 1171 #ifdef G4HEPREPFILEDEBUG
                                                   >> 1172   G4cout <<
                                                   >> 1173     "G4HepRepFileSceneHandler::AddPrimitive(const G4Circle& circle) called:"
                                                   >> 1174     "\n  radius: " << circle.GetWorldRadius()
                                                   >> 1175   << G4endl;
                                                   >> 1176   PrintThings();
                                                   >> 1177 #endif
                                                   >> 1178   
                                                   >> 1179   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 1180   
                                                   >> 1181   if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 1182     return;
                                                   >> 1183   
                                                   >> 1184   if (inPrimitives2D) {
                                                   >> 1185     if (!warnedAbout2DMarkers) {
                                                   >> 1186       G4cout << "HepRepFile does not currently support 2D circles." << G4endl;
                                                   >> 1187       warnedAbout2DMarkers = true;
                                                   >> 1188     }
                                                   >> 1189     return;
                                                   >> 1190     }
                                                   >> 1191   
                                                   >> 1192   MarkerSizeType sizeType;
                                                   >> 1193   G4double size = GetMarkerSize (circle, sizeType);
                                                   >> 1194   if (sizeType==world)
                                                   >> 1195     size = 4.;
                                                   >> 1196   
                                                   >> 1197   if (drawingTraj)
                                                   >> 1198     return;
                                                   >> 1199   
                                                   >> 1200   if (drawingHit)
                                                   >> 1201     InitHit();
                                                   >> 1202   
                                                   >> 1203   haveVisible = true;
                                                   >> 1204   AddHepRepInstance("Point", circle);
                                                   >> 1205   
                                                   >> 1206   hepRepXMLWriter->addAttValue("MarkName", "Dot");
                                                   >> 1207   hepRepXMLWriter->addAttValue("MarkSize", (G4int) size);
                                                   >> 1208   
                                                   >> 1209   hepRepXMLWriter->addPrimitive();
                                                   >> 1210   
                                                   >> 1211   G4Point3D center = (fObjectTransformation) * circle.GetPosition();
                                                   >> 1212   hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
                                                   >> 1213 }
                                                   >> 1214 
                                                   >> 1215 
                                                   >> 1216 void G4HepRepFileSceneHandler::AddPrimitive(const G4Square& square) {
                                                   >> 1217 #ifdef G4HEPREPFILEDEBUG
                                                   >> 1218   G4cout <<
                                                   >> 1219     "G4HepRepFileSceneHandler::AddPrimitive(const G4Square& square) called:"
                                                   >> 1220     "\n  side: " << square.GetWorldRadius()
                                                   >> 1221   << G4endl;
                                                   >> 1222   PrintThings();
                                                   >> 1223 #endif
                                                   >> 1224   
                                                   >> 1225   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 1226   
                                                   >> 1227   if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 1228     return;
                                                   >> 1229   
                                                   >> 1230   if (inPrimitives2D) {
                                                   >> 1231     if (!warnedAbout2DMarkers) {
                                                   >> 1232       G4cout << "HepRepFile does not currently support 2D squares." << G4endl;
                                                   >> 1233       warnedAbout2DMarkers = true;
                                                   >> 1234     }
                                                   >> 1235     return;
                                                   >> 1236     }
                                                   >> 1237   
                                                   >> 1238   MarkerSizeType sizeType;
                                                   >> 1239   G4double size = GetMarkerSize (square, sizeType);
                                                   >> 1240   if (sizeType==world)
                                                   >> 1241     size = 4.;
                                                   >> 1242   
                                                   >> 1243   if (drawingTraj)
                                                   >> 1244     return;
                                                   >> 1245   
                                                   >> 1246   if (drawingHit)
                                                   >> 1247     InitHit();
                                                   >> 1248   
                                                   >> 1249   haveVisible = true;
                                                   >> 1250   AddHepRepInstance("Point", square);
                                                   >> 1251   
                                                   >> 1252   hepRepXMLWriter->addAttValue("MarkName", "Square");
                                                   >> 1253   hepRepXMLWriter->addAttValue("MarkSize", (G4int) size);
                                                   >> 1254   
                                                   >> 1255   hepRepXMLWriter->addPrimitive();
                                                   >> 1256   
                                                   >> 1257   G4Point3D center = (fObjectTransformation) * square.GetPosition();
                                                   >> 1258   hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
                                                   >> 1259 }
                                                   >> 1260 
                                                   >> 1261 
                                                   >> 1262 void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) {
                                                   >> 1263 #ifdef G4HEPREPFILEDEBUG
                                                   >> 1264   G4cout <<
                                                   >> 1265     "G4HepRepFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) called."
                                                   >> 1266   << G4endl;
                                                   >> 1267   PrintThings();
                                                   >> 1268 #endif
                                                   >> 1269   
                                                   >> 1270   G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
                                                   >> 1271   
                                                   >> 1272   if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
                                                   >> 1273     return;
                                                   >> 1274   
                                                   >> 1275   if(polyhedron.GetNoFacets()==0)return;
                                                   >> 1276   
                                                   >> 1277   if (drawingTraj)
                                                   >> 1278     return;
                                                   >> 1279   
                                                   >> 1280   if (drawingHit)
                                                   >> 1281     InitHit();
                                                   >> 1282   
                                                   >> 1283   haveVisible = true;
                                                   >> 1284   AddHepRepInstance("Polygon", polyhedron);
                                                   >> 1285   
                                                   >> 1286   G4Normal3D surfaceNormal;
                                                   >> 1287   G4Point3D vertex;
                                                   >> 1288   
                                                   >> 1289   G4bool notLastFace;
                                                   >> 1290   do {
                                                   >> 1291     hepRepXMLWriter->addPrimitive();
                                                   >> 1292     notLastFace = polyhedron.GetNextNormal (surfaceNormal);
                                                   >> 1293     
                                                   >> 1294     G4int edgeFlag = 1;
                                                   >> 1295     G4bool notLastEdge;
                                                   >> 1296     do {
                                                   >> 1297       notLastEdge = polyhedron.GetNextVertex (vertex, edgeFlag);
                                                   >> 1298       vertex = (fObjectTransformation) * vertex;
                                                   >> 1299       hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
                                                   >> 1300     } while (notLastEdge);
                                                   >> 1301   } while (notLastFace);
1340 }                                                1302 }
1341                                                  1303 
1342 void G4HepRepFileSceneHandler::AddPrimitive(c << 
1343 {                                             << 
1344 #ifdef G4HEPREPFILEDEBUG                      << 
1345   G4cout << "G4HepRepFileSceneHandler::AddPri << 
1346             "polyhedron) called."             << 
1347          << G4endl;                           << 
1348   PrintThings();                              << 
1349 #endif                                        << 
1350                                               << 
1351   G4HepRepMessenger* messenger = G4HepRepMess << 
1352                                               << 
1353   if(fpVisAttribs && (fpVisAttribs->IsVisible << 
1354      messenger->getCullInvisibles())          << 
1355     return;                                   << 
1356                                               << 
1357   if(polyhedron.GetNoFacets() == 0)           << 
1358     return;                                   << 
1359                                               << 
1360   if(drawingTraj)                             << 
1361     return;                                   << 
1362                                               << 
1363   if(drawingHit)                              << 
1364     InitHit();                                << 
1365                                                  1304 
1366   haveVisible = true;                         << 1305 G4HepRepFileXMLWriter *G4HepRepFileSceneHandler::GetHepRepXMLWriter() {
1367   AddHepRepInstance("Polygon", polyhedron);   << 1306     return hepRepXMLWriter;
1368                                               << 
1369   G4Normal3D surfaceNormal;                   << 
1370   G4Point3D vertex;                           << 
1371                                               << 
1372   G4bool notLastFace;                         << 
1373   do                                          << 
1374   {                                           << 
1375     hepRepXMLWriter->addPrimitive();          << 
1376     notLastFace = polyhedron.GetNextNormal(su << 
1377                                               << 
1378     G4int edgeFlag = 1;                       << 
1379     G4bool notLastEdge;                       << 
1380     do                                        << 
1381     {                                         << 
1382       notLastEdge = polyhedron.GetNextVertex( << 
1383       vertex      = (fObjectTransformation) * << 
1384       hepRepXMLWriter->addPoint(vertex.x(), v << 
1385     } while(notLastEdge);                     << 
1386   } while(notLastFace);                       << 
1387 }                                                1307 }
1388                                                  1308 
1389 G4HepRepFileXMLWriter* G4HepRepFileSceneHandl << 
1390 {                                             << 
1391   return hepRepXMLWriter;                     << 
1392 }                                             << 
1393                                                  1309 
1394 void G4HepRepFileSceneHandler::AddHepRepInsta    1310 void G4HepRepFileSceneHandler::AddHepRepInstance(const char* primName,
1395                                               << 1311                                                  const G4Visible visible) {
1396 {                                             << 
1397 #ifdef G4HEPREPFILEDEBUG                         1312 #ifdef G4HEPREPFILEDEBUG
1398   G4cout << "G4HepRepFileSceneHandler::AddHep << 1313   G4cout <<
1399 #endif                                        << 1314     "G4HepRepFileSceneHandler::AddHepRepInstance called."
1400                                               << 1315   << G4endl;
1401   // Open the HepRep output file if it is not << 1316 #endif
1402   CheckFileOpen();                            << 1317   
1403                                               << 1318   // Open the HepRep output file if it is not already open.
1404   G4VPhysicalVolume* pCurrentPV = 0;          << 1319   CheckFileOpen();
1405   G4LogicalVolume* pCurrentLV   = 0;          << 1320   
1406   G4int currentDepth            = 0;          << 1321   G4VPhysicalVolume* pCurrentPV = 0;
1407   G4PhysicalVolumeModel* pPVModel =           << 1322   G4LogicalVolume* pCurrentLV = 0;
1408     dynamic_cast<G4PhysicalVolumeModel*>(fpMo << 1323   G4int currentDepth = 0;
1409   if(pPVModel)                                << 1324   G4PhysicalVolumeModel* pPVModel = dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
1410   {                                           << 1325   if (pPVModel) {
1411     pCurrentPV   = pPVModel->GetCurrentPV();  << 1326     pCurrentPV = pPVModel->GetCurrentPV();
1412     pCurrentLV   = pPVModel->GetCurrentLV();  << 1327     pCurrentLV = pPVModel->GetCurrentLV();
1413     currentDepth = pPVModel->GetCurrentDepth( << 1328     currentDepth = pPVModel->GetCurrentDepth();
1414   }                                           << 1329   }
1415                                               << 1330   
1416 #ifdef G4HEPREPFILEDEBUG                      << 1331 #ifdef G4HEPREPFILEDEBUG
1417   G4cout << "pCurrentPV:" << pCurrentPV       << 1332   G4cout <<
1418          << ", readyForTransients:" << fReady << 1333     "pCurrentPV:" << pCurrentPV << ", readyForTransients:" << fReadyForTransients
1419 #endif                                        << 1334     << G4endl;
1420                                               << 1335 #endif
1421   if(drawingTraj || drawingHit)               << 1336   
1422   {                                           << 1337   if (drawingTraj || drawingHit) {
1423     // In this case, HepRep type, layer and i << 1338     // In this case, HepRep type, layer and instance were already created
1424     // in the AddCompound method.             << 1339     // in the AddCompound method.
1425   }                                           << 1340   }
1426   else if(fReadyForTransients)                << 1341   else if (fReadyForTransients) {
1427   {                                           << 1342     if (strcmp("Event Data",hepRepXMLWriter->prevTypeName[0])!=0) {
1428     if(strcmp("Event Data", hepRepXMLWriter-> << 1343       hepRepXMLWriter->addType("Event Data",0);
1429     {                                         << 1344       hepRepXMLWriter->addInstance();
1430       hepRepXMLWriter->addType("Event Data",  << 1345     }
1431       hepRepXMLWriter->addInstance();         << 1346     
1432     }                                         << 1347     // Applications have the option of either calling AddSolid(G4VTrajectory&) and
1433                                               << 1348     // AddSolid(G4VHits&), or of just decomposing these into simpler primitives.
1434     // Applications have the option of either << 1349     // In the former case, drawing will be handled above and will include setting of
1435     // and AddSolid(G4VHits&), or of just dec << 1350     // physics attributes.
1436     // primitives. In the former case, drawin << 1351     // In the latter case, which is an older style of working, we end up drawing the
1437     // include setting of physics attributes. << 1352     // trajectories and hits here, where we have no access to physics attributes. 
1438     // older style of working, we end up draw << 1353     // We receive primitives here.  We can figure out that these are transients, but we
1439     // where we have no access to physics att << 1354     // have to guess exactly what these transients represent.
1440     // here.  We can figure out that these ar << 1355     // We assume the primitives are being used as in G4VTrajectory, hence we assume:
1441     // exactly what these transients represen << 1356     // Lines are Trajectories
1442     // being used as in G4VTrajectory, hence  << 1357     // Squares that come after we've seen trajectories are Auxiliary Points
1443     // Squares that come after we've seen tra << 1358     // Circles that come after we've seen trajectories are Step Points
1444     // Circles that come after we've seen tra << 1359     // Other primitives are Hits
1445     // Other primitives are Hits              << 1360     
1446                                               << 1361     int layer;
1447     int layer;                                << 1362     
1448                                               << 1363     if (strcmp("Text",primName)==0) {
1449     if(strcmp("Text", primName) == 0)         << 1364       hepRepXMLWriter->addType("EventID",1);
1450     {                                         << 1365     } else {
1451       hepRepXMLWriter->addType("EventID", 1); << 1366       if (strcmp("Line",primName)==0) {
1452     }                                         << 1367         hepRepXMLWriter->addType("TransientPolylines",1);
1453     else                                      << 1368         layer = 100;
1454     {                                         << 1369       } else {
1455       if(strcmp("Line", primName) == 0)       << 1370         if (strcmp(hepRepXMLWriter->prevTypeName[1],"TransientPolylines")==0 &&
1456       {                                       << 1371           strcmp("Square",primName)==0)
1457         hepRepXMLWriter->addType("TransientPo << 1372         {
1458         layer = 100;                          << 1373           hepRepXMLWriter->addType("AuxiliaryPoints",2);
1459       }                                       << 1374           layer = 110;
1460       else                                    << 1375         } else {
1461       {                                       << 1376           if (strcmp(hepRepXMLWriter->prevTypeName[1],"TransientPolylines")==0 &&
1462         if(strcmp(hepRepXMLWriter->prevTypeNa << 1377             strcmp("Circle",primName)==0)
1463              0 &&                             << 1378           {
1464            strcmp("Square", primName) == 0)   << 1379             hepRepXMLWriter->addType("StepPoints",2);
1465         {                                     << 1380             layer = 120;
1466           hepRepXMLWriter->addType("Auxiliary << 1381           } else {
1467           layer = 110;                        << 1382             hepRepXMLWriter->addType("Hits",1);
1468         }                                     << 1383             layer = 130;
1469         else                                  << 1384           }
1470         {                                     << 1385         }
1471           if(strcmp(hepRepXMLWriter->prevType << 1386       }
1472                0 &&                           << 1387       hepRepXMLWriter->addAttValue("Layer",layer);
1473              strcmp("Circle", primName) == 0) << 1388     }
1474           {                                   << 1389     
1475             hepRepXMLWriter->addType("StepPoi << 1390     hepRepXMLWriter->addInstance();
1476             layer = 120;                      << 1391     
1477           }                                   << 1392     // Handle Type declaration for Axes, Ruler, etc.
1478           else                                << 1393   } else if (pCurrentPV==0) {
1479           {                                   << 1394     if (strcmp("AxesEtc",hepRepXMLWriter->prevTypeName[0])!=0) {
1480             hepRepXMLWriter->addType("Hits",  << 1395       hepRepXMLWriter->addType("AxesEtc",0);
1481             layer = 130;                      << 1396       hepRepXMLWriter->addInstance();
1482           }                                   << 1397     }
1483         }                                     << 1398     
1484       }                                       << 1399     int layer;
1485       hepRepXMLWriter->addAttValue("Layer", l << 1400     
1486     }                                         << 1401     if (strcmp("Text",primName)==0) {
1487                                               << 1402       hepRepXMLWriter->addType("Text",1);
1488     hepRepXMLWriter->addInstance();           << 1403     } else {
1489                                               << 1404       if (strcmp("Line",primName)==0) {
1490     // Handle Type declaration for Axes, Rule << 1405         hepRepXMLWriter->addType("Polylines",1);
1491   }                                           << 1406         layer = 100;
1492   else if(pCurrentPV == 0)                    << 1407       } else {
1493   {                                           << 1408         hepRepXMLWriter->addType("Points",1);
1494     if(strcmp("AxesEtc", hepRepXMLWriter->pre << 1409         layer = 130;
1495     {                                         << 1410       }
1496       hepRepXMLWriter->addType("AxesEtc", 0); << 1411       hepRepXMLWriter->addAttValue("Layer",layer);
1497       hepRepXMLWriter->addInstance();         << 1412     }
1498     }                                         << 1413     
1499                                               << 1414     hepRepXMLWriter->addInstance();
1500     int layer;                                << 1415     
1501                                               << 1416     // Handle Type declaration for Detector Geometry,
1502     if(strcmp("Text", primName) == 0)         << 1417     // replacing G4's top geometry level name "worldPhysical" with the
1503     {                                         << 1418     // name "Detector Geometry".
1504       hepRepXMLWriter->addType("Text", 1);    << 1419   } else {
1505     }                                         << 1420     //G4cout << "CurrentDepth" << currentDepth << G4endl;
1506     else                                      << 1421     //G4cout << "currentName" << pCurrentPV->GetName() << G4endl;
1507     {                                         << 1422     if (strcmp("Detector Geometry",hepRepXMLWriter->prevTypeName[0])!=0) {
1508       if(strcmp("Line", primName) == 0)       << 1423       //G4cout << "Adding Det Geom type" << G4endl;
1509       {                                       << 1424       hepRepXMLWriter->addType("Detector Geometry",0);
1510         hepRepXMLWriter->addType("Polylines", << 1425       hepRepXMLWriter->addInstance();
1511         layer = 100;                          << 1426     }
1512       }                                       << 1427     
1513       else                                    << 1428     // Re-insert any layers of the hierarchy that were removed by G4's culling process.
1514       {                                       << 1429     // Don't bother checking if same type name as last instance.
1515         hepRepXMLWriter->addType("Points", 1) << 1430     if(strcmp(hepRepXMLWriter->prevTypeName[currentDepth+1],pCurrentPV->GetName())!=0) {
1516         layer = 130;                          << 1431       //G4cout << "Looking for mother of:" << pCurrentLV->GetName() << G4endl;
1517       }                                       << 1432       typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
1518       hepRepXMLWriter->addAttValue("Layer", l << 1433       typedef std::vector<PVNodeID> PVPath;
1519     }                                         << 1434       const PVPath& drawnPVPath = pPVModel->GetDrawnPVPath();
1520                                               << 1435       PVPath::const_reverse_iterator ri = ++drawnPVPath.rbegin();
1521     hepRepXMLWriter->addInstance();           << 1436       G4int drawnMotherDepth;
1522                                               << 1437       if (ri != drawnPVPath.rend()) {
1523     // Handle Type declaration for Detector G << 1438         // This volume has a mother.
1524     // replacing G4's top geometry level name << 1439         drawnMotherDepth = ri->GetNonCulledDepth();
1525     // name "Detector Geometry".              << 1440         //G4cout << "drawnMotherDepth" << drawnMotherDepth << G4endl;
1526   }                                           << 1441       } else {
1527   else                                        << 1442         // This volume has no mother.  Must be a top level volume.
1528   {                                           << 1443         drawnMotherDepth = -1;
1529     // G4cout << "CurrentDepth" << currentDep << 1444         //G4cout << "Mother must be very top" << G4endl;
1530     // G4cout << "currentName" << pCurrentPV- << 1445       }
1531     if(strcmp("Detector Geometry", hepRepXMLW << 1446       
1532     {                                         << 1447       while (drawnMotherDepth < (currentDepth-1)) {
1533       // G4cout << "Adding Det Geom type" <<  << 1448         G4String culledParentName = "Culled parent of " + pCurrentPV->GetName();
1534       hepRepXMLWriter->addType("Detector Geom << 1449         //G4cout << "Inserting culled layer " << culledParentName << " at depth:" << drawnMotherDepth+2 << G4endl;
1535       hepRepXMLWriter->addInstance();         << 1450         hepRepXMLWriter->addType(culledParentName, drawnMotherDepth+2);
1536     }                                         << 1451         hepRepXMLWriter->addInstance();
1537                                               << 1452         drawnMotherDepth ++;
1538     // Re-insert any layers of the hierarchy  << 1453       }
1539     // process. Don't bother checking if same << 1454     }
1540     if(strcmp(hepRepXMLWriter->prevTypeName[c << 1455     
1541               pCurrentPV->GetName()) != 0)    << 1456     // Add the HepRepType for the current volume.
1542     {                                         << 1457     hepRepXMLWriter->addType(pCurrentPV->GetName(),currentDepth+1);
1543       // G4cout << "Looking for mother of:" < << 1458     hepRepXMLWriter->addInstance();
1544       typedef G4PhysicalVolumeModel::G4Physic << 1459     
1545       typedef std::vector<PVNodeID> PVPath;   << 1460     G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
1546       const PVPath& drawnPVPath         = pPV << 1461     
1547       PVPath::const_reverse_iterator ri = ++d << 1462     if (fpVisAttribs && (fpVisAttribs->IsVisible()==0) && messenger->getCullInvisibles())
1548       G4int drawnMotherDepth;                 << 1463       return;
1549       if(ri != drawnPVPath.rend())            << 1464     
1550       {                                       << 1465     // Additional attributes.
1551         // This volume has a mother.          << 1466     hepRepXMLWriter->addAttValue("Layer",hepRepXMLWriter->typeDepth);
1552         drawnMotherDepth = ri->GetNonCulledDe << 1467     hepRepXMLWriter->addAttValue("LVol", pCurrentLV->GetName());
1553         // G4cout << "drawnMotherDepth" << dr << 1468     G4Region* region = pCurrentLV->GetRegion();
1554       }                                       << 1469     G4String regionName = region? region->GetName(): G4String("No region");
1555       else                                    << 1470     hepRepXMLWriter->addAttValue("Region", regionName);
1556       {                                       << 1471     hepRepXMLWriter->addAttValue("RootRegion", pCurrentLV->IsRootRegion());
1557         // This volume has no mother.  Must b << 1472     hepRepXMLWriter->addAttValue("Solid", pCurrentLV->GetSolid()->GetName());
1558         drawnMotherDepth = -1;                << 1473     hepRepXMLWriter->addAttValue("EType", pCurrentLV->GetSolid()->GetEntityType());
1559         // G4cout << "Mother must be very top << 1474     G4Material * material = pPVModel->GetCurrentMaterial();
1560       }                                       << 1475     G4String matName = material? material->GetName(): G4String("No material");
1561                                               << 1476     hepRepXMLWriter->addAttValue("Material", matName);
1562       while(drawnMotherDepth < (currentDepth  << 1477     G4double matDensity = material? material->GetDensity(): 0.;
1563       {                                       << 1478     hepRepXMLWriter->addAttValue("Density", matDensity*m3/kg);
1564         G4String culledParentName = "Culled p << 1479     G4State matState = material? material->GetState(): kStateUndefined;
1565         // G4cout << "Inserting culled layer  << 1480     hepRepXMLWriter->addAttValue("State", matState);
1566         // depth:" << drawnMotherDepth+2 << G << 1481     G4double matRadlen = material? material->GetRadlen(): 0.;
1567         hepRepXMLWriter->addType(culledParent << 1482     hepRepXMLWriter->addAttValue("Radlen", matRadlen/m);
1568         hepRepXMLWriter->addInstance();       << 1483   }
1569         drawnMotherDepth++;                   << 1484   
1570       }                                       << 1485   hepRepXMLWriter->addAttValue("DrawAs",primName);
1571     }                                         << 1486   
1572                                               << 1487   // Handle color and visibility attributes.
1573     // Add the HepRepType for the current vol << 1488   float redness;
1574     hepRepXMLWriter->addType(pCurrentPV->GetN << 1489   float greenness;
1575     hepRepXMLWriter->addInstance();           << 1490   float blueness;
1576                                               << 1491   G4bool isVisible; 
1577     G4HepRepMessenger* messenger = G4HepRepMe << 1492   
1578                                               << 1493   if (fpVisAttribs || haveVisible) {
1579     if(fpVisAttribs && (fpVisAttribs->IsVisib << 1494     G4Colour colour;
1580        messenger->getCullInvisibles())        << 1495     
1581       return;                                 << 1496     if (fpVisAttribs) {
1582                                               << 1497       colour = fpVisAttribs->GetColour();
1583     // Additional attributes.                 << 1498       isVisible = fpVisAttribs->IsVisible();
1584     hepRepXMLWriter->addAttValue("Layer", hep << 1499     } else {
1585     hepRepXMLWriter->addAttValue("LVol", pCur << 1500       colour = visible.GetVisAttributes()->GetColour();
1586     G4Region* region    = pCurrentLV->GetRegi << 1501       isVisible = fpViewer->
1587     G4String regionName = region ? region->Ge << 1502       GetApplicableVisAttributes(visible.GetVisAttributes())->IsVisible();
1588     hepRepXMLWriter->addAttValue("Region", re << 1503     }
1589     hepRepXMLWriter->addAttValue("RootRegion" << 1504 
1590     hepRepXMLWriter->addAttValue("Solid", pCu << 1505     redness = colour.GetRed();
1591     hepRepXMLWriter->addAttValue("EType",     << 1506     greenness = colour.GetGreen();
1592                                  pCurrentLV-> << 1507     blueness = colour.GetBlue();
1593     G4Material* material = pPVModel->GetCurre << 1508     
1594     G4String matName = material ? material->G << 1509     // Avoiding drawing anything black on black.  
1595     hepRepXMLWriter->addAttValue("Material",  << 1510     if (redness==0. && greenness==0. && blueness==0.) {
1596     G4double matDensity = material ? material << 1511       redness = 1.;
1597     hepRepXMLWriter->addAttValue("Density", m << 1512       greenness = 1.;
1598     G4State matState = material ? material->G << 1513       blueness = 1.;
1599     hepRepXMLWriter->addAttValue("State", mat << 1514     }
1600     G4double matRadlen = material ? material- << 1515   } else {
1601     hepRepXMLWriter->addAttValue("Radlen", ma << 1516 #ifdef G4HEPREPFILEDEBUG
1602   }                                           << 1517     G4cout <<
1603                                               << 1518     "G4HepRepFileSceneHandler::AddHepRepInstance using default colour."
1604   hepRepXMLWriter->addAttValue("DrawAs", prim << 1519     << G4endl;
1605                                               << 1520 #endif
1606   // Handle color and visibility attributes.  << 1521     redness = 1.;
1607   float redness;                              << 1522     greenness = 1.;
1608   float greenness;                            << 1523     blueness = 1.;
1609   float blueness;                             << 1524     isVisible = true;
1610   G4bool isVisible;                           << 1525   }
1611                                               << 1526   
1612   if(fpVisAttribs || haveVisible)             << 1527   if (strcmp(primName,"Point")==0)
1613   {                                           << 1528     hepRepXMLWriter->addAttValue("MarkColor",redness,greenness,blueness);
1614     G4Colour colour;                          << 1529   else
1615                                               << 1530     hepRepXMLWriter->addAttValue("LineColor",redness,greenness,blueness);
1616     if(fpVisAttribs)                          << 1531   
1617     {                                         << 1532   hepRepXMLWriter->addAttValue("Visibility",isVisible);
1618       colour    = fpVisAttribs->GetColour();  << 1533 }
1619       isVisible = fpVisAttribs->IsVisible();  << 1534 
1620     }                                         << 1535 
1621     else                                      << 1536 void G4HepRepFileSceneHandler::CheckFileOpen() {
1622     {                                         << 1537 #ifdef G4HEPREPFILEDEBUG
1623       colour = visible.GetVisAttributes()->Ge << 1538   G4cout <<
1624       isVisible =                             << 1539     "G4HepRepFileSceneHandler::CheckFileOpen called."
1625         fpViewer->GetApplicableVisAttributes( << 1540   << G4endl;
1626           ->IsVisible();                      << 1541 #endif
1627     }                                         << 1542   
1628                                               << 1543   if (!hepRepXMLWriter->isOpen) {
1629     redness   = colour.GetRed();              << 1544     G4String newFileSpec;
1630     greenness = colour.GetGreen();            << 1545 
1631     blueness  = colour.GetBlue();             << 1546     G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
1632                                               << 1547     
1633     // Avoiding drawing anything black on bla << 1548     if (messenger->getOverwrite()) {
1634     if(redness == 0. && greenness == 0. && bl << 1549       newFileSpec = messenger->getFileDir()+messenger->getFileName()+".heprep";
1635     {                                         << 1550     } else {
1636       redness   = 1.;                         << 1551       newFileSpec = messenger->getFileDir()+messenger->getFileName()+G4UIcommand::ConvertToString(fileCounter)+".heprep";
1637       greenness = 1.;                         << 1552     }
1638       blueness  = 1.;                         << 1553     
1639     }                                         << 1554     G4cout << "HepRepFile writing to " << newFileSpec << G4endl;
1640   }                                           << 1555     
1641   else                                        << 1556     hepRepXMLWriter->open(newFileSpec);
1642   {                                           << 1557     
1643 #ifdef G4HEPREPFILEDEBUG                      << 1558     if (!messenger->getOverwrite())
1644     G4cout                                    << 1559       fileCounter++;
1645       << "G4HepRepFileSceneHandler::AddHepRep << 1560     
1646       << G4endl;                              << 1561     hepRepXMLWriter->addAttDef("Generator", "HepRep Data Generator", "Physics","");
1647 #endif                                        << 1562     G4String versionString = G4Version;
1648     redness   = 1.;                           << 1563     versionString = versionString.substr(1,versionString.size()-2);
1649     greenness = 1.;                           << 1564     versionString = " Geant4 version " + versionString + "   " + G4Date;
1650     blueness  = 1.;                           << 1565     hepRepXMLWriter->addAttValue("Generator", versionString);
1651     isVisible = true;                         << 1566     
1652   }                                           << 1567     hepRepXMLWriter->addAttDef("LVol", "Logical Volume", "Physics","");
1653                                               << 1568     hepRepXMLWriter->addAttDef("Region", "Cuts Region", "Physics","");
1654   if(strcmp(primName, "Point") == 0)          << 1569     hepRepXMLWriter->addAttDef("RootRegion", "Root Region", "Physics","");
1655     hepRepXMLWriter->addAttValue("MarkColor", << 1570     hepRepXMLWriter->addAttDef("Solid", "Solid Name", "Physics","");
1656   else                                        << 1571     hepRepXMLWriter->addAttDef("EType", "Entity Type", "Physics","");
1657     hepRepXMLWriter->addAttValue("LineColor", << 1572     hepRepXMLWriter->addAttDef("Material", "Material Name", "Physics","");
1658                                               << 1573     hepRepXMLWriter->addAttDef("Density", "Material Density", "Physics","kg/m3");
1659   hepRepXMLWriter->addAttValue("Visibility",  << 1574     hepRepXMLWriter->addAttDef("State", "Material State", "Physics","");
1660 }                                             << 1575     hepRepXMLWriter->addAttDef("Radlen", "Material Radiation Length", "Physics","m");
1661                                               << 1576   }
1662 void G4HepRepFileSceneHandler::CheckFileOpen( << 1577 }
1663 {                                             << 1578 
1664 #ifdef G4HEPREPFILEDEBUG                      << 1579 
1665   G4cout << "G4HepRepFileSceneHandler::CheckF << 1580 void G4HepRepFileSceneHandler::ClearTransientStore() {
1666 #endif                                        << 1581   // This is typically called after an update and before drawing hits
1667                                               << 1582   // of the next event.  To simulate the clearing of "transients"
1668   if(!hepRepXMLWriter->isOpen)                << 1583   // (hits, etc.) the detector is redrawn...
1669   {                                           << 1584   if (fpViewer) {
1670     G4String newFileSpec;                     << 1585     fpViewer -> SetView();
1671                                               << 1586     fpViewer -> ClearView();
1672     G4HepRepMessenger* messenger = G4HepRepMe << 1587     fpViewer -> DrawView();
1673                                               << 1588   }
1674     if(messenger->getOverwrite())             << 
1675     {                                         << 
1676       newFileSpec =                           << 
1677         messenger->getFileDir() + messenger-> << 
1678     }                                         << 
1679     else                                      << 
1680     {                                         << 
1681       newFileSpec = messenger->getFileDir() + << 
1682                     G4UIcommand::ConvertToStr << 
1683     }                                         << 
1684                                               << 
1685     G4cout << "HepRepFile writing to " << new << 
1686                                               << 
1687     hepRepXMLWriter->open(newFileSpec);       << 
1688                                               << 
1689     if(!messenger->getOverwrite())            << 
1690       fileCounter++;                          << 
1691                                               << 
1692     hepRepXMLWriter->addAttDef("Generator", " << 
1693                                "");           << 
1694     G4String versionString = G4Version;       << 
1695     versionString          = versionString.su << 
1696     versionString = " Geant4 version " + vers << 
1697     hepRepXMLWriter->addAttValue("Generator", << 
1698                                               << 
1699     hepRepXMLWriter->addAttDef("LVol", "Logic << 
1700     hepRepXMLWriter->addAttDef("Region", "Cut << 
1701     hepRepXMLWriter->addAttDef("RootRegion",  << 
1702     hepRepXMLWriter->addAttDef("Solid", "Soli << 
1703     hepRepXMLWriter->addAttDef("EType", "Enti << 
1704     hepRepXMLWriter->addAttDef("Material", "M << 
1705     hepRepXMLWriter->addAttDef("Density", "Ma << 
1706                                "kg/m3");      << 
1707     hepRepXMLWriter->addAttDef("State", "Mate << 
1708     hepRepXMLWriter->addAttDef("Radlen", "Mat << 
1709                                "m");          << 
1710   }                                           << 
1711 }                                             << 
1712                                               << 
1713 void G4HepRepFileSceneHandler::ClearTransient << 
1714 {                                             << 
1715   // This is typically called after an update << 
1716   // of the next event.  To simulate the clea << 
1717   // (hits, etc.) the detector is redrawn...  << 
1718   if(fpViewer)                                << 
1719   {                                           << 
1720     fpViewer->SetView();                      << 
1721     fpViewer->ClearView();                    << 
1722     fpViewer->DrawView();                     << 
1723   }                                           << 
1724 }                                                1589 }
1725                                                  1590