29#define USE_CADMESH_ASSIMP_READER
36#include "CLHEP/Units/SystemOfUnits.h"
39 std::unordered_map<std::string,
48 if (thisG4Volume->getSolid() !=
nullptr)
return thisG4Volume->getSolid();
54 auto sourceName = s->
getSystem() +
"/" + copyOf;
56 if (sourceG4Volume->getSolid() !=
nullptr)
return sourceG4Volume->getSolid();
63 G4String g4filename = fileName;
66 std::string extension =
70 if (extension ==
"ply" || extension ==
"stl") {
71 auto mesh = CADMesh::TessellatedMesh::From(g4filename,
72 CADMesh::File::ASSIMP());
79 if (!pars.empty() && pars !=
"NULL") {
80 try { scale = std::stod(pars); }
81 catch (
const std::exception&) {
82 log->warning(
"G4CadSystemFactory: volume <", g4name,
83 "> has a non-numeric scale <", pars,
">; using 1.0");
89 mesh->SetScale(CLHEP::mm * scale);
92 mesh->SetReverse(
false);
94 thisG4Volume->setSolid(mesh->GetSolid(),
log);
95 return thisG4Volume->getSolid();
99 log->warning(
"G4CadSystemFactory: file <", fileName,
100 "> has unsupported extension <", extension,
">");
Factory that converts CAD files (PLY / STL) into Geant4 tessellated solids via CADMesh.
G4VSolid * buildSolid(const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s) override
Create (or fetch) a tessellated solid from a CAD file.
G4Volume * getOrCreateG4Volume(const std::string &volume_name, std::unordered_map< std::string, G4Volume * > *g4s)
Get or create a G4Volume wrapper entry in the map.
bool checkSolidDependencies(const GVolume *s, std::unordered_map< std::string, G4Volume * > *g4s)
Check whether all prerequisites to build a solid are satisfied.
Convenience container holding a Geant4 solid, logical, and physical volume.
std::shared_ptr< GLogger > log
std::string getDescription() const
std::string getCopyOf() const
std::string getParameters() const
std::string getG4Name() const
std::string getSystem() const
#define UNINITIALIZEDSTRINGQUANTITY
vector< string > getStringVectorFromStringWithDelimiter(const string &input, const string &x)