Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DisplacedSolid Class Reference

G4DisplacedSolid is a solid that has been shifted from its original frame of reference to a new one. It is meant to be used internally only, for simplifying the implementation of "Boolean solids". More...

#include <G4DisplacedSolid.hh>

Inheritance diagram for G4DisplacedSolid:

Public Member Functions

 G4DisplacedSolid (const G4String &pName, G4VSolid *pSolid, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
 G4DisplacedSolid (const G4String &pName, G4VSolid *pSolid, const G4Transform3D &transform)
 G4DisplacedSolid (const G4String &pName, G4VSolid *pSolid, const G4AffineTransform directTransform)
 ~G4DisplacedSolid () override
 G4DisplacedSolid (__void__ &)
 G4DisplacedSolid (const G4DisplacedSolid &rhs)
G4DisplacedSolidoperator= (const G4DisplacedSolid &rhs)
EInside Inside (const G4ThreeVector &p) const override
void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const override
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const override
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const override
G4double DistanceToIn (const G4ThreeVector &p) const override
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const override
G4double DistanceToOut (const G4ThreeVector &p) const override
void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep) override
void CleanTransformations ()
G4double GetCubicVolume () override
G4double GetSurfaceArea () override
G4ThreeVector GetPointOnSurface () const override
G4int GetNumOfConstituents () const override
G4bool IsFaceted () const override
G4GeometryType GetEntityType () const override
G4VSolidClone () const override
const G4DisplacedSolidGetDisplacedSolidPtr () const override
G4DisplacedSolidGetDisplacedSolidPtr () override
G4VSolidGetConstituentMovedSolid () const
G4AffineTransform GetTransform () const
void SetTransform (G4AffineTransform &)
G4AffineTransform GetDirectTransform () const
void SetDirectTransform (G4AffineTransform &)
G4RotationMatrix GetFrameRotation () const
void SetFrameRotation (const G4RotationMatrix &)
G4ThreeVector GetFrameTranslation () const
void SetFrameTranslation (const G4ThreeVector &)
G4RotationMatrix GetObjectRotation () const
void SetObjectRotation (const G4RotationMatrix &)
G4ThreeVector GetObjectTranslation () const
void SetObjectTranslation (const G4ThreeVector &)
std::ostream & StreamInfo (std::ostream &os) const override
void DescribeYourselfTo (G4VGraphicsScene &scene) const override
G4PolyhedronCreatePolyhedron () const override
G4PolyhedronGetPolyhedron () const override
Public Member Functions inherited from G4VSolid
 G4VSolid (const G4String &name)
virtual ~G4VSolid ()
 G4VSolid (const G4VSolid &rhs)
G4VSolidoperator= (const G4VSolid &rhs)
G4bool operator== (const G4VSolid &s) const
G4String GetName () const
void SetName (const G4String &name)
G4double GetTolerance () const
void DumpInfo () const
virtual G4VisExtent GetExtent () const
virtual const G4VSolidGetConstituentSolid (G4int no) const
virtual G4VSolidGetConstituentSolid (G4int no)
 G4VSolid (__void__ &)
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
G4double EstimateSurfaceArea (G4int nStat, G4double epsilon) const

Protected Attributes

G4VSolidfPtrSolid = nullptr
G4AffineTransformfPtrTransform = nullptr
G4AffineTransformfDirectTransform = nullptr
G4bool fRebuildPolyhedron = false
G4PolyhedronfpPolyhedron = nullptr
Protected Attributes inherited from G4VSolid
G4double kCarTolerance

Additional Inherited Members

Protected Member Functions inherited from G4VSolid
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const

Detailed Description

G4DisplacedSolid is a solid that has been shifted from its original frame of reference to a new one. It is meant to be used internally only, for simplifying the implementation of "Boolean solids".

Definition at line 51 of file G4DisplacedSolid.hh.

Constructor & Destructor Documentation

◆ G4DisplacedSolid() [1/5]

G4DisplacedSolid::G4DisplacedSolid ( const G4String & pName,
G4VSolid * pSolid,
G4RotationMatrix * rotMatrix,
const G4ThreeVector & transVector )

Constructor of a displaced solid rotation and translation vectors.

Parameters
[in]pNameThe name of the diplaced solid.
[in]pSolidPointer to the original reference solid.
[in]rotMatrixPointer to the rotation vector.
[in]transVectorThe translation vector.

Definition at line 47 of file G4DisplacedSolid.cc.

51 : G4VSolid(pName)
52{
53 if (pSolid->GetEntityType() == "G4DisplacedSolid")
54 {
55 fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
56 G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
57 G4AffineTransform t2 = G4AffineTransform(rotMatrix,transVector);
58 fDirectTransform = new G4AffineTransform(t1*t2);
59 }
60 else
61 {
62 fPtrSolid = pSolid;
63 fDirectTransform = new G4AffineTransform(rotMatrix,transVector);
64 }
65 fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
66}
G4AffineTransform * fPtrTransform
G4AffineTransform * fDirectTransform
G4DisplacedSolid(const G4String &pName, G4VSolid *pSolid, G4RotationMatrix *rotMatrix, const G4ThreeVector &transVector)
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59
virtual G4GeometryType GetEntityType() const =0

Referenced by Clone(), G4DisplacedSolid(), GetDisplacedSolidPtr(), GetDisplacedSolidPtr(), and operator=().

◆ G4DisplacedSolid() [2/5]

G4DisplacedSolid::G4DisplacedSolid ( const G4String & pName,
G4VSolid * pSolid,
const G4Transform3D & transform )

Constructor of a displaced solid with a transformation.

Parameters
[in]pNameThe name of the displaced solid.
[in]pSolidPointer to the original reference solid.
[in]transformThe composed 3D transformation.

Definition at line 72 of file G4DisplacedSolid.cc.

75 : G4VSolid(pName)
76{
77 if (pSolid->GetEntityType() == "G4DisplacedSolid")
78 {
79 fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
80 G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
81 G4AffineTransform t2 = G4AffineTransform(transform.getRotation().inverse(),
82 transform.getTranslation());
83 fDirectTransform = new G4AffineTransform(t1*t2);
84 }
85 else
86 {
87 fPtrSolid = pSolid;
88 fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
89 transform.getTranslation()) ;
90 }
91 fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
92}
HepRotation inverse() const
CLHEP::HepRotation getRotation() const
CLHEP::Hep3Vector getTranslation() const

◆ G4DisplacedSolid() [3/5]

G4DisplacedSolid::G4DisplacedSolid ( const G4String & pName,
G4VSolid * pSolid,
const G4AffineTransform directTransform )

Constructor for use in instantiating a transient instance from a persistent one.

Parameters
[in]pNameThe name of the displaced solid.
[in]pSolidPointer to the original reference solid.
[in]directTransformThe internal transformation.

Definition at line 99 of file G4DisplacedSolid.cc.

102 : G4VSolid(pName)
103{
104 if (pSolid->GetEntityType() == "G4DisplacedSolid")
105 {
106 fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
107 G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
108 auto t2 = G4AffineTransform(directTransform);
109 fDirectTransform = new G4AffineTransform(t1*t2);
110 }
111 else
112 {
113 fPtrSolid = pSolid;
114 fDirectTransform = new G4AffineTransform(directTransform);
115 }
116 fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
117}

◆ ~G4DisplacedSolid()

G4DisplacedSolid::~G4DisplacedSolid ( )
override

Destructor. Deletes all cached transformations.

Definition at line 133 of file G4DisplacedSolid.cc.

134{
136 delete fpPolyhedron; fpPolyhedron = nullptr;
137}
G4Polyhedron * fpPolyhedron

◆ G4DisplacedSolid() [4/5]

G4DisplacedSolid::G4DisplacedSolid ( __void__ & a)

Fake default constructor for usage restricted to direct object persistency for clients requiring preallocation of memory for persistifiable objects.

Definition at line 124 of file G4DisplacedSolid.cc.

125 : G4VSolid(a)
126{
127}

◆ G4DisplacedSolid() [5/5]

G4DisplacedSolid::G4DisplacedSolid ( const G4DisplacedSolid & rhs)

Copy constructor and assignment operator.

Definition at line 143 of file G4DisplacedSolid.cc.

144 : G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid)
145{
146 fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
147 fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
148}

Member Function Documentation

◆ BoundingLimits()

void G4DisplacedSolid::BoundingLimits ( G4ThreeVector & pMin,
G4ThreeVector & pMax ) const
overridevirtual

Computes the bounding limits of the solid.

Parameters
[out]pMinThe minimum bounding limit point.
[out]pMaxThe maximum bounding limit point.

Reimplemented from G4VSolid.

Definition at line 286 of file G4DisplacedSolid.cc.

288{
289 if (!fDirectTransform->IsRotated())
290 {
291 // Special case of pure translation
292 //
293 fPtrSolid->BoundingLimits(pMin,pMax);
294 G4ThreeVector offset = fDirectTransform->NetTranslation();
295 pMin += offset;
296 pMax += offset;
297 }
298 else
299 {
300 // General case, use CalculateExtent() to find bounding box
301 //
302 G4VoxelLimits unLimit;
303 G4double xmin,xmax,ymin,ymax,zmin,zmax;
304 fPtrSolid->CalculateExtent(kXAxis,unLimit,*fDirectTransform,xmin,xmax);
305 fPtrSolid->CalculateExtent(kYAxis,unLimit,*fDirectTransform,ymin,ymax);
306 fPtrSolid->CalculateExtent(kZAxis,unLimit,*fDirectTransform,zmin,zmax);
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.y() || pMin.z() >= pMax.z())
314 {
315 std::ostringstream message;
316 message << "Bad bounding box (min >= max) for solid: "
317 << GetName() << " !"
318 << "\npMin = " << pMin
319 << "\npMax = " << pMax;
320 G4Exception("G4DisplacedSolid::BoundingLimits()", "GeomMgt0001",
321 JustWarning, message);
322 DumpInfo();
323 }
324}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4ThreadLocal T * G4GeomSplitter< T >::offset
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
double z() const
double x() const
double y() const
void set(double x, double y, double z)
G4String GetName() const
void DumpInfo() const
@ kYAxis
Definition geomdefs.hh:56
@ kXAxis
Definition geomdefs.hh:55
@ kZAxis
Definition geomdefs.hh:57

◆ CalculateExtent()

G4bool G4DisplacedSolid::CalculateExtent ( const EAxis pAxis,
const G4VoxelLimits & pVoxelLimit,
const G4AffineTransform & pTransform,
G4double & pMin,
G4double & pMax ) const
overridevirtual

Calculates the minimum and maximum extent of the solid, when under the specified transform, and within the specified limits.

Parameters
[in]pAxisThe axis along which compute the extent.
[in]pVoxelLimitThe limiting space dictated by voxels.
[in]pTransformThe internal transformation applied to the solid.
[out]pMinThe minimum extent value.
[out]pMaxThe maximum extent value.
Returns
True if the solid is intersected by the extent region.

Implements G4VSolid.

Definition at line 331 of file G4DisplacedSolid.cc.

336{
337 G4AffineTransform sumTransform ;
338 sumTransform.Product(*fDirectTransform,pTransform) ;
339 return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform,pMin,pMax) ;
340}
G4AffineTransform & Product(const G4AffineTransform &tf1, const G4AffineTransform &tf2)

◆ CleanTransformations()

void G4DisplacedSolid::CleanTransformations ( )

Deletes cached transformations. Used in destructor.

Definition at line 176 of file G4DisplacedSolid.cc.

177{
178 if(fPtrTransform != nullptr)
179 {
180 delete fPtrTransform; fPtrTransform = nullptr;
181 delete fDirectTransform; fDirectTransform = nullptr;
182 }
183}

Referenced by ~G4DisplacedSolid().

◆ Clone()

G4VSolid * G4DisplacedSolid::Clone ( ) const
overridevirtual

Makes a clone of the object for use in multi-treading.

Returns
A pointer to the new cloned allocated solid.

Reimplemented from G4VSolid.

Definition at line 499 of file G4DisplacedSolid.cc.

500{
501 return new G4DisplacedSolid(*this);
502}

◆ ComputeDimensions()

void G4DisplacedSolid::ComputeDimensions ( G4VPVParameterisation * p,
const G4int n,
const G4VPhysicalVolume * pRep )
overridevirtual

Throws an exception as paramterisations are not allowed for these solids.

Reimplemented from G4VSolid.

Definition at line 428 of file G4DisplacedSolid.cc.

431{
432 DumpInfo();
433 G4Exception("G4DisplacedSolid::ComputeDimensions()",
434 "GeomSolids0001", FatalException,
435 "Method not applicable in this context!");
436}
@ FatalException

◆ CreatePolyhedron()

G4Polyhedron * G4DisplacedSolid::CreatePolyhedron ( ) const
overridevirtual

Creates a Polyhedron used for Visualisation. It is the caller's responsibility to delete it. A null pointer means "not created".

Reimplemented from G4VSolid.

Definition at line 545 of file G4DisplacedSolid.cc.

546{
547 G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
548 if (polyhedron != nullptr)
549 {
550 polyhedron
552 }
553 else
554 {
555 DumpInfo();
556 G4Exception("G4DisplacedSolid::CreatePolyhedron()",
557 "GeomSolids2002", JustWarning,
558 "No G4Polyhedron for displaced solid");
559 }
560 return polyhedron;
561}
HepGeom::Transform3D G4Transform3D
G4RotationMatrix GetObjectRotation() const
G4ThreeVector GetObjectTranslation() const
HepPolyhedron & Transform(const G4Transform3D &t)

Referenced by GetPolyhedron().

◆ DescribeYourselfTo()

void G4DisplacedSolid::DescribeYourselfTo ( G4VGraphicsScene & scene) const
overridevirtual

Methods for creating graphical representations (i.e. for visualisation).

Implements G4VSolid.

Definition at line 535 of file G4DisplacedSolid.cc.

536{
537 scene.AddSolid (*this);
538}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

G4double G4DisplacedSolid::DistanceToIn ( const G4ThreeVector & p) const
overridevirtual

Calculates the safety distance to the nearest surface of a shape from an outside point. The distance can be an underestimate.

Implements G4VSolid.

Definition at line 383 of file G4DisplacedSolid.cc.

384{
385 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
386 return fPtrSolid->DistanceToIn(newPoint) ;
387}

◆ DistanceToIn() [2/2]

G4double G4DisplacedSolid::DistanceToIn ( const G4ThreeVector & p,
const G4ThreeVector & v ) const
overridevirtual

Returns the distance along the normalised vector "v" to the shape, from the point at offset "p". If there is no intersection, return kInfinity. The first intersection resulting from leaving a surface/volume is discarded. Hence, it is tolerant of points on the surface of the shape.

Implements G4VSolid.

Definition at line 369 of file G4DisplacedSolid.cc.

371{
372 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
373 G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
374 return fPtrSolid->DistanceToIn(newPoint,newDirection) ;
375}

◆ DistanceToOut() [1/2]

G4double G4DisplacedSolid::DistanceToOut ( const G4ThreeVector & p) const
overridevirtual

Calculates the safety distance to the nearest surface of a shape from an inside point "p". The distance can be an underestimate.

Implements G4VSolid.

Definition at line 417 of file G4DisplacedSolid.cc.

418{
419 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
420 return fPtrSolid->DistanceToOut(newPoint) ;
421}

◆ DistanceToOut() [2/2]

G4double G4DisplacedSolid::DistanceToOut ( const G4ThreeVector & p,
const G4ThreeVector & v,
const G4bool calcNorm = false,
G4bool * validNorm = nullptr,
G4ThreeVector * n = nullptr ) const
overridevirtual

Returns the distance along the normalised vector "v" to the shape, from a point at an offset "p" inside or on the surface of the shape. Intersections with surfaces, when the point is < Tolerance/2 from a surface must be ignored. Must be called as solid.DistanceToOut(p,v) or by specifying all the parameters.

Parameters
[in]pThe reference point in space.
[in]vThe normalised direction.
[in]calcNormFlag to enable the normal computation or not.
[out]validNormSet to true if the solid lies entirely behind or on the exiting surface (calcNorm must be true, otherwise it is unused).
[out]nThe exiting outwards normal vector (undefined Magnitude). (calcNorm must be true, otherwise it is unused).
Returns
The distance value to exit the volume.

Implements G4VSolid.

Definition at line 394 of file G4DisplacedSolid.cc.

399{
400 G4ThreeVector solNorm ;
401 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
402 G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
403 G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection,
404 calcNorm,validNorm,&solNorm) ;
405 if(calcNorm)
406 {
407 *n = fDirectTransform->TransformAxis(solNorm) ;
408 }
409 return dist ;
410}

◆ GetConstituentMovedSolid()

G4VSolid * G4DisplacedSolid::GetConstituentMovedSolid ( ) const

Returns a pointer to the original not displaced solid.

Definition at line 195 of file G4DisplacedSolid.cc.

196{
197 return fPtrSolid;
198}

Referenced by G4tgbGeometryDumper::DumpBooleanVolume(), and G4BooleanSolid::GetListOfPrimitives().

◆ GetCubicVolume()

G4double G4DisplacedSolid::GetCubicVolume ( )
overridevirtual

Methods returning an estimation of the solid volume (capacity) and surface area, in internal units.

Reimplemented from G4VSolid.

Definition at line 442 of file G4DisplacedSolid.cc.

443{
444 return fPtrSolid->GetCubicVolume();
445}

◆ GetDirectTransform()

G4AffineTransform G4DisplacedSolid::GetDirectTransform ( ) const

Accessor/modifier for the associated internal transformation, as above.

Definition at line 216 of file G4DisplacedSolid.cc.

217{
218 G4AffineTransform aTransform= *fDirectTransform;
219 return aTransform;
220}

◆ GetDisplacedSolidPtr() [1/2]

const G4DisplacedSolid * G4DisplacedSolid::GetDisplacedSolidPtr ( ) const
overridevirtual

If the Solid is a "G4DisplacedSolid", return a self pointer else return nullptr.

Reimplemented from G4VSolid.

Definition at line 185 of file G4DisplacedSolid.cc.

186{
187 return this;
188}

◆ GetDisplacedSolidPtr() [2/2]

G4DisplacedSolid * G4DisplacedSolid::GetDisplacedSolidPtr ( )
overridevirtual

Reimplemented from G4VSolid.

Definition at line 190 of file G4DisplacedSolid.cc.

191{
192 return this;
193}

◆ GetEntityType()

G4GeometryType G4DisplacedSolid::GetEntityType ( ) const
overridevirtual

Returns the type ID, "G4DisplacedSolid" of the solid.

Implements G4VSolid.

Definition at line 490 of file G4DisplacedSolid.cc.

491{
492 return {"G4DisplacedSolid"};
493}

Referenced by StreamInfo().

◆ GetFrameRotation()

G4RotationMatrix G4DisplacedSolid::GetFrameRotation ( ) const

Get/Set the rotation/translation, as applied to the frame of reference.

Definition at line 230 of file G4DisplacedSolid.cc.

231{
232 G4RotationMatrix InvRotation = fDirectTransform->NetRotation();
233 return InvRotation;
234}
CLHEP::HepRotation G4RotationMatrix

◆ GetFrameTranslation()

G4ThreeVector G4DisplacedSolid::GetFrameTranslation ( ) const

Definition at line 244 of file G4DisplacedSolid.cc.

245{
246 return fPtrTransform->NetTranslation();
247}

◆ GetNumOfConstituents()

G4int G4DisplacedSolid::GetNumOfConstituents ( ) const
overridevirtual

Returns the number of constituents of the solid. For non-Boolean solids the return value is one.

Reimplemented from G4VSolid.

Definition at line 472 of file G4DisplacedSolid.cc.

473{
474 return fPtrSolid->GetNumOfConstituents();
475}

◆ GetObjectRotation()

G4RotationMatrix G4DisplacedSolid::GetObjectRotation ( ) const

Get/Set the rotation/translation, as applied to the object.

Definition at line 257 of file G4DisplacedSolid.cc.

258{
259 G4RotationMatrix Rotation = fPtrTransform->NetRotation();
260 return Rotation;
261}

Referenced by CreatePolyhedron().

◆ GetObjectTranslation()

G4ThreeVector G4DisplacedSolid::GetObjectTranslation ( ) const

Definition at line 271 of file G4DisplacedSolid.cc.

272{
273 return fDirectTransform->NetTranslation();
274}

Referenced by CreatePolyhedron(), and G4tgbGeometryDumper::DumpBooleanVolume().

◆ GetPointOnSurface()

G4ThreeVector G4DisplacedSolid::GetPointOnSurface ( ) const
overridevirtual

Returns a random point located on the surface of the solid. Points returned may not necessarily be uniformly distributed.

Reimplemented from G4VSolid.

Definition at line 462 of file G4DisplacedSolid.cc.

463{
464 G4ThreeVector p = fPtrSolid->GetPointOnSurface();
465 return fDirectTransform->TransformPoint(p);
466}

◆ GetPolyhedron()

G4Polyhedron * G4DisplacedSolid::GetPolyhedron ( ) const
overridevirtual

Smart access function - creates on request and stores for future access. A null pointer means "not available".

Reimplemented from G4VSolid.

Definition at line 567 of file G4DisplacedSolid.cc.

568{
569 if (fpPolyhedron == nullptr ||
571 fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
572 fpPolyhedron->GetNumberOfRotationSteps())
573 {
575 fRebuildPolyhedron = false;
576 }
577 return fpPolyhedron;
578}
G4Polyhedron * CreatePolyhedron() const override

Referenced by G4MultiUnion::CreatePolyhedron().

◆ GetSurfaceArea()

G4double G4DisplacedSolid::GetSurfaceArea ( )
overridevirtual

Returns an estimation of the solid surface area in internal units. This method may be overloaded by derived classes to compute the exact geometrical quantity for solids where this is possible, or anyway to cache the computed value. Note: the computed value is NOT cached.

Reimplemented from G4VSolid.

Definition at line 451 of file G4DisplacedSolid.cc.

452{
453 return fPtrSolid->GetSurfaceArea();
454}

◆ GetTransform()

G4AffineTransform G4DisplacedSolid::GetTransform ( ) const

Accessor/modifier for the associated internal transformation.

Definition at line 202 of file G4DisplacedSolid.cc.

203{
204 G4AffineTransform aTransform = *fPtrTransform;
205 return aTransform;
206}

Referenced by G4tgbGeometryDumper::DumpBooleanVolume().

◆ Inside()

EInside G4DisplacedSolid::Inside ( const G4ThreeVector & p) const
overridevirtual

Returns if the given point "p" is inside or not the solid.

Implements G4VSolid.

Definition at line 346 of file G4DisplacedSolid.cc.

347{
348 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
349 return fPtrSolid->Inside(newPoint) ;
350}

◆ IsFaceted()

G4bool G4DisplacedSolid::IsFaceted ( ) const
overridevirtual

Returns true if the solid has only planar faces, false otherwise.

Reimplemented from G4VSolid.

Definition at line 481 of file G4DisplacedSolid.cc.

482{
483 return fPtrSolid->IsFaceted();
484}

◆ operator=()

G4DisplacedSolid & G4DisplacedSolid::operator= ( const G4DisplacedSolid & rhs)

Definition at line 154 of file G4DisplacedSolid.cc.

155{
156 // Check assignment to self
157 //
158 if (this == &rhs) { return *this; }
159
160 // Copy base class data
161 //
163
164 // Copy data
165 //
166 fPtrSolid = rhs.fPtrSolid;
167 delete fPtrTransform; delete fDirectTransform;
168 fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
169 fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
170 fRebuildPolyhedron = false;
171 delete fpPolyhedron; fpPolyhedron = nullptr;
172
173 return *this;
174}
G4VSolid & operator=(const G4VSolid &rhs)
Definition G4VSolid.cc:108

◆ SetDirectTransform()

void G4DisplacedSolid::SetDirectTransform ( G4AffineTransform & transform)

Definition at line 222 of file G4DisplacedSolid.cc.

223{
224 fDirectTransform = &transform ;
225 fRebuildPolyhedron = true;
226}

◆ SetFrameRotation()

void G4DisplacedSolid::SetFrameRotation ( const G4RotationMatrix & matrix)

Definition at line 236 of file G4DisplacedSolid.cc.

237{
238 fDirectTransform->SetNetRotation(matrix);
239 fRebuildPolyhedron = true;
240}

◆ SetFrameTranslation()

void G4DisplacedSolid::SetFrameTranslation ( const G4ThreeVector & vector)

Definition at line 249 of file G4DisplacedSolid.cc.

250{
251 fPtrTransform->SetNetTranslation(vector);
252 fRebuildPolyhedron = true;
253}

◆ SetObjectRotation()

void G4DisplacedSolid::SetObjectRotation ( const G4RotationMatrix & matrix)

Definition at line 263 of file G4DisplacedSolid.cc.

264{
265 fPtrTransform->SetNetRotation(matrix);
266 fRebuildPolyhedron = true;
267}

◆ SetObjectTranslation()

void G4DisplacedSolid::SetObjectTranslation ( const G4ThreeVector & vector)

Definition at line 276 of file G4DisplacedSolid.cc.

277{
278 fDirectTransform->SetNetTranslation(vector);
279 fRebuildPolyhedron = true;
280}

◆ SetTransform()

void G4DisplacedSolid::SetTransform ( G4AffineTransform & transform)

Definition at line 208 of file G4DisplacedSolid.cc.

209{
210 fPtrTransform = &transform ;
211 fRebuildPolyhedron = true;
212}

◆ StreamInfo()

std::ostream & G4DisplacedSolid::StreamInfo ( std::ostream & os) const
overridevirtual

Streams the object contents to an output stream.

Implements G4VSolid.

Definition at line 508 of file G4DisplacedSolid.cc.

509{
510 os << "-----------------------------------------------------------\n"
511 << " *** Dump for Displaced solid - " << GetName() << " ***\n"
512 << " ===================================================\n"
513 << " Solid type: " << GetEntityType() << "\n"
514 << " Parameters of constituent solid: \n"
515 << "===========================================================\n";
516 fPtrSolid->StreamInfo(os);
517 os << "===========================================================\n"
518 << " Transformations: \n"
519 << " Direct transformation - translation : \n"
520 << " " << fDirectTransform->NetTranslation() << "\n"
521 << " - rotation : \n"
522 << " ";
523 fDirectTransform->NetRotation().print(os);
524 os << "\n"
525 << "===========================================================\n";
526
527 return os;
528}
G4GeometryType GetEntityType() const override

◆ SurfaceNormal()

G4ThreeVector G4DisplacedSolid::SurfaceNormal ( const G4ThreeVector & p) const
overridevirtual

Returns the outwards pointing unit normal of the shape for the surface closest to the point at offset "p".

Implements G4VSolid.

Definition at line 357 of file G4DisplacedSolid.cc.

358{
359 G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
360 G4ThreeVector normal = fPtrSolid->SurfaceNormal(newPoint) ;
361 return fDirectTransform->TransformAxis(normal) ;
362}

Member Data Documentation

◆ fDirectTransform

◆ fpPolyhedron

G4Polyhedron* G4DisplacedSolid::fpPolyhedron = nullptr
mutableprotected

Definition at line 289 of file G4DisplacedSolid.hh.

Referenced by GetPolyhedron(), operator=(), and ~G4DisplacedSolid().

◆ fPtrSolid

◆ fPtrTransform

◆ fRebuildPolyhedron

G4bool G4DisplacedSolid::fRebuildPolyhedron = false
mutableprotected

The documentation for this class was generated from the following files: