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