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 G4String g4filename = fileName;
57 std::string extension =
61 if (extension ==
"ply" || extension ==
"stl") {
62 auto mesh = CADMesh::TessellatedMesh::From(g4filename,
63 CADMesh::File::ASSIMP());
70 if (!pars.empty() && pars !=
"NULL") {
71 try { scale = std::stod(pars); }
72 catch (
const std::exception&) {
73 log->
warning(
"G4CadSystemFactory: volume <", g4name,
74 "> has a non-numeric scale <", pars,
">; using 1.0");
80 mesh->SetScale(CLHEP::mm * scale);
83 mesh->SetReverse(
false);
85 thisG4Volume->setSolid(mesh->GetSolid(),
log);
86 return thisG4Volume->getSolid();
90 log->
warning(
"G4CadSystemFactory: file <", fileName,
91 "> 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
void warning(Args &&... args) const
std::string getDescription() const
std::string getParameters() const
std::string getG4Name() const
vector< string > getStringVectorFromStringWithDelimiter(const string &input, const string &x)