G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
G4OCCTDetectorConstruction.hh
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2// Copyright (C) 2026 G4OCCT Contributors
3
6
7#ifndef G4OCCT_APP_G4OCCTDetectorConstruction_hh
8#define G4OCCT_APP_G4OCCTDetectorConstruction_hh
9
10#include <G4String.hh>
11#include <G4ThreeVector.hh>
12#include <G4VUserDetectorConstruction.hh>
13
14#include <memory>
15#include <string>
16#include <vector>
17
18class G4GenericMessenger;
19class G4VPhysicalVolume;
20
53class G4OCCTDetectorConstruction : public G4VUserDetectorConstruction {
54public:
57
58 G4VPhysicalVolume* Construct() override;
59
60 // ── Public API (callable from main() or messenger) ───────────────────────
61
63 void LoadMaterial(G4String xmlFile);
64
66 void AddSTEP(G4String stepFile);
67
69 void AddSolid(G4String stepFile, G4String materialName = "");
70
72 void AddAssembly(G4String stepFile);
73
75 void SetWorldMaterial(G4String name) { fWorldMaterial = std::move(name); }
76
78 void SetWorldHalfSize(G4ThreeVector halfSize) { fWorldHalfSize = halfSize; }
79
80private:
81 struct SolidEntry {
82 std::string file;
83 std::string material;
84 };
85
86 struct AssemblyEntry {
87 std::string file;
88 };
89
90 // Material XML files are stored and loaded at Construct() time so that
91 // all maps can be merged before any geometry is built.
92 std::vector<std::string> fMaterialXmlFiles;
93 std::vector<SolidEntry> fSolidEntries;
94 std::vector<AssemblyEntry> fAssemblyEntries;
95 G4String fWorldMaterial{"G4_AIR"};
96 G4ThreeVector fWorldHalfSize{0, 0, 0};
97
98 std::unique_ptr<G4GenericMessenger> fLoadMessenger;
99 std::unique_ptr<G4GenericMessenger> fWorldMessenger;
100 std::unique_ptr<G4GenericMessenger> fVisMessenger;
101
102 void DefineMessengers();
103
105 static void UI(const G4String& cmd);
106
108 void OpenViewer(G4String driver);
109 void RefreshScene();
110};
111
112#endif // G4OCCT_APP_G4OCCTDetectorConstruction_hh
Dynamically constructs a Geant4 world from STEP solids and assemblies.
void LoadMaterial(G4String xmlFile)
Queue a material-map XML file to be loaded at construction time.
G4VPhysicalVolume * Construct() override
void AddSTEP(G4String stepFile)
Queue a STEP file as a solid or assembly (auto-detected).
void SetWorldMaterial(G4String name)
Set the world volume material by Geant4/NIST name.
void AddSolid(G4String stepFile, G4String materialName="")
Explicitly queue a STEP file as a G4OCCTSolid with an optional material override.
void AddAssembly(G4String stepFile)
Explicitly queue a STEP file as a G4OCCTAssemblyVolume.
void SetWorldHalfSize(G4ThreeVector halfSize)
Set the world half-size. Overrides auto-sizing.
~G4OCCTDetectorConstruction() override