Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4VCSGfaceted implementation; a virtual cla << 23 // the GEANT4 collaboration. 27 // that is built entirely out of G4VCSGface fa << 24 // >> 25 // By copying, distributing or modifying the Program (or any work >> 26 // based on the Program) you indicate your acceptance of this statement, >> 27 // and all its terms. >> 28 // >> 29 // $Id: G4VCSGfaceted.cc,v 1.7 2001/07/11 10:00:17 gunter Exp $ >> 30 // GEANT4 tag $Name: geant4-04-01 $ >> 31 // >> 32 // >> 33 // -------------------------------------------------------------------- >> 34 // GEANT 4 class source file >> 35 // >> 36 // >> 37 // G4VCSGfaceted.cc >> 38 // >> 39 // Implementation of the virtual class of a CSG type shape that is built >> 40 // entirely out of G4VCSGface faces. 28 // 41 // 29 // Author: David C. Williams (davidw@scipp.ucs << 30 // ------------------------------------------- 42 // -------------------------------------------------------------------- 31 43 32 #include "G4VCSGfaceted.hh" 44 #include "G4VCSGfaceted.hh" 33 #include "G4VCSGface.hh" 45 #include "G4VCSGface.hh" 34 #include "G4SolidExtentList.hh" 46 #include "G4SolidExtentList.hh" 35 47 36 #include "G4VoxelLimits.hh" 48 #include "G4VoxelLimits.hh" 37 #include "G4AffineTransform.hh" 49 #include "G4AffineTransform.hh" 38 50 39 #include "Randomize.hh" << 40 << 41 #include "G4Polyhedron.hh" 51 #include "G4Polyhedron.hh" 42 #include "G4VGraphicsScene.hh" 52 #include "G4VGraphicsScene.hh" >> 53 #include "G4NURBS.hh" >> 54 #include "G4NURBSbox.hh" 43 #include "G4VisExtent.hh" 55 #include "G4VisExtent.hh" 44 56 45 #include "G4AutoLock.hh" << 46 << 47 namespace << 48 { << 49 G4Mutex polyhedronMutex = G4MUTEX_INITIALIZE << 50 } << 51 << 52 // << 53 // Constructor << 54 // << 55 G4VCSGfaceted::G4VCSGfaceted( const G4String& << 56 : G4VSolid(name), << 57 fStatistics(1000000), fCubVolEpsilon(0.001 << 58 { << 59 } << 60 << 61 << 62 // << 63 // Fake default constructor - sets only member << 64 // for usage restri << 65 // << 66 G4VCSGfaceted::G4VCSGfaceted( __void__& a ) << 67 : G4VSolid(a), << 68 fStatistics(1000000), fCubVolEpsilon(0.001 << 69 { << 70 } << 71 << 72 // 57 // 73 // Destructor 58 // Destructor 74 // 59 // 75 G4VCSGfaceted::~G4VCSGfaceted() 60 G4VCSGfaceted::~G4VCSGfaceted() 76 { 61 { 77 DeleteStuff(); << 62 DeleteStuff(); 78 delete fpPolyhedron; fpPolyhedron = nullptr; << 79 } 63 } 80 64 81 65 82 // 66 // 83 // Copy constructor 67 // Copy constructor 84 // 68 // 85 G4VCSGfaceted::G4VCSGfaceted( const G4VCSGface << 69 G4VCSGfaceted::G4VCSGfaceted( const G4VCSGfaceted &source ) : G4VSolid( source ) 86 : G4VSolid( source ) << 87 { 70 { 88 fStatistics = source.fStatistics; << 71 CopyStuff( source ); 89 fCubVolEpsilon = source.fCubVolEpsilon; << 90 fAreaAccuracy = source.fAreaAccuracy; << 91 << 92 CopyStuff( source ); << 93 } 72 } 94 73 95 74 96 // 75 // 97 // Assignment operator 76 // Assignment operator 98 // 77 // 99 G4VCSGfaceted& G4VCSGfaceted::operator=( const << 78 const G4VCSGfaceted &G4VCSGfaceted::operator=( const G4VCSGfaceted &source ) 100 { 79 { 101 if (&source == this) { return *this; } << 80 if (&source == this) return *this; 102 << 81 103 // Copy base class data << 82 DeleteStuff(); 104 // << 83 CopyStuff( source ); 105 G4VSolid::operator=(source); << 84 106 << 85 return *this; 107 // Copy data << 108 // << 109 fStatistics = source.fStatistics; << 110 fCubVolEpsilon = source.fCubVolEpsilon; << 111 fAreaAccuracy = source.fAreaAccuracy; << 112 << 113 DeleteStuff(); << 114 CopyStuff( source ); << 115 << 116 return *this; << 117 } 86 } 118 87 119 88 120 // 89 // 121 // CopyStuff (protected) 90 // CopyStuff (protected) 122 // 91 // 123 // Copy the contents of source 92 // Copy the contents of source 124 // 93 // 125 void G4VCSGfaceted::CopyStuff( const G4VCSGfac << 94 void G4VCSGfaceted::CopyStuff( const G4VCSGfaceted &source ) 126 { 95 { 127 numFace = source.numFace; << 96 numFace = source.numFace; 128 if (numFace == 0) { return; } // odd, but << 97 if (numFace == 0) return; // odd, but permissable? 129 << 98 130 faces = new G4VCSGface*[numFace]; << 99 faces = new G4VCSGface*[numFace]; 131 << 100 132 G4VCSGface **face = faces, << 101 G4VCSGface **face = faces, 133 **sourceFace = source.faces; << 102 **sourceFace = source.faces; 134 do // Loop checking, 13.08.2015, G.Cosmo << 103 do { 135 { << 104 *face = (*sourceFace)->Clone(); 136 *face = (*sourceFace)->Clone(); << 105 } while( ++sourceFace, ++face < faces+numFace ); 137 } while( ++sourceFace, ++face < faces+numFac << 138 fCubicVolume = source.fCubicVolume; << 139 fSurfaceArea = source.fSurfaceArea; << 140 fRebuildPolyhedron = false; << 141 fpPolyhedron = nullptr; << 142 } 106 } 143 107 144 108 145 // 109 // 146 // DeleteStuff (protected) 110 // DeleteStuff (protected) 147 // 111 // 148 // Delete all allocated objects 112 // Delete all allocated objects 149 // 113 // 150 void G4VCSGfaceted::DeleteStuff() 114 void G4VCSGfaceted::DeleteStuff() 151 { 115 { 152 if (numFace != 0) << 116 if (numFace) { 153 { << 117 G4VCSGface **face = faces; 154 G4VCSGface **face = faces; << 118 do { 155 do // Loop checking, 13.08.2015, G.Cosm << 119 delete *face; 156 { << 120 } while( ++face < faces + numFace ); 157 delete *face; << 121 158 } while( ++face < faces + numFace ); << 122 delete [] faces; 159 << 123 } 160 delete [] faces; << 161 } << 162 delete fpPolyhedron; fpPolyhedron = nullptr; << 163 } 124 } 164 125 165 126 166 // 127 // 167 // CalculateExtent 128 // CalculateExtent 168 // 129 // 169 G4bool G4VCSGfaceted::CalculateExtent( const E 130 G4bool G4VCSGfaceted::CalculateExtent( const EAxis axis, 170 const G << 131 const G4VoxelLimits &voxelLimit, 171 const G << 132 const G4AffineTransform &transform, 172 G << 133 G4double &min, G4double &max ) const 173 G << 134 { 174 { << 135 G4SolidExtentList extentList( axis, voxelLimit ); 175 G4SolidExtentList extentList( axis, voxelLi << 136 176 << 137 // 177 // << 138 // Loop over all faces, checking min/max extent as we go. 178 // Loop over all faces, checking min/max ext << 139 // 179 // << 140 G4VCSGface **face = faces; 180 G4VCSGface **face = faces; << 141 do { 181 do // Loop checking, 13.08.2015, G.Cosmo << 142 (*face)->CalculateExtent( axis, voxelLimit, transform, extentList ); 182 { << 143 } while( ++face < faces + numFace ); 183 (*face)->CalculateExtent( axis, voxelLimit << 144 184 } while( ++face < faces + numFace ); << 145 // 185 << 146 // Return min/max value 186 // << 147 // 187 // Return min/max value << 148 return extentList.GetExtent( min, max ); 188 // << 189 return extentList.GetExtent( min, max ); << 190 } 149 } 191 150 192 151 193 // 152 // 194 // Inside 153 // Inside 195 // 154 // 196 // It could be a good idea to override this vi 155 // It could be a good idea to override this virtual 197 // member to add first a simple test (such as 156 // member to add first a simple test (such as spherical 198 // test or whatnot) and to call this version o 157 // test or whatnot) and to call this version only if 199 // the simplier test fails. 158 // the simplier test fails. 200 // 159 // 201 EInside G4VCSGfaceted::Inside( const G4ThreeVe << 160 EInside G4VCSGfaceted::Inside( const G4ThreeVector &p ) const 202 { 161 { 203 EInside answer=kOutside; << 162 EInside answer=kOutside; 204 G4VCSGface **face = faces; << 163 G4VCSGface **face = faces; 205 G4double best = kInfinity; << 164 G4double best = kInfinity; 206 do // Loop checking, 13.08.2015, G.Cosmo << 165 do { 207 { << 166 G4double distance; 208 G4double distance; << 167 EInside result = (*face)->Inside( p, kCarTolerance/2, &distance ); 209 EInside result = (*face)->Inside( p, kCarT << 168 if (result == kSurface) return kSurface; 210 if (result == kSurface) { return kSurface; << 169 if (distance < best) { 211 if (distance < best) << 170 best = distance; 212 { << 171 answer = result; 213 best = distance; << 172 } 214 answer = result; << 173 } while( ++face < faces + numFace ); 215 } << 216 } while( ++face < faces + numFace ); << 217 174 218 return answer; << 175 return answer; 219 } 176 } 220 177 221 178 222 // 179 // 223 // SurfaceNormal 180 // SurfaceNormal 224 // 181 // 225 G4ThreeVector G4VCSGfaceted::SurfaceNormal( co << 182 G4ThreeVector G4VCSGfaceted::SurfaceNormal( const G4ThreeVector& p) const 226 { 183 { 227 G4ThreeVector answer; << 184 G4ThreeVector answer; 228 G4VCSGface **face = faces; << 185 G4VCSGface **face = faces; 229 G4double best = kInfinity; << 186 G4double best = kInfinity; 230 do // Loop checking, 13.08.2015, G.Cosmo << 187 do { 231 { << 188 G4double distance; 232 G4double distance = kInfinity; << 189 G4ThreeVector normal = (*face)->Normal( p, &distance ); 233 G4ThreeVector normal = (*face)->Normal( p, << 190 if (distance < best) { 234 if (distance < best) << 191 best = distance; 235 { << 192 answer = normal; 236 best = distance; << 193 } 237 answer = normal; << 194 } while( ++face < faces + numFace ); 238 } << 239 } while( ++face < faces + numFace ); << 240 195 241 return answer; << 196 return answer; 242 } 197 } 243 198 244 199 245 // 200 // 246 // DistanceToIn(p,v) 201 // DistanceToIn(p,v) 247 // 202 // 248 G4double G4VCSGfaceted::DistanceToIn( const G4 << 203 G4double G4VCSGfaceted::DistanceToIn( const G4ThreeVector &p, const G4ThreeVector &v ) const 249 const G4 << 250 { 204 { 251 G4double distance = kInfinity; << 205 G4double distance = kInfinity; 252 G4double distFromSurface = kInfinity; << 206 G4double distFromSurface = kInfinity; 253 G4VCSGface **face = faces; << 207 G4VCSGface *bestFace=0; 254 G4VCSGface *bestFace = *face; << 208 G4VCSGface **face = faces; 255 do // Loop checking, 13.08.2015, G.Cosmo << 209 do { 256 { << 210 G4double faceDistance, 257 G4double faceDistance, << 211 faceDistFromSurface; 258 faceDistFromSurface; << 212 G4ThreeVector faceNormal; 259 G4ThreeVector faceNormal; << 213 G4bool faceAllBehind; 260 G4bool faceAllBehind; << 214 if ((*face)->Intersect( p, v, false, kCarTolerance/2, 261 if ((*face)->Intersect( p, v, false, kCarT << 215 faceDistance, faceDistFromSurface, 262 faceDistance, faceDistFromSurf << 216 faceNormal, faceAllBehind ) ) { 263 faceNormal, faceAllBehind ) ) << 217 // 264 { << 218 // Intersecting face 265 // << 219 // 266 // Intersecting face << 220 if (faceDistance < distance) { 267 // << 221 distance = faceDistance; 268 if (faceDistance < distance) << 222 distFromSurface = faceDistFromSurface; 269 { << 223 bestFace = *face; 270 distance = faceDistance; << 224 if (distFromSurface <= 0) return 0; 271 distFromSurface = faceDistFromSurface; << 225 } 272 bestFace = *face; << 226 } 273 if (distFromSurface <= 0) { return 0; << 227 } while( ++face < faces + numFace ); 274 } << 228 275 } << 229 if (distance < kInfinity && distFromSurface<kCarTolerance/2) { 276 } while( ++face < faces + numFace ); << 230 if (bestFace->Distance(p,false) < kCarTolerance/2) distance = 0; 277 << 231 } 278 if (distance < kInfinity && distFromSurface< << 279 { << 280 if (bestFace->Distance(p,false) < kCarTole << 281 } << 282 232 283 return distance; << 233 return distance; 284 } 234 } 285 235 286 236 287 // 237 // 288 // DistanceToIn(p) 238 // DistanceToIn(p) 289 // 239 // 290 G4double G4VCSGfaceted::DistanceToIn( const G4 << 240 G4double G4VCSGfaceted::DistanceToIn( const G4ThreeVector &p ) const 291 { 241 { 292 return DistanceTo( p, false ); << 242 return DistanceTo( p, false ); 293 } 243 } 294 244 295 245 296 // 246 // 297 // DistanceToOut(p,v) 247 // DistanceToOut(p,v) 298 // 248 // 299 G4double G4VCSGfaceted::DistanceToOut( const G << 249 G4double G4VCSGfaceted::DistanceToOut( const G4ThreeVector &p, const G4ThreeVector &v, 300 const G << 250 const G4bool calcNorm, 301 const G << 251 G4bool *validNorm, G4ThreeVector *n ) const 302 G << 252 { 303 G << 253 G4bool allBehind = true; 304 { << 254 G4double distance = kInfinity; 305 G4bool allBehind = true; << 255 G4double distFromSurface = kInfinity; 306 G4double distance = kInfinity; << 256 G4ThreeVector normal; 307 G4double distFromSurface = kInfinity; << 257 G4VCSGface *bestFace=0; 308 G4ThreeVector normal; << 258 309 << 259 G4VCSGface **face = faces; 310 G4VCSGface **face = faces; << 260 do { 311 G4VCSGface *bestFace = *face; << 261 G4double faceDistance, 312 do // Loop checking, 13.08.2015, G.Cosmo << 262 faceDistFromSurface; 313 { << 263 G4ThreeVector faceNormal; 314 G4double faceDistance, << 264 G4bool faceAllBehind; 315 faceDistFromSurface; << 265 if ((*face)->Intersect( p, v, true, kCarTolerance/2, 316 G4ThreeVector faceNormal; << 266 faceDistance, faceDistFromSurface, 317 G4bool faceAllBehind; << 267 faceNormal, faceAllBehind ) ) { 318 if ((*face)->Intersect( p, v, true, kCarTo << 268 // 319 faceDistance, faceDistFromSurf << 269 // Intersecting face 320 faceNormal, faceAllBehind ) ) << 270 // 321 { << 271 if ( (distance < kInfinity) || (!faceAllBehind) ) allBehind = false; 322 // << 272 if (faceDistance < distance) { 323 // Intersecting face << 273 distance = faceDistance; 324 // << 274 distFromSurface = faceDistFromSurface; 325 if ( (distance < kInfinity) || (!faceAll << 275 normal = faceNormal; 326 if (faceDistance < distance) << 276 bestFace = *face; 327 { << 277 if (distFromSurface <= 0) break; 328 distance = faceDistance; << 278 } 329 distFromSurface = faceDistFromSurface; << 279 } 330 normal = faceNormal; << 280 } while( ++face < faces + numFace ); 331 bestFace = *face; << 281 332 if (distFromSurface <= 0.) { break; } << 282 if (distance < kInfinity) { 333 } << 283 if (distFromSurface <= 0) 334 } << 284 distance = 0; 335 } while( ++face < faces + numFace ); << 285 else if (distFromSurface<kCarTolerance/2) { 336 << 286 if (bestFace->Distance(p,true) < kCarTolerance/2) distance = 0; 337 if (distance < kInfinity) << 287 } 338 { << 288 339 if (distFromSurface <= 0.) << 289 if (calcNorm) { 340 { << 290 *validNorm = allBehind; 341 distance = 0.; << 291 *n = normal; 342 } << 292 } 343 else if (distFromSurface<kCarTolerance/2) << 293 } 344 { << 294 else { 345 if (bestFace->Distance(p,true) < kCarTol << 295 if (calcNorm) *validNorm = false; 346 } << 296 } 347 << 348 if (calcNorm) << 349 { << 350 *validNorm = allBehind; << 351 *n = normal; << 352 } << 353 } << 354 else << 355 { << 356 if (Inside(p) == kSurface) { distance = 0 << 357 if (calcNorm) { *validNorm = false; } << 358 } << 359 297 360 return distance; << 298 return distance; 361 } 299 } 362 300 363 301 364 // 302 // 365 // DistanceToOut(p) 303 // DistanceToOut(p) 366 // 304 // 367 G4double G4VCSGfaceted::DistanceToOut( const G << 305 G4double G4VCSGfaceted::DistanceToOut( const G4ThreeVector &p ) const 368 { 306 { 369 return DistanceTo( p, true ); << 307 return DistanceTo( p, true ); 370 } 308 } 371 309 372 310 373 // 311 // 374 // DistanceTo 312 // DistanceTo 375 // 313 // 376 // Protected routine called by DistanceToIn an 314 // Protected routine called by DistanceToIn and DistanceToOut 377 // 315 // 378 G4double G4VCSGfaceted::DistanceTo( const G4Th << 316 G4double G4VCSGfaceted::DistanceTo( const G4ThreeVector &p, const G4bool outgoing ) const 379 const G4bo << 380 { 317 { 381 G4VCSGface **face = faces; << 318 G4VCSGface **face = faces; 382 G4double best = kInfinity; << 319 G4double best = kInfinity; 383 do // Loop checking, 13.08.2015, G.Cosmo << 320 do { 384 { << 321 G4double distance = (*face)->Distance( p, outgoing ); 385 G4double distance = (*face)->Distance( p, << 322 if (distance < best) best = distance; 386 if (distance < best) { best = distance; } << 323 } while( ++face < faces + numFace ); 387 } while( ++face < faces + numFace ); << 388 324 389 return (best < 0.5*kCarTolerance) ? 0. : bes << 325 return (best < 0.5*kCarTolerance) ? 0 : best; 390 } 326 } 391 327 392 328 393 // 329 // 394 // DescribeYourselfTo 330 // DescribeYourselfTo 395 // 331 // 396 void G4VCSGfaceted::DescribeYourselfTo( G4VGra 332 void G4VCSGfaceted::DescribeYourselfTo( G4VGraphicsScene& scene ) const 397 { 333 { 398 scene.AddSolid( *this ); << 334 scene.AddThis( *this ); 399 } 335 } 400 336 401 337 402 // 338 // 403 // GetExtent 339 // GetExtent 404 // 340 // 405 // Define the sides of the box into which our 341 // Define the sides of the box into which our solid instance would fit. 406 // 342 // 407 G4VisExtent G4VCSGfaceted::GetExtent() const 343 G4VisExtent G4VCSGfaceted::GetExtent() const 408 { 344 { 409 static const G4ThreeVector xMax(1,0,0), xMin << 345 static const G4ThreeVector xMax(1,0,0), xMin(-1,0,0), 410 yMax(0,1,0), yMin << 346 yMax(0,1,0), yMin(0,-1,0), 411 zMax(0,0,1), zMin << 347 zMax(0,0,1), zMin(0,0,-1); 412 static const G4ThreeVector *axes[6] = << 348 static const G4ThreeVector *axes[6] = { &xMin, &xMax, &yMin, &yMax, &zMin, &zMax }; 413 { &xMin, &xMax, &yMin, &yMax, &zMin, &zMa << 349 414 << 350 G4double answers[6] = {-kInfinity, -kInfinity, -kInfinity, -kInfinity, -kInfinity, -kInfinity}; 415 G4double answers[6] = << 351 416 {-kInfinity, -kInfinity, -kInfinity, -kIn << 352 G4VCSGface **face = faces; 417 << 353 do { 418 G4VCSGface **face = faces; << 354 const G4ThreeVector **axis = axes+5 ; 419 do // Loop checking, 13.08.2015, G.Cosmo << 355 G4double *answer = answers+5; 420 { << 356 do { 421 const G4ThreeVector **axis = axes+5 ; << 357 G4double testFace = (*face)->Extent( **axis ); 422 G4double* answer = answers+5; << 358 if (testFace > *answer) *answer = testFace; 423 do // Loop checking, 13.08.2015, G.Cosm << 359 } 424 { << 360 while( --axis, --answer >= answers ); 425 G4double testFace = (*face)->Extent( **a << 361 426 if (testFace > *answer) { *answer = tes << 362 } while( ++face < faces + numFace ); 427 } << 428 while( --axis, --answer >= answers ); << 429 << 430 } while( ++face < faces + numFace ); << 431 363 432 return { -answers[0], answers[1], << 364 return G4VisExtent( -answers[0], answers[1], 433 -answers[2], answers[3], << 365 -answers[2], answers[3], 434 -answers[4], answers[5] }; << 366 -answers[4], answers[5] ); 435 } << 436 << 437 << 438 // << 439 // GetEntityType << 440 // << 441 G4GeometryType G4VCSGfaceted::GetEntityType() << 442 { << 443 return {"G4CSGfaceted"}; << 444 } << 445 << 446 << 447 // << 448 // Stream object contents to an output stream << 449 // << 450 std::ostream& G4VCSGfaceted::StreamInfo( std:: << 451 { << 452 os << "------------------------------------- << 453 << " *** Dump for solid - " << GetName << 454 << " ================================= << 455 << " Solid type: G4VCSGfaceted\n" << 456 << " Parameters: \n" << 457 << " number of faces: " << numFace << << 458 << "------------------------------------- << 459 << 460 return os; << 461 } << 462 << 463 << 464 // << 465 // GetCubVolStatistics << 466 // << 467 G4int G4VCSGfaceted::GetCubVolStatistics() con << 468 { << 469 return fStatistics; << 470 } << 471 << 472 << 473 // << 474 // GetCubVolEpsilon << 475 // << 476 G4double G4VCSGfaceted::GetCubVolEpsilon() con << 477 { << 478 return fCubVolEpsilon; << 479 } << 480 << 481 << 482 // << 483 // SetCubVolStatistics << 484 // << 485 void G4VCSGfaceted::SetCubVolStatistics(G4int << 486 { << 487 fCubicVolume=0.; << 488 fStatistics=st; << 489 } << 490 << 491 << 492 // << 493 // SetCubVolEpsilon << 494 // << 495 void G4VCSGfaceted::SetCubVolEpsilon(G4double << 496 { << 497 fCubicVolume=0.; << 498 fCubVolEpsilon=ep; << 499 } << 500 << 501 << 502 // << 503 // GetAreaStatistics << 504 // << 505 G4int G4VCSGfaceted::GetAreaStatistics() const << 506 { << 507 return fStatistics; << 508 } << 509 << 510 << 511 // << 512 // GetAreaAccuracy << 513 // << 514 G4double G4VCSGfaceted::GetAreaAccuracy() cons << 515 { << 516 return fAreaAccuracy; << 517 } << 518 << 519 << 520 // << 521 // SetAreaStatistics << 522 // << 523 void G4VCSGfaceted::SetAreaStatistics(G4int st << 524 { << 525 fSurfaceArea=0.; << 526 fStatistics=st; << 527 } << 528 << 529 << 530 // << 531 // SetAreaAccuracy << 532 // << 533 void G4VCSGfaceted::SetAreaAccuracy(G4double e << 534 { << 535 fSurfaceArea=0.; << 536 fAreaAccuracy=ep; << 537 } << 538 << 539 << 540 // << 541 // GetCubicVolume << 542 // << 543 G4double G4VCSGfaceted::GetCubicVolume() << 544 { << 545 if(fCubicVolume != 0.) {;} << 546 else { fCubicVolume = EstimateCubicVolume( << 547 return fCubicVolume; << 548 } << 549 << 550 << 551 // << 552 // GetSurfaceArea << 553 // << 554 G4double G4VCSGfaceted::GetSurfaceArea() << 555 { << 556 if(fSurfaceArea != 0.) {;} << 557 else { fSurfaceArea = EstimateSurfaceArea( << 558 return fSurfaceArea; << 559 } << 560 << 561 << 562 // << 563 // GetPolyhedron << 564 // << 565 G4Polyhedron* G4VCSGfaceted::GetPolyhedron () << 566 { << 567 if (fpPolyhedron == nullptr || << 568 fRebuildPolyhedron || << 569 fpPolyhedron->GetNumberOfRotationStepsAt << 570 fpPolyhedron->GetNumberOfRotationSteps() << 571 { << 572 G4AutoLock l(&polyhedronMutex); << 573 delete fpPolyhedron; << 574 fpPolyhedron = CreatePolyhedron(); << 575 fRebuildPolyhedron = false; << 576 l.unlock(); << 577 } << 578 return fpPolyhedron; << 579 } << 580 << 581 << 582 // << 583 // GetPointOnSurfaceGeneric proportional to Ar << 584 // in case of GenericPolycone or GenericPolyhe << 585 // << 586 G4ThreeVector G4VCSGfaceted::GetPointOnSurface << 587 { << 588 // Preparing variables << 589 // << 590 G4ThreeVector answer=G4ThreeVector(0.,0.,0.) << 591 G4VCSGface **face = faces; << 592 G4double area = 0.; << 593 G4int i; << 594 std::vector<G4double> areas; << 595 << 596 // First step: calculate surface areas << 597 // << 598 do // Loop checking, 13.08.2015, G.Cosmo << 599 { << 600 G4double result = (*face)->SurfaceArea( ); << 601 areas.push_back(result); << 602 area=area+result; << 603 } while( ++face < faces + numFace ); << 604 << 605 // Second Step: choose randomly one surface << 606 // << 607 G4VCSGface **face1 = faces; << 608 G4double chose = area*G4UniformRand(); << 609 G4double Achose1, Achose2; << 610 Achose1=0.; Achose2=0.; << 611 i=0; << 612 << 613 do << 614 { << 615 Achose2+=areas[i]; << 616 if(chose>=Achose1 && chose<Achose2) << 617 { << 618 G4ThreeVector point; << 619 point= (*face1)->GetPointOnFace(); << 620 return point; << 621 } << 622 ++i; << 623 Achose1=Achose2; << 624 } while( ++face1 < faces + numFace ); << 625 << 626 return answer; << 627 } 367 } 628 368