Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. 1 // 3 // 2 // ******************************************* << 4 // By copying, distributing or modifying the Program (or any work 3 // * License and Disclaimer << 5 // based on the Program) you indicate your acceptance of this statement, 4 // * << 6 // and all its terms. 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // 7 // 26 // Implementation of G4DisplacedSolid class fo << 8 // $Id: G4DisplacedSolid.cc,v 1.13 2000/11/22 15:19:20 grichine Exp $ >> 9 // GEANT4 tag $Name: geant4-03-00 $ >> 10 // >> 11 // Implementation for G4DisplacedSolid class for boolean 27 // operations between other solids 12 // operations between other solids 28 // 13 // 29 // 28.10.98 V.Grichine: created << 14 // History: 30 // 28.02.18 E.Tcherniaev: improved contruction << 15 // 31 // ------------------------------------------- << 16 // 28.10.98 V.Grichine, creation according J. Apostolakis's recommendations >> 17 // 14.11.99 V.Grichine, modifications in CalculateExtent(...) method >> 18 // 22.11.00 V.Grichine, new set methods for matrix/vectors 32 19 33 #include "G4DisplacedSolid.hh" 20 #include "G4DisplacedSolid.hh" 34 21 >> 22 35 #include "G4VoxelLimits.hh" 23 #include "G4VoxelLimits.hh" >> 24 #include "G4AffineTransform.hh" 36 25 37 #include "G4VPVParameterisation.hh" 26 #include "G4VPVParameterisation.hh" 38 27 39 #include "G4VGraphicsScene.hh" 28 #include "G4VGraphicsScene.hh" 40 #include "G4Polyhedron.hh" 29 #include "G4Polyhedron.hh" >> 30 #include "G4NURBS.hh" >> 31 #include "G4NURBSbox.hh" 41 32 42 ////////////////////////////////////////////// 33 //////////////////////////////////////////////////////////////// 43 // 34 // 44 // Constructor for transformation like rotatio << 35 // Constractor for transformation like rotation of frame then translation 45 // in new frame. It is similar to 1st constrac 36 // in new frame. It is similar to 1st constractor in G4PVPlacement 46 37 47 G4DisplacedSolid::G4DisplacedSolid( const G4St << 38 G4DisplacedSolid:: 48 G4VS << 39 G4DisplacedSolid( const G4String& pName, 49 G4Ro << 40 G4VSolid* pSolid , 50 const G4Th << 41 G4RotationMatrix* rotMatrix, 51 : G4VSolid(pName) << 42 const G4ThreeVector& transVector ) 52 { << 43 : G4VSolid(pName) 53 if (pSolid->GetEntityType() == "G4DisplacedS << 44 { 54 { << 45 fPtrSolid = pSolid ; 55 fPtrSolid = ((G4DisplacedSolid*)pSolid)->G << 46 fPtrTransform = new G4AffineTransform(rotMatrix,transVector) ; 56 G4AffineTransform t1 = ((G4DisplacedSolid* << 47 fPtrTransform->Invert() ; 57 G4AffineTransform t2 = G4AffineTransform(r << 48 fDirectTransform = new G4AffineTransform(rotMatrix,transVector) ; 58 fDirectTransform = new G4AffineTransform(t << 59 } << 60 else << 61 { << 62 fPtrSolid = pSolid; << 63 fDirectTransform = new G4AffineTransform(r << 64 } << 65 fPtrTransform = new G4AffineTransform(fDirec << 66 } 49 } 67 50 68 ////////////////////////////////////////////// 51 ///////////////////////////////////////////////////////////////////////////////// 69 // 52 // 70 // Constructor << 71 << 72 G4DisplacedSolid::G4DisplacedSolid( const G4St << 73 G4VS << 74 const G4Tr << 75 : G4VSolid(pName) << 76 { << 77 if (pSolid->GetEntityType() == "G4DisplacedS << 78 { << 79 fPtrSolid = ((G4DisplacedSolid*)pSolid)->G << 80 G4AffineTransform t1 = ((G4DisplacedSolid* << 81 G4AffineTransform t2 = G4AffineTransform(t << 82 t << 83 fDirectTransform = new G4AffineTransform(t << 84 } << 85 else << 86 { << 87 fPtrSolid = pSolid; << 88 fDirectTransform = new G4AffineTransform(t << 89 t << 90 } << 91 fPtrTransform = new G4AffineTransform(fDirec << 92 } << 93 << 94 ////////////////////////////////////////////// << 95 // 53 // 96 // Constructor for use with creation of Transi << 97 // from Persistent object << 98 << 99 G4DisplacedSolid::G4DisplacedSolid( const G4St 54 G4DisplacedSolid::G4DisplacedSolid( const G4String& pName, 100 G4VS 55 G4VSolid* pSolid , 101 const G4Af << 56 const G4Transform3D& transform ) : 102 : G4VSolid(pName) << 57 G4VSolid(pName) 103 { 58 { 104 if (pSolid->GetEntityType() == "G4DisplacedS << 59 fPtrSolid = pSolid ; 105 { << 60 fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(), 106 fPtrSolid = ((G4DisplacedSolid*)pSolid)->G << 61 transform.getTranslation()) ; 107 G4AffineTransform t1 = ((G4DisplacedSolid* << 62 108 auto t2 = G4AffineTransform(directTransfo << 63 fPtrTransform = new G4AffineTransform(transform.getRotation().inverse(), 109 fDirectTransform = new G4AffineTransform(t << 64 transform.getTranslation()) ; 110 } << 65 fPtrTransform->Invert() ; 111 else << 112 { << 113 fPtrSolid = pSolid; << 114 fDirectTransform = new G4AffineTransform(d << 115 } << 116 fPtrTransform = new G4AffineTransform(fDirec << 117 } 66 } 118 67 119 ////////////////////////////////////////////// << 68 ///////////////////////////////////////////////////////////////////////////////// >> 69 // Constructor for use with creation of Transient object from Persistent object 120 // 70 // 121 // Fake default constructor - sets only member << 122 // for usage restri << 123 71 124 G4DisplacedSolid::G4DisplacedSolid( __void__& << 72 G4DisplacedSolid::G4DisplacedSolid( const G4String& pName, 125 : G4VSolid(a) << 73 G4VSolid* pSolid , 126 { << 74 const G4AffineTransform directTransform ) : >> 75 G4VSolid(pName) >> 76 { >> 77 fPtrSolid = pSolid ; >> 78 fDirectTransform = new G4AffineTransform( directTransform ); >> 79 fPtrTransform = new G4AffineTransform( directTransform.Inverse() ) ; 127 } 80 } 128 81 129 ////////////////////////////////////////////// 82 /////////////////////////////////////////////////////////////////// 130 // 83 // 131 // Destructor << 132 84 133 G4DisplacedSolid::~G4DisplacedSolid() 85 G4DisplacedSolid::~G4DisplacedSolid() 134 { 86 { 135 CleanTransformations(); << 87 if(fPtrTransform) 136 delete fpPolyhedron; fpPolyhedron = nullptr; << 137 } << 138 << 139 ////////////////////////////////////////////// << 140 // << 141 // Copy constructor << 142 << 143 G4DisplacedSolid::G4DisplacedSolid(const G4Dis << 144 : G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid) << 145 { << 146 fPtrTransform = new G4AffineTransform(*(rhs. << 147 fDirectTransform = new G4AffineTransform(*(r << 148 } << 149 << 150 ////////////////////////////////////////////// << 151 // << 152 // Assignment operator << 153 << 154 G4DisplacedSolid& G4DisplacedSolid::operator = << 155 { << 156 // Check assignment to self << 157 // << 158 if (this == &rhs) { return *this; } << 159 << 160 // Copy base class data << 161 // << 162 G4VSolid::operator=(rhs); << 163 << 164 // Copy data << 165 // << 166 fPtrSolid = rhs.fPtrSolid; << 167 delete fPtrTransform; delete fDirectTransfor << 168 fPtrTransform = new G4AffineTransform(*(rhs. << 169 fDirectTransform = new G4AffineTransform(*(r << 170 fRebuildPolyhedron = false; << 171 delete fpPolyhedron; fpPolyhedron = nullptr; << 172 << 173 return *this; << 174 } << 175 << 176 void G4DisplacedSolid::CleanTransformations() << 177 { << 178 if(fPtrTransform != nullptr) << 179 { 88 { 180 delete fPtrTransform; fPtrTransform = null << 89 delete fPtrTransform ; 181 delete fDirectTransform; fDirectTransform << 90 delete fDirectTransform; 182 } 91 } 183 } 92 } 184 93 185 const G4DisplacedSolid* G4DisplacedSolid::GetD << 94 G4GeometryType G4DisplacedSolid::GetEntityType() const 186 { 95 { 187 return this; << 96 return G4String("G4DisplacedSolid"); 188 } 97 } 189 98 190 G4DisplacedSolid* G4DisplacedSolid::GetDisplac << 99 const G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr() const 191 { << 100 { return this; } 192 return this; << 101 193 } << 102 G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr() >> 103 { return this; } 194 104 195 G4VSolid* G4DisplacedSolid::GetConstituentMove 105 G4VSolid* G4DisplacedSolid::GetConstituentMovedSolid() const 196 { 106 { 197 return fPtrSolid; 107 return fPtrSolid; 198 } 108 } 199 109 200 ////////////////////////////////////////////// 110 ///////////////////////////////////////////////////////////////////////////// 201 111 202 G4AffineTransform G4DisplacedSolid::GetTransf 112 G4AffineTransform G4DisplacedSolid::GetTransform() const 203 { 113 { 204 G4AffineTransform aTransform = *fPtrTransfor << 114 G4AffineTransform aTransform = *fPtrTransform; 205 return aTransform; << 115 return aTransform; 206 } 116 } 207 117 208 void G4DisplacedSolid::SetTransform(G4AffineTr 118 void G4DisplacedSolid::SetTransform(G4AffineTransform& transform) 209 { 119 { 210 fPtrTransform = &transform ; << 120 fPtrTransform = &transform ; 211 fRebuildPolyhedron = true; << 212 } 121 } 213 122 214 ////////////////////////////////////////////// 123 ////////////////////////////////////////////////////////////////////////////// 215 124 216 G4AffineTransform G4DisplacedSolid::GetDirect 125 G4AffineTransform G4DisplacedSolid::GetDirectTransform() const 217 { 126 { 218 G4AffineTransform aTransform= *fDirectTransf << 127 G4AffineTransform aTransform= *fDirectTransform; 219 return aTransform; << 128 return aTransform; 220 } 129 } 221 130 222 void G4DisplacedSolid::SetDirectTransform(G4Af 131 void G4DisplacedSolid::SetDirectTransform(G4AffineTransform& transform) 223 { 132 { 224 fDirectTransform = &transform ; << 133 fDirectTransform = &transform ; 225 fRebuildPolyhedron = true; << 226 } 134 } 227 135 228 ////////////////////////////////////////////// 136 ///////////////////////////////////////////////////////////////////////////// 229 137 230 G4RotationMatrix G4DisplacedSolid::GetFrameRot 138 G4RotationMatrix G4DisplacedSolid::GetFrameRotation() const 231 { 139 { 232 G4RotationMatrix InvRotation = fDirectTransf << 140 G4RotationMatrix InvRotation= fDirectTransform->NetRotation(); 233 return InvRotation; << 141 return InvRotation; 234 } 142 } 235 143 236 void G4DisplacedSolid::SetFrameRotation(const 144 void G4DisplacedSolid::SetFrameRotation(const G4RotationMatrix& matrix) 237 { 145 { 238 fDirectTransform->SetNetRotation(matrix); << 146 fDirectTransform->SetNetRotation(matrix); 239 fRebuildPolyhedron = true; << 240 } 147 } 241 148 242 ////////////////////////////////////////////// 149 ///////////////////////////////////////////////////////////////////////////// 243 150 244 G4ThreeVector G4DisplacedSolid::GetFrameTrans 151 G4ThreeVector G4DisplacedSolid::GetFrameTranslation() const 245 { 152 { 246 return fPtrTransform->NetTranslation(); << 153 return fPtrTransform->NetTranslation(); 247 } 154 } 248 155 249 void G4DisplacedSolid::SetFrameTranslation(con 156 void G4DisplacedSolid::SetFrameTranslation(const G4ThreeVector& vector) 250 { 157 { 251 fPtrTransform->SetNetTranslation(vector); 158 fPtrTransform->SetNetTranslation(vector); 252 fRebuildPolyhedron = true; << 253 } 159 } 254 160 255 ////////////////////////////////////////////// 161 /////////////////////////////////////////////////////////////// 256 162 257 G4RotationMatrix G4DisplacedSolid::GetObjectRo 163 G4RotationMatrix G4DisplacedSolid::GetObjectRotation() const 258 { 164 { 259 G4RotationMatrix Rotation = fPtrTransform->N << 165 G4RotationMatrix Rotation= fPtrTransform->NetRotation(); 260 return Rotation; << 166 return Rotation; 261 } 167 } 262 168 263 void G4DisplacedSolid::SetObjectRotation(const 169 void G4DisplacedSolid::SetObjectRotation(const G4RotationMatrix& matrix) 264 { 170 { 265 fPtrTransform->SetNetRotation(matrix); << 171 fPtrTransform->SetNetRotation(matrix); 266 fRebuildPolyhedron = true; << 267 } 172 } 268 173 269 ////////////////////////////////////////////// 174 /////////////////////////////////////////////////////////////////////// 270 175 271 G4ThreeVector G4DisplacedSolid::GetObjectTran 176 G4ThreeVector G4DisplacedSolid::GetObjectTranslation() const 272 { 177 { 273 return fDirectTransform->NetTranslation(); << 178 return fDirectTransform->NetTranslation(); 274 } 179 } 275 180 276 void G4DisplacedSolid::SetObjectTranslation(co 181 void G4DisplacedSolid::SetObjectTranslation(const G4ThreeVector& vector) 277 { 182 { 278 fDirectTransform->SetNetTranslation(vector); 183 fDirectTransform->SetNetTranslation(vector); 279 fRebuildPolyhedron = true; << 280 } 184 } 281 185 282 ////////////////////////////////////////////// << 186 /////////////////////////////////////////////////////////////// 283 // 187 // 284 // Get bounding box << 285 << 286 void G4DisplacedSolid::BoundingLimits(G4ThreeV << 287 G4ThreeV << 288 { << 289 if (!fDirectTransform->IsRotated()) << 290 { << 291 // Special case of pure translation << 292 // << 293 fPtrSolid->BoundingLimits(pMin,pMax); << 294 G4ThreeVector offset = fDirectTransform->N << 295 pMin += offset; << 296 pMax += offset; << 297 } << 298 else << 299 { << 300 // General case, use CalculateExtent() to << 301 // << 302 G4VoxelLimits unLimit; << 303 G4double xmin,xmax,ymin,ymax,zmin,zmax; << 304 fPtrSolid->CalculateExtent(kXAxis,unLimit, << 305 fPtrSolid->CalculateExtent(kYAxis,unLimit, << 306 fPtrSolid->CalculateExtent(kZAxis,unLimit, << 307 pMin.set(xmin,ymin,zmin); << 308 pMax.set(xmax,ymax,zmax); << 309 } << 310 << 311 // Check correctness of the bounding box << 312 // << 313 if (pMin.x() >= pMax.x() || pMin.y() >= pMax << 314 { << 315 std::ostringstream message; << 316 message << "Bad bounding box (min >= max) << 317 << GetName() << " !" << 318 << "\npMin = " << pMin << 319 << "\npMax = " << pMax; << 320 G4Exception("G4DisplacedSolid::BoundingLim << 321 JustWarning, message); << 322 DumpInfo(); << 323 } << 324 } << 325 << 326 ////////////////////////////////////////////// << 327 // 188 // 328 // Calculate extent under transform and specif << 329 189 330 G4bool 190 G4bool 331 G4DisplacedSolid::CalculateExtent( const EAxis 191 G4DisplacedSolid::CalculateExtent( const EAxis pAxis, 332 const G4Vox << 192 const G4VoxelLimits& pVoxelLimit, 333 const G4Aff << 193 const G4AffineTransform& pTransform, 334 G4dou << 194 G4double& pMin, 335 G4dou 195 G4double& pMax ) const 336 { 196 { 337 G4AffineTransform sumTransform ; 197 G4AffineTransform sumTransform ; 338 sumTransform.Product(*fDirectTransform,pTran 198 sumTransform.Product(*fDirectTransform,pTransform) ; 339 return fPtrSolid->CalculateExtent(pAxis,pVox << 199 return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform, >> 200 pMin,pMax) ; 340 } 201 } 341 202 342 ////////////////////////////////////////////// 203 ///////////////////////////////////////////////////// 343 // 204 // 344 // SurfaceNormal << 205 // 345 206 346 EInside G4DisplacedSolid::Inside(const G4Three 207 EInside G4DisplacedSolid::Inside(const G4ThreeVector& p) const 347 { 208 { 348 G4ThreeVector newPoint = fPtrTransform->Tran 209 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ; 349 return fPtrSolid->Inside(newPoint) ; 210 return fPtrSolid->Inside(newPoint) ; 350 } 211 } 351 212 352 ////////////////////////////////////////////// 213 ////////////////////////////////////////////////////////////// 353 // 214 // 354 // 215 // 355 216 356 G4ThreeVector 217 G4ThreeVector 357 G4DisplacedSolid::SurfaceNormal( const G4Three 218 G4DisplacedSolid::SurfaceNormal( const G4ThreeVector& p ) const 358 { 219 { 359 G4ThreeVector newPoint = fPtrTransform->Tran 220 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ; 360 G4ThreeVector normal = fPtrSolid->SurfaceNor 221 G4ThreeVector normal = fPtrSolid->SurfaceNormal(newPoint) ; 361 return fDirectTransform->TransformAxis(norma 222 return fDirectTransform->TransformAxis(normal) ; >> 223 362 } 224 } 363 225 364 ////////////////////////////////////////////// 226 ///////////////////////////////////////////////////////////// 365 // 227 // 366 // The same algorithm as in DistanceToIn(p) 228 // The same algorithm as in DistanceToIn(p) 367 229 368 G4double 230 G4double 369 G4DisplacedSolid::DistanceToIn( const G4ThreeV 231 G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p, 370 const G4ThreeV << 232 const G4ThreeVector& v ) const 371 { 233 { 372 G4ThreeVector newPoint = fPtrTransform->Tran 234 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ; 373 G4ThreeVector newDirection = fPtrTransform-> 235 G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ; 374 return fPtrSolid->DistanceToIn(newPoint,newD 236 return fPtrSolid->DistanceToIn(newPoint,newDirection) ; 375 } 237 } 376 238 377 ////////////////////////////////////////////// 239 //////////////////////////////////////////////////////// 378 // 240 // 379 // Approximate nearest distance from the point 241 // Approximate nearest distance from the point p to the intersection of 380 // two solids 242 // two solids 381 243 382 G4double 244 G4double 383 G4DisplacedSolid::DistanceToIn( const G4ThreeV << 245 G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p) const 384 { 246 { 385 G4ThreeVector newPoint = fPtrTransform->Tran 247 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ; 386 return fPtrSolid->DistanceToIn(newPoint) ; 248 return fPtrSolid->DistanceToIn(newPoint) ; 387 } 249 } 388 250 389 ////////////////////////////////////////////// 251 ////////////////////////////////////////////////////////// 390 // 252 // 391 // The same algorithm as DistanceToOut(p) 253 // The same algorithm as DistanceToOut(p) 392 254 393 G4double 255 G4double 394 G4DisplacedSolid::DistanceToOut( const G4Three 256 G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p, 395 const G4Three << 257 const G4ThreeVector& v, 396 const G4bool << 258 const G4bool calcNorm, 397 G4bool << 259 G4bool *validNorm, 398 G4Three << 260 G4ThreeVector *n ) const 399 { 261 { 400 G4ThreeVector solNorm ; 262 G4ThreeVector solNorm ; 401 G4ThreeVector newPoint = fPtrTransform->Tran 263 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ; 402 G4ThreeVector newDirection = fPtrTransform-> 264 G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ; 403 G4double dist = fPtrSolid->DistanceToOut(new 265 G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection, 404 cal << 266 calcNorm,validNorm,&solNorm) ; 405 if(calcNorm) 267 if(calcNorm) 406 { 268 { 407 *n = fDirectTransform->TransformAxis(solNo 269 *n = fDirectTransform->TransformAxis(solNorm) ; 408 } 270 } 409 return dist ; 271 return dist ; 410 } 272 } 411 273 412 ////////////////////////////////////////////// 274 ////////////////////////////////////////////////////////////// 413 // 275 // 414 // Inverted algorithm of DistanceToIn(p) 276 // Inverted algorithm of DistanceToIn(p) 415 277 416 G4double 278 G4double 417 G4DisplacedSolid::DistanceToOut( const G4Three 279 G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p ) const 418 { 280 { 419 G4ThreeVector newPoint = fPtrTransform->Tran 281 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ; 420 return fPtrSolid->DistanceToOut(newPoint) ; 282 return fPtrSolid->DistanceToOut(newPoint) ; 421 } 283 } 422 284 423 ////////////////////////////////////////////// 285 ////////////////////////////////////////////////////////////// 424 // 286 // 425 // ComputeDimensions << 426 << 427 void << 428 G4DisplacedSolid::ComputeDimensions( G4V << 429 const G4i << 430 const G4V << 431 { << 432 DumpInfo(); << 433 G4Exception("G4DisplacedSolid::ComputeDimens << 434 "GeomSolids0001", FatalException << 435 "Method not applicable in this c << 436 } << 437 << 438 ////////////////////////////////////////////// << 439 // << 440 // Return volume << 441 << 442 G4double G4DisplacedSolid::GetCubicVolume() << 443 { << 444 return fPtrSolid->GetCubicVolume(); << 445 } << 446 << 447 ////////////////////////////////////////////// << 448 // << 449 // Return surface area << 450 << 451 G4double G4DisplacedSolid::GetSurfaceArea() << 452 { << 453 return fPtrSolid->GetSurfaceArea(); << 454 } << 455 << 456 ////////////////////////////////////////////// << 457 // << 458 // Returns a point (G4ThreeVector) randomly an << 459 // on the solid surface << 460 // << 461 << 462 G4ThreeVector G4DisplacedSolid::GetPointOnSurf << 463 { << 464 G4ThreeVector p = fPtrSolid->GetPointOnSurfa << 465 return fDirectTransform->TransformPoint(p); << 466 } << 467 << 468 ////////////////////////////////////////////// << 469 // 287 // 470 // Return the number of constituents used for << 471 288 472 G4int G4DisplacedSolid::GetNumOfConstituents() << 289 void 473 { << 290 G4DisplacedSolid::ComputeDimensions( G4VPVParameterisation* p, 474 return fPtrSolid->GetNumOfConstituents(); << 291 const G4int n, 475 } << 292 const G4VPhysicalVolume* pRep ) 476 << 477 ////////////////////////////////////////////// << 478 // << 479 // Return true if the solid has only planar fa << 480 << 481 G4bool G4DisplacedSolid::IsFaceted() const << 482 { << 483 return fPtrSolid->IsFaceted(); << 484 } << 485 << 486 ////////////////////////////////////////////// << 487 // << 488 // Return object type name << 489 << 490 G4GeometryType G4DisplacedSolid::GetEntityType << 491 { << 492 return {"G4DisplacedSolid"}; << 493 } << 494 << 495 ////////////////////////////////////////////// << 496 // << 497 // Make a clone of the object << 498 // << 499 G4VSolid* G4DisplacedSolid::Clone() const << 500 { << 501 return new G4DisplacedSolid(*this); << 502 } << 503 << 504 ////////////////////////////////////////////// << 505 // << 506 // Stream object contents to an output stream << 507 << 508 std::ostream& G4DisplacedSolid::StreamInfo(std << 509 { 293 { 510 os << "------------------------------------- << 294 // fPtrSolid->ComputeDimensions(p,n,pRep); 511 << " *** Dump for Displaced solid - " << 512 << " ================================= << 513 << " Solid type: " << GetEntityType() << << 514 << " Parameters of constituent solid: \n" << 515 << "===================================== << 516 fPtrSolid->StreamInfo(os); << 517 os << "===================================== << 518 << " Transformations: \n" << 519 << " Direct transformation - translati << 520 << " " << fDirectTransform->Net << 521 << " - rotation << 522 << " "; << 523 fDirectTransform->NetRotation().print(os); << 524 os << "\n" << 525 << "===================================== << 526 295 527 return os; << 296 G4Exception("ERROR: ComputeDimensions has no meaning for a G4DisplacedSolid. It cannot be called."); 528 } 297 } 529 298 530 ////////////////////////////////////////////// << 299 ///////////////////////////////////////////////// 531 // 300 // 532 // DescribeYourselfTo << 301 // 533 302 534 void 303 void 535 G4DisplacedSolid::DescribeYourselfTo ( G4VGrap 304 G4DisplacedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const 536 { 305 { 537 scene.AddSolid (*this); << 306 scene.AddThis (*this); 538 } 307 } 539 308 540 ////////////////////////////////////////////// << 309 //////////////////////////////////////////////////// >> 310 // 541 // 311 // 542 // CreatePolyhedron << 543 312 544 G4Polyhedron* 313 G4Polyhedron* 545 G4DisplacedSolid::CreatePolyhedron () const 314 G4DisplacedSolid::CreatePolyhedron () const 546 { 315 { 547 G4Polyhedron* polyhedron = fPtrSolid->Create 316 G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron(); 548 if (polyhedron != nullptr) << 317 polyhedron->Transform 549 { << 318 (G4Transform3D(GetObjectRotation(),GetObjectTranslation())); 550 polyhedron << 551 ->Transform(G4Transform3D(GetObjectRotatio << 552 } << 553 else << 554 { << 555 DumpInfo(); << 556 G4Exception("G4DisplacedSolid::CreatePolyh << 557 "GeomSolids2002", JustWarning, << 558 "No G4Polyhedron for displaced << 559 } << 560 return polyhedron; 319 return polyhedron; 561 } 320 } 562 321 563 ////////////////////////////////////////////// << 322 ///////////////////////////////////////////////////////// >> 323 // 564 // 324 // 565 // GetPolyhedron << 566 325 567 G4Polyhedron* G4DisplacedSolid::GetPolyhedron << 326 G4NURBS* >> 327 G4DisplacedSolid::CreateNURBS () const 568 { 328 { 569 if (fpPolyhedron == nullptr || << 329 // Take into account local transformation - see CreatePolyhedron. 570 fRebuildPolyhedron || << 330 // return fPtrSolid->CreateNURBS() ; 571 fpPolyhedron->GetNumberOfRotationStepsAt << 331 return 0; 572 fpPolyhedron->GetNumberOfRotationSteps() << 573 { << 574 fpPolyhedron = CreatePolyhedron(); << 575 fRebuildPolyhedron = false; << 576 } << 577 return fpPolyhedron; << 578 } 332 } 579 333