19#include "BDSException.hh"
20#include "BDSSDEnergyDeposition.hh"
21#include "BDSGeometryExternal.hh"
22#include "BDSGeometryFactory.hh"
23#include "BDSGeometryFactoryBase.hh"
25#include "BDSGeometryFactoryGDML.hh"
27#include "BDSGeometryFactorySQL.hh"
28#include "BDSGeometryType.hh"
29#include "BDSSDType.hh"
30#include "BDSUtilities.hh"
58BDSGeometryFactory::~BDSGeometryFactory()
72 case BDSGeometryType::gdml:
75 case BDSGeometryType::mokka:
79 G4cout <<
"Unsupported factory type " << type;
86 const G4String& formatAndFileName,
87 std::map<G4String, G4Colour*>* colourMapping,
89 G4double suggestedLength,
90 G4double suggestedHorizontalWidth,
91 std::vector<G4String>* namedVacuumVolumes,
95 G4bool stripOuterVolumeAndMakeAssembly,
96 G4UserLimits* userLimitsToAttachToAllLVs,
97 G4bool dontReloadGeometry)
102 G4String searchName = fileName;
107 if (stripOuterVolumeAndMakeAssembly)
108 {searchName +=
"_stripped";}
115 G4String searchComponentName = componentName;
116 if (dontReloadGeometry)
117 {searchComponentName =
"dontReloadGeometry";}
122 auto nameAndField = std::make_pair((std::string)searchName, searchComponentName);
123 const auto search =
registry.find(nameAndField);
125 {
return search->second;}
130 {
throw BDSException(__METHOD_NAME__,
"No such file \"" + fileName +
"\"");}
142 suggestedHorizontalWidth,
146 vacuumSensitivityType,
147 userLimitsToAttachToAllLVs);
151 if (stripOuterVolumeAndMakeAssembly)
155 auto key = std::make_pair((std::string)searchName, searchComponentName);
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.