8 #include "G4TransportationManager.hh"
9 #include "G4VPhysicalVolume.hh"
10 #include "G4LogicalVolume.hh"
11 #include "G4VisAttributes.hh"
13 #include "G4Polyhedron.hh"
14 #include "G4RotationMatrix.hh"
15 #include "G4ThreeVector.hh"
16 #include "G4RotationMatrix.hh"
17 #include "G4Point3D.hh"
18 #include "G4SystemOfUnits.hh"
26 _out.open(filename.c_str());
36 processTopVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume());
52 writeLine(
"DEF " + pv->GetName() +
" Transform {");
58 const G4VisAttributes* vis = pv->GetLogicalVolume()->GetVisAttributes();
60 if (vis && !vis->IsVisible())
63 writeLine(
"DEF " + pv->GetName() +
" Shape {");
71 G4LogicalVolume* lv = pv->GetLogicalVolume();
74 bool showDaughters =
true;
75 if (vis && vis->IsDaughtersInvisible())
76 showDaughters =
false;
78 for (
int i = 0, ndau = lv->GetNoDaughters(); i < ndau; i++) {
87 const G4ThreeVector& pos = pv->GetTranslation();
89 ss <<
"translation " << pos.x() / m <<
" " << pos.y() / m <<
" " << pos.z() / m;
93 const G4RotationMatrix* rot = pv->GetRotation();
94 CLHEP::Hep3Vector axis(0, 0, 0);
97 rot->getAngleAxis(angle, axis);
98 std::stringstream ss2;
99 ss2 <<
"rotation " << axis.x() <<
" " << axis.y() <<
" " << axis.z() <<
" " << -angle;
108 const G4VisAttributes* vis = pv->GetLogicalVolume()->GetVisAttributes();
112 const G4Colour& col = vis->GetColour();
121 std::stringstream ss;
122 ss << r <<
" " << g <<
" " << b;
132 if (solid->GetEntityType() ==
"G4Box") {
142 std::stringstream ss;
143 ss <<
"size " << box->GetXHalfLength() * 2 / m <<
" " << box->GetYHalfLength() * 2 / m <<
" " << box->GetZHalfLength() * 2 / m;
160 for (i = 1, j = polyhedron->GetNoVertices(); j; j--, i++) {
161 G4Point3D point = polyhedron->GetVertex(i);
162 std::stringstream ss;
163 ss << point.x() / m <<
" " << point.y() / m <<
" " << point.z() / m;
176 for (f = polyhedron->GetNoFacets(); f; f--) {
179 int index = -1, edgeFlag = 1;
180 std::stringstream ss;
182 notLastEdge = polyhedron->GetNextVertexIndex(index, edgeFlag);
183 ss << index - 1 <<
", ";
184 }
while (notLastEdge);
void processBox(G4Box *box)
void processSolid(G4VSolid *solid)
VRML2Writer(const std::string &filename)
void processPolyhedron(G4Polyhedron *poly)
void processVisualization(G4VPhysicalVolume *volume)
void writeLine(const std::string &line)
void processTopVolume(G4VPhysicalVolume *volume)
void processPhysicalVolume(G4VPhysicalVolume *volume)