20#include "BDSException.hh"
21#include "BDSSDEnergyDeposition.hh"
22#include "BDSGeometryExternal.hh"
23#include "BDSGeometryFactory.hh"
24#include "BDSGeometryFactoryBase.hh"
26#include "BDSGeometryFactoryGDML.hh"
28#include "BDSGeometryFactorySQL.hh"
29#include "BDSGeometryType.hh"
30#include "BDSSDType.hh"
31#include "BDSUtilities.hh"
59BDSGeometryFactory::~BDSGeometryFactory()
73 case BDSGeometryType::gdml:
76 case BDSGeometryType::mokka:
80 G4cout <<
"Unsupported factory type " << type;
87 const G4String& formatAndFileName,
88 std::map<G4String, G4Colour*>* colourMapping,
90 G4double suggestedLength,
91 G4double suggestedHorizontalWidth,
92 std::vector<G4String>* namedVacuumVolumes,
96 G4bool stripOuterVolumeAndMakeAssembly,
97 G4UserLimits* userLimitsToAttachToAllLVs,
98 G4bool dontReloadGeometry)
103 G4String searchName = fileName;
108 if (stripOuterVolumeAndMakeAssembly)
109 {searchName +=
"_stripped";}
116 if (dontReloadGeometry)
117 {componentName =
"dontReloadGeometry";}
119 auto nameAndField = std::make_pair(searchName, componentName);
120 const auto search =
registry.find(nameAndField);
122 {
return search->second;}
127 {
throw BDSException(__METHOD_NAME__,
"No such file \"" + fileName +
"\"");}
139 suggestedHorizontalWidth,
143 vacuumSensitivityType,
144 userLimitsToAttachToAllLVs);
148 if (stripOuterVolumeAndMakeAssembly)
152 auto key = std::make_pair((std::string)searchName, componentName);
General exception with possible name of object and message.
void StripOuterAndMakeAssemblyVolume()
Change from a container logical volume to an assembly volume.
A loaded piece of externally provided geometry.
Base class for external geometry loading factories.
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 > *vacuumBiasVolumeNames=nullptr, G4bool makeSensitive=true, BDSSDType sensitivityType=BDSSDType::energydep, BDSSDType vacuumSensitivityType=BDSSDType::energydepvacuum, G4UserLimits *userLimitsToAttachToAllLVs=nullptr)=0
Main method to load and construct geometry.
Interface to Geant4's GDML loader.
Geometry factory for SQL geometry.
Interface to external geometry construction.
BDSGeometryExternal * BuildGeometry(G4String componentName, const G4String &formatAndFilePath, 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, G4bool stripOuterVolumeAndMakeAssembly=false, G4UserLimits *userLimitsToAttachToAllLVs=nullptr, G4bool dontReloadGeometry=false)
static BDSGeometryFactory * Instance()
Singleton accessor.
static BDSGeometryFactory * instance
Singleton instance.
BDSGeometryFactoryBase * gdml
Factory instance.
std::map< std::pair< std::string, std::string >, BDSGeometryExternal * > registry
BDSGeometryFactoryBase * GetAppropriateFactory(BDSGeometryType type)
Get the appropriate geometry factory.
BDSGeometryFactory()
Private accessor as singleton.
std::set< BDSGeometryExternal * > storage
BDSGeometryFactoryBase * sql
Factory instance.
Improve type-safety of native enum data type in C++.
type underlying() const
return underlying value (can be used in switch statement)
std::pair< G4String, G4String > SplitOnColon(const G4String &formatAndPath)
BDSGeometryType DetermineGeometryType(G4String geometryType)
function that gives corresponding enum value for string (case-insensitive)
G4String GetFullPath(G4String filename, bool excludeNameFromPath=false, bool useCWDForPrefix=false)
G4bool FileExists(const G4String &filename)
Checks if filename exists.