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

Extends Geant4's G4AssemblyVolume with an OCCT XDE label reference. More...

#include <G4OCCTAssemblyVolume.hh>

Inheritance diagram for G4OCCTAssemblyVolume:

Classes

struct  BuildContext
 State threaded through the recursive XDE label traversal. More...
 

Public Member Functions

 G4OCCTAssemblyVolume ()=default
 
 ~G4OCCTAssemblyVolume ()=default
 
const std::map< G4String, G4OCCTLogicalVolume * > & GetLogicalVolumes () const
 

Static Public Member Functions

static G4OCCTAssemblyVolumeFromSTEP (const std::string &path, const G4OCCTMaterialMap &materialMap)
 

Detailed Description

Extends Geant4's G4AssemblyVolume with an OCCT XDE label reference.

Imports a STEP assembly file using the OCCT Extended Data Exchange (XDE) layer and constructs the corresponding Geant4 volume hierarchy.

OCCT XDE to Geant4 mapping

XDE entity Geant4 result
Top-level assembly label G4OCCTAssemblyVolume (this class)
Simple-shape label (first use) G4OCCTSolid + G4OCCTLogicalVolume
Simple-shape label (repeated use) Shared G4OCCTLogicalVolume
Reference label + TopLoc_Location AddPlacedVolume() on parent assembly
XDE name attribute Volume name string
XDE material attribute (if present) G4Material* via G4OCCTMaterialMap
Part name (fallback when no mat attr) G4Material* via G4OCCTMaterialMap

Instance sharing

When the same XDE shape label is referenced from multiple locations the corresponding G4OCCTLogicalVolume is created only once and reused for each placement (incrementing the copy number each time). This mirrors Geant4's own convention.

Thread safety

This class constructs the Geant4 geometry during FromSTEP() and is subsequently read-only. It inherits G4AssemblyVolume's thread-safety guarantees after construction.

Usage

matMap.Add("Al 6061-T6", G4NistManager::Instance()->FindOrBuildMaterial("G4_Al"));
auto* assembly = G4OCCTAssemblyVolume::FromSTEP("detector.step", matMap);
// Imprint into the world logical volume
G4ThreeVector pos;
G4RotationMatrix rot;
assembly->MakeImprint(worldLV, pos, &rot);
static G4OCCTAssemblyVolume * FromSTEP(const std::string &path, const G4OCCTMaterialMap &materialMap)
Maps STEP material names to Geant4 G4Material objects.
void Add(const G4String &stepName, G4Material *material)

See docs/step_assembly_import.md for the full design and background.

Definition at line 69 of file G4OCCTAssemblyVolume.hh.

Constructor & Destructor Documentation

◆ G4OCCTAssemblyVolume()

G4OCCTAssemblyVolume::G4OCCTAssemblyVolume ( )
default

Referenced by FromSTEP().

◆ ~G4OCCTAssemblyVolume()

G4OCCTAssemblyVolume::~G4OCCTAssemblyVolume ( )
default

Member Function Documentation

◆ FromSTEP()

G4OCCTAssemblyVolume * G4OCCTAssemblyVolume::FromSTEP ( const std::string &  path,
const G4OCCTMaterialMap materialMap 
)
static

Import a STEP assembly file and construct the Geant4 volume hierarchy.

Reads the STEP file at path using STEPCAFControl_Reader (the OCCT XDE reader that preserves assembly structure, names, and material attributes). The label tree is traversed depth-first; each simple-shape leaf creates a G4OCCTSolid + G4OCCTLogicalVolume, and each placement is recorded via AddPlacedVolume() on the top-level assembly.

Every material name encountered in the STEP file must be present in materialMap; an unresolved name triggers a fatal G4Exception. When a shape carries no XDE material attribute, its part (label) name is used as the lookup key instead, accommodating STEP writers that do not write material attributes.

The leaf shapes are recentered (bounding-box centroid moved to the OCCT origin) before being wrapped in G4OCCTSolid; the recentering offset is absorbed into the placement transformation so that parts appear at their correct world positions.

Parameters
pathFilesystem path to the STEP file.
materialMapMap from STEP material name or part name to G4Material*.
Returns
Pointer to a newly heap-allocated G4OCCTAssemblyVolume owned by the caller. The returned object already contains all child volumes; call MakeImprint() to place it in the world.
Exceptions
std::runtime_errorif the file cannot be read or yields no shapes.

Definition at line 312 of file G4OCCTAssemblyVolume.cc.

References G4OCCTAssemblyVolume(), and G4OCCTAssemblyVolume::BuildContext::materialMap.

Referenced by G4OCCTDetectorConstruction::Construct(), and G4OCCT_ImportSTEPAssembly().

◆ GetLogicalVolumes()

const std::map< G4String, G4OCCTLogicalVolume * > & G4OCCTAssemblyVolume::GetLogicalVolumes ( ) const
inline

Return all logical volumes created during import, keyed by part name.

The map is populated during FromSTEP(). When two STEP parts share the same name the later name is suffixed with _<n> so that every entry is unique.

Definition at line 111 of file G4OCCTAssemblyVolume.hh.

Referenced by G4OCCT_ImportSTEPAssembly().


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