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

G4ScaledSolid is a solid that has been scaled in dimensions in X, Y or Z, from its original description. More...

#include <G4ScaledSolid.hh>

Inheritance diagram for G4ScaledSolid:

Public Member Functions

 G4ScaledSolid (const G4String &pName, G4VSolid *pSolid, const G4Scale3D &pScale)
 ~G4ScaledSolid () override
 G4ScaledSolid (__void__ &)
 G4ScaledSolid (const G4ScaledSolid &rhs)
G4ScaledSolidoperator= (const G4ScaledSolid &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
G4double GetCubicVolume () override
G4double GetSurfaceArea () override
G4ThreeVector GetPointOnSurface () const override
G4int GetNumOfConstituents () const override
G4bool IsFaceted () const override
G4Scale3D GetScaleTransform () const
void SetScaleTransform (const G4Scale3D &scale)
G4VSolidGetUnscaledSolid () const
G4GeometryType GetEntityType () const override
G4VSolidClone () const override
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)
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 G4VSolid (__void__ &)
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
G4double EstimateSurfaceArea (G4int nStat, G4double epsilon) const

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
Protected Attributes inherited from G4VSolid
G4double kCarTolerance

Detailed Description

G4ScaledSolid is a solid that has been scaled in dimensions in X, Y or Z, from its original description.

Definition at line 50 of file G4ScaledSolid.hh.

Constructor & Destructor Documentation

◆ G4ScaledSolid() [1/3]

G4ScaledSolid::G4ScaledSolid ( const G4String & pName,
G4VSolid * pSolid,
const G4Scale3D & pScale )

Constructor of a solid with scaled transformation.

Parameters
[in]pNameThe name of the solid.
[in]pSolidPointer to the original reference solid.
[in]pScaleThe scaling transformation.

Definition at line 51 of file G4ScaledSolid.cc.

54 : G4VSolid(pName), fPtrSolid(pSolid)
55{
56 fScale = new G4ScaleTransform(pScale);
57}
G4VSolid(const G4String &name)
Definition G4VSolid.cc:59

Referenced by Clone(), G4ScaledSolid(), and operator=().

◆ ~G4ScaledSolid()

G4ScaledSolid::~G4ScaledSolid ( )
override

The destructor, clearing the cached transformation.

Definition at line 73 of file G4ScaledSolid.cc.

74{
75 delete fpPolyhedron; fpPolyhedron = nullptr;
76 delete fScale; fScale = nullptr;
77}

◆ G4ScaledSolid() [2/3]

G4ScaledSolid::G4ScaledSolid ( __void__ & a)

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

Definition at line 64 of file G4ScaledSolid.cc.

65 : G4VSolid(a)
66{
67}

◆ G4ScaledSolid() [3/3]

G4ScaledSolid::G4ScaledSolid ( const G4ScaledSolid & rhs)

Copy constructor and assignment operator.

Definition at line 83 of file G4ScaledSolid.cc.

84 : G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid),
85 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea)
86{
87 fScale = new G4ScaleTransform(*(rhs.fScale));
88}

Member Function Documentation

◆ BoundingLimits()

void G4ScaledSolid::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 130 of file G4ScaledSolid.cc.

132{
133 G4ThreeVector bmin,bmax;
134 G4ThreeVector scale = fScale->GetScale();
135
136 fPtrSolid->BoundingLimits(bmin,bmax);
137 pMin.set(bmin.x()*scale.x(),bmin.y()*scale.y(),bmin.z()*scale.z());
138 pMax.set(bmax.x()*scale.x(),bmax.y()*scale.y(),bmax.z()*scale.z());
139
140 // Check correctness of the bounding box
141 //
142 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
143 {
144 std::ostringstream message;
145 message << "Bad bounding box (min >= max) for solid: "
146 << GetName() << " !"
147 << "\npMin = " << pMin
148 << "\npMax = " << pMax;
149 G4Exception("G4ScaledSolid::BoundingLimits()", "GeomMgt0001",
150 JustWarning, message);
151 DumpInfo();
152 }
153}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
double z() const
double x() const
double y() const
void set(double x, double y, double z)
G4String GetName() const
void DumpInfo() const

◆ CalculateExtent()

G4bool G4ScaledSolid::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 160 of file G4ScaledSolid.cc.

165{
166 // Find bounding box of unscaled solid
167 G4ThreeVector bmin,bmax;
168 fPtrSolid->BoundingLimits(bmin,bmax);
169
170 // Set combined transformation
171 G4Transform3D transform3D =
172 G4Transform3D(pTransform.NetRotation().inverse(),
173 pTransform.NetTranslation())*GetScaleTransform();
174
175 // Find extent
176 G4BoundingEnvelope bbox(bmin,bmax);
177 return bbox.CalculateExtent(pAxis,pVoxelLimit,transform3D,pMin,pMax);
178}
HepGeom::Transform3D G4Transform3D
HepRotation inverse() const
G4ThreeVector NetTranslation() const
G4RotationMatrix NetRotation() const
G4Scale3D GetScaleTransform() const

◆ Clone()

G4VSolid * G4ScaledSolid::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 355 of file G4ScaledSolid.cc.

356{
357 return new G4ScaledSolid(*this);
358}
G4ScaledSolid(const G4String &pName, G4VSolid *pSolid, const G4Scale3D &pScale)

◆ ComputeDimensions()

void G4ScaledSolid::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 305 of file G4ScaledSolid.cc.

308{
309 DumpInfo();
310 G4Exception("G4ScaledSolid::ComputeDimensions()",
311 "GeomSolids0001", FatalException,
312 "Method not applicable in this context!");
313}
@ FatalException

◆ CreatePolyhedron()

G4Polyhedron * G4ScaledSolid::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 454 of file G4ScaledSolid.cc.

455{
456 G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
457 if (polyhedron != nullptr)
458 {
459 polyhedron->Transform(GetScaleTransform());
460 }
461 else
462 {
463 DumpInfo();
464 G4Exception("G4ScaledSolid::CreatePolyhedron()",
465 "GeomSolids2003", JustWarning,
466 "No G4Polyhedron for scaled solid");
467 }
468 return polyhedron;
469}
HepPolyhedron & Transform(const G4Transform3D &t)

Referenced by GetPolyhedron().

◆ DescribeYourselfTo()

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

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

Implements G4VSolid.

Definition at line 444 of file G4ScaledSolid.cc.

445{
446 scene.AddSolid (*this);
447}
virtual void AddSolid(const G4Box &)=0

◆ DistanceToIn() [1/2]

G4double G4ScaledSolid::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 238 of file G4ScaledSolid.cc.

239{
240 // Transform point to unscaled shape frame
241 G4ThreeVector newPoint;
242 fScale->Transform(p, newPoint);
243
244 // Compute unscaled safety, then scale it
245 G4double dist = fPtrSolid->DistanceToIn(newPoint);
246 return fScale->InverseTransformDistance(dist);
247}
double G4double
Definition G4Types.hh:83

◆ DistanceToIn() [2/2]

G4double G4ScaledSolid::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 214 of file G4ScaledSolid.cc.

216{
217 // Transform point and direction to unscaled shape frame
218 G4ThreeVector newPoint;
219 fScale->Transform(p, newPoint);
220
221 // Direction is un-normalized after scale transformation
222 G4ThreeVector newDirection;
223 fScale->Transform(v, newDirection);
224 newDirection = newDirection/newDirection.mag();
225
226 // Compute distance in unscaled system
227 G4double dist = fPtrSolid->DistanceToIn(newPoint,newDirection);
228
229 // Return converted distance to global
230 return fScale->InverseTransformDistance(dist, newDirection);
231}
double mag() const

◆ DistanceToOut() [1/2]

G4double G4ScaledSolid::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 289 of file G4ScaledSolid.cc.

290{
291 // Transform point to unscaled shape frame
292 G4ThreeVector newPoint;
293 fScale->Transform(p, newPoint);
294
295 // Compute unscaled safety, then scale it
296 G4double dist = fPtrSolid->DistanceToOut(newPoint);
297 return fScale->InverseTransformDistance(dist);
298}

◆ DistanceToOut() [2/2]

G4double G4ScaledSolid::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 254 of file G4ScaledSolid.cc.

259{
260 // Transform point and direction to unscaled shape frame
261 G4ThreeVector newPoint;
262 fScale->Transform(p, newPoint);
263
264 // Direction is un-normalized after scale transformation
265 G4ThreeVector newDirection;
266 fScale->Transform(v, newDirection);
267 newDirection = newDirection/newDirection.mag();
268
269 // Compute distance in unscaled system
270 G4ThreeVector solNorm;
271 G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection,
272 calcNorm,validNorm,&solNorm);
273 if(calcNorm)
274 {
275 G4ThreeVector normal;
276 fScale->TransformNormal(solNorm, normal);
277 *n = normal.unit();
278 }
279
280 // Return distance converted to global
281 return fScale->InverseTransformDistance(dist, newDirection);
282}
Hep3Vector unit() const

◆ GetCubicVolume()

G4double G4ScaledSolid::GetCubicVolume ( )
overridevirtual

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

Reimplemented from G4VSolid.

Definition at line 386 of file G4ScaledSolid.cc.

387{
388 if(fCubicVolume < 0.)
389 {
390 G4RecursiveAutoLock l(&scaledMutex);
391 fCubicVolume = fPtrSolid->GetCubicVolume() *
392 fScale->GetScale().x() *
393 fScale->GetScale().y() *
394 fScale->GetScale().z();
395 l.unlock();
396 }
397 return fCubicVolume;
398}
G4TemplateAutoLock< G4RecursiveMutex > G4RecursiveAutoLock

◆ GetEntityType()

G4GeometryType G4ScaledSolid::GetEntityType ( ) const
overridevirtual

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

Implements G4VSolid.

Definition at line 346 of file G4ScaledSolid.cc.

347{
348 return {"G4ScaledSolid"};
349}

Referenced by StreamInfo().

◆ GetNumOfConstituents()

G4int G4ScaledSolid::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 328 of file G4ScaledSolid.cc.

329{
330 return fPtrSolid->GetNumOfConstituents();
331}

◆ GetPointOnSurface()

G4ThreeVector G4ScaledSolid::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 320 of file G4ScaledSolid.cc.

321{
322 return fScale->InverseTransform(fPtrSolid->GetPointOnSurface());
323}

◆ GetPolyhedron()

G4Polyhedron * G4ScaledSolid::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 475 of file G4ScaledSolid.cc.

476{
477 if (fpPolyhedron == nullptr ||
478 fRebuildPolyhedron ||
479 fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
480 fpPolyhedron->GetNumberOfRotationSteps())
481 {
482 fpPolyhedron = CreatePolyhedron();
483 fRebuildPolyhedron = false;
484 }
485 return fpPolyhedron;
486}
G4Polyhedron * CreatePolyhedron() const override

◆ GetScaleTransform()

G4Scale3D G4ScaledSolid::GetScaleTransform ( ) const

Accessor and setter for the scaling transformation.

Definition at line 364 of file G4ScaledSolid.cc.

365{
366 return { fScale->GetScale().x(),
367 fScale->GetScale().y(),
368 fScale->GetScale().z() };
369}

Referenced by CalculateExtent(), CreatePolyhedron(), G4tgbGeometryDumper::DumpScaledVolume(), and G4GDMLWriteSolids::ScaledWrite().

◆ GetSurfaceArea()

G4double G4ScaledSolid::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 404 of file G4ScaledSolid.cc.

405{
406 if(fSurfaceArea < 0.)
407 {
408 G4RecursiveAutoLock l(&scaledMutex);
409 fSurfaceArea = G4VSolid::GetSurfaceArea();
410 l.unlock();
411 }
412 return fSurfaceArea;
413}
virtual G4double GetSurfaceArea()
Definition G4VSolid.cc:275

◆ GetUnscaledSolid()

G4VSolid * G4ScaledSolid::GetUnscaledSolid ( ) const

Returns a pointer to the original not scaled solid.

Definition at line 121 of file G4ScaledSolid.cc.

122{
123 return fPtrSolid;
124}

Referenced by G4tgbGeometryDumper::DumpScaledVolume(), and G4GDMLWriteSolids::ScaledWrite().

◆ Inside()

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

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

Implements G4VSolid.

Definition at line 184 of file G4ScaledSolid.cc.

185{
186 return fPtrSolid->Inside(fScale->Transform(p));
187}

◆ IsFaceted()

G4bool G4ScaledSolid::IsFaceted ( ) const
overridevirtual

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

Reimplemented from G4VSolid.

Definition at line 337 of file G4ScaledSolid.cc.

338{
339 return fPtrSolid->IsFaceted();
340}

◆ operator=()

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

Definition at line 94 of file G4ScaledSolid.cc.

95{
96 // Check assignment to self
97 //
98 if (this == &rhs) { return *this; }
99
100 // Copy base class data
101 //
103
104 // Copy data
105 //
106 fPtrSolid = rhs.fPtrSolid;
107 delete fScale;
108 fScale = new G4ScaleTransform(*(rhs.fScale));
109 fCubicVolume = rhs.fCubicVolume;
110 fSurfaceArea = rhs.fSurfaceArea;
111 fRebuildPolyhedron = false;
112 delete fpPolyhedron; fpPolyhedron = nullptr;
113
114 return *this;
115}
G4VSolid & operator=(const G4VSolid &rhs)
Definition G4VSolid.cc:108

◆ SetScaleTransform()

void G4ScaledSolid::SetScaleTransform ( const G4Scale3D & scale)

Definition at line 375 of file G4ScaledSolid.cc.

376{
377 delete fScale;
378 fScale = new G4ScaleTransform(scale);
379 fRebuildPolyhedron = true;
380}

◆ StreamInfo()

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

Streams the object contents to an output stream.

Implements G4VSolid.

Definition at line 419 of file G4ScaledSolid.cc.

420{
421 os << "-----------------------------------------------------------\n"
422 << " *** Dump for Scaled solid - " << GetName() << " ***\n"
423 << " ===================================================\n"
424 << " Solid type: " << GetEntityType() << "\n"
425 << " Parameters of constituent solid: \n"
426 << "===========================================================\n";
427 fPtrSolid->StreamInfo(os);
428 os << "===========================================================\n"
429 << " Scaling: \n"
430 << " Scale transformation : \n"
431 << " " << fScale->GetScale().x() << ", "
432 << fScale->GetScale().y() << ", "
433 << fScale->GetScale().z() << "\n"
434 << "===========================================================\n";
435
436 return os;
437}
G4GeometryType GetEntityType() const override

◆ SurfaceNormal()

G4ThreeVector G4ScaledSolid::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 194 of file G4ScaledSolid.cc.

195{
196 // Transform point to unscaled shape frame
197 G4ThreeVector newPoint;
198 fScale->Transform(p, newPoint);
199
200 // Compute normal in unscaled frame
201 G4ThreeVector newNormal = fPtrSolid->SurfaceNormal(newPoint);
202 G4ThreeVector normal;
203
204 // Convert normal to scaled frame
205 fScale->InverseTransformNormal(newNormal, normal);
206 return normal/normal.mag();
207}

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