BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSGeometryFactoryGDML.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifdef USE_GDML
19
20#ifndef BDSGEOMETRYFACTORYGDML_H
21#define BDSGEOMETRYFACTORYGDML_H
22
23#include "BDSGeometryFactoryBase.hh"
24
25#include "globals.hh"
26#include "G4String.hh"
27#include "G4VisAttributes.hh"
28
29#include <array>
30#include <map>
31#include <set>
32#include <vector>
33
35class G4Colour;
36class G4GDMLParser;
37class G4LogicalVolume;
38class G4UserLimits;
39class G4VPhysicalVolume;
40
48{
49public:
51 virtual ~BDSGeometryFactoryGDML(){;}
52
55 virtual BDSGeometryExternal* Build(G4String componentName,
56 G4String fileName,
57 std::map<G4String, G4Colour*>* colourMapping = nullptr,
58 G4bool autoColour = true,
59 G4double suggestedLength = 0,
60 G4double suggestedHorizontalWidth = 0,
61 std::vector<G4String>* namedVacuumVolumes = nullptr,
62 G4bool makeSensitive = true,
63 BDSSDType sensitivityType = BDSSDType::energydep,
64 BDSSDType vacuumSensitivityType = BDSSDType::energydepvacuum,
65 G4UserLimits* userLimitsToAttachToAllLVs = nullptr);
66
69 static std::array<G4double, 4> VRGBAStringAndUnitToColourAndStyle(const G4String& value,
70 G4bool& visible);
71
72protected:
74 virtual G4String PreprocessedName(const G4String& objectName,
75 const G4String& acceleratorComponentName) const;
76
77private:
78 std::map<G4String, G4Colour*> BuildColourMap(const std::set<G4LogicalVolume*>& lvsGDML,
79 G4GDMLParser* parser,
80 const G4String& componentName);
81
86 void ReplaceStringInFile(const G4String& filename,
87 const G4String& outputFileName,
88 const G4String& key,
89 const G4String& replacement);
90
93 void GetAllLogicalPhysicalAndMaterials(const G4VPhysicalVolume* volume,
94 std::set<G4VPhysicalVolume*>& pvs,
95 std::set<G4LogicalVolume*>& lvs,
96 std::map<G4String, G4Material*>& materialsGDML);
97};
98
99#endif
100
101#endif
A loaded piece of externally provided geometry.
Base class for external geometry loading factories.
Interface to Geant4's GDML loader.
void GetAllLogicalPhysicalAndMaterials(const G4VPhysicalVolume *volume, std::set< G4VPhysicalVolume * > &pvs, std::set< G4LogicalVolume * > &lvs, std::map< G4String, G4Material * > &materialsGDML)
static std::array< G4double, 4 > VRGBAStringAndUnitToColourAndStyle(const G4String &value, G4bool &visible)
virtual BDSGeometryExternal * Build(G4String componentName, G4String fileName, std::map< G4String, G4Colour * > *colourMapping=nullptr, G4bool autoColour=true, G4double suggestedLength=0, G4double suggestedHorizontalWidth=0, std::vector< G4String > *namedVacuumVolumes=nullptr, G4bool makeSensitive=true, BDSSDType sensitivityType=BDSSDType::energydep, BDSSDType vacuumSensitivityType=BDSSDType::energydepvacuum, G4UserLimits *userLimitsToAttachToAllLVs=nullptr)
virtual G4String PreprocessedName(const G4String &objectName, const G4String &acceleratorComponentName) const
Use the GDML preprocessing scheme to prepare the preprocessed volume names.
void ReplaceStringInFile(const G4String &filename, const G4String &outputFileName, const G4String &key, const G4String &replacement)
Improve type-safety of native enum data type in C++.