G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
G4OCCT_STEPAssembly_impl.cc
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2// Copyright (C) 2026 G4OCCT Contributors
3
10
12
16
17#include <map>
18#include <memory>
19#include <stdexcept>
20#include <string>
21#include <vector>
22
23class G4Material;
24
25int G4OCCT_ImportSTEPAssembly(const std::string& path,
26 const std::map<std::string, G4Material*>& materials,
27 const std::string& detectorName,
28 const std::vector<std::string>& /*sensitiveNames*/) {
29 G4OCCTMaterialMap matMap;
30 for (const auto& [stepName, g4mat] : materials) {
31 matMap.Add(stepName, g4mat);
32 }
33
34 std::unique_ptr<G4OCCTAssemblyVolume> assembly;
35 try {
36 assembly.reset(G4OCCTAssemblyVolume::FromSTEP(path, matMap));
37 } catch (const std::exception& ex) {
38 throw std::runtime_error("G4OCCT_STEPAssembly: failed to import '" + path + "' (" + ex.what() +
39 ")");
40 }
41
42 const int nConstituents = static_cast<int>(assembly->GetLogicalVolumes().size());
43 G4OCCTAssemblyRegistry::Instance().Register(detectorName, assembly.get());
44 assembly.release(); // registry takes ownership
45 return nConstituents;
46}
Declaration of G4OCCTAssemblyRegistry.
Declaration of G4OCCTAssemblyVolume.
Declaration of G4OCCTMaterialMap.
int G4OCCT_ImportSTEPAssembly(const std::string &path, const std::map< std::string, G4Material * > &materials, const std::string &detectorName, const std::vector< std::string > &)
Firewall bridge between the DD4hep plugin TU and G4OCCT/OCCT.
static G4OCCTAssemblyRegistry & Instance()
Return the singleton instance.
void Register(const std::string &name, G4OCCTAssemblyVolume *assembly)
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)