G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
G4OCCTSolid Class Reference

Geant4 solid wrapping an Open CASCADE Technology (OCCT) TopoDS_Shape. More...

#include <G4OCCTSolid.hh>

Inheritance diagram for G4OCCTSolid:

Classes

class  Impl
 

Public Member Functions

 G4OCCTSolid (const G4String &name, const TopoDS_Shape &shape)
 
 ~G4OCCTSolid () override
 
EInside Inside (const G4ThreeVector &p) 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
 
G4ThreeVector GetPointOnSurface () const override
 
G4double ExactDistanceToIn (const G4ThreeVector &p) const
 
G4double ExactDistanceToOut (const G4ThreeVector &p) const
 
G4double GetCubicVolume () override
 
G4double GetSurfaceArea () override
 
G4GeometryType GetEntityType () const override
 
G4VisExtent GetExtent () 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
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const override
 
G4Polyhedron * CreatePolyhedron () const override
 
std::ostream & StreamInfo (std::ostream &os) const override
 
const TopoDS_Shape & GetOCCTShape () const
 
void SetOCCTShape (const TopoDS_Shape &shape)
 

Static Public Member Functions

static G4OCCTSolidFromSTEP (const G4String &name, const std::string &path)
 

Detailed Description

Geant4 solid wrapping an Open CASCADE Technology (OCCT) TopoDS_Shape.

G4OCCTSolid is the Geant4-facing adapter over G4OCCT's shared OCCT solid query kernel. The adapter preserves the original G4VSolid contract and keeps Geant4 worker-thread cache ownership local to the Geant4 workflow, while the shared kernel owns the reusable OCCT geometry/query state needed for future non-Geant4 frontends.

Definition at line 31 of file G4OCCTSolid.hh.

Constructor & Destructor Documentation

◆ G4OCCTSolid()

G4OCCTSolid::G4OCCTSolid ( const G4String &  name,
const TopoDS_Shape &  shape 
)

Construct with a Geant4 solid name and an OCCT shape.

Parameters
nameName registered with the Geant4 solid store.
shapeOCCT boundary-representation shape to wrap.
Exceptions
std::invalid_argumentif shape is null or has no computable bounding box.

Definition at line 76 of file G4OCCTSolid.cc.

◆ ~G4OCCTSolid()

G4OCCTSolid::~G4OCCTSolid ( )
overridedefault

Destroy the solid and release its adapter-owned caches.

Member Function Documentation

◆ BoundingLimits()

void G4OCCTSolid::BoundingLimits ( G4ThreeVector &  pMin,
G4ThreeVector &  pMax 
) const
override

Return axis-aligned bounding-box limits.

Definition at line 160 of file G4OCCTSolid.cc.

◆ CalculateExtent()

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

Calculate the solid extent along axis pAxis under pTransform and pVoxelLimit.

Definition at line 166 of file G4OCCTSolid.cc.

◆ CreatePolyhedron()

G4Polyhedron * G4OCCTSolid::CreatePolyhedron ( ) const
override

Create a polyhedron representation for visualisation.

The adapter caches the generated polyhedron per shape generation.

Definition at line 176 of file G4OCCTSolid.cc.

References g4occt::detail::kOCCTRelativeDeflection.

◆ DescribeYourselfTo()

void G4OCCTSolid::DescribeYourselfTo ( G4VGraphicsScene &  scene) const
override

Describe the solid to the graphics scene.

Definition at line 174 of file G4OCCTSolid.cc.

◆ DistanceToIn() [1/2]

G4double G4OCCTSolid::DistanceToIn ( const G4ThreeVector &  p) const
override

Lower bound on the shortest distance from external point p to the surface.

Use ExactDistanceToIn() when the exact shortest distance is required.

Definition at line 121 of file G4OCCTSolid.cc.

◆ DistanceToIn() [2/2]

G4double G4OCCTSolid::DistanceToIn ( const G4ThreeVector &  p,
const G4ThreeVector &  v 
) const
override

Distance from external point p along direction v to the surface.

Parameters
pPoint outside (or on) the solid surface.
vNon-zero direction vector, as required by the G4VSolid contract.
Returns
Distance to the first surface intersection, or kInfinity if the ray does not intersect the solid.

Definition at line 117 of file G4OCCTSolid.cc.

◆ DistanceToOut() [1/2]

G4double G4OCCTSolid::DistanceToOut ( const G4ThreeVector &  p) const
override

Lower bound on the shortest distance from internal point p to the surface.

Use ExactDistanceToOut() when the exact shortest distance is required.

Definition at line 132 of file G4OCCTSolid.cc.

◆ DistanceToOut() [2/2]

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

Distance from internal point p along direction v to the surface.

Parameters
pPoint inside (or on) the solid surface.
vNon-zero direction vector, as required by the G4VSolid contract.
calcNormWhen true, also request the exit normal information.
validNormOptional output flag reporting whether n contains a valid normal.
nOptional output for the exit normal.
Returns
Distance to the first exit intersection along v.

Definition at line 125 of file G4OCCTSolid.cc.

◆ ExactDistanceToIn()

G4double G4OCCTSolid::ExactDistanceToIn ( const G4ThreeVector &  p) const

Exact shortest distance from external point p to the surface.

Returns
Zero when p is on or inside the surface.

Definition at line 140 of file G4OCCTSolid.cc.

◆ ExactDistanceToOut()

G4double G4OCCTSolid::ExactDistanceToOut ( const G4ThreeVector &  p) const

Exact shortest distance from internal point p to the surface.

Returns
Zero when p is within the surface tolerance of the boundary.

Definition at line 144 of file G4OCCTSolid.cc.

◆ FromSTEP()

G4OCCTSolid * G4OCCTSolid::FromSTEP ( const G4String &  name,
const std::string &  path 
)
static

Load a STEP file and construct a G4OCCTSolid from the first shape found.

Convenience factory that combines STEP file reading with solid construction.

Parameters
nameName registered with the Geant4 solid store.
pathFilesystem path to the STEP file.
Returns
Pointer to a newly heap-allocated G4OCCTSolid (owned by the caller).
Exceptions
std::runtime_errorif the file cannot be read, transfers no roots, or yields a null shape.

Definition at line 81 of file G4OCCTSolid.cc.

Referenced by G4OCCTDetectorConstruction::Construct().

◆ GetCubicVolume()

G4double G4OCCTSolid::GetCubicVolume ( )
override

Compute and return the cubic volume of the solid.

The shared kernel caches the result after the first evaluation for the current shape generation.

Definition at line 148 of file G4OCCTSolid.cc.

◆ GetEntityType()

G4GeometryType G4OCCTSolid::GetEntityType ( ) const
override

Return a string identifying the entity type.

Definition at line 152 of file G4OCCTSolid.cc.

◆ GetExtent()

G4VisExtent G4OCCTSolid::GetExtent ( ) const
override

Return the axis-aligned bounding-box extent.

Definition at line 154 of file G4OCCTSolid.cc.

◆ GetOCCTShape()

const TopoDS_Shape & G4OCCTSolid::GetOCCTShape ( ) const

Read-only access to the underlying OCCT shape currently used for queries.

Definition at line 281 of file G4OCCTSolid.cc.

◆ GetPointOnSurface()

G4ThreeVector G4OCCTSolid::GetPointOnSurface ( ) const
override

Return a point sampled on the solid surface.

Sampling is performed from the cached OCCT tessellation used by the shared kernel and projected back to the analytical face where possible.

Definition at line 136 of file G4OCCTSolid.cc.

◆ GetSurfaceArea()

G4double G4OCCTSolid::GetSurfaceArea ( )
override

Compute and return the surface area of the solid.

The shared kernel caches the result after the first evaluation for the current shape generation.

Definition at line 150 of file G4OCCTSolid.cc.

◆ Inside()

EInside G4OCCTSolid::Inside ( const G4ThreeVector &  p) const
override

Return kInside, kSurface, or kOutside for point p.

Definition at line 107 of file G4OCCTSolid.cc.

◆ SetOCCTShape()

void G4OCCTSolid::SetOCCTShape ( const TopoDS_Shape &  shape)

Replace the underlying OCCT shape.

Note
Updating the shape bumps the kernel generation so each worker-thread thread-local cache entry is rebuilt lazily on the next query. This call is not synchronised with in-flight navigation; do not call it while a simulation run is in progress.
Exceptions
std::invalid_argumentif shape is null or has no computable bounding box.

Definition at line 283 of file G4OCCTSolid.cc.

◆ StreamInfo()

std::ostream & G4OCCTSolid::StreamInfo ( std::ostream &  os) const
override

Stream a human-readable description of the solid.

Definition at line 271 of file G4OCCTSolid.cc.

◆ SurfaceNormal()

G4ThreeVector G4OCCTSolid::SurfaceNormal ( const G4ThreeVector &  p) const
override

Return the outward unit normal at surface point p.

Behaviour is defined for points on the surface, following the Geant4 G4VSolid contract.

Definition at line 113 of file G4OCCTSolid.cc.


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