|
G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
|
step2dd4hep — generate a DD4hep compact file from a STEP geometry. More...
#include <IFSelect_ReturnStatus.hxx>#include <STEPCAFControl_Reader.hxx>#include <TDataStd_Name.hxx>#include <TDF_LabelSequence.hxx>#include <TDocStd_Application.hxx>#include <TDocStd_Document.hxx>#include <XCAFDoc_DocumentTool.hxx>#include <XCAFDoc_MaterialTool.hxx>#include <XCAFDoc_ShapeTool.hxx>#include <algorithm>#include <cstdlib>#include <cstring>#include <filesystem>#include <fstream>#include <iostream>#include <map>#include <set>#include <sstream>#include <stdexcept>#include <string>#include <vector>Go to the source code of this file.
Functions | |
| static std::string | LabelName (const TDF_Label &label) |
Return the TDataStd_Name value for label, or empty string. | |
| static std::string | MaterialName (const TDF_Label &label, const Handle(XCAFDoc_MaterialTool) &matTool) |
Return the XDE material name for label, or empty string. | |
| static void | CollectMaterials (const TDF_Label &label, const Handle(XCAFDoc_ShapeTool) &shapeTool, const Handle(XCAFDoc_MaterialTool) &matTool, std::set< std::string > &out) |
| static std::string | XmlAttr (const std::string &s) |
| Escape characters that must be escaped inside an XML attribute value. | |
| static std::string | XmlUnescape (std::string s) |
| static std::map< std::string, std::string > | ReadExistingMap (const std::string &path) |
| static void | PrintUsage (const char *prog) |
| int | main (int argc, char **argv) |
step2dd4hep — generate a DD4hep compact file from a STEP geometry.
Usage:
The tool reads the STEP file with the OpenCASCADE XDE framework, collects all unique material names attached to solid labels (the same attribute that G4OCCTAssemblyVolume::FromSTEP uses), and emits:
<entry> per unique STEP material name, with dd4hep_material left as a TODO placeholder (or filled in from an existing map that the user provides).If no material names are found in the STEP metadata, the label names of the free shapes are used instead, which matches the fall-back key used by G4OCCTAssemblyVolume when a material attribute is absent.
Definition in file main.cc.
|
static |
Recursively walk the XDE label tree and collect unique material keys.
The priority order matches G4OCCTAssemblyVolume::ImportLabel:
Definition at line 96 of file main.cc.
References CollectMaterials(), LabelName(), and MaterialName().
Referenced by CollectMaterials(), and main().
|
static |
Return the TDataStd_Name value for label, or empty string.
Definition at line 66 of file main.cc.
Referenced by CollectMaterials().
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 216 of file main.cc.
References CollectMaterials(), PrintUsage(), ReadExistingMap(), and XmlAttr().
|
static |
Return the XDE material name for label, or empty string.
Definition at line 77 of file main.cc.
Referenced by CollectMaterials().
|
static |
|
static |
Parse an existing material-map XML produced by this tool and return a map of step_name → dd4hep_material for entries that are not placeholders.
Definition at line 171 of file main.cc.
References XmlUnescape().
Referenced by main().
|
static |
|
static |
Unescape the five predefined XML entities in an attribute value string so that names read back from the written XML match the raw OCCT strings.
Definition at line 151 of file main.cc.
Referenced by ReadExistingMap().