48void 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);
69void 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!");
113void 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)); }
198void G4STRead::ReadGeom(
const G4String& name)
200 G4cout <<
"G4STRead: Reading '" << name <<
"'..." <<
G4endl;
202 std::ifstream GeomFile(name);
206 G4String error_msg =
"Cannot open file: " + 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;
229void G4STRead::ReadTree(
const G4String& name)
231 G4cout <<
"G4STRead: Reading '" << name <<
"'..." <<
G4endl;
233 std::ifstream TreeFile(name);
237 G4String error_msg =
"Cannot open file: " + 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;
269 world_box =
new G4Box(
"TessellatedWorldBox",kInfinity,kInfinity,kInfinity);
272 "TessellatedWorldLV", 0, 0, 0);
275 ReadGeom(name+
".geom");
276 ReadTree(name+
".tree");
CLHEP::Hep3Vector G4ThreeVector
G4DLLIMPORT 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)
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)