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 // Implementation for G4UParaboloid wrapper cl 26 // Implementation for G4UParaboloid wrapper class 27 // 27 // 28 // 19.08.2015 Guilherme Lima, FNAL 28 // 19.08.2015 Guilherme Lima, FNAL 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include "G4Paraboloid.hh" 31 #include "G4Paraboloid.hh" 32 #include "G4UParaboloid.hh" 32 #include "G4UParaboloid.hh" 33 33 34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G 34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) ) 35 35 36 #include "G4AffineTransform.hh" 36 #include "G4AffineTransform.hh" 37 #include "G4VPVParameterisation.hh" 37 #include "G4VPVParameterisation.hh" 38 #include "G4PhysicalConstants.hh" 38 #include "G4PhysicalConstants.hh" 39 #include "G4BoundingEnvelope.hh" 39 #include "G4BoundingEnvelope.hh" 40 #include "G4Polyhedron.hh" 40 #include "G4Polyhedron.hh" 41 41 42 ////////////////////////////////////////////// 42 //////////////////////////////////////////////////////////////////////// 43 // 43 // 44 // Constructor - check & set half widths 44 // Constructor - check & set half widths 45 45 46 46 47 G4UParaboloid::G4UParaboloid(const G4String& p 47 G4UParaboloid::G4UParaboloid(const G4String& pName, 48 G4double dz 48 G4double dz, 49 G4double rl 49 G4double rlo, 50 G4double rh 50 G4double rhi ) 51 : Base_t(pName, rlo, rhi, dz) 51 : Base_t(pName, rlo, rhi, dz) 52 { } 52 { } 53 53 54 ////////////////////////////////////////////// 54 ////////////////////////////////////////////////////////////////////////// 55 // 55 // 56 // Fake default constructor - sets only member 56 // Fake default constructor - sets only member data and allocates memory 57 // for usage restri 57 // for usage restricted to object persistency. 58 58 59 G4UParaboloid::G4UParaboloid( __void__& a ) 59 G4UParaboloid::G4UParaboloid( __void__& a ) 60 : Base_t(a) 60 : Base_t(a) 61 { } 61 { } 62 62 63 ////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////////// 64 // 64 // 65 // Destructor 65 // Destructor 66 66 67 G4UParaboloid::~G4UParaboloid() = default; << 67 G4UParaboloid::~G4UParaboloid() { } 68 68 69 ////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////// 70 // 70 // 71 // Copy constructor 71 // Copy constructor 72 72 73 G4UParaboloid::G4UParaboloid(const G4UParabolo 73 G4UParaboloid::G4UParaboloid(const G4UParaboloid& rhs) 74 : Base_t(rhs) 74 : Base_t(rhs) 75 { } 75 { } 76 76 77 ////////////////////////////////////////////// 77 ////////////////////////////////////////////////////////////////////////// 78 // 78 // 79 // Assignment operator 79 // Assignment operator 80 80 81 G4UParaboloid& G4UParaboloid::operator = (cons 81 G4UParaboloid& G4UParaboloid::operator = (const G4UParaboloid& rhs) 82 { 82 { 83 // Check assignment to self 83 // Check assignment to self 84 // 84 // 85 if (this == &rhs) { return *this; } 85 if (this == &rhs) { return *this; } 86 86 87 // Copy base class data 87 // Copy base class data 88 // 88 // 89 Base_t::operator=(rhs); 89 Base_t::operator=(rhs); 90 90 91 return *this; 91 return *this; 92 } 92 } 93 93 94 ////////////////////////////////////////////// 94 ////////////////////////////////////////////////////////////////////////// 95 // 95 // 96 // Accessors 96 // Accessors 97 97 98 G4double G4UParaboloid::GetZHalfLength() const 98 G4double G4UParaboloid::GetZHalfLength() const 99 { 99 { 100 return GetDz(); 100 return GetDz(); 101 } 101 } 102 102 103 G4double G4UParaboloid::GetRadiusMinusZ() cons 103 G4double G4UParaboloid::GetRadiusMinusZ() const 104 { 104 { 105 return GetRlo(); 105 return GetRlo(); 106 } 106 } 107 107 108 G4double G4UParaboloid::GetRadiusPlusZ() const 108 G4double G4UParaboloid::GetRadiusPlusZ() const 109 { 109 { 110 return GetRhi(); 110 return GetRhi(); 111 } 111 } 112 112 113 ////////////////////////////////////////////// 113 ////////////////////////////////////////////////////////////////////////// 114 // 114 // 115 // Modifiers 115 // Modifiers 116 116 117 void G4UParaboloid::SetZHalfLength(G4double dz 117 void G4UParaboloid::SetZHalfLength(G4double dz) 118 { 118 { 119 SetDz(dz); 119 SetDz(dz); 120 } 120 } 121 121 122 void G4UParaboloid::SetRadiusMinusZ(G4double r 122 void G4UParaboloid::SetRadiusMinusZ(G4double r1) 123 { 123 { 124 SetRlo(r1); 124 SetRlo(r1); 125 } 125 } 126 126 127 void G4UParaboloid::SetRadiusPlusZ(G4double r2 127 void G4UParaboloid::SetRadiusPlusZ(G4double r2) 128 { 128 { 129 SetRhi(r2); 129 SetRhi(r2); 130 } 130 } 131 131 132 ////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////////// 133 // 133 // 134 // Make a clone of the object 134 // Make a clone of the object 135 135 136 G4VSolid* G4UParaboloid::Clone() const 136 G4VSolid* G4UParaboloid::Clone() const 137 { 137 { 138 return new G4UParaboloid(*this); 138 return new G4UParaboloid(*this); 139 } 139 } 140 140 141 ////////////////////////////////////////////// 141 ////////////////////////////////////////////////////////////////////////// 142 // 142 // 143 // Get bounding box 143 // Get bounding box 144 144 145 void G4UParaboloid::BoundingLimits(G4ThreeVect 145 void G4UParaboloid::BoundingLimits(G4ThreeVector& pMin, 146 G4ThreeVect 146 G4ThreeVector& pMax) const 147 { 147 { 148 static G4bool checkBBox = true; 148 static G4bool checkBBox = true; 149 149 150 G4double r2 = GetRadiusPlusZ(); 150 G4double r2 = GetRadiusPlusZ(); 151 G4double dz = GetZHalfLength(); 151 G4double dz = GetZHalfLength(); 152 pMin.set(-r2,-r2,-dz); 152 pMin.set(-r2,-r2,-dz); 153 pMax.set( r2, r2, dz); 153 pMax.set( r2, r2, dz); 154 154 155 // Check correctness of the bounding box 155 // Check correctness of the bounding box 156 // 156 // 157 if (pMin.x() >= pMax.x() || pMin.y() >= pMax 157 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z()) 158 { 158 { 159 std::ostringstream message; 159 std::ostringstream message; 160 message << "Bad bounding box (min >= max) 160 message << "Bad bounding box (min >= max) for solid: " 161 << GetName() << " !" 161 << GetName() << " !" 162 << "\npMin = " << pMin 162 << "\npMin = " << pMin 163 << "\npMax = " << pMax; 163 << "\npMax = " << pMax; 164 G4Exception("G4UParaboloid::BoundingLimits 164 G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001", 165 JustWarning, message); 165 JustWarning, message); 166 StreamInfo(G4cout); 166 StreamInfo(G4cout); 167 } 167 } 168 168 169 // Check consistency of bounding boxes 169 // Check consistency of bounding boxes 170 // 170 // 171 if (checkBBox) 171 if (checkBBox) 172 { 172 { 173 U3Vector vmin, vmax; 173 U3Vector vmin, vmax; 174 Extent(vmin,vmax); 174 Extent(vmin,vmax); 175 if (std::abs(pMin.x()-vmin.x()) > kCarTole 175 if (std::abs(pMin.x()-vmin.x()) > kCarTolerance || 176 std::abs(pMin.y()-vmin.y()) > kCarTole 176 std::abs(pMin.y()-vmin.y()) > kCarTolerance || 177 std::abs(pMin.z()-vmin.z()) > kCarTole 177 std::abs(pMin.z()-vmin.z()) > kCarTolerance || 178 std::abs(pMax.x()-vmax.x()) > kCarTole 178 std::abs(pMax.x()-vmax.x()) > kCarTolerance || 179 std::abs(pMax.y()-vmax.y()) > kCarTole 179 std::abs(pMax.y()-vmax.y()) > kCarTolerance || 180 std::abs(pMax.z()-vmax.z()) > kCarTole 180 std::abs(pMax.z()-vmax.z()) > kCarTolerance) 181 { 181 { 182 std::ostringstream message; 182 std::ostringstream message; 183 message << "Inconsistency in bounding bo 183 message << "Inconsistency in bounding boxes for solid: " 184 << GetName() << " !" 184 << GetName() << " !" 185 << "\nBBox min: wrapper = " << p 185 << "\nBBox min: wrapper = " << pMin << " solid = " << vmin 186 << "\nBBox max: wrapper = " << p 186 << "\nBBox max: wrapper = " << pMax << " solid = " << vmax; 187 G4Exception("G4UParaboloid::BoundingLimi 187 G4Exception("G4UParaboloid::BoundingLimits()", "GeomMgt0001", 188 JustWarning, message); 188 JustWarning, message); 189 checkBBox = false; 189 checkBBox = false; 190 } 190 } 191 } 191 } 192 } 192 } 193 193 194 ////////////////////////////////////////////// 194 ////////////////////////////////////////////////////////////////////////// 195 // 195 // 196 // Calculate extent under transform and specif 196 // Calculate extent under transform and specified limit 197 197 198 G4bool 198 G4bool 199 G4UParaboloid::CalculateExtent(const EAxis pAx 199 G4UParaboloid::CalculateExtent(const EAxis pAxis, 200 const G4VoxelLi 200 const G4VoxelLimits& pVoxelLimit, 201 const G4AffineT 201 const G4AffineTransform& pTransform, 202 G4double& 202 G4double& pMin, G4double& pMax) const 203 { 203 { 204 G4ThreeVector bmin, bmax; 204 G4ThreeVector bmin, bmax; 205 205 206 // Get bounding box 206 // Get bounding box 207 BoundingLimits(bmin,bmax); 207 BoundingLimits(bmin,bmax); 208 208 209 // Find extent 209 // Find extent 210 G4BoundingEnvelope bbox(bmin,bmax); 210 G4BoundingEnvelope bbox(bmin,bmax); 211 return bbox.CalculateExtent(pAxis,pVoxelLimi 211 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax); 212 } 212 } 213 213 214 ////////////////////////////////////////////// 214 //////////////////////////////////////////////////////////////////////// 215 // 215 // 216 // CreatePolyhedron 216 // CreatePolyhedron 217 // 217 // 218 G4Polyhedron* G4UParaboloid::CreatePolyhedron( 218 G4Polyhedron* G4UParaboloid::CreatePolyhedron() const 219 { 219 { 220 return new G4PolyhedronParaboloid(GetRadiusM 220 return new G4PolyhedronParaboloid(GetRadiusMinusZ(), 221 GetRadiusP 221 GetRadiusPlusZ(), 222 GetZHalfLe 222 GetZHalfLength(), 0., twopi); 223 } 223 } 224 224 225 #endif // G4GEOM_USE_USOLIDS 225 #endif // G4GEOM_USE_USOLIDS 226 226