|
G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
|
Geant4 solid wrapping an Open CASCADE Technology (OCCT) TopoDS_Shape. More...
#include <G4OCCTSolid.hh>
Public Member Functions | |
| G4OCCTSolid (const G4String &name, const TopoDS_Shape &shape) | |
| ~G4OCCTSolid () override | |
| EInside | Inside (const G4ThreeVector &p) const override |
Return kInside, kSurface, or kOutside for point p. | |
| G4ThreeVector | SurfaceNormal (const G4ThreeVector &p) const override |
Return the outward unit normal at surface point p. | |
| 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 |
| Return a string identifying the entity type. | |
| G4VisExtent | GetExtent () const override |
| Return the axis-aligned bounding box extent. | |
| void | BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const override |
| Return the axis-aligned bounding box limits. | |
| G4bool | CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override |
| Calculate the extent of the solid in the given axis. | |
| void | DescribeYourselfTo (G4VGraphicsScene &scene) const override |
| Describe the solid to the graphics scene. | |
| G4Polyhedron * | CreatePolyhedron () const override |
| Create a polyhedron representation for visualisation. | |
| std::ostream & | StreamInfo (std::ostream &os) const override |
| Stream a human-readable description. | |
| const TopoDS_Shape & | GetOCCTShape () const |
| Read access to the underlying OCCT shape. | |
| void | SetOCCTShape (const TopoDS_Shape &shape) |
Static Public Member Functions | |
| static G4OCCTSolid * | FromSTEP (const G4String &name, const std::string &path) |
Geant4 solid wrapping an Open CASCADE Technology (OCCT) TopoDS_Shape.
Wraps an Open CASCADE Technology (OCCT) TopoDS_Shape as a Geant4 solid (G4VSolid). The OCCT shape is stored by value and is queried directly for Geant4 navigation, extent, and visualisation requests.
In OCCT the closest analogue to G4VSolid is TopoDS_Shape, which is the root of the Boundary-Representation topology hierarchy and can describe any shape from a simple box to a complex multi-face shell. The mapping is discussed in detail in docs/geometry_mapping.md.
G4OCCTSolid is shared read-only across all Geant4 worker threads once the geometry is constructed. OCCT algorithm objects such as BRepClass3d_SolidClassifier and IntCurvesFace_Intersector hold mutable internal state and must not be shared between threads. Per-thread caches of both algorithm objects are maintained via G4Cache so that the one-time O(N_faces) initialisation cost is paid only once per thread rather than on every navigation call.
A monotonically increasing fShapeGeneration counter is incremented by SetOCCTShape(). Each per-thread cache entry records the generation at which it was built; GetOrCreateClassifier() and GetOrCreateIntersector() rebuild the entry whenever the stored generation is stale. This ensures that all worker threads automatically pick up a new shape on their next navigation call, even if SetOCCTShape() is invoked after some threads have already initialised their caches.
Definition at line 70 of file G4OCCTSolid.hh.
| G4OCCTSolid::G4OCCTSolid | ( | const G4String & | name, |
| const TopoDS_Shape & | shape | ||
| ) |
Construct with a Geant4 solid name and an OCCT shape.
| name | Name registered with the Geant4 solid store. |
| shape | OCCT boundary-representation shape to wrap. |
| std::invalid_argument | if shape is null or has no computable bounding box. |
Definition at line 481 of file G4OCCTSolid.cc.
|
override |
Definition at line 489 of file G4OCCTSolid.cc.
|
override |
Return the axis-aligned bounding box limits.
Definition at line 1564 of file G4OCCTSolid.cc.
|
override |
Calculate the extent of the solid in the given axis.
Definition at line 1569 of file G4OCCTSolid.cc.
|
override |
Create a polyhedron representation for visualisation.
Definition at line 1578 of file G4OCCTSolid.cc.
|
override |
Describe the solid to the graphics scene.
Definition at line 1576 of file G4OCCTSolid.cc.
|
override |
A lower bound on the shortest distance from external point p to the solid surface.
Uses a two-stage acceleration pipeline:
Tier 0 (O(1)): If p is outside the cached axis-aligned bounding box by more than IntersectionTolerance(), the AABB distance is returned immediately. This is always a valid conservative lower bound and avoids any OCCT call for distant exterior points.
Fallback: Points within IntersectionTolerance() of the AABB fall through to ExactDistanceToIn(p).
For the exact shortest distance, use ExactDistanceToIn(p).
Definition at line 1282 of file G4OCCTSolid.cc.
References ExactDistanceToIn().
|
override |
Distance from external point p along direction v to solid surface.
| p | Point outside (or on) the solid surface. |
| v | Non-zero unit direction vector (precondition required by the G4VSolid contract). |
Definition at line 1175 of file G4OCCTSolid.cc.
|
override |
A lower bound on the shortest distance from internal point p to the solid surface. For the exact shortest distance, use ExactDistanceToOut(p).
Definition at line 1392 of file G4OCCTSolid.cc.
References ExactDistanceToOut().
|
override |
Distance from internal point p along direction v to solid surface.
| p | Point inside (or on) the solid surface. |
| v | Non-zero unit direction vector (precondition required by the G4VSolid contract). |
Definition at line 1305 of file G4OCCTSolid.cc.
| G4double G4OCCTSolid::ExactDistanceToIn | ( | const G4ThreeVector & | p | ) | const |
Exact shortest distance from external point p to the solid surface. Returns 0 if p is on or inside the surface, or kInfinity if the calculation fails.
Definition at line 1212 of file G4OCCTSolid.cc.
Referenced by DistanceToIn().
| G4double G4OCCTSolid::ExactDistanceToOut | ( | const G4ThreeVector & | p | ) | const |
Exact shortest distance from internal point p to the solid surface. Returns 0 if p is within IntersectionTolerance() of the surface, or if the calculation fails. For points outside the solid, returns the positive distance to the nearest surface.
Definition at line 1381 of file G4OCCTSolid.cc.
Referenced by DistanceToOut().
|
static |
Load a STEP file and construct a G4OCCTSolid from the first shape found.
Convenience factory that combines STEP file reading with solid construction. Equivalent to constructing a G4OCCTSolid from the shape returned by a STEPControl_Reader.
| name | Name registered with the Geant4 solid store. |
| path | Filesystem path to the STEP file. |
| std::runtime_error | if the file cannot be read or yields a null shape. |
Definition at line 503 of file G4OCCTSolid.cc.
Referenced by G4OCCTDetectorConstruction::Construct(), and G4OCCT_ImportSTEPSolid().
|
override |
Compute and return the cubic volume of the solid. The result is cached; repeated calls return the cached value.
Definition at line 1415 of file G4OCCTSolid.cc.
|
override |
Return a string identifying the entity type.
Definition at line 1557 of file G4OCCTSolid.cc.
|
override |
Return the axis-aligned bounding box extent.
Definition at line 1559 of file G4OCCTSolid.cc.
|
inline |
Read access to the underlying OCCT shape.
Definition at line 206 of file G4OCCTSolid.hh.
Referenced by G4OCCT_ImportSTEPSolid().
|
override |
Return a point sampled uniformly at random from the solid's surface.
The OCCT shape is tessellated with a relative chord deflection of 1 % and each mesh triangle is selected with probability proportional to its (planar) area. A random point within the selected triangle is then generated using standard barycentric-coordinate sampling and projected back to the nearest point on the triangle's originating analytical OCCT face surface via GeomAPI_ProjectPointOnSurf. This projection step places the returned point on the analytical surface for curved faces (spheres, cylinders, cones, tori, etc.), rather than inside the solid at a chord midpoint of the tessellation mesh. If projection fails (e.g. for a degenerate or null surface), the raw tessellation point is returned as a fallback; such a point may lie slightly inside the solid.
The distribution is area-weighted over the triangulated surface, which approximates the uniform distribution over the true analytic surface; the bias is proportional to the curvature and the 1 % chord-height error. The tessellation is cached per shape generation so repeated calls only require an O(log N_triangles) area selection plus one surface projection.
Emits a JustWarning G4Exception and returns the origin if the tessellation produces no valid triangles.
Definition at line 1500 of file G4OCCTSolid.cc.
|
override |
Compute and return the surface area of the solid. The result is cached; repeated calls return the cached value.
Definition at line 1425 of file G4OCCTSolid.cc.
|
override |
Return kInside, kSurface, or kOutside for point p.
Definition at line 880 of file G4OCCTSolid.cc.
|
inline |
Replace the underlying OCCT shape.
| std::invalid_argument | if shape is null or has no computable bounding box. |
Definition at line 215 of file G4OCCTSolid.hh.
|
override |
Stream a human-readable description.
Definition at line 1689 of file G4OCCTSolid.cc.
|
override |
Return the outward unit normal at surface point p.
Definition at line 1074 of file G4OCCTSolid.cc.