Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/geometry/management/src/G4VSolid.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 /geometry/management/src/G4VSolid.cc (Version 11.3.0) and /geometry/management/src/G4VSolid.cc (Version 9.0.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4VSolid implementation for solid base clas << 
 27 //                                                 26 //
 28 // 10.10.18 E.Tcherniaev, more robust Estimate <<  27 // $Id: G4VSolid.cc,v 1.35 2007/10/24 14:09:27 gcosmo Exp $
 29 // 30.06.95 P.Kent, Created.                   <<  28 // GEANT4 tag $Name: geant4-09-00-patch-02 $
                                                   >>  29 //
                                                   >>  30 // class G4VSolid
                                                   >>  31 //
                                                   >>  32 // Implementation for solid base class
                                                   >>  33 //
                                                   >>  34 // History:
                                                   >>  35 //
                                                   >>  36 //  06.12.02 V.Grichine, restored original conditions in ClipPolygon()
                                                   >>  37 //  10.05.02 V.Grichine, ClipPolygon(): clip only other axis and limited voxels
                                                   >>  38 //  15.04.02 V.Grichine, bug fixed in ClipPolygon(): clip only one axis
                                                   >>  39 //  13.03.02 V.Grichine, cosmetics of voxel limit functions  
                                                   >>  40 //  15.11.00 D.Williams, V.Grichine, fix in CalculateClippedPolygonExtent()
                                                   >>  41 //  10.07.95 P.Kent, Added == operator, solid Store entry
                                                   >>  42 //  30.06.95 P.Kent, Created.
 30 // -------------------------------------------     43 // --------------------------------------------------------------------
 31                                                    44 
 32 #include "G4VSolid.hh"                             45 #include "G4VSolid.hh"
 33 #include "G4SolidStore.hh"                         46 #include "G4SolidStore.hh"
 34 #include "globals.hh"                              47 #include "globals.hh"
 35 #include "G4QuickRand.hh"                      <<  48 #include "Randomize.hh"
 36 #include "G4GeometryTolerance.hh"                  49 #include "G4GeometryTolerance.hh"
 37                                                    50 
 38 #include "G4VoxelLimits.hh"                        51 #include "G4VoxelLimits.hh"
 39 #include "G4AffineTransform.hh"                    52 #include "G4AffineTransform.hh"
 40 #include "G4VisExtent.hh"                          53 #include "G4VisExtent.hh"
 41                                                    54 
 42 //////////////////////////////////////////////     55 //////////////////////////////////////////////////////////////////////////
 43 //                                                 56 //
 44 // Streaming operator dumping solid contents   << 
 45                                                << 
 46 std::ostream& operator<< ( std::ostream& os, c << 
 47 {                                              << 
 48     return e.StreamInfo(os);                   << 
 49 }                                              << 
 50                                                << 
 51 ////////////////////////////////////////////// << 
 52 //                                             << 
 53 // Constructor                                     57 // Constructor
 54 //  - Copies name                                  58 //  - Copies name
 55 //  - Add ourselves to solid Store                 59 //  - Add ourselves to solid Store
 56                                                    60 
 57 G4VSolid::G4VSolid(const G4String& name)           61 G4VSolid::G4VSolid(const G4String& name)
 58   : fshapeName(name)                               62   : fshapeName(name)
 59 {                                                  63 {
 60     kCarTolerance = G4GeometryTolerance::GetIn     64     kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
 61                                                    65 
 62     // Register to store                           66     // Register to store
 63     //                                             67     //
 64     G4SolidStore::GetInstance()->Register(this     68     G4SolidStore::GetInstance()->Register(this);
 65 }                                                  69 }
 66                                                    70 
 67 //////////////////////////////////////////////     71 //////////////////////////////////////////////////////////////////////////
 68 //                                                 72 //
 69 // Copy constructor                            << 
 70 //                                             << 
 71                                                << 
 72 G4VSolid::G4VSolid(const G4VSolid& rhs)        << 
 73   : kCarTolerance(rhs.kCarTolerance), fshapeNa << 
 74 {                                              << 
 75     // Register to store                       << 
 76     //                                         << 
 77     G4SolidStore::GetInstance()->Register(this << 
 78 }                                              << 
 79                                                << 
 80 ////////////////////////////////////////////// << 
 81 //                                             << 
 82 // Fake default constructor - sets only member     73 // Fake default constructor - sets only member data and allocates memory
 83 //                            for usage restri     74 //                            for usage restricted to object persistency.
 84 //                                                 75 //
 85 G4VSolid::G4VSolid( __void__& )                    76 G4VSolid::G4VSolid( __void__& )
 86   : fshapeName("")                                 77   : fshapeName("")
 87 {                                                  78 {
 88     // Register to store                           79     // Register to store
 89     //                                             80     //
 90     G4SolidStore::GetInstance()->Register(this     81     G4SolidStore::GetInstance()->Register(this);
 91 }                                                  82 }
 92                                                    83 
 93 //////////////////////////////////////////////     84 //////////////////////////////////////////////////////////////////////////
 94 //                                                 85 //
 95 // Destructor (virtual)                            86 // Destructor (virtual)
 96 // - Remove ourselves from solid Store             87 // - Remove ourselves from solid Store
 97                                                    88 
 98 G4VSolid::~G4VSolid()                              89 G4VSolid::~G4VSolid()
 99 {                                                  90 {
100     G4SolidStore::GetInstance()->DeRegister(th     91     G4SolidStore::GetInstance()->DeRegister(this);
101 }                                                  92 }
102                                                    93 
103 //////////////////////////////////////////////     94 //////////////////////////////////////////////////////////////////////////
104 //                                                 95 //
105 // Assignment operator                         <<  96 // Streaming operator dumping solid contents
106                                                << 
107 G4VSolid& G4VSolid::operator = (const G4VSolid << 
108 {                                              << 
109    // Check assignment to self                 << 
110    //                                          << 
111    if (this == &rhs)  { return *this; }        << 
112                                                << 
113    // Copy data                                << 
114    //                                          << 
115    kCarTolerance = rhs.kCarTolerance;          << 
116    fshapeName = rhs.fshapeName;                << 
117                                                << 
118    return *this;                               << 
119 }                                              << 
120                                                << 
121                                                << 
122                                                << 
123 ////////////////////////////////////////////// << 
124 //                                             << 
125 // Set solid name and notify store of the chan << 
126                                                    97 
127 void G4VSolid::SetName(const G4String& name)   <<  98 std::ostream& operator<< ( std::ostream& os, const G4VSolid& e )
128 {                                                  99 {
129   fshapeName = name;                           << 100     return e.StreamInfo(os);
130   G4SolidStore::GetInstance()->SetMapValid(fal << 
131 }                                                 101 }
132                                                   102 
133 //////////////////////////////////////////////    103 //////////////////////////////////////////////////////////////////////////
134 //                                                104 //
135 // Throw exception if ComputeDimensions called    105 // Throw exception if ComputeDimensions called for illegal derived class
136                                                   106 
137 void G4VSolid::ComputeDimensions(G4VPVParamete    107 void G4VSolid::ComputeDimensions(G4VPVParameterisation*,
138                                  const G4int,     108                                  const G4int,
139                                  const G4VPhys    109                                  const G4VPhysicalVolume*)
140 {                                                 110 {
141     std::ostringstream message;                << 111     G4cerr << "ERROR - Illegal call to G4VSolid::ComputeDimensions()" << G4endl
142     message << "Illegal call to G4VSolid::Comp << 112            << "        Method not overloaded by derived class !" << G4endl;
143             << "Method not overloaded by deriv << 113     G4Exception("G4VSolid::ComputeDimensions()", "NotApplicable",
144     G4Exception("G4VSolid::ComputeDimensions() << 114                 FatalException, "Illegal call to case class.");
145                 FatalException, message);      << 
146 }                                                 115 }
147                                                   116 
148 //////////////////////////////////////////////    117 //////////////////////////////////////////////////////////////////////////
149 //                                                118 //
150 // Throw exception (warning) for solids not im    119 // Throw exception (warning) for solids not implementing the method
151                                                   120 
152 G4ThreeVector G4VSolid::GetPointOnSurface() co    121 G4ThreeVector G4VSolid::GetPointOnSurface() const
153 {                                                 122 {
154     std::ostringstream message;                << 123     G4cerr << "WARNING - G4VSolid::GetPointOnSurface()" << G4endl
155     message << "Not implemented for solid: "   << 124            << "          Not implemented for solid: "
156             << GetEntityType() << " !" << G4en << 125            << this->GetEntityType() << " !" << G4endl;
157             << "Returning origin.";            << 126     G4Exception("G4VSolid::GetPointOnSurface()", "NotImplemented",
158     G4Exception("G4VSolid::GetPointOnSurface() << 127         JustWarning, "Not implemented for this solid ! Returning origin.");
159                 JustWarning, message);         << 128     return G4ThreeVector(0,0,0);
160     return {0,0,0};                            << 
161 }                                              << 
162                                                << 
163 ////////////////////////////////////////////// << 
164 //                                             << 
165 // Returns total number of constituents that w << 
166 // of the solid. For non-Boolean solids the re << 
167                                                << 
168 G4int G4VSolid::GetNumOfConstituents() const   << 
169 { return 1; }                                  << 
170                                                << 
171 ////////////////////////////////////////////// << 
172 //                                             << 
173 // Returns true if the solid has only planar f << 
174                                                << 
175 G4bool G4VSolid::IsFaceted() const             << 
176 { return false; }                              << 
177                                                << 
178 ////////////////////////////////////////////// << 
179 //                                             << 
180 // Dummy implementations ...                   << 
181                                                << 
182 const G4VSolid* G4VSolid::GetConstituentSolid( << 
183 { return nullptr; }                            << 
184                                                << 
185 G4VSolid* G4VSolid::GetConstituentSolid(G4int) << 
186 { return nullptr; }                            << 
187                                                << 
188 const G4DisplacedSolid* G4VSolid::GetDisplaced << 
189 { return nullptr; }                            << 
190                                                << 
191 G4DisplacedSolid* G4VSolid::GetDisplacedSolidP << 
192 { return nullptr; }                            << 
193                                                << 
194 ////////////////////////////////////////////// << 
195 //                                             << 
196 // Returns an estimation of the solid volume i << 
197 // The number of statistics and error accuracy << 
198 // This method may be overloaded by derived cl << 
199 // exact geometrical quantity for solids where << 
200 // or anyway to cache the computed value.      << 
201 // This implementation does NOT cache the comp << 
202                                                << 
203 G4double G4VSolid::GetCubicVolume()            << 
204 {                                              << 
205   G4int cubVolStatistics = 1000000;            << 
206   G4double cubVolEpsilon = 0.001;              << 
207   return EstimateCubicVolume(cubVolStatistics, << 
208 }                                              << 
209                                                << 
210 ////////////////////////////////////////////// << 
211 //                                             << 
212 // Calculate cubic volume based on Inside() me << 
213 // Accuracy is limited by the second argument  << 
214 // expressed by the first argument.            << 
215 // Implementation is courtesy of Vasiliki Desp << 
216 // University of Athens.                       << 
217                                                << 
218 G4double G4VSolid::EstimateCubicVolume(G4int n << 
219 {                                              << 
220   G4int iInside=0;                             << 
221   G4double px,py,pz,minX,maxX,minY,maxY,minZ,m << 
222   G4ThreeVector p;                             << 
223   EInside in;                                  << 
224                                                << 
225   // values needed for CalculateExtent signatu << 
226                                                << 
227   G4VoxelLimits limit;                // Unlim << 
228   G4AffineTransform origin;                    << 
229                                                << 
230   // min max extents of pSolid along X,Y,Z     << 
231                                                << 
232   CalculateExtent(kXAxis,limit,origin,minX,max << 
233   CalculateExtent(kYAxis,limit,origin,minY,max << 
234   CalculateExtent(kZAxis,limit,origin,minZ,max << 
235                                                << 
236   // limits                                    << 
237                                                << 
238   if(nStat < 100)    nStat   = 100;            << 
239   if(epsilon > 0.01) epsilon = 0.01;           << 
240   halfepsilon = 0.5*epsilon;                   << 
241                                                << 
242   for(auto i = 0; i < nStat; ++i )             << 
243   {                                            << 
244     px = minX-halfepsilon+(maxX-minX+epsilon)* << 
245     py = minY-halfepsilon+(maxY-minY+epsilon)* << 
246     pz = minZ-halfepsilon+(maxZ-minZ+epsilon)* << 
247     p  = G4ThreeVector(px,py,pz);              << 
248     in = Inside(p);                            << 
249     if(in != kOutside) ++iInside;              << 
250   }                                            << 
251   volume = (maxX-minX+epsilon)*(maxY-minY+epsi << 
252          * (maxZ-minZ+epsilon)*iInside/nStat;  << 
253   return volume;                               << 
254 }                                              << 
255                                                << 
256 ////////////////////////////////////////////// << 
257 //                                             << 
258 // Returns an estimation of the solid surface  << 
259 // The number of statistics and error accuracy << 
260 // This method may be overloaded by derived cl << 
261 // exact geometrical quantity for solids where << 
262 // or anyway to cache the computed value.      << 
263 // This implementation does NOT cache the comp << 
264                                                << 
265 G4double G4VSolid::GetSurfaceArea()            << 
266 {                                              << 
267   G4int stat = 1000000;                        << 
268   G4double ell = -1.;                          << 
269   return EstimateSurfaceArea(stat,ell);        << 
270 }                                              << 
271                                                << 
272 ////////////////////////////////////////////// << 
273 //                                             << 
274 // Calculate surface area by estimating volume << 
275 // surrounding the surface using Monte-Carlo m << 
276 // Input parameters:                           << 
277 //    nstat - statistics (number of random poi << 
278 //    eps   - shell thinkness                  << 
279                                                << 
280 G4double G4VSolid::EstimateSurfaceArea(G4int n << 
281 {                                              << 
282   static const G4double s2 = 1./std::sqrt(2.); << 
283   static const G4double s3 = 1./std::sqrt(3.); << 
284   static const G4ThreeVector directions[64] =  << 
285   {                                            << 
286     G4ThreeVector(  0,  0,  0), G4ThreeVector( << 
287     G4ThreeVector(  1,  0,  0), G4ThreeVector( << 
288     G4ThreeVector(  0, -1,  0), G4ThreeVector( << 
289     G4ThreeVector( s2, -s2, 0), G4ThreeVector( << 
290                                                << 
291     G4ThreeVector(  0,  1,  0), G4ThreeVector( << 
292     G4ThreeVector( s2, s2,  0), G4ThreeVector( << 
293     G4ThreeVector(  0, -1,  0), G4ThreeVector( << 
294     G4ThreeVector(  1,  0,  0), G4ThreeVector( << 
295                                                << 
296     G4ThreeVector(  0,  0, -1), G4ThreeVector( << 
297     G4ThreeVector( s2,  0,-s2), G4ThreeVector( << 
298     G4ThreeVector(  0,-s2,-s2), G4ThreeVector( << 
299     G4ThreeVector( s3,-s3,-s3), G4ThreeVector( << 
300                                                << 
301     G4ThreeVector(  0, s2,-s2), G4ThreeVector( << 
302     G4ThreeVector( s3, s3,-s3), G4ThreeVector( << 
303     G4ThreeVector(  0,  0, -1), G4ThreeVector( << 
304     G4ThreeVector( s2,  0,-s2), G4ThreeVector( << 
305                                                << 
306     G4ThreeVector(  0,  0,  1), G4ThreeVector( << 
307     G4ThreeVector( s2,  0, s2), G4ThreeVector( << 
308     G4ThreeVector(  0,-s2, s2), G4ThreeVector( << 
309     G4ThreeVector( s3,-s3, s3), G4ThreeVector( << 
310                                                << 
311     G4ThreeVector(  0, s2, s2), G4ThreeVector( << 
312     G4ThreeVector( s3, s3, s3), G4ThreeVector( << 
313     G4ThreeVector(  0,  0,  1), G4ThreeVector( << 
314     G4ThreeVector( s2,  0, s2), G4ThreeVector( << 
315                                                << 
316     G4ThreeVector(  0,  0, -1), G4ThreeVector( << 
317     G4ThreeVector(  1,  0,  0), G4ThreeVector( << 
318     G4ThreeVector(  0, -1,  0), G4ThreeVector( << 
319     G4ThreeVector( s2, -s2, 0), G4ThreeVector( << 
320                                                << 
321     G4ThreeVector(  0,  1,  0), G4ThreeVector( << 
322     G4ThreeVector( s2, s2,  0), G4ThreeVector( << 
323     G4ThreeVector(  0, -1,  0), G4ThreeVector( << 
324     G4ThreeVector(  1,  0,  0), G4ThreeVector( << 
325   };                                           << 
326                                                << 
327   G4ThreeVector bmin, bmax;                    << 
328   BoundingLimits(bmin, bmax);                  << 
329                                                << 
330   G4double dX = bmax.x() - bmin.x();           << 
331   G4double dY = bmax.y() - bmin.y();           << 
332   G4double dZ = bmax.z() - bmin.z();           << 
333                                                << 
334   // Define statistics and shell thickness     << 
335   //                                           << 
336   G4int npoints = (nstat < 1000) ? 1000 : nsta << 
337   G4double coeff = 0.5 / std::cbrt(G4double(np << 
338   G4double eps = (ell > 0) ? ell : coeff * std << 
339   G4double del = 1.8 * eps; // shold be more t << 
340                                                << 
341   G4double minX = bmin.x() - eps;              << 
342   G4double minY = bmin.y() - eps;              << 
343   G4double minZ = bmin.z() - eps;              << 
344                                                << 
345   G4double dd = 2. * eps;                      << 
346   dX += dd;                                    << 
347   dY += dd;                                    << 
348   dZ += dd;                                    << 
349                                                << 
350   // Calculate surface area                    << 
351   //                                           << 
352   G4int icount = 0;                            << 
353   for(auto i = 0; i < npoints; ++i)            << 
354   {                                            << 
355     G4double px = minX + dX*G4QuickRand();     << 
356     G4double py = minY + dY*G4QuickRand();     << 
357     G4double pz = minZ + dZ*G4QuickRand();     << 
358     G4ThreeVector p  = G4ThreeVector(px, py, p << 
359     EInside in = Inside(p);                    << 
360     G4double dist = 0;                         << 
361     if (in == kInside)                         << 
362     {                                          << 
363       if (DistanceToOut(p) >= eps) continue;   << 
364       G4int icase = 0;                         << 
365       if (Inside(G4ThreeVector(px-del, py, pz) << 
366       if (Inside(G4ThreeVector(px+del, py, pz) << 
367       if (Inside(G4ThreeVector(px, py-del, pz) << 
368       if (Inside(G4ThreeVector(px, py+del, pz) << 
369       if (Inside(G4ThreeVector(px, py, pz-del) << 
370       if (Inside(G4ThreeVector(px, py, pz+del) << 
371       if (icase == 0) continue;                << 
372       G4ThreeVector v = directions[icase];     << 
373       dist = DistanceToOut(p, v);              << 
374       G4ThreeVector n = SurfaceNormal(p + v*di << 
375       dist *= v.dot(n);                        << 
376     }                                          << 
377     else if (in == kOutside)                   << 
378     {                                          << 
379       if (DistanceToIn(p) >= eps) continue;    << 
380       G4int icase = 0;                         << 
381       if (Inside(G4ThreeVector(px-del, py, pz) << 
382       if (Inside(G4ThreeVector(px+del, py, pz) << 
383       if (Inside(G4ThreeVector(px, py-del, pz) << 
384       if (Inside(G4ThreeVector(px, py+del, pz) << 
385       if (Inside(G4ThreeVector(px, py, pz-del) << 
386       if (Inside(G4ThreeVector(px, py, pz+del) << 
387       if (icase == 0) continue;                << 
388       G4ThreeVector v = directions[icase];     << 
389       dist = DistanceToIn(p, v);               << 
390       if (dist == kInfinity) continue;         << 
391       G4ThreeVector n = SurfaceNormal(p + v*di << 
392       dist *= -(v.dot(n));                     << 
393     }                                          << 
394     if (dist < eps) ++icount;                  << 
395   }                                            << 
396   return dX*dY*dZ*icount/npoints/dd;           << 
397 }                                              << 
398                                                << 
399 ////////////////////////////////////////////// << 
400 //                                             << 
401 // Returns a pointer of a dynamically allocate << 
402 // Returns NULL pointer with warning in case t << 
403 // implement this method. The caller has respo << 
404 //                                             << 
405                                                << 
406 G4VSolid* G4VSolid::Clone() const              << 
407 {                                              << 
408   std::ostringstream message;                  << 
409   message << "Clone() method not implemented f << 
410           << GetEntityType() << "!" << G4endl  << 
411           << "Returning NULL pointer!";        << 
412   G4Exception("G4VSolid::Clone()", "GeomMgt100 << 
413   return nullptr;                              << 
414 }                                                 129 }
415                                                   130 
416 //////////////////////////////////////////////    131 ///////////////////////////////////////////////////////////////////////////
417 //                                             << 132 // 
418 // Calculate the maximum and minimum extents o    133 // Calculate the maximum and minimum extents of the polygon described
419 // by the vertices: pSectionIndex->pSectionInd    134 // by the vertices: pSectionIndex->pSectionIndex+1->
420 //                   pSectionIndex+2->pSection    135 //                   pSectionIndex+2->pSectionIndex+3->pSectionIndex
421 // in the List pVertices                          136 // in the List pVertices
422 //                                                137 //
423 // If the minimum is <pMin pMin is set to the     138 // If the minimum is <pMin pMin is set to the new minimum
424 // If the maximum is >pMax pMax is set to the     139 // If the maximum is >pMax pMax is set to the new maximum
425 //                                                140 //
426 // No modifications are made to pVertices         141 // No modifications are made to pVertices
427 //                                                142 //
428                                                   143 
429 void G4VSolid::ClipCrossSection(       G4Three    144 void G4VSolid::ClipCrossSection(       G4ThreeVectorList* pVertices,
430                                  const G4int p    145                                  const G4int pSectionIndex,
431                                  const G4Voxel    146                                  const G4VoxelLimits& pVoxelLimit,
432                                  const EAxis p << 147                                  const EAxis pAxis, 
433                                        G4doubl    148                                        G4double& pMin, G4double& pMax) const
434 {                                                 149 {
435                                                   150 
436   G4ThreeVectorList polygon;                      151   G4ThreeVectorList polygon;
437   polygon.reserve(4);                          << 
438   polygon.push_back((*pVertices)[pSectionIndex    152   polygon.push_back((*pVertices)[pSectionIndex]);
439   polygon.push_back((*pVertices)[pSectionIndex    153   polygon.push_back((*pVertices)[pSectionIndex+1]);
440   polygon.push_back((*pVertices)[pSectionIndex    154   polygon.push_back((*pVertices)[pSectionIndex+2]);
441   polygon.push_back((*pVertices)[pSectionIndex    155   polygon.push_back((*pVertices)[pSectionIndex+3]);
                                                   >> 156   //  G4cout<<"ClipCrossSection: 0-1-2-3"<<G4endl;
442   CalculateClippedPolygonExtent(polygon,pVoxel    157   CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
443   return;                                         158   return;
444 }                                                 159 }
445                                                   160 
446 //////////////////////////////////////////////    161 //////////////////////////////////////////////////////////////////////////////////
447 //                                                162 //
448 // Calculate the maximum and minimum extents o    163 // Calculate the maximum and minimum extents of the polygons
449 // joining the CrossSections at pSectionIndex-    164 // joining the CrossSections at pSectionIndex->pSectionIndex+3 and
450 //                              pSectionIndex+    165 //                              pSectionIndex+4->pSectionIndex7
451 //                                                166 //
452 // in the List pVertices, within the boundarie    167 // in the List pVertices, within the boundaries of the voxel limits pVoxelLimit
453 //                                                168 //
454 // If the minimum is <pMin pMin is set to the     169 // If the minimum is <pMin pMin is set to the new minimum
455 // If the maximum is >pMax pMax is set to the     170 // If the maximum is >pMax pMax is set to the new maximum
456 //                                                171 //
457 // No modifications are made to pVertices         172 // No modifications are made to pVertices
458                                                   173 
459 void G4VSolid::ClipBetweenSections(      G4Thr    174 void G4VSolid::ClipBetweenSections(      G4ThreeVectorList* pVertices,
460                                    const G4int    175                                    const G4int pSectionIndex,
461                                    const G4Vox    176                                    const G4VoxelLimits& pVoxelLimit,
462                                    const EAxis << 177                                    const EAxis pAxis, 
463                                          G4dou    178                                          G4double& pMin, G4double& pMax) const
464 {                                                 179 {
465   G4ThreeVectorList polygon;                      180   G4ThreeVectorList polygon;
466   polygon.reserve(4);                          << 
467   polygon.push_back((*pVertices)[pSectionIndex    181   polygon.push_back((*pVertices)[pSectionIndex]);
468   polygon.push_back((*pVertices)[pSectionIndex    182   polygon.push_back((*pVertices)[pSectionIndex+4]);
469   polygon.push_back((*pVertices)[pSectionIndex    183   polygon.push_back((*pVertices)[pSectionIndex+5]);
470   polygon.push_back((*pVertices)[pSectionIndex    184   polygon.push_back((*pVertices)[pSectionIndex+1]);
                                                   >> 185   // G4cout<<"ClipBetweenSections: 0-4-5-1"<<G4endl;
471   CalculateClippedPolygonExtent(polygon,pVoxel    186   CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
472   polygon.clear();                                187   polygon.clear();
473                                                   188 
474   polygon.push_back((*pVertices)[pSectionIndex    189   polygon.push_back((*pVertices)[pSectionIndex+1]);
475   polygon.push_back((*pVertices)[pSectionIndex    190   polygon.push_back((*pVertices)[pSectionIndex+5]);
476   polygon.push_back((*pVertices)[pSectionIndex    191   polygon.push_back((*pVertices)[pSectionIndex+6]);
477   polygon.push_back((*pVertices)[pSectionIndex    192   polygon.push_back((*pVertices)[pSectionIndex+2]);
                                                   >> 193   // G4cout<<"ClipBetweenSections: 1-5-6-2"<<G4endl;
478   CalculateClippedPolygonExtent(polygon,pVoxel    194   CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
479   polygon.clear();                                195   polygon.clear();
480                                                   196 
481   polygon.push_back((*pVertices)[pSectionIndex    197   polygon.push_back((*pVertices)[pSectionIndex+2]);
482   polygon.push_back((*pVertices)[pSectionIndex    198   polygon.push_back((*pVertices)[pSectionIndex+6]);
483   polygon.push_back((*pVertices)[pSectionIndex    199   polygon.push_back((*pVertices)[pSectionIndex+7]);
484   polygon.push_back((*pVertices)[pSectionIndex    200   polygon.push_back((*pVertices)[pSectionIndex+3]);
                                                   >> 201   //  G4cout<<"ClipBetweenSections: 2-6-7-3"<<G4endl;
485   CalculateClippedPolygonExtent(polygon,pVoxel    202   CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
486   polygon.clear();                                203   polygon.clear();
487                                                   204 
488   polygon.push_back((*pVertices)[pSectionIndex    205   polygon.push_back((*pVertices)[pSectionIndex+3]);
489   polygon.push_back((*pVertices)[pSectionIndex    206   polygon.push_back((*pVertices)[pSectionIndex+7]);
490   polygon.push_back((*pVertices)[pSectionIndex    207   polygon.push_back((*pVertices)[pSectionIndex+4]);
491   polygon.push_back((*pVertices)[pSectionIndex    208   polygon.push_back((*pVertices)[pSectionIndex]);
                                                   >> 209   //  G4cout<<"ClipBetweenSections: 3-7-4-0"<<G4endl;
492   CalculateClippedPolygonExtent(polygon,pVoxel    210   CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
493   return;                                         211   return;
494 }                                                 212 }
495                                                   213 
496                                                   214 
497 //////////////////////////////////////////////    215 ///////////////////////////////////////////////////////////////////////////////
498 //                                                216 //
499 // Calculate the maximum and minimum extents o    217 // Calculate the maximum and minimum extents of the convex polygon pPolygon
500 // along the axis pAxis, within the limits pVo    218 // along the axis pAxis, within the limits pVoxelLimit
501 //                                                219 //
502                                                   220 
503 void                                              221 void
504 G4VSolid::CalculateClippedPolygonExtent(G4Thre    222 G4VSolid::CalculateClippedPolygonExtent(G4ThreeVectorList& pPolygon,
505                                   const G4Voxe    223                                   const G4VoxelLimits& pVoxelLimit,
506                                   const EAxis  << 224                                   const EAxis pAxis, 
507                                         G4doub    225                                         G4double& pMin,
508                                         G4doub    226                                         G4double& pMax) const
509 {                                                 227 {
510   G4int noLeft,i;                                 228   G4int noLeft,i;
511   G4double component;                             229   G4double component;
512                                                << 230   /*  
                                                   >> 231   G4cout<<G4endl;
                                                   >> 232   for(i = 0 ; i < pPolygon.size() ; i++ )
                                                   >> 233   {
                                                   >> 234       G4cout << i << "\t"
                                                   >> 235              << "p.x = " << pPolygon[i].operator()(pAxis) << "\t"
                                                   >> 236         //   << "p.y = " << pPolygon[i].y() << "\t"
                                                   >> 237         //   << "p.z = " << pPolygon[i].z() << "\t"
                                                   >> 238              << G4endl;
                                                   >> 239   }    
                                                   >> 240   G4cout<<G4endl;
                                                   >> 241   */  
513   ClipPolygon(pPolygon,pVoxelLimit,pAxis);        242   ClipPolygon(pPolygon,pVoxelLimit,pAxis);
514   noLeft = (G4int)pPolygon.size();             << 243   noLeft = pPolygon.size();
515                                                   244 
516   if ( noLeft != 0 )                           << 245   if ( noLeft )
517   {                                               246   {
518     for (i=0; i<noLeft; ++i)                   << 247     //  G4cout<<G4endl;
                                                   >> 248     for (i=0;i<noLeft;i++)
519     {                                             249     {
520       component = pPolygon[i].operator()(pAxis    250       component = pPolygon[i].operator()(pAxis);
521                                                << 251       //  G4cout <<i<<"\t"<<component<<G4endl;
522       if (component < pMin)                    << 252  
523       {                                        << 253       if (component < pMin) 
524         pMin = component;                      << 254       { 
                                                   >> 255         //  G4cout <<i<<"\t"<<"Pmin = "<<component<<G4endl;
                                                   >> 256         pMin = component;      
525       }                                           257       }
526       if (component > pMax)                       258       if (component > pMax)
527       {                                        << 259       {  
528         pMax = component;                      << 260         //  G4cout <<i<<"\t"<<"PMax = "<<component<<G4endl;
529       }                                        << 261         pMax = component;  
                                                   >> 262       }    
530     }                                             263     }
                                                   >> 264     //  G4cout<<G4endl;
531   }                                               265   }
                                                   >> 266   // G4cout<<"pMin = "<<pMin<<"\t"<<"pMax = "<<pMax<<G4endl;
532 }                                                 267 }
533                                                   268 
534 //////////////////////////////////////////////    269 /////////////////////////////////////////////////////////////////////////////
535 //                                                270 //
536 // Clip the convex polygon described by the ve    271 // Clip the convex polygon described by the vertices at
537 // pSectionIndex ->pSectionIndex+3 within pVer    272 // pSectionIndex ->pSectionIndex+3 within pVertices to the limits pVoxelLimit
538 //                                                273 //
539 // Set pMin to the smallest                       274 // Set pMin to the smallest
540 //                                                275 //
541 // Calculate the extent of the polygon along p    276 // Calculate the extent of the polygon along pAxis, when clipped to the
542 // limits pVoxelLimit. If the polygon exists a    277 // limits pVoxelLimit. If the polygon exists after clippin, set pMin to
543 // the polygon's minimum extent along the axis    278 // the polygon's minimum extent along the axis if <pMin, and set pMax to
544 // the polygon's maximum extent along the axis    279 // the polygon's maximum extent along the axis if >pMax.
545 //                                                280 //
546 // The polygon is described by a set of vector    281 // The polygon is described by a set of vectors, where each vector represents
547 // a vertex, so that the polygon is described     282 // a vertex, so that the polygon is described by the vertex sequence:
548 //   0th->1st 1st->2nd 2nd->... nth->0th          283 //   0th->1st 1st->2nd 2nd->... nth->0th
549 //                                                284 //
550 // Modifications to the polygon are made          285 // Modifications to the polygon are made
551 //                                                286 //
552 // NOTE: Execessive copying during clipping       287 // NOTE: Execessive copying during clipping
553                                                   288 
554 void G4VSolid::ClipPolygon(      G4ThreeVector    289 void G4VSolid::ClipPolygon(      G4ThreeVectorList& pPolygon,
555                            const G4VoxelLimits    290                            const G4VoxelLimits& pVoxelLimit,
556                            const EAxis            291                            const EAxis                        ) const
557 {                                                 292 {
558   G4ThreeVectorList outputPolygon;                293   G4ThreeVectorList outputPolygon;
559                                                   294 
560   if ( pVoxelLimit.IsLimited() )                  295   if ( pVoxelLimit.IsLimited() )
561   {                                               296   {
562     if (pVoxelLimit.IsXLimited() ) // && pAxis    297     if (pVoxelLimit.IsXLimited() ) // && pAxis != kXAxis)
563     {                                             298     {
564       G4VoxelLimits simpleLimit1;                 299       G4VoxelLimits simpleLimit1;
565       simpleLimit1.AddLimit(kXAxis,pVoxelLimit    300       simpleLimit1.AddLimit(kXAxis,pVoxelLimit.GetMinXExtent(),kInfinity);
                                                   >> 301       //  G4cout<<"MinXExtent()"<<G4endl;
566       ClipPolygonToSimpleLimits(pPolygon,outpu    302       ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
567                                                << 303    
568       pPolygon.clear();                           304       pPolygon.clear();
569                                                   305 
570       if ( outputPolygon.empty() )  return;    << 306       if ( !outputPolygon.size() )  return;
571                                                   307 
572       G4VoxelLimits simpleLimit2;                 308       G4VoxelLimits simpleLimit2;
                                                   >> 309       //  G4cout<<"MaxXExtent()"<<G4endl;
573       simpleLimit2.AddLimit(kXAxis,-kInfinity,    310       simpleLimit2.AddLimit(kXAxis,-kInfinity,pVoxelLimit.GetMaxXExtent());
574       ClipPolygonToSimpleLimits(outputPolygon,    311       ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
575                                                   312 
576       if ( pPolygon.empty() )       return;    << 313       if ( !pPolygon.size() )       return;
577       else                          outputPoly    314       else                          outputPolygon.clear();
578     }                                             315     }
579     if ( pVoxelLimit.IsYLimited() ) // && pAxi    316     if ( pVoxelLimit.IsYLimited() ) // && pAxis != kYAxis)
580     {                                             317     {
581       G4VoxelLimits simpleLimit1;                 318       G4VoxelLimits simpleLimit1;
582       simpleLimit1.AddLimit(kYAxis,pVoxelLimit    319       simpleLimit1.AddLimit(kYAxis,pVoxelLimit.GetMinYExtent(),kInfinity);
583       ClipPolygonToSimpleLimits(pPolygon,outpu    320       ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
584                                                   321 
585       // Must always clear pPolygon - for clip    322       // Must always clear pPolygon - for clip to simpleLimit2 and in case of
586       // early exit                               323       // early exit
587                                                   324 
588       pPolygon.clear();                           325       pPolygon.clear();
589                                                   326 
590       if ( outputPolygon.empty() )  return;    << 327       if ( !outputPolygon.size() )  return;
591                                                   328 
592       G4VoxelLimits simpleLimit2;                 329       G4VoxelLimits simpleLimit2;
593       simpleLimit2.AddLimit(kYAxis,-kInfinity,    330       simpleLimit2.AddLimit(kYAxis,-kInfinity,pVoxelLimit.GetMaxYExtent());
594       ClipPolygonToSimpleLimits(outputPolygon,    331       ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
595                                                   332 
596       if ( pPolygon.empty() )       return;    << 333       if ( !pPolygon.size() )       return;
597       else                          outputPoly    334       else                          outputPolygon.clear();
598     }                                             335     }
599     if ( pVoxelLimit.IsZLimited() ) // && pAxi    336     if ( pVoxelLimit.IsZLimited() ) // && pAxis != kZAxis)
600     {                                             337     {
601       G4VoxelLimits simpleLimit1;                 338       G4VoxelLimits simpleLimit1;
602       simpleLimit1.AddLimit(kZAxis,pVoxelLimit    339       simpleLimit1.AddLimit(kZAxis,pVoxelLimit.GetMinZExtent(),kInfinity);
603       ClipPolygonToSimpleLimits(pPolygon,outpu    340       ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
604                                                   341 
605       // Must always clear pPolygon - for clip    342       // Must always clear pPolygon - for clip to simpleLimit2 and in case of
606       // early exit                               343       // early exit
607                                                   344 
608       pPolygon.clear();                           345       pPolygon.clear();
609                                                   346 
610       if ( outputPolygon.empty() )  return;    << 347       if ( !outputPolygon.size() )  return;
611                                                   348 
612       G4VoxelLimits simpleLimit2;                 349       G4VoxelLimits simpleLimit2;
613       simpleLimit2.AddLimit(kZAxis,-kInfinity,    350       simpleLimit2.AddLimit(kZAxis,-kInfinity,pVoxelLimit.GetMaxZExtent());
614       ClipPolygonToSimpleLimits(outputPolygon,    351       ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
615                                                   352 
616       // Return after final clip - no cleanup     353       // Return after final clip - no cleanup
617     }                                             354     }
618   }                                               355   }
619 }                                                 356 }
620                                                   357 
621 //////////////////////////////////////////////    358 ////////////////////////////////////////////////////////////////////////////
622 //                                                359 //
623 // pVoxelLimits must be only limited along one    360 // pVoxelLimits must be only limited along one axis, and either the maximum
624 // along the axis must be +kInfinity, or the m    361 // along the axis must be +kInfinity, or the minimum -kInfinity
625                                                   362 
626 void                                              363 void
627 G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVe    364 G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
628                                      G4ThreeVe    365                                      G4ThreeVectorList& outputPolygon,
629                                const G4VoxelLi    366                                const G4VoxelLimits& pVoxelLimit       ) const
630 {                                                 367 {
631   G4int i;                                        368   G4int i;
632   auto  noVertices = (G4int)pPolygon.size();   << 369   G4int noVertices=pPolygon.size();
633   G4ThreeVector vEnd,vStart;                      370   G4ThreeVector vEnd,vStart;
634                                                   371 
635   for (i = 0 ; i < noVertices ; ++i )          << 372   for (i = 0 ; i < noVertices ; i++ )
636   {                                               373   {
637     vStart = pPolygon[i];                         374     vStart = pPolygon[i];
                                                   >> 375     // G4cout << "i = " << i << G4endl;
638     if ( i == noVertices-1 )    vEnd = pPolygo    376     if ( i == noVertices-1 )    vEnd = pPolygon[0];
639     else                        vEnd = pPolygo    377     else                        vEnd = pPolygon[i+1];
640                                                   378 
641     if ( pVoxelLimit.Inside(vStart) )             379     if ( pVoxelLimit.Inside(vStart) )
642     {                                             380     {
643       if (pVoxelLimit.Inside(vEnd))               381       if (pVoxelLimit.Inside(vEnd))
644       {                                           382       {
645         // vStart and vEnd inside -> output en    383         // vStart and vEnd inside -> output end point
646         //                                        384         //
647         outputPolygon.push_back(vEnd);            385         outputPolygon.push_back(vEnd);
648       }                                           386       }
649       else                                        387       else
650       {                                           388       {
651         // vStart inside, vEnd outside -> outp    389         // vStart inside, vEnd outside -> output crossing point
652         //                                        390         //
                                                   >> 391         // G4cout << "vStart inside, vEnd outside" << G4endl;
653         pVoxelLimit.ClipToLimits(vStart,vEnd);    392         pVoxelLimit.ClipToLimits(vStart,vEnd);
654         outputPolygon.push_back(vEnd);            393         outputPolygon.push_back(vEnd);
655       }                                        << 394       }    
656     }                                             395     }
657     else                                          396     else
658     {                                             397     {
659       if (pVoxelLimit.Inside(vEnd))               398       if (pVoxelLimit.Inside(vEnd))
660       {                                           399       {
661         // vStart outside, vEnd inside -> outp    400         // vStart outside, vEnd inside -> output inside section
662         //                                        401         //
                                                   >> 402         // G4cout << "vStart outside, vEnd inside" << G4endl;
663         pVoxelLimit.ClipToLimits(vStart,vEnd);    403         pVoxelLimit.ClipToLimits(vStart,vEnd);
664         outputPolygon.push_back(vStart);          404         outputPolygon.push_back(vStart);
665         outputPolygon.push_back(vEnd);         << 405         outputPolygon.push_back(vEnd);  
666       }                                           406       }
667       else  // Both point outside -> no output    407       else  // Both point outside -> no output
668       {                                           408       {
669         // outputPolygon.push_back(vStart);       409         // outputPolygon.push_back(vStart);
670         // outputPolygon.push_back(vEnd);      << 410         // outputPolygon.push_back(vEnd);  
671       }                                           411       }
672     }                                             412     }
673   }                                               413   }
674 }                                                 414 }
675                                                   415 
676 ////////////////////////////////////////////// << 416 const G4VSolid* G4VSolid::GetConstituentSolid(G4int) const
677 //                                             << 417 { return 0; } 
678 // Throw exception (warning) for solids not im << 
679                                                   418 
680 void G4VSolid::BoundingLimits(G4ThreeVector& p << 419 G4VSolid* G4VSolid::GetConstituentSolid(G4int)
681 {                                              << 420 { return 0; } 
682   std::ostringstream message;                  << 
683   message << "Not implemented for solid: "     << 
684           << GetEntityType() << " !"           << 
685           << "\nReturning infinite boundinx bo << 
686   G4Exception("G4VSolid::BoundingLimits()", "G << 
687               JustWarning, message);           << 
688                                                   421 
689   pMin.set(-kInfinity,-kInfinity,-kInfinity);  << 422 const G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr() const
690   pMax.set( kInfinity, kInfinity, kInfinity);  << 423 { return 0; } 
691 }                                              << 
692                                                   424 
693 ////////////////////////////////////////////// << 425 G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr() 
694 //                                             << 426 { return 0; } 
695 // Get G4VisExtent - bounding box for graphics << 
696                                                   427 
697 G4VisExtent G4VSolid::GetExtent () const       << 428 G4VisExtent G4VSolid::GetExtent () const 
698 {                                                 429 {
699   G4VisExtent extent;                             430   G4VisExtent extent;
700   G4VoxelLimits voxelLimits;  // Defaults to "    431   G4VoxelLimits voxelLimits;  // Defaults to "infinite" limits.
701   G4AffineTransform affineTransform;              432   G4AffineTransform affineTransform;
702   G4double vmin, vmax;                            433   G4double vmin, vmax;
703   CalculateExtent(kXAxis,voxelLimits,affineTra    434   CalculateExtent(kXAxis,voxelLimits,affineTransform,vmin,vmax);
704   extent.SetXmin (vmin);                          435   extent.SetXmin (vmin);
705   extent.SetXmax (vmax);                          436   extent.SetXmax (vmax);
706   CalculateExtent(kYAxis,voxelLimits,affineTra    437   CalculateExtent(kYAxis,voxelLimits,affineTransform,vmin,vmax);
707   extent.SetYmin (vmin);                          438   extent.SetYmin (vmin);
708   extent.SetYmax (vmax);                          439   extent.SetYmax (vmax);
709   CalculateExtent(kZAxis,voxelLimits,affineTra    440   CalculateExtent(kZAxis,voxelLimits,affineTransform,vmin,vmax);
710   extent.SetZmin (vmin);                          441   extent.SetZmin (vmin);
711   extent.SetZmax (vmax);                          442   extent.SetZmax (vmax);
712   return extent;                                  443   return extent;
713 }                                                 444 }
714                                                   445 
715 G4Polyhedron* G4VSolid::CreatePolyhedron () co    446 G4Polyhedron* G4VSolid::CreatePolyhedron () const
716 {                                                 447 {
717   return nullptr;                              << 448   return 0;
                                                   >> 449 }
                                                   >> 450 
                                                   >> 451 G4NURBS* G4VSolid::CreateNURBS () const
                                                   >> 452 {
                                                   >> 453   return 0;
718 }                                                 454 }
719                                                   455 
720 G4Polyhedron* G4VSolid::GetPolyhedron () const    456 G4Polyhedron* G4VSolid::GetPolyhedron () const
721 {                                                 457 {
722   return nullptr;                              << 458   return 0;
                                                   >> 459 }
                                                   >> 460 
                                                   >> 461 ////////////////////////////////////////////////////////////////
                                                   >> 462 //
                                                   >> 463 // Returns an estimation of the solid volume in internal units.
                                                   >> 464 // The number of statistics and error accuracy is fixed.
                                                   >> 465 // This method may be overloaded by derived classes to compute the
                                                   >> 466 // exact geometrical quantity for solids where this is possible.
                                                   >> 467 // or anyway to cache the computed value.
                                                   >> 468 // This implementation does NOT cache the computed value.
                                                   >> 469 
                                                   >> 470 G4double G4VSolid::GetCubicVolume()
                                                   >> 471 {
                                                   >> 472   G4int cubVolStatistics = 1000000;
                                                   >> 473   G4double cubVolEpsilon = 0.001;
                                                   >> 474   return EstimateCubicVolume(cubVolStatistics, cubVolEpsilon);
                                                   >> 475 }
                                                   >> 476 
                                                   >> 477 ////////////////////////////////////////////////////////////////
                                                   >> 478 //
                                                   >> 479 // Calculate cubic volume based on Inside() method.
                                                   >> 480 // Accuracy is limited by the second argument or the statistics
                                                   >> 481 // expressed by the first argument.
                                                   >> 482 // Implementation is courtesy of Vasiliki Despoina Mitsou,
                                                   >> 483 // University of Athens.
                                                   >> 484 
                                                   >> 485 G4double G4VSolid::EstimateCubicVolume(G4int nStat, G4double epsilon) const
                                                   >> 486 {
                                                   >> 487   G4int iInside=0;
                                                   >> 488   G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,volume;
                                                   >> 489   G4bool yesno;
                                                   >> 490   G4ThreeVector p;
                                                   >> 491   EInside in;
                                                   >> 492 
                                                   >> 493   // values needed for CalculateExtent signature
                                                   >> 494 
                                                   >> 495   G4VoxelLimits limit;                // Unlimited
                                                   >> 496   G4AffineTransform origin;
                                                   >> 497 
                                                   >> 498   // min max extents of pSolid along X,Y,Z
                                                   >> 499 
                                                   >> 500   yesno = this->CalculateExtent(kXAxis,limit,origin,minX,maxX);
                                                   >> 501   yesno = this->CalculateExtent(kYAxis,limit,origin,minY,maxY);
                                                   >> 502   yesno = this->CalculateExtent(kZAxis,limit,origin,minZ,maxZ);
                                                   >> 503 
                                                   >> 504   // limits
                                                   >> 505 
                                                   >> 506   if(nStat < 100)    nStat   = 100;
                                                   >> 507   if(epsilon > 0.01) epsilon = 0.01;
                                                   >> 508 
                                                   >> 509   for(G4int i = 0; i < nStat; i++ )
                                                   >> 510   {
                                                   >> 511     px = minX+(maxX-minX)*G4UniformRand();
                                                   >> 512     py = minY+(maxY-minY)*G4UniformRand();
                                                   >> 513     pz = minZ+(maxZ-minZ)*G4UniformRand();
                                                   >> 514     p  = G4ThreeVector(px,py,pz);
                                                   >> 515     in = this->Inside(p);
                                                   >> 516     if(in != kOutside) iInside++;    
                                                   >> 517   }
                                                   >> 518   volume = (maxX-minX)*(maxY-minY)*(maxZ-minZ)*iInside/nStat;
                                                   >> 519   return volume;
                                                   >> 520 }
                                                   >> 521 
                                                   >> 522 ////////////////////////////////////////////////////////////////
                                                   >> 523 //
                                                   >> 524 // Returns an estimation of the solid surface area in internal units.
                                                   >> 525 // The number of statistics and error accuracy is fixed.
                                                   >> 526 // This method may be overloaded by derived classes to compute the
                                                   >> 527 // exact geometrical quantity for solids where this is possible.
                                                   >> 528 // or anyway to cache the computed value.
                                                   >> 529 // This implementation does NOT cache the computed value.
                                                   >> 530 
                                                   >> 531 G4double G4VSolid::GetSurfaceArea()
                                                   >> 532 {
                                                   >> 533   G4int stat = 1000000;
                                                   >> 534   G4double ell = -1.;
                                                   >> 535   return EstimateSurfaceArea(stat,ell);
                                                   >> 536 }
                                                   >> 537 
                                                   >> 538 ////////////////////////////////////////////////////////////////
                                                   >> 539 //
                                                   >> 540 // Estimate surface area based on Inside(), DistanceToIn(), and
                                                   >> 541 // DistanceToOut() methods. Accuracy is limited by the statistics
                                                   >> 542 // defined by the first argument. Implemented by Mikhail Kosov.
                                                   >> 543 
                                                   >> 544 G4double G4VSolid::EstimateSurfaceArea(G4int nStat, G4double ell) const
                                                   >> 545 {
                                                   >> 546   G4int inside=0;
                                                   >> 547   G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,surf;
                                                   >> 548   G4bool yesno;
                                                   >> 549   G4ThreeVector p;
                                                   >> 550   EInside in;
                                                   >> 551 
                                                   >> 552   // values needed for CalculateExtent signature
                                                   >> 553 
                                                   >> 554   G4VoxelLimits limit;                // Unlimited
                                                   >> 555   G4AffineTransform origin;
                                                   >> 556 
                                                   >> 557   // min max extents of pSolid along X,Y,Z
                                                   >> 558 
                                                   >> 559   yesno = this->CalculateExtent(kXAxis,limit,origin,minX,maxX);
                                                   >> 560   yesno = this->CalculateExtent(kYAxis,limit,origin,minY,maxY);
                                                   >> 561   yesno = this->CalculateExtent(kZAxis,limit,origin,minZ,maxZ);
                                                   >> 562 
                                                   >> 563   // limits
                                                   >> 564 
                                                   >> 565   if(nStat < 100) { nStat = 100; }
                                                   >> 566 
                                                   >> 567   G4double dX=maxX-minX;
                                                   >> 568   G4double dY=maxY-minY;
                                                   >> 569   G4double dZ=maxZ-minZ;
                                                   >> 570   if(ell<=0.)          // Automatic definition of skin thickness
                                                   >> 571   {
                                                   >> 572     G4double minval=dX;
                                                   >> 573     if(dY<dX) { minval=dY; }
                                                   >> 574     if(dZ<minval) { minval=dZ; }
                                                   >> 575     ell=.01*minval;
                                                   >> 576   }
                                                   >> 577 
                                                   >> 578   G4double dd=2*ell;
                                                   >> 579   minX-=ell; minY-=ell; minZ-=ell; dX+=dd; dY+=dd; dZ+=dd;
                                                   >> 580 
                                                   >> 581   for(G4int i = 0; i < nStat; i++ )
                                                   >> 582   {
                                                   >> 583     px = minX+dX*G4UniformRand();
                                                   >> 584     py = minY+dY*G4UniformRand();
                                                   >> 585     pz = minZ+dZ*G4UniformRand();
                                                   >> 586     p  = G4ThreeVector(px,py,pz);
                                                   >> 587     in = this->Inside(p);
                                                   >> 588     if(in != kOutside)
                                                   >> 589     {
                                                   >> 590       if  (DistanceToOut(p)<ell) { inside++; }
                                                   >> 591     }
                                                   >> 592     else if(DistanceToIn(p)<ell) { inside++; }
                                                   >> 593   }
                                                   >> 594   // @@ The conformal correction can be upgraded
                                                   >> 595   surf = dX*dY*dZ*inside/dd/nStat;
                                                   >> 596   return surf;
723 }                                                 597 }
724                                                   598