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

Shared OCCT-backed query kernel used by adapter frontends. More...

#include <G4OCCTSolidKernel.hh>

Classes

struct  AxisAlignedBounds
 Axis-aligned bounds in the imported OCCT coordinate system. More...
 
struct  ClassifierCache
 
struct  InscribedSphere
 Cached inscribed sphere used to accelerate deep-interior classifications. More...
 
struct  IntersectorCache
 
struct  SphereCacheData
 
struct  SurfaceSamplingCache
 
struct  SurfaceTriangle
 Tessellated triangle entry used for random surface-point sampling. More...
 

Public Types

enum class  PointClassification { kInside , kSurface , kOutside }
 Classification result for point-in-solid queries. More...
 

Public Member Functions

 G4OCCTSolidKernel (const TopoDS_Shape &shape)
 
void SetShape (const TopoDS_Shape &shape)
 
const TopoDS_Shape & Shape () const
 Read-only access to the currently wrapped OCCT shape.
 
std::uint64_t ShapeGeneration () const
 Monotonic generation counter incremented after successful SetShape().
 
const AxisAlignedBoundsBounds () const
 Return the cached axis-aligned bounds for the current shape.
 
PointClassification ClassifyPoint (const G4ThreeVector &p, ClassifierCache &classifierCache, IntersectorCache &intersectorCache, SphereCacheData &sphereCache) const
 Classify a point as inside, on, or outside the solid.
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 Return the outward surface normal at the face nearest point p.
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v, IntersectorCache &intersectorCache) const
 Exact ray distance from an exterior point to the first entry intersection.
 
G4double DistanceToIn (const G4ThreeVector &p, ClassifierCache &classifierCache) const
 Conservative lower bound on the shortest exterior distance to the solid.
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, IntersectorCache &intersectorCache, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
 Exact ray distance from an interior point to the first exit intersection.
 
G4double DistanceToOut (const G4ThreeVector &p, SphereCacheData &sphereCache) const
 Conservative lower bound on the shortest interior distance to the surface.
 
G4double ExactDistanceToIn (const G4ThreeVector &p, ClassifierCache &classifierCache) const
 Exact shortest distance from an exterior point to the surface.
 
G4double ExactDistanceToOut (const G4ThreeVector &p) const
 Exact shortest distance from a point to the surface.
 
G4double GetCubicVolume ()
 Compute and cache the solid volume for the current shape generation.
 
G4double GetSurfaceArea ()
 Compute and cache the solid surface area for the current shape generation.
 
G4ThreeVector GetPointOnSurface (const char *diagnosticName=nullptr) const
 
const SurfaceSamplingCacheGetOrBuildSurfaceCache () const
 Build or return the shared surface-sampling cache for the current shape.
 

Static Public Member Functions

static G4double Infinity ()
 Return the Geant4 navigation infinity sentinel used by the kernel.
 

Static Public Attributes

static constexpr std::size_t kMaxInscribedSpheres = 64
 Maximum number of inscribed spheres retained in a per-thread sphere cache.
 

Detailed Description

Shared OCCT-backed query kernel used by adapter frontends.

G4OCCTSolidKernel owns the shape-dependent state that is common to all frontends over the OCCT solid-query implementation: cached bounds, per-face metadata, tessellation/BVH state, and generation-tagged caches for exact OCCT query helpers.

The kernel is intentionally Geant4-dependent today because it reuses G4ThreeVector, G4double, kInfinity, and the Geant4 tolerance/error model. It is nevertheless separated from G4OCCTSolid so that adapter responsibilities such as G4VSolid integration, worker-thread G4Cache ownership, and visualisation-specific polyhedron generation remain outside the core shape-query implementation.

Definition at line 56 of file G4OCCTSolidKernel.hh.

Member Enumeration Documentation

◆ PointClassification

Classification result for point-in-solid queries.

Enumerator
kInside 
kSurface 
kOutside 

Definition at line 62 of file G4OCCTSolidKernel.hh.

Constructor & Destructor Documentation

◆ G4OCCTSolidKernel()

g4occt::detail::G4OCCTSolidKernel::G4OCCTSolidKernel ( const TopoDS_Shape &  shape)
explicit

Construct the kernel around an OCCT shape and eagerly derive shape-dependent metadata.

Exceptions
std::invalid_argumentif shape is null or has no computable bounding box.

Definition at line 365 of file G4OCCTSolidKernel.cc.

Member Function Documentation

◆ Bounds()

const AxisAlignedBounds & g4occt::detail::G4OCCTSolidKernel::Bounds ( ) const
inline

Return the cached axis-aligned bounds for the current shape.

Definition at line 155 of file G4OCCTSolidKernel.hh.

◆ ClassifyPoint()

◆ DistanceToIn() [1/2]

G4double g4occt::detail::G4OCCTSolidKernel::DistanceToIn ( const G4ThreeVector &  p,
ClassifierCache classifierCache 
) const

Conservative lower bound on the shortest exterior distance to the solid.

Definition at line 1015 of file G4OCCTSolidKernel.cc.

References ExactDistanceToIn(), and Infinity().

◆ DistanceToIn() [2/2]

G4double g4occt::detail::G4OCCTSolidKernel::DistanceToIn ( const G4ThreeVector &  p,
const G4ThreeVector &  v,
IntersectorCache intersectorCache 
) const

Exact ray distance from an exterior point to the first entry intersection.

Definition at line 914 of file G4OCCTSolidKernel.cc.

References g4occt::detail::G4OCCTSolidKernel::IntersectorCache::expandedBoxes, g4occt::detail::G4OCCTSolidKernel::IntersectorCache::faceIntersectors, and Infinity().

◆ DistanceToOut() [1/2]

G4double g4occt::detail::G4OCCTSolidKernel::DistanceToOut ( const G4ThreeVector &  p,
const G4ThreeVector &  v,
IntersectorCache intersectorCache,
const G4bool  calcNorm = false,
G4bool *  validNorm = nullptr,
G4ThreeVector *  n = nullptr 
) const

Exact ray distance from an interior point to the first exit intersection.

Definition at line 1032 of file G4OCCTSolidKernel.cc.

References g4occt::detail::G4OCCTSolidKernel::IntersectorCache::expandedBoxes, g4occt::detail::G4OCCTSolidKernel::IntersectorCache::faceIntersectors, and Infinity().

◆ DistanceToOut() [2/2]

G4double g4occt::detail::G4OCCTSolidKernel::DistanceToOut ( const G4ThreeVector &  p,
SphereCacheData sphereCache 
) const

Conservative lower bound on the shortest interior distance to the surface.

Definition at line 1112 of file G4OCCTSolidKernel.cc.

References ExactDistanceToOut(), and Infinity().

◆ ExactDistanceToIn()

G4double g4occt::detail::G4OCCTSolidKernel::ExactDistanceToIn ( const G4ThreeVector &  p,
ClassifierCache classifierCache 
) const

Exact shortest distance from an exterior point to the surface.

Definition at line 948 of file G4OCCTSolidKernel.cc.

References classifier, and Infinity().

Referenced by DistanceToIn().

◆ ExactDistanceToOut()

G4double g4occt::detail::G4OCCTSolidKernel::ExactDistanceToOut ( const G4ThreeVector &  p) const

Exact shortest distance from a point to the surface.

Definition at line 1104 of file G4OCCTSolidKernel.cc.

Referenced by DistanceToOut().

◆ GetCubicVolume()

G4double g4occt::detail::G4OCCTSolidKernel::GetCubicVolume ( )

Compute and cache the solid volume for the current shape generation.

Definition at line 1132 of file G4OCCTSolidKernel.cc.

◆ GetOrBuildSurfaceCache()

◆ GetPointOnSurface()

◆ GetSurfaceArea()

G4double g4occt::detail::G4OCCTSolidKernel::GetSurfaceArea ( )

Compute and cache the solid surface area for the current shape generation.

Definition at line 1142 of file G4OCCTSolidKernel.cc.

◆ Infinity()

static G4double g4occt::detail::G4OCCTSolidKernel::Infinity ( )
inlinestatic

Return the Geant4 navigation infinity sentinel used by the kernel.

Definition at line 59 of file G4OCCTSolidKernel.hh.

Referenced by DistanceToIn(), DistanceToIn(), DistanceToOut(), DistanceToOut(), ExactDistanceToIn(), g4occt::detail::TGeoOCCTSolidBridge::InfinityCm(), and SurfaceNormal().

◆ SetShape()

void g4occt::detail::G4OCCTSolidKernel::SetShape ( const TopoDS_Shape &  shape)

Replace the current shape and invalidate all generation-tagged caches.

Existing per-thread cache objects become stale and will rebuild lazily on their next use.

Exceptions
std::invalid_argumentif shape is null or has no computable bounding box.

Definition at line 372 of file G4OCCTSolidKernel.cc.

◆ Shape()

const TopoDS_Shape & g4occt::detail::G4OCCTSolidKernel::Shape ( ) const
inline

Read-only access to the currently wrapped OCCT shape.

Definition at line 149 of file G4OCCTSolidKernel.hh.

◆ ShapeGeneration()

std::uint64_t g4occt::detail::G4OCCTSolidKernel::ShapeGeneration ( ) const
inline

Monotonic generation counter incremented after successful SetShape().

Definition at line 152 of file G4OCCTSolidKernel.hh.

◆ SurfaceNormal()

G4ThreeVector g4occt::detail::G4OCCTSolidKernel::SurfaceNormal ( const G4ThreeVector &  p) const

Return the outward surface normal at the face nearest point p.

Definition at line 848 of file G4OCCTSolidKernel.cc.

References Infinity().

Member Data Documentation

◆ kMaxInscribedSpheres

constexpr std::size_t g4occt::detail::G4OCCTSolidKernel::kMaxInscribedSpheres = 64
staticconstexpr

Maximum number of inscribed spheres retained in a per-thread sphere cache.

Definition at line 107 of file G4OCCTSolidKernel.hh.


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