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

Parses an XML material-map file into a G4OCCTMaterialMap. More...

#include <G4OCCTMaterialMapReader.hh>

Inheritance diagram for G4OCCTMaterialMapReader:

Public Member Functions

 G4OCCTMaterialMapReader ()=default
 
 ~G4OCCTMaterialMapReader () override=default
 
G4OCCTMaterialMap ReadFile (const G4String &path)
 

Detailed Description

Parses an XML material-map file into a G4OCCTMaterialMap.

Subclasses G4GDMLReadStructure to gain zero-duplication access to all G4GDMLReadMaterials protected parsing methods (MaterialRead, ElementRead, IsotopeRead, FractionRead, DRead, …). Only the dispatching logic for the custom G4OCCT attributes (stepName and geant4Name) is new code.

File format

The root element must be <materials>. Two entry types are supported:

Type 1 — Named lookup (no <fraction> children required):

<material stepName="AISI 316L" geant4Name="G4_STAINLESS-STEEL"/>
<material stepName="CaloModule" geant4Name="LeadGlass"/>

geant4Name is passed to G4NistManager::FindOrBuildMaterial(), which first checks the global G4MaterialTable and then falls back to the NIST database. This means any material already registered (e.g. by a preceding G4GDMLParser::Read() call with name-stripping) can be referenced by its plain name — not only NIST materials. An unrecognised name is a fatal error.

Type 2 — Inline GDML material definition:

<element name="Si" Z="14"><atom value="28.085"/></element>
<material stepName="FR4" name="FR4" state="solid">
<D value="1.86" unit="g/cm3"/>
<fraction n="0.18" ref="Si"/>
<fraction n="0.39" ref="O"/>
...
</material>

The name attribute is the GDML registry key; it must be present for inline definitions. Setting name equal to stepName is recommended for clarity. If a material with the same name (or its GDML-generated decorated form) is already in the G4MaterialTable, it is reused without re-creation. Prefer Type 1 when the material is already defined in the reference geometry GDML, to avoid creating duplicate G4 objects (extra elements and materials) that can disturb the Geant4 thread-local cache.

<element> and <isotope> definitions must appear before <material> entries that reference them.

Usage

G4OCCTMaterialMap map = reader.ReadFile("materials.xml");
auto* assembly = G4OCCTAssemblyVolume::FromSTEP("detector.step", map);
static G4OCCTAssemblyVolume * FromSTEP(const std::string &path, const G4OCCTMaterialMap &materialMap)
Parses an XML material-map file into a G4OCCTMaterialMap.
G4OCCTMaterialMap ReadFile(const G4String &path)
Maps STEP material names to Geant4 G4Material objects.

Definition at line 68 of file G4OCCTMaterialMapReader.hh.

Constructor & Destructor Documentation

◆ G4OCCTMaterialMapReader()

G4OCCTMaterialMapReader::G4OCCTMaterialMapReader ( )
default

◆ ~G4OCCTMaterialMapReader()

G4OCCTMaterialMapReader::~G4OCCTMaterialMapReader ( )
overridedefault

Member Function Documentation

◆ ReadFile()

G4OCCTMaterialMap G4OCCTMaterialMapReader::ReadFile ( const G4String &  path)

Parse the material-map XML file at path and return the populated map.

Parameters
pathFilesystem path to the XML material-map file.
Returns
G4OCCTMaterialMap with one entry per <material> element.
Exceptions
G4Exception(FatalException) on any parse or resolution error.

Definition at line 21 of file G4OCCTMaterialMapReader.cc.

References G4OCCTMaterialMap::Add().

Referenced by G4OCCTDetectorConstruction::Construct().


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