00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <cmath>
00032
00033 #include "G4CSGSolid.hh"
00034 #include "Randomize.hh"
00035 #include "G4Polyhedron.hh"
00036
00038
00039
00040
00041
00042 G4CSGSolid::G4CSGSolid(const G4String& name) :
00043 G4VSolid(name), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
00044 {
00045 }
00046
00048
00049
00050
00051
00052 G4CSGSolid::G4CSGSolid( __void__& a )
00053 : G4VSolid(a), fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
00054 {
00055 }
00056
00058
00059
00060
00061
00062 G4CSGSolid::~G4CSGSolid()
00063 {
00064 delete fpPolyhedron;
00065 }
00066
00068
00069
00070
00071
00072 G4CSGSolid::G4CSGSolid(const G4CSGSolid& rhs)
00073 : G4VSolid(rhs), fCubicVolume(rhs.fCubicVolume),
00074 fSurfaceArea(rhs.fSurfaceArea), fpPolyhedron(0)
00075 {
00076 }
00077
00079
00080
00081
00082 G4CSGSolid& G4CSGSolid::operator = (const G4CSGSolid& rhs)
00083 {
00084
00085
00086 if (this == &rhs) { return *this; }
00087
00088
00089
00090 G4VSolid::operator=(rhs);
00091
00092
00093
00094 fCubicVolume = rhs.fCubicVolume;
00095 fSurfaceArea = rhs.fSurfaceArea;
00096 fpPolyhedron = 0;
00097
00098 return *this;
00099 }
00100
00101 G4double G4CSGSolid::GetRadiusInRing(G4double rmin, G4double rmax) const
00102 {
00103
00104
00105 if (rmin<=0.) { return rmax*std::sqrt(G4UniformRand()); }
00106 if (rmin!=rmax) { return std::sqrt(G4UniformRand()
00107 * (sqr(rmax)-sqr(rmin))+sqr(rmin)); }
00108 return rmin;
00109 }
00110
00111 std::ostream& G4CSGSolid::StreamInfo(std::ostream& os) const
00112 {
00113 os << "-----------------------------------------------------------\n"
00114 << " *** Dump for solid - " << GetName() << " ***\n"
00115 << " ===================================================\n"
00116 << " Solid type: " << GetEntityType() << "\n"
00117 << " Parameters: \n"
00118 << " NOT available !\n"
00119 << "-----------------------------------------------------------\n";
00120
00121 return os;
00122 }
00123
00124 G4Polyhedron* G4CSGSolid::GetPolyhedron () const
00125 {
00126 if (!fpPolyhedron ||
00127 fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
00128 fpPolyhedron->GetNumberOfRotationSteps())
00129 {
00130 delete fpPolyhedron;
00131 fpPolyhedron = CreatePolyhedron();
00132 }
00133 return fpPolyhedron;
00134 }