46void G4STRead::TessellatedRead(
const std::string& line)
48 if(tessellatedList.size() > 0)
50 tessellatedList.back()->SetSolidClosed(
true);
54 std::istringstream stream(line.substr(2));
60 volumeMap[tessellated] =
61 new G4LogicalVolume(tessellated, solid_material, name +
"_LV", 0, 0, 0);
62 tessellatedList.push_back(tessellated);
70void G4STRead::FacetRead(
const std::string& line)
72 if(tessellatedList.size() == 0)
75 "A solid must be defined before defining a facet!");
84 std::istringstream stream(line.substr(4));
85 stream >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3;
90 else if(line[2] ==
'4')
97 std::istringstream stream(line.substr(4));
98 stream >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3 >> x4 >> y4 >>
107 "Number of vertices per facet should be either 3 or 4!");
112void G4STRead::PhysvolRead(
const std::string& line)
122 std::istringstream stream(line.substr(2));
123 stream >> level >>
name >> r1 >> r2 >> r3 >> n1 >> r4 >> r5 >> r6 >> n2 >>
124 r7 >> r8 >> r9 >> n3 >> pX >> pY >> pZ >> n4 >> n5;
125 std::string::size_type idx =
name.rfind(
"_");
126 if(idx != std::string::npos)
133 "Invalid input stream!");
141 for(std::size_t i = 0; i < tessellatedList.size(); ++i)
143 if(tessellatedList[i]->GetName() ==
G4String(name))
145 tessellated = tessellatedList[i];
150 if(tessellated ==
nullptr)
152 G4String error_msg =
"Referenced solid '" +
name +
"' not found!";
156 if(volumeMap.find(tessellated) == volumeMap.cend())
159 "' is not associated with a logical volume!";
169 name +
"_PV", world_volume, 0, 0);
183 if(world_extent.
x() < std::fabs(minx))
185 world_extent.
setX(std::fabs(minx));
187 if(world_extent.
y() < std::fabs(miny))
189 world_extent.
setY(std::fabs(miny));
191 if(world_extent.
z() < std::fabs(minz))
193 world_extent.
setZ(std::fabs(minz));
195 if(world_extent.
x() < std::fabs(maxx))
197 world_extent.
setX(std::fabs(maxx));
199 if(world_extent.
y() < std::fabs(maxy))
201 world_extent.
setY(std::fabs(maxy));
203 if(world_extent.
z() < std::fabs(maxz))
205 world_extent.
setZ(std::fabs(maxz));
210void G4STRead::ReadGeom(
const G4String& name)
215 std::ifstream GeomFile(name);
223 tessellatedList.clear();
227 while(getline(GeomFile, line))
231 TessellatedRead(line);
233 else if(line[0] ==
'p')
239 if(tessellatedList.size() > 0)
241 tessellatedList.back()->SetSolidClosed(
true);
248void G4STRead::ReadTree(
const G4String& name)
253 std::ifstream TreeFile(name);
263 while(getline(TreeFile, line))
279 if(mediumMaterial ==
nullptr)
282 "Pointer to medium material is not valid!");
284 if(solidMaterial ==
nullptr)
287 "Pointer to solid material is not valid!");
290 solid_material = solidMaterial;
292 world_box =
new G4Box(
"TessellatedWorldBox", kInfinity, kInfinity, kInfinity);
295 "TessellatedWorldLV", 0, 0, 0);
298 ReadGeom(name +
".geom");
299 ReadTree(name +
".tree");
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
G4double GetYHalfLength() const
G4double GetZHalfLength() const
void SetZHalfLength(G4double dz)
G4double GetXHalfLength() const
void SetYHalfLength(G4double dy)
void SetXHalfLength(G4double dx)
G4LogicalVolume * Read(const G4String &, G4Material *mediumMaterial, G4Material *solidMaterial)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const override
const char * name(G4int ptype)