G4OCCT 0.1.0
Geant4 interface to Open CASCADE Technology (OCCT) geometry definitions
Loading...
Searching...
No Matches
G4OCCTMaterialMap.cc
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2// Copyright (C) 2026 G4OCCT Contributors
3
6
8
9#include <G4Exception.hh>
10#include <G4Material.hh>
11
12void G4OCCTMaterialMap::Add(const G4String& stepName, G4Material* material) {
13 if (!material) {
14 G4Exception("G4OCCTMaterialMap::Add", "G4OCCT_MatMap000", FatalException,
15 ("Null G4Material* provided for STEP material name: \"" + stepName +
16 "\". G4OCCTMaterialMap::Add() requires a non-null material pointer.")
17 .c_str());
18 return; // unreachable; silences compiler warnings
19 }
20 fMap[stepName] = material;
21}
22
23G4Material* G4OCCTMaterialMap::Resolve(const G4String& stepName) const {
24 auto it = fMap.find(stepName);
25 if (it == fMap.end()) {
26 G4Exception("G4OCCTMaterialMap::Resolve", "G4OCCT_MatMap001", FatalException,
27 ("Unresolved STEP material name: \"" + stepName +
28 "\". Register it with G4OCCTMaterialMap::Add() before importing.")
29 .c_str());
30 return nullptr; // unreachable; silences compiler warnings
31 }
32 return it->second;
33}
34
35bool G4OCCTMaterialMap::Contains(const G4String& stepName) const {
36 return fMap.count(stepName) > 0;
37}
38
40 for (const auto& [name, mat] : other.fMap) {
41 Add(name, mat);
42 }
43}
Declaration of G4OCCTMaterialMap.
Maps STEP material names to Geant4 G4Material objects.
void Add(const G4String &stepName, G4Material *material)
bool Contains(const G4String &stepName) const
void Merge(const G4OCCTMaterialMap &other)
G4Material * Resolve(const G4String &stepName) const