#include <G4VCSGfaceted.hh>
Inheritance diagram for G4VCSGfaceted:
Definition at line 53 of file G4VCSGfaceted.hh.
G4VCSGfaceted::G4VCSGfaceted | ( | const G4String & | name | ) |
Definition at line 64 of file G4VCSGfaceted.cc.
00065 : G4VSolid(name), 00066 numFace(0), faces(0), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0), 00067 fStatistics(1000000), fCubVolEpsilon(0.001), fAreaAccuracy(-1.) 00068 { 00069 }
G4VCSGfaceted::~G4VCSGfaceted | ( | ) | [virtual] |
Definition at line 86 of file G4VCSGfaceted.cc.
References DeleteStuff(), and fpPolyhedron.
00087 { 00088 DeleteStuff(); 00089 delete fpPolyhedron; 00090 }
G4VCSGfaceted::G4VCSGfaceted | ( | const G4VCSGfaceted & | source | ) |
Definition at line 96 of file G4VCSGfaceted.cc.
References CopyStuff(), fAreaAccuracy, fCubVolEpsilon, and fStatistics.
00097 : G4VSolid( source ) 00098 { 00099 fStatistics = source.fStatistics; 00100 fCubVolEpsilon = source.fCubVolEpsilon; 00101 fAreaAccuracy = source.fAreaAccuracy; 00102 00103 CopyStuff( source ); 00104 }
G4VCSGfaceted::G4VCSGfaceted | ( | __void__ & | ) |
Definition at line 76 of file G4VCSGfaceted.cc.
00077 : G4VSolid(a), 00078 numFace(0), faces(0), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0), 00079 fStatistics(1000000), fCubVolEpsilon(0.001), fAreaAccuracy(-1.) 00080 { 00081 }
G4bool G4VCSGfaceted::CalculateExtent | ( | const EAxis | pAxis, | |
const G4VoxelLimits & | pVoxelLimit, | |||
const G4AffineTransform & | pTransform, | |||
G4double & | pmin, | |||
G4double & | pmax | |||
) | const [virtual] |
Implements G4VSolid.
Definition at line 178 of file G4VCSGfaceted.cc.
References G4VCSGface::CalculateExtent(), faces, G4SolidExtentList::GetExtent(), and numFace.
00183 { 00184 G4SolidExtentList extentList( axis, voxelLimit ); 00185 00186 // 00187 // Loop over all faces, checking min/max extent as we go. 00188 // 00189 G4VCSGface **face = faces; 00190 do 00191 { 00192 (*face)->CalculateExtent( axis, voxelLimit, transform, extentList ); 00193 } while( ++face < faces + numFace ); 00194 00195 // 00196 // Return min/max value 00197 // 00198 return extentList.GetExtent( min, max ); 00199 }
void G4VCSGfaceted::CopyStuff | ( | const G4VCSGfaceted & | source | ) | [protected] |
Definition at line 136 of file G4VCSGfaceted.cc.
References G4VCSGface::Clone(), faces, fCubicVolume, fpPolyhedron, fSurfaceArea, and numFace.
Referenced by G4VCSGfaceted(), and operator=().
00137 { 00138 numFace = source.numFace; 00139 if (numFace == 0) { return; } // odd, but permissable? 00140 00141 faces = new G4VCSGface*[numFace]; 00142 00143 G4VCSGface **face = faces, 00144 **sourceFace = source.faces; 00145 do 00146 { 00147 *face = (*sourceFace)->Clone(); 00148 } while( ++sourceFace, ++face < faces+numFace ); 00149 fCubicVolume = source.fCubicVolume; 00150 fSurfaceArea = source.fSurfaceArea; 00151 fpPolyhedron = 0; 00152 }
virtual G4Polyhedron* G4VCSGfaceted::CreatePolyhedron | ( | ) | const [pure virtual] |
Reimplemented from G4VSolid.
Implemented in G4Polycone, and G4Polyhedra.
Referenced by GetPolyhedron().
void G4VCSGfaceted::DeleteStuff | ( | ) | [protected] |
Reimplemented in G4Polyhedra.
Definition at line 160 of file G4VCSGfaceted.cc.
References faces, and numFace.
Referenced by operator=(), G4Polyhedra::Reset(), G4Polycone::Reset(), and ~G4VCSGfaceted().
00161 { 00162 if (numFace) 00163 { 00164 G4VCSGface **face = faces; 00165 do 00166 { 00167 delete *face; 00168 } while( ++face < faces + numFace ); 00169 00170 delete [] faces; 00171 } 00172 }
void G4VCSGfaceted::DescribeYourselfTo | ( | G4VGraphicsScene & | scene | ) | const [virtual] |
Implements G4VSolid.
Definition at line 405 of file G4VCSGfaceted.cc.
References G4VGraphicsScene::AddSolid().
00406 { 00407 scene.AddSolid( *this ); 00408 }
G4double G4VCSGfaceted::DistanceTo | ( | const G4ThreeVector & | p, | |
const G4bool | outgoing | |||
) | const [protected, virtual] |
Definition at line 387 of file G4VCSGfaceted.cc.
References faces, G4VSolid::kCarTolerance, and numFace.
Referenced by DistanceToIn(), and DistanceToOut().
00389 { 00390 G4VCSGface **face = faces; 00391 G4double best = kInfinity; 00392 do 00393 { 00394 G4double distance = (*face)->Distance( p, outgoing ); 00395 if (distance < best) { best = distance; } 00396 } while( ++face < faces + numFace ); 00397 00398 return (best < 0.5*kCarTolerance) ? 0 : best; 00399 }
G4double G4VCSGfaceted::DistanceToIn | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Reimplemented in G4Polycone, and G4Polyhedra.
Definition at line 299 of file G4VCSGfaceted.cc.
References DistanceTo().
00300 { 00301 return DistanceTo( p, false ); 00302 }
G4double G4VCSGfaceted::DistanceToIn | ( | const G4ThreeVector & | p, | |
const G4ThreeVector & | v | |||
) | const [virtual] |
Implements G4VSolid.
Reimplemented in G4Polycone, and G4Polyhedra.
Definition at line 257 of file G4VCSGfaceted.cc.
References G4VCSGface::Distance(), faces, G4VSolid::kCarTolerance, and numFace.
Referenced by G4Polyhedra::DistanceToIn(), and G4Polycone::DistanceToIn().
00259 { 00260 G4double distance = kInfinity; 00261 G4double distFromSurface = kInfinity; 00262 G4VCSGface **face = faces; 00263 G4VCSGface *bestFace = *face; 00264 do 00265 { 00266 G4double faceDistance, 00267 faceDistFromSurface; 00268 G4ThreeVector faceNormal; 00269 G4bool faceAllBehind; 00270 if ((*face)->Intersect( p, v, false, kCarTolerance/2, 00271 faceDistance, faceDistFromSurface, 00272 faceNormal, faceAllBehind ) ) 00273 { 00274 // 00275 // Intersecting face 00276 // 00277 if (faceDistance < distance) 00278 { 00279 distance = faceDistance; 00280 distFromSurface = faceDistFromSurface; 00281 bestFace = *face; 00282 if (distFromSurface <= 0) { return 0; } 00283 } 00284 } 00285 } while( ++face < faces + numFace ); 00286 00287 if (distance < kInfinity && distFromSurface<kCarTolerance/2) 00288 { 00289 if (bestFace->Distance(p,false) < kCarTolerance/2) { distance = 0; } 00290 } 00291 00292 return distance; 00293 }
G4double G4VCSGfaceted::DistanceToOut | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Definition at line 376 of file G4VCSGfaceted.cc.
References DistanceTo().
00377 { 00378 return DistanceTo( p, true ); 00379 }
G4double G4VCSGfaceted::DistanceToOut | ( | const G4ThreeVector & | p, | |
const G4ThreeVector & | v, | |||
const G4bool | calcNorm = false , |
|||
G4bool * | validNorm = 0 , |
|||
G4ThreeVector * | n = 0 | |||
) | const [virtual] |
Implements G4VSolid.
Definition at line 308 of file G4VCSGfaceted.cc.
References G4VCSGface::Distance(), faces, Inside(), G4VSolid::kCarTolerance, kSurface, and numFace.
00313 { 00314 G4bool allBehind = true; 00315 G4double distance = kInfinity; 00316 G4double distFromSurface = kInfinity; 00317 G4ThreeVector normal; 00318 00319 G4VCSGface **face = faces; 00320 G4VCSGface *bestFace = *face; 00321 do 00322 { 00323 G4double faceDistance, 00324 faceDistFromSurface; 00325 G4ThreeVector faceNormal; 00326 G4bool faceAllBehind; 00327 if ((*face)->Intersect( p, v, true, kCarTolerance/2, 00328 faceDistance, faceDistFromSurface, 00329 faceNormal, faceAllBehind ) ) 00330 { 00331 // 00332 // Intersecting face 00333 // 00334 if ( (distance < kInfinity) || (!faceAllBehind) ) { allBehind = false; } 00335 if (faceDistance < distance) 00336 { 00337 distance = faceDistance; 00338 distFromSurface = faceDistFromSurface; 00339 normal = faceNormal; 00340 bestFace = *face; 00341 if (distFromSurface <= 0) { break; } 00342 } 00343 } 00344 } while( ++face < faces + numFace ); 00345 00346 if (distance < kInfinity) 00347 { 00348 if (distFromSurface <= 0) 00349 { 00350 distance = 0; 00351 } 00352 else if (distFromSurface<kCarTolerance/2) 00353 { 00354 if (bestFace->Distance(p,true) < kCarTolerance/2) { distance = 0; } 00355 } 00356 00357 if (calcNorm) 00358 { 00359 *validNorm = allBehind; 00360 *n = normal; 00361 } 00362 } 00363 else 00364 { 00365 if (Inside(p) == kSurface) { distance = 0; } 00366 if (calcNorm) { *validNorm = false; } 00367 } 00368 00369 return distance; 00370 }
G4double G4VCSGfaceted::GetAreaAccuracy | ( | ) | const |
G4int G4VCSGfaceted::GetAreaStatistics | ( | ) | const |
G4double G4VCSGfaceted::GetCubicVolume | ( | ) | [virtual] |
Reimplemented from G4VSolid.
Definition at line 552 of file G4VCSGfaceted.cc.
References G4VSolid::EstimateCubicVolume(), and fCubicVolume.
00553 { 00554 if(fCubicVolume != 0.) {;} 00555 else { fCubicVolume = EstimateCubicVolume(fStatistics,fCubVolEpsilon); } 00556 return fCubicVolume; 00557 }
G4double G4VCSGfaceted::GetCubVolEpsilon | ( | ) | const |
G4int G4VCSGfaceted::GetCubVolStatistics | ( | ) | const |
G4GeometryType G4VCSGfaceted::GetEntityType | ( | ) | const [virtual] |
Implements G4VSolid.
Reimplemented in G4Polycone, and G4Polyhedra.
Definition at line 450 of file G4VCSGfaceted.cc.
00451 { 00452 return G4String("G4CSGfaceted"); 00453 }
G4VisExtent G4VCSGfaceted::GetExtent | ( | ) | const [virtual] |
Reimplemented from G4VSolid.
Definition at line 416 of file G4VCSGfaceted.cc.
References faces, and numFace.
00417 { 00418 static const G4ThreeVector xMax(1,0,0), xMin(-1,0,0), 00419 yMax(0,1,0), yMin(0,-1,0), 00420 zMax(0,0,1), zMin(0,0,-1); 00421 static const G4ThreeVector *axes[6] = 00422 { &xMin, &xMax, &yMin, &yMax, &zMin, &zMax }; 00423 00424 G4double answers[6] = 00425 {-kInfinity, -kInfinity, -kInfinity, -kInfinity, -kInfinity, -kInfinity}; 00426 00427 G4VCSGface **face = faces; 00428 do 00429 { 00430 const G4ThreeVector **axis = axes+5 ; 00431 G4double *answer = answers+5; 00432 do 00433 { 00434 G4double testFace = (*face)->Extent( **axis ); 00435 if (testFace > *answer) { *answer = testFace; } 00436 } 00437 while( --axis, --answer >= answers ); 00438 00439 } while( ++face < faces + numFace ); 00440 00441 return G4VisExtent( -answers[0], answers[1], 00442 -answers[2], answers[3], 00443 -answers[4], answers[5] ); 00444 }
G4ThreeVector G4VCSGfaceted::GetPointOnSurfaceGeneric | ( | ) | const [protected] |
Definition at line 591 of file G4VCSGfaceted.cc.
References faces, G4UniformRand, and numFace.
00592 { 00593 // Preparing variables 00594 // 00595 G4ThreeVector answer=G4ThreeVector(0.,0.,0.); 00596 G4VCSGface **face = faces; 00597 G4double area = 0; 00598 G4int i; 00599 std::vector<G4double> areas; 00600 00601 // First step: calculate surface areas 00602 // 00603 do 00604 { 00605 G4double result = (*face)->SurfaceArea( ); 00606 areas.push_back(result); 00607 area=area+result; 00608 } while( ++face < faces + numFace ); 00609 00610 // Second Step: choose randomly one surface 00611 // 00612 G4VCSGface **face1 = faces; 00613 G4double chose = area*G4UniformRand(); 00614 G4double Achose1, Achose2; 00615 Achose1=0; Achose2=0.; 00616 i=0; 00617 00618 do 00619 { 00620 Achose2+=areas[i]; 00621 if(chose>=Achose1 && chose<Achose2) 00622 { 00623 G4ThreeVector point; 00624 point= (*face1)->GetPointOnFace(); 00625 return point; 00626 } 00627 i++; 00628 Achose1=Achose2; 00629 } while( ++face1 < faces + numFace ); 00630 00631 return answer; 00632 }
G4Polyhedron * G4VCSGfaceted::GetPolyhedron | ( | ) | const [virtual] |
Reimplemented from G4VSolid.
Definition at line 574 of file G4VCSGfaceted.cc.
References CreatePolyhedron(), fpPolyhedron, and G4Polyhedron::GetNumberOfRotationStepsAtTimeOfCreation().
00575 { 00576 if (!fpPolyhedron || 00577 fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() != 00578 fpPolyhedron->GetNumberOfRotationSteps()) 00579 { 00580 delete fpPolyhedron; 00581 fpPolyhedron = CreatePolyhedron(); 00582 } 00583 return fpPolyhedron; 00584 }
G4double G4VCSGfaceted::GetSurfaceArea | ( | ) | [virtual] |
Reimplemented from G4VSolid.
Definition at line 563 of file G4VCSGfaceted.cc.
References G4VSolid::EstimateSurfaceArea(), and fSurfaceArea.
00564 { 00565 if(fSurfaceArea != 0.) {;} 00566 else { fSurfaceArea = EstimateSurfaceArea(fStatistics,fAreaAccuracy); } 00567 return fSurfaceArea; 00568 }
EInside G4VCSGfaceted::Inside | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Reimplemented in G4Polycone, and G4Polyhedra.
Definition at line 210 of file G4VCSGfaceted.cc.
References faces, G4VSolid::kCarTolerance, kOutside, kSurface, and numFace.
Referenced by DistanceToOut(), G4Polyhedra::Inside(), and G4Polycone::Inside().
00211 { 00212 EInside answer=kOutside; 00213 G4VCSGface **face = faces; 00214 G4double best = kInfinity; 00215 do 00216 { 00217 G4double distance; 00218 EInside result = (*face)->Inside( p, kCarTolerance/2, &distance ); 00219 if (result == kSurface) { return kSurface; } 00220 if (distance < best) 00221 { 00222 best = distance; 00223 answer = result; 00224 } 00225 } while( ++face < faces + numFace ); 00226 00227 return answer; 00228 }
const G4VCSGfaceted & G4VCSGfaceted::operator= | ( | const G4VCSGfaceted & | source | ) |
Definition at line 110 of file G4VCSGfaceted.cc.
References CopyStuff(), DeleteStuff(), fAreaAccuracy, fCubVolEpsilon, fStatistics, and G4VSolid::operator=().
Referenced by G4Polyhedra::operator=(), and G4Polycone::operator=().
00111 { 00112 if (&source == this) { return *this; } 00113 00114 // Copy base class data 00115 // 00116 G4VSolid::operator=(source); 00117 00118 // Copy data 00119 // 00120 fStatistics = source.fStatistics; 00121 fCubVolEpsilon = source.fCubVolEpsilon; 00122 fAreaAccuracy = source.fAreaAccuracy; 00123 00124 DeleteStuff(); 00125 CopyStuff( source ); 00126 00127 return *this; 00128 }
void G4VCSGfaceted::SetAreaAccuracy | ( | G4double | ep | ) |
Definition at line 542 of file G4VCSGfaceted.cc.
References fSurfaceArea.
00543 { 00544 fSurfaceArea=0.; 00545 fAreaAccuracy=ep; 00546 }
void G4VCSGfaceted::SetAreaStatistics | ( | G4int | st | ) |
Definition at line 532 of file G4VCSGfaceted.cc.
References fSurfaceArea.
00533 { 00534 fSurfaceArea=0.; 00535 fStatistics=st; 00536 }
void G4VCSGfaceted::SetCubVolEpsilon | ( | G4double | ep | ) |
Definition at line 504 of file G4VCSGfaceted.cc.
References fCubicVolume.
00505 { 00506 fCubicVolume=0.; 00507 fCubVolEpsilon=ep; 00508 }
void G4VCSGfaceted::SetCubVolStatistics | ( | G4int | st | ) |
Definition at line 494 of file G4VCSGfaceted.cc.
References fCubicVolume.
00495 { 00496 fCubicVolume=0.; 00497 fStatistics=st; 00498 }
std::ostream & G4VCSGfaceted::StreamInfo | ( | std::ostream & | os | ) | const [virtual] |
Implements G4VSolid.
Reimplemented in G4Polycone, and G4Polyhedra.
Definition at line 459 of file G4VCSGfaceted.cc.
References G4VSolid::GetName(), and numFace.
00460 { 00461 os << "-----------------------------------------------------------\n" 00462 << " *** Dump for solid - " << GetName() << " ***\n" 00463 << " ===================================================\n" 00464 << " Solid type: G4VCSGfaceted\n" 00465 << " Parameters: \n" 00466 << " number of faces: " << numFace << "\n" 00467 << "-----------------------------------------------------------\n"; 00468 00469 return os; 00470 }
G4ThreeVector G4VCSGfaceted::SurfaceNormal | ( | const G4ThreeVector & | p | ) | const [virtual] |
Implements G4VSolid.
Definition at line 234 of file G4VCSGfaceted.cc.
References faces, and numFace.
00235 { 00236 G4ThreeVector answer; 00237 G4VCSGface **face = faces; 00238 G4double best = kInfinity; 00239 do 00240 { 00241 G4double distance; 00242 G4ThreeVector normal = (*face)->Normal( p, &distance ); 00243 if (distance < best) 00244 { 00245 best = distance; 00246 answer = normal; 00247 } 00248 } while( ++face < faces + numFace ); 00249 00250 return answer; 00251 }
G4VCSGface** G4VCSGfaceted::faces [protected] |
Definition at line 120 of file G4VCSGfaceted.hh.
Referenced by CalculateExtent(), CopyStuff(), G4Polyhedra::Create(), G4Polycone::Create(), DeleteStuff(), DistanceTo(), DistanceToIn(), DistanceToOut(), GetExtent(), GetPointOnSurfaceGeneric(), Inside(), and SurfaceNormal().
G4double G4VCSGfaceted::fCubicVolume [protected] |
Definition at line 121 of file G4VCSGfaceted.hh.
Referenced by CopyStuff(), GetCubicVolume(), SetCubVolEpsilon(), SetCubVolStatistics(), G4Polyhedra::SetOriginalParameters(), and G4Polycone::SetOriginalParameters().
G4Polyhedron* G4VCSGfaceted::fpPolyhedron [mutable, protected] |
Definition at line 123 of file G4VCSGfaceted.hh.
Referenced by CopyStuff(), GetPolyhedron(), G4Polyhedra::SetOriginalParameters(), G4Polycone::SetOriginalParameters(), and ~G4VCSGfaceted().
G4double G4VCSGfaceted::fSurfaceArea [protected] |
Definition at line 122 of file G4VCSGfaceted.hh.
Referenced by CopyStuff(), GetSurfaceArea(), SetAreaAccuracy(), and SetAreaStatistics().
G4int G4VCSGfaceted::numFace [protected] |
Definition at line 119 of file G4VCSGfaceted.hh.
Referenced by CalculateExtent(), CopyStuff(), G4Polyhedra::Create(), G4Polycone::Create(), DeleteStuff(), DistanceTo(), DistanceToIn(), DistanceToOut(), GetExtent(), GetPointOnSurfaceGeneric(), Inside(), StreamInfo(), and SurfaceNormal().