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 // >> 27 // 26 // Implementation for G4UHype wrapper class 28 // Implementation for G4UHype wrapper class 27 // 29 // 28 // 16-10-2017 G.Cosmo, CERN 30 // 16-10-2017 G.Cosmo, CERN >> 31 // 29 // ------------------------------------------- 32 // -------------------------------------------------------------------- 30 33 31 #include "G4Hype.hh" 34 #include "G4Hype.hh" 32 35 33 #include "G4UHype.hh" 36 #include "G4UHype.hh" 34 37 35 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G 38 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) ) 36 39 37 #include "G4AffineTransform.hh" 40 #include "G4AffineTransform.hh" 38 #include "G4VPVParameterisation.hh" 41 #include "G4VPVParameterisation.hh" 39 #include "G4BoundingEnvelope.hh" 42 #include "G4BoundingEnvelope.hh" 40 #include "G4Polyhedron.hh" 43 #include "G4Polyhedron.hh" 41 44 42 ////////////////////////////////////////////// 45 //////////////////////////////////////////////////////////////////////// 43 // 46 // 44 // Constructor 47 // Constructor 45 48 46 G4UHype::G4UHype(const G4String& pName, 49 G4UHype::G4UHype(const G4String& pName, 47 G4double newInnerRadiu 50 G4double newInnerRadius, 48 G4double newOuterRadiu 51 G4double newOuterRadius, 49 G4double newInnerStere 52 G4double newInnerStereo, 50 G4double newOuterStere 53 G4double newOuterStereo, 51 G4double newHalfLenZ) 54 G4double newHalfLenZ) 52 : Base_t(pName, newInnerRadius, newOuterRadi 55 : Base_t(pName, newInnerRadius, newOuterRadius, 53 newInnerStereo, newOuterSter 56 newInnerStereo, newOuterStereo, newHalfLenZ) 54 { } 57 { } 55 58 56 ////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////// 57 // 60 // 58 // Fake default constructor - sets only member 61 // Fake default constructor - sets only member data and allocates memory 59 // for usage restri 62 // for usage restricted to object persistency. 60 63 61 G4UHype::G4UHype( __void__& a ) 64 G4UHype::G4UHype( __void__& a ) 62 : Base_t(a) 65 : Base_t(a) 63 { } 66 { } 64 67 65 ////////////////////////////////////////////// 68 ////////////////////////////////////////////////////////////////////////// 66 // 69 // 67 // Destructor 70 // Destructor 68 71 69 G4UHype::~G4UHype() = default; << 72 G4UHype::~G4UHype() { } 70 73 71 ////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////// 72 // 75 // 73 // Copy constructor 76 // Copy constructor 74 77 75 G4UHype::G4UHype(const G4UHype& rhs) 78 G4UHype::G4UHype(const G4UHype& rhs) 76 : Base_t(rhs) 79 : Base_t(rhs) 77 { } 80 { } 78 81 79 ////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////////// 80 // 83 // 81 // Assignment operator 84 // Assignment operator 82 85 83 G4UHype& G4UHype::operator = (const G4UHype& r 86 G4UHype& G4UHype::operator = (const G4UHype& rhs) 84 { 87 { 85 // Check assignment to self 88 // Check assignment to self 86 // 89 // 87 if (this == &rhs) { return *this; } 90 if (this == &rhs) { return *this; } 88 91 89 // Copy base class data 92 // Copy base class data 90 // 93 // 91 Base_t::operator=(rhs); 94 Base_t::operator=(rhs); 92 95 93 return *this; 96 return *this; 94 } 97 } 95 98 96 ////////////////////////////////////////////// 99 ////////////////////////////////////////////////////////////////////////// 97 // 100 // 98 // Accessors 101 // Accessors 99 102 100 G4double G4UHype::GetInnerRadius () const 103 G4double G4UHype::GetInnerRadius () const 101 { 104 { 102 return GetRmin(); 105 return GetRmin(); 103 } 106 } 104 107 105 G4double G4UHype::GetOuterRadius () const 108 G4double G4UHype::GetOuterRadius () const 106 { 109 { 107 return GetRmax(); 110 return GetRmax(); 108 } 111 } 109 112 110 G4double G4UHype::GetZHalfLength () const 113 G4double G4UHype::GetZHalfLength () const 111 { 114 { 112 return GetDz(); 115 return GetDz(); 113 } 116 } 114 117 115 G4double G4UHype::GetInnerStereo () const 118 G4double G4UHype::GetInnerStereo () const 116 { 119 { 117 return GetStIn(); 120 return GetStIn(); 118 } 121 } 119 122 120 G4double G4UHype::GetOuterStereo () const 123 G4double G4UHype::GetOuterStereo () const 121 { 124 { 122 return GetStOut(); 125 return GetStOut(); 123 } 126 } 124 127 125 ////////////////////////////////////////////// 128 ////////////////////////////////////////////////////////////////////////// 126 // 129 // 127 // Modifiers 130 // Modifiers 128 131 129 void G4UHype::SetInnerRadius (G4double newIRad 132 void G4UHype::SetInnerRadius (G4double newIRad) 130 { 133 { 131 SetParameters(newIRad, GetRmax(), GetStIn(), 134 SetParameters(newIRad, GetRmax(), GetStIn(), GetStOut(), GetDz()); 132 fRebuildPolyhedron = true; 135 fRebuildPolyhedron = true; 133 } 136 } 134 137 135 void G4UHype::SetOuterRadius (G4double newORad 138 void G4UHype::SetOuterRadius (G4double newORad) 136 { 139 { 137 SetParameters(GetRmin(), newORad, GetStIn(), 140 SetParameters(GetRmin(), newORad, GetStIn(), GetStOut(), GetDz()); 138 fRebuildPolyhedron = true; 141 fRebuildPolyhedron = true; 139 } 142 } 140 143 141 void G4UHype::SetZHalfLength (G4double newHLZ) 144 void G4UHype::SetZHalfLength (G4double newHLZ) 142 { 145 { 143 SetParameters(GetRmin(), GetRmax(), GetStIn( 146 SetParameters(GetRmin(), GetRmax(), GetStIn(), GetStOut(), newHLZ); 144 fRebuildPolyhedron = true; 147 fRebuildPolyhedron = true; 145 } 148 } 146 149 147 void G4UHype::SetInnerStereo (G4double newISte 150 void G4UHype::SetInnerStereo (G4double newISte) 148 { 151 { 149 SetParameters(GetRmin(), GetRmax(), newISte, 152 SetParameters(GetRmin(), GetRmax(), newISte, GetStOut(), GetDz()); 150 fRebuildPolyhedron = true; 153 fRebuildPolyhedron = true; 151 } 154 } 152 155 153 void G4UHype::SetOuterStereo (G4double newOSte 156 void G4UHype::SetOuterStereo (G4double newOSte) 154 { 157 { 155 SetParameters(GetRmin(), GetRmax(), GetStIn( 158 SetParameters(GetRmin(), GetRmax(), GetStIn(), newOSte, GetDz()); 156 fRebuildPolyhedron = true; 159 fRebuildPolyhedron = true; 157 } 160 } 158 161 159 162 160 ////////////////////////////////////////////// 163 //////////////////////////////////////////////////////////////////////// 161 // 164 // 162 // Dispatch to parameterisation for replicatio 165 // Dispatch to parameterisation for replication mechanism dimension 163 // computation & modification. 166 // computation & modification. 164 167 165 void G4UHype::ComputeDimensions(G4VPVParameter 168 void G4UHype::ComputeDimensions(G4VPVParameterisation* p, 166 const G4int n, 169 const G4int n, 167 const G4VPhysi 170 const G4VPhysicalVolume* pRep) 168 { 171 { 169 p->ComputeDimensions(*(G4Hype*)this,n,pRep); 172 p->ComputeDimensions(*(G4Hype*)this,n,pRep); 170 } 173 } 171 174 172 175 173 ////////////////////////////////////////////// 176 ////////////////////////////////////////////////////////////////////////// 174 // 177 // 175 // Make a clone of the object 178 // Make a clone of the object 176 179 177 G4VSolid* G4UHype::Clone() const 180 G4VSolid* G4UHype::Clone() const 178 { 181 { 179 return new G4UHype(*this); 182 return new G4UHype(*this); 180 } 183 } 181 184 182 ////////////////////////////////////////////// 185 ////////////////////////////////////////////////////////////////////////// 183 // 186 // 184 // Get bounding box 187 // Get bounding box 185 188 186 void G4UHype::BoundingLimits(G4ThreeVector& pM 189 void G4UHype::BoundingLimits(G4ThreeVector& pMin, 187 G4ThreeVector& pM 190 G4ThreeVector& pMax) const 188 { 191 { 189 G4double endORadius = GetEndInnerRadius(); 192 G4double endORadius = GetEndInnerRadius(); 190 pMin.set(-endORadius,-endORadius,-GetDz()); 193 pMin.set(-endORadius,-endORadius,-GetDz()); 191 pMax.set( endORadius, endORadius, GetDz()); 194 pMax.set( endORadius, endORadius, GetDz()); 192 195 193 // Check correctness of the bounding box 196 // Check correctness of the bounding box 194 // 197 // 195 if (pMin.x() >= pMax.x() || pMin.y() >= pMax 198 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z()) 196 { 199 { 197 std::ostringstream message; 200 std::ostringstream message; 198 message << "Bad bounding box (min >= max) 201 message << "Bad bounding box (min >= max) for solid: " 199 << GetName() << " !" 202 << GetName() << " !" 200 << "\npMin = " << pMin 203 << "\npMin = " << pMin 201 << "\npMax = " << pMax; 204 << "\npMax = " << pMax; 202 G4Exception("G4UHype::BoundingLimits()", " 205 G4Exception("G4UHype::BoundingLimits()", "GeomMgt0001", 203 JustWarning, message); 206 JustWarning, message); 204 StreamInfo(G4cout); 207 StreamInfo(G4cout); 205 } 208 } 206 } 209 } 207 210 208 ////////////////////////////////////////////// 211 ////////////////////////////////////////////////////////////////////////// 209 // 212 // 210 // Calculate extent under transform and specif 213 // Calculate extent under transform and specified limit 211 214 212 G4bool 215 G4bool 213 G4UHype::CalculateExtent(const EAxis pAxis, 216 G4UHype::CalculateExtent(const EAxis pAxis, 214 const G4VoxelLimits& 217 const G4VoxelLimits& pVoxelLimit, 215 const G4AffineTransfo 218 const G4AffineTransform& pTransform, 216 G4double& pMin, 219 G4double& pMin, G4double& pMax) const 217 { 220 { 218 G4ThreeVector bmin, bmax; 221 G4ThreeVector bmin, bmax; 219 222 220 // Get bounding box 223 // Get bounding box 221 BoundingLimits(bmin,bmax); 224 BoundingLimits(bmin,bmax); 222 225 223 // Find extent 226 // Find extent 224 G4BoundingEnvelope bbox(bmin,bmax); 227 G4BoundingEnvelope bbox(bmin,bmax); 225 return bbox.CalculateExtent(pAxis,pVoxelLimi 228 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax); 226 } 229 } 227 230 228 ////////////////////////////////////////////// 231 //////////////////////////////////////////////////////////////////////// 229 // 232 // 230 // CreatePolyhedron 233 // CreatePolyhedron 231 // 234 // 232 G4Polyhedron* G4UHype::CreatePolyhedron() cons 235 G4Polyhedron* G4UHype::CreatePolyhedron() const 233 { 236 { 234 return new G4PolyhedronHype(GetRmin(), GetRm 237 return new G4PolyhedronHype(GetRmin(), GetRmax(), 235 GetTIn2(), GetTO 238 GetTIn2(), GetTOut2(), GetDz()); 236 } 239 } 237 240 238 #endif // G4GEOM_USE_USOLIDS 241 #endif // G4GEOM_USE_USOLIDS 239 242