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 G4ScaledSolid class 26 // Implementation for G4ScaledSolid class 27 // 27 // 28 // 27.10.15 G.Cosmo: created, based on impleme 28 // 27.10.15 G.Cosmo: created, based on implementation also provided in Root 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include "G4ScaledSolid.hh" 31 #include "G4ScaledSolid.hh" 32 #include "G4BoundingEnvelope.hh" 32 #include "G4BoundingEnvelope.hh" 33 33 34 #include "G4VPVParameterisation.hh" 34 #include "G4VPVParameterisation.hh" 35 35 36 #include "G4ScaleTransform.hh" 36 #include "G4ScaleTransform.hh" 37 37 38 #include "G4VGraphicsScene.hh" 38 #include "G4VGraphicsScene.hh" 39 #include "G4Polyhedron.hh" 39 #include "G4Polyhedron.hh" 40 40 41 ////////////////////////////////////////////// 41 /////////////////////////////////////////////////////////////////// 42 // 42 // 43 // Constructor 43 // Constructor 44 // 44 // 45 G4ScaledSolid::G4ScaledSolid( const G4String& 45 G4ScaledSolid::G4ScaledSolid( const G4String& pName, 46 G4VSolid* 46 G4VSolid* pSolid, 47 const G4Scale3D& 47 const G4Scale3D& pScale ) 48 : G4VSolid(pName), fPtrSolid(pSolid) 48 : G4VSolid(pName), fPtrSolid(pSolid) 49 { 49 { 50 fScale = new G4ScaleTransform(pScale); 50 fScale = new G4ScaleTransform(pScale); 51 } 51 } 52 52 53 ////////////////////////////////////////////// 53 /////////////////////////////////////////////////////////////////// 54 // 54 // 55 // Fake default constructor - sets only member 55 // Fake default constructor - sets only member data and allocates memory 56 // for usage restri 56 // for usage restricted to object persistency 57 // 57 // 58 G4ScaledSolid::G4ScaledSolid( __void__& a ) 58 G4ScaledSolid::G4ScaledSolid( __void__& a ) 59 : G4VSolid(a) 59 : G4VSolid(a) 60 { 60 { 61 } 61 } 62 62 63 ////////////////////////////////////////////// 63 /////////////////////////////////////////////////////////////////// 64 // 64 // 65 // Destructor 65 // Destructor 66 // 66 // 67 G4ScaledSolid::~G4ScaledSolid() 67 G4ScaledSolid::~G4ScaledSolid() 68 { 68 { 69 delete fpPolyhedron; fpPolyhedron = nullptr; 69 delete fpPolyhedron; fpPolyhedron = nullptr; 70 delete fScale; fScale = nullptr; 70 delete fScale; fScale = nullptr; 71 } 71 } 72 72 73 ////////////////////////////////////////////// 73 /////////////////////////////////////////////////////////////// 74 // 74 // 75 // Copy constructor 75 // Copy constructor 76 // 76 // 77 G4ScaledSolid::G4ScaledSolid(const G4ScaledSol 77 G4ScaledSolid::G4ScaledSolid(const G4ScaledSolid& rhs) 78 : G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid), 78 : G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid), 79 fCubicVolume(rhs.fCubicVolume), fSurfaceAr 79 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea) 80 { 80 { 81 fScale = new G4ScaleTransform(*(rhs.fScale)) 81 fScale = new G4ScaleTransform(*(rhs.fScale)); 82 } 82 } 83 83 84 ////////////////////////////////////////////// 84 /////////////////////////////////////////////////////////////// 85 // 85 // 86 // Assignment operator 86 // Assignment operator 87 // 87 // 88 G4ScaledSolid& G4ScaledSolid::operator = (cons 88 G4ScaledSolid& G4ScaledSolid::operator = (const G4ScaledSolid& rhs) 89 { 89 { 90 // Check assignment to self 90 // Check assignment to self 91 // 91 // 92 if (this == &rhs) { return *this; } 92 if (this == &rhs) { return *this; } 93 93 94 // Copy base class data 94 // Copy base class data 95 // 95 // 96 G4VSolid::operator=(rhs); 96 G4VSolid::operator=(rhs); 97 97 98 // Copy data 98 // Copy data 99 // 99 // 100 fPtrSolid = rhs.fPtrSolid; 100 fPtrSolid = rhs.fPtrSolid; 101 delete fScale; 101 delete fScale; 102 fScale = new G4ScaleTransform(*(rhs.fScale)) 102 fScale = new G4ScaleTransform(*(rhs.fScale)); 103 fCubicVolume = rhs.fCubicVolume; 103 fCubicVolume = rhs.fCubicVolume; 104 fSurfaceArea = rhs.fSurfaceArea; 104 fSurfaceArea = rhs.fSurfaceArea; 105 fRebuildPolyhedron = false; 105 fRebuildPolyhedron = false; 106 delete fpPolyhedron; fpPolyhedron = nullptr; 106 delete fpPolyhedron; fpPolyhedron = nullptr; 107 107 108 return *this; 108 return *this; 109 } 109 } 110 110 111 ////////////////////////////////////////////// 111 ////////////////////////////////////////////////////////////////////////// 112 // 112 // 113 // Return original solid not scaled 113 // Return original solid not scaled 114 // 114 // 115 G4VSolid* G4ScaledSolid::GetUnscaledSolid() co 115 G4VSolid* G4ScaledSolid::GetUnscaledSolid() const 116 { 116 { 117 return fPtrSolid; 117 return fPtrSolid; 118 } 118 } 119 119 120 ////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////////// 121 // 121 // 122 // Get bounding box 122 // Get bounding box 123 // << 123 124 void G4ScaledSolid::BoundingLimits(G4ThreeVect 124 void G4ScaledSolid::BoundingLimits(G4ThreeVector& pMin, 125 G4ThreeVect 125 G4ThreeVector& pMax) const 126 { 126 { 127 G4ThreeVector bmin,bmax; 127 G4ThreeVector bmin,bmax; 128 G4ThreeVector scale = fScale->GetScale(); 128 G4ThreeVector scale = fScale->GetScale(); 129 129 130 fPtrSolid->BoundingLimits(bmin,bmax); 130 fPtrSolid->BoundingLimits(bmin,bmax); 131 pMin.set(bmin.x()*scale.x(),bmin.y()*scale.y 131 pMin.set(bmin.x()*scale.x(),bmin.y()*scale.y(),bmin.z()*scale.z()); 132 pMax.set(bmax.x()*scale.x(),bmax.y()*scale.y 132 pMax.set(bmax.x()*scale.x(),bmax.y()*scale.y(),bmax.z()*scale.z()); 133 133 134 // Check correctness of the bounding box 134 // Check correctness of the bounding box 135 // 135 // 136 if (pMin.x() >= pMax.x() || pMin.y() >= pMax 136 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z()) 137 { 137 { 138 std::ostringstream message; 138 std::ostringstream message; 139 message << "Bad bounding box (min >= max) 139 message << "Bad bounding box (min >= max) for solid: " 140 << GetName() << " !" 140 << GetName() << " !" 141 << "\npMin = " << pMin 141 << "\npMin = " << pMin 142 << "\npMax = " << pMax; 142 << "\npMax = " << pMax; 143 G4Exception("G4ScaledSolid::BoundingLimits 143 G4Exception("G4ScaledSolid::BoundingLimits()", "GeomMgt0001", 144 JustWarning, message); 144 JustWarning, message); 145 DumpInfo(); 145 DumpInfo(); 146 } 146 } 147 } 147 } 148 148 149 ////////////////////////////////////////////// 149 ////////////////////////////////////////////////////////////////////////// 150 // 150 // 151 // Calculate extent under transform and specif 151 // Calculate extent under transform and specified limit 152 // 152 // 153 G4bool 153 G4bool 154 G4ScaledSolid::CalculateExtent( const EAxis pA 154 G4ScaledSolid::CalculateExtent( const EAxis pAxis, 155 const G4VoxelL 155 const G4VoxelLimits& pVoxelLimit, 156 const G4Affine 156 const G4AffineTransform& pTransform, 157 G4double 157 G4double& pMin, 158 G4double 158 G4double& pMax ) const 159 { 159 { 160 // Find bounding box of unscaled solid 160 // Find bounding box of unscaled solid 161 G4ThreeVector bmin,bmax; 161 G4ThreeVector bmin,bmax; 162 fPtrSolid->BoundingLimits(bmin,bmax); 162 fPtrSolid->BoundingLimits(bmin,bmax); 163 163 164 // Set combined transformation 164 // Set combined transformation 165 G4Transform3D transform3D = 165 G4Transform3D transform3D = 166 G4Transform3D(pTransform.NetRotation().inv 166 G4Transform3D(pTransform.NetRotation().inverse(), 167 pTransform.NetTranslation()) 167 pTransform.NetTranslation())*GetScaleTransform(); 168 168 169 // Find extent 169 // Find extent 170 G4BoundingEnvelope bbox(bmin,bmax); 170 G4BoundingEnvelope bbox(bmin,bmax); 171 return bbox.CalculateExtent(pAxis,pVoxelLimi 171 return bbox.CalculateExtent(pAxis,pVoxelLimit,transform3D,pMin,pMax); 172 } 172 } 173 173 174 ////////////////////////////////////////////// 174 ///////////////////////////////////////////////////// 175 // 175 // 176 // Inside 176 // Inside 177 // 177 // 178 EInside G4ScaledSolid::Inside(const G4ThreeVec 178 EInside G4ScaledSolid::Inside(const G4ThreeVector& p) const 179 { 179 { 180 return fPtrSolid->Inside(fScale->Transform(p 180 return fPtrSolid->Inside(fScale->Transform(p)); 181 } 181 } 182 182 183 ////////////////////////////////////////////// 183 ////////////////////////////////////////////////////////////// 184 // 184 // 185 // SurfaceNormal 185 // SurfaceNormal 186 // 186 // 187 G4ThreeVector 187 G4ThreeVector 188 G4ScaledSolid::SurfaceNormal( const G4ThreeVec 188 G4ScaledSolid::SurfaceNormal( const G4ThreeVector& p ) const 189 { 189 { 190 // Transform point to unscaled shape frame 190 // Transform point to unscaled shape frame 191 G4ThreeVector newPoint; 191 G4ThreeVector newPoint; 192 fScale->Transform(p, newPoint); 192 fScale->Transform(p, newPoint); 193 193 194 // Compute normal in unscaled frame 194 // Compute normal in unscaled frame 195 G4ThreeVector newNormal = fPtrSolid->Surface 195 G4ThreeVector newNormal = fPtrSolid->SurfaceNormal(newPoint); 196 G4ThreeVector normal; 196 G4ThreeVector normal; 197 197 198 // Convert normal to scaled frame 198 // Convert normal to scaled frame 199 fScale->InverseTransformNormal(newNormal, no 199 fScale->InverseTransformNormal(newNormal, normal); 200 return normal/normal.mag(); 200 return normal/normal.mag(); 201 } 201 } 202 202 203 ////////////////////////////////////////////// 203 ///////////////////////////////////////////////////////////// 204 // 204 // 205 // The same algorithm as in DistanceToIn(p) 205 // The same algorithm as in DistanceToIn(p) 206 // 206 // 207 G4double 207 G4double 208 G4ScaledSolid::DistanceToIn( const G4ThreeVect 208 G4ScaledSolid::DistanceToIn( const G4ThreeVector& p, 209 const G4ThreeVect 209 const G4ThreeVector& v ) const 210 { 210 { 211 // Transform point and direction to unscaled 211 // Transform point and direction to unscaled shape frame 212 G4ThreeVector newPoint; 212 G4ThreeVector newPoint; 213 fScale->Transform(p, newPoint); 213 fScale->Transform(p, newPoint); 214 214 215 // Direction is un-normalized after scale tr 215 // Direction is un-normalized after scale transformation 216 G4ThreeVector newDirection; 216 G4ThreeVector newDirection; 217 fScale->Transform(v, newDirection); 217 fScale->Transform(v, newDirection); 218 newDirection = newDirection/newDirection.mag 218 newDirection = newDirection/newDirection.mag(); 219 219 220 // Compute distance in unscaled system 220 // Compute distance in unscaled system 221 G4double dist = fPtrSolid->DistanceToIn(newP 221 G4double dist = fPtrSolid->DistanceToIn(newPoint,newDirection); 222 222 223 // Return converted distance to global 223 // Return converted distance to global 224 return fScale->InverseTransformDistance(dist 224 return fScale->InverseTransformDistance(dist, newDirection); 225 } 225 } 226 226 227 ////////////////////////////////////////////// 227 //////////////////////////////////////////////////////// 228 // 228 // 229 // Approximate nearest distance from the point 229 // Approximate nearest distance from the point p to the solid from outside 230 // 230 // 231 G4double 231 G4double 232 G4ScaledSolid::DistanceToIn( const G4ThreeVect 232 G4ScaledSolid::DistanceToIn( const G4ThreeVector& p ) const 233 { 233 { 234 // Transform point to unscaled shape frame 234 // Transform point to unscaled shape frame 235 G4ThreeVector newPoint; 235 G4ThreeVector newPoint; 236 fScale->Transform(p, newPoint); 236 fScale->Transform(p, newPoint); 237 237 238 // Compute unscaled safety, then scale it 238 // Compute unscaled safety, then scale it 239 G4double dist = fPtrSolid->DistanceToIn(newP 239 G4double dist = fPtrSolid->DistanceToIn(newPoint); 240 return fScale->InverseTransformDistance(dist 240 return fScale->InverseTransformDistance(dist); 241 } 241 } 242 242 243 ////////////////////////////////////////////// 243 ////////////////////////////////////////////////////////// 244 // 244 // 245 // The same algorithm as DistanceToOut(p) 245 // The same algorithm as DistanceToOut(p) 246 // 246 // 247 G4double 247 G4double 248 G4ScaledSolid::DistanceToOut( const G4ThreeVec 248 G4ScaledSolid::DistanceToOut( const G4ThreeVector& p, 249 const G4ThreeVec 249 const G4ThreeVector& v, 250 const G4bool cal 250 const G4bool calcNorm, 251 G4bool *va 251 G4bool *validNorm, 252 G4ThreeVec 252 G4ThreeVector *n ) const 253 { 253 { 254 // Transform point and direction to unscaled 254 // Transform point and direction to unscaled shape frame 255 G4ThreeVector newPoint; 255 G4ThreeVector newPoint; 256 fScale->Transform(p, newPoint); 256 fScale->Transform(p, newPoint); 257 257 258 // Direction is un-normalized after scale tr 258 // Direction is un-normalized after scale transformation 259 G4ThreeVector newDirection; 259 G4ThreeVector newDirection; 260 fScale->Transform(v, newDirection); 260 fScale->Transform(v, newDirection); 261 newDirection = newDirection/newDirection.mag 261 newDirection = newDirection/newDirection.mag(); 262 262 263 // Compute distance in unscaled system 263 // Compute distance in unscaled system 264 G4ThreeVector solNorm; 264 G4ThreeVector solNorm; 265 G4double dist = fPtrSolid->DistanceToOut(new 265 G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection, 266 cal 266 calcNorm,validNorm,&solNorm); 267 if(calcNorm) 267 if(calcNorm) 268 { 268 { 269 G4ThreeVector normal; 269 G4ThreeVector normal; 270 fScale->TransformNormal(solNorm, normal); 270 fScale->TransformNormal(solNorm, normal); 271 *n = normal.unit(); 271 *n = normal.unit(); 272 } 272 } 273 273 274 // Return distance converted to global 274 // Return distance converted to global 275 return fScale->InverseTransformDistance(dist 275 return fScale->InverseTransformDistance(dist, newDirection); 276 } 276 } 277 277 278 ////////////////////////////////////////////// 278 ////////////////////////////////////////////////////////////// 279 // 279 // 280 // Approximate nearest distance from the poin 280 // Approximate nearest distance from the point p to the solid from inside 281 // 281 // 282 G4double 282 G4double 283 G4ScaledSolid::DistanceToOut( const G4ThreeVec 283 G4ScaledSolid::DistanceToOut( const G4ThreeVector& p ) const 284 { 284 { 285 // Transform point to unscaled shape frame 285 // Transform point to unscaled shape frame 286 G4ThreeVector newPoint; 286 G4ThreeVector newPoint; 287 fScale->Transform(p, newPoint); 287 fScale->Transform(p, newPoint); 288 288 289 // Compute unscaled safety, then scale it 289 // Compute unscaled safety, then scale it 290 G4double dist = fPtrSolid->DistanceToOut(new 290 G4double dist = fPtrSolid->DistanceToOut(newPoint); 291 return fScale->InverseTransformDistance(dist 291 return fScale->InverseTransformDistance(dist); 292 } 292 } 293 293 294 ////////////////////////////////////////////// 294 ////////////////////////////////////////////////////////////// 295 // 295 // 296 // ComputeDimensions 296 // ComputeDimensions 297 // 297 // 298 void 298 void 299 G4ScaledSolid::ComputeDimensions( G4VPVParamet 299 G4ScaledSolid::ComputeDimensions( G4VPVParameterisation*, 300 const G4int, 300 const G4int, 301 const G4VPhy 301 const G4VPhysicalVolume* ) 302 { 302 { 303 DumpInfo(); 303 DumpInfo(); 304 G4Exception("G4ScaledSolid::ComputeDimension 304 G4Exception("G4ScaledSolid::ComputeDimensions()", 305 "GeomSolids0001", FatalException 305 "GeomSolids0001", FatalException, 306 "Method not applicable in this c 306 "Method not applicable in this context!"); 307 } 307 } 308 308 309 ////////////////////////////////////////////// 309 ////////////////////////////////////////////////////////////////////////// 310 // 310 // 311 // Returns a point (G4ThreeVector) randomly an 311 // Returns a point (G4ThreeVector) randomly and uniformly selected 312 // on the solid surface 312 // on the solid surface 313 // 313 // 314 G4ThreeVector G4ScaledSolid::GetPointOnSurface 314 G4ThreeVector G4ScaledSolid::GetPointOnSurface() const 315 { 315 { 316 return fScale->InverseTransform(fPtrSolid->G 316 return fScale->InverseTransform(fPtrSolid->GetPointOnSurface()); 317 } 317 } 318 ////////////////////////////////////////////// << 319 // << 320 // Return the number of constituents used for << 321 // << 322 G4int G4ScaledSolid::GetNumOfConstituents() co << 323 { << 324 return fPtrSolid->GetNumOfConstituents(); << 325 } << 326 << 327 ////////////////////////////////////////////// << 328 // << 329 // Return true if the solid has only planar fa << 330 // << 331 G4bool G4ScaledSolid::IsFaceted() const << 332 { << 333 return fPtrSolid->IsFaceted(); << 334 } << 335 318 336 ////////////////////////////////////////////// 319 ////////////////////////////////////////////////////////////////////////// 337 // 320 // 338 // Return object type name 321 // Return object type name 339 // 322 // 340 G4GeometryType G4ScaledSolid::GetEntityType() 323 G4GeometryType G4ScaledSolid::GetEntityType() const 341 { 324 { 342 return {"G4ScaledSolid"}; << 325 return G4String("G4ScaledSolid"); 343 } 326 } 344 327 345 ////////////////////////////////////////////// 328 ////////////////////////////////////////////////////////////////////////// 346 // 329 // 347 // Make a clone of the object 330 // Make a clone of the object 348 // 331 // 349 G4VSolid* G4ScaledSolid::Clone() const 332 G4VSolid* G4ScaledSolid::Clone() const 350 { 333 { 351 return new G4ScaledSolid(*this); 334 return new G4ScaledSolid(*this); 352 } 335 } 353 336 354 ////////////////////////////////////////////// 337 ////////////////////////////////////////////////////////////////////////// 355 // 338 // 356 // Returning the scaling transformation 339 // Returning the scaling transformation 357 // 340 // 358 G4Scale3D G4ScaledSolid::GetScaleTransform() c 341 G4Scale3D G4ScaledSolid::GetScaleTransform() const 359 { 342 { 360 return { fScale->GetScale().x(), << 343 return G4Scale3D(fScale->GetScale().x(), 361 fScale->GetScale().y(), << 344 fScale->GetScale().y(), 362 fScale->GetScale().z() }; << 345 fScale->GetScale().z()); 363 } 346 } 364 347 365 ////////////////////////////////////////////// 348 ////////////////////////////////////////////////////////////////////////// 366 // 349 // 367 // Setting the scaling transformation 350 // Setting the scaling transformation 368 // 351 // 369 void G4ScaledSolid::SetScaleTransform(const G4 352 void G4ScaledSolid::SetScaleTransform(const G4Scale3D& scale) 370 { 353 { 371 delete fScale; << 354 if (fScale != nullptr) { delete fScale; } 372 fScale = new G4ScaleTransform(scale); 355 fScale = new G4ScaleTransform(scale); 373 fRebuildPolyhedron = true; 356 fRebuildPolyhedron = true; 374 } 357 } 375 358 376 ////////////////////////////////////////////// 359 ////////////////////////////////////////////////////////////////////////// 377 // 360 // 378 // Get volume of the scaled solid 361 // Get volume of the scaled solid 379 // 362 // 380 G4double G4ScaledSolid::GetCubicVolume() 363 G4double G4ScaledSolid::GetCubicVolume() 381 { 364 { 382 if(fCubicVolume < 0.) 365 if(fCubicVolume < 0.) 383 { 366 { 384 fCubicVolume = fPtrSolid->GetCubicVolume() 367 fCubicVolume = fPtrSolid->GetCubicVolume() * 385 fScale->GetScale().x() * 368 fScale->GetScale().x() * 386 fScale->GetScale().y() * 369 fScale->GetScale().y() * 387 fScale->GetScale().z(); 370 fScale->GetScale().z(); 388 } 371 } 389 return fCubicVolume; 372 return fCubicVolume; 390 } 373 } 391 374 392 ////////////////////////////////////////////// 375 ////////////////////////////////////////////////////////////////////////// 393 // 376 // 394 // Get estimated surface area of the scaled so 377 // Get estimated surface area of the scaled solid 395 // 378 // 396 G4double G4ScaledSolid::GetSurfaceArea() 379 G4double G4ScaledSolid::GetSurfaceArea() 397 { 380 { 398 if(fSurfaceArea < 0.) 381 if(fSurfaceArea < 0.) 399 { 382 { 400 fSurfaceArea = G4VSolid::GetSurfaceArea(); 383 fSurfaceArea = G4VSolid::GetSurfaceArea(); 401 } 384 } 402 return fSurfaceArea; 385 return fSurfaceArea; 403 } 386 } 404 387 405 ////////////////////////////////////////////// 388 ////////////////////////////////////////////////////////////////////////// 406 // 389 // 407 // Stream object contents to an output stream 390 // Stream object contents to an output stream 408 // 391 // 409 std::ostream& G4ScaledSolid::StreamInfo(std::o 392 std::ostream& G4ScaledSolid::StreamInfo(std::ostream& os) const 410 { 393 { 411 os << "------------------------------------- 394 os << "-----------------------------------------------------------\n" 412 << " *** Dump for Scaled solid - " << 395 << " *** Dump for Scaled solid - " << GetName() << " ***\n" 413 << " ================================= 396 << " ===================================================\n" 414 << " Solid type: " << GetEntityType() << 397 << " Solid type: " << GetEntityType() << "\n" 415 << " Parameters of constituent solid: \n" 398 << " Parameters of constituent solid: \n" 416 << "===================================== 399 << "===========================================================\n"; 417 fPtrSolid->StreamInfo(os); 400 fPtrSolid->StreamInfo(os); 418 os << "===================================== 401 os << "===========================================================\n" 419 << " Scaling: \n" 402 << " Scaling: \n" 420 << " Scale transformation : \n" 403 << " Scale transformation : \n" 421 << " " << fScale->GetScale().x( 404 << " " << fScale->GetScale().x() << ", " 422 << fScale->GetScale().y( 405 << fScale->GetScale().y() << ", " 423 << fScale->GetScale().z( 406 << fScale->GetScale().z() << "\n" 424 << "===================================== 407 << "===========================================================\n"; 425 408 426 return os; 409 return os; 427 } 410 } 428 411 429 ////////////////////////////////////////////// 412 ////////////////////////////////////////////////////////////////////////// 430 // 413 // 431 // DescribeYourselfTo 414 // DescribeYourselfTo 432 // 415 // 433 void 416 void 434 G4ScaledSolid::DescribeYourselfTo ( G4VGraphic 417 G4ScaledSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const 435 { 418 { 436 scene.AddSolid (*this); 419 scene.AddSolid (*this); 437 } 420 } 438 421 439 ////////////////////////////////////////////// 422 ////////////////////////////////////////////////////////////////////////// 440 // 423 // 441 // CreatePolyhedron 424 // CreatePolyhedron 442 // 425 // 443 G4Polyhedron* 426 G4Polyhedron* 444 G4ScaledSolid::CreatePolyhedron () const 427 G4ScaledSolid::CreatePolyhedron () const 445 { 428 { 446 G4Polyhedron* polyhedron = fPtrSolid->Create 429 G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron(); 447 if (polyhedron != nullptr) 430 if (polyhedron != nullptr) 448 { 431 { 449 polyhedron->Transform(GetScaleTransform()) 432 polyhedron->Transform(GetScaleTransform()); 450 } 433 } 451 else 434 else 452 { 435 { 453 DumpInfo(); 436 DumpInfo(); 454 G4Exception("G4ScaledSolid::CreatePolyhedr 437 G4Exception("G4ScaledSolid::CreatePolyhedron()", 455 "GeomSolids2003", JustWarning, 438 "GeomSolids2003", JustWarning, 456 "No G4Polyhedron for scaled so 439 "No G4Polyhedron for scaled solid"); 457 } 440 } 458 return polyhedron; 441 return polyhedron; 459 } 442 } 460 443 461 ////////////////////////////////////////////// 444 ////////////////////////////////////////////////////////////////////////// 462 // 445 // 463 // GetPolyhedron 446 // GetPolyhedron 464 // 447 // 465 G4Polyhedron* G4ScaledSolid::GetPolyhedron () 448 G4Polyhedron* G4ScaledSolid::GetPolyhedron () const 466 { 449 { 467 if (fpPolyhedron == nullptr || 450 if (fpPolyhedron == nullptr || 468 fRebuildPolyhedron || 451 fRebuildPolyhedron || 469 fpPolyhedron->GetNumberOfRotationStepsAt 452 fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() != 470 fpPolyhedron->GetNumberOfRotationSteps() 453 fpPolyhedron->GetNumberOfRotationSteps()) 471 { 454 { 472 fpPolyhedron = CreatePolyhedron(); 455 fpPolyhedron = CreatePolyhedron(); 473 fRebuildPolyhedron = false; 456 fRebuildPolyhedron = false; 474 } 457 } 475 return fpPolyhedron; 458 return fpPolyhedron; 476 } 459 } 477 460