Import Geant4 4.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:18:25 +02:00
parent 36c080dca6
commit 921d3b1cda
3990 changed files with 185376 additions and 82884 deletions
+25
View File
@@ -0,0 +1,25 @@
# $Id: GNUmakefile,v 1.3 2001/11/08 21:50:51 perl Exp $
name := G4visHepRep
ifndef G4INSTALL
G4INSTALL = ../../..
endif
include $(G4INSTALL)/config/architecture.gmk
include $(G4INSTALL)/config/G4VIS_BUILD.gmk
include $(G4INSTALL)/config/interactivity.gmk
CPPFLAGS += -I$(G4BASE)/visualization/management/include
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
CPPFLAGS += -I$(G4BASE)/global/management/include
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
CPPFLAGS += -I$(G4BASE)/graphics_reps/include
CPPFLAGS += -I$(G4BASE)/intercoms/include
CPPFLAGS += -I$(G4BASE)/geometry/management/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
CPPFLAGS += -I$(G4BASE)/geometry/volumes/include
CPPFLAGS += -I$(G4BASE)/geometry/solids/specific/include
CPPFLAGS += -I$(G4BASE)/materials/include
include $(G4INSTALL)/config/common.gmk
+53
View File
@@ -0,0 +1,53 @@
$Id: History,v 1.9 2001/11/19 15:08:37 johna Exp $
-------------------------------------------------------------------
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
History file for visualization/HepRep sub-category
---------------------------------------------------------------------------
19th November 2001 John Allison (vis-V03-02-19)
- Added G4HEPREPFILEDEBUG to control debug code.
- Changed <fstream.h> to "g4std/fstream".
- Changed cout to G4cout, endl to G4endl.
- Changed G4HepRep.xml to G4HepRepFile.xml in hepRepXMLWriter->open("..."");
8th November 2001 Joseph Perl
- HepRep Type names now come from Physical Volume names.
- Added many HepRep Attributes for other volume properties.
6th November 2001 John Allison (HepRep-pure-C++-1st-version)
- Removed HepRep files G4HepRep.hh, G4HepRepSceneHandler.hh,
G4HepRepViewer.hh, G4HepRep.cc, G4HepRepSceneHandler.cc and
G4HepRepViewer.cc (recoverable with tag HepRep-Java-version).
- Added HepRepFile from version of 27th September 2001 Joseph Perl.
First pure C++ version (eliminates need for Java jni or freehep).
Named as HepRepFile rather than HepRep.
- GNUmakefile: removed CPPFLAGS += -DHEPREP and CPPFLAGS += -DDEBUG.
- README: completely re-written for HepRepFile.
6th November 2001 John Allison (HepRep-Java-version)
- Tagged before major revision.
4th September 2001 Joseph Perl
- minor improvements to README.
26th August 2001 Joseph Perl
- handle PolyHedron.getNoFacets()==0 and improve README.
24th August 2001 Joseph Perl (vis-V03-02-13-00)
- First version of HepRep Graphics Driver
+20
View File
@@ -0,0 +1,20 @@
This G4 Graphics Driver creates a HepRep File suitable for viewing
by the WIRED Event Display client. It requires no external packages.
The HepRep graphics format is further described at
http://heprep.freehep.org
The version of HepRep produced by this driver is HepRep Version 1.
Each call to /vis/viewer/update
rewrites the file G4HepRep.xml.
View the file using the WIRED Event Display, available from:
http://www.slac.stanford.edu/BFROOT/www/Computing/Graphics/Wired/
WIRED can read xml files in zipped format as well as unzipped,
so you can save space by applying gzip to the xml file.
This will reduce the file to about five percent of its original size.
Joseph Perl
9 November 2001
@@ -0,0 +1,49 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4HepRepFile.hh,v 1.1 2001/11/06 11:48:04 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// John Allison 5th April 2001
// A graphics system to dump geometry hierarchy.
#ifndef G4HepRepFile_HH
#define G4HepRepFile_HH
#include "G4VGraphicsSystem.hh"
// HepRep
#include "HepRepXMLWriter.hh"
class G4HepRepFile: public G4VGraphicsSystem {
public:
G4HepRepFile();
virtual ~G4HepRepFile();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
HepRepXMLWriter *GetHepRepXMLWriter();
};
#endif
@@ -0,0 +1,134 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4HepRepFileSceneHandler.hh,v 1.4 2001/11/21 16:48:58 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// John Allison 5th April 2001
// A base class for a scene handler to dump geometry hierarchy.
#ifndef G4HepRepFileSCENEHANDLER_HH
#define G4HepRepFileSCENEHANDLER_HH
// #define G4HEPREPFILEDEBUG // Comment this out to suppress debug code.
#include "G4VSceneHandler.hh"
#include "G4Box.hh"
#include "G4Cons.hh"
#include "G4Tubs.hh"
#include "G4Trd.hh"
#include "G4Trap.hh"
#include "G4Sphere.hh"
#include "G4Para.hh"
#include "G4Torus.hh"
#include "G4Polycone.hh"
#include "G4Polyhedra.hh"
// HepRep
#include "HepRepXMLWriter.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4ModelingParameters;
class G4HepRepFileSceneHandler: public G4VSceneHandler {
public:
G4HepRepFileSceneHandler(G4VGraphicsSystem& system,
const G4String& name);
virtual ~G4HepRepFileSceneHandler();
////////////////////////////////////////////////////////////////
// No need to implement these, but if you do...
void AddThis(const G4Box&);
void AddThis(const G4Cons&);
void AddThis(const G4Tubs&);
void AddThis(const G4Trd&);
void AddThis(const G4Trap&);
void AddThis(const G4Sphere&);
void AddThis(const G4Para&);
void AddThis(const G4Torus&);
void AddThis(const G4Polycone&);
void AddThis(const G4Polyhedra&);
void AddThis(const G4VSolid&);
// void PreAddThis(const G4Transform3D& objectTransformation,
// const G4VisAttributes&);
// void PostAddThis();
// Allows G4PhysicalVolumeModel to provide extra information...
void EstablishSpecials(G4PhysicalVolumeModel&);
////////////////////////////////////////////////////////////////
// Required implementation of pure virtual functions...
void AddPrimitive(const G4Polyline&);
void AddPrimitive(const G4Text&);
void AddPrimitive(const G4Circle&);
void AddPrimitive(const G4Square&);
void AddPrimitive(const G4Polyhedron&);
void AddPrimitive(const G4NURBS&);
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
// Further optional AddPrimtive methods. Explicitly invoke base
// class methods if not otherwise defined to avoid warnings about
// hiding of base class methods.
void AddPrimitive(const G4Polymarker&);
void AddPrimitive(const G4Scale& scale) {
G4VSceneHandler::AddPrimitive (scale);
}
////////////////////////////////////////////////////////////////
// Further optional virtual functions...
// void BeginPrimitives(const G4Transform3D& objectTransformation);
// void EndPrimitives();
// void BeginModeling();
// void EndModeling();
////////////////////////////////////////////////////////////////
// Required...
static G4int GetSceneCount() {return fSceneCount;}
HepRepXMLWriter *GetHepRepXMLWriter();
protected:
static G4int fSceneIdCount; // Counter for HepRep scene handlers.
static G4int fSceneCount; // No. of extanct scene handlers.
G4int fCurrentDepth; // Current depth of geom. hierarchy.
G4VPhysicalVolume* fpCurrentPV; // Current physical volume.
G4LogicalVolume* fpCurrentLV; // Current logical volume.
private:
HepRepXMLWriter *hepRepXMLWriter;
#ifdef G4HEPREPFILEDEBUG
void PrintThings();
#endif
};
#endif
@@ -0,0 +1,53 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4HepRepFileViewer.hh,v 1.2 2001/11/19 15:06:52 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// John Allison 5th April 2001
// A base class for a dummy viewer to dump geometry hierarchy.
#ifndef G4HepRepFileVIEWER_HH
#define G4HepRepFileVIEWER_HH
// #define G4HEPREPFILEDEBUG // Comment this out to suppress debug code.
#include "G4VViewer.hh"
#include "HepRepXMLWriter.hh"
class G4HepRepFileViewer: public G4VViewer {
public:
G4HepRepFileViewer(G4VSceneHandler&,const G4String& name);
virtual ~G4HepRepFileViewer();
void SetView();
void ClearView();
void DrawView();
void ShowView();
private:
HepRepXMLWriter *hepRepXMLWriter;
};
#endif
@@ -0,0 +1,96 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//--------------------------------------------------------------------------
// File and Version Information:
// $Id: HepRepXMLWriter.hh,v 1.4 2001/12/13 12:04:25 gunter Exp $
//
// Description:
// Create a HepRep XML File (HepRep version 1).
//
// Environment:
// Software developed for the general High Energy Physics community.
//
// Author :
// J. Perl Original Author
//
// Copyright Information:
// Copyright (C) 2001 Stanford Linear Accelerator Center
//------------------------------------------------------------------------
#ifndef HepRepXMLWriter_hh
#define HepRepXMLWriter_hh
#include "globals.hh"
#include "g4std/fstream"
class HepRepXMLWriter
{
public:
HepRepXMLWriter();
void addType(const char* name);
void addInstance();
void addPrimitive();
void addPoint(double x, double y, double z);
void addAttDef(const char* name,
const char* desc,
const char* type,
const char* extra);
// Four methods to fill attValues
void addAttValue(const char* name,
const char* value);
void addAttValue(const char* name,
double value);
void addAttValue(const char* name,
int value);
void addAttValue(const char* name,
bool value);
void addAttValue(const char* name,
double value1,
double value2,
double value3);
void open(const char* filespec);
void close();
private:
G4std::ofstream fout;
bool inType;
bool inInstance;
bool inPrimitive;
bool inPoint;
void endType();
void endInstance();
void endPrimitive();
void endPoint();
void indent();
};
#endif
@@ -0,0 +1,83 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4HepRepFile.cc,v 1.1 2001/11/06 11:48:07 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// Joseph Perl 1 October 2001
// A graphics system to dump geometry hierarchy to the
// HepRep graphics format (HepRep version 1).
//HepRep
#include "HepRepXMLWriter.hh"
#include "G4HepRepFile.hh"
#include "G4HepRepFileSceneHandler.hh"
#include "G4HepRepFileViewer.hh"
static HepRepXMLWriter* hepRepXMLWriter;
G4HepRepFile::G4HepRepFile():
G4VGraphicsSystem("G4HepRepFile",
"HepRepFile",
"A template graphics driver",
G4VGraphicsSystem::noFunctionality) {
hepRepXMLWriter = new HepRepXMLWriter();
}
G4HepRepFile::~G4HepRepFile() {}
G4VSceneHandler* G4HepRepFile::CreateSceneHandler(const G4String& name) {
G4VSceneHandler* pScene = new G4HepRepFileSceneHandler(*this, name);
G4cout << G4HepRepFileSceneHandler::GetSceneCount()
<< ' ' << fName << " scene handlers extanct." << G4endl;
return pScene;
}
G4VViewer* G4HepRepFile::CreateViewer(G4VSceneHandler& scene,
const G4String& name) {
G4VViewer* pView =
new G4HepRepFileViewer((G4HepRepFileSceneHandler&) scene, name);
if (pView) {
if (pView->GetViewId() < 0) {
G4cout <<
"G4HepRepFile::CreateViewer: ERROR flagged by negative"
" view id in G4HepRepFileViewer creation."
"\n Destroying view and returning null pointer."
<< G4endl;
delete pView;
pView = 0;
}
}
else {
G4cout <<
"G4HepRepFile::CreateViewer: ERROR: null pointer on new G4HepRepFileViewer."
<< G4endl;
}
return pView;
}
HepRepXMLWriter* G4HepRepFile::GetHepRepXMLWriter () {
return hepRepXMLWriter;
}
@@ -0,0 +1,397 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4HepRepFileSceneHandler.cc,v 1.3 2001/11/19 15:07:28 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
//
// John Allison 5th April 2001
// A base class for a scene handler to dump geometry hierarchy.
// Based on a provisional G4HepRepFileGraphicsScene (was in modeling).
#include "G4HepRepFileSceneHandler.hh"
#include "G4HepRepFile.hh"
#include "G4VSolid.hh"
#include "G4PhysicalVolumeModel.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4ModelingParameters.hh"
#include "G4Polymarker.hh"
#include "G4Polyline.hh"
#include "G4Text.hh"
#include "G4Circle.hh"
#include "G4Square.hh"
#include "G4Polyhedron.hh"
#include "G4NURBS.hh"
//HepRep
#include "HepRepXMLWriter.hh"
G4int G4HepRepFileSceneHandler::fSceneIdCount = 0;
// Counter for HepRep scene handlers.
G4int G4HepRepFileSceneHandler::fSceneCount = 0;
// No. of extanct scene handlers.
G4HepRepFileSceneHandler::G4HepRepFileSceneHandler(G4VGraphicsSystem& system,
const G4String& name):
G4VSceneHandler(system, fSceneIdCount++, name),
fCurrentDepth (0),
fpCurrentPV (0),
fpCurrentLV (0)
{
fSceneCount++;
hepRepXMLWriter = ((G4HepRepFile*)(&system))->GetHepRepXMLWriter();
G4cout << " From scene handler const: opening file, G4HepRepFile.xml"
<< G4endl;
}
G4HepRepFileSceneHandler::~G4HepRepFileSceneHandler() {}
#ifdef G4HEPREPFILEDEBUG
void G4HepRepFileSceneHandler::PrintThings() {
G4cout <<
" with transformation "
<< (void*)fpObjectTransformation;
if (fpCurrentPV) {
G4cout <<
"\n current physical volume: "
<< fpCurrentPV->GetName() <<
"\n current logical volume: "
<< fpCurrentLV->GetName() <<
"\n current depth of geometry tree: "
<< fCurrentDepth;
}
G4cout << G4endl;
}
#endif
void G4HepRepFileSceneHandler::AddThis(const G4Box& box) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Box& box) called for "
<< box.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(box); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Cons& cons) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Cons& cons) called for "
<< cons.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(cons); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Tubs& tubs) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Tubs& tubs) called for "
<< tubs.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(tubs); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Trd& trd) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Trd& trd) called for "
<< trd.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(trd); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Trap& trap) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Trap& trap) called for "
<< trap.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(trap); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Sphere& sphere) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Sphere& sphere) called for "
<< sphere.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(sphere); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Para& para) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Para& para) called for "
<< para.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(para); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Torus& torus) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Torus& torus) called for "
<< torus.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(torus); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Polycone& polycone) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Polycone& polycone) called for "
<< polycone.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(polycone); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4Polyhedra& polyhedra) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Polyhedra& polyhedra) called for "
<< polyhedra.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(polyhedra); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddThis(const G4VSolid& solid) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddThis(const G4Solid& solid) called for "
<< solid.GetName()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addType(fpCurrentPV->GetName());
G4VSceneHandler::AddThis(solid); // Invoke default action.
}
void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyline& polyline) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddPrimitive(const G4Polyline& polyline) called:"
"\n polyline: " << polyline
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Line");
G4Colour color = GetColour(polyline);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
hepRepXMLWriter->addPrimitive();
for (size_t i=0; i < polyline.size(); i++) {
G4Point3D vertex = (*fpObjectTransformation) * polyline[i];
hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
}
}
void G4HepRepFileSceneHandler::AddPrimitive (const G4Polymarker& line) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddPrimitive(const G4Polymarker& line) called"
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Point");
// 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->addPrimitive();
for (size_t i=0; i < line.size(); i++) {
G4Point3D vertex = (*fpObjectTransformation) * line[i];
hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
}
}
void G4HepRepFileSceneHandler::AddPrimitive(const G4Text& text) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddPrimitive(const G4Text& text) called:"
"\n text: " << text.GetText()
<< G4endl;
PrintThings();
#endif
G4cout << "G4HepRepFileSceneHandler::AddPrimitive G4Text : not yet implemented. " << G4endl;
}
void G4HepRepFileSceneHandler::AddPrimitive(const G4Circle& circle) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddPrimitive(const G4Circle& circle) called:"
"\n radius: " << circle.GetWorldRadius()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Point");
hepRepXMLWriter->addAttValue("MarkName", "Dot");
G4Colour color = GetColour(circle);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
hepRepXMLWriter->addPrimitive();
G4double radius = circle.GetWorldSize();
hepRepXMLWriter->addAttValue("MarkSize", radius);
G4Point3D center = (*fpObjectTransformation) * circle.GetPosition();
hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
}
void G4HepRepFileSceneHandler::AddPrimitive(const G4Square& square) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddPrimitive(const G4Square& square) called:"
"\n side: " << square.GetWorldRadius()
<< G4endl;
PrintThings();
#endif
hepRepXMLWriter->addInstance();
hepRepXMLWriter->addAttValue("DrawAs","Point");
hepRepXMLWriter->addAttValue("MarkName", "Square");
G4Colour color = GetColour(square);
hepRepXMLWriter->addAttValue("LineColor", color.GetRed(), color.GetGreen(), color.GetBlue());
hepRepXMLWriter->addPrimitive();
G4double size = square.GetWorldSize();
hepRepXMLWriter->addAttValue("MarkSize", size);
G4Point3D center = (*fpObjectTransformation) * square.GetPosition();
hepRepXMLWriter->addPoint(center.x(), center.y(), center.z());
}
void G4HepRepFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddPrimitive(const G4Polyhedron& polyhedron) called."
<< G4endl;
PrintThings();
#endif
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();
notLastFace = polyhedron.GetNextNormal (surfaceNormal);
G4int edgeFlag = 1;
G4bool notLastEdge;
do {
notLastEdge = polyhedron.GetNextVertex (vertex, edgeFlag);
vertex = (*fpObjectTransformation) * vertex;
hepRepXMLWriter->addPoint(vertex.x(), vertex.y(), vertex.z());
} while (notLastEdge);
} while (notLastFace);
}
void G4HepRepFileSceneHandler::AddPrimitive(const G4NURBS& nurbs) {
#ifdef G4HEPREPFILEDEBUG
G4cout <<
"G4HepRepFileSceneHandler::AddPrimitive(const G4NURBS& nurbs) called."
<< G4endl;
PrintThings();
#endif
G4cout << "G4HepRepFileSceneHandler::AddPrimitive G4NURBS : not implemented. " << G4endl;
}
void G4HepRepFileSceneHandler::EstablishSpecials
(G4PhysicalVolumeModel& pvModel) {
pvModel.DefinePointersToWorkingSpace(&fCurrentDepth,
&fpCurrentPV,
&fpCurrentLV);
}
HepRepXMLWriter *G4HepRepFileSceneHandler::GetHepRepXMLWriter() {
return hepRepXMLWriter;
}
@@ -0,0 +1,86 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4HepRepFileViewer.cc,v 1.3 2001/11/19 15:07:28 johna Exp $
// GEANT4 tag $Name: geant4-04-00 $
#include "G4HepRepFileViewer.hh"
#include "G4ios.hh"
#include "g4std/strstream"
#include "G4VSceneHandler.hh"
#include "G4HepRepFileSceneHandler.hh"
//HepRep
#include "HepRepXMLWriter.hh"
G4HepRepFileViewer::G4HepRepFileViewer
(G4VSceneHandler& sceneHandler, const G4String& name):
G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name) {
hepRepXMLWriter = ((G4HepRepFileSceneHandler*)(&sceneHandler))->GetHepRepXMLWriter();
}
G4HepRepFileViewer::~G4HepRepFileViewer() {}
void G4HepRepFileViewer::SetView() {
#ifdef G4HEPREPFILEDEBUG
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() {
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::ClearView() called." << G4endl;
#endif
}
void G4HepRepFileViewer::DrawView() {
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::DrawView() called." << G4endl;
#endif
NeedKernelVisit (); // Always need to visit G4 kernel.
ProcessView ();
}
void G4HepRepFileViewer::ShowView () {
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::ShowView" << G4endl;
#endif
G4VViewer::ShowView();
hepRepXMLWriter->close();
}
@@ -0,0 +1,297 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//--------------------------------------------------------------------------
// File and Version Information:
// $Id: HepRepXMLWriter.cc,v 1.3 2001/12/13 12:04:26 gunter Exp $
//
// Description:
// Create a HepRep XML File (HepRep version 1).
//
// Environment:
// Software developed for the general High Energy Physics community.
//
// Author :
// J. Perl Original Author
//
// Copyright Information:
// Copyright (C) 2001 Stanford Linear Accelerator Center
//------------------------------------------------------------------------
#include "HepRepXMLWriter.hh"
#include "G4ios.hh"
HepRepXMLWriter::HepRepXMLWriter()
{
}
void HepRepXMLWriter::addType(const char* name)
{
if (fout.good())
{
endType();
fout << " <heprep:type version=\"null\" name=\"" << name << "\">"
<< G4endl;
inType = true;
} else {
G4cout << "HepRepXMLWriter:addType No file is currently open." << G4endl;
}
}
void HepRepXMLWriter::addInstance()
{
if (fout.good())
{
if (inType)
{
endInstance();
fout << " <heprep:instance>" << G4endl;
inInstance = true;
} else {
G4cout << "HepRepXMLWriter:addInstance No HepRep Type is currently open"
<< G4endl;
}
} else {
G4cout << "HepRepXMLWriter:addInstance No file is currently open"
<< G4endl;
}
}
void HepRepXMLWriter::addPrimitive()
{
if (fout.good())
{
if (inInstance)
{
endPrimitive();
fout << " <heprep:primitive>" << G4endl;
inPrimitive = true;
} else {
G4cout <<
"HepRepXMLWriter:addPrimitive No HepRep Instance is currently open"
<< G4endl;
}
} else {
G4cout << "HepRepXMLWriter:addPrimitive No file is currently open"
<< G4endl;
}
}
void HepRepXMLWriter::addPoint(double x, double y, double z)
{
if (fout.good())
{
if (inPrimitive)
{
endPoint();
fout << " <heprep:point x=\"" << x << "\" y=\"" << y << "\" z=\"" << z << "\">" << G4endl;
inPoint = true;
} else {
G4cout <<
"HepRepXMLWriter:addPoint No HepRep Primitive is currently open"
<< G4endl;
}
} else {
G4cout << "HepRepXMLWriter:addPoint No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::addAttDef(const char* name,
const char* desc,
const char* type,
const char* extra)
{
if (fout.good())
{
indent();
fout << " <heprep:attdef extra=\"" << extra << "\" name=\"" << name << "\" type=\"" << type << "\"" << G4endl;
indent();
fout << " desc=\"" << desc << "\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttDef No file is currently open" << G4endl;
}
}
// Four methods to fill attValues
void HepRepXMLWriter::addAttValue (const char* name,
const char* value)
{
if (fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttValue No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::addAttValue (const char* name,
double value)
{
if (fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttValue No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::addAttValue (const char* name,
int value)
{
if (fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttValue No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::addAttValue (const char* name,
bool value)
{
if (fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttValue No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::addAttValue (const char* name,
double value1,
double value2,
double value3)
{
if (fout.good())
{
indent();
int redness = int(value1*255.);
int greenness = int(value2*255.);
int blueness = int(value3*255.);
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
indent();
fout << " value=\"" << redness << "," << greenness << "," << blueness << "\"/>" << G4endl;
} else {
G4cout << "HepRepXMLWriter:addAttValue No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::open(const char* filespec)
{
if (fout.good())
fout.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;
} else {
G4cout << "HepRepXMLWriter:open Unable to write to file " << filespec << G4endl;
}
}
void HepRepXMLWriter::close()
{
if (fout.good())
{
endType();
fout << "</heprep:heprep>" << G4endl;
fout.close( );
} else {
G4cout << "HepRepXMLWriter:close No file is currently open" << G4endl;
}
}
void HepRepXMLWriter::endType()
{
if (inType)
{
endInstance();
fout << " </heprep:type>" << G4endl;
inType = false;
}
}
void HepRepXMLWriter::endInstance()
{
if (inInstance)
{
endPrimitive();
fout << " </heprep:instance>" << G4endl;
inInstance = false;
}
}
void HepRepXMLWriter::endPrimitive()
{
if (inPrimitive)
{
endPoint();
fout << " </heprep:primitive>" << G4endl;
inPrimitive = false;
}
}
void HepRepXMLWriter::endPoint()
{
if (inPoint)
{
fout << " </heprep:point>" << G4endl;
inPoint = false;
}
}
void HepRepXMLWriter::indent()
{
if (fout.good())
{
if (inType)
fout << " ";
if (inInstance)
fout << " ";
if (inPrimitive)
fout << " ";
if (inPoint)
fout << " ";
}
}