48 void G4STRead::TessellatedRead(
const std::string& line)
50 if (tessellatedList.size()>0)
52 tessellatedList.back()->SetSolidClosed(
true);
56 std::istringstream stream(line.substr(2));
62 volumeMap[tessellated] =
64 tessellatedList.push_back(tessellated);
69 void G4STRead::FacetRead(
const std::string& line)
71 if (tessellatedList.size()==0)
74 "A solid must be defined before defining a facet!");
83 std::istringstream stream(line.substr(4));
84 stream >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> x3 >> y3 >> z3;
85 tessellatedList.back()->
90 else if (line[2]==
'4')
97 std::istringstream stream(line.substr(4));
98 stream >> x1 >> y1 >> z1 >> x2 >> y2 >> z2
99 >> x3 >> y3 >> z3 >> x4 >> y4 >> z4;
100 tessellatedList.back()->
109 "Number of vertices per facet should be either 3 or 4!");
113 void G4STRead::PhysvolRead(
const std::string& line)
123 std::istringstream stream(line.substr(2));
124 stream >> level >> name >> r1 >> r2 >> r3 >> n1 >> r4 >> r5 >> r6
125 >> n2 >> r7 >> r8 >> r9 >> n3 >> pX >> pY >> pZ >> n4 >> n5;
126 std::string::size_type idx = name.rfind(
"_");
127 if (idx!=std::string::npos)
133 G4Exception(
"G4STRead::PhysvolRead()",
"ReadError",
138 G4cout <<
"G4STRead: Placing tessellated solid: " << name <<
G4endl;
142 for (
size_t i=0; i<tessellatedList.size(); i++)
144 if (tessellatedList[i]->GetName() ==
G4String(name))
146 tessellated = tessellatedList[i];
151 if (tessellated == 0)
153 G4String error_msg =
"Referenced solid '" + name +
"' not found!";
154 G4Exception(
"G4STRead::PhysvolRead()",
"ReadError",
157 if (volumeMap.find(tessellated) == volumeMap.end())
159 G4String error_msg =
"Referenced solid '" + name
160 +
"' is not associated with a logical volume!";
161 G4Exception(
"G4STRead::PhysvolRead()",
"InvalidSetup",
170 volumeMap[tessellated], name+
"_PV",
world_volume, 0, 0);
184 if (world_extent.
x() < std::fabs(minx))
185 { world_extent.
setX(std::fabs(minx)); }
186 if (world_extent.
y() < std::fabs(miny))
187 { world_extent.
setY(std::fabs(miny)); }
188 if (world_extent.
z() < std::fabs(minz))
189 { world_extent.
setZ(std::fabs(minz)); }
190 if (world_extent.
x() < std::fabs(maxx))
191 { world_extent.
setX(std::fabs(maxx)); }
192 if (world_extent.
y() < std::fabs(maxy))
193 { world_extent.
setY(std::fabs(maxy)); }
194 if (world_extent.
z() < std::fabs(maxz))
195 { world_extent.
setZ(std::fabs(maxz)); }
198 void G4STRead::ReadGeom(
const G4String& name)
200 G4cout <<
"G4STRead: Reading '" << name <<
"'..." <<
G4endl;
202 std::ifstream GeomFile(name);
211 tessellatedList.clear();
215 while (getline(GeomFile,line))
217 if (line[0] ==
'f') { TessellatedRead(line); }
else
218 if (line[0] ==
'p') { FacetRead(line); }
221 if (tessellatedList.size()>0)
223 tessellatedList.back()->SetSolidClosed(
true);
226 G4cout <<
"G4STRead: Reading '" << name <<
"' done." <<
G4endl;
229 void G4STRead::ReadTree(
const G4String& name)
231 G4cout <<
"G4STRead: Reading '" << name <<
"'..." <<
G4endl;
233 std::ifstream TreeFile(name);
244 while (getline(TreeFile,line))
246 if (line[0] ==
'g') { PhysvolRead(line); }
249 G4cout <<
"G4STRead: Reading '" << name <<
"' done." <<
G4endl;
256 if (mediumMaterial == 0)
259 "Pointer to medium material is not valid!");
261 if (solidMaterial == 0)
264 "Pointer to solid material is not valid!");
267 solid_material = solidMaterial;
272 "TessellatedWorldLV", 0, 0, 0);
275 ReadGeom(name+
".geom");
276 ReadTree(name+
".tree");
G4double GetXHalfLength() const
void SetZHalfLength(G4double dz)
G4LogicalVolume * Read(const G4String &, G4Material *mediumMaterial, G4Material *solidMaterial)
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
G4double GetZHalfLength() const
G4GLOB_DLL std::ostream G4cout
G4double GetYHalfLength() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetYHalfLength(G4double dy)
void SetXHalfLength(G4double dx)
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
static const G4double pos