Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/modeling/src/G4PhysicalVolumeModel.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/modeling/src/G4PhysicalVolumeModel.cc (Version 11.3.0) and /visualization/modeling/src/G4PhysicalVolumeModel.cc (Version 10.0.p4)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4PhysicalVolumeModel.cc 70646 2013-06-03 15:07:58Z gcosmo $
 27 //                                                 28 //
 28 //                                                 29 // 
 29 // John Allison  31st December 1997.               30 // John Allison  31st December 1997.
 30 // Model for physical volumes.                     31 // Model for physical volumes.
 31                                                    32 
 32 #include "G4PhysicalVolumeModel.hh"                33 #include "G4PhysicalVolumeModel.hh"
 33                                                    34 
                                                   >>  35 #include "G4ModelingParameters.hh"
 34 #include "G4VGraphicsScene.hh"                     36 #include "G4VGraphicsScene.hh"
 35 #include "G4VPhysicalVolume.hh"                    37 #include "G4VPhysicalVolume.hh"
 36 #include "G4PhysicalVolumeStore.hh"            << 
 37 #include "G4VPVParameterisation.hh"                38 #include "G4VPVParameterisation.hh"
 38 #include "G4LogicalVolume.hh"                      39 #include "G4LogicalVolume.hh"
 39 #include "G4VSolid.hh"                             40 #include "G4VSolid.hh"
 40 #include "G4SubtractionSolid.hh"                   41 #include "G4SubtractionSolid.hh"
 41 #include "G4IntersectionSolid.hh"                  42 #include "G4IntersectionSolid.hh"
 42 #include "G4Material.hh"                           43 #include "G4Material.hh"
 43 #include "G4VisAttributes.hh"                      44 #include "G4VisAttributes.hh"
 44 #include "G4BoundingExtentScene.hh"            <<  45 #include "G4BoundingSphereScene.hh"
                                                   >>  46 #include "G4PhysicalVolumeSearchScene.hh"
 45 #include "G4TransportationManager.hh"              47 #include "G4TransportationManager.hh"
 46 #include "G4Polyhedron.hh"                         48 #include "G4Polyhedron.hh"
 47 #include "HepPolyhedronProcessor.h"                49 #include "HepPolyhedronProcessor.h"
 48 #include "G4AttDefStore.hh"                        50 #include "G4AttDefStore.hh"
 49 #include "G4AttDef.hh"                             51 #include "G4AttDef.hh"
 50 #include "G4AttValue.hh"                           52 #include "G4AttValue.hh"
 51 #include "G4UnitsTable.hh"                         53 #include "G4UnitsTable.hh"
 52 #include "G4Vector3D.hh"                           54 #include "G4Vector3D.hh"
 53 #include "G4Mesh.hh"                           << 
 54                                                    55 
 55 #include <sstream>                                 56 #include <sstream>
 56 #include <iomanip>                             << 
 57                                                << 
 58 #define G4warn G4cout                          << 
 59                                                    57 
 60 G4PhysicalVolumeModel::G4PhysicalVolumeModel       58 G4PhysicalVolumeModel::G4PhysicalVolumeModel
 61 (G4VPhysicalVolume*            pVPV            <<  59 (G4VPhysicalVolume*          pVPV,
 62  , G4int                       requestedDepth  <<  60  G4int                       requestedDepth,
 63  , const G4Transform3D&        modelTransform  <<  61  const G4Transform3D& modelTransformation,
 64  , const G4ModelingParameters* pMP             <<  62  const G4ModelingParameters* pMP,
 65  , G4bool                      useFullExtent   <<  63  G4bool useFullExtent):
 66  , const std::vector<G4PhysicalVolumeNodeID>&  <<  64   G4VModel        (modelTransformation, pMP),
 67 : G4VModel           (pMP)                     <<  65   fpTopPV         (pVPV),
 68 , fpTopPV            (pVPV)                    <<  66   fTopPVCopyNo    (0),
 69 , fTopPVCopyNo       (pVPV? pVPV->GetCopyNo(): <<  67   fRequestedDepth (requestedDepth),
 70 , fRequestedDepth    (requestedDepth)          <<  68   fUseFullExtent  (useFullExtent),
 71 , fUseFullExtent     (useFullExtent)           <<  69   fCurrentDepth   (0),
 72 , fTransform         (modelTransform)          <<  70   fpCurrentPV     (0),
 73 , fCurrentDepth      (0)                       <<  71   fpCurrentLV     (0),
 74 , fpCurrentPV        (fpTopPV)                 <<  72   fpCurrentMaterial (0),
 75 , fCurrentPVCopyNo   (fpTopPV? fpTopPV->GetCop <<  73   fpCurrentTransform (0),
 76 , fpCurrentLV        (fpTopPV? fpTopPV->GetLog <<  74   fCurtailDescent (false),
 77 , fpCurrentMaterial  (fpCurrentLV? fpCurrentLV <<  75   fpClippingSolid (0),
 78 , fCurrentTransform  (modelTransform)          <<  76   fClippingMode   (subtraction)
 79 , fBaseFullPVPath    (baseFullPVPath)          <<  77 {
 80 , fFullPVPath        (fBaseFullPVPath)         <<  78   if (fpTopPV) {
 81 , fAbort             (false)                   <<  79     
 82 , fCurtailDescent    (false)                   <<  80     fType = "G4PhysicalVolumeModel";
 83 , fpClippingSolid    (0)                       << 
 84 , fClippingMode      (subtraction)             << 
 85 , fNClippers         (0)                       << 
 86 , fTotalTouchables   (0)                       << 
 87 {                                              << 
 88   fType = "G4PhysicalVolumeModel";             << 
 89                                                << 
 90   if (!fpTopPV) {                              << 
 91                                                << 
 92     // In some circumstances creating an "empt << 
 93     // allowed, so I have supressed the G4Exce << 
 94     // be a problem we might have to re-instat << 
 95     // be used except by visualisation experts << 
 96     // where it is used simply to get a list o << 
 97     //    G4Exception                          << 
 98     //    ("G4PhysicalVolumeModel::G4PhysicalV << 
 99     //     "modeling0010", FatalException, "Nu << 
100                                                << 
101     fTopPVName = "NULL";                       << 
102     fGlobalTag = "Empty";                      << 
103     fGlobalDescription = "G4PhysicalVolumeMode << 
104                                                << 
105   } else {                                     << 
106                                                << 
107     fTopPVName = fpTopPV -> GetName ();            81     fTopPVName = fpTopPV -> GetName ();
108     std::ostringstream oss;                    <<  82     fTopPVCopyNo = fpTopPV -> GetCopyNo ();
109     oss << fpTopPV->GetName() << ':' << fpTopP <<  83     std::ostringstream o;
110     << " BasePath:" << fBaseFullPVPath;        <<  84     o << fpTopPV -> GetCopyNo ();
111     fGlobalTag = oss.str();                    <<  85     fGlobalTag = fpTopPV -> GetName () + "." + o.str();
112     fGlobalDescription = "G4PhysicalVolumeMode     86     fGlobalDescription = "G4PhysicalVolumeModel " + fGlobalTag;
                                                   >>  87 
113     CalculateExtent ();                            88     CalculateExtent ();
114   }                                                89   }
115 }                                                  90 }
116                                                    91 
117 G4PhysicalVolumeModel::~G4PhysicalVolumeModel      92 G4PhysicalVolumeModel::~G4PhysicalVolumeModel ()
118 {                                                  93 {
119   delete fpClippingSolid;                          94   delete fpClippingSolid;
120 }                                                  95 }
121                                                    96 
122 G4ModelingParameters::PVNameCopyNoPath G4Physi << 
123 (const std::vector<G4PhysicalVolumeNodeID>& pa << 
124 {                                              << 
125   G4ModelingParameters::PVNameCopyNoPath PVNam << 
126   for (const auto& node: path) {               << 
127     PVNameCopyNoPath.push_back                 << 
128     (G4ModelingParameters::PVNameCopyNo        << 
129      (node.GetPhysicalVolume()->GetName(),node << 
130   }                                            << 
131   return PVNameCopyNoPath;                     << 
132 }                                              << 
133                                                << 
134 G4String G4PhysicalVolumeModel::GetPVNamePathS << 
135 (const std::vector<G4PhysicalVolumeNodeID>& pa << 
136 // Converts to path string, e.g., " World 0 En << 
137 // Note leading space character.               << 
138 {                                              << 
139   std::ostringstream oss;                      << 
140   oss << path;                                 << 
141   return oss.str();                            << 
142 }                                              << 
143                                                << 
144 void G4PhysicalVolumeModel::CalculateExtent ()     97 void G4PhysicalVolumeModel::CalculateExtent ()
145 {                                                  98 {
146   // To handle paramaterisations, set copy num << 
147   // to get extent right                       << 
148   G4VPVParameterisation* pP = fpTopPV -> GetPa << 
149   if (pP) {                                    << 
150     fpTopPV -> SetCopyNo (fTopPVCopyNo);       << 
151     G4VSolid* solid = pP -> ComputeSolid (fTop << 
152     solid -> ComputeDimensions (pP, fTopPVCopy << 
153   }                                            << 
154   if (fUseFullExtent) {                            99   if (fUseFullExtent) {
155     fExtent = fpTopPV -> GetLogicalVolume () -    100     fExtent = fpTopPV -> GetLogicalVolume () -> GetSolid () -> GetExtent ();
156   } else {                                     << 101   }
157     // Calculate extent of *drawn* volumes, i. << 102   else {
158     // invisible volumes, by traversing the wh << 103     G4BoundingSphereScene bsScene(this);
159     // this physical volume.                   << 
160     G4BoundingExtentScene beScene(this);       << 
161     const G4int tempRequestedDepth = fRequeste    104     const G4int tempRequestedDepth = fRequestedDepth;
162     const G4Transform3D tempTransform = fTrans << 
163     const G4ModelingParameters* tempMP = fpMP; << 
164     fRequestedDepth = -1;  // Always search to    105     fRequestedDepth = -1;  // Always search to all depths to define extent.
165     fTransform = G4Transform3D();  // Extent i << 106     const G4ModelingParameters* tempMP = fpMP;
166     G4ModelingParameters mParams                  107     G4ModelingParameters mParams
167       (0,      // No default vis attributes ne    108       (0,      // No default vis attributes needed.
168        G4ModelingParameters::wf,  // wireframe    109        G4ModelingParameters::wf,  // wireframe (not relevant for this).
169        true,   // Global culling.                 110        true,   // Global culling.
170        true,   // Cull invisible volumes.         111        true,   // Cull invisible volumes.
171        false,  // Density culling.                112        false,  // Density culling.
172        0.,     // Density (not relevant if den    113        0.,     // Density (not relevant if density culling false).
173        true,   // Cull daughters of opaque mot    114        true,   // Cull daughters of opaque mothers.
174        24);    // No of sides (not relevant fo    115        24);    // No of sides (not relevant for this operation).
175     mParams.SetSpecialMeshRendering(true);  // << 
176     fpMP = &mParams;                              116     fpMP = &mParams;
177     DescribeYourselfTo (beScene);              << 117     DescribeYourselfTo (bsScene);
178     fExtent = beScene.GetBoundingExtent();     << 118     G4double radius = bsScene.GetRadius();
                                                   >> 119     if (radius < 0.) {  // Nothing in the scene.
                                                   >> 120       fExtent = fpTopPV -> GetLogicalVolume () -> GetSolid () -> GetExtent ();
                                                   >> 121     } else {
                                                   >> 122       // Transform back to coordinates relative to the top
                                                   >> 123       // transformation, which is in G4VModel::fTransform.  This makes
                                                   >> 124       // it conform to all models, which are defined by a
                                                   >> 125       // transformation and an extent relative to that
                                                   >> 126       // transformation...
                                                   >> 127       G4Point3D centre = bsScene.GetCentre();
                                                   >> 128       centre.transform(fTransform.inverse());
                                                   >> 129       fExtent = G4VisExtent(centre, radius);
                                                   >> 130     }
179     fpMP = tempMP;                                131     fpMP = tempMP;
180     fTransform = tempTransform;                << 
181     fRequestedDepth = tempRequestedDepth;         132     fRequestedDepth = tempRequestedDepth;
182   }                                               133   }
183   G4double radius = fExtent.GetExtentRadius(); << 
184   if (radius < 0.) {  // Nothing in the scene  << 
185     fExtent = fpTopPV -> GetLogicalVolume () - << 
186   }                                            << 
187   fExtent.Transform(fTransform);               << 
188 }                                                 134 }
189                                                   135 
190 void G4PhysicalVolumeModel::DescribeYourselfTo    136 void G4PhysicalVolumeModel::DescribeYourselfTo
191 (G4VGraphicsScene& sceneHandler)                  137 (G4VGraphicsScene& sceneHandler)
192 {                                                 138 {
193   if (!fpTopPV) {                              << 139   if (!fpTopPV) G4Exception
194     G4Exception                                << 
195     ("G4PhysicalVolumeModel::DescribeYourselfT    140     ("G4PhysicalVolumeModel::DescribeYourselfTo",
196      "modeling0012", FatalException, "No model    141      "modeling0012", FatalException, "No model.");
197     return;  // Should never reach here, but k << 
198   }                                            << 
199                                                   142 
200   if (!fpMP) {                                 << 143   if (!fpMP) G4Exception
201     G4Exception                                << 
202     ("G4PhysicalVolumeModel::DescribeYourselfT    144     ("G4PhysicalVolumeModel::DescribeYourselfTo",
203      "modeling0013", FatalException, "No model << 145      "modeling0003", FatalException, "No modeling parameters.");
204     return;  // Should never reach here, but k << 
205   }                                            << 
206                                                   146 
207   fNClippers = 0;                              << 147   // For safety...
208   G4DisplacedSolid* pSectionSolid = fpMP->GetS << 148   fCurrentDepth = 0;
209   G4DisplacedSolid* pCutawaySolid = fpMP->GetC << 
210   if (fpClippingSolid) fNClippers++;           << 
211   if (pSectionSolid)   fNClippers++;           << 
212   if (pCutawaySolid)   fNClippers++;           << 
213   if (fNClippers > 1) {                        << 
214     G4ExceptionDescription ed;                 << 
215     ed << "More than one solid cutter/clipper: << 
216     if (fpClippingSolid) ed << "\nclipper in f << 
217     if (pSectionSolid)   ed << "\nsectioner in << 
218     if (pCutawaySolid)   ed << "\ncutaway in f << 
219     G4Exception("G4PhysicalVolumeModel::Descri << 
220   }                                            << 
221                                                   149 
222   G4Transform3D startingTransformation = fTran    150   G4Transform3D startingTransformation = fTransform;
223                                                   151 
224   fNTouchables.clear();  // Keeps count of tou << 
225                                                << 
226   VisitGeometryAndGetVisReps                      152   VisitGeometryAndGetVisReps
227     (fpTopPV,                                     153     (fpTopPV,
228      fRequestedDepth,                             154      fRequestedDepth,
229      startingTransformation,                      155      startingTransformation,
230      sceneHandler);                               156      sceneHandler);
231                                                   157 
232   fTotalTouchables = 0;                        << 158   // Clear data...
233   for (const auto& entry : fNTouchables) {     << 
234     fTotalTouchables += entry.second;          << 
235   }                                            << 
236                                                << 
237   // Reset or clear data...                    << 
238   fCurrentDepth     = 0;                          159   fCurrentDepth     = 0;
239   fpCurrentPV       = fpTopPV;                 << 160   fpCurrentPV       = 0;
240   fCurrentPVCopyNo  = fpTopPV->GetCopyNo();    << 161   fpCurrentLV       = 0;
241   fpCurrentLV       = fpTopPV->GetLogicalVolum << 162   fpCurrentMaterial = 0;
242   fpCurrentMaterial = fpCurrentLV? fpCurrentLV << 163   if (fFullPVPath.size() != fBaseFullPVPath.size()) {
243   fFullPVPath       = fBaseFullPVPath;         << 164     // They should be equal if pushing and popping is happening properly.
                                                   >> 165     G4Exception
                                                   >> 166     ("G4PhysicalVolumeModel::DescribeYourselfTo",
                                                   >> 167      "modeling0013",
                                                   >> 168      FatalException,
                                                   >> 169      "Path at start of modeling not equal to base path.  Something badly"
                                                   >> 170      "\nwrong.  Please contact visualisation coordinator.");
                                                   >> 171   }
244   fDrawnPVPath.clear();                           172   fDrawnPVPath.clear();
245   fAbort            = false;                   << 
246   fCurtailDescent   = false;                   << 
247 }                                                 173 }
248                                                   174 
249 G4String G4PhysicalVolumeModel::GetCurrentTag     175 G4String G4PhysicalVolumeModel::GetCurrentTag () const
250 {                                                 176 {
251   if (fpCurrentPV) {                              177   if (fpCurrentPV) {
252     std::ostringstream o;                         178     std::ostringstream o;
253     o << fpCurrentPV -> GetCopyNo ();             179     o << fpCurrentPV -> GetCopyNo ();
254     return fpCurrentPV -> GetName () + ":" + o << 180     return fpCurrentPV -> GetName () + "." + o.str();
255   }                                               181   }
256   else {                                          182   else {
257     return "WARNING: NO CURRENT VOLUME - globa    183     return "WARNING: NO CURRENT VOLUME - global tag is " + fGlobalTag;
258   }                                               184   }
259 }                                                 185 }
260                                                   186 
261 G4String G4PhysicalVolumeModel::GetCurrentDesc    187 G4String G4PhysicalVolumeModel::GetCurrentDescription () const
262 {                                                 188 {
263   return "G4PhysicalVolumeModel " + GetCurrent    189   return "G4PhysicalVolumeModel " + GetCurrentTag ();
264 }                                                 190 }
265                                                   191 
266 void G4PhysicalVolumeModel::VisitGeometryAndGe    192 void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
267 (G4VPhysicalVolume* pVPV,                         193 (G4VPhysicalVolume* pVPV,
268  G4int requestedDepth,                            194  G4int requestedDepth,
269  const G4Transform3D& theAT,                      195  const G4Transform3D& theAT,
270  G4VGraphicsScene& sceneHandler)                  196  G4VGraphicsScene& sceneHandler)
271 {                                                 197 {
272   // Visits geometry structure to a given dept    198   // Visits geometry structure to a given depth (requestedDepth), starting
273   //   at given physical volume with given sta    199   //   at given physical volume with given starting transformation and
274   //   describes volumes to the scene handler.    200   //   describes volumes to the scene handler.
275   // requestedDepth < 0 (default) implies full    201   // requestedDepth < 0 (default) implies full visit.
276   // theAT is the Accumulated Transformation.     202   // theAT is the Accumulated Transformation.
277                                                   203 
278   // Find corresponding logical volume and (la    204   // Find corresponding logical volume and (later) solid, storing in
279   // local variables to preserve re-entrancy.     205   // local variables to preserve re-entrancy.
280   G4LogicalVolume* pLV  = pVPV -> GetLogicalVo    206   G4LogicalVolume* pLV  = pVPV -> GetLogicalVolume ();
281   G4VSolid* pSol = nullptr;                    << 207 
282   G4Material* pMaterial = nullptr;             << 208   G4VSolid* pSol;
                                                   >> 209   G4Material* pMaterial;
283                                                   210 
284   if (!(pVPV -> IsReplicated ())) {               211   if (!(pVPV -> IsReplicated ())) {
285     // Non-replicated physical volume.            212     // Non-replicated physical volume.
286     pSol = pLV -> GetSolid ();                    213     pSol = pLV -> GetSolid ();
287     pMaterial = pLV -> GetMaterial ();            214     pMaterial = pLV -> GetMaterial ();
288     DescribeAndDescend (pVPV, requestedDepth,     215     DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
289       theAT, sceneHandler);                       216       theAT, sceneHandler);
290   }                                               217   }
291   else {                                          218   else {
292     // Replicated or parametrised physical vol    219     // Replicated or parametrised physical volume.
293     EAxis axis;                                   220     EAxis axis;
294     G4int nReplicas;                              221     G4int nReplicas;
295     G4double width;                               222     G4double width;
296     G4double offset;                              223     G4double offset;
297     G4bool consuming;                             224     G4bool consuming;
298     pVPV -> GetReplicationData (axis, nReplica    225     pVPV -> GetReplicationData (axis, nReplicas, width,  offset, consuming);
299     G4int nBegin = 0;                          << 226     if (fCurrentDepth == 0) nReplicas = 1;  // Just draw first
300     G4int nEnd = nReplicas;                    << 
301     if (fCurrentDepth == 0) { // i.e., top vol << 
302       nBegin = fTopPVCopyNo;  // Describe only << 
303       nEnd = nBegin + 1;      // specified by  << 
304     }                                          << 
305     G4VPVParameterisation* pP = pVPV -> GetPar    227     G4VPVParameterisation* pP = pVPV -> GetParameterisation ();
306     if (pP) {  // Parametrised volume.            228     if (pP) {  // Parametrised volume.
307       for (int n = nBegin; n < nEnd; n++) {    << 229       for (int n = 0; n < nReplicas; n++) {
308         pSol = pP -> ComputeSolid (n, pVPV);   << 230   pSol = pP -> ComputeSolid (n, pVPV);
309         pP -> ComputeTransformation (n, pVPV); << 231   pP -> ComputeTransformation (n, pVPV);
310         pSol -> ComputeDimensions (pP, n, pVPV << 232   pSol -> ComputeDimensions (pP, n, pVPV);
311         pVPV -> SetCopyNo (n);                 << 233   pVPV -> SetCopyNo (n);
312         fCurrentPVCopyNo = n;                  << 234   // Create a touchable of current parent for ComputeMaterial.
313         // Create a touchable of current paren << 235   // fFullPVPath has not been updated yet so at this point it
314         // fFullPVPath has not been updated ye << 236   // corresponds to the parent.
315         // corresponds to the parent.          << 237   G4PhysicalVolumeModelTouchable parentTouchable(fFullPVPath);
316         G4PhysicalVolumeModelTouchable parentT << 238   pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
317         pMaterial = pP -> ComputeMaterial (n,  << 239   DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
318         DescribeAndDescend (pVPV, requestedDep << 240           theAT, sceneHandler);
319                             theAT, sceneHandle << 
320       }                                           241       }
321     }                                             242     }
322     else {  // Plain replicated volume.  From     243     else {  // Plain replicated volume.  From geometry_guide.txt...
323       // The replica's positions are claculate    244       // The replica's positions are claculated by means of a linear formula.
324       // Replication may occur along:             245       // Replication may occur along:
325       //                                          246       // 
326       // o Cartesian axes (kXAxis,kYAxis,kZAxi    247       // o Cartesian axes (kXAxis,kYAxis,kZAxis)
327       //                                          248       // 
328       //   The replications, of specified widt    249       //   The replications, of specified width have coordinates of
329       //   form (-width*(nReplicas-1)*0.5+n*wi    250       //   form (-width*(nReplicas-1)*0.5+n*width,0,0) where n=0.. nReplicas-1
330       //   for the case of kXAxis, and are unr    251       //   for the case of kXAxis, and are unrotated.
331       //                                          252       // 
332       // o Radial axis (cylindrical polar) (kR    253       // o Radial axis (cylindrical polar) (kRho)
333       //                                          254       // 
334       //   The replications are cons/tubs sect    255       //   The replications are cons/tubs sections, centred on the origin
335       //   and are unrotated.                     256       //   and are unrotated.
336       //   They have radii of width*n+offset t    257       //   They have radii of width*n+offset to width*(n+1)+offset
337       //                      where n=0..nRepl    258       //                      where n=0..nReplicas-1
338       //                                          259       // 
339       // o Phi axis (cylindrical polar) (kPhi)    260       // o Phi axis (cylindrical polar) (kPhi)
340       //   The replications are `phi sections'    261       //   The replications are `phi sections' or wedges, and of cons/tubs form
341       //   They have phi of offset+n*width to     262       //   They have phi of offset+n*width to offset+(n+1)*width where
342       //   n=0..nReplicas-1                       263       //   n=0..nReplicas-1
343       //                                          264       // 
344       pSol = pLV -> GetSolid ();                  265       pSol = pLV -> GetSolid ();
345       pMaterial = pLV -> GetMaterial ();          266       pMaterial = pLV -> GetMaterial ();
346       G4ThreeVector originalTranslation = pVPV    267       G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
347       G4RotationMatrix* pOriginalRotation = pV    268       G4RotationMatrix* pOriginalRotation = pVPV -> GetRotation ();
348       G4double originalRMin = 0., originalRMax    269       G4double originalRMin = 0., originalRMax = 0.;
349       if (axis == kRho && pSol->GetEntityType(    270       if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
350         originalRMin = ((G4Tubs*)pSol)->GetInn << 271   originalRMin = ((G4Tubs*)pSol)->GetInnerRadius();
351         originalRMax = ((G4Tubs*)pSol)->GetOut << 272   originalRMax = ((G4Tubs*)pSol)->GetOuterRadius();
352       }                                           273       }
353       G4bool visualisable = true;                 274       G4bool visualisable = true;
354       for (int n = nBegin; n < nEnd; n++) {    << 275       for (int n = 0; n < nReplicas; n++) {
355         G4ThreeVector translation;  // Identit << 276   G4ThreeVector translation;  // Null.
356         G4RotationMatrix rotation;  // Identit << 277   G4RotationMatrix rotation;  // Null - life long enough for visualizing.
357         G4RotationMatrix* pRotation = 0;       << 278   G4RotationMatrix* pRotation = 0;
358         switch (axis) {                        << 279   switch (axis) {
359           default:                             << 280   default:
360           case kXAxis:                         << 281   case kXAxis:
361             translation = G4ThreeVector (-widt << 282     translation = G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
362             break;                             << 283     break;
363           case kYAxis:                         << 284   case kYAxis:
364             translation = G4ThreeVector (0,-wi << 285     translation = G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
365             break;                             << 286     break;
366           case kZAxis:                         << 287   case kZAxis:
367             translation = G4ThreeVector (0,0,- << 288     translation = G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
368             break;                             << 289     break;
369           case kRho:                           << 290   case kRho:
370             if (pSol->GetEntityType() == "G4Tu << 291     if (pSol->GetEntityType() == "G4Tubs") {
371               ((G4Tubs*)pSol)->SetInnerRadius( << 292       ((G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
372               ((G4Tubs*)pSol)->SetOuterRadius( << 293       ((G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
373             } else {                           << 294     } else {
374               if (fpMP->IsWarning())           << 295       if (fpMP->IsWarning())
375                 G4warn <<                      << 296         G4cout <<
376                 "G4PhysicalVolumeModel::VisitG << 297     "G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
377                 "\n  built-in replicated volum << 298     "\n  built-in replicated volumes replicated in radius for "
378                 << pSol->GetEntityType() <<    << 299          << pSol->GetEntityType() <<
379                 "-type\n  solids (your solid \ << 300     "-type\n  solids (your solid \""
380                 << pSol->GetName() <<          << 301          << pSol->GetName() <<
381                 "\") are not visualisable."    << 302     "\") are not visualisable."
382                 << G4endl;                     << 303          << G4endl;
383               visualisable = false;            << 304       visualisable = false;
384             }                                  << 305     }
385             break;                             << 306     break;
386           case kPhi:                           << 307   case kPhi:
387             rotation.rotateZ (-(offset+(n+0.5) << 308     rotation.rotateZ (-(offset+(n+0.5)*width));
388             // Minus Sign because for the phys << 309     // Minus Sign because for the physical volume we need the
389             // coordinate system rotation.     << 310     // coordinate system rotation.
390             pRotation = &rotation;             << 311     pRotation = &rotation;
391             break;                             << 312     break;
392         }                                      << 313   } 
393         pVPV -> SetTranslation (translation);  << 314   pVPV -> SetTranslation (translation);
394         pVPV -> SetRotation    (pRotation);    << 315   pVPV -> SetRotation    (pRotation);
395         pVPV -> SetCopyNo (n);                 << 316   pVPV -> SetCopyNo (n);
396         fCurrentPVCopyNo = n;                  << 317   if (visualisable) {
397         if (visualisable) {                    << 318     DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
398           DescribeAndDescend (pVPV, requestedD << 319           theAT, sceneHandler);
399                               theAT, sceneHand << 320   }
400         }                                      << 
401       }                                           321       }
402       // Restore originals...                     322       // Restore originals...
403       pVPV -> SetTranslation (originalTranslat    323       pVPV -> SetTranslation (originalTranslation);
404       pVPV -> SetRotation    (pOriginalRotatio    324       pVPV -> SetRotation    (pOriginalRotation);
405       if (axis == kRho && pSol->GetEntityType(    325       if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
406         ((G4Tubs*)pSol)->SetInnerRadius(origin << 326   ((G4Tubs*)pSol)->SetInnerRadius(originalRMin);
407         ((G4Tubs*)pSol)->SetOuterRadius(origin << 327   ((G4Tubs*)pSol)->SetOuterRadius(originalRMax);
408       }                                           328       }
409     }                                             329     }
410   }                                               330   }
                                                   >> 331 
                                                   >> 332   return;
411 }                                                 333 }
412                                                   334 
413 void G4PhysicalVolumeModel::DescribeAndDescend    335 void G4PhysicalVolumeModel::DescribeAndDescend
414 (G4VPhysicalVolume* pVPV,                         336 (G4VPhysicalVolume* pVPV,
415  G4int requestedDepth,                            337  G4int requestedDepth,
416  G4LogicalVolume* pLV,                            338  G4LogicalVolume* pLV,
417  G4VSolid* pSol,                                  339  G4VSolid* pSol,
418  G4Material* pMaterial,                           340  G4Material* pMaterial,
419  const G4Transform3D& theAT,                      341  const G4Transform3D& theAT,
420  G4VGraphicsScene& sceneHandler)                  342  G4VGraphicsScene& sceneHandler)
421 {                                                 343 {
422   // Maintain useful data members...              344   // Maintain useful data members...
423   fpCurrentPV = pVPV;                             345   fpCurrentPV = pVPV;
424   fCurrentPVCopyNo = pVPV->GetCopyNo();        << 
425   fpCurrentLV = pLV;                              346   fpCurrentLV = pLV;
426   fpCurrentMaterial = pMaterial;                  347   fpCurrentMaterial = pMaterial;
427                                                   348 
428   // Create a nodeID for use below - note the  << 
429   G4int copyNo = fpCurrentPV->GetCopyNo();     << 
430   auto nodeID = G4PhysicalVolumeNodeID         << 
431   (fpCurrentPV,copyNo,fCurrentDepth,fCurrentTr << 
432                                                << 
433   // Update full path of physical volumes...   << 
434   fFullPVPath.push_back(nodeID);               << 
435                                                << 
436   const G4RotationMatrix objectRotation = pVPV    349   const G4RotationMatrix objectRotation = pVPV -> GetObjectRotationValue ();
437   const G4ThreeVector&  translation     = pVPV    350   const G4ThreeVector&  translation     = pVPV -> GetTranslation ();
438   G4Transform3D theLT (G4Transform3D (objectRo    351   G4Transform3D theLT (G4Transform3D (objectRotation, translation));
439                                                   352 
440   // Compute the accumulated transformation...    353   // Compute the accumulated transformation...
441   // Note that top volume's transformation rel    354   // Note that top volume's transformation relative to the world
442   // coordinate system is specified in theAT =    355   // coordinate system is specified in theAT == startingTransformation
443   // = fTransform (see DescribeYourselfTo), so    356   // = fTransform (see DescribeYourselfTo), so first time through the
444   // volume's own transformation, which is onl    357   // volume's own transformation, which is only relative to its
445   // mother, i.e., not relative to the world c    358   // mother, i.e., not relative to the world coordinate system, should
446   // not be accumulated.                          359   // not be accumulated.
447   G4Transform3D theNewAT (theAT);                 360   G4Transform3D theNewAT (theAT);
448   if (fCurrentDepth != 0) theNewAT = theAT * t    361   if (fCurrentDepth != 0) theNewAT = theAT * theLT;
449   fCurrentTransform = theNewAT;                << 362   fpCurrentTransform = &theNewAT;
450                                                   363 
451   const G4VisAttributes* pVisAttribs = pLV->Ge    364   const G4VisAttributes* pVisAttribs = pLV->GetVisAttributes();
452   //  If the volume does not have any vis attr << 365   if (!pVisAttribs) pVisAttribs = fpMP->GetDefaultVisAttributes();
453   G4VisAttributes* tempVisAtts = nullptr;      << 366   // Beware - pVisAttribs might still be zero - create a temporary default one...
                                                   >> 367   G4bool visAttsCreated = false;
454   if (!pVisAttribs) {                             368   if (!pVisAttribs) {
455     if (fpMP->GetDefaultVisAttributes()) {     << 369     pVisAttribs = new G4VisAttributes;
456       tempVisAtts = new G4VisAttributes(*fpMP- << 370     visAttsCreated = true;
457     } else {                                   << 
458       tempVisAtts = new G4VisAttributes;       << 
459     }                                          << 
460     // The user may request /vis/viewer/set/co << 
461     if (fpMP->GetCBDAlgorithmNumber() == 1) {  << 
462       // Algorithm 1: 3 parameters: Simple rai << 
463       if (fpMP->GetCBDParameters().size() != 3 << 
464         G4Exception("G4PhysicalVolumeModelTouc << 
465                     "modeling0014",            << 
466                     FatalErrorInArgument,      << 
467                     "Algorithm-parameter misma << 
468       } else {                                 << 
469         const G4double d = pMaterial? pMateria << 
470         const G4double d0 = fpMP->GetCBDParame << 
471         const G4double d1 = fpMP->GetCBDParame << 
472         const G4double d2 = fpMP->GetCBDParame << 
473         if (d < d0) { // Density < d0 is invis << 
474           tempVisAtts->SetVisibility(false);   << 
475         } else { // Intermediate densities are << 
476           G4double red, green, blue;           << 
477           if (d < d1) {                        << 
478             red = (d1-d)/(d1-d0); green = (d-d << 
479           } else if (d < d2) {                 << 
480             red = 0.; green = (d2-d)/(d2-d1);  << 
481           } else {  // Density >= d2 is blue.  << 
482             red = 0.; green = 0.; blue = 1.;   << 
483           }                                    << 
484           tempVisAtts->SetColour(G4Colour(red, << 
485         }                                      << 
486       }                                        << 
487     } else if (fpMP->GetCBDAlgorithmNumber() = << 
488       // Algorithm 2                           << 
489       // ...etc.                               << 
490     }                                          << 
491     pVisAttribs = tempVisAtts;                 << 
492   }                                               371   }
493   // From here, can assume pVisAttribs is a va << 372   // From here, can assume pVisAttribs is a valid pointer.
494   // because PreAddSolid needs a vis attribute << 373   
495                                                << 374   // Make decision to draw...
                                                   >> 375   G4bool thisToBeDrawn = true;
                                                   >> 376   
                                                   >> 377   // Update full path of physical volumes...
                                                   >> 378   G4int copyNo = fpCurrentPV->GetCopyNo();
                                                   >> 379   fFullPVPath.push_back
                                                   >> 380   (G4PhysicalVolumeNodeID
                                                   >> 381    (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
                                                   >> 382   
                                                   >> 383   // In case we need to copy the vis atts for modification...
                                                   >> 384   G4bool copyForVAM = false;
                                                   >> 385   const G4VisAttributes* pUnmodifiedVisAtts = pVisAttribs;
                                                   >> 386   G4VisAttributes* pModifiedVisAtts = 0;
                                                   >> 387   
496   // Check if vis attributes are to be modifie    388   // Check if vis attributes are to be modified by a /vis/touchable/set/ command.
497   const auto& vams = fpMP->GetVisAttributesMod << 389   const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
498   if (vams.size()) {                           << 390     fpMP->GetVisAttributesModifiers();
499     // OK, we have some VAMs (Vis Attributes M << 391   std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
500     for (const auto& vam: vams) {              << 392     iModifier;
501       const auto& vamPath = vam.GetPVNameCopyN << 393   for (iModifier = vams.begin();
502       if (vamPath.size() == fFullPVPath.size() << 394        iModifier != vams.end();
503         // OK, we have a size match.           << 395        ++iModifier) {
504         // Check the volume name/copy number p << 396     const G4ModelingParameters::PVNameCopyNoPath& vamPath =
505         auto iVAMNameCopyNo = vamPath.begin(); << 397       iModifier->GetPVNameCopyNoPath();
506         auto iPVNodeId = fFullPVPath.begin();  << 398     if (vamPath.size() == fFullPVPath.size()) {
507         for (; iVAMNameCopyNo != vamPath.end() << 399       // OK - there's a size match.  Check it out.
508           if (!(                               << 400 //      G4cout << "Size match" << G4endl;
509                 iVAMNameCopyNo->GetName() ==   << 401       G4ModelingParameters::PVNameCopyNoPathConstIterator iVAMNameCopyNo;
510                 iPVNodeId->GetPhysicalVolume() << 402       std::vector<G4PhysicalVolumeNodeID>::const_iterator iPVNodeId;
511                 iVAMNameCopyNo->GetCopyNo() == << 403       for (iVAMNameCopyNo = vamPath.begin(), iPVNodeId = fFullPVPath.begin();
512                 iPVNodeId->GetPhysicalVolume() << 404            iVAMNameCopyNo != vamPath.end();
513                 )) {                           << 405            ++iVAMNameCopyNo, ++iPVNodeId) {
514             // This path element does NOT matc << 406 //        G4cout
515             break;                             << 407 //        << iVAMNameCopyNo->fName
516           }                                    << 408 //        << ',' << iVAMNameCopyNo->fCopyNo
517         }                                      << 409 //        << "; " << iPVNodeId->GetPhysicalVolume()->GetName()
518         if (iVAMNameCopyNo == vamPath.end()) { << 410 //        << ','  << iPVNodeId->GetPhysicalVolume()->GetCopyNo()
519           // OK, the paths match (the above lo << 411 //        << G4endl;
520           // Create a vis atts object for the  << 412         if (!(
521           // It is static so that we may retur << 413               iVAMNameCopyNo->GetName() ==
522           static G4VisAttributes modifiedVisAt << 414               iPVNodeId->GetPhysicalVolume()->GetName() &&
523           // Initialise it with the current vi << 415               iVAMNameCopyNo->GetCopyNo() ==
524           modifiedVisAtts = *pVisAttribs;      << 416               iPVNodeId->GetPhysicalVolume()->GetCopyNo()
525           pVisAttribs = &modifiedVisAtts;      << 417               )) {
526           const G4VisAttributes& transVisAtts  << 418           break;
527           switch (vam.GetVisAttributesSignifie << 
528             case G4ModelingParameters::VASVisi << 
529               modifiedVisAtts.SetVisibility(tr << 
530               break;                           << 
531             case G4ModelingParameters::VASDaug << 
532               modifiedVisAtts.SetDaughtersInvi << 
533               (transVisAtts.IsDaughtersInvisib << 
534               break;                           << 
535             case G4ModelingParameters::VASColo << 
536               modifiedVisAtts.SetColour(transV << 
537               break;                           << 
538             case G4ModelingParameters::VASLine << 
539               modifiedVisAtts.SetLineStyle(tra << 
540               break;                           << 
541             case G4ModelingParameters::VASLine << 
542               modifiedVisAtts.SetLineWidth(tra << 
543               break;                           << 
544             case G4ModelingParameters::VASForc << 
545               if (transVisAtts.IsForceDrawingS << 
546                 if (transVisAtts.GetForcedDraw << 
547                     G4VisAttributes::wireframe << 
548                   modifiedVisAtts.SetForceWire << 
549                 }                              << 
550               }                                << 
551               break;                           << 
552             case G4ModelingParameters::VASForc << 
553               if (transVisAtts.IsForceDrawingS << 
554                 if (transVisAtts.GetForcedDraw << 
555                     G4VisAttributes::solid) {  << 
556                   modifiedVisAtts.SetForceSoli << 
557                 }                              << 
558               }                                << 
559               break;                           << 
560             case G4ModelingParameters::VASForc << 
561               if (transVisAtts.IsForceDrawingS << 
562                 if (transVisAtts.GetForcedDraw << 
563                     G4VisAttributes::cloud) {  << 
564                   modifiedVisAtts.SetForceClou << 
565                 }                              << 
566               }                                << 
567               break;                           << 
568             case G4ModelingParameters::VASForc << 
569               modifiedVisAtts.SetForceNumberOf << 
570               (transVisAtts.GetForcedNumberOfC << 
571               break;                           << 
572             case G4ModelingParameters::VASForc << 
573               if (transVisAtts.IsForceAuxEdgeV << 
574                 modifiedVisAtts.SetForceAuxEdg << 
575                 (transVisAtts.IsForcedAuxEdgeV << 
576               }                                << 
577               break;                           << 
578             case G4ModelingParameters::VASForc << 
579               modifiedVisAtts.SetForceLineSegm << 
580               (transVisAtts.GetForcedLineSegme << 
581               break;                           << 
582           }                                    << 
583         }                                         419         }
584       }                                           420       }
585     }                                          << 421       if (iVAMNameCopyNo == vamPath.end()) {
586   }                                            << 422 //        G4cout << "Match found" << G4endl;
587                                                << 423         if (!copyForVAM) {
588   // Check for special mesh rendering          << 424           pModifiedVisAtts = new G4VisAttributes(*pUnmodifiedVisAtts);
589   if (fpMP->IsSpecialMeshRendering()) {        << 425           pVisAttribs = pModifiedVisAtts;
590     G4bool potentialG4Mesh = false;            << 426           copyForVAM = true;
591     if (fpMP->GetSpecialMeshVolumes().empty()) << 427         }
592       // No volumes specified - all are potent << 428         const G4VisAttributes& transVisAtts = iModifier->GetVisAttributes();
593       potentialG4Mesh = true;                  << 429         switch (iModifier->GetVisAttributesSignifier()) {
594     } else {                                   << 430           case G4ModelingParameters::VASVisibility:
595       // Name and (optionally) copy number of  << 431             pModifiedVisAtts->SetVisibility(transVisAtts.IsVisible());
596       for (const auto& pvNameCopyNo: fpMP->Get << 432             break;
597         if (pVPV->GetName() == pvNameCopyNo.Ge << 433           case G4ModelingParameters::VASDaughtersInvisible:
598           // We have a name match              << 434             pModifiedVisAtts->SetDaughtersInvisible
599           if (pvNameCopyNo.GetCopyNo() < 0) {  << 435             (transVisAtts.IsDaughtersInvisible());
600             // Any copy number is OK           << 436             break;
601             potentialG4Mesh = true;            << 437           case G4ModelingParameters::VASColour:
602           } else {                             << 438             pModifiedVisAtts->SetColour(transVisAtts.GetColour());
603             if (pVPV->GetCopyNo() == pvNameCop << 439             break;
604               // We have a name and copy numbe << 440           case G4ModelingParameters::VASLineStyle:
605               potentialG4Mesh = true;          << 441             pModifiedVisAtts->SetLineStyle(transVisAtts.GetLineStyle());
                                                   >> 442             break;
                                                   >> 443           case G4ModelingParameters::VASLineWidth:
                                                   >> 444             pModifiedVisAtts->SetLineWidth(transVisAtts.GetLineWidth());
                                                   >> 445             break;
                                                   >> 446           case G4ModelingParameters::VASForceWireframe:
                                                   >> 447             if (transVisAtts.GetForcedDrawingStyle() ==
                                                   >> 448                 G4VisAttributes::wireframe) {
                                                   >> 449               pModifiedVisAtts->SetForceWireframe
                                                   >> 450               (transVisAtts.IsForceDrawingStyle());
                                                   >> 451             }
                                                   >> 452             break;
                                                   >> 453           case G4ModelingParameters::VASForceSolid:
                                                   >> 454             if (transVisAtts.GetForcedDrawingStyle() ==
                                                   >> 455                 G4VisAttributes::solid) {
                                                   >> 456               pModifiedVisAtts->SetForceSolid
                                                   >> 457               (transVisAtts.IsForceDrawingStyle());
606             }                                     458             }
607           }                                    << 459             break;
                                                   >> 460           case G4ModelingParameters::VASForceAuxEdgeVisible:
                                                   >> 461             pModifiedVisAtts->SetForceAuxEdgeVisible
                                                   >> 462             (transVisAtts.IsForceAuxEdgeVisible());
                                                   >> 463             break;
                                                   >> 464           case G4ModelingParameters::VASForceLineSegmentsPerCircle:
                                                   >> 465             pModifiedVisAtts->SetForceLineSegmentsPerCircle
                                                   >> 466             (transVisAtts.GetForcedLineSegmentsPerCircle());
                                                   >> 467             break;
608         }                                         468         }
609       }                                           469       }
610     }                                             470     }
611     if (potentialG4Mesh) {                     << 
612       // Create - or at least attempt to creat << 
613       // out of this pVPV the type will be "in << 
614       G4Mesh mesh(pVPV,theNewAT);              << 
615       if (mesh.GetMeshType() != G4Mesh::invali << 
616         // Create "artificial" nodeID to repre << 
617         G4int artCopyNo = 0;                   << 
618         auto artPV = mesh.GetParameterisedVolu << 
619         auto artDepth = fCurrentDepth + 1;     << 
620         auto artNodeID = G4PhysicalVolumeNodeI << 
621         fFullPVPath.push_back(artNodeID);      << 
622         fDrawnPVPath.push_back(artNodeID);     << 
623         sceneHandler.AddCompound(mesh);        << 
624         fFullPVPath.pop_back();                << 
625         fDrawnPVPath.pop_back();               << 
626         delete tempVisAtts;  // Needs cleaning << 
627         return;  // Mesh found and processed - << 
628       }  // else continue processing           << 
629     }                                          << 
630   }                                               471   }
631                                                   472 
632   // Make decision to draw...                  << 
633   G4bool thisToBeDrawn = true;                 << 
634                                                << 
635   // There are various reasons why this volume    473   // There are various reasons why this volume
636   // might not be drawn...                        474   // might not be drawn...
637   G4bool culling = fpMP->IsCulling();             475   G4bool culling = fpMP->IsCulling();
638   G4bool cullingInvisible = fpMP->IsCullingInv    476   G4bool cullingInvisible = fpMP->IsCullingInvisible();
639   G4bool markedVisible                         << 477   G4bool markedVisible = pVisAttribs->IsVisible();
640   = pVisAttribs->IsVisible() && pVisAttribs->G << 
641   G4bool cullingLowDensity = fpMP->IsDensityCu    478   G4bool cullingLowDensity = fpMP->IsDensityCulling();
642   G4double density = pMaterial? pMaterial->Get    479   G4double density = pMaterial? pMaterial->GetDensity(): 0;
643   G4double densityCut = fpMP -> GetVisibleDens    480   G4double densityCut = fpMP -> GetVisibleDensity ();
644                                                   481 
645   // 1) Global culling is on....                  482   // 1) Global culling is on....
646   if (culling) {                                  483   if (culling) {
647     // 2) Culling of invisible volumes is on..    484     // 2) Culling of invisible volumes is on...
648     if (cullingInvisible) {                       485     if (cullingInvisible) {
649       // 3) ...and the volume is marked not vi    486       // 3) ...and the volume is marked not visible...
650       if (!markedVisible) thisToBeDrawn = fals    487       if (!markedVisible) thisToBeDrawn = false;
651     }                                             488     }
652     // 4) Or culling of low density volumes is    489     // 4) Or culling of low density volumes is on...
653     if (cullingLowDensity) {                      490     if (cullingLowDensity) {
654       // 5) ...and density is less than cut va    491       // 5) ...and density is less than cut value...
655       if (density < densityCut) thisToBeDrawn     492       if (density < densityCut) thisToBeDrawn = false;
656     }                                             493     }
657   }                                               494   }
658   // 6) The user has asked for all further tra << 495   
659   if (fAbort) thisToBeDrawn = false;           << 496   // Record thisToBeDrawn in path...
660                                                << 497   fFullPVPath.back().SetDrawn(thisToBeDrawn);
661   // Set "drawn" flag (it was true by default) << 
662   nodeID.SetDrawn(thisToBeDrawn);              << 
663                                                   498 
664   if (thisToBeDrawn) {                            499   if (thisToBeDrawn) {
665                                                   500 
666     // Update path of drawn physical volumes..    501     // Update path of drawn physical volumes...
667     fDrawnPVPath.push_back(nodeID);            << 502     fDrawnPVPath.push_back
                                                   >> 503       (G4PhysicalVolumeNodeID
                                                   >> 504        (fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform,thisToBeDrawn));
668                                                   505 
669     if (fpMP->IsExplode() && fDrawnPVPath.size    506     if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
670       // For top-level drawn volumes, explode     507       // For top-level drawn volumes, explode along radius...
671       G4Transform3D centering = G4Translate3D(    508       G4Transform3D centering = G4Translate3D(fpMP->GetExplodeCentre());
672       G4Transform3D centred = centering.invers    509       G4Transform3D centred = centering.inverse() * theNewAT;
673       G4Scale3D oldScale;                         510       G4Scale3D oldScale;
674       G4Rotate3D oldRotation;                     511       G4Rotate3D oldRotation;
675       G4Translate3D oldTranslation;               512       G4Translate3D oldTranslation;
676       centred.getDecomposition(oldScale, oldRo    513       centred.getDecomposition(oldScale, oldRotation, oldTranslation);
677       G4double explodeFactor = fpMP->GetExplod    514       G4double explodeFactor = fpMP->GetExplodeFactor();
678       G4Translate3D newTranslation =              515       G4Translate3D newTranslation =
679   G4Translate3D(explodeFactor * oldTranslation    516   G4Translate3D(explodeFactor * oldTranslation.dx(),
680           explodeFactor * oldTranslation.dy(),    517           explodeFactor * oldTranslation.dy(),
681           explodeFactor * oldTranslation.dz())    518           explodeFactor * oldTranslation.dz());
682       theNewAT = centering * newTranslation *     519       theNewAT = centering * newTranslation * oldRotation * oldScale;
683     }                                             520     }
684                                                   521 
685     auto fullDepth = fCurrentDepth + (G4int)fB << 
686     fNTouchables[fullDepth]++;  // Increment f << 
687                                                << 
688     DescribeSolid (theNewAT, pSol, pVisAttribs    522     DescribeSolid (theNewAT, pSol, pVisAttribs, sceneHandler);
689                                                   523 
690   }                                               524   }
691                                                   525 
692   // Make decision to draw daughters, if any.     526   // Make decision to draw daughters, if any.  There are various
693   // reasons why daughters might not be drawn.    527   // reasons why daughters might not be drawn...
694                                                   528 
695   // First, reasons that do not depend on cull    529   // First, reasons that do not depend on culling policy...
696   G4int nDaughters = (G4int)pLV->GetNoDaughter << 530   G4int nDaughters = pLV->GetNoDaughters();
697   G4bool daughtersToBeDrawn = true;               531   G4bool daughtersToBeDrawn = true;
698   // 1) There are no daughters...                 532   // 1) There are no daughters...
699   if (!nDaughters) daughtersToBeDrawn = false;    533   if (!nDaughters) daughtersToBeDrawn = false;
700   // 2) We are at the limit if requested depth    534   // 2) We are at the limit if requested depth...
701   else if (requestedDepth == 0) daughtersToBeD    535   else if (requestedDepth == 0) daughtersToBeDrawn = false;
702   // 3) The user has asked for all further tra << 536   // 3) The user has asked that the descent be curtailed...
703   else if (fAbort) daughtersToBeDrawn = false; << 
704   // 4) The user has asked that the descent be << 
705   else if (fCurtailDescent) daughtersToBeDrawn    537   else if (fCurtailDescent) daughtersToBeDrawn = false;
706                                                   538 
707   // Now, reasons that depend on culling polic    539   // Now, reasons that depend on culling policy...
708   else {                                          540   else {
709     G4bool daughtersInvisible = pVisAttribs->I    541     G4bool daughtersInvisible = pVisAttribs->IsDaughtersInvisible();
710     // Culling of covered daughters request.      542     // Culling of covered daughters request.  This is computed in
711     // G4VSceneHandler::CreateModelingParamete    543     // G4VSceneHandler::CreateModelingParameters() depending on view
712     // parameters...                              544     // parameters...
713     G4bool cullingCovered = fpMP->IsCullingCov    545     G4bool cullingCovered = fpMP->IsCullingCovered();
714     G4bool surfaceDrawing =                       546     G4bool surfaceDrawing =
715       fpMP->GetDrawingStyle() == G4ModelingPar    547       fpMP->GetDrawingStyle() == G4ModelingParameters::hsr ||
716       fpMP->GetDrawingStyle() == G4ModelingPar    548       fpMP->GetDrawingStyle() == G4ModelingParameters::hlhsr;    
717     if (pVisAttribs->IsForceDrawingStyle()) {     549     if (pVisAttribs->IsForceDrawingStyle()) {
718       switch (pVisAttribs->GetForcedDrawingSty    550       switch (pVisAttribs->GetForcedDrawingStyle()) {
719       default:                                    551       default:
720       case G4VisAttributes::wireframe: surface    552       case G4VisAttributes::wireframe: surfaceDrawing = false; break;
721       case G4VisAttributes::solid: surfaceDraw    553       case G4VisAttributes::solid: surfaceDrawing = true; break;
722       }                                           554       }
723     }                                             555     }
724     G4bool opaque = pVisAttribs->GetColour().G    556     G4bool opaque = pVisAttribs->GetColour().GetAlpha() >= 1.;
725     // 5) Global culling is on....             << 557     // 4) Global culling is on....
726     if (culling) {                                558     if (culling) {
727       // 6) ..and culling of invisible volumes << 559       // 5) ..and culling of invisible volumes is on...
728       if (cullingInvisible) {                     560       if (cullingInvisible) {
729   // 7) ...and the mother requests daughters i << 561   // 6) ...and the mother requests daughters invisible
730   if (daughtersInvisible) daughtersToBeDrawn =    562   if (daughtersInvisible) daughtersToBeDrawn = false;
731       }                                           563       }
732       // 8) Or culling of covered daughters is << 564       // 7) Or culling of covered daughters is requested...
733       if (cullingCovered) {                       565       if (cullingCovered) {
734   // 9) ...and surface drawing is operating... << 566   // 8) ...and surface drawing is operating...
735   if (surfaceDrawing) {                           567   if (surfaceDrawing) {
736     // 10) ...but only if mother is visible... << 568     // 9) ...but only if mother is visible...
737     if (thisToBeDrawn) {                          569     if (thisToBeDrawn) {
738       // 11) ...and opaque...                  << 570       // 10) ...and opaque...
739         if (opaque) daughtersToBeDrawn = false    571         if (opaque) daughtersToBeDrawn = false;
740     }                                             572     }
741   }                                               573   }
742       }                                           574       }
743     }                                             575     }
744   }                                               576   }
745                                                   577 
                                                   >> 578   // Delete modified vis atts if created...
                                                   >> 579   if (copyForVAM) {
                                                   >> 580     delete pModifiedVisAtts;
                                                   >> 581     pVisAttribs = pUnmodifiedVisAtts;
                                                   >> 582     copyForVAM = false;
                                                   >> 583   }
                                                   >> 584   
                                                   >> 585   // Vis atts for this volume no longer needed if created...
                                                   >> 586   if (visAttsCreated) delete pVisAttribs;
                                                   >> 587 
746   if (daughtersToBeDrawn) {                       588   if (daughtersToBeDrawn) {
747     for (G4int iDaughter = 0; iDaughter < nDau    589     for (G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
748       // Store daughter pVPV in local variable    590       // Store daughter pVPV in local variable ready for recursion...
749       G4VPhysicalVolume* pDaughterVPV = pLV ->    591       G4VPhysicalVolume* pDaughterVPV = pLV -> GetDaughter (iDaughter);
750       // Descend the geometry structure recurs    592       // Descend the geometry structure recursively...
751       fCurrentDepth++;                            593       fCurrentDepth++;
752       VisitGeometryAndGetVisReps                  594       VisitGeometryAndGetVisReps
753   (pDaughterVPV, requestedDepth - 1, theNewAT,    595   (pDaughterVPV, requestedDepth - 1, theNewAT, sceneHandler);
754       fCurrentDepth--;                            596       fCurrentDepth--;
755     }                                             597     }
756   }                                               598   }
757                                                   599 
758   // Clean up                                  << 
759   delete tempVisAtts;                          << 
760                                                << 
761   // Reset for normal descending of next volum    600   // Reset for normal descending of next volume at this level...
762   fCurtailDescent = false;                        601   fCurtailDescent = false;
763                                                   602 
764   // Pop item from paths physical volumes...      603   // Pop item from paths physical volumes...
765   fFullPVPath.pop_back();                         604   fFullPVPath.pop_back();
766   if (thisToBeDrawn) {                            605   if (thisToBeDrawn) {
767     fDrawnPVPath.pop_back();                      606     fDrawnPVPath.pop_back();
768   }                                               607   }
769 }                                                 608 }
770                                                   609 
771 namespace                                      << 
772 {                                              << 
773   G4bool SubtractionBoundingLimits(const G4VSo << 
774   {                                            << 
775     // Algorithm from G4SubtractionSolid::Boun << 
776     // Since it is unclear how the shape of th << 
777     // after subtraction, just return its orig << 
778     G4ThreeVector pMin, pMax;                  << 
779     const auto& pSolA = target;                << 
780     pSolA->BoundingLimits(pMin,pMax);          << 
781     // Check correctness of the bounding box   << 
782     if (pMin.x() >= pMax.x() || pMin.y() >= pM << 
783       // Bad bounding box (min >= max)         << 
784       // This signifies a subtraction of non-i << 
785       return false;                            << 
786     }                                          << 
787     return true;                               << 
788   }                                            << 
789                                                << 
790   G4bool IntersectionBoundingLimits(const G4VS << 
791   {                                            << 
792     // Algorithm from G4IntersectionSolid::Bou << 
793     G4ThreeVector pMin, pMax;                  << 
794     G4ThreeVector minA,maxA, minB,maxB;        << 
795     const auto& pSolA = target;                << 
796     const auto& pSolB = intersector;           << 
797     pSolA->BoundingLimits(minA,maxA);          << 
798     pSolB->BoundingLimits(minB,maxB);          << 
799     pMin.set(std::max(minA.x(),minB.x()),      << 
800              std::max(minA.y(),minB.y()),      << 
801              std::max(minA.z(),minB.z()));     << 
802     pMax.set(std::min(maxA.x(),maxB.x()),      << 
803              std::min(maxA.y(),maxB.y()),      << 
804              std::min(maxA.z(),maxB.z()));     << 
805     if (pMin.x() >= pMax.x() || pMin.y() >= pM << 
806       // Bad bounding box (min >= max)         << 
807       // This signifies a subtraction of non-i << 
808       return false;                            << 
809     }                                          << 
810     return true;                               << 
811   }                                            << 
812 }                                              << 
813                                                << 
814 void G4PhysicalVolumeModel::DescribeSolid         610 void G4PhysicalVolumeModel::DescribeSolid
815 (const G4Transform3D& theAT,                      611 (const G4Transform3D& theAT,
816  G4VSolid* pSol,                                  612  G4VSolid* pSol,
817  const G4VisAttributes* pVisAttribs,              613  const G4VisAttributes* pVisAttribs,
818  G4VGraphicsScene& sceneHandler)                  614  G4VGraphicsScene& sceneHandler)
819 {                                                 615 {
820   G4DisplacedSolid* pSectionSolid = fpMP->GetS << 616   sceneHandler.PreAddSolid (theAT, *pVisAttribs);
821   G4DisplacedSolid* pCutawaySolid = fpMP->GetC << 617 
                                                   >> 618   G4VSolid* pSectionSolid = fpMP->GetSectionSolid();
                                                   >> 619   G4VSolid* pCutawaySolid = fpMP->GetCutawaySolid();
822                                                   620 
823   if (fNClippers <= 0 || fNClippers > 1) {     << 621   if (!fpClippingSolid && !pSectionSolid && !pCutawaySolid) {
824                                                   622 
825     // Normal case - no clipping, etc. - or, i << 
826     sceneHandler.PreAddSolid (theAT, *pVisAttr << 
827     pSol -> DescribeYourselfTo (sceneHandler);    623     pSol -> DescribeYourselfTo (sceneHandler);  // Standard treatment.
828     sceneHandler.PostAddSolid ();              << 
829                                                   624 
830   } else {  // fNClippers == 1                 << 625   } else {
831                                                   626 
832     G4VSolid*         pResultantSolid = nullpt << 627     // Clipping, etc., performed by Boolean operations.
833     G4DisplacedSolid* pDisplacedSolid = nullpt << 
834                                                   628 
835     if (fpClippingSolid) {                     << 629     // First, get polyhedron for current solid...
836       pDisplacedSolid = new G4DisplacedSolid(" << 630     if (pVisAttribs->IsForceLineSegmentsPerCircle())
837       switch (fClippingMode) {                 << 631       G4Polyhedron::SetNumberOfRotationSteps
838         case subtraction:                      << 632   (pVisAttribs->GetForcedLineSegmentsPerCircle());
839           if (SubtractionBoundingLimits(pSol)) << 633     else
840             pResultantSolid = new G4Subtractio << 634       G4Polyhedron::SetNumberOfRotationSteps(fpMP->GetNoOfSides());
841             ("subtracted_clipped_solid", pSol, << 635     const G4Polyhedron* pOriginal = pSol->GetPolyhedron();
842           }                                    << 636     G4Polyhedron::ResetNumberOfRotationSteps();
843           break;                               << 637 
844         case intersection:                     << 638     if (!pOriginal) {
845           if (IntersectionBoundingLimits(pSol, << 639 
846             pResultantSolid = new G4Intersecti << 640       if (fpMP->IsWarning())
847             ("intersected_clipped_solid", pSol << 641   G4cout <<
848           }                                    << 642     "WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n  \""
849           break;                               << 643          << pSol->GetName() <<
                                                   >> 644     "\" has no polyhedron.  Cannot by clipped."
                                                   >> 645          << G4endl;
                                                   >> 646       pSol -> DescribeYourselfTo (sceneHandler);  // Standard treatment.
                                                   >> 647 
                                                   >> 648     } else {
                                                   >> 649 
                                                   >> 650       G4Polyhedron resultant(*pOriginal);
                                                   >> 651       G4VisAttributes resultantVisAttribs(*pVisAttribs);
                                                   >> 652       G4VSolid* resultantSolid = 0;
                                                   >> 653 
                                                   >> 654       if (fpClippingSolid) {
                                                   >> 655   switch (fClippingMode) {
                                                   >> 656   default:
                                                   >> 657   case subtraction:
                                                   >> 658     resultantSolid = new G4SubtractionSolid
                                                   >> 659       ("resultant_solid", pSol, fpClippingSolid, theAT.inverse());
                                                   >> 660     break;
                                                   >> 661   case intersection:
                                                   >> 662     resultantSolid = new G4IntersectionSolid
                                                   >> 663       ("resultant_solid", pSol, fpClippingSolid, theAT.inverse());
                                                   >> 664     break;
                                                   >> 665   }
850       }                                           666       }
851                                                   667 
852     } else if (pSectionSolid) {                << 668       if (pSectionSolid) {
853       pDisplacedSolid = new G4DisplacedSolid(" << 669   resultantSolid = new G4IntersectionSolid
854       if (IntersectionBoundingLimits(pSol, pDi << 670     ("sectioned_solid", pSol, pSectionSolid, theAT.inverse());
855         pResultantSolid = new G4IntersectionSo << 
856       }                                           671       }
857                                                   672 
858     } else if (pCutawaySolid) {                << 673       if (pCutawaySolid) {
859       pDisplacedSolid = new G4DisplacedSolid(" << 674   resultantSolid = new G4SubtractionSolid
860       switch (fpMP->GetCutawayMode()) {        << 675     ("cutaway_solid", pSol, pCutawaySolid, theAT.inverse());
861         case G4ModelingParameters::cutawayUnio << 
862           if (SubtractionBoundingLimits(pSol)) << 
863             pResultantSolid = new G4Subtractio << 
864           }                                    << 
865           break;                               << 
866         case G4ModelingParameters::cutawayInte << 
867           if (IntersectionBoundingLimits(pSol, << 
868             pResultantSolid = new G4Intersecti << 
869           }                                    << 
870           break;                               << 
871       }                                           676       }
872     }                                          << 
873                                                   677 
874     if (pResultantSolid) {                     << 678       G4Polyhedron* tmpResultant = resultantSolid->GetPolyhedron();
875       sceneHandler.PreAddSolid (theAT, *pVisAt << 679       if (tmpResultant) resultant = *tmpResultant;
876       pResultantSolid -> DescribeYourselfTo (s << 680       else {
877       sceneHandler.PostAddSolid ();            << 681   if (fpMP->IsWarning())
878     }                                          << 682     G4cout <<
                                                   >> 683       "WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
                                                   >> 684       "\n  solid \"" << pSol->GetName() <<
                                                   >> 685       "\" not defined due to error during Boolean processing."
                                                   >> 686       "\n  Original will be drawn in red."
                                                   >> 687      << G4endl;
                                                   >> 688   resultantVisAttribs.SetColour(G4Colour::Red());
                                                   >> 689       }
879                                                   690 
880     delete pResultantSolid;                    << 691       delete resultantSolid;
881     delete pDisplacedSolid;                    << 692 
                                                   >> 693       // Finally, force polyhedron drawing...
                                                   >> 694       resultant.SetVisAttributes(resultantVisAttribs);
                                                   >> 695       sceneHandler.BeginPrimitives(theAT);
                                                   >> 696       sceneHandler.AddPrimitive(resultant);
                                                   >> 697       sceneHandler.EndPrimitives();
                                                   >> 698     }
882   }                                               699   }
                                                   >> 700   sceneHandler.PostAddSolid ();
883 }                                                 701 }
884                                                   702 
885 G4bool G4PhysicalVolumeModel::Validate (G4bool    703 G4bool G4PhysicalVolumeModel::Validate (G4bool warn)
886 {                                                 704 {
887 // Not easy to see how to validate this sort o << 705   G4TransportationManager* transportationManager =
888 // a check that a volume of the same name (fTo << 706     G4TransportationManager::GetTransportationManager ();
889 // the geometry tree but under some circumstan << 707 
890 // time. Instead, let us simply check that the << 708   size_t nWorlds = transportationManager->GetNoWorlds();
891 // physical volume store.                      << 709 
892   const auto& pvStore = G4PhysicalVolumeStore: << 710   G4bool found = false;
893   auto iterator = find(pvStore->begin(),pvStor << 711 
894   if (iterator == pvStore->end()) {            << 712   std::vector<G4VPhysicalVolume*>::iterator iterWorld =
                                                   >> 713     transportationManager->GetWorldsIterator();
                                                   >> 714   for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
                                                   >> 715     G4VPhysicalVolume* world = (*iterWorld);
                                                   >> 716     // The idea now is to seek a PV with the same name and copy no
                                                   >> 717     // in the hope it's the same one!!
                                                   >> 718     G4PhysicalVolumeModel searchModel (world);
                                                   >> 719     G4int verbosity = 0;  // Suppress messages from G4PhysicalVolumeSearchScene.
                                                   >> 720     G4PhysicalVolumeSearchScene searchScene
                                                   >> 721       (&searchModel, fTopPVName, fTopPVCopyNo, verbosity);
                                                   >> 722     G4ModelingParameters mp;  // Default modeling parameters for this search.
                                                   >> 723     mp.SetDefaultVisAttributes(fpMP? fpMP->GetDefaultVisAttributes(): 0);
                                                   >> 724     searchModel.SetModelingParameters (&mp);
                                                   >> 725     searchModel.DescribeYourselfTo (searchScene);
                                                   >> 726     G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
                                                   >> 727     if (foundVolume) {
                                                   >> 728       if (foundVolume != fpTopPV && warn) {
                                                   >> 729   G4cout <<
                                                   >> 730     "G4PhysicalVolumeModel::Validate(): A volume of the same name and"
                                                   >> 731     "\n  copy number (\""
                                                   >> 732          << fTopPVName << "\", copy " << fTopPVCopyNo
                                                   >> 733          << ") still exists and is being used."
                                                   >> 734     "\n  But it is not the same volume you originally specified"
                                                   >> 735     "\n  in /vis/scene/add/."
                                                   >> 736          << G4endl;
                                                   >> 737       }
                                                   >> 738       fpTopPV = foundVolume;
                                                   >> 739       CalculateExtent ();
                                                   >> 740       found = true;
                                                   >> 741     }
                                                   >> 742   }
                                                   >> 743   if (found) return true;
                                                   >> 744   else {
895     if (warn) {                                   745     if (warn) {
896       G4ExceptionDescription ed;               << 746       G4cout <<
897       ed << "Attempt to validate a volume that << 747   "G4PhysicalVolumeModel::Validate(): No volume of name and"
898       G4Exception("G4PhysicalVolumeModel::Vali << 748   "\n  copy number (\""
                                                   >> 749        << fTopPVName << "\", copy " << fTopPVCopyNo
                                                   >> 750        << ") exists."
                                                   >> 751        << G4endl;
899     }                                             752     }
900     return false;                                 753     return false;
901   } else {                                     << 
902     return true;                               << 
903   }                                               754   }
904 }                                                 755 }
905                                                   756 
906 const std::map<G4String,G4AttDef>* G4PhysicalV    757 const std::map<G4String,G4AttDef>* G4PhysicalVolumeModel::GetAttDefs() const
907 {                                                 758 {
908     G4bool isNew;                                 759     G4bool isNew;
909     std::map<G4String,G4AttDef>* store            760     std::map<G4String,G4AttDef>* store
910       = G4AttDefStore::GetInstance("G4Physical    761       = G4AttDefStore::GetInstance("G4PhysicalVolumeModel", isNew);
911     if (isNew) {                                  762     if (isNew) {
912       (*store)["PVPath"] =                        763       (*store)["PVPath"] =
913       G4AttDef("PVPath","Physical Volume Path" << 764   G4AttDef("PVPath","Physical Volume Path","Physics","","G4String");
914       (*store)["BasePVPath"] =                 << 
915       G4AttDef("BasePVPath","Base Physical Vol << 
916       (*store)["LVol"] =                          765       (*store)["LVol"] =
917       G4AttDef("LVol","Logical Volume","Physic << 766   G4AttDef("LVol","Logical Volume","Physics","","G4String");
918       (*store)["Solid"] =                         767       (*store)["Solid"] =
919       G4AttDef("Solid","Solid Name","Physics", << 768   G4AttDef("Solid","Solid Name","Physics","","G4String");
920       (*store)["EType"] =                         769       (*store)["EType"] =
921       G4AttDef("EType","Entity Type","Physics" << 770   G4AttDef("EType","Entity Type","Physics","","G4String");
922       (*store)["DmpSol"] =                        771       (*store)["DmpSol"] =
923       G4AttDef("DmpSol","Dump of Solid propert << 772   G4AttDef("DmpSol","Dump of Solid properties","Physics","","G4String");
924       (*store)["LocalTrans"] =                 << 773       (*store)["Trans"] =
925       G4AttDef("LocalTrans","Local transformat << 774   G4AttDef("Trans","Transformation of volume","Physics","","G4String");
926       (*store)["LocalExtent"] =                << 
927       G4AttDef("LocalExtent","Local extent of  << 
928       (*store)["GlobalTrans"] =                << 
929       G4AttDef("GlobalTrans","Global transform << 
930       (*store)["GlobalExtent"] =               << 
931       G4AttDef("GlobalExtent","Global extent o << 
932       (*store)["Material"] =                      775       (*store)["Material"] =
933       G4AttDef("Material","Material Name","Phy << 776   G4AttDef("Material","Material Name","Physics","","G4String");
934       (*store)["Density"] =                       777       (*store)["Density"] =
935       G4AttDef("Density","Material Density","P << 778   G4AttDef("Density","Material Density","Physics","G4BestUnit","G4double");
936       (*store)["State"] =                         779       (*store)["State"] =
937       G4AttDef("State","Material State (enum u << 780   G4AttDef("State","Material State (enum undefined,solid,liquid,gas)","Physics","","G4String");
938       (*store)["Radlen"] =                        781       (*store)["Radlen"] =
939       G4AttDef("Radlen","Material Radiation Le << 782   G4AttDef("Radlen","Material Radiation Length","Physics","G4BestUnit","G4double");
940       (*store)["Region"] =                        783       (*store)["Region"] =
941       G4AttDef("Region","Cuts Region","Physics << 784   G4AttDef("Region","Cuts Region","Physics","","G4String");
942       (*store)["RootRegion"] =                    785       (*store)["RootRegion"] =
943       G4AttDef("RootRegion","Root Region (0/1  << 786   G4AttDef("RootRegion","Root Region (0/1 = false/true)","Physics","","G4bool");
944     }                                             787     }
945   return store;                                   788   return store;
946 }                                                 789 }
947                                                   790 
                                                   >> 791 #include <iomanip>
                                                   >> 792 
948 static std::ostream& operator<< (std::ostream&    793 static std::ostream& operator<< (std::ostream& o, const G4Transform3D t)
949 {                                                 794 {
950   using namespace std;                            795   using namespace std;
951                                                   796 
952   G4Scale3D sc;                                   797   G4Scale3D sc;
953   G4Rotate3D r;                                   798   G4Rotate3D r;
954   G4Translate3D tl;                               799   G4Translate3D tl;
955   t.getDecomposition(sc, r, tl);                  800   t.getDecomposition(sc, r, tl);
956                                                   801 
957   const int w = 10;                               802   const int w = 10;
958                                                   803 
959   // Transformation itself                        804   // Transformation itself
960   o << setw(w) << t.xx() << setw(w) << t.xy()     805   o << setw(w) << t.xx() << setw(w) << t.xy() << setw(w) << t.xz() << setw(w) << t.dx() << endl;
961   o << setw(w) << t.yx() << setw(w) << t.yy()     806   o << setw(w) << t.yx() << setw(w) << t.yy() << setw(w) << t.yz() << setw(w) << t.dy() << endl;
962   o << setw(w) << t.zx() << setw(w) << t.zy()     807   o << setw(w) << t.zx() << setw(w) << t.zy() << setw(w) << t.zz() << setw(w) << t.dz() << endl;
963                                                   808 
964   // Translation                                  809   // Translation
965   o << "= translation:" << endl;                  810   o << "= translation:" << endl;
966   o << setw(w) << tl.dx() << setw(w) << tl.dy(    811   o << setw(w) << tl.dx() << setw(w) << tl.dy() << setw(w) << tl.dz() << endl;
967                                                   812 
968   // Rotation                                     813   // Rotation
969   o << "* rotation:" << endl;                     814   o << "* rotation:" << endl;
970   o << setw(w) << r.xx() << setw(w) << r.xy()     815   o << setw(w) << r.xx() << setw(w) << r.xy() << setw(w) << r.xz() << endl;
971   o << setw(w) << r.yx() << setw(w) << r.yy()     816   o << setw(w) << r.yx() << setw(w) << r.yy() << setw(w) << r.yz() << endl;
972   o << setw(w) << r.zx() << setw(w) << r.zy()     817   o << setw(w) << r.zx() << setw(w) << r.zy() << setw(w) << r.zz() << endl;
973                                                   818 
974   // Scale                                        819   // Scale
975   o << "* scale:" << endl;                        820   o << "* scale:" << endl;
976   o << setw(w) << sc.xx() << setw(w) << sc.yy(    821   o << setw(w) << sc.xx() << setw(w) << sc.yy() << setw(w) << sc.zz() << endl;
977                                                   822 
978   // Transformed axes                             823   // Transformed axes
979   o << "Transformed axes:" << endl;               824   o << "Transformed axes:" << endl;
980   o << "x': " << r * G4Vector3D(1., 0., 0.) <<    825   o << "x': " << r * G4Vector3D(1., 0., 0.) << endl;
981   o << "y': " << r * G4Vector3D(0., 1., 0.) <<    826   o << "y': " << r * G4Vector3D(0., 1., 0.) << endl;
982   o << "z': " << r * G4Vector3D(0., 0., 1.) <<    827   o << "z': " << r * G4Vector3D(0., 0., 1.) << endl;
983                                                   828 
984   return o;                                       829   return o;
985 }                                                 830 }
986                                                   831 
987 std::vector<G4AttValue>* G4PhysicalVolumeModel    832 std::vector<G4AttValue>* G4PhysicalVolumeModel::CreateCurrentAttValues() const
988 {                                                 833 {
989   std::vector<G4AttValue>* values = new std::v    834   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
                                                   >> 835   std::ostringstream oss;
                                                   >> 836   for (size_t i = 0; i < fFullPVPath.size(); ++i) {
                                                   >> 837     oss << fFullPVPath[i].GetPhysicalVolume()->GetName()
                                                   >> 838   << ':' << fFullPVPath[i].GetCopyNo();
                                                   >> 839     if (i != fFullPVPath.size() - 1) oss << '/';
                                                   >> 840   }
990                                                   841 
991   if (!fpCurrentLV) {                             842   if (!fpCurrentLV) {
992      G4Exception                                  843      G4Exception
993         ("G4PhysicalVolumeModel::CreateCurrent    844         ("G4PhysicalVolumeModel::CreateCurrentAttValues",
994          "modeling0004",                          845          "modeling0004",
995          JustWarning,                             846          JustWarning,
996          "Current logical volume not defined."    847          "Current logical volume not defined.");
997      return values;                               848      return values;
998   }                                               849   }
999                                                   850 
1000   std::ostringstream oss; oss << fFullPVPath; << 
1001   values->push_back(G4AttValue("PVPath", oss.    851   values->push_back(G4AttValue("PVPath", oss.str(),""));
1002                                               << 
1003   oss.str(""); oss << fBaseFullPVPath;        << 
1004   values->push_back(G4AttValue("BasePVPath",  << 
1005                                               << 
1006   values->push_back(G4AttValue("LVol", fpCurr    852   values->push_back(G4AttValue("LVol", fpCurrentLV->GetName(),""));
1007   G4VSolid* pSol = fpCurrentLV->GetSolid();      853   G4VSolid* pSol = fpCurrentLV->GetSolid();
1008                                               << 
1009   values->push_back(G4AttValue("Solid", pSol-    854   values->push_back(G4AttValue("Solid", pSol->GetName(),""));
1010                                               << 
1011   values->push_back(G4AttValue("EType", pSol-    855   values->push_back(G4AttValue("EType", pSol->GetEntityType(),""));
1012                                               << 
1013   oss.str(""); oss << '\n' << *pSol;             856   oss.str(""); oss << '\n' << *pSol;
1014   values->push_back(G4AttValue("DmpSol", oss.    857   values->push_back(G4AttValue("DmpSol", oss.str(),""));
1015                                               << 858   oss.str(""); oss << '\n' << *fpCurrentTransform;
1016   const G4RotationMatrix localRotation = fpCu << 859   values->push_back(G4AttValue("Trans", oss.str(),""));
1017   const G4ThreeVector& localTranslation = fpC << 
1018   oss.str(""); oss << '\n' << G4Transform3D(l << 
1019   values->push_back(G4AttValue("LocalTrans",  << 
1020                                               << 
1021   oss.str(""); oss << '\n' << pSol->GetExtent << 
1022   values->push_back(G4AttValue("LocalExtent", << 
1023                                               << 
1024   oss.str(""); oss << '\n' << fCurrentTransfo << 
1025   values->push_back(G4AttValue("GlobalTrans", << 
1026                                               << 
1027   oss.str(""); oss << '\n' << (pSol->GetExten << 
1028   values->push_back(G4AttValue("GlobalExtent" << 
1029                                               << 
1030   G4String matName = fpCurrentMaterial? fpCur    860   G4String matName = fpCurrentMaterial? fpCurrentMaterial->GetName(): G4String("No material");
1031   values->push_back(G4AttValue("Material", ma    861   values->push_back(G4AttValue("Material", matName,""));
1032                                               << 
1033   G4double matDensity = fpCurrentMaterial? fp    862   G4double matDensity = fpCurrentMaterial? fpCurrentMaterial->GetDensity(): 0.;
1034   values->push_back(G4AttValue("Density", G4B    863   values->push_back(G4AttValue("Density", G4BestUnit(matDensity,"Volumic Mass"),""));
1035                                               << 
1036   G4State matState = fpCurrentMaterial? fpCur    864   G4State matState = fpCurrentMaterial? fpCurrentMaterial->GetState(): kStateUndefined;
1037   oss.str(""); oss << matState;                  865   oss.str(""); oss << matState;
1038   values->push_back(G4AttValue("State", oss.s    866   values->push_back(G4AttValue("State", oss.str(),""));
1039                                               << 
1040   G4double matRadlen = fpCurrentMaterial? fpC    867   G4double matRadlen = fpCurrentMaterial? fpCurrentMaterial->GetRadlen(): 0.;
1041   values->push_back(G4AttValue("Radlen", G4Be    868   values->push_back(G4AttValue("Radlen", G4BestUnit(matRadlen,"Length"),""));
1042                                               << 
1043   G4Region* region = fpCurrentLV->GetRegion()    869   G4Region* region = fpCurrentLV->GetRegion();
1044   G4String regionName = region? region->GetNa    870   G4String regionName = region? region->GetName(): G4String("No region");
1045   values->push_back(G4AttValue("Region", regi    871   values->push_back(G4AttValue("Region", regionName,""));
1046                                               << 
1047   oss.str(""); oss << fpCurrentLV->IsRootRegi    872   oss.str(""); oss << fpCurrentLV->IsRootRegion();
1048   values->push_back(G4AttValue("RootRegion",     873   values->push_back(G4AttValue("RootRegion", oss.str(),""));
1049                                               << 
1050   return values;                                 874   return values;
1051 }                                                875 }
1052                                                  876 
1053 G4bool G4PhysicalVolumeModel::G4PhysicalVolum    877 G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
1054   (const G4PhysicalVolumeModel::G4PhysicalVol    878   (const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& right) const
1055 {                                                879 {
1056   if (fpPV < right.fpPV) return true;            880   if (fpPV < right.fpPV) return true;
1057   if (fpPV == right.fpPV) {                      881   if (fpPV == right.fpPV) {
1058     if (fCopyNo < right.fCopyNo) return true;    882     if (fCopyNo < right.fCopyNo) return true;
1059     if (fCopyNo == right.fCopyNo)                883     if (fCopyNo == right.fCopyNo)
1060       return fNonCulledDepth < right.fNonCull    884       return fNonCulledDepth < right.fNonCulledDepth;
1061   }                                              885   }
1062   return false;                                  886   return false;
1063 }                                                887 }
1064                                                  888 
1065 G4bool G4PhysicalVolumeModel::G4PhysicalVolum << 
1066   (const G4PhysicalVolumeModel::G4PhysicalVol << 
1067 {                                             << 
1068   if (fpPV            != right.fpPV ||        << 
1069       fCopyNo         != right.fCopyNo ||     << 
1070       fNonCulledDepth != right.fNonCulledDept << 
1071       fTransform      != right.fTransform ||  << 
1072       fDrawn          != right.fDrawn) return << 
1073   return false;                               << 
1074 }                                             << 
1075                                               << 
1076 std::ostream& operator<<                         889 std::ostream& operator<<
1077   (std::ostream& os, const G4PhysicalVolumeMo << 890   (std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID node)
1078 {                                                891 {
1079   G4VPhysicalVolume* pPV = node.GetPhysicalVo    892   G4VPhysicalVolume* pPV = node.GetPhysicalVolume();
1080   if (pPV) {                                     893   if (pPV) {
1081     os << pPV->GetName()                         894     os << pPV->GetName()
1082        << ' ' << node.GetCopyNo()             << 895        << ':' << node.GetCopyNo()
1083 //       << '[' << node.GetNonCulledDepth() < << 896        << '[' << node.GetNonCulledDepth() << ']'
1084 //       << ':' << node.GetTransform()        << 897        << ':' << node.GetTransform();
1085     ;                                         << 898     if (!node.GetDrawn()) os << "  Not "; os << "drawn";
1086 //    os << " (";                             << 
1087 //    if (!node.GetDrawn()) os << "not ";     << 
1088 //    os << "drawn)";                         << 
1089   } else {                                       899   } else {
1090     os << " (Null PV node)";                  << 900     os << "Null node";
1091   }                                           << 
1092   return os;                                  << 
1093 }                                             << 
1094                                               << 
1095 std::ostream& operator<<                      << 
1096 (std::ostream& os, const std::vector<G4Physic << 
1097 {                                             << 
1098   if (path.empty()) {                         << 
1099     os << " TOP";                             << 
1100   } else {                                    << 
1101     for (const auto& nodeID: path) {          << 
1102       os << ' ' << nodeID;                    << 
1103     }                                         << 
1104   }                                              901   }
1105   return os;                                     902   return os;
1106 }                                                903 }
1107                                                  904 
1108 G4PhysicalVolumeModel::G4PhysicalVolumeModelT    905 G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::G4PhysicalVolumeModelTouchable
1109 (const std::vector<G4PhysicalVolumeNodeID>& f    906 (const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
1110   fFullPVPath(fullPVPath) {}                     907   fFullPVPath(fullPVPath) {}
1111                                                  908 
1112 const G4ThreeVector& G4PhysicalVolumeModel::G    909 const G4ThreeVector& G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetTranslation(G4int depth) const
1113 {                                                910 {
1114   size_t i = fFullPVPath.size() - depth - 1;     911   size_t i = fFullPVPath.size() - depth - 1;
1115   if (i >= fFullPVPath.size()) {                 912   if (i >= fFullPVPath.size()) {
1116     G4Exception("G4PhysicalVolumeModelTouchab    913     G4Exception("G4PhysicalVolumeModelTouchable::GetTranslation",
1117     "modeling0005",                              914     "modeling0005",
1118     FatalErrorInArgument,                        915     FatalErrorInArgument,
1119     "Index out of range. Asking for non-exist    916     "Index out of range. Asking for non-existent depth");
1120   }                                              917   }
1121   static G4ThreeVector tempTranslation;          918   static G4ThreeVector tempTranslation;
1122   tempTranslation = fFullPVPath[i].GetTransfo    919   tempTranslation = fFullPVPath[i].GetTransform().getTranslation();
1123   return tempTranslation;                        920   return tempTranslation;
1124 }                                                921 }
1125                                                  922 
1126 const G4RotationMatrix* G4PhysicalVolumeModel    923 const G4RotationMatrix* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetRotation(G4int depth) const
1127 {                                                924 {
1128   size_t i = fFullPVPath.size() - depth - 1;     925   size_t i = fFullPVPath.size() - depth - 1;
1129   if (i >= fFullPVPath.size()) {                 926   if (i >= fFullPVPath.size()) {
1130     G4Exception("G4PhysicalVolumeModelTouchab    927     G4Exception("G4PhysicalVolumeModelTouchable::GetRotation",
1131     "modeling0006",                              928     "modeling0006",
1132     FatalErrorInArgument,                        929     FatalErrorInArgument,
1133     "Index out of range. Asking for non-exist    930     "Index out of range. Asking for non-existent depth");
1134   }                                              931   }
1135   static G4RotationMatrix tempRotation;          932   static G4RotationMatrix tempRotation;
1136   tempRotation = fFullPVPath[i].GetTransform(    933   tempRotation = fFullPVPath[i].GetTransform().getRotation();
1137   return &tempRotation;                          934   return &tempRotation;
1138 }                                                935 }
1139                                                  936 
1140 G4VPhysicalVolume* G4PhysicalVolumeModel::G4P    937 G4VPhysicalVolume* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetVolume(G4int depth) const
1141 {                                                938 {
1142   size_t i = fFullPVPath.size() - depth - 1;     939   size_t i = fFullPVPath.size() - depth - 1;
1143   if (i >= fFullPVPath.size()) {                 940   if (i >= fFullPVPath.size()) {
1144     G4Exception("G4PhysicalVolumeModelTouchab    941     G4Exception("G4PhysicalVolumeModelTouchable::GetVolume",
1145     "modeling0007",                              942     "modeling0007",
1146     FatalErrorInArgument,                        943     FatalErrorInArgument,
1147     "Index out of range. Asking for non-exist    944     "Index out of range. Asking for non-existent depth");
1148   }                                              945   }
1149   return fFullPVPath[i].GetPhysicalVolume();     946   return fFullPVPath[i].GetPhysicalVolume();
1150 }                                                947 }
1151                                                  948 
1152 G4VSolid* G4PhysicalVolumeModel::G4PhysicalVo    949 G4VSolid* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetSolid(G4int depth) const
1153 {                                                950 {
1154   size_t i = fFullPVPath.size() - depth - 1;     951   size_t i = fFullPVPath.size() - depth - 1;
1155   if (i >= fFullPVPath.size()) {                 952   if (i >= fFullPVPath.size()) {
1156     G4Exception("G4PhysicalVolumeModelTouchab    953     G4Exception("G4PhysicalVolumeModelTouchable::GetSolid",
1157     "modeling0008",                              954     "modeling0008",
1158     FatalErrorInArgument,                        955     FatalErrorInArgument,
1159     "Index out of range. Asking for non-exist    956     "Index out of range. Asking for non-existent depth");
1160   }                                              957   }
1161   return fFullPVPath[i].GetPhysicalVolume()->    958   return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
1162 }                                                959 }
1163                                                  960 
1164 G4int G4PhysicalVolumeModel::G4PhysicalVolume    961 G4int G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetReplicaNumber(G4int depth) const
1165 {                                                962 {
1166   size_t i = fFullPVPath.size() - depth - 1;     963   size_t i = fFullPVPath.size() - depth - 1;
1167   if (i >= fFullPVPath.size()) {                 964   if (i >= fFullPVPath.size()) {
1168     G4Exception("G4PhysicalVolumeModelTouchab    965     G4Exception("G4PhysicalVolumeModelTouchable::GetReplicaNumber",
1169     "modeling0009",                              966     "modeling0009",
1170     FatalErrorInArgument,                        967     FatalErrorInArgument,
1171     "Index out of range. Asking for non-exist    968     "Index out of range. Asking for non-existent depth");
1172   }                                              969   }
1173   return fFullPVPath[i].GetCopyNo();             970   return fFullPVPath[i].GetCopyNo();
1174 }                                                971 }
1175                                                  972