Import Geant4 4.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:39:52 +02:00
parent 921d3b1cda
commit 330b82b769
4524 changed files with 178689 additions and 43575 deletions
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4HepRepFile.cc,v 1.1 2001/11/06 11:48:07 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4HepRepFile.cc,v 1.4 2002/02/02 04:00:22 perl Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// Joseph Perl 1 October 2001
@@ -21,13 +21,13 @@
// ********************************************************************
//
//
// $Id: G4HepRepFileSceneHandler.cc,v 1.3 2001/11/19 15:07:28 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4HepRepFileSceneHandler.cc,v 1.7 2002/02/03 22:22:58 perl Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
//
// John Allison 5th April 2001
// A base class for a scene handler to dump geometry hierarchy.
// Based on a provisional G4HepRepFileGraphicsScene (was in modeling).
// Joseph Perl 27th January 2002
// A base class for a scene handler to export geometry and trajectories
// to the HepRep xml file format.
#include "G4HepRepFileSceneHandler.hh"
#include "G4HepRepFile.hh"
@@ -65,12 +65,39 @@ G4HepRepFileSceneHandler::G4HepRepFileSceneHandler(G4VGraphicsSystem& system,
fSceneCount++;
hepRepXMLWriter = ((G4HepRepFile*)(&system))->GetHepRepXMLWriter();
G4cout << " From scene handler const: opening file, G4HepRepFile.xml"
<< G4endl;
fileCounter = 0;
}
G4HepRepFileSceneHandler::~G4HepRepFileSceneHandler() {}
void G4HepRepFileSceneHandler::EstablishSpecials
(G4PhysicalVolumeModel& pvModel) {
pvModel.DefinePointersToWorkingSpace (&fCurrentDepth,
&fpCurrentPV,
&fpCurrentLV);
}
void G4HepRepFileSceneHandler::BeginModeling() {
G4VSceneHandler::BeginModeling(); // Required: see G4VSceneHandler.hh.
// Force culling off...
if (fpModel) {
fpOriginalMP = fpModel->GetModelingParameters();
if (fpOriginalMP) {
fpNonCullingMP = new G4ModelingParameters(*fpOriginalMP);
fpNonCullingMP->SetCulling(false);
fpModel->SetModelingParameters(fpNonCullingMP);
}
}
}
void G4HepRepFileSceneHandler::EndModeling() {
if (fpModel && fpOriginalMP) {
fpModel->SetModelingParameters(fpOriginalMP);
delete fpNonCullingMP;
}
G4VSceneHandler::EndModeling(); // Required: see G4VSceneHandler.hh.
}
#ifdef G4HEPREPFILEDEBUG
void G4HepRepFileSceneHandler::PrintThings() {
G4cout <<
@@ -97,7 +124,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Box& box) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(box); // Invoke default action.
}
@@ -109,7 +135,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Cons& cons) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(cons); // Invoke default action.
}
@@ -121,7 +146,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Tubs& tubs) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(tubs); // Invoke default action.
}
@@ -133,7 +157,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Trd& trd) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(trd); // Invoke default action.
}
@@ -145,7 +168,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Trap& trap) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(trap); // Invoke default action.
}
@@ -157,7 +179,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Sphere& sphere) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(sphere); // Invoke default action.
}
@@ -169,7 +190,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Para& para) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(para); // Invoke default action.
}
@@ -181,7 +201,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Torus& torus) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(torus); // Invoke default action.
}
@@ -193,7 +212,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Polycone& polycone) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(polycone); // Invoke default action.
}
@@ -205,7 +223,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4Polyhedra& polyhedra) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(polyhedra); // Invoke default action.
}
@@ -217,7 +234,6 @@ void G4HepRepFileSceneHandler::AddThis(const G4VSolid& solid) {
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(solid); // Invoke default action.
}
@@ -231,11 +247,7 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyline& polyline) {
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Line");
G4Colour color = GetColour(polyline);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
AddHepRepInstance("Line",polyline);
hepRepXMLWriter->addPrimitive();
@@ -254,15 +266,10 @@ void G4HepRepFileSceneHandler::AddPrimitive (const G4Polymarker& line) {
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Point");
AddHepRepInstance("Point",line);
// FIXME: should be taken from G4
hepRepXMLWriter->addAttValue("MarkName", "Square");
hepRepXMLWriter->addAttValue("MarkSize", 5);
G4Colour color = GetColour(line);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
hepRepXMLWriter->addAttValue("MarkName", "Dot");
hepRepXMLWriter->addAttValue("MarkSize", 4);
hepRepXMLWriter->addPrimitive();
@@ -292,18 +299,13 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Circle& circle) {
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Point");
AddHepRepInstance("Point",circle);
hepRepXMLWriter->addAttValue("MarkName", "Dot");
G4Colour color = GetColour(circle);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
hepRepXMLWriter->addAttValue("MarkSize", 4);
hepRepXMLWriter->addPrimitive();
G4double radius = circle.GetWorldSize();
hepRepXMLWriter->addAttValue("MarkSize", radius);
G4Point3D center = (*fpObjectTransformation) * circle.GetPosition();
hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
}
@@ -317,18 +319,13 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Square& square) {
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Point");
hepRepXMLWriter->addAttValue("MarkName", "Square");
AddHepRepInstance("Point",square);
G4Colour color = GetColour(square);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
hepRepXMLWriter->addAttValue("MarkName", "Square");
hepRepXMLWriter->addAttValue("MarkSize", 4);
hepRepXMLWriter->addPrimitive();
G4double size = square.GetWorldSize();
hepRepXMLWriter->addAttValue("MarkSize", size);
G4Point3D center = (*fpObjectTransformation) * square.GetPosition();
hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
}
@@ -340,26 +337,14 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) {
<< G4endl;
PrintThings();
#endif
AddHepRepInstance("Polygon",polyhedron);
if(polyhedron.GetNoFacets()==0)return;
G4Normal3D surfaceNormal;
G4Point3D vertex;
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Polygon");
G4Colour color = GetColour(polyhedron);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
// Additional attributes.
hepRepXMLWriter->addAttValue("LVol", fpCurrentLV->GetName());
hepRepXMLWriter->addAttValue("Solid", fpCurrentLV->GetSolid()->GetName());
hepRepXMLWriter->addAttValue("EType", fpCurrentLV->GetSolid()->GetEntityType());
hepRepXMLWriter->addAttValue("Material", fpCurrentLV->GetMaterial()->GetName());
hepRepXMLWriter->addAttValue("Density", fpCurrentLV->GetMaterial()->GetDensity());
hepRepXMLWriter->addAttValue("State", fpCurrentLV->GetMaterial()->GetState());
hepRepXMLWriter->addAttValue("Radlen", fpCurrentLV->GetMaterial()->GetRadlen());
G4bool notLastFace;
do {
hepRepXMLWriter->addPrimitive();
@@ -385,13 +370,112 @@ void G4HepRepFileSceneHandler::AddPrimitive(const G4NURBS& nurbs) {
G4cout << "G4HepRepFileSceneHandler::AddPrimitive G4NURBS : not implemented. " << G4endl;
}
void G4HepRepFileSceneHandler::EstablishSpecials
(G4PhysicalVolumeModel& pvModel) {
pvModel.DefinePointersToWorkingSpace(&fCurrentDepth,
&fpCurrentPV,
&fpCurrentLV);
}
HepRepXMLWriter *G4HepRepFileSceneHandler::GetHepRepXMLWriter() {
return hepRepXMLWriter;
}
void G4HepRepFileSceneHandler::AddHepRepInstance(const char* primName,
const G4Visible visible) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddHepRepInstance called."
<< G4endl;
#endif
if (!hepRepXMLWriter->isOpen) {
char* newFileSpec;
newFileSpec = new char [100];
int length;
length = sprintf (newFileSpec, "%s%d%s","G4Data",fileCounter,".heprep");
hepRepXMLWriter->open(newFileSpec);
fileCounter++;
hepRepXMLWriter->addAttDef("LVol", "Logical Volume", "Physics","");
hepRepXMLWriter->addAttDef("Solid", "Solid Name", "Physics","");
hepRepXMLWriter->addAttDef("EType", "Entity Type", "Physics","");
hepRepXMLWriter->addAttDef("Material", "Material Name", "Physics","");
hepRepXMLWriter->addAttDef("Density", "Material Density", "Physics","");
hepRepXMLWriter->addAttDef("State", "Material State", "Physics","");
hepRepXMLWriter->addAttDef("Radlen", "Material Radiation Length", "Physics","");
}
// Handle Type declaration for Event Data.
// Should be able to just test on fReadyForTransients, but this seems to
// be falsely false if no geometry has yet been drawn.
// So I test on both !fpCurrentPV (means no geometry has yet been drawn)
// and fReadyForTransients.
if (!fpCurrentPV || fReadyForTransients) {
if (strcmp("Event Data",hepRepXMLWriter->prevTypeName[0])!=0) {
hepRepXMLWriter->addType("Event Data",0);
hepRepXMLWriter->addInstance();
}
if (strcmp("Line",primName)==0)
hepRepXMLWriter->addType("Trajectories",1);
else {
if (strcmp(hepRepXMLWriter->prevTypeName[1],"Trajectories")==0)
hepRepXMLWriter->addType("Trajectory Points",2);
else
hepRepXMLWriter->addType("Trajectory Points",1);
}
hepRepXMLWriter->addInstance();
// Handle Type declaration for Detector Geometry,
// replacing G4's top geometry level name "worldPhysical" with the
// name "Detector Geometry".
} else {
if (strcmp("Detector Geometry",hepRepXMLWriter->prevTypeName[0])!=0) {
hepRepXMLWriter->addType("Detector Geometry",0);
hepRepXMLWriter->addInstance();
}
// Re-insert any layers of the hierarchy that were removed by G4's culling process.
while (hepRepXMLWriter->typeDepth < (fCurrentDepth-1)) {
hepRepXMLWriter->addType("G4 Culled Layer", hepRepXMLWriter->typeDepth + 1);
hepRepXMLWriter->addInstance();
}
if (fCurrentDepth!=0) {
// Add the HepRepType for the current volume.
hepRepXMLWriter->addType(fpCurrentPV->GetName(),fCurrentDepth);
hepRepXMLWriter->addInstance();
}
// Additional attributes.
hepRepXMLWriter->addAttValue("LVol", fpCurrentLV->GetName());
hepRepXMLWriter->addAttValue("Solid", fpCurrentLV->GetSolid()->GetName());
hepRepXMLWriter->addAttValue("EType", fpCurrentLV->GetSolid()->GetEntityType());
hepRepXMLWriter->addAttValue("Material", fpCurrentLV->GetMaterial()->GetName());
hepRepXMLWriter->addAttValue("Density", fpCurrentLV->GetMaterial()->GetDensity());
hepRepXMLWriter->addAttValue("State", fpCurrentLV->GetMaterial()->GetState());
hepRepXMLWriter->addAttValue("Radlen", fpCurrentLV->GetMaterial()->GetRadlen());
}
hepRepXMLWriter->addAttValue("DrawAs",primName);
hepRepXMLWriter->addAttValue("Layer",hepRepXMLWriter->typeDepth);
// Handle color attribute, avoiding drawing anything black on black.
G4Colour colour = GetColour(visible);
float redness = colour.GetRed();
float greenness = colour.GetGreen();
float blueness = colour.GetBlue();
if (redness==0. && greenness==0. && blueness==0.) {
redness = 1.;
greenness = 1.;
blueness = 1.;
}
if (strcmp(primName,"Point")==0)
hepRepXMLWriter->addAttValue("MarkColor",redness,greenness,blueness);
else
hepRepXMLWriter->addAttValue("LineColor",redness,greenness,blueness);
// Handle visibility attribute.
const G4VisAttributes* visAtts = visible.GetVisAttributes();
if (visAtts && (visAtts->IsVisible()==0))
hepRepXMLWriter->addAttValue("Visibility",false);
else
hepRepXMLWriter->addAttValue("Visibility",true);
}
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4HepRepFileViewer.cc,v 1.3 2001/11/19 15:07:28 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
// $Id: G4HepRepFileViewer.cc,v 1.6 2002/02/02 04:00:27 perl Exp $
// GEANT4 tag $Name: geant4-04-01 $
#include "G4HepRepFileViewer.hh"
@@ -39,7 +39,6 @@
G4HepRepFileViewer::G4HepRepFileViewer
(G4VSceneHandler& sceneHandler, const G4String& name):
G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name) {
hepRepXMLWriter = ((G4HepRepFileSceneHandler*)(&sceneHandler))->GetHepRepXMLWriter();
}
@@ -47,16 +46,8 @@ G4HepRepFileViewer::~G4HepRepFileViewer() {}
void G4HepRepFileViewer::SetView() {
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::SetView() called." << G4endl;
G4cout << "G4HepRepFileViewer::SetView() called.=" << G4endl;
#endif
hepRepXMLWriter->open("G4HepRepFile.xml");
hepRepXMLWriter->addAttDef("LVol", "Logical Volume", "Physics","");
hepRepXMLWriter->addAttDef("Solid", "Solid Name", "Physics","");
hepRepXMLWriter->addAttDef("EType", "Entity Type", "Physics","");
hepRepXMLWriter->addAttDef("Material", "Material Name", "Physics","");
hepRepXMLWriter->addAttDef("Density", "Material Density", "Physics","");
hepRepXMLWriter->addAttDef("State", "Material State", "Physics","");
hepRepXMLWriter->addAttDef("Radlen", "Material Radiation Length", "Physics","");
}
void G4HepRepFileViewer::ClearView() {
@@ -75,12 +66,9 @@ void G4HepRepFileViewer::DrawView() {
void G4HepRepFileViewer::ShowView () {
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::ShowView" << G4endl;
G4cout << "G4HepRepFileViewer::ShowView" << G4endl;
#endif
G4VViewer::ShowView();
hepRepXMLWriter->close();
G4VViewer::ShowView();
hepRepXMLWriter->close();
}
@@ -22,7 +22,7 @@
//
//--------------------------------------------------------------------------
// File and Version Information:
// $Id: HepRepXMLWriter.cc,v 1.3 2001/12/13 12:04:26 gunter Exp $
// $Id: HepRepXMLWriter.cc,v 1.8 2002/02/05 19:52:01 perl Exp $
//
// Description:
// Create a HepRep XML File (HepRep version 1).
@@ -43,16 +43,69 @@
HepRepXMLWriter::HepRepXMLWriter()
{
isOpen = false;
init();
}
void HepRepXMLWriter::addType(const char* name)
void HepRepXMLWriter::init()
{
typeDepth = -1;
int i = -1;
while (i++<49) {
prevTypeName[i] = new char[1];
strcpy(prevTypeName[i],"");
inType[i] = false;
inInstance[i] = false;
}
inPrimitive = false;
inPoint = false;
}
void HepRepXMLWriter::addType(const char* name,int newTypeDepth)
{
if (fout.good())
{
endType();
fout << " <heprep:type version=\"null\" name=\"" << name << "\">"
// Flatten structure if it exceeds maximum allowed typeDepth of 49.
if (newTypeDepth > 49)
newTypeDepth = 49;
if (newTypeDepth < 0)
newTypeDepth = 0;
// Insert any layers that are missing from the hierarchy (protects against
// callers that skip from, say, layer 1 to layer 3 with no layer 2).
while (typeDepth < (newTypeDepth-1)) {
addType("Layer Inserted by HepRepXMLWriter", typeDepth + 1);
addInstance();
}
// If moving closer to the root, close previously open types.
while (newTypeDepth<typeDepth)
endType();
// Close any remaining primitives of the current instance.
endPrimitive();
// If this is a new type name for the current depth, declare the
// new Type. Otherwise, it is just another Instance of the current Type.
if (strcmp(name,prevTypeName[newTypeDepth])!=0)
{
if (inType[newTypeDepth])
endType();
prevTypeName[newTypeDepth] = new char[strlen(name)+1];
strcpy(prevTypeName[newTypeDepth],name);
inType[newTypeDepth] = true;
indent();
fout << "<heprep:type version=\"null\" name=\"" << name << "\">"
<< G4endl;
inType = true;
typeDepth = newTypeDepth;
}
} else {
G4cout << "HepRepXMLWriter:addType No file is currently open." << G4endl;
}
@@ -62,13 +115,15 @@ void HepRepXMLWriter::addInstance()
{
if (fout.good())
{
if (inType)
if (inType[typeDepth])
{
endInstance();
fout << " <heprep:instance>" << G4endl;
inInstance = true;
inInstance[typeDepth] = true;
indent();
fout << "<heprep:instance>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addInstance No HepRep Type is currently open"
G4cout <<
"HepRepXMLWriter:addInstance No HepRep Type is currently open"
<< G4endl;
}
} else {
@@ -81,11 +136,12 @@ void HepRepXMLWriter::addPrimitive()
{
if (fout.good())
{
if (inInstance)
if (inInstance[typeDepth])
{
endPrimitive();
fout << " <heprep:primitive>" << G4endl;
inPrimitive = true;
indent();
fout << "<heprep:primitive>" << G4endl;
} else {
G4cout <<
"HepRepXMLWriter:addPrimitive No HepRep Instance is currently open"
@@ -104,8 +160,9 @@ void HepRepXMLWriter::addPoint(double x, double y, double z)
if (inPrimitive)
{
endPoint();
fout << " <heprep:point x=\"" << x << "\" y=\"" << y << "\" z=\"" << z << "\">" << G4endl;
inPoint = true;
indent();
fout << "<heprep:point x=\"" << x << "\" y=\"" << y << "\" z=\"" << z << "\">" << G4endl;
} else {
G4cout <<
"HepRepXMLWriter:addPoint No HepRep Primitive is currently open"
@@ -124,9 +181,9 @@ void HepRepXMLWriter::addAttDef(const char* name,
if (fout.good())
{
indent();
fout << " <heprep:attdef extra=\"" << extra << "\" name=\"" << name << "\" type=\"" << type << "\"" << G4endl;
fout << "<heprep:attdef extra=\"" << extra << "\" name=\"" << name << "\" type=\"" << type << "\"" << G4endl;
indent();
fout << " desc=\"" << desc << "\"/>" << G4endl;
fout << " desc=\"" << desc << "\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttDef No file is currently open" << G4endl;
}
@@ -183,7 +240,10 @@ void HepRepXMLWriter::addAttValue (const char* name,
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
if (value)
fout << " value=\"True\"/>" << G4endl;
else
fout << " value=\"False\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttValue No file is currently open" << G4endl;
}
@@ -196,10 +256,10 @@ void HepRepXMLWriter::addAttValue (const char* name,
{
if (fout.good())
{
indent();
int redness = int(value1*255.);
int greenness = int(value2*255.);
int blueness = int(value3*255.);
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
indent();
fout << " value=\"" << redness << "," << greenness << "," << blueness << "\"/>" << G4endl;
@@ -208,57 +268,66 @@ void HepRepXMLWriter::addAttValue (const char* name,
}
}
void HepRepXMLWriter::open(const char* filespec)
void HepRepXMLWriter::open(const char* fileSpec)
{
if (fout.good())
fout.close();
fout.open(filespec);
if (fout.good())
{
if (isOpen)
close();
fout.open(fileSpec);
if (fout.good()) {
fout << "<?xml version=\"1.0\" ?>" << G4endl;
fout << "<heprep:heprep xmlns:heprep=\"http://www.freehep.org/HepRep\"" << G4endl;
fout << " xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xsi:schemaLocation=\"HepRep.xsd\">" << G4endl;
inType = false;
inInstance = false;
inPrimitive = false;
inPoint = false;
isOpen = true;
init();
} else {
G4cout << "HepRepXMLWriter:open Unable to write to file " << filespec << G4endl;
G4cout << "HepRepXMLWriter:open Unable to write to file " << fileSpec << G4endl;
}
}
void HepRepXMLWriter::close()
{
if (fout.good())
{
endType();
// Close any remaining open Types
endTypes();
if (fout.good()) {
fout << "</heprep:heprep>" << G4endl;
fout.close( );
isOpen = false;
} else {
G4cout << "HepRepXMLWriter:close No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::endTypes()
{
// Close any remaining open Types
while(typeDepth>-1)
endType();
}
void HepRepXMLWriter::endType()
{
if (inType)
{
endInstance();
fout << " </heprep:type>" << G4endl;
inType = false;
}
endInstance();
indent();
fout << "</heprep:type>" << G4endl;
inType[typeDepth] = false;
delete [] prevTypeName[typeDepth];
prevTypeName[typeDepth] = new char[1];
strcpy(prevTypeName[typeDepth],"");
typeDepth--;
}
void HepRepXMLWriter::endInstance()
{
if (inInstance)
if (inInstance[typeDepth])
{
endPrimitive();
fout << " </heprep:instance>" << G4endl;
inInstance = false;
indent();
fout << "</heprep:instance>" << G4endl;
inInstance[typeDepth] = false;
}
}
@@ -267,7 +336,8 @@ void HepRepXMLWriter::endPrimitive()
if (inPrimitive)
{
endPoint();
fout << " </heprep:primitive>" << G4endl;
indent();
fout << "</heprep:primitive>" << G4endl;
inPrimitive = false;
}
}
@@ -276,7 +346,8 @@ void HepRepXMLWriter::endPoint()
{
if (inPoint)
{
fout << " </heprep:point>" << G4endl;
indent();
fout << "</heprep:point>" << G4endl;
inPoint = false;
}
}
@@ -285,10 +356,14 @@ void HepRepXMLWriter::indent()
{
if (fout.good())
{
if (inType)
fout << " ";
if (inInstance)
int i = 0;
while (inType[i] && i<12) {
fout << " ";
if (inInstance[i])
fout << " ";
i++;
}
if (inPrimitive)
fout << " ";
if (inPoint)