Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
+11
View File
@@ -18,6 +18,17 @@ committal in the CVS repository !
History file for visualization/HepRep sub-category
--------------------------------------------------
27 August 2021 Ben Morgan (vis-HepRep-V10-07-04)
- Remove obsolete HepRep(WIRED) driver and associated files
30 June 2021 John Allison (vis-HepRep-V10-07-03)
- Requires greps-V10-07-09, modeling-V10-07-11 and visman-V10-07-11.
- Revise vis models. See visualization/modeling/History for more details.
- Consequent changes:
o AddPrimitive(const G4Scale&) has been removed from all scene handlers.
29 June 2021 Gabriele Cosmo (vis-HepRep-V10-07-02)
- Fixed compilation error in G4HepRepSceneHandler when c++20 is enabled.
07 June 2021 John Allison (vis-HepRep-V10-07-01)
- Fix hidden function warning.
-152
View File
@@ -1,152 +0,0 @@
This G4 Graphics Driver creates a HepRep File suitable for viewing
by the HepRApp, Wired4 or FRED Event Display clients.
It requires no external packages.
The HepRep graphics format is further described at
http://www.slac.stanford.edu/~perl/heprep/
Two different drivers are available for either HepRep1 or HepRep2.
Driver: HepRepFile
------------------
The version of HepRep produced by this driver is HepRep Version 1.
Writes files with file extension .heprep.
First file is written to current directory and is named G4Data0.heprep.
Subsequent files increment the number, as in G4Data1.heprep, G4Data2.heprep...
To specify a different output file directory (instead of current directory),
set G4HEPREPFILE_DIR
To specify a different output file name (instead of G4Data),
set G4HEPREPFILE_NAME
To repeatedly overwrite the same output file (instead of having incremental
numbers at the end of the file name),
set G4HEPREPFILE_OVERWRITE
By default, invisible objects are not culled but are left in the heprep file
with their visibility initially set to false (so that you can subsequently
choose to make them visible from within the heprep browser).
To force culling of invisible objects,
set G44HEPREPFILE_CULL
View the file using the HepRApp HepRep Browser, available from:
http://www.slac.stanford.edu/~perl/HepRApp
HepRApp 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
15 November 2007
Driver: HepRepXML
-----------------
The version of HepRep produced by this driver is HepRep Version 2.
This driver can write both Binary HepRep (.bheprep) and XML HepRep
(.heprep) files. Binary HepRep files are a one-to-one translation
of XML HepRep files, but they are considerably shorter and faster
to parse by a HepRepViewer such as WIRED 4.
You can view the files using the WIRED 4 Event Display, available from:
http://wired4.freehep.org
Both Binary HepRep and XML HepRep can be compressed using the standard
zlib library if linked into Geant4 using G4LIB_USE_ZLIB. If a standard
zlib is not available (WIN32-VC for instance) you should also set
G4LIB_BUILD_ZLIB to build G4zlib included with Geant4.
HepRep files (Binary and XML) can contain multiple HepRep events/geometries.
If the file contains more than one HepRep it is not strictly XML anymore.
Files can be written in .heprep.zip, .heprep.gz or .heprep format and their
binary versions .bheprep.zip, .bheprep.gz or .bheprep.
The .heprep.zip is the default for file output, the .heprep is the default
for stdout and stderr.
(Optional) To set the filename with a particular extension such as:
.heprep.zip, .heprep.gz, .heprep, .bheprep.zip, .bheprep.gz or .bheprep
use for instance:
/vis/scene/create filename.bheprep.zip
(Optional) To create separate files for each event, you can set a suffix such as
"-0001" to start writing files from filename-0001.bheprep.zip to
filename-9999.bheprep.zip (or up), while "-55-sub" will start write files
filename-55-sub.bheprep.zip to filename-99-sub.bheprep.zip (or up).
/vis/heprep/setEventNumberSuffix -0001
(Note: suffix has to contain at least one digit)
(Optional) To route the HepRep XML output to stdout (or stderr),
by default uncompressed, use:
/vis/scene/create stdout
To select the driver, where the file if not create by scene is set to
G4HepRepOutput.heprep.zip, use:
/vis/open HepRepXML
(Optional) To write a geometry, use:
/vis/viewer/flush
(Optional) To signal a change in geometry (to be written with the next event), use:
/vis/viewer/refresh
To write 10 events (and geometries), use:
/run/beamOn 10
(Optional) To accumulate multiple (5) G4 events into one HepRep event, use:
/vis/scene/endOfEventAction accumulate
/run/beamOn 5
/vis/viewer/update
(Optional) To add attributes to each point on a trajectory, use:
/vis/heprep/addPointAttributes 1
Be aware that this may increase the size of the output dramatically.
(Optional) You may use the commands:
/vis/viewer/zoom to set an initial zoom factor
/vis/viewer/set/viewpointThetaPhi to set an initial view point
/vis/heprep/setCoordinateSystem uvw to change the coordinate system, where uvw can be "xyz", "zxy", ...
(Optional) You may decide to write .zip files with events and geometry separated (but linked).
This results in a smaller zip file, as the geometry is only written once. Use the command:
/vis/heprep/appendGeometry false
(Optional) To close the file, remove the SceneHandler, use:
/vis/sceneHandler/remove scene-handler-0
Limitations:
Only one SceneHandler can exist at any time, connected to a single Viewer.
Since the HepRep format is a model rather than a view this is not a real
limitation. In WIRED 4 you can create as many views (SceneHandlers) as you like.
1 June 2005
Mark.Donszelmann@slac.stanford.edu
@@ -1,52 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/**
* @author Mark Donszelmann
*/
#ifndef G4HEPREP_HH
#define G4HEPREP_HH 1
//G4
#include "G4VGraphicsSystem.hh"
class G4HepRep: public G4VGraphicsSystem {
public:
G4HepRep ();
virtual ~G4HepRep ();
G4VSceneHandler* CreateSceneHandler (const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
void removeSceneHandler();
void removeViewer();
private:
G4VSceneHandler* sceneHandler;
G4VViewer* viewer;
};
#endif
@@ -25,7 +25,7 @@
//
//
//
//
//
// John Allison 5th April 2001
// A graphics system to dump geometry hierarchy.
@@ -37,14 +37,15 @@
// HepRep
#include "G4HepRepFileXMLWriter.hh"
class G4HepRepFile: public G4VGraphicsSystem {
public:
class G4HepRepFile : public G4VGraphicsSystem
{
public:
G4HepRepFile();
virtual ~G4HepRepFile();
G4VSceneHandler* CreateSceneHandler(const G4String& name = "");
G4VViewer* CreateViewer (G4VSceneHandler&, const G4String& name = "");
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "");
G4HepRepFileXMLWriter *GetHepRepXMLWriter();
G4HepRepFileXMLWriter* GetHepRepXMLWriter();
};
#endif
@@ -55,11 +55,10 @@ class G4LogicalVolume;
class G4ModelingParameters;
class G4VisTrajContext;
class G4HepRepFileSceneHandler: public G4VSceneHandler {
public:
G4HepRepFileSceneHandler(G4VGraphicsSystem& system,
const G4String& name);
class G4HepRepFileSceneHandler : public G4VSceneHandler
{
public:
G4HepRepFileSceneHandler(G4VGraphicsSystem& system, const G4String& name);
virtual ~G4HepRepFileSceneHandler();
////////////////////////////////////////////////////////////////
@@ -80,9 +79,9 @@ public:
void AddSolid(const G4VSolid&);
using G4VSceneHandler::AddCompound;
void AddCompound (const G4VTrajectory&);
void AddCompound(const G4VTrajectory&);
void InitTrajectory();
void AddCompound (const G4VHit&);
void AddCompound(const G4VHit&);
void InitHit();
// void PreAddSolid(const G4Transform3D& objectTransformation,
@@ -114,28 +113,27 @@ public:
void BeginModeling();
void EndModeling();
void BeginPrimitives2D(const G4Transform3D& objectTransformation);
void EndPrimitives2D();
//////////////////////////////////////////////////////////////
// Administration functions.
//void ClearStore ();
void ClearTransientStore ();
// void ClearStore ();
void ClearTransientStore();
////////////////////////////////////////////////////////////////
// Required...
G4HepRepFileXMLWriter *GetHepRepXMLWriter();
G4HepRepFileXMLWriter* GetHepRepXMLWriter();
protected:
static G4int fSceneIdCount; // Counter for HepRep scene handlers.
protected:
static G4int fSceneIdCount; // Counter for HepRep scene handlers.
private:
G4HepRepFileXMLWriter *hepRepXMLWriter;
void AddHepRepInstance(const char* primName,
const G4Visible visible);
private:
G4HepRepFileXMLWriter* hepRepXMLWriter;
void AddHepRepInstance(const char* primName, const G4Visible visible);
void CheckFileOpen();
int fileCounter;
G4bool haveVisible;
@@ -146,18 +144,17 @@ private:
G4bool doneInitTraj;
G4bool drawingHit;
G4bool doneInitHit;
const G4VisTrajContext* trajContext;
std::vector<G4AttValue>* trajAttValues;
std::map<G4String,G4AttDef>* trajAttDefs;
std::map<G4String, G4AttDef>* trajAttDefs;
std::vector<G4AttValue>* hitAttValues;
std::map<G4String,G4AttDef>* hitAttDefs;
std::map<G4String, G4AttDef>* hitAttDefs;
#ifdef G4HEPREPFILEDEBUG
void PrintThings();
#endif
};
#endif
@@ -25,7 +25,7 @@
//
//
//
//
//
// John Allison 5th April 2001
// A base class for a dummy viewer to dump geometry hierarchy.
@@ -39,17 +39,18 @@
#include "G4HepRepFileXMLWriter.hh"
#include "G4HepRepFileSceneHandler.hh"
class G4HepRepFileViewer: public G4VViewer {
public:
G4HepRepFileViewer(G4VSceneHandler&,const G4String& name);
class G4HepRepFileViewer : public G4VViewer
{
public:
G4HepRepFileViewer(G4VSceneHandler&, const G4String& name);
virtual ~G4HepRepFileViewer();
void SetView();
void ClearView();
void DrawView();
void ShowView();
private:
G4HepRepFileXMLWriter *hepRepXMLWriter;
private:
G4HepRepFileXMLWriter* hepRepXMLWriter;
};
#endif
@@ -49,7 +49,7 @@
class G4HepRepFileXMLWriter
{
public:
public:
G4HepRepFileXMLWriter();
void addType(const char* name, int newTypeDepth);
@@ -57,27 +57,19 @@ public:
void addPrimitive();
void addPoint(double x, double y, double z);
void addAttDef(const char* name,
const char* desc,
const char* type,
const char* extra);
void addAttDef(const char* name, const char* desc, const char* type,
const char* extra);
void addAttValue(const char* name,
const char* value);
void addAttValue(const char* name, const char* value);
void addAttValue(const char* name,
double value);
void addAttValue(const char* name, double value);
void addAttValue(const char* name,
int value);
void addAttValue(const char* name, int value);
void addAttValue(const char* name,
bool value);
void addAttValue(const char* name, bool value);
void addAttValue(const char* name,
double value1,
double value2,
double value3);
void addAttValue(const char* name, double value1, double value2,
double value3);
void open(const char* filespec);
void close();
@@ -89,8 +81,8 @@ public:
bool inType[50];
bool inInstance[50];
char* prevTypeName[50];
private:
private:
std::ofstream fout;
void init();
@@ -37,71 +37,71 @@
#include "G4UIcommand.hh"
#include "G4ThreeVector.hh"
class G4HepRepMessenger : public G4UImessenger {
public:
static G4HepRepMessenger* GetInstance(); // Singleton constructor.
virtual ~G4HepRepMessenger();
class G4HepRepMessenger : public G4UImessenger
{
public:
static G4HepRepMessenger* GetInstance(); // Singleton constructor.
virtual ~G4HepRepMessenger();
virtual G4String GetCurrentValue(G4UIcommand * command);
virtual void SetNewValue(G4UIcommand * command, G4String newValue);
// Used by HepRepFile
virtual G4String getFileDir();
virtual G4String getFileName();
virtual G4bool getOverwrite();
virtual G4bool getCullInvisibles();
virtual G4bool renderCylAsPolygons();
virtual G4double getScale();
virtual G4ThreeVector getCenter();
// Used by HepRepXML
virtual G4String getEventNumberSuffix();
virtual G4bool appendGeometry();
virtual G4bool addPointAttributes();
virtual G4bool useSolids();
virtual G4bool writeInvisibles();
virtual G4String GetCurrentValue(G4UIcommand* command);
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
private:
G4HepRepMessenger(); // Private constructor.
static G4HepRepMessenger* fpInstance;
G4UIdirectory* heprepDirectory;
G4String fileDir;
G4UIcmdWithAString* setFileDirCommand;
G4String fileName;
G4UIcmdWithAString* setFileNameCommand;
G4bool overwrite;
G4UIcmdWithABool* setOverwriteCommand;
G4bool cullInvisibles;
G4UIcmdWithABool* setCullInvisiblesCommand;
G4bool cylAsPolygons;
G4UIcmdWithABool* renderCylAsPolygonsCommand;
G4double scale;
G4UIcmdWithADouble* setScaleCommand;
G4ThreeVector center;
G4UIcmdWith3VectorAndUnit* setCenterCommand;
G4String suffix;
G4UIcmdWithAString* setEventNumberSuffixCommand;
G4bool geometry;
G4UIcmdWithABool* appendGeometryCommand;
// Used by HepRepFile
virtual G4String getFileDir();
virtual G4String getFileName();
virtual G4bool getOverwrite();
virtual G4bool getCullInvisibles();
virtual G4bool renderCylAsPolygons();
virtual G4double getScale();
virtual G4ThreeVector getCenter();
G4bool pointAttributes;
G4UIcmdWithABool* addPointAttributesCommand;
// Used by HepRepXML
virtual G4String getEventNumberSuffix();
virtual G4bool appendGeometry();
virtual G4bool addPointAttributes();
virtual G4bool useSolids();
virtual G4bool writeInvisibles();
G4bool solids;
G4UIcmdWithABool* useSolidsCommand;
G4bool invisibles;
private:
G4HepRepMessenger(); // Private constructor.
static G4HepRepMessenger* fpInstance;
G4UIdirectory* heprepDirectory;
G4String fileDir;
G4UIcmdWithAString* setFileDirCommand;
G4String fileName;
G4UIcmdWithAString* setFileNameCommand;
G4bool overwrite;
G4UIcmdWithABool* setOverwriteCommand;
G4bool cullInvisibles;
G4UIcmdWithABool* setCullInvisiblesCommand;
G4bool cylAsPolygons;
G4UIcmdWithABool* renderCylAsPolygonsCommand;
G4double scale;
G4UIcmdWithADouble* setScaleCommand;
G4ThreeVector center;
G4UIcmdWith3VectorAndUnit* setCenterCommand;
G4String suffix;
G4UIcmdWithAString* setEventNumberSuffixCommand;
G4bool geometry;
G4UIcmdWithABool* appendGeometryCommand;
G4bool pointAttributes;
G4UIcmdWithABool* addPointAttributesCommand;
G4bool solids;
G4UIcmdWithABool* useSolidsCommand;
G4bool invisibles;
};
#endif
@@ -1,225 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/**
* @author Mark Donszelmann
*/
#ifndef G4HEPREPSCENEHANDLER_HH
#define G4HEPREPSCENEHANDLER_HH 1
#include "globals.hh"
#include <iostream>
#include <stack>
#include <map>
#include <vector>
// HepRep
#include "HEPREP/HepRep.h"
//G4
#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"
#include "G4VGraphicsSystem.hh"
#include "G4VSceneHandler.hh"
#include "G4Visible.hh"
#include "G4Material.hh"
#include "G4LogicalVolume.hh"
#include "G4PhysicalVolumeModel.hh"
class G4HepRepSceneHandler: public G4VSceneHandler {
public:
G4HepRepSceneHandler (G4VGraphicsSystem& system, const G4String& name = "");
virtual ~G4HepRepSceneHandler ();
void AddSolid (const G4Box& box);
void AddSolid (const G4Cons& cons);
void AddSolid (const G4Tubs& tubs);
void AddSolid (const G4Trd& trd);
void AddSolid (const G4Trap& trap);
void AddSolid (const G4Sphere& sphere);
void AddSolid (const G4Para& para);
void AddSolid (const G4Torus& torus);
void AddSolid (const G4Polycone& polycone);
void AddSolid (const G4Polyhedra& polyhedra);
void AddSolid (const G4Orb& orb);
void AddSolid (const G4Ellipsoid& ellipsoid);
void AddSolid (const G4TessellatedSolid& tess);
void AddSolid (const G4VSolid& solid);
using G4VSceneHandler::AddCompound;
void AddCompound (const G4VTrajectory&);
void AddCompound (const G4VHit& hit);
void PreAddSolid (const G4Transform3D& objectTransformation, const G4VisAttributes& visAttribs);
void PostAddSolid ();
void AddPrimitive (const G4Polyline&);
void AddPrimitive (const G4Text&);
void AddPrimitive (const G4Circle&);
void AddPrimitive (const G4Square&);
void AddPrimitive (const G4Polyhedron&);
void AddPrimitive (const G4Polymarker&);
void AddPrimitive (const G4Scale& scale);
void BeginPrimitives (const G4Transform3D& objectTransformation);
void EndPrimitives ();
void BeginModeling ();
void EndModeling ();
void openHepRep();
bool closeHepRep(bool final = false);
void openFile(G4String name);
void closeFile();
private:
G4HepRepSceneHandler (const G4HepRepSceneHandler&);
G4HepRepSceneHandler& operator= (const G4HepRepSceneHandler&);
static G4int sceneIdCount;
G4Transform3D transform;
std::ostream* out;
HEPREP::HepRepFactory* factory;
HEPREP::HepRepWriter* writer;
// Methods
G4bool dontWrite();
void setColor (HEPREP::HepRepAttribute *attribute, const G4Color& color,
const G4String& key = G4String("Color"));
G4Color getColorFor (const G4Visible& visible);
G4Color getColorFor (const G4VSolid& solid);
void setVisibility (HEPREP::HepRepAttribute *attribute, const G4VSolid& solid);
void setLine (HEPREP::HepRepAttribute *attribute, const G4VSolid& solid);
void setVisibility (HEPREP::HepRepAttribute *attribute, const G4Visible& visible);
void setLine (HEPREP::HepRepAttribute *attribute, const G4Visible& visible);
void setMarker (HEPREP::HepRepAttribute *attribute, const G4VMarker& marker);
inline void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, char* value) {
setAttribute(attribute, name, G4String(value));
}
void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, G4String value);
void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, bool value);
void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, double value);
void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, int value);
void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, double red, double green, double blue, double alpha);
bool isEventData();
void open(G4String name);
void close();
void writeLayers(HEPREP::HepRep* heprep);
void addAttributes(HEPREP::HepRepInstance* instance, HEPREP::HepRepType* type);
void addAttDefs(HEPREP::HepRepDefinition* definition, const std::map<G4String,G4AttDef>* attDefs);
void addAttVals(HEPREP::HepRepAttribute* attribute, const std::map<G4String,G4AttDef>* attDefs, std::vector<G4AttValue>* attValues);
void addTopLevelAttributes(HEPREP::HepRepType* type);
HEPREP::HepRepInstance* getGeometryOrEventInstance(HEPREP::HepRepType* type);
// Returns the particular instance/type or if not created, creates them and adds them to the HepRep
HEPREP::HepRep* getHepRep();
HEPREP::HepRep* getHepRepGeometry();
HEPREP::HepRepInstanceTree* getGeometryInstanceTree();
HEPREP::HepRepInstance* getGeometryInstance(G4LogicalVolume* volume, G4Material* material, int depth);
HEPREP::HepRepInstance* getGeometryInstance(G4String volumeName, int depth);
HEPREP::HepRepInstance* getGeometryRootInstance();
HEPREP::HepRepTypeTree* getGeometryTypeTree();
HEPREP::HepRepType* getGeometryType(G4String volumeName, int depth);
HEPREP::HepRepType* getGeometryRootType();
HEPREP::HepRepInstanceTree* getEventInstanceTree();
HEPREP::HepRepInstance* getEventInstance();
HEPREP::HepRepTypeTree* getEventTypeTree();
HEPREP::HepRepType* getEventType();
HEPREP::HepRepType* getTrajectoryType ();
HEPREP::HepRepType* getHitType ();
HEPREP::HepRepType* getCalHitType ();
HEPREP::HepRepType* getCalHitFaceType ();
G4String getFullTypeName(G4String volumeName, int depth);
G4String getParentTypeName(int currentDepth);
// initialized Member Variables
G4String geometryLayer, eventLayer, calHitLayer;
G4String trajectoryLayer, hitLayer;
G4String rootVolumeName;
G4String baseName;
G4String eventNumberPrefix;
G4String eventNumberSuffix;
G4int eventNumber;
G4int eventNumberWidth;
G4String extension;
G4bool writeBinary;
G4bool writeZip;
G4bool writeGZ;
G4bool writeMultipleFiles;
const G4VHit* currentHit;
const G4VTrajectory* currentTrack;
// DO NOT USE member vars directly, use get methods.
HEPREP::HepRep* _heprep;
HEPREP::HepRep* _heprepGeometry;
HEPREP::HepRepInstanceTree* _geometryInstanceTree;
std::vector<HEPREP::HepRepInstance*> _geometryInstance;
HEPREP::HepRepInstance* _geometryRootInstance;
HEPREP::HepRepTypeTree* _geometryTypeTree;
std::vector<G4String> _geometryTypeName;
std::map<G4String, HEPREP::HepRepType*> _geometryType;
HEPREP::HepRepType* _geometryRootType;
HEPREP::HepRepInstanceTree* _eventInstanceTree;
HEPREP::HepRepInstance* _eventInstance;
HEPREP::HepRepTypeTree* _eventTypeTree;
HEPREP::HepRepType* _eventType;
HEPREP::HepRepType* _trajectoryType;
HEPREP::HepRepType* _hitType;
HEPREP::HepRepType* _calHitType;
HEPREP::HepRepType* _calHitFaceType;
std::map<int, G4String> materialState;
};
#endif
@@ -1,57 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/**
* @author Mark Donszelmann
*/
#ifndef G4HEPREPVIEWER_HH
#define G4HEPREPVIEWER_HH 1
// HepRep
#include "HEPREP/HepRep.h"
// Geant4
#include "G4VViewer.hh"
class G4HepRepViewer: public G4VViewer {
public:
G4HepRepViewer (G4VSceneHandler& scene, const G4String& name = "");
virtual ~G4HepRepViewer ();
void SetView ();
void ClearView ();
void DrawView ();
void ShowView ();
void FinishView ();
void reset();
private:
bool geometryIncluded;
};
#endif
@@ -1,34 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HASHEPREP_H
#define HEPREP_HASHEPREP_H 1
// Copyright 2000-2005, FreeHEP.
namespace HEPREP {
class HepRep;
/**
* The HasHepRep interface.
*
* @author Mark Donszelmann
*/
class HasHepRep {
public:
/// Destructor.
virtual ~HasHepRep() { /* nop */; }
/**
* Returns the associated HepRep to this object.
*
*/
virtual HepRep & getHepRep() = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HASHEPREP_H */
@@ -1,210 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREP_H
#define HEPREP_HEPREP_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
#include <vector>
// Include all other HepRep header files here for convenience
#include "HEPREP/HasHepRep.h"
#include "HEPREP/HepRepAction.h"
#include "HEPREP/HepRepAttDef.h"
#include "HEPREP/HepRepAttribute.h"
#include "HEPREP/HepRepAttributeListener.h"
#include "HEPREP/HepRepAttValue.h"
#include "HEPREP/HepRepConstants.h"
#include "HEPREP/HepRepDefinition.h"
#include "HEPREP/HepRepFactory.h"
#include "HEPREP/HepRepFrameListener.h"
#include "HEPREP/HepRepInstance.h"
#include "HEPREP/HepRepInstanceTree.h"
#include "HEPREP/HepRepIterator.h"
#include "HEPREP/HepRepPoint.h"
#include "HEPREP/HepRepSelectFilter.h"
#include "HEPREP/HepRepTreeID.h"
#include "HEPREP/HepRepType.h"
#include "HEPREP/HepRepTypeTree.h"
#include "HEPREP/HepRepWriter.h"
namespace HEPREP {
class HepRepAction;
class HepRepInstanceTree;
class HepRepSelectFilter;
class HepRepTypeTree;
/**
* The HepRep interface.
*
* Any of these methods may throw a UnsupportedOperationException in Java.
*
* This interface is NOT final yet.
*
* @author Mark Donszelmann
*/
class HepRep {
public:
/// Destructor.
virtual ~HepRep() { /* nop */; }
/**
* Add a layer to the list of layers in this heprep.
* The layer is added to the back of the list.
*
* @param layer name of layer to be added to the back of the list.
*/
virtual void addLayer(std::string layer) = 0;
/**
* Returns the list of layers.
*
* @return the known layer names, in the order back-to-front.
*/
virtual std::vector<std::string> getLayerOrder() = 0;
/**
* Add a typetree to this heprep.
*
* @param typeTree to be added.
*/
virtual void addTypeTree(HepRepTypeTree * typeTree) = 0;
/**
* Remove a typetree from this heprep.
*
* @param typeTree to be removed.
*/
virtual void removeTypeTree(HepRepTypeTree * typeTree) = 0;
/**
* Returns the collection of all typetrees of this heprep.
*
* @return collection of HepRepTypeTrees.
*/
virtual std::vector<HepRepTypeTree *> getTypeTreeList() = 0;
/**
* Returns a named and versioned typetree.
*
* @param name name of the typetree.
* @param version version of the typetree.
* @return named and versioned HepRepTypeTree.
*/
virtual HepRepTypeTree * getTypeTree(std::string name, std::string version) = 0;
/**
* Searches for a named type in any of the typetrees.
* The first occurrence found is returned.
*
* @param name name of type.
* @return named HepRepType.
*/
// HepRepType* getType(String name);
/**
* Adds an instancetree to this heprep.
*
* @param instanceTree to be added.
*/
virtual void addInstanceTree(HepRepInstanceTree * instanceTree) = 0;
/**
* Overlays an instancetree to this heprep, overriding attributes and adding children.
*
* @param instanceTree to be overlaid.
*/
virtual void overlayInstanceTree(HepRepInstanceTree * instanceTree) = 0;
/**
* Remove an instanectree from this heprep.
*
* @param instanceTree to be removed.
*/
virtual void removeInstanceTree(HepRepInstanceTree * instanceTree) = 0;
/**
* Returns a collection of instancetrees.
*
* @return collection of HepRepInstanceTrees.
*/
virtual std::vector<HepRepInstanceTree *> getInstanceTreeList() = 0;
/**
* Returns a named and versioned instancetree.
* FIXME: doc is incorrect here, should only return TOP of the tree. Filling
* in should be done by getInstances calls.
* <p>
* This tree needs to be added to the heprep afterwards.
*
* @param name name of the instancetree.
* @param version version of the instancetree.
* @return HepRepIntanceTree
*/
virtual HepRepInstanceTree * getInstanceTreeTop(std::string name, std::string version) = 0;
/**
* Returns a named and versioned instancetree for a list of typenames.
* <p>
* This tree needs to be added to the heprep afterwards.
*
* @param name name of the instancetree.
* @param version version of the instancetree.
* @param typeNames a list of typenames for which we need instancetrees.
* @return HepRepIntanceTree
*/
virtual HepRepInstanceTree * getInstances(std::string name, std::string version, std::vector<std::string> typeNames) = 0;
/**
* Returns a named and versioned instancetree for a list of typenames
* after executing some action and for specific filters.
*
* This tree needs to be added to the heprep afterwards.
* <p>
* The inversion effect of invertAtts depends on the values of
* GetDrawAtts and GetNonDrawAtts as follows:
* <UL>
* <LI>GetDrawAtts GetNonDrawAtts effect of InvertAtts
* <LI>FALSE FALSE all Attributes specified will be downloaded
* <LI>TRUE FALSE Draw Attributes specified will be omitted, NonDraw Attributes specified will be included
* <LI>FALSE TRUE Draw Attributes specified will be included, NonDraw Attributes specified will be omitted
* <LI>TRUE TRUE all Attributes specified will be omitted
* </UL>
*
* @param name name of the instancetree.
* @param version version of the instancetree.
* @param typeNames a list of typenames for which we need instancetrees.
* @param actions execute this list of actions before returning.
* @param getPoints include the HepRepPoints in the instance tree.
* @param getDrawAtts include the Draw attributes in the instance tree.
* @param getNonDrawAtts include the Non-Draw attributes in the instance tree.
* @param invertAtts list of attributes to be included or not depending on getDrawAtts and getNonDrawAtts.
* @return HepRepIntanceTree
*/
virtual HepRepInstanceTree * getInstancesAfterAction(std::string name, std::string version, std::vector<std::string> typeNames, std::vector<HepRepAction *> actions, bool getPoints, bool getDrawAtts, bool getNonDrawAtts, std::vector<std::string> invertAtts) = 0;
/**
* Returns last exception thrown and clears it. Useful for implementations without
* exception handling.
*
* @return last exception and clears it.
*/
virtual std::string checkForException() = 0;
/**
* Returns a deep copy of the heprep, with all its attached trees, where
* instances are filtered using a HepRepSelectFilter.
*
* @param filter to be used for filtering instances.
* @return copy of heprep.
*/
virtual HepRep * copy(HepRepSelectFilter * filter = NULL) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREP_H */
@@ -1,49 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPACTION_H
#define HEPREP_HEPREPACTION_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
namespace HEPREP {
/**
* HepRepAction interface.
*
* @author Mark Donszelmann
*/
class HepRepAction {
public:
/// Destructor.
virtual ~HepRepAction() { /* nop */; }
/**
* Returns name of this action.
*
* @return name of this action.
*/
virtual std::string getName() = 0;
/**
* Returns expression associated with this action.
*
* @return expression of this action.
*/
virtual std::string getExpression() = 0;
/**
* Returns a deep copy of this action.
*
* @return copy of this action.
*/
virtual HepRepAction * copy() = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPACTION_H */
@@ -1,70 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPATTDEF_H
#define HEPREP_HEPREPATTDEF_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
namespace HEPREP {
/**
* HepRepAttDef interface.
*
* @author Mark Donszelmann
*/
class HepRepAttDef {
public:
/// Destructor.
virtual ~HepRepAttDef() { /* nop */; }
/**
* Returns the mixed case name of this attdef.
*
* @return name.
*/
virtual std::string getName() = 0;
/**
* Returns the lowercased name of this attdef.
*
* @return lowercased name.
*/
virtual std::string getLowerCaseName() = 0;
/**
* Returns a description of this attdef.
*
* @return description.
*/
virtual std::string getDescription() = 0;
/**
* Returns category of this attdef.
*
* @return category.
*/
virtual std::string getCategory() = 0;
/**
* Returns any extra information of this attdef.
*
* @return extra info.
*/
virtual std::string getExtra() = 0;
/**
* Returns a deep copy of this attdef.
*
* @return copy of this attdef.
*/
virtual HepRepAttDef * copy() = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPATTDEF_H */
@@ -1,129 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPATTVALUE_H
#define HEPREP_HEPREPATTVALUE_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
#include <vector>
#include "HEPREP/Types.h"
namespace HEPREP {
/**
* HepRepAttValue interface.
*
* @author Mark Donszelmann
*/
class HepRepAttValue {
public:
/// Destructor.
virtual ~HepRepAttValue() { /* nop */; }
/**
* Returns name of the attvalue.
*
* @return Capitalized Name.
*/
virtual std::string getName() = 0;
/**
* Returns lowercased name of the attvalue.
*
* @return Lowercased Name.
*/
virtual std::string getLowerCaseName() = 0;
/**
* Returns type of the attvalue, defined in HepRepConstants with names TYPE_xxx.
*
* @return type.
*/
virtual int getType() = 0;
/**
* Returns the Java-like name for the type of this attvalue.
*
* @return type name.
*/
virtual std::string getTypeName() = 0;
/**
* Returns the flag bits for showing this attvalue as a label, defined in HepRepConstants with names SHOW_xxx.
*
* @return flag bits if should be shown as label.
*/
virtual int showLabel() = 0;
/**
* Returns value as string.
*
* @return value as string (if type is string).
*/
virtual std::string getString() = 0;
/**
* Returns value as lowercase string.
*
* @return value as string (if type is string).
*/
virtual std::string getLowerCaseString() = 0;
/**
* Returns value as string.
*
* @return value (of any type) in string format.
*/
virtual std::string getAsString() = 0;
/**
* Returns value as Color.
*
* @return value as Color.
*/
virtual std::vector<double> getColor() = 0;
/**
* Returns value as long.
*
* @return value as long.
*/
virtual int64 getLong() = 0;
/**
* Returns value as int.
*
* @return value as integer.
*/
virtual int getInteger() = 0;
/**
* Returns value as double.
*
* @return value as double.
*/
virtual double getDouble() = 0;
/**
* Returns value as boolean.
*
* @return value as boolean.
*/
virtual bool getBoolean() = 0;
/**
* Returns a deep copy of this attvalue.
*
* @return copy of this attvalue.
*/
virtual HepRepAttValue * copy() = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPATTVALUE_H */
@@ -1,153 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPATTRIBUTE_H
#define HEPREP_HEPREPATTRIBUTE_H 1
// Copyright 2000-2005, FreeHEP.
#include <set>
#include <string>
#include <vector>
#include "HEPREP/Types.h"
#include "HEPREP/HepRepConstants.h"
namespace HEPREP {
class HepRepAttValue;
/**
* HepRepAttribute interface.
*
* @author Mark Donszelmann
*/
class HepRepAttribute {
public:
/// Destructor.
virtual ~HepRepAttribute() { /* nop */; }
/**
* Adds an attValue.
*
* @param attValue to be added.
*/
virtual void addAttValue(HepRepAttValue * attValue) = 0;
/**
* Adds a char* attValue as a String.
* This call should be mapped to addAttValue(std::string, std::string, int); and necessary
* because C++ converts char* into bool and would thus call addAttValue(std::string, bool, int)
* for a call such as addAttValue("drawAs", "Cylinder", 0);
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, char* value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, std::string value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, int64 value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, int value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, double value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds an attValue.
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, bool value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds a Color attValue.
*
* @param key name of attValue
* @param value value of attValue
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, std::vector<double> value, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Adds a Color attValue.
*
* @param key name of attValue
* @param red color
* @param green color
* @param blue color
* @param alpha value
* @param showLabel show this as label
*/
virtual void addAttValue(std::string key, double red, double green, double blue, double alpha = 1.0, int showLabel = HepRepConstants::SHOW_NONE) = 0;
/**
* Remove the attvalue named by key.
*
* @param key name of the attValue to be removed.
* @return removed HepRepAttValue, or null if not removed.
*/
virtual HepRepAttValue * removeAttValue(std::string key) = 0;
/**
* Returns the attValue specified by name. This attValue is normally searched
* on the node itself and then on its type, moving up the typetree.
*
* @param name of attribute value.
* @return attribute value.
*/
virtual HepRepAttValue * getAttValue(std::string name) = 0;
/**
* Returns a collection of all attribute values from this node.
*
* @return collection of HepRepAttValues.
*/
virtual std::set<HepRepAttValue *> getAttValuesFromNode() = 0;
/**
* Returns a named attribute value from this node.
*
* @param lowerCaseName name in all lowercase.
* @return corresponding HepRepAttValue.
*/
virtual HepRepAttValue * getAttValueFromNode(std::string lowerCaseName) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPATTRIBUTE_H */
@@ -1,103 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPATTRIBUTELISTENER_H
#define HEPREP_HEPREPATTRIBUTELISTENER_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
#include <vector>
namespace HEPREP {
class HepRepInstance;
/**
* HepRepAttributeListener interface. The implementor is called back for changes
* of attributes while using the HepRepIterator to iterate over all the HepRepInstances.
*
* All names are lowercased.
*
* @author Mark Donszelmann
*/
class HepRepAttributeListener {
public:
/// Destructor.
virtual ~HepRepAttributeListener() { /* nop */; }
/**
* Called if attribute key changes its value.
*
* @param instance instance for which this attribute is set.
* @param key name of the changed attribute.
* @param value value of the changed attribute.
* @param lowerCaseValue lower case value of the changed attribute.
* @param showLabel value of showLabel.
*/
virtual void setAttribute(HepRepInstance * instance, std::string key, std::string value, std::string lowerCaseValue, int showLabel) = 0;
/**
* Called if attribute key changes its value.
*
* @param instance instance for which this attribute is set.
* @param key name of the changed attribute.
* @param value value of the changed attribute.
* @param showLabel value of showLabel.
*/
virtual void setAttribute(HepRepInstance * instance, std::string key, std::vector<double> value, int showLabel) = 0;
/**
* Called if attribute key changes its value.
*
* @param instance instance for which this attribute is set.
* @param key name of the changed attribute.
* @param value value of the changed attribute.
* @param showLabel value of showLabel.
*/
virtual void setAttribute(HepRepInstance * instance, std::string key, long value, int showLabel) = 0;
/**
* Called if attribute key changes its value.
*
* @param instance instance for which this attribute is set.
* @param key name of the changed attribute.
* @param value value of the changed attribute.
* @param showLabel value of showLabel.
*/
virtual void setAttribute(HepRepInstance * instance, std::string key, int value, int showLabel) = 0;
/**
* Called if attribute key changes its value.
*
* @param instance instance for which this attribute is set.
* @param key name of the changed attribute.
* @param value value of the changed attribute.
* @param showLabel value of showLabel.
*/
virtual void setAttribute(HepRepInstance * instance, std::string key, double value, int showLabel) = 0;
/**
* Called if attribute key changes its value.
*
* @param instance instance for which this attribute is set.
* @param key name of the changed attribute.
* @param value value of the changed attribute.
* @param showLabel value of showLabel.
*/
virtual void setAttribute(HepRepInstance * instance, std::string key, bool value, int showLabel) = 0;
/**
* Called if attribute key is removed from the attribute set.
*
* @param instance instance for which this attribute is set.
* @param key name of the removed attribute.
*/
virtual void removeAttribute(HepRepInstance * instance, std::string key) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPATTRIBUTELISTENER_H */
@@ -1,36 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPCONSTANTS_H
#define HEPREP_HEPREPCONSTANTS_H 1
// Copyright 2000-2005, FreeHEP.
namespace HEPREP {
/**
* Constants for HepRep interfaces.
*
* @author Mark Donszelmann
*/
class HepRepConstants {
public:
/// Destructor.
virtual ~HepRepConstants() { /* nop */; }
/**
* Defines constants for type
*/
enum { TYPE_UNKNOWN = -1, TYPE_STRING = 1, TYPE_COLOR = 2, TYPE_LONG = 10, TYPE_INT = 11, TYPE_DOUBLE = 20, TYPE_BOOLEAN = 30 };
/**
* Defines constants for showLabel
*/
enum { SHOW_NONE = 0x0000, SHOW_NAME = 0x0001, SHOW_DESC = 0x0002, SHOW_VALUE = 0x0004, SHOW_EXTRA = 0x0008 };
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPCONSTANTS_H */
@@ -1,74 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPDEFINITION_H
#define HEPREP_HEPREPDEFINITION_H 1
// Copyright 2000-2005, FreeHEP.
#include <set>
#include <string>
#include "HEPREP/HepRepAttribute.h"
namespace HEPREP {
class HepRepAttDef;
/**
* HepRepDefinition interface.
*
* @author Mark Donszelmann
*
*/
class HepRepDefinition : virtual public HepRepAttribute {
public:
/// Destructor.
virtual ~HepRepDefinition() { /* nop */; }
/**
* Adds an attdef.
*
* @param name name of the definition.
* @param desc description of the definition.
* @param category category of the definition.
* @param extra extra info of the definition.
*/
virtual void addAttDef(std::string name, std::string desc, std::string category, std::string extra) = 0;
/**
* Adds an attdef.
*
* @param attDef to be added.
*/
virtual void addAttDef(HepRepAttDef * attDef) = 0;
/**
* Return a named attribute definition searched on this node and any parent nodes.
*
* @param name of attribute definition.
* @return attribute definition.
*/
virtual HepRepAttDef * getAttDef(std::string name) = 0;
/**
* Returns a collection of all attribute definitions defined on this node.
*
* @return collection of attributes definitions.
*/
virtual std::set<HepRepAttDef *> getAttDefsFromNode() = 0;
/**
* Returns a named attribute definition defined on this node.
*
* @param lowerCaseName name of the attribute in lower case.
* @return attribute definition.
*/
virtual HepRepAttDef * getAttDefFromNode(std::string lowerCaseName) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPDEFINITION_H */
@@ -1,148 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPFACTORY_H
#define HEPREP_HEPREPFACTORY_H 1
// Copyright 2000-2005, FreeHEP.
#include <iostream>
#include <string>
namespace HEPREP {
class HepRep;
class HepRepAction;
class HepRepInstance;
class HepRepInstanceTree;
class HepRepPoint;
class HepRepReader;
class HepRepTreeID;
class HepRepType;
class HepRepTypeTree;
class HepRepWriter;
/**
* HepRepFactory interface.
*
* @author Mark Donszelmann
*/
class HepRepFactory {
public:
/// Destructor.
virtual ~HepRepFactory() { /* nop */; }
/**
* Creates a HepRepReader from a stream.
*
* @param in input stream.
*/
virtual HepRepReader * createHepRepReader(std::istream * in) = 0;
/**
* Creates a HepRepReader from a file name.
*
* @param inputFileName file name.
*/
virtual HepRepReader * createHepRepReader(std::string inputFileName) = 0;
/**
* Creates a HepRepWriter.
*
* @param out output stream.
* @param randomAccess create a writer in a format that will allow random access (may be ignored).
* @param compress create a writer that uses compression (may be ignored).
*/
virtual HepRepWriter * createHepRepWriter(std::ostream * out, bool randomAccess, bool compress) = 0;
/**
* Creates a HepRepPoint.
*
* @param instance to add the point to.
* @param x x coordinate of point.
* @param y y coordinate of point.
* @param z z coordinate of point.
*/
virtual HepRepPoint * createHepRepPoint(HepRepInstance * instance, double x, double y, double z) = 0;
/**
* Creates a HepRepInstance.
*
* @parent to add the instance to.
* @type type the associated type.
*/
virtual HepRepInstance * createHepRepInstance(HepRepInstance * parent, HepRepType * type) = 0;
/**
* Creates a HepRepInstance.
*
* @parent to add the instance to.
* @type type the associated type.
*/
virtual HepRepInstance * createHepRepInstance(HepRepInstanceTree * parent, HepRepType * type) = 0;
/**
* Creates a HepRepTreeID.
*
* @param name of the treeID.
* @param version of the treeID.
* @param qualifier of the treeID.
*/
virtual HepRepTreeID * createHepRepTreeID(std::string name, std::string version, std::string qualifier = "top-level") = 0;
/**
* Creates a HepRepAction.
*
* @param name of the action.
* @param expression of the action.
*/
virtual HepRepAction * createHepRepAction(std::string name, std::string expression) = 0;
/**
* Creates a HepRepInstanceTree.
* <p>
* The tree needs to be added to the HepRep.
*
* @param name of the instancetree.
* @param version of the instancetree.
* @param typeTree associated typetree.
*/
virtual HepRepInstanceTree * createHepRepInstanceTree(std::string name, std::string version, HepRepTreeID * typeTree) = 0;
/**
* Creates a HepRepType.
*
* @param parent to add this type to.
* @param name of the type to create.
*/
virtual HepRepType * createHepRepType(HepRepTypeTree * parent, std::string name) = 0;
/**
* Creates a HepRepType.
*
* @param parent to add this type to.
* @param name of the type to create.
*/
virtual HepRepType * createHepRepType(HepRepType * parent, std::string name) = 0;
/**
* Creates a HepRepTypeTree.
* <p>
* The tree needs to be added to the HepRep.
*
* @param treeID to name the tree being created.
*/
virtual HepRepTypeTree * createHepRepTypeTree(HepRepTreeID * treeID) = 0;
/**
* Creates a HepRep.
*
*/
virtual HepRep * createHepRep() = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPFACTORY_H */
@@ -1,34 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPFRAMELISTENER_H
#define HEPREP_HEPREPFRAMELISTENER_H 1
// Copyright 2004-2005, FreeHEP.
namespace HEPREP {
/**
* HepRepFrameListener interface. The implementor is called back for changes in
* drawing in or out of the frame layer.
*
* @author Mark Donszelmann
*/
class HepRepFrameListener {
public:
/// Destructor.
virtual ~HepRepFrameListener() { /* nop */; }
/**
* Called if we switch from a normal layer to a frame layer, and back.
*
* @param inFrame true if in a frame layer
*/
virtual void setFrameLayer(bool inFrame) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPFRAMELISTENER_H */
@@ -1,138 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPINSTANCE_H
#define HEPREP_HEPREPINSTANCE_H 1
// Copyright 2000-2005, FreeHEP.
#include <vector>
#include "HEPREP/HepRepAttribute.h"
namespace HEPREP {
class HepRepInstanceTree;
class HepRepPoint;
class HepRepSelectFilter;
class HepRepType;
class HepRepTypeTree;
/**
* HepRepInstance interface.
*
* @author Mark Donszelmann
*/
class HepRepInstance : virtual public HepRepAttribute {
public:
/// Destructor.
virtual ~HepRepInstance() { /* nop */; }
/**
* Overlays the instance on the current instance.
*
* Attributes of the instance override or are added to the current instance.
* Sub-instances of the instance are added only if the current instance has no sub-instances.
* Points of the instance are added only if the current instance has no points.
*/
virtual void overlay(HepRepInstance * instance) = 0;
/**
* Adds an sub-instance to this instance.
*
* @param instance sub-instance.
*/
virtual void addInstance(HepRepInstance * instance) = 0;
/**
* Removes a sub-instance from this instance.
*
* @param instance sub-instance.
*/
virtual void removeInstance(HepRepInstance * instance) = 0;
/**
* Returns a collection of all sub-instances this instance keeps.
*
* @return collection of HepRepInstances.
*/
virtual std::vector<HepRepInstance *> getInstances() = 0;
/**
* Returns the associated type for this instance.
*
* @return associated HepRepType.
*/
virtual HepRepType * getType() = 0;
/**
* Adds a point to this instance.
*
* @param point to be added.
*/
virtual void addPoint(HepRepPoint * point) = 0;
/**
* Returns a collection of all points this instance keeps.
*
* @return collection of HepRepPoints.
*/
virtual std::vector<HepRepPoint *> getPoints() = 0;
/**
* Fills a double[3][n] array with the coordinates of all points, if
* none of the points have any attributes defined on them.
* The actual number of points filled is returned. In case the number
* of points is larger than n, or if any points have attributes, -1 is returned.
* One could then call getPoint().
*
* @see #getPoints()
*
* @param xyz a double[3][n] array to be filled with points.
* @return number of points filled in xyz, or -1 in case of error or non-implementation.
*
* ONLY in JAVA
*/
/**
* Returns true if this instance has a frame. Speedy access for iterator.
*
* ONLY in JAVA
*/
/**
* Returns String layername. Speedy access for iterator.
*
* ONLY in JAVA
*/
/**
* Returns the parent of this instance.
*
* @return parent of instance, or null if top-level.
*/
virtual HepRepInstance * getSuperInstance() = 0;
/**
* Returns a deep copy of this instance.
*
* @param typeTree needed to find the associated type.
* @param parent to which the copy is added.
* @param filter run on all instances before copying.
* @return copy of this instance.
*/
virtual HepRepInstance * copy(HepRepTypeTree * typeTree, HepRepInstance * parent, HepRepSelectFilter * filter = NULL) = 0;
/**
* Returns a deep copy of this instance.
*
* @param typeTree needed to find the associated type.
* @param parent to which the copy is added.
* @param filter run on all instances before copying.
* @return copy of this instance.
*/
virtual HepRepInstance * copy(HepRepTypeTree * typeTree, HepRepInstanceTree * parent, HepRepSelectFilter * filter = NULL) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPINSTANCE_H */
@@ -1,92 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPINSTANCETREE_H
#define HEPREP_HEPREPINSTANCETREE_H 1
// Copyright 2000-2005, FreeHEP.
#include <vector>
#include "HEPREP/HepRepTreeID.h"
namespace HEPREP {
class HepRepInstance;
class HepRepSelectFilter;
class HepRepTreeID;
class HepRepTypeTree;
/**
* HepRepInstanceTree interface.
*
* @author Mark Donszelmann
*/
class HepRepInstanceTree : virtual public HepRepTreeID {
public:
/// Destructor.
virtual ~HepRepInstanceTree() { /* nop */; }
/**
* Overlays the instance tree on the current tree.
*
* The list of instances of the instanceTree has to be the same as the current tree.
*/
virtual void overlay(HepRepInstanceTree * instanceTree) = 0;
/**
* Adds an instance to this instancetree.
*
* @param instance to be added.
*/
virtual void addInstance(HepRepInstance * instance) = 0;
/**
* Removes an instance from this instancetree.
*
* @param instance to be removed.
*/
virtual void removeInstance(HepRepInstance * instance) = 0;
/**
* Returns a collection of instances.
*
* @return collection of HepRepInstances.
*/
virtual std::vector<HepRepInstance *> getInstances() = 0;
/**
* Adds a related instance tree to this instancetree.
*
* @param instanceTree related instancetree.
*/
virtual void addInstanceTree(HepRepTreeID * instanceTree) = 0;
/**
* Returns a collection of associated instance trees.
*
* @return collection of HepRepTreeIDs.
*/
virtual std::vector<HepRepTreeID *> getInstanceTreeList() = 0;
/**
* Returns the associated typetree.
*
* @return TreeID of the associated typetree.
*/
virtual HepRepTreeID * getTypeTree() = 0;
/**
* Returns a deep copy of this instancetree.
*
* @param filter to filter the instances.
* @return copy of this instancetree.
*/
virtual HepRepInstanceTree * copy(HepRepTypeTree * typeTree, HepRepSelectFilter * filter = NULL) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPINSTANCETREE_H */
@@ -1,87 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPITERATOR_H
#define HEPREP_HEPREPITERATOR_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
namespace HEPREP {
class HepRepAttributeListener;
class HepRepFrameListener;
class HepRepInstance;
/**
* HepRepIterator interface.
*
* @author Mark Donszelmann
*/
class HepRepIterator {
public:
/// Destructor.
virtual ~HepRepIterator() { /* nop */; }
/**
* Signals if there is a next instance to iterate to.
*
* @return true if next() can be called.
*/
virtual bool hasNext() = 0;
/**
* Returns next instance.
*
* @return next HepRepInstance.
*/
virtual HepRepInstance * nextInstance() = 0;
/**
* Adds a listener to be informed about attribute changes while iterating.
*
* @param listener to be added.
*/
virtual void addHepRepAttributeListener(std::string name, HepRepAttributeListener * listener) = 0;
/**
* Removes a listener.
*
* @param listener to be removed.
*/
virtual void removeHepRepAttributeListener(std::string name, HepRepAttributeListener * listener) = 0;
/**
* Adds a listener to be informed about attribute changes while iterating.
*
* @param listener to be added.
*/
virtual void addHepRepFrameListener(HepRepFrameListener * listener) = 0;
/**
* Removes a listener.
*
* @param listener to be removed.
*/
virtual void removeHepRepFrameListener(HepRepFrameListener * listener) = 0;
/**
* Returns true if the current instance, just delivered by nextInstance(), is to be drawn as a frame.
*/
virtual bool drawAsFrame() = 0;
/**
* Returns the attValue for key at the current point of iteration.
*
* @param key name of the attribute to be looked up.
* @return value associated to name at this point in the iteration.
*/
// HepRepAttValue* getAttValue(String key);
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPITERATOR_H */
@@ -1,168 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPPOINT_H
#define HEPREP_HEPREPPOINT_H 1
// Copyright 2000-2005, FreeHEP.
#include <vector>
#include "HEPREP/HepRepAttribute.h"
namespace HEPREP {
class HepRepInstance;
/**
* HepRepPoint interface. The HepRepMath class can be used to deal with the conversions.
*
* @author Mark Donszelmann
*/
class HepRepPoint : virtual public HepRepAttribute {
public:
/// Destructor.
virtual ~HepRepPoint() { /* nop */; }
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return dx-coordinate
*/
virtual double getX() = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return dy-coordinate
*/
virtual double getY() = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return dz-coordinate
*/
virtual double getZ() = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return rho = std::sqrt(dx2+dy2);
*/
virtual double getRho() = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return phi = std::atan2(dy, dx);
*/
virtual double getPhi() = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return theta = std::atan2(rho, dx);
*/
virtual double getTheta() = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return r = std::sqrt(dx2+dy2+dz2);
*/
virtual double getR() = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @return eta = -0.5*clog((1.-ct)/(1.+ct)), where ct = .cos(getTheta(dx, dy, dz));
*/
virtual double getEta() = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return dx-coordinate
*/
virtual double getX(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return dy-coordinate
*/
virtual double getY(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return dz-coordinate
*/
virtual double getZ(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return rho = std::sqrt(dx2+dy2);
*/
virtual double getRho(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return phi = std::atan2(dy, dx);
*/
virtual double getPhi(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return theta = std::atan2(rho, dx);
*/
virtual double getTheta(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return r = std::sqrt(dx2+dy2+dz2);
*/
virtual double getR(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (xVertex, yVertex, zVertex).
*
* @return eta = -0.5*clog((1.-ct)/(1.+ct)), where ct = .cos(getTheta(dx, dy, dz));
*/
virtual double getEta(double xVertex, double yVertex, double zVertex) = 0;
/**
* Returns coordinate with respect to vertex at (0, 0, 0).
*
* @param xyz list of three coordinates which are filled and returned.
* If null, a new list of three coordinates is allocated.
* @return list of 3 coordinates.
*/
virtual std::vector<double> * getXYZ(std::vector<double> * xyz) = 0;
/**
* Returns associated instance (parent).
*
* @return HepRepInstance.
*/
virtual HepRepInstance * getInstance() = 0;
/**
* Returns a deep copy of this point.
*
* @param parent to add the copy to.
* @return copy of this point.
*/
virtual HepRepPoint * copy(HepRepInstance * parent) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPPOINT_H */
@@ -1,124 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPREADER_H
#define HEPREP_HEPREPREADER_H 1
// Copyright 2002-2004, Freehep.
#include <string>
#include <vector>
namespace HEPREP {
class HepRep;
/**
* HepRepReader interface.
*
* @author Mark Donszelmann
*/
class HepRepReader {
public:
/// Destructor.
virtual ~HepRepReader() { /* nop */; }
/**
* Returns a property (if set in the heprep.properties file).
*
* @param key property name
* @param defaultValue value if property not found
*/
virtual std::string getProperty(std::string key, std::string defaultValue) = 0;
/**
* Closes the reader and its underlying stream.
*
* @return false in case of a stream problem.
*/
virtual bool close() = 0;
/**
* Allows random access.
*
* @return true if this reader provides random access
*/
virtual bool hasRandomAccess() = 0;
/**
* Reads a HepRep by name (random access only).
*
* @param name for the heprep to be read.
* @return heprep.
*/
virtual HepRep * read(std::string name) = 0;
/**
* Returns the current entry name (random acces only).
*
* @return name of the current entry or null if not supported.
*/
virtual std::string entryName() = 0;
/**
* Returns a list of names of available entries (random rccess only).
* Zip files may contain instructions to skip a number of files. These files
* will not be included in the entries.
*
* @return list of entrynames or null if not supported.
*/
virtual std::vector<std::string> entryNames() = 0;
/**
* Allows for sequential access.
*
* @return true if sequential access is possible.
*/
virtual bool hasSequentialAccess() = 0;
/**
* Resets a sequential HepRep reader.
*
* @return false in case of a stream problem.
*/
virtual bool reset() = 0;
/**
* Returns the (estimated) number of HepReps in the reader.
* Zip files may contain instructions to skip a number of files. These files
* will not be included in the estimate.
*
* @return number of HepReps, or -1 if cannot be calculated.
*/
virtual int size() = 0;
/**
* Skips a number of HepReps in the reader.
* Zip files may contain instructions to skip a number of files. These files
* will not be included in the count to be skipped.
*
* @param n number of HepReps to be skipped.
* @return number of HepReps skipped.
*/
virtual int skip(int n) = 0;
/**
* Is there a next heprep.
*
* @return true if the next heprep is available.
*/
virtual bool hasNext() = 0;
/**
* Reads the next HepRep from the Reader.
*
* @return heprep.
*/
virtual HepRep * next() = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPREADER_H */
@@ -1,36 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPSELECTFILTER_H
#define HEPREP_HEPREPSELECTFILTER_H 1
// Copyright 2000-2005, FreeHEP.
namespace HEPREP {
class HepRepInstance;
/**
* HepRepSelectFilter interface used in copying HepReps.
*
* @author Mark Donszelmann
*/
class HepRepSelectFilter {
public:
/// Destructor.
virtual ~HepRepSelectFilter() { /* nop */; }
/**
* Selects if the given instance will pass.
*
* @param instance to be checked.
* @return true if instance passes.
*/
virtual bool select(HepRepInstance * instance) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPSELECTFILTER_H */
@@ -1,64 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPTREEID_H
#define HEPREP_HEPREPTREEID_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
namespace HEPREP {
/**
* HepRepTreeID interface.
*
* @author Mark Donszelmann
*/
class HepRepTreeID {
public:
/// Destructor.
virtual ~HepRepTreeID() { /* nop */; }
/**
* Returns the name of this treeID.
*
* @return name of treeID.
*/
virtual std::string getName() = 0;
/**
* Returns the version of this treeID.
*
* @return version of treeID.
*/
virtual std::string getVersion() = 0;
/**
* Returns the qualifier that qualifies the relation that this treeID has with what it refers to.
*
* @return qualifier.
*/
virtual std::string getQualifier() = 0;
/**
* Sets the qualifier that qualifies the relation that this treeID has with what it refers to.
*
* @param qualifier to be set.
*/
virtual void setQualifier(std::string qualifier) = 0;
/**
* Returns a deep copy of this treeID.
*
* @return copy of this treeID.
* @throws CloneNotSupportedException if copying is not possible.
*/
// HepRepTreeID* copy() throws CloneNotSupportedException;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPTREEID_H */
@@ -1,109 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPTYPE_H
#define HEPREP_HEPREPTYPE_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
#include <vector>
#include "HEPREP/HepRepDefinition.h"
namespace HEPREP {
/**
* HepRepType interface.
*
* @author Mark Donszelmann
*/
class HepRepType : virtual public HepRepDefinition {
public:
/// Destructor.
virtual ~HepRepType() { /* nop */; }
/**
* Adds a sub-type to this type.
*
* @param type sub-type to be added.
*/
virtual void addType(HepRepType * type) = 0;
/**
* Returns the name of this type.
* This is the full name if one uses flat-types, and the node name if one
* uses hierarchical typenames. It is the name supplied at construction of the type.
*
* @return name of type.
* @see #getFullName()
*/
virtual std::string getName() = 0;
/**
* Returns the full name of this type.
* The full name is constructed from the root of the typeTree (without the typeTreeName)
* by concatenating all the node names separated by slashes "/". For example:
* Geometry/InnerDetector/Sector24/Wire20
*
* @return full name of type.
* @see #getName()
*/
virtual std::string getFullName() = 0;
/**
* Returns the description of this type.
*
* @return description of type.
*/
virtual std::string getDescription() = 0;
/**
* Sets the description of this type.
*
* @param infoURL
*/
virtual void setDescription(std::string description) = 0;
/**
* Returns the information URL of this type.
*
* @return info URL of type.
*/
virtual std::string getInfoURL() = 0;
/**
* Sets the information URL of this type.
*
* @param infoURL
*/
virtual void setInfoURL(std::string infoURL) = 0;
/**
* Returns the parent of this type.
*
* @return parent of type, or null if top-level.
*/
virtual HepRepType * getSuperType() = 0;
/**
* Returns a collection of all the sub-types of this type.
*
* @return collection of HepRepTypes.
*/
virtual std::vector<HepRepType *> getTypeList() = 0;
/**
* Returns a deep copy of this type.
*
* @param parent to which this copy is added.
* @return copy of this type.
*/
virtual HepRepType * copy(HepRepType * parent) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPTYPE_H */
@@ -1,66 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPTYPETREE_H
#define HEPREP_HEPREPTYPETREE_H 1
// Copyright 2000-2005, FreeHEP.
#include <string>
#include <vector>
#include "HEPREP/HepRepTreeID.h"
namespace HEPREP {
class HepRepType;
/**
* HepRepTypeTree interface.
*
* @author Mark Donszelmann
*/
class HepRepTypeTree : virtual public HepRepTreeID {
public:
/// Destructor.
virtual ~HepRepTypeTree() { /* nop */; }
/**
* Adds a type to this typetree.
*
* @param type to be added.
*/
virtual void addType(HepRepType * type) = 0;
/**
* Returns a collection of all types in this tree.
*
* @return collection of HepRepTypes.
*/
virtual std::vector<HepRepType *> getTypeList() = 0;
/**
* Returns type
*/
virtual HepRepType * getType(std::string fullName) = 0;
/**
* Returns a deep copy of this typetree.
*
* @return copy of this typetree.
*/
virtual HepRepTypeTree * copy() = 0;
//
// To be enable in g++ 3.0
// using HepRep::HepRepTreeID::copy;
// To be disabled in g++ 3.0
// HepRepTreeID * copy();
//
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPTYPETREE_H */
@@ -1,34 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPVIEWER_H
#define HEPREP_HEPREPVIEWER_H 1
// Copyright 2000-2005, FreeHEP.
namespace HEPREP {
class HepRep;
/**
* The HepRepViewer interface.
*
* @author Mark Donszelmann
*/
class HepRepViewer {
public:
/// Destructor.
virtual ~HepRepViewer() { /* nop */; }
/**
* Display a heprep
*
*/
virtual void display(HepRep heprep) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPVIEWER_H */
@@ -1,163 +0,0 @@
// -*- C++ -*-
// AID-GENERATED
// =========================================================================
// This class was generated by AID - Abstract Interface Definition
// DO NOT MODIFY, but use the org.freehep.aid.Aid utility to regenerate it.
// =========================================================================
#ifndef HEPREP_HEPREPWRITER_H
#define HEPREP_HEPREPWRITER_H 1
// Copyright 2002-2005, Freehep.
#include <string>
#include <vector>
namespace HEPREP {
class HepRep;
class HepRepAction;
class HepRepAttDef;
class HepRepAttValue;
class HepRepAttribute;
class HepRepDefinition;
class HepRepInstance;
class HepRepInstanceTree;
class HepRepPoint;
class HepRepTreeID;
class HepRepType;
class HepRepTypeTree;
/**
* HepRepWriter interface.
*
* @author Mark Donszelmann
*/
class HepRepWriter {
public:
/// Destructor.
virtual ~HepRepWriter() { /* nop */; }
/**
* Adds a property, to be written to the HepRep file when closed.
*
* @param key
* @param value
* @return false in case of a stream problem.
*/
virtual bool addProperty(std::string key, std::string value) = 0;
/**
* Closes the writer and its underlying stream.
*
* @return false in case of a stream problem.
*/
virtual bool close() = 0;
/**
* Writes a HepRep.
*
* @param heprep to be written.
* @param name for the heprep to be written (for tagged access), may be ommited.
* @return false in case of a stream problem.
*/
virtual bool write(HepRep * heprep, std::string name) = 0;
/**
* Writes the layerOrder.
*
* @param layerOrder to be written.
* @return false in case of a stream problem.
*/
virtual bool write(std::vector<std::string> layerOrder) = 0;
/**
* Writes a HepRepTypeTree.
*
* @param typeTree to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepTypeTree * typeTree) = 0;
/**
* Writes a HepRepType.
*
* @param type to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepType * type) = 0;
/**
* Writes a HepRepTreeID.
*
* @param treeID to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepTreeID * treeID) = 0;
/**
* Writes a HepRepAction.
*
* @param action to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepAction * action) = 0;
/**
* Writes a HepRepInstanceTree.
*
* @param instanceTree to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepInstanceTree * instanceTree) = 0;
/**
* Writes a HepRepInstance.
*
* @param instance to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepInstance * instance) = 0;
/**
* Writes a HepRepPoint.
*
* @param point to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepPoint * point) = 0;
/**
* Writes a HepRepAttribute.
*
* @param attribute to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepAttribute * attribute) = 0;
/**
* Writes a HepRepDefinition.
*
* @param definition to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepDefinition * definition) = 0;
/**
* Writes a HepRepAttValue.
*
* @param attValue to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepAttValue * attValue) = 0;
/**
* Writes a HepRepAttDef.
*
* @param attDef to be written.
* @return false in case of a stream problem.
*/
virtual bool write(HepRepAttDef * attDef) = 0;
}; // class
} // namespace HEPREP
#endif /* ifndef HEPREP_HEPREPWRITER_H */
@@ -1,36 +0,0 @@
#ifndef HEPREP_TYPES_H
#define HEPREP_TYPES_H 1
namespace HEPREP {
#if defined(WIN32) && !defined(GNU_GCC)
// WIN32 and NOT GNU_GCC
typedef long int32;
typedef __int64 int64;
#define HEPREP_INT32_FORMAT "%d"
#define HEPREP_INT64_FORMAT "%ld"
#else // other than WIN32-MSVC
#if defined(_LP64)
// 64 Bit Platforms
typedef int int32;
typedef long int64;
#define HEPREP_INT32_FORMAT "%d"
#define HEPREP_INT64_FORMAT "%ld"
#else
// 32-Bit Platforms
typedef long int32;
typedef long long int64;
#define HEPREP_INT32_FORMAT "%ld"
#define HEPREP_INT64_FORMAT "%lld"
#endif // 32-Bit Platforms
#endif // other than WIN32-MSVC
} // namespace HEPREP
#endif
@@ -1 +0,0 @@
source = freehep-heprep-2.0.1
@@ -1,23 +0,0 @@
Apart from the heprep1 files:
G4HepRepFile.hh
G4HepRepFileSceneHandler.hh
G4HepRepFileViewer.hh
G4HepRepFileXMLWriter.hh
and heprep2 files:
G4HepRep.hh
G4HepRepSceneHandler.hh
G4HepRepMessenger.hh
G4HepRepViewer.hh
the other sources are copies from the FreeHEP library
(java.freehep.org) and are maintained there.
The files starting with G4 are geant4 compliant, the others may not be.
Changes made here may be overwritten.
4 May 2005
Mark Donszelmann
@@ -1,47 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef ABSTRACTXMLWRITER_H
#define ABSTRACTXMLWRITER_H 1
#include "cheprep/config.h"
#include <string>
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class AbstractXMLWriter {
public:
AbstractXMLWriter(std::string aDefaultNameSpace) : defaultNameSpace(aDefaultNameSpace) {
}
virtual ~AbstractXMLWriter() {
}
virtual void openTag(std::string ns, std::string name) = 0;
virtual void printTag(std::string ns, std::string name) = 0;
virtual void setAttribute(std::string ns, std::string name, std::string value) = 0;
virtual void setAttribute(std::string ns, std::string name, double value) = 0;
virtual void close() = 0;
virtual void openDoc(std::string version = "1.0", std::string encoding = "", bool standalone = false) = 0;
virtual void closeDoc(bool force = false) = 0;
virtual void openTag(std::string name) = 0;
virtual void closeTag() = 0;
virtual void printTag(std::string name) = 0;
virtual void setAttribute(std::string name, char* value) = 0;
virtual void setAttribute(std::string name, std::string value) = 0;
virtual void setAttribute(std::string name, std::vector<double> value) = 0;
virtual void setAttribute(std::string name, int64 value) = 0;
virtual void setAttribute(std::string name, int value) = 0;
virtual void setAttribute(std::string name, bool value) = 0;
virtual void setAttribute(std::string name, double value) = 0;
protected:
std::string defaultNameSpace;
};
} // cheprep
#endif // ABSTRACTXMLWRITER_H
@@ -1,130 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_BHEPREPWRITER_H
#define CHEPREP_BHEPREPWRITER_H
#include "cheprep/config.h"
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include "cheprep/AbstractXMLWriter.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class BHepRepWriter : public AbstractXMLWriter {
public:
BHepRepWriter(std::ostream& os);
virtual ~BHepRepWriter();
void close();
void openDoc(std::string version = "BinaryHepRep/1.0", std::string encoding = "UTF-8", bool standalone = false);
void closeDoc(bool force = false);
void openTag(std::string name);
void closeTag();
void printTag(std::string name);
void setAttribute(std::string name, char* value);
void setAttribute(std::string name, std::string value);
void setAttribute(std::string name, std::vector<double> value);
void setAttribute(std::string name, int64 value);
void setAttribute(std::string name, int value);
void setAttribute(std::string name, bool value);
void setAttribute(std::string name, double value);
//
// Can be removed when we can properly inherit those (since names are equal to overloaded ones).
//
void openTag(std::string ns, std::string name) {
openTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
}
void printTag(std::string ns, std::string name) {
printTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
}
void setAttribute(std::string ns, std::string name, std::string value) {
setAttribute(ns.append(":").append(name), value);
}
void setAttribute(std::string ns, std::string name, double value) {
setAttribute(ns.append(":").append(name), value);
}
private:
static const unsigned char WBXML_VERSION = 0x03;
static const unsigned char UNKNOWN_PID = 0x01;
static const unsigned char UTF8 = 0x6a;
// standard tags
static const unsigned char SWITCH_PAGE = 0x00;
static const unsigned char END = 0x01;
static const unsigned char ENTITY = 0x02;
static const unsigned char STR_I = 0x03;
static const unsigned char LITERAL = 0x04;
static const unsigned char CONTENT = 0x40;
static const unsigned char EXT_I_0 = 0x40;
static const unsigned char EXT_I_1 = 0x41;
static const unsigned char EXT_I_2 = 0x42;
static const unsigned char PI = 0x43;
static const unsigned char LITERAL_C = 0x44;
static const unsigned char ATTRIBUTE = 0x80;
static const unsigned char EXT_T_0 = 0x80;
static const unsigned char EXT_T_1 = 0x81;
static const unsigned char EXT_T_2 = 0x82;
static const unsigned char STR_T = 0x83;
static const unsigned char LITERAL_A = 0x84;
static const unsigned char EXT_0 = 0xC0;
static const unsigned char EXT_1 = 0xC1;
static const unsigned char EXT_2 = 0xC2;
static const unsigned char OPAQUE = 0xC3;
static const unsigned char LITERAL_AC = 0xC4;
// our own extensions
static const unsigned char STR_D = EXT_I_0;
static const unsigned char STR_R = EXT_T_0;
// class definitions
static std::map<std::string, unsigned char> tags;
static std::map<std::string, unsigned char> attributes;
static std::map<std::string, unsigned char> values;
// outputstream variables
std::ostream& os;
bool singlePrecision;
bool isBigEndian;
// document variables
std::map<std::string, unsigned int> stringValues;
// tag variables
std::map<std::string, std::string> stringAttributes;
std::map<std::string, std::vector<double> > colorAttributes;
std::map<std::string, int64> longAttributes;
std::map<std::string, int> intAttributes;
std::map<std::string, bool> booleanAttributes;
std::map<std::string, double> doubleAttributes;
// point array
std::vector<double> points;
// methods
void writeTag(std::string name, bool content = false);
void writePoints();
void writeStringDefine(std::string s);
void writeMultiByteInt(unsigned int ui);
void writeReal(double ui);
void writeLong(int64 i);
void writeInt(int i);
void writeByte(unsigned char b);
void writeString(std::string s);
};
} // cheprep
#endif // CHEPREP_BHEPREPWRITER_H
@@ -1,62 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREP_H
#define CHEPREP_DEFAULTHEPREP_H 1
#include "cheprep/config.h"
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepSelectFilter.h"
#include "HEPREP/HepRepWriter.h"
#include "HEPREP/HepRepType.h"
#include "HEPREP/HepRepTypeTree.h"
#include "HEPREP/HepRepInstanceTree.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRep : public virtual HEPREP::HepRep {
private:
std::vector<std::string> layers;
std::vector<HEPREP::HepRepTypeTree*> typeTrees;
std::vector<HEPREP::HepRepInstanceTree*> instanceTrees;
public:
DefaultHepRep();
~DefaultHepRep();
HEPREP::HepRep* copy(HEPREP::HepRepSelectFilter* filter);
std::vector<std::string> getLayerOrder();
void addLayer(std::string layer);
void addTypeTree(HEPREP::HepRepTypeTree* typeTree);
void removeTypeTree(HEPREP::HepRepTypeTree* typeTree);
HEPREP::HepRepTypeTree* getTypeTree(std::string name, std::string version);
std::vector<HEPREP::HepRepTypeTree*> getTypeTreeList();
void addInstanceTree(HEPREP::HepRepInstanceTree* instanceTree);
void overlayInstanceTree(HEPREP::HepRepInstanceTree * instanceTree);
void removeInstanceTree(HEPREP::HepRepInstanceTree* instanceTree);
HEPREP::HepRepInstanceTree* getInstanceTreeTop(std::string name, std::string version);
HEPREP::HepRepInstanceTree* getInstances(std::string name, std::string version,
std::vector<std::string> typeNames);
HEPREP::HepRepInstanceTree* getInstancesAfterAction(
std::string name,
std::string version,
std::vector<std::string> typeNames,
std::vector<HEPREP::HepRepAction*> actions,
bool getPoints,
bool getDrawAtts,
bool getNonDrawAtts,
std::vector<std::string> invertAtts);
std::string checkForException();
std::vector<HEPREP::HepRepInstanceTree*> getInstanceTreeList();
};
} // cheprep
#endif
@@ -1,34 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPACTION_H
#define CHEPREP_DEFAULTHEPREPACTION_H 1
#include "cheprep/config.h"
#include <string>
#include "HEPREP/HepRepAction.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepAction : public virtual HEPREP::HepRepAction {
private:
std::string name;
std::string expression;
public:
DefaultHepRepAction(std::string name, std::string expression);
~DefaultHepRepAction();
std::string getName();
std::string getExpression();
HEPREP::HepRepAction* copy();
};
} // cheprep
#endif
@@ -1,36 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPATTDEF_H
#define CHEPREP_DEFAULTHEPREPATTDEF_H 1
#include "cheprep/config.h"
#include <string>
#include "HEPREP/HepRepAttDef.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepAttDef : public virtual HEPREP::HepRepAttDef {
private:
std::string name, desc, category, extra;
public:
DefaultHepRepAttDef(std::string name, std::string desc, std::string category, std::string extra);
~DefaultHepRepAttDef();
HEPREP::HepRepAttDef* copy();
std::string getName();
std::string getLowerCaseName();
std::string getDescription();
std::string getCategory();
std::string getExtra();
};
} // cheprep
#endif
@@ -1,75 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPATTVALUE_H
#define CHEPREP_DEFAULTHEPREPATTVALUE_H 1
#include "cheprep/config.h"
#include <string>
#include "HEPREP/HepRepAttValue.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepAttValue : public virtual HEPREP::HepRepAttValue {
private:
enum { LABELSTRINGS_LEN = 4 };
std::string name;
int type;
// values implemented as separate items, so that they do not take up unnecessary space for an Object
// only ONE of these is filled
std::string stringValue;
int64 longValue;
double doubleValue;
bool booleanValue;
std::vector<double> colorValue;
int showLabelValue;
static std::string labelStrings[LABELSTRINGS_LEN];
void init();
public:
DefaultHepRepAttValue(std::string name, std::string value, int showLabel);
DefaultHepRepAttValue(std::string name, int64 value, int showLabel);
DefaultHepRepAttValue(std::string name, int value, int showLabel);
DefaultHepRepAttValue(std::string name, double value, int showLabel);
DefaultHepRepAttValue(std::string name, bool value, int showLabel);
DefaultHepRepAttValue(std::string name, std::vector<double> value, int showLabel);
~DefaultHepRepAttValue();
HEPREP::HepRepAttValue* copy();
std::string getName();
std::string getLowerCaseName();
int getType();
std::string getTypeName();
int showLabel();
std::string getString();
std::string getLowerCaseString();
int64 getLong();
int getInteger();
double getDouble();
bool getBoolean();
std::vector<double> getColor();
std::string getAsString();
static std::string getAsString(std::vector<double> c);
static std::string getAsString(int i);
static std::string getAsString(int64 i);
static std::string getAsString(double d);
static std::string getAsString(bool b);
std::string toShowLabel();
static std::string toShowLabel(int showLabel);
};
} // cheprep
#endif
@@ -1,50 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPATTRIBUTE_H
#define CHEPREP_DEFAULTHEPREPATTRIBUTE_H 1
#include "cheprep/config.h"
#include <string>
#include <map>
#include <set>
#include <vector>
#include "HEPREP/HepRepAttribute.h"
#include "HEPREP/HepRepAttValue.h"
#include "HEPREP/HepRepConstants.h"
#include "HEPREP/HepRepWriter.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepAttribute : public virtual HEPREP::HepRepAttribute {
private:
std::map<std::string, HEPREP::HepRepAttValue*> attValues;
public:
DefaultHepRepAttribute();
~DefaultHepRepAttribute();
std::set<HEPREP::HepRepAttValue*> getAttValuesFromNode();
void addAttValue(HEPREP::HepRepAttValue* hepRepAttValue);
void addAttValue(std::string key, char *value, int showLabel);
void addAttValue(std::string key, std::string value, int showLabel);
void addAttValue(std::string key, int value, int showLabel);
void addAttValue(std::string key, int64 value, int showLabel);
void addAttValue(std::string key, double value, int showLabel);
void addAttValue(std::string key, bool value, int showLabel);
void addAttValue(std::string key, std::vector<double> value, int showLabel);
void addAttValue(std::string key, double red, double green, double blue, double alpha, int showLabel);
HEPREP::HepRepAttValue* getAttValueFromNode(std::string lowerCaseName);
HEPREP::HepRepAttValue* removeAttValue(std::string key);
HEPREP::HepRepAttValue* getAttValue(std::string name) = 0;
};
} // cheprep
#endif
@@ -1,42 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPDEFINITION_H
#define CHEPREP_DEFAULTHEPREPDEFINITION_H 1
#include "cheprep/config.h"
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRepDefinition.h"
#include "HEPREP/HepRepWriter.h"
#include "DefaultHepRepAttribute.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepDefinition : public DefaultHepRepAttribute, public virtual HEPREP::HepRepDefinition {
private:
std::map<std::string, HEPREP::HepRepAttDef*> attDefs;
public:
DefaultHepRepDefinition();
~DefaultHepRepDefinition();
void addAttDef(HEPREP::HepRepAttDef* hepRepAttDef);
void addAttDef(std::string name, std::string desc, std::string type, std::string extra);
std::set<HEPREP::HepRepAttDef *> getAttDefsFromNode();
HEPREP::HepRepAttDef* getAttDefFromNode(std::string lowerCaseName);
HEPREP::HepRepAttDef* getAttDef(std::string name) = 0;
HEPREP::HepRepAttValue* getAttValue(std::string name) = 0;
};
} // cheprep
#endif
@@ -1,54 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPFACTORY_H
#define CHEPREP_DEFAULTHEPREPFACTORY_H 1
#include "cheprep/config.h"
#include <string>
#include <iostream>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepFactory.h"
#include "HEPREP/HepRepReader.h"
#include "HEPREP/HepRepWriter.h"
#include "HEPREP/HepRepPoint.h"
#include "HEPREP/HepRepInstance.h"
#include "HEPREP/HepRepInstanceTree.h"
#include "HEPREP/HepRepTreeID.h"
#include "HEPREP/HepRepAction.h"
#include "HEPREP/HepRepType.h"
#include "HEPREP/HepRepTypeTree.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepFactory : public virtual HEPREP::HepRepFactory {
public:
DefaultHepRepFactory();
~DefaultHepRepFactory();
// static HEPREP::HepRepFactory* create();
HEPREP::HepRepReader* createHepRepReader (std::istream* in);
HEPREP::HepRepReader* createHepRepReader (std::string filename);
HEPREP::HepRepWriter* createHepRepWriter (std::ostream* out, bool randomAccess, bool compress);
HEPREP::HepRepPoint* createHepRepPoint (HEPREP::HepRepInstance* instance,
double x, double y, double z);
HEPREP::HepRepInstance* createHepRepInstance (HEPREP::HepRepInstance* parent, HEPREP::HepRepType* type);
HEPREP::HepRepInstance* createHepRepInstance (HEPREP::HepRepInstanceTree* parent, HEPREP::HepRepType* type);
HEPREP::HepRepTreeID* createHepRepTreeID (std::string name, std::string version, std::string qualifier = "top-level");
HEPREP::HepRepAction* createHepRepAction (std::string name, std::string expression);
HEPREP::HepRepInstanceTree* createHepRepInstanceTree (std::string name, std::string version,
HEPREP::HepRepTreeID* typeTreeID);
HEPREP::HepRepType* createHepRepType (HEPREP::HepRepType* parent, std::string name);
HEPREP::HepRepType* createHepRepType (HEPREP::HepRepTypeTree* parent, std::string name);
HEPREP::HepRepTypeTree* createHepRepTypeTree (HEPREP::HepRepTreeID* treeID);
HEPREP::HepRep* createHepRep ();
};
} // cheprep
#endif
@@ -1,58 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPINSTANCE_H
#define CHEPREP_DEFAULTHEPREPINSTANCE_H 1
#include "cheprep/config.h"
#include <string>
#include <vector>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepSelectFilter.h"
#include "HEPREP/HepRepInstanceTree.h"
#include "HEPREP/HepRepInstance.h"
#include "HEPREP/HepRepWriter.h"
#include "HEPREP/HepRepType.h"
#include "HEPREP/HepRepPoint.h"
#include "HEPREP/HepRepAttValue.h"
#include "DefaultHepRepAttribute.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepInstance : public DefaultHepRepAttribute, public virtual HEPREP::HepRepInstance {
private:
HEPREP::HepRepInstance* parent;
HEPREP::HepRepType* type;
std::vector<HEPREP::HepRepPoint*> points;
std::vector<HEPREP::HepRepInstance*> instances;
public:
DefaultHepRepInstance(HEPREP::HepRepInstance* parent, HEPREP::HepRepType* type);
DefaultHepRepInstance(HEPREP::HepRepInstanceTree* parent, HEPREP::HepRepType* type);
~DefaultHepRepInstance();
void overlay(HEPREP::HepRepInstance * instance);
HEPREP::HepRepInstance* copy(HEPREP::HepRepTypeTree* typeTree, HEPREP::HepRepInstance* parent, HEPREP::HepRepSelectFilter* filter);
HEPREP::HepRepInstance* copy(HEPREP::HepRepTypeTree* typeTree, HEPREP::HepRepInstanceTree* parent, HEPREP::HepRepSelectFilter* filter);
HEPREP::HepRepType* getType();
void addPoint(HEPREP::HepRepPoint* point);
std::vector<HEPREP::HepRepPoint *> getPoints();
HEPREP::HepRepInstance* getSuperInstance();
void addInstance(HEPREP::HepRepInstance* instance);
void removeInstance(HEPREP::HepRepInstance* instance);
std::vector<HEPREP::HepRepInstance *> getInstances();
HEPREP::HepRepAttValue* getAttValue(std::string name);
void *getParent() { return parent; }
};
} // cheprep
#endif
@@ -1,49 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPINSTANCETREE_H
#define CHEPREP_DEFAULTHEPREPINSTANCETREE_H 1
#include "cheprep/config.h"
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepSelectFilter.h"
#include "HEPREP/HepRepInstanceTree.h"
#include "HEPREP/HepRepInstance.h"
#include "HEPREP/HepRepWriter.h"
#include "HEPREP/HepRepTreeID.h"
#include "DefaultHepRepTreeID.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepInstanceTree : public DefaultHepRepTreeID, public virtual HEPREP::HepRepInstanceTree {
private:
HEPREP::HepRepTreeID* typeTree;
std::vector<HEPREP::HepRepInstance*> instances;
std::vector<HEPREP::HepRepTreeID*> instanceTrees;
public:
DefaultHepRepInstanceTree(std::string name, std::string version, HEPREP::HepRepTreeID* typeTree);
~DefaultHepRepInstanceTree();
void overlay(HEPREP::HepRepInstanceTree * instanceTree);
HEPREP::HepRepInstanceTree* copy(HEPREP::HepRepTypeTree* typeTree, HEPREP::HepRepSelectFilter* filter);
void addInstance(HEPREP::HepRepInstance* instance);
void removeInstance(HEPREP::HepRepInstance* instance);
std::vector<HEPREP::HepRepInstance*> getInstances();
void addInstanceTree(HEPREP::HepRepTreeID* treeID);
HEPREP::HepRepTreeID* getTypeTree();
std::vector<HEPREP::HepRepTreeID*> getInstanceTreeList();
};
} // cheprep
#endif
@@ -1,61 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPPOINT_H
#define CHEPREP_DEFAULTHEPREPPOINT_H 1
#include "cheprep/config.h"
#include <string>
#include <vector>
#include "HEPREP/HepRepInstance.h"
#include "HEPREP/HepRepWriter.h"
#include "HEPREP/HepRepAttValue.h"
#include "HEPREP/HepRepPoint.h"
#include "DefaultHepRepAttribute.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepPoint : public DefaultHepRepAttribute, public virtual HEPREP::HepRepPoint {
private:
HEPREP::HepRepInstance* instance;
protected:
double x, y, z;
public:
DefaultHepRepPoint(HEPREP::HepRepInstance* instance, double x, double y, double z);
~DefaultHepRepPoint();
HEPREP::HepRepInstance* getInstance();
HEPREP::HepRepAttValue* getAttValue(std::string lowerCaseName);
HEPREP::HepRepPoint* copy(HEPREP::HepRepInstance* parent);
double getX();
double getY();
double getZ();
std::vector<double>* getXYZ(std::vector<double>* xyz);
double getRho();
double getPhi();
double getTheta();
double getR();
double getEta();
double getX(double xVertex, double yVertex, double zVertex);
double getY(double xVertex, double yVertex, double zVertex);
double getZ(double xVertex, double yVertex, double zVertex);
double getRho(double xVertex, double yVertex, double zVertex);
double getPhi(double xVertex, double yVertex, double zVertex);
double getTheta(double xVertex, double yVertex, double zVertex);
double getR(double xVertex, double yVertex, double zVertex);
double getEta(double xVertex, double yVertex, double zVertex);
};
} // cheprep
#endif
@@ -1,36 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPTREEID_H
#define CHEPREP_DEFAULTHEPREPTREEID_H 1
#include "cheprep/config.h"
#include <string>
#include "HEPREP/HepRepTreeID.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepTreeID : public virtual HEPREP::HepRepTreeID {
private:
std::string name;
std::string version;
std::string qualifier;
public:
DefaultHepRepTreeID(std::string name, std::string version, std::string qualifier = "top_level");
~DefaultHepRepTreeID();
std::string getQualifier();
void setQualifier(std::string qualifier);
std::string getName();
std::string getVersion();
};
} // cheprep
#endif
@@ -1,55 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPTYPE_H
#define CHEPREP_DEFAULTHEPREPTYPE_H 1
#include "cheprep/config.h"
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepType.h"
#include "HEPREP/HepRepAttDef.h"
#include "HEPREP/HepRepAttValue.h"
#include "HEPREP/HepRepWriter.h"
#include "DefaultHepRepDefinition.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepType : public DefaultHepRepDefinition, public virtual HEPREP::HepRepType {
private:
HEPREP::HepRepType* parent;
std::vector<HEPREP::HepRepType*> types;
std::string name;
std::string description;
std::string infoURL;
public:
DefaultHepRepType(HEPREP::HepRepType* parent, std::string name);
DefaultHepRepType(HEPREP::HepRepTypeTree* parent, std::string name);
~DefaultHepRepType();
HEPREP::HepRepType* getSuperType();
HEPREP::HepRepAttDef* getAttDef(std::string name);
HEPREP::HepRepAttValue* getAttValue(std::string name);
HEPREP::HepRepType* copy(HEPREP::HepRepType* parent);
std::string getName();
std::string getFullName();
std::string getDescription();
void setDescription(std::string description);
std::string getInfoURL();
void setInfoURL(std::string infoURL);
void addType(HEPREP::HepRepType* type);
std::vector<HEPREP::HepRepType*> getTypeList();
};
} // cheprep
#endif
@@ -1,42 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFAULTHEPREPTYPETREE_H
#define CHEPREP_DEFAULTHEPREPTYPETREE_H 1
#include "cheprep/config.h"
#include <string>
#include <vector>
#include <set>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepTypeTree.h"
#include "HEPREP/HepRepType.h"
#include "HEPREP/HepRepWriter.h"
#include "HEPREP/HepRepTreeID.h"
#include "DefaultHepRepTreeID.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DefaultHepRepTypeTree : public DefaultHepRepTreeID, public virtual HEPREP::HepRepTypeTree {
private:
std::vector<HEPREP::HepRepType*> types;
public:
DefaultHepRepTypeTree(HEPREP::HepRepTreeID* typeTree);
~DefaultHepRepTypeTree();
HEPREP::HepRepTypeTree* copy();
void addType(HEPREP::HepRepType* type);
std::vector<HEPREP::HepRepType* > getTypeList();
HEPREP::HepRepType* getType(std::string name);
};
} // cheprep
#endif
@@ -1,98 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_DEFLATEOUTPUTSTREAMBUF_H
#define CHEPREP_DEFLATEOUTPUTSTREAMBUF_H
#include <vector>
#include <iostream>
#include <string>
#include <cstdio>
#ifndef CHEPREP_NO_ZLIB
#include <zlib.h>
#endif // CHEPREP_NO_ZLIB
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class DeflateOutputStreamBuffer : public std::streambuf {
public:
DeflateOutputStreamBuffer(std::streambuf *buffer);
void init(bool compress);
void finish();
virtual ~DeflateOutputStreamBuffer();
protected:
int overflow(int c = EOF);
#ifndef CHEPREP_NO_ZLIB
bool flushOut();
#endif // CHEPREP_NO_ZLIB
inline void putUI(unsigned int ui) {
unsigned char* ucp = reinterpret_cast<unsigned char *>(&ui);
unsigned int i = (static_cast<unsigned int>(ucp[ 3 ]) << 24) +
(static_cast<unsigned int>(ucp[ 2 ]) << 16) +
(static_cast<unsigned int>(ucp[ 1 ]) << 8 ) +
(static_cast<unsigned int>(ucp[ 0 ]));
buffer->sputn(reinterpret_cast<char *>(&i), sizeof(unsigned int));
}
inline void putUS(unsigned short us) {
unsigned char* ucp = reinterpret_cast<unsigned char *>(&us);
unsigned short s = (static_cast<unsigned short>(ucp[ 1 ]) << 8 ) +
(static_cast<unsigned short>(ucp[ 0 ]));
buffer->sputn(reinterpret_cast<char *>(&s), sizeof(unsigned short));
}
inline void putUB(unsigned char ub) {
buffer->sputc(ub);
}
inline void putS(const std::string s) {
buffer->sputn(s.c_str(), s.length());
}
inline std::streampos pos() {
std::ostream os(buffer);
return os.tellp();
}
inline unsigned int getSize() {
return size;
}
inline unsigned int getCRC() {
return crc;
}
private:
static unsigned long crctable[256];
std::streambuf *buffer;
unsigned int crc;
unsigned int size;
#ifndef CHEPREP_NO_ZLIB
static const unsigned int inSize = 1000;
static const unsigned int outSize = 1000;
z_stream zStream;
bool zStreamOpen;
std::vector<char> in;
std::vector<char> out;
#endif // CHEPREP_NO_ZLIB
};
} // cheprep
#endif // CHEPREP_DEFLATEOUTPUTSTREAMBUF_H
@@ -1,33 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_GZIPOUTPUTSTREAM_H
#define CHEPREP_GZIPOUTPUTSTREAM_H
#include <string>
#include "cheprep/GZIPOutputStreamBuffer.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class GZIPOutputStream : public std::ostream {
public:
GZIPOutputStream(std::ostream &os);
void setFilename(const std::string &filename);
void setComment(const std::string &comment);
void close();
virtual ~GZIPOutputStream();
private:
GZIPOutputStreamBuffer *buffer;
};
} // cheprep.
#endif // CHEPREP_GZIPOUTPUTSTREAM_H
@@ -1,41 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_GZIPOUTPUTSTREAMBUF_H
#define CHEPREP_GZIPOUTPUTSTREAMBUF_H
#include <string>
#include "cheprep/DeflateOutputStreamBuffer.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class GZIPOutputStreamBuffer : public DeflateOutputStreamBuffer {
public:
GZIPOutputStreamBuffer( std::streambuf *outbuf );
int overflow(int);
void setFilename( const std::string &filename );
void setComment( const std::string &comment );
void close() ;
virtual ~GZIPOutputStreamBuffer() ;
private:
void writeHeader();
void writeTrailer();
std::string filename;
std::string comment;
bool open;
};
} // cheprep
#endif // CHEPREP_GZIPOUTPUTSTREAMBUF_H
@@ -1,54 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_INDENTPRINTWRITER_H
#define CHEPREP_INDENTPRINTWRITER_H 1
#include "cheprep/config.h"
#include <iostream>
#include <string>
/**
* A PrintWriter that keeps track of an indentation level
* and indents the output appropriately.
*
* <b>Warning:</b> Only print and println methods taking strings have been overriden,
* print, println methods taking other arguments may not be indented properly.
*
* @author Mark Donszelmann
*/
namespace cheprep {
class IndentPrintWriter {
public:
IndentPrintWriter(std::ostream* out, int level = 0);
virtual ~IndentPrintWriter();
void close();
IndentPrintWriter& operator<< (const std::string & s);
IndentPrintWriter& operator<< (std::ostream& (*pf)(std::ostream&));
void println(const std::string & s);
void print(const std::string & s);
void println();
void indent();
void outdent();
int getIndent() const;
void setIndent(const int level);
std::string getIndentString() const;
void setIndentString(const std::string & indentString);
private:
void doIndent();
std::ostream* out;
bool closed;
int indentLevel;
bool indented;
std::string indentString;
};
} // cheprep
#endif
@@ -1,32 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef XMLHEPREPFACTORY_H
#define XMLHEPREPFACTORY_H 1
#include <string>
#include <iostream>
#include "HEPREP/HepRepReader.h"
#include "HEPREP/HepRepWriter.h"
#include "DefaultHepRepFactory.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class XMLHepRepFactory : public DefaultHepRepFactory {
public:
XMLHepRepFactory();
~XMLHepRepFactory();
HEPREP::HepRepReader* createHepRepReader (std::istream* in);
HEPREP::HepRepReader* createHepRepReader (std::string filename);
HEPREP::HepRepWriter* createHepRepWriter (std::ostream* out, bool randomAccess, bool compress);
};
} // cheprep
#endif
@@ -1,72 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_XMLHEPREPWRITER_H
#define CHEPREP_XMLHEPREPWRITER_H 1
#include "cheprep/config.h"
#include <iostream>
#include <string>
#include <stack>
#include <set>
#include <vector>
#include <map>
#include "HEPREP/HepRep.h"
#include "HEPREP/HepRepFactory.h"
#include "HEPREP/HepRepWriter.h"
#include "HEPREP/HepRepPoint.h"
#include "HEPREP/HepRepInstance.h"
#include "HEPREP/HepRepInstanceTree.h"
#include "HEPREP/HepRepTreeID.h"
#include "HEPREP/HepRepAction.h"
#include "HEPREP/HepRepType.h"
#include "HEPREP/HepRepTypeTree.h"
#include "HEPREP/HepRepAttDef.h"
#include "HEPREP/HepRepAttValue.h"
#include "HEPREP/HepRepAttribute.h"
#include "cheprep/AbstractXMLWriter.h"
#include "cheprep/ZipOutputStream.h"
#include "cheprep/GZIPOutputStream.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class XMLHepRepWriter : public virtual HEPREP::HepRepWriter {
private:
std::ostream *out;
bool compress;
std::string nameSpace;
AbstractXMLWriter *xml;
cheprep::ZipOutputStream *zip;
cheprep::GZIPOutputStream *gz;
std::map<std::string, std::string> properties;
public:
XMLHepRepWriter(std::ostream* out, bool randomAccess, bool compress);
~XMLHepRepWriter();
bool addProperty(std::string key, std::string value);
bool close();
bool write(HEPREP::HepRep* heprep, std::string name);
bool write(std::vector<std::string> layers);
bool write(HEPREP::HepRepTypeTree* typeTree);
bool write(HEPREP::HepRepType* type);
bool write(HEPREP::HepRepTreeID* treeID);
bool write(HEPREP::HepRepAction* action);
bool write(HEPREP::HepRepInstanceTree* instanceTree);
bool write(HEPREP::HepRepInstance* instance);
bool write(HEPREP::HepRepPoint* point);
bool write(HEPREP::HepRepAttribute* attribute);
bool write(HEPREP::HepRepDefinition* definition);
bool write(HEPREP::HepRepAttValue* attValue);
bool write(HEPREP::HepRepAttDef* attDef);
};
} // cheprep
#endif
@@ -1,80 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_XMLWRITER_H
#define CHEPREP_XMLWRITER_H 1
#include "cheprep/config.h"
#include <iostream>
#include <map>
#include <stack>
#include <vector>
#include <string>
#include "cheprep/AbstractXMLWriter.h"
#include "cheprep/IndentPrintWriter.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class XMLWriter : public AbstractXMLWriter {
public:
XMLWriter(std::ostream* out, std::string indentString = " ", std::string defaultNameSpace = "");
virtual ~XMLWriter();
void close();
void openDoc(std::string version = "1.0", std::string encoding = "", bool standalone = false);
void referToDTD(std::string name, std::string pid, std::string ref);
void referToDTD(std::string name, std::string system);
void closeDoc(bool force = false);
void printComment(std::string comment);
void printPlain(std::string text);
void print(std::string text);
void println(std::string text);
void openTag(std::string name);
void closeTag();
void printTag(std::string name);
void setAttribute(std::string name, char* value);
void setAttribute(std::string name, std::string value);
void setAttribute(std::string name, std::vector<double> value);
void setAttribute(std::string name, int64 value);
void setAttribute(std::string name, int value);
void setAttribute(std::string name, bool value);
void setAttribute(std::string name, double value);
void printAttributes(int tagLength);
std::string normalize(std::string s);
std::string normalizeText(std::string s);
void checkNameValid(std::string s);
//
// Can be removed when we can properly inherit those (since names are equal to overloaded ones).
//
void openTag(std::string ns, std::string name) {
openTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
}
void printTag(std::string ns, std::string name) {
printTag(ns == defaultNameSpace ? name : ns.append(":").append(name));
}
void setAttribute(std::string ns, std::string name, std::string value) {
setAttribute(ns.append(":").append(name), value);
}
void setAttribute(std::string ns, std::string name, double value) {
setAttribute(ns.append(":").append(name), value);
}
protected:
bool closed;
IndentPrintWriter* writer;
private:
std::string dtdName;
std::map<std::string, std::string> attributes;
std::stack<std::string> openTags;
};
} // cheprep
#endif
@@ -1,36 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_ZIPENTRY_H
#define CHEPREP_ZIPENTRY_H
#include <string>
#include <vector>
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class ZipEntry {
public:
std::string name;
int method;
int date;
int time;
unsigned int crc;
unsigned int size;
unsigned int csize;
long offset;
long data;
ZipEntry() {
}
virtual ~ZipEntry() {
}
};
} // cheprep
#endif // CHEPREP_ZIPENTRY_H
@@ -1,39 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_ZIPOUTPUTSTREAM_H
#define CHEPREP_ZIPOUTPUTSTREAM_H
#include <string>
#include <iostream>
#include <vector>
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class ZipOutputStreamBuffer;
class ZipOutputStream : public std::ostream {
public:
ZipOutputStream(std::ostream& os);
void closeEntry();
void close();
void putNextEntry(const std::string& name, bool compress);
void setComment(const std::string& comment);
virtual ~ZipOutputStream();
private:
ZipOutputStreamBuffer* buffer;
};
} // cheprep
#endif // CHEPREP_ZIPOUTPUTSTREAM_H
@@ -1,57 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_ZIPOUTPUTSTREAMBUFFER_H
#define CHEPREP_ZIPOUTPUTSTREAMBUFFER_H
#include <string>
#include <iostream>
#include <vector>
#include "cheprep/DeflateOutputStreamBuffer.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
class ZipEntry;
class ZipOutputStreamBuffer : public DeflateOutputStreamBuffer {
public:
ZipOutputStreamBuffer(std::streambuf* buffer);
int overflow(int c);
void closeEntry();
void close();
void putNextEntry(const std::string& name, bool compress);
void setMethod(int method);
void setComment(const std::string& comment);
virtual ~ZipOutputStreamBuffer();
private:
std::string comment;
bool closed;
ZipEntry* entry;
std::vector<ZipEntry*>* entries;
static const unsigned int LOCSIG = 0x04034b50;
static const unsigned int EXTSIG = 0x08074b50;
static const unsigned int CENSIG = 0x02014b50;
static const unsigned int ENDSIG = 0x06054b50;
static const unsigned int VERSIONMADE = 0x0014;
static const unsigned int VERSIONEXTRACT = 0x0014;
static const unsigned int GENFLAG = 0x0008;
};
} // cheprep
#endif // CHEPREP_ZIPOUTPUTSTREAMBUFFER_H
@@ -1,62 +0,0 @@
// Copyright FreeHEP, 2005.
#ifndef CHEPREP_CONFIG_H
#define CHEPREP_CONFIG_H 1
/**
* @author Mark Donszelmann
*/
namespace cheprep {
#if defined(WIN32) && !defined(GNU_GCC)
// WIN32 and NOT GNU_GCC
typedef __int64 int64;
typedef unsigned __int64 uint64;
#define CHEPREP_INT64_FORMAT "%lld"
#define CHEPREP_UINT64_FORMAT "%llu"
#else // other than WIN32-MSVC
#if defined(_LP64)
// 64 Bit Platforms
typedef long int64;
typedef unsigned long uint64;
#define CHEPREP_INT64_FORMAT "%ld"
#define CHEPREP_UINT64_FORMAT "%uld"
#else
// 32-Bit Platforms
typedef long long int64;
typedef unsigned long long uint64;
#define CHEPREP_INT64_FORMAT "%lld"
#define CHEPREP_UINT64_FORMAT "%ulld"
#endif // 32-Bit Platforms
#endif // other than WIN32-MSVC
} // namespace cheprep
#ifdef WIN32
#ifndef GNU_GCC
// Disable warning C4786: identifier was truncated to '255' characters in the debug information
#pragma warning ( disable : 4786 )
// Disable warning C4250: inherits via dominance
#pragma warning ( disable : 4250 )
#ifdef VC6
// FIX for KB 168440 - VC6
// Stream Operator << Cannot Handle __int64 Type
#include<iostream>
inline std::ostream& operator<<(std::ostream& os, __int64 i ) {
char buf[20];
sprintf(buf,"%I64d", i );
os << buf;
return os;
}
#endif // VC6
#endif // GNU_GCC
#endif // WIN32
#endif // CHEPREP_CONFIG_H
@@ -1 +0,0 @@
source = freehep-cheprep-2.0.5
+2 -34
View File
@@ -3,46 +3,17 @@
# Define the Geant4 Module.
geant4_add_module(G4visHepRep
PUBLIC_HEADERS
G4HepRep.hh
G4HepRepFile.hh
G4HepRepFileSceneHandler.hh
G4HepRepFileViewer.hh
G4HepRepFileXMLWriter.hh
G4HepRepMessenger.hh
G4HepRepSceneHandler.hh
G4HepRepViewer.hh
SOURCES
BHepRepWriter.cc
DefaultHepRep.cc
DefaultHepRepAction.cc
DefaultHepRepAttDef.cc
DefaultHepRepAttValue.cc
DefaultHepRepAttribute.cc
DefaultHepRepDefinition.cc
DefaultHepRepFactory.cc
DefaultHepRepInstance.cc
DefaultHepRepInstanceTree.cc
DefaultHepRepPoint.cc
DefaultHepRepTreeID.cc
DefaultHepRepType.cc
DefaultHepRepTypeTree.cc
DeflateOutputStreamBuffer.cc
G4HepRep.cc
G4HepRepFile.cc
G4HepRepFileSceneHandler.cc
G4HepRepFileViewer.cc
G4HepRepFileXMLWriter.cc
G4HepRepMessenger.cc
G4HepRepSceneHandler.cc
G4HepRepViewer.cc
GZIPOutputStream.cc
GZIPOutputStreamBuffer.cc
IndentPrintWriter.cc
XMLHepRepFactory.cc
XMLHepRepWriter.cc
XMLWriter.cc
ZipOutputStream.cc
ZipOutputStreamBuffer.cc)
G4HepRepMessenger.cc)
geant4_module_link_libraries(G4visHepRep
PUBLIC
@@ -57,9 +28,6 @@ geant4_module_link_libraries(G4visHepRep
G4graphics_reps
PRIVATE
G4hepgeometry
G4hits
G4UIcommon
G4tracking
${ZLIB_LIBRARIES})
G4tracking)
# List any source specific properties here
@@ -1,544 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/config.h"
#include <iostream>
#include <algorithm>
#include "cheprep/BHepRepWriter.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
// class variables
std::map<std::string, unsigned char> BHepRepWriter::tags;
std::map<std::string, unsigned char> BHepRepWriter::attributes;
std::map<std::string, unsigned char> BHepRepWriter::values;
BHepRepWriter::BHepRepWriter( std::ostream& ostrm)
: AbstractXMLWriter("heprep"),
os(ostrm),
singlePrecision(true) {
// resolve endiannes
union { long l; char c[sizeof (long)]; } u;
u.l = 1;
isBigEndian = (u.c[sizeof (long) - 1] == 1);
// std::cout << "Host is " << (isBigEndian ? "Big-Endian" : "Little-Endian") << "." << std::endl;
if (tags.size() <= 0) {
// tags
tags["heprep"] = 0x05;
tags["attdef"] = 0x06;
tags["attvalue"] = 0x07;
tags["instance"] = 0x08;
tags["treeid"] = 0x09;
tags["action"] = 0x0a;
tags["instancetree"] = 0x0b;
tags["type"] = 0x0c;
tags["typetree"] = 0x0d;
tags["layer"] = 0x0e;
tags["point"] = 0x0f;
}
if (attributes.size() <= 0) {
// attribute names
attributes["version"] = 0x05;
attributes["xmlns"] = 0x06;
attributes["xmlns:xsi"] = 0x07;
attributes["xsi:schemaLocation"] = 0x08;
attributes["valueString"] = 0x10;
attributes["valueColor"] = 0x11;
attributes["valueLong"] = 0x12;
attributes["valueInt"] = 0x13;
attributes["valueBoolean"] = 0x14;
attributes["valueDouble"] = 0x15;
attributes["name"] = 0x20;
attributes["type"] = 0x22;
attributes["showlabel"] = 0x23;
attributes["desc"] = 0x24;
attributes["category"] = 0x25;
attributes["extra"] = 0x26;
attributes["x"] = 0x27;
attributes["y"] = 0x28;
attributes["z"] = 0x29;
attributes["qualifier"] = 0x2a;
attributes["expression"] = 0x2b;
attributes["typetreename"] = 0x2c;
attributes["typetreeversion"] = 0x2d;
attributes["order"] = 0x2e;
// for PI
attributes["eof"] = 0x7f;
}
if (values.size() <= 0) {
// attribute values
values["drawas"] = 0x85;
values["drawasoptions"] = 0x86;
values["visibility"] = 0x87;
values["label"] = 0x88;
values["fontname"] = 0x89;
values["fontstyle"] = 0x8a;
values["fontsize"] = 0x8b;
values["fontcolor"] = 0x8c;
values["fonthasframe"] = 0x8d;
values["fontframecolor"] = 0x8e;
values["fontframewidth"] = 0x8f;
values["fonthasbanner"] = 0x90;
values["fontbannercolor"] = 0x91;
values["color"] = 0x92;
values["framecolor"] = 0x93;
values["layer"] = 0x94;
values["markname"] = 0x95;
values["marksize"] = 0x96;
values["marksizemultiplier"] = 0x97;
values["marktype"] = 0x98;
values["hasframe"] = 0x99;
values["framecolor"] = 0x9a;
values["framewidth"] = 0x9b;
values["linestyle"] = 0x9c;
values["linewidth"] = 0x9d;
values["linewidthmultiplier"] = 0x9e;
values["linehasarrow"] = 0x9f;
values["fillcolor"] = 0xa0;
values["filltype"] = 0xa1;
values["fill"] = 0xa2;
values["radius"] = 0xa3;
values["phi"] = 0xa4;
values["theta"] = 0xa5;
values["omega"] = 0xa6;
values["radius1"] = 0xa7;
values["radius2"] = 0xa8;
values["radius3"] = 0xa9;
values["curvature"] = 0xaa;
values["flylength"] = 0xab;
values["faces"] = 0xac;
values["text"] = 0xad;
values["hpos"] = 0xae;
values["vpos"] = 0xaf;
values["halign"] = 0xb0;
values["valign"] = 0xb1;
values["ispickable"] = 0xb2;
values["showparentvalues"] = 0xb3;
values["pickparent"] = 0xb4;
// attvalue values
values["false"] = 0xd0;
values["true"] = 0xd1;
values["point"] = 0xd2;
values["line"] = 0xd3;
values["helix"] = 0xd4;
values["polygon"] = 0xd5;
values["circle"] = 0xd6;
values["curve"] = 0xd7;
values["ellipse"] = 0xd8;
values["ellipsoid"] = 0xd9;
values["prism"] = 0xda;
values["cylinder"] = 0xdb;
values["ellipseprism"] = 0xdc;
values["text"] = 0xdd;
values["nonzero"] = 0xde;
values["evenodd"] = 0xdf;
values["circle"] = 0xe0;
values["box"] = 0xe1;
values["uptriangle"] = 0xe2;
values["dntriangle"] = 0xe3;
values["diamond"] = 0xe4;
values["cross"] = 0xe5;
values["star"] = 0xe6;
values["plus"] = 0xe7;
values["hline"] = 0xe8;
values["vline"] = 0xe9;
values["solid"] = 0xea;
values["dotted"] = 0xeb;
values["dashed"] = 0xec;
values["dotdash"] = 0xed;
values["none"] = 0xee;
values["start"] = 0xef;
values["end"] = 0xf0;
values["both"] = 0xf1;
values["serif"] = 0xf2;
values["sansserif"] = 0xf3;
values["monotype"] = 0xf4;
values["symbol"] = 0xf5;
values["plain"] = 0xf6;
values["bold"] = 0xf7;
values["italic"] = 0xf8;
values["top"] = 0xf9;
values["baseline"] = 0xfa;
values["center"] = 0xfb;
values["bottom"] = 0xfc;
values["left"] = 0xfd;
values["right"] = 0xfe;
values["default"] = 0xff;
}
}
BHepRepWriter::~BHepRepWriter() {
}
void BHepRepWriter::close() {
}
void BHepRepWriter::openDoc(std::string version, std::string /* encoding */, bool /* standalone */) {
stringValues.clear();
// header
writeByte(WBXML_VERSION);
writeMultiByteInt(UNKNOWN_PID);
writeMultiByteInt(UTF8);
version = "BinaryHepRep/1.0";
// string table
writeMultiByteInt(version.length()+1);
// BHepRep Header (as part of the string table)
writeString(version);
}
void BHepRepWriter::closeDoc(bool /* force */) {
writeByte(PI);
writeByte(attributes["eof"]);
writeByte(END);
}
void BHepRepWriter::openTag(std::string name) {
writeTag(name, true);
}
void BHepRepWriter::closeTag() {
writePoints();
writeByte(END);
}
void BHepRepWriter::printTag(std::string name) {
writeTag(name);
}
void BHepRepWriter::writeTag(std::string tagName, bool hasContent) {
std::string s = tagName;
std::transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
// find tag
if (tags.count(s) <= 0) {
std::cerr << "Cannot find tag '" << s << "' in tags table." << std::endl;
return;
}
// write tag
bool isPoint = (s == "point");
bool hasAttributes = (stringAttributes.size() > 0) || (doubleAttributes.size() > (unsigned int)(isPoint ? 3 : 0));
if (!hasAttributes && isPoint) {
// store the point for the future
points.push_back(doubleAttributes["x"]);
points.push_back(doubleAttributes["y"]);
points.push_back(doubleAttributes["z"]);
return;
}
writePoints();
writeByte(tags[s] | ((hasContent || isPoint) ? CONTENT : 0x00) | (hasAttributes ? ATTRIBUTE : 0x00));
// write attributes
if (hasAttributes) {
// write string attributes
for (std::map<std::string,std::string>::iterator i = stringAttributes.begin(); i != stringAttributes.end(); i++) {
std::string name = i->first;
std::string value = i->second;
// write ATTRSTART
writeByte(attributes[name]);
std::string v = value;
std::transform(v.begin(), v.end(), v.begin(), (int(*)(int)) tolower);
if (values.count(v) > 0) {
// write ATTRVALUE
writeByte(values[v]);
} else {
if (stringValues.count(value) <= 0) {
// define this new string
writeStringDefine(value);
int index = stringValues.size();
stringValues[value] = index;
} else {
// write string ref
writeByte(STR_R);
writeMultiByteInt(stringValues[value]);
}
}
}
stringAttributes.clear();
// write color attributes
for (std::map<std::string,std::vector<double> >::iterator i = colorAttributes.begin(); i != colorAttributes.end(); i++) {
std::string name = i->first;
std::vector<double> value = i->second;
// write ATTRSTART
writeByte(attributes[name]);
// write OPAQUE
writeByte(OPAQUE);
writeMultiByteInt(value.size());
writeByte((int)(value[0] * 0xff) & 0xff);
writeByte((int)(value[1] * 0xff) & 0xff);
writeByte((int)(value[2] * 0xff) & 0xff);
if (value.size() > 3) writeByte((int)(value[3] * 0xff) & 0xff);
}
colorAttributes.clear();
// write long attributes
for (std::map<std::string,int64>::iterator i = longAttributes.begin(); i != longAttributes.end(); i++) {
std::string name = i->first;
int64 value = i->second;
// write ATTRSTART
writeByte(attributes[name]);
// write OPAQUE
writeByte(OPAQUE);
writeMultiByteInt(8);
writeLong(value);
}
longAttributes.clear();
// write int attributes
for (std::map<std::string,int>::iterator i = intAttributes.begin(); i != intAttributes.end(); i++) {
std::string name = i->first;
int value = i->second;
// write ATTRSTART
writeByte(attributes[name]);
// write OPAQUE
writeByte(OPAQUE);
writeMultiByteInt(4);
writeInt(value);
}
intAttributes.clear();
// write boolean attributes
for (std::map<std::string,bool>::iterator i = booleanAttributes.begin(); i != booleanAttributes.end(); i++) {
std::string name = i->first;
bool value = i->second;
// write ATTRSTART
writeByte(attributes[name]);
// write ATTRVALUE
writeByte(value ? values["true"] : values["false"]);
}
booleanAttributes.clear();
// write double attributes
for (std::map<std::string,double>::iterator i = doubleAttributes.begin(); i != doubleAttributes.end(); i++) {
std::string name = i->first;
double value = i->second;
if (!isPoint && (name != "x") && (name != "y") && (name != "z")) {
// write ATTRSTART
writeByte(attributes[name]);
// write OPAQUE
writeByte(OPAQUE);
writeMultiByteInt(singlePrecision ? 4 : 8);
writeReal(value);
}
}
doubleAttributes.clear();
// end of attributes
writeByte(END);
}
if (s == "point") {
writeByte(OPAQUE);
writeMultiByteInt(singlePrecision ? 12 : 24);
writeReal(doubleAttributes["x"]);
writeReal(doubleAttributes["y"]);
writeReal(doubleAttributes["z"]);
}
if (isPoint && !hasContent) {
// end this tag
writeByte(END);
}
}
void BHepRepWriter::writePoints() {
if (points.size() <= 0) return;
writeByte(tags["point"] | CONTENT);
writeByte(OPAQUE);
writeMultiByteInt(points.size()*(singlePrecision ? 4 : 8));
for (std::vector<double>::iterator i = points.begin(); i != points.end(); ) {
writeReal(*i++);
writeReal(*i++);
writeReal(*i++);
}
writeByte(END);
points.clear();
}
void BHepRepWriter::setAttribute(std::string name, char* value) {
setAttribute(name, (std::string)value);
}
void BHepRepWriter::setAttribute(std::string name, std::string value) {
if (name == "value") name = name.append("String");
// make sure the attribute name is defined
if (attributes.count(name) <= 0) {
std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
return;
}
stringAttributes[name] = value;
}
void BHepRepWriter::setAttribute(std::string name, std::vector<double> value) {
if (name == "value") name = name.append("Color");
// make sure the attribute name is defined
if (attributes.count(name) <= 0) {
std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
return;
}
colorAttributes[name] = value;
}
void BHepRepWriter::setAttribute(std::string name, int64 value) {
if (name == "value") name = name.append("Long");
// make sure the attribute name is defined
if (attributes.count(name) <= 0) {
std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
return;
}
longAttributes[name] = value;
}
void BHepRepWriter::setAttribute(std::string name, int value) {
if (name == "value") name = name.append("Int");
// make sure the attribute name is defined
if (attributes.count(name) <= 0) {
std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
return;
}
intAttributes[name] = value;
}
void BHepRepWriter::setAttribute(std::string name, bool value) {
if (name == "value") name = name.append("Boolean");
// make sure the attribute name is defined
if (attributes.count(name) <= 0) {
std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
return;
}
booleanAttributes[name] = value;
}
void BHepRepWriter::setAttribute(std::string name, double value) {
if (name == "value") name = name.append("Double");
// make sure the attribute name is defined
if (attributes.count(name) <= 0) {
std::cerr << "Cannot find attribute name '" << name << "' in attributes table, skipped." << std::endl;
return;
}
doubleAttributes[name] = value;
}
void BHepRepWriter::writeStringDefine(std::string s) {
writeByte(STR_D);
writeString(s);
}
void BHepRepWriter::writeMultiByteInt(unsigned int ui) {
unsigned char buf[5];
int idx = 0;
do {
buf[idx++] = (unsigned char) (ui & 0x7f);
ui = ui >> 7;
}
while (ui != 0);
while (idx > 1) {
writeByte(buf[--idx] | 0x80);
}
writeByte(buf[0]);
}
void BHepRepWriter::writeReal(double d) {
if (singlePrecision) {
union {
int i;
float f;
} u;
u.f = (float)d;
writeInt(u.i);
} else {
union {
int64 i;
double d;
} u;
u.d = d;
writeLong(u.i);
}
}
void BHepRepWriter::writeLong(int64 i) {
// write network-order
os.put((i >> 56) & 0xff);
os.put((i >> 48) & 0xff);
os.put((i >> 40) & 0xff);
os.put((i >> 32) & 0xff);
os.put((i >> 24) & 0xff);
os.put((i >> 16) & 0xff);
os.put((i >> 8) & 0xff);
os.put((i ) & 0xff);
}
void BHepRepWriter::writeInt(int i) {
// write network-order
os.put((i >> 24) & 0xff);
os.put((i >> 16) & 0xff);
os.put((i >> 8) & 0xff);
os.put((i ) & 0xff);
}
void BHepRepWriter::writeByte(unsigned char b) {
os.put((char)b);
}
void BHepRepWriter::writeString(std::string s) {
os << s;
os.put(0);
}
} // cheprep
@@ -1,102 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/DefaultHepRep.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRep::DefaultHepRep() {
}
DefaultHepRep::~DefaultHepRep() {
for (vector<HepRepTypeTree*>::iterator i1 = typeTrees.begin(); i1 != typeTrees.end(); i1++) {
delete (*i1);
}
for (vector<HepRepInstanceTree*>::iterator i2 = instanceTrees.begin(); i2 != instanceTrees.end(); i2++) {
delete (*i2);
}
}
HepRep* DefaultHepRep::copy(HepRepSelectFilter*) {
cerr << "DefaultHepRep::copy(HepRepSelectFilter*) not implemented." << endl;
return NULL;
}
vector<string> DefaultHepRep::getLayerOrder() {
return layers;
}
void DefaultHepRep::addLayer(string layer) {
layers.push_back(layer);
}
void DefaultHepRep::addTypeTree(HepRepTypeTree* typeTree) {
// FIXME check if already exist
typeTrees.push_back(typeTree);
}
void DefaultHepRep::removeTypeTree(HepRepTypeTree*) {
cerr << "DefaultHepRep::removeTypeTree(HepRepTypeTree*) not implemented." << endl;
}
HepRepTypeTree* DefaultHepRep::getTypeTree(string, string) {
cerr << "DefaultHepRep::getTypeTree(string, string) not implemented." << endl;
return NULL;
}
vector<HepRepTypeTree*> DefaultHepRep::getTypeTreeList() {
return typeTrees;
}
void DefaultHepRep::addInstanceTree(HepRepInstanceTree* instanceTree) {
// FIXME check if already exist
instanceTrees.push_back(instanceTree);
}
void DefaultHepRep::overlayInstanceTree(HepRepInstanceTree *) {
cerr << "DefaultHepRep::overlayInstanceTree(HepRepInstanceTree * instanceTree) not implemented." << endl;
}
void DefaultHepRep::removeInstanceTree(HepRepInstanceTree*) {
cerr << "DefaultHepRep::removeInstanceTree(HepRepInstanceTree*) not implemented." << endl;
}
HepRepInstanceTree* DefaultHepRep::getInstanceTreeTop(string, string) {
cerr << "DefaultHepRep::getInstanceTreeTop(string, string) not implemented." << endl;
return NULL;
}
HepRepInstanceTree* DefaultHepRep::getInstances(string, string,
vector<string>) {
cerr << "DefaultHepRep::getInstances(string, string, vector<string>) not implemented." << endl;
return NULL;
}
HepRepInstanceTree* DefaultHepRep::getInstancesAfterAction(
string,
string,
vector<string>,
vector<HepRepAction*>,
bool,
bool,
bool,
vector<string>) {
cerr << "DefaultHepRep::getInstancesAfterAction(string, string, vector<string>, vector<HepRepAction*>, bool, bool, bool, vector<string>) not implemented." << endl;
return NULL;
}
string DefaultHepRep::checkForException() {
return NULL;
}
vector<HepRepInstanceTree*> DefaultHepRep::getInstanceTreeList() {
return instanceTrees;
}
} // cheprep
@@ -1,35 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include "cheprep/DefaultHepRepAction.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepAction::DefaultHepRepAction(string aName, string anExpression)
: name(aName), expression(anExpression) {
}
DefaultHepRepAction::~DefaultHepRepAction() {
}
string DefaultHepRepAction::getName() {
return name;
}
string DefaultHepRepAction::getExpression() {
return expression;
}
HepRepAction* DefaultHepRepAction::copy() {
return new DefaultHepRepAction(name, expression);
}
} // cheprep
@@ -1,51 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include <cstring>
#include <cctype>
#include <algorithm>
#include "cheprep/DefaultHepRepAttDef.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepAttDef::DefaultHepRepAttDef(string aName, string aDesc, string aCategory, string anExtra)
: name(aName), desc(aDesc), category(aCategory), extra(anExtra) {
}
DefaultHepRepAttDef::~DefaultHepRepAttDef() {
}
HepRepAttDef* DefaultHepRepAttDef::copy() {
return new DefaultHepRepAttDef(name, desc, category, extra);
}
string DefaultHepRepAttDef::getName() {
return name;
}
string DefaultHepRepAttDef::getLowerCaseName() {
string s = name;
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
return s;
}
string DefaultHepRepAttDef::getDescription() {
return desc;
}
string DefaultHepRepAttDef::getCategory() {
return category;
}
string DefaultHepRepAttDef::getExtra() {
return extra;
}
} // cheprep
@@ -1,271 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/config.h"
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include "HEPREP/HepRepConstants.h"
#include "cheprep/DefaultHepRepAttValue.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
std::string DefaultHepRepAttValue::labelStrings[LABELSTRINGS_LEN];
DefaultHepRepAttValue::DefaultHepRepAttValue(string aName, string aValue, int aShowLabel)
: name(aName)
, type(HepRepConstants::TYPE_STRING)
, stringValue(aValue)
, longValue(0)
, doubleValue(0.)
, booleanValue(false)
, showLabelValue(aShowLabel)
{
init();
}
DefaultHepRepAttValue::DefaultHepRepAttValue(string aName, int64 aValue, int aShowLabel)
: name(aName)
, type(HepRepConstants::TYPE_LONG)
, longValue(aValue)
, doubleValue(0.)
, booleanValue(false)
, showLabelValue(aShowLabel)
{
init();
}
DefaultHepRepAttValue::DefaultHepRepAttValue(string aName, int aValue, int aShowLabel)
: name(aName)
, type(HepRepConstants::TYPE_INT)
, longValue(aValue)
, doubleValue(0.)
, booleanValue(false)
, showLabelValue(aShowLabel)
{
init();
}
DefaultHepRepAttValue::DefaultHepRepAttValue(string aName, double aValue, int aShowLabel)
: name(aName)
, type(HepRepConstants::TYPE_DOUBLE)
, longValue(0)
, doubleValue(aValue)
, booleanValue(false)
, showLabelValue(aShowLabel)
{
init();
}
DefaultHepRepAttValue::DefaultHepRepAttValue(string aName, bool aValue, int aShowLabel)
: name(aName)
, type(HepRepConstants::TYPE_BOOLEAN)
, longValue(0)
, doubleValue(0.)
, booleanValue(aValue)
, showLabelValue(aShowLabel)
{
init();
}
DefaultHepRepAttValue::DefaultHepRepAttValue(string aName, vector<double> aValue, int aShowLabel)
: name(aName)
, type(HepRepConstants::TYPE_COLOR)
, longValue(0)
, doubleValue(0.)
, booleanValue(false)
, colorValue(aValue)
, showLabelValue(aShowLabel)
{
init();
}
DefaultHepRepAttValue::~DefaultHepRepAttValue() {
}
void DefaultHepRepAttValue::init() {
labelStrings[0] = "NAME";
labelStrings[1] = "DESC";
labelStrings[2] = "VALUE";
labelStrings[3] = "EXTRA";
}
HepRepAttValue* DefaultHepRepAttValue::copy() {
// Coverity issues warnings here. It looks to me (JA) that "return" is
// missing on severeal lines.
switch(type) {
// case HepRepConstants::TYPE_COLOR: new DefaultHepRepAttValue(name, colorValue, showLabelValue);
// case HepRepConstants::TYPE_STRING: new DefaultHepRepAttValue(name, stringValue, showLabelValue);
// case HepRepConstants::TYPE_LONG: new DefaultHepRepAttValue(name, longValue, showLabelValue);
// case HepRepConstants::TYPE_INT: new DefaultHepRepAttValue(name, (int)longValue, showLabelValue);
// case HepRepConstants::TYPE_DOUBLE: new DefaultHepRepAttValue(name, doubleValue, showLabelValue);
// case HepRepConstants::TYPE_BOOLEAN: new DefaultHepRepAttValue(name, booleanValue, showLabelValue);
case HepRepConstants::TYPE_COLOR: return new DefaultHepRepAttValue(name, colorValue, showLabelValue);
case HepRepConstants::TYPE_STRING: return new DefaultHepRepAttValue(name, stringValue, showLabelValue);
case HepRepConstants::TYPE_LONG: return new DefaultHepRepAttValue(name, longValue, showLabelValue);
case HepRepConstants::TYPE_INT: return new DefaultHepRepAttValue(name, (int)longValue, showLabelValue);
case HepRepConstants::TYPE_DOUBLE: return new DefaultHepRepAttValue(name, doubleValue, showLabelValue);
case HepRepConstants::TYPE_BOOLEAN: return new DefaultHepRepAttValue(name, booleanValue, showLabelValue);
default: return new DefaultHepRepAttValue(name, "Unknown type stored in HepRepAttDef", showLabelValue);
}
}
string DefaultHepRepAttValue::getName() {
return name;
}
string DefaultHepRepAttValue::getLowerCaseName() {
string s = name;
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
return s;
}
int DefaultHepRepAttValue::getType() {
return type;
}
string DefaultHepRepAttValue::getTypeName() {
switch(type) {
case HepRepConstants::TYPE_COLOR: return("Color");
case HepRepConstants::TYPE_STRING: return("String");
case HepRepConstants::TYPE_LONG: return("long");
case HepRepConstants::TYPE_INT: return("int");
case HepRepConstants::TYPE_DOUBLE: return("double");
case HepRepConstants::TYPE_BOOLEAN: return("boolean");
default: return "Unknown type stored in HepRepAttDef";
}
}
int DefaultHepRepAttValue::showLabel() {
return showLabelValue;
}
string DefaultHepRepAttValue::getString() {
if (type != HepRepConstants::TYPE_STRING) cerr << "Trying to access AttValue '" << getName() << "' as 'string'" << endl;
return stringValue;
}
string DefaultHepRepAttValue::getLowerCaseString() {
if (type != HepRepConstants::TYPE_STRING) cerr << "Trying to access AttValue '" << getName() << "' as 'string'" << endl;
string s = stringValue;
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
return s;
}
int64 DefaultHepRepAttValue::getLong() {
if (type != HepRepConstants::TYPE_LONG) cerr << "Trying to access AttValue '" << getName() << "' as 'long'" << endl;
return longValue;
}
int DefaultHepRepAttValue::getInteger() {
if (type != HepRepConstants::TYPE_INT) cerr << "Trying to access AttValue '" << getName() << "' as 'int'" << endl;
return (int64)longValue;
}
double DefaultHepRepAttValue::getDouble() {
if (type != HepRepConstants::TYPE_DOUBLE) cerr << "Trying to access AttValue '" << getName() << "' as 'double'" << endl;
return doubleValue;
}
bool DefaultHepRepAttValue::getBoolean() {
if (type != HepRepConstants::TYPE_BOOLEAN) cerr << "Trying to access AttValue '" << getName() << "' as 'boolean'" << endl;
return booleanValue;
}
vector<double> DefaultHepRepAttValue::getColor() {
if (type != HepRepConstants::TYPE_COLOR) cerr << "Trying to access AttValue '" << getName() << "' as 'color'" << endl;
return colorValue;
}
string DefaultHepRepAttValue::getAsString() {
switch(type) {
case HepRepConstants::TYPE_COLOR: return getAsString(getColor());
case HepRepConstants::TYPE_STRING: return getString();
case HepRepConstants::TYPE_LONG: return getAsString(getLong());
case HepRepConstants::TYPE_INT: return getAsString(getInteger());
case HepRepConstants::TYPE_DOUBLE: return getAsString(getDouble());
case HepRepConstants::TYPE_BOOLEAN: return getAsString(getBoolean());
default: return "Unknown typecode";
}
}
string DefaultHepRepAttValue::getAsString(vector<double> c) {
char buffer[40];
sprintf(buffer, "%4.2f, %4.2f, %4.2f, %4.2f",
c[0],
c[1],
c[2],
(c.size() > 3) ? c[3] : 1.0);
return buffer;
}
string DefaultHepRepAttValue::getAsString(int i) {
char buffer[40];
sprintf(buffer, "%d", i);
return buffer;
}
string DefaultHepRepAttValue::getAsString(int64 i) {
char buffer[40];
sprintf(buffer, CHEPREP_INT64_FORMAT, i);
return buffer;
}
// NOTE: keep at %g rather than %lg for backward compatibility
string DefaultHepRepAttValue::getAsString(double d) {
char buffer[40];
sprintf(buffer, "%g", d);
return buffer;
}
string DefaultHepRepAttValue::getAsString(bool b) {
return b ? "true" : "false";
}
string DefaultHepRepAttValue::toShowLabel() {
return toShowLabel(showLabel());
}
string DefaultHepRepAttValue::toShowLabel(int showLabel) {
string label = "";
bool first = true;
if (showLabel == HepRepConstants::SHOW_NONE) {
label = "NONE";
} else {
for (int i=0; i<16; i++) {
if (((showLabel >> i) & 0x0001) == 0x0001) {
if (first) {
first = false;
} else {
label.append(", ");
}
if (i < LABELSTRINGS_LEN) {
label.append(labelStrings[i]);
} else {
char hex[20];
sprintf(hex, "%0x", 1 << i);
label.append(hex);
}
}
}
}
return label;
}
} // cheprep
@@ -1,95 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/config.h"
#include <iostream>
#include <algorithm>
#include "cheprep/DefaultHepRepAttribute.h"
#include "cheprep/DefaultHepRepAttValue.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepAttribute::DefaultHepRepAttribute() {
}
DefaultHepRepAttribute::~DefaultHepRepAttribute() {
for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
delete (*i).second;
}
}
set<HepRepAttValue*> DefaultHepRepAttribute::getAttValuesFromNode() {
set<HepRepAttValue*> attSet;
for (map<string, HepRepAttValue*>::iterator i = attValues.begin(); i != attValues.end(); i++) {
if ((*i).first != "layer") attSet.insert((*i).second);
}
return attSet;
}
void DefaultHepRepAttribute::addAttValue(HepRepAttValue* hepRepAttValue) {
string lowerCaseName = hepRepAttValue->getLowerCaseName();
if (attValues[lowerCaseName] != NULL) delete attValues[lowerCaseName];
attValues[lowerCaseName] = hepRepAttValue;
}
void DefaultHepRepAttribute::addAttValue(string key, char *value, int showLabel) {
addAttValue(key, (std::string)value, showLabel);
}
void DefaultHepRepAttribute::addAttValue(string key, string value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
void DefaultHepRepAttribute::addAttValue(string key, int64 value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
void DefaultHepRepAttribute::addAttValue(string key, int value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
void DefaultHepRepAttribute::addAttValue(string key, double value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
void DefaultHepRepAttribute::addAttValue(string key, bool value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
void DefaultHepRepAttribute::addAttValue(string key, vector<double> value, int showLabel) {
addAttValue(new DefaultHepRepAttValue(key, value, showLabel));
}
void DefaultHepRepAttribute::addAttValue(string key, double red, double green, double blue, double alpha, int showLabel) {
vector<double> color;
color.push_back(red);
color.push_back(green);
color.push_back(blue);
color.push_back(alpha);
addAttValue(new DefaultHepRepAttValue(key, color, showLabel));
}
HepRepAttValue* DefaultHepRepAttribute::getAttValueFromNode(string name) {
string s = name;
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
return (attValues.count(s) > 0) ? attValues[s] : NULL;
}
HepRepAttValue* DefaultHepRepAttribute::removeAttValue(string name) {
string s = name;
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
HepRepAttValue* attValue = attValues[s];
attValues.erase(s);
return attValue;
}
} // cheprep
@@ -1,52 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/DefaultHepRepDefinition.h"
#include "cheprep/DefaultHepRepAttDef.h"
#include <iostream>
#include <algorithm>
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepDefinition::DefaultHepRepDefinition()
: DefaultHepRepAttribute() {
}
DefaultHepRepDefinition::~DefaultHepRepDefinition() {
set<HepRepAttDef *> list = getAttDefsFromNode();
for (set<HepRepAttDef*>::iterator i1 = list.begin(); i1 != list.end(); i1++) {
delete (*i1);
}
}
set<HepRepAttDef *> DefaultHepRepDefinition::getAttDefsFromNode() {
set<HepRepAttDef*> attSet;
for (map<string, HepRepAttDef*>::iterator i = attDefs.begin(); i != attDefs.end(); i++) {
attSet.insert((*i).second);
}
return attSet;
}
void DefaultHepRepDefinition::addAttDef(HepRepAttDef* hepRepAttDef) {
string lowerCaseName = hepRepAttDef->getLowerCaseName();
if (attDefs[lowerCaseName] != NULL) delete attDefs[lowerCaseName];
attDefs[lowerCaseName] = hepRepAttDef;
}
void DefaultHepRepDefinition::addAttDef(string name, string desc, string type, string extra) {
addAttDef(new DefaultHepRepAttDef(name, desc, type, extra));
}
HepRepAttDef* DefaultHepRepDefinition::getAttDefFromNode(string name) {
string s = name;
transform(s.begin(), s.end(), s.begin(), (int(*)(int)) tolower);
return (attDefs.count(s) > 0) ? attDefs[s] : NULL;
}
} // cheprep
@@ -1,89 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include <fstream>
#include "cheprep/DefaultHepRepFactory.h"
#include "cheprep/DefaultHepRepPoint.h"
#include "cheprep/DefaultHepRepInstance.h"
#include "cheprep/DefaultHepRepInstanceTree.h"
#include "cheprep/DefaultHepRepType.h"
#include "cheprep/DefaultHepRepTypeTree.h"
#include "cheprep/DefaultHepRep.h"
#include "cheprep/DefaultHepRepAction.h"
#include "cheprep/DefaultHepRepTreeID.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepFactory::DefaultHepRepFactory() {
}
DefaultHepRepFactory::~DefaultHepRepFactory() {
}
HepRepReader* DefaultHepRepFactory::createHepRepReader (istream*) {
cerr << "DefaultHepRepFactory::createHepRepReader not implemented" << endl;
return NULL;
}
HepRepReader* DefaultHepRepFactory::createHepRepReader (std::string) {
cerr << "DefaultHepRepFactory::createHepRepReader not implemented" << endl;
return NULL;
}
HepRepWriter* DefaultHepRepFactory::createHepRepWriter(ostream*, bool, bool) {
cerr << "DefaultHepRepFactory::createHepRepWriter not implemented" << endl;
return NULL;
}
HepRepPoint* DefaultHepRepFactory::createHepRepPoint (HepRepInstance* instance,
double x, double y, double z) {
return new DefaultHepRepPoint(instance, x, y, z);
}
HepRepInstance* DefaultHepRepFactory::createHepRepInstance (HepRepInstance* parent, HepRepType* type) {
return new DefaultHepRepInstance(parent, type);
}
HepRepInstance* DefaultHepRepFactory::createHepRepInstance (HepRepInstanceTree* parent, HepRepType* type) {
return new DefaultHepRepInstance(parent, type);
}
HepRepTreeID* DefaultHepRepFactory::createHepRepTreeID (string name, string version, string qualifier) {
return new DefaultHepRepTreeID(name, version, qualifier);
}
HepRepAction* DefaultHepRepFactory::createHepRepAction (string name, string expression) {
return new DefaultHepRepAction(name, expression);
}
HepRepInstanceTree* DefaultHepRepFactory::createHepRepInstanceTree (string name, string version,
HepRepTreeID* typeTreeID) {
return new DefaultHepRepInstanceTree(name, version, typeTreeID);
}
HepRepType* DefaultHepRepFactory::createHepRepType (HepRepType* parent, string name) {
return new DefaultHepRepType(parent, name);
}
HepRepType* DefaultHepRepFactory::createHepRepType (HepRepTypeTree* parent, string name) {
return new DefaultHepRepType(parent, name);
}
HepRepTypeTree* DefaultHepRepFactory::createHepRepTypeTree (HepRepTreeID* treeID) {
return new DefaultHepRepTypeTree(treeID);
}
HepRep* DefaultHepRepFactory::createHepRep () {
return new DefaultHepRep();
}
} // cheprep
@@ -1,87 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include "cheprep/DefaultHepRepInstance.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstance* instance, HepRepType* heprepType)
: DefaultHepRepAttribute(), parent(instance), type(heprepType) {
if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
parent->addInstance(this);
}
DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstanceTree* instanceTree, HepRepType* heprepType)
: DefaultHepRepAttribute(), parent(NULL), type(heprepType) {
if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
instanceTree->addInstance(this);
}
DefaultHepRepInstance::~DefaultHepRepInstance() {
parent = NULL;
type = NULL;
for (vector<HepRepInstance*>::iterator i1 = instances.begin(); i1 != instances.end(); i1++) {
delete (*i1);
}
for (vector<HepRepPoint*>::iterator i2 = points.begin(); i2 != points.end(); i2++) {
delete (*i2);
}
}
void DefaultHepRepInstance::overlay(HepRepInstance *) {
cerr << "DefaultHepRepInstance::overlay(HepRepInstance * instance) not implemented." << endl;
}
HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) not implemented." << endl;
return NULL;
}
HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) not implemented." << endl;
return NULL;
}
HepRepType* DefaultHepRepInstance::getType() {
return type;
}
void DefaultHepRepInstance::addPoint(HepRepPoint* point) {
points.push_back(point);
}
vector<HepRepPoint*> DefaultHepRepInstance::getPoints() {
return points;
}
HepRepInstance* DefaultHepRepInstance::getSuperInstance() {
return parent;
}
void DefaultHepRepInstance::addInstance(HepRepInstance* instance) {
instances.push_back(instance);
}
void DefaultHepRepInstance::removeInstance(HepRepInstance*) {
cerr << "DefaultHepRepInstance::removeInstance(HepRepInstance*) not implemented." << endl;
}
vector<HepRepInstance*> DefaultHepRepInstance::getInstances() {
return instances;
}
HepRepAttValue* DefaultHepRepInstance::getAttValue(string name) {
HepRepAttValue* value = getAttValueFromNode(name);
return (value != NULL) ? value : type->getAttValue(name);
}
} // cheprep
@@ -1,58 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/DefaultHepRepInstanceTree.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepInstanceTree::DefaultHepRepInstanceTree(string aName, string aVersion, HepRepTreeID* aTypeTree)
: DefaultHepRepTreeID(aName, aVersion), typeTree(aTypeTree) {
}
DefaultHepRepInstanceTree::~DefaultHepRepInstanceTree() {
for (vector<HepRepInstance*>::iterator i1 = instances.begin(); i1 != instances.end(); i1++) {
delete (*i1);
}
instances.clear();
}
void DefaultHepRepInstanceTree::overlay(HepRepInstanceTree *) {
cerr << "DefaultHepRepInstanceTree::overlay(HepRepInstanceTree * instanceTree) not implemented." << endl;
}
HepRepInstanceTree* DefaultHepRepInstanceTree::copy(HepRepTypeTree*, HepRepSelectFilter*) {
cerr << "DefaultHepRepInstanceTree::copy(HepRepTypeTree*, HepRepSelectFilter*) not implemented." << endl;
return NULL;
}
void DefaultHepRepInstanceTree::addInstance(HepRepInstance* instance) {
instances.push_back(instance);
}
void DefaultHepRepInstanceTree::removeInstance(HepRepInstance*) {
cerr << "DefaultHepRepInstanceTree::removeInstance(HepRepInstance*) not implemented." << endl;
}
vector<HepRepInstance*> DefaultHepRepInstanceTree::getInstances() {
return instances;
}
void DefaultHepRepInstanceTree::addInstanceTree(HepRepTreeID* treeID) {
instanceTrees.push_back(treeID);
}
HepRepTreeID* DefaultHepRepInstanceTree::getTypeTree() {
return typeTree;
}
vector<HepRepTreeID*> DefaultHepRepInstanceTree::getInstanceTreeList() {
return instanceTrees;
}
} // cheprep
@@ -1,123 +0,0 @@
// Copyright FreeHEP, 2005.
#include <string>
#include <iostream>
#include <cmath>
#include "cheprep/DefaultHepRepPoint.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepPoint::DefaultHepRepPoint(HepRepInstance* inst, double xx, double yy, double zz)
: DefaultHepRepAttribute(), instance(inst), x(xx), y(yy), z(zz) {
if (instance == NULL) {
cerr << "HepRepPoints cannot be created without a HepRepInstance." << endl;
} else {
instance->addPoint(this);
}
}
DefaultHepRepPoint::~DefaultHepRepPoint() {
}
HepRepInstance* DefaultHepRepPoint::getInstance() {
return instance;
}
HepRepAttValue* DefaultHepRepPoint::getAttValue(string lowerCaseName) {
HepRepAttValue* value = getAttValueFromNode(lowerCaseName);
return (value != NULL) ? value : instance->getAttValue(lowerCaseName);
}
HepRepPoint* DefaultHepRepPoint::copy(HepRepInstance* inst) {
return new DefaultHepRepPoint(inst, x, y, z);
}
double DefaultHepRepPoint::getX() {
return x;
}
double DefaultHepRepPoint::getY() {
return y;
}
double DefaultHepRepPoint::getZ() {
return z;
}
vector<double>* DefaultHepRepPoint::getXYZ(vector<double>* xyz) {
(*xyz)[0] = x;
(*xyz)[1] = y;
(*xyz)[2] = z;
return xyz;
}
double DefaultHepRepPoint::getRho() {
return sqrt(x*x + y*y);
}
double DefaultHepRepPoint::getPhi() {
return atan2(y, x);
}
double DefaultHepRepPoint::getTheta() {
return atan2(getRho(), z);
}
double DefaultHepRepPoint::getR() {
double r = getRho();
return sqrt(r*r + z*z);
}
double DefaultHepRepPoint::getEta() {
double ct = cos(getTheta());
return -0.5*log((1.-ct)/(1.+ct));
}
double DefaultHepRepPoint::getX(double xVertex, double, double) {
return x - xVertex;
}
double DefaultHepRepPoint::getY(double, double yVertex, double) {
return y - yVertex;
}
double DefaultHepRepPoint::getZ(double, double, double zVertex) {
return z - zVertex;
}
double DefaultHepRepPoint::getRho(double xVertex, double yVertex, double zVertex) {
double dx = getX(xVertex, yVertex, zVertex);
double dy = getY(xVertex, yVertex, zVertex);
return sqrt(dx*dx + dy*dy);
}
double DefaultHepRepPoint::getPhi(double xVertex, double yVertex, double zVertex) {
return atan2(getY(xVertex, yVertex, zVertex), getX(xVertex, yVertex, zVertex));
}
double DefaultHepRepPoint::getTheta(double xVertex, double yVertex, double zVertex) {
return atan2(getRho(xVertex, yVertex, zVertex), getZ(xVertex, yVertex, zVertex));
}
double DefaultHepRepPoint::getR(double xVertex, double yVertex, double zVertex) {
double dr = getRho(xVertex, yVertex, zVertex);
double dz = getZ(xVertex, yVertex, zVertex);
return sqrt(dr*dr + dz*dz);
}
double DefaultHepRepPoint::getEta(double xVertex, double yVertex, double zVertex) {
double ct = cos(getTheta(xVertex, yVertex, zVertex));
return -0.5*log((1.-ct)/(1.+ct));
}
} // cheprep
@@ -1,38 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include "cheprep/DefaultHepRepTreeID.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepTreeID::DefaultHepRepTreeID(string aName, string aVersion, string aQualifier)
: name(aName), version(aVersion), qualifier(aQualifier) {
}
DefaultHepRepTreeID::~DefaultHepRepTreeID() {
}
string DefaultHepRepTreeID::getQualifier() {
return qualifier;
}
void DefaultHepRepTreeID::setQualifier(string qual) {
this->qualifier = qual;
}
string DefaultHepRepTreeID::getName() {
return name;
}
string DefaultHepRepTreeID::getVersion() {
return version;
}
} // cheprep
@@ -1,112 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/DefaultHepRepType.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepType::DefaultHepRepType(HepRepType* parentType, string typeName)
: DefaultHepRepDefinition(), parent(parentType), name(typeName) {
this->description = "No Description";
this->infoURL = "No Info URL";
// HepRepTypes are sometimes used without a parent (top-level)
if (parent != NULL) {
parent->addType(this);
}
}
DefaultHepRepType::DefaultHepRepType(HepRepTypeTree* parentTypeTree, string typeName)
: DefaultHepRepDefinition(), parent(NULL), name(typeName) {
this->description = "No Description";
this->infoURL = "No Info URL";
parentTypeTree->addType(this);
}
DefaultHepRepType::~DefaultHepRepType() {
for (vector<HepRepType*>::iterator i1 = types.begin(); i1 != types.end(); i1++) {
delete (*i1);
}
}
HepRepType* DefaultHepRepType::getSuperType() {
return parent;
}
HepRepAttDef* DefaultHepRepType::getAttDef(string defName) {
HepRepAttDef* def = NULL;
HepRepType* type = this;
while ((def == NULL) && (type != NULL)) {
def = type->getAttDefFromNode(defName);
type = type->getSuperType();
}
if (def == NULL) {
cerr << "ERROR: No HepRepDefaults, trying to get definition for: " << defName << endl;
// FIXME, no HepRepDefaults
}
return def;
}
/**
* searched for a value with given name. Search up the type tree if needed.
*/
HepRepAttValue* DefaultHepRepType::getAttValue(string attName) {
HepRepAttValue* value = NULL;
HepRepType* type = this;
while ((value == NULL) && (type != NULL)) {
value = type->getAttValueFromNode(attName);
type = type->getSuperType();
}
if (value == NULL) {
cerr << "ERROR: No HepRepDefaults, trying to get value for: " << attName << endl;
// FIXME, no HepRepDefaults
}
return value;
}
HepRepType* DefaultHepRepType::copy(HepRepType*) {
cerr << "DefaultHepRepType::copy(HepRepType*) not implemented." << endl;
return NULL;
}
string DefaultHepRepType::getName() {
return name;
}
string DefaultHepRepType::getFullName() {
return (getSuperType() == NULL) ? getName() : getSuperType()->getFullName() + "/" + getName();
}
string DefaultHepRepType::getDescription() {
return description;
}
void DefaultHepRepType::setDescription(string desc) {
this->description = desc;
}
string DefaultHepRepType::getInfoURL() {
return infoURL;
}
void DefaultHepRepType::setInfoURL(string info) {
this->infoURL = info;
}
void DefaultHepRepType::addType(HepRepType* type) {
// FIXME should check if type already exists
types.push_back(type);
}
vector<HepRepType*> DefaultHepRepType::getTypeList() {
return types;
}
} // cheprep
@@ -1,45 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include "cheprep/DefaultHepRepTypeTree.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
DefaultHepRepTypeTree::DefaultHepRepTypeTree(HepRepTreeID* typeTree)
: DefaultHepRepTreeID(typeTree->getName(), typeTree->getVersion()) {
delete typeTree;
}
DefaultHepRepTypeTree::~DefaultHepRepTypeTree() {
for (vector<HepRepType*>::iterator i1 = types.begin(); i1 != types.end(); i1++) {
delete (*i1);
}
}
HepRepTypeTree* DefaultHepRepTypeTree::copy() {
cerr << "DefaultHepRepTypeTree::copy() not implemented." << endl;
return NULL;
}
void DefaultHepRepTypeTree::addType(HepRepType* type) {
// FIXME should check if type already exists
types.push_back(type);
}
vector<HepRepType*> DefaultHepRepTypeTree::getTypeList() {
return types;
}
HepRepType* DefaultHepRepTypeTree::getType(string /*typeName*/) {
cerr << "DefaultHepRepTypeTree::getType(string) not implemented." << endl;
return NULL;
}
} // cheprep
@@ -1,244 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/DeflateOutputStreamBuffer.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
using namespace std;
unsigned long DeflateOutputStreamBuffer::crctable[] = {
0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL,
0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L,
0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L,
0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L,
0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL,
0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L,
0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL,
0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L,
0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L,
0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL,
0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L,
0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L,
0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L,
0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL,
0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L,
0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL,
0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL,
0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L,
0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L,
0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L,
0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL,
0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L,
0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL,
0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L,
0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L,
0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL,
0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L,
0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L,
0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L,
0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL,
0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L,
0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL,
0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL,
0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L,
0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L,
0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L,
0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL,
0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L,
0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL,
0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L,
0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L,
0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL,
0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L,
0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L,
0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L,
0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL,
0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L,
0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL,
0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL,
0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L,
0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L,
0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L,
0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL,
0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L,
0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL,
0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L,
0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L,
0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL,
0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L,
0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L,
0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L,
0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL,
0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L,
0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL
};
DeflateOutputStreamBuffer::DeflateOutputStreamBuffer(streambuf *aBuffer)
: buffer(aBuffer)
, crc(0)
, size(0)
#ifndef CHEPREP_NO_ZLIB
, zStreamOpen(false)
, in(inSize)
, out(outSize)
#endif // CHEPREP_NO_ZLIB
{
#ifndef CHEPREP_NO_ZLIB
zStream.zalloc = Z_NULL;
zStream.zfree = Z_NULL;
zStream.opaque = Z_NULL;
zStream.msg = 0;
zStream.next_in = 0;
zStream.next_out = 0;
zStream.state = 0;
#endif // CHEPREP_NO_ZLIB
}
#ifndef CHEPREP_NO_ZLIB
void DeflateOutputStreamBuffer::init(bool compress) {
if (compress) {
if (zStreamOpen) return;
zStream.next_in = reinterpret_cast<unsigned char *>(&(in[0]));
zStream.avail_in = 0 ;
zStream.next_out = reinterpret_cast<unsigned char *>(&(out[0]));
zStream.avail_out = out.size();
if (deflateInit2(&zStream, 6, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY ) != Z_OK) {
cerr << "ERROR: deflateInit2 failed" << endl;
} else {
zStreamOpen = true;
setp(&(in[0]), &(in[0])+inSize);
}
}
#else
void DeflateOutputStreamBuffer::init(bool /*compress*/) {
#endif // CHEPREP_NO_ZLIB
crc = 0;
size = 0;
}
void DeflateOutputStreamBuffer::finish() {
#ifndef CHEPREP_NO_ZLIB
if (zStreamOpen) {
overflow() ;
zStream.next_out = reinterpret_cast<unsigned char *>(&(out[0]));
zStream.avail_out = outSize;
int err = Z_OK ;
while ( err == Z_OK ) {
if (zStream.avail_out == 0) {
flushOut();
}
err = deflate(&zStream, Z_FINISH);
}
flushOut() ;
if (err != Z_STREAM_END) {
cerr << "ERROR: deflation failed" << endl;
}
if (deflateEnd(&zStream) != Z_OK) {
cerr << "ERROR: deflateEnd failed" << endl;
}
zStreamOpen = false ;
}
#endif // CHEPREP_NO_ZLIB
}
DeflateOutputStreamBuffer::~DeflateOutputStreamBuffer() {
}
#ifndef CHEPREP_NO_ZLIB
#define DO1 crc = crctable[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
#endif // CHEPREP_NO_ZLIB
int DeflateOutputStreamBuffer::overflow(int c) {
#ifndef CHEPREP_NO_ZLIB
if (zStreamOpen) {
zStream.avail_in = pptr() - pbase() ;
zStream.next_in = reinterpret_cast<unsigned char *>(&(in[0]));
int len = zStream.avail_in;
unsigned char* buf = zStream.next_in;
crc = crc ^ 0xffffffffUL;
while (len >= 8) {
DO8;
len -= 8;
}
if (len) do {
DO1;
} while (--len);
crc = crc ^ 0xffffffffUL;
size += zStream.avail_in;
zStream.next_out = reinterpret_cast<unsigned char *>(&(out[0]));
zStream.avail_out = outSize ;
int err = Z_OK ;
while ((zStream.avail_in > 0 || zStream.avail_out == 0) && err == Z_OK) {
if (zStream.avail_out == 0 ) {
flushOut();
}
err = deflate(&zStream, Z_NO_FLUSH);
}
flushOut();
setp(&(in[0]), &(in[0]) + inSize);
if ((err != Z_OK) && (err != Z_STREAM_END)) {
cerr << "ERROR: deflation failed" << endl;
return EOF ;
}
if ( c != EOF ) {
*pptr() = c ;
pbump(1);
}
return 0 ;
} else {
#endif // CHEPREP_NO_ZLIB
crc = crc ^ 0xffffffffUL;
crc = crctable[(crc ^ c) & 0xff] ^ (crc >> 8);
crc = crc ^ 0xffffffffUL;
size++;
return buffer->sputc((char)c);
#ifndef CHEPREP_NO_ZLIB
}
#endif // CHEPREP_NO_ZLIB
}
#ifndef CHEPREP_NO_ZLIB
bool DeflateOutputStreamBuffer::flushOut() {
int deflatedCount = outSize - zStream.avail_out;
int byteCount = buffer->sputn(&(out[0]), deflatedCount);
zStream.next_out = reinterpret_cast<unsigned char *>(&(out[0]));
zStream.avail_out = outSize ;
return deflatedCount == byteCount ;
}
#endif // CHEPREP_NO_ZLIB
} // cheprep
@@ -1,87 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/**
* We allow only one HepRep Scene handler and one attached Viewer.
* The sceneHandler associates with the output file
*
* @author Mark Donszelmann
*/
//G4
#include "G4Types.hh"
#include "G4HepRepViewer.hh"
#include "G4HepRepSceneHandler.hh"
#include "G4HepRepMessenger.hh"
//This
#include "G4HepRep.hh"
using namespace HEPREP;
using namespace std;
G4HepRep::G4HepRep ()
: G4VGraphicsSystem ("G4HepRep",
"HepRepXML",
"HepRep Generic Driver for XML, RMI and CORBA",
G4VGraphicsSystem::fileWriter),
sceneHandler(NULL),
viewer(NULL) {
G4HepRepMessenger::GetInstance();
}
G4HepRep::~G4HepRep () {
}
G4VSceneHandler* G4HepRep::CreateSceneHandler (const G4String& name) {
if (sceneHandler != NULL) {
cout << "G4HepRep::CreateSceneHandler: Cannot create more than one G4HepRepSceneHandler" << endl;
return NULL;
}
sceneHandler = new G4HepRepSceneHandler (*this, name);
return sceneHandler;
}
G4VViewer* G4HepRep::CreateViewer (G4VSceneHandler& scene, const G4String& name) {
if (viewer != NULL) {
cout << "G4HepRep::CreateViewer: Cannot create more than one G4HepRepViewer" << endl;
return NULL;
}
viewer = new G4HepRepViewer ((G4HepRepSceneHandler&)scene, name);
return viewer;
}
void G4HepRep::removeSceneHandler() {
// actual deletion is done in VisManager
sceneHandler = NULL;
}
void G4HepRep::removeViewer() {
// actual deletion is done in VisManager
viewer = NULL;
}
+30 -28
View File
@@ -24,12 +24,12 @@
// ********************************************************************
//
//
//
//
// Joseph Perl 1 October 2001
// A graphics system to dump geometry hierarchy to the
// HepRep graphics format (HepRep version 1).
//HepRep
// HepRep
#include "G4HepRepFileXMLWriter.hh"
#include "G4HepRepFile.hh"
@@ -39,48 +39,50 @@
static G4HepRepFileXMLWriter* hepRepXMLWriter;
G4HepRepFile::G4HepRepFile():
G4VGraphicsSystem("G4HepRepFile",
"HepRepFile",
"A HepRep (format 1) ascii file driver",
G4VGraphicsSystem::fileWriter) {
G4HepRepMessenger::GetInstance();
hepRepXMLWriter = new G4HepRepFileXMLWriter();
}
G4HepRepFile::~G4HepRepFile()
G4HepRepFile::G4HepRepFile()
: G4VGraphicsSystem("G4HepRepFile", "HepRepFile",
"A HepRep (format 1) ascii file driver",
G4VGraphicsSystem::fileWriter)
{
delete hepRepXMLWriter;
G4HepRepMessenger::GetInstance();
hepRepXMLWriter = new G4HepRepFileXMLWriter();
}
G4VSceneHandler* G4HepRepFile::CreateSceneHandler(const G4String& name) {
G4HepRepFile::~G4HepRepFile() { delete hepRepXMLWriter; }
G4VSceneHandler* G4HepRepFile::CreateSceneHandler(const G4String& name)
{
G4VSceneHandler* pScene = new G4HepRepFileSceneHandler(*this, name);
return pScene;
}
G4VViewer* G4HepRepFile::CreateViewer(G4VSceneHandler& scene,
const G4String& name) {
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;
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;
else
{
G4cout << "G4HepRepFile::CreateViewer: ERROR: null pointer on new "
"G4HepRepFileViewer."
<< G4endl;
}
return pView;
}
G4HepRepFileXMLWriter* G4HepRepFile::GetHepRepXMLWriter () {
return hepRepXMLWriter;
G4HepRepFileXMLWriter* G4HepRepFile::GetHepRepXMLWriter()
{
return hepRepXMLWriter;
}
File diff suppressed because it is too large Load Diff
@@ -30,48 +30,52 @@
#include "G4HepRepFileSceneHandler.hh"
//HepRep
// HepRep
#include "G4HepRepFileXMLWriter.hh"
G4HepRepFileViewer::G4HepRepFileViewer
(G4VSceneHandler& sceneHandler, const G4String& name):
G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name) {
hepRepXMLWriter = ((G4HepRepFileSceneHandler*)(&sceneHandler))->GetHepRepXMLWriter();
G4HepRepFileViewer::G4HepRepFileViewer(G4VSceneHandler& sceneHandler,
const G4String& name)
: G4VViewer(sceneHandler, sceneHandler.IncrementViewCount(), name)
{
hepRepXMLWriter =
((G4HepRepFileSceneHandler*) (&sceneHandler))->GetHepRepXMLWriter();
// Make changes to view parameters for HepRep...
fVP.SetCulling(false);
fDefaultVP.SetCulling(false);
}
G4HepRepFileViewer::~G4HepRepFileViewer() {
ShowView ();
}
G4HepRepFileViewer::~G4HepRepFileViewer() { ShowView(); }
void G4HepRepFileViewer::SetView() {
void G4HepRepFileViewer::SetView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::SetView() called.=" << G4endl;
#endif
}
void G4HepRepFileViewer::ClearView() {
void G4HepRepFileViewer::ClearView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::ClearView() called." << G4endl;
#endif
}
void G4HepRepFileViewer::DrawView() {
void G4HepRepFileViewer::DrawView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::DrawView() called." << G4endl;
#endif
NeedKernelVisit (); // Always need to visit G4 kernel.
ProcessView ();
NeedKernelVisit(); // Always need to visit G4 kernel.
ProcessView();
}
void G4HepRepFileViewer::ShowView () {
void G4HepRepFileViewer::ShowView()
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileViewer::ShowView" << G4endl;
#endif
G4VViewer::ShowView();
if (hepRepXMLWriter->isOpen)
if(hepRepXMLWriter->isOpen)
hepRepXMLWriter->close();
}
@@ -55,38 +55,40 @@ void G4HepRepFileXMLWriter::init()
typeDepth = -1;
int i = -1;
while (i++<49) {
while(i++ < 49)
{
prevTypeName[i] = new char[1];
strcpy(prevTypeName[i],"");
strcpy(prevTypeName[i], "");
inType[i] = false;
inType[i] = false;
inInstance[i] = false;
}
inPrimitive = false;
inPoint = false;
inPoint = false;
}
void G4HepRepFileXMLWriter::addType(const char* name,int newTypeDepth)
void G4HepRepFileXMLWriter::addType(const char* name, int newTypeDepth)
{
if (fout.good())
if(fout.good())
{
// Flatten structure if it exceeds maximum allowed typeDepth of 49.
if (newTypeDepth > 49)
if(newTypeDepth > 49)
newTypeDepth = 49;
if (newTypeDepth < 0)
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)) {
while(typeDepth < (newTypeDepth - 1))
{
addType("Layer Inserted by G4HepRepFileXMLWriter", typeDepth + 1);
addInstance();
}
// If moving closer to the root, close previously open types.
while (newTypeDepth<typeDepth)
while(newTypeDepth < typeDepth)
endType();
// Close any remaining primitives of the current instance.
@@ -94,226 +96,276 @@ void G4HepRepFileXMLWriter::addType(const char* name,int newTypeDepth)
// 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(strcmp(name, prevTypeName[newTypeDepth]) != 0)
{
if (inType[newTypeDepth])
endType();
if(inType[newTypeDepth])
endType();
prevTypeName[newTypeDepth] = new char[strlen(name)+1];
strcpy(prevTypeName[newTypeDepth],name);
prevTypeName[newTypeDepth] = new char[strlen(name) + 1];
strcpy(prevTypeName[newTypeDepth], name);
inType[newTypeDepth] = true;
indent();
fout << "<heprep:type version=\"null\" name=\"" << name << "\">"
<< G4endl;
<< G4endl;
typeDepth = newTypeDepth;
}
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addType No file is currently open." << G4endl;
G4cout << "G4HepRepFileXMLWriter:addType No file is currently open."
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addInstance()
{
if (fout.good())
if(fout.good())
{
if (inType[typeDepth])
if(inType[typeDepth])
{
endInstance();
inInstance[typeDepth] = true;
indent();
fout << "<heprep:instance>" << G4endl;
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addInstance No HepRep Type is currently open" << G4endl;
G4cout
<< "G4HepRepFileXMLWriter:addInstance No HepRep Type is currently open"
<< G4endl;
#endif
}
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addInstance No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addInstance No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addPrimitive()
{
if (fout.good())
if(fout.good())
{
if (inInstance[typeDepth])
if(inInstance[typeDepth])
{
endPrimitive();
inPrimitive = true;
indent();
fout << "<heprep:primitive>" << G4endl;
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPrimitive No HepRep Instance is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addPrimitive No HepRep Instance is "
"currently open"
<< G4endl;
#endif
}
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPrimitive No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addPrimitive No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addPoint(double x, double y, double z)
{
if (fout.good())
if(fout.good())
{
if (inPrimitive)
if(inPrimitive)
{
endPoint();
inPoint = true;
indent();
// Include scale and center values
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
G4double scale = messenger->getScale();
G4ThreeVector center = messenger->getCenter();
G4double xNew = scale * ( x - center.x());
G4double yNew = scale * ( y - center.y());
G4double zNew = scale * ( z - center.z());
fout << "<heprep:point x=\"" << xNew << "\" y=\"" << yNew << "\" z=\"" << zNew << "\">" << G4endl;
} else {
// Include scale and center values
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
G4double scale = messenger->getScale();
G4ThreeVector center = messenger->getCenter();
G4double xNew = scale * (x - center.x());
G4double yNew = scale * (y - center.y());
G4double zNew = scale * (z - center.z());
fout << "<heprep:point x=\"" << xNew << "\" y=\"" << yNew << "\" z=\""
<< zNew << "\">" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPoint No HepRep Primitive is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addPoint No HepRep Primitive is "
"currently open"
<< G4endl;
#endif
}
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addPoint No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addPoint No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttDef(const char* name,
const char* desc,
const char* type,
const char* extra)
void G4HepRepFileXMLWriter::addAttDef(const char* name, const char* desc,
const char* type, const char* extra)
{
if (fout.good())
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;
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttDef No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addAttDef No file is currently open"
<< G4endl;
#endif
}
}
// Four methods to fill attValues
void G4HepRepFileXMLWriter::addAttValue (const char* name,
const char* value)
void G4HepRepFileXMLWriter::addAttValue(const char* name, const char* value)
{
if (fout.good())
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue (const char* name,
double value)
void G4HepRepFileXMLWriter::addAttValue(const char* name, double value)
{
if (fout.good())
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue (const char* name,
int value)
void G4HepRepFileXMLWriter::addAttValue(const char* name, int value)
{
if (fout.good())
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << value << "\"/>" << G4endl;
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue (const char* name,
bool value)
void G4HepRepFileXMLWriter::addAttValue(const char* name, bool value)
{
if (fout.good())
if(fout.good())
{
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
if (value)
if(value)
fout << " value=\"True\"/>" << G4endl;
else
fout << " value=\"False\"/>" << G4endl;
} else {
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::addAttValue (const char* name,
double value1,
double value2,
double value3)
void G4HepRepFileXMLWriter::addAttValue(const char* name, double value1,
double value2, double value3)
{
if (fout.good())
if(fout.good())
{
int redness = int(value1*255.);
int greenness = int(value2*255.);
int blueness = int(value3*255.);
int redness = int(value1 * 255.);
int greenness = int(value2 * 255.);
int blueness = int(value3 * 255.);
indent();
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\"" << G4endl;
fout << " <heprep:attvalue showLabel=\"NONE\" name=\"" << name << "\""
<< G4endl;
indent();
fout << " value=\"" << redness << "," << greenness << "," << blueness << "\"/>" << G4endl;
} else {
fout << " value=\"" << redness << "," << greenness << "," << blueness
<< "\"/>" << G4endl;
}
else
{
#ifdef G4HEPREPFILEDEBUG
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open" << G4endl;
G4cout << "G4HepRepFileXMLWriter:addAttValue No file is currently open"
<< G4endl;
#endif
}
}
void G4HepRepFileXMLWriter::open(const char* fileSpec)
{
if (isOpen)
if(isOpen)
close();
fout.open(fileSpec);
if (fout.good()) {
if(fout.good())
{
fout << "<?xml version=\"1.0\" ?>" << G4endl;
fout << "<heprep:heprep xmlns:heprep=\"http://www.slac.stanford.edu/~perl/heprep/\"" << G4endl;
fout << " xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xsi:schemaLocation=\"HepRep.xsd\">" << G4endl;
fout << "<heprep:heprep "
"xmlns:heprep=\"http://www.slac.stanford.edu/~perl/heprep/\""
<< G4endl;
fout << " xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" "
"xsi:schemaLocation=\"HepRep.xsd\">"
<< G4endl;
isOpen = true;
init();
} else {
G4cout << "G4HepRepFileXMLWriter:open Unable to write to file " << fileSpec << G4endl;
}
else
{
G4cout << "G4HepRepFileXMLWriter:open Unable to write to file " << fileSpec
<< G4endl;
}
}
@@ -322,11 +374,14 @@ void G4HepRepFileXMLWriter::close()
// Close any remaining open Types
endTypes();
if (fout.good()) {
if(fout.good())
{
fout << "</heprep:heprep>" << G4endl;
fout.close( );
fout.close();
isOpen = false;
} else {
}
else
{
G4cout << "G4HepRepFileXMLWriter:close No file is currently open" << G4endl;
}
}
@@ -334,8 +389,8 @@ void G4HepRepFileXMLWriter::close()
void G4HepRepFileXMLWriter::endTypes()
{
// Close any remaining open Types
while(typeDepth>-1)
endType();
while(typeDepth > -1)
endType();
}
void G4HepRepFileXMLWriter::endType()
@@ -344,15 +399,15 @@ void G4HepRepFileXMLWriter::endType()
indent();
fout << "</heprep:type>" << G4endl;
inType[typeDepth] = false;
delete [] prevTypeName[typeDepth];
delete[] prevTypeName[typeDepth];
prevTypeName[typeDepth] = new char[1];
strcpy(prevTypeName[typeDepth],"");
strcpy(prevTypeName[typeDepth], "");
typeDepth--;
}
void G4HepRepFileXMLWriter::endInstance()
{
if (inInstance[typeDepth])
if(inInstance[typeDepth])
{
endPrimitive();
indent();
@@ -363,7 +418,7 @@ void G4HepRepFileXMLWriter::endInstance()
void G4HepRepFileXMLWriter::endPrimitive()
{
if (inPrimitive)
if(inPrimitive)
{
endPoint();
indent();
@@ -374,7 +429,7 @@ void G4HepRepFileXMLWriter::endPrimitive()
void G4HepRepFileXMLWriter::endPoint()
{
if (inPoint)
if(inPoint)
{
indent();
fout << "</heprep:point>" << G4endl;
@@ -384,19 +439,20 @@ void G4HepRepFileXMLWriter::endPoint()
void G4HepRepFileXMLWriter::indent()
{
if (fout.good())
if(fout.good())
{
int i = 0;
while (inType[i] && i<12) {
while(inType[i] && i < 12)
{
fout << " ";
if (inInstance[i])
if(inInstance[i])
fout << " ";
i++;
}
if (inPrimitive)
if(inPrimitive)
fout << " ";
if (inPoint)
if(inPoint)
fout << " ";
}
}
@@ -26,244 +26,302 @@
//
#include "G4HepRepMessenger.hh"
G4HepRepMessenger*
G4HepRepMessenger::fpInstance = 0;
G4HepRepMessenger* G4HepRepMessenger::fpInstance = 0;
G4HepRepMessenger*
G4HepRepMessenger::GetInstance()
G4HepRepMessenger* G4HepRepMessenger::GetInstance()
{
if (!fpInstance) fpInstance = new G4HepRepMessenger;
return fpInstance;
if(!fpInstance)
fpInstance = new G4HepRepMessenger;
return fpInstance;
}
G4HepRepMessenger::G4HepRepMessenger() :
fileDir(""),
fileName("G4Data"),
overwrite(false),
cullInvisibles(false),
cylAsPolygons(false),
scale(1.),
suffix (""),
geometry(true),
pointAttributes(false),
solids(true),
invisibles(true) {
G4HepRepMessenger::G4HepRepMessenger()
: fileDir("")
, fileName("G4Data")
, overwrite(false)
, cullInvisibles(false)
, cylAsPolygons(false)
, scale(1.)
, suffix("")
, geometry(true)
, pointAttributes(false)
, solids(true)
, invisibles(true)
{
heprepDirectory = new G4UIdirectory("/vis/heprep/");
heprepDirectory->SetGuidance("HepRep commands.");
heprepDirectory = new G4UIdirectory("/vis/heprep/");
heprepDirectory->SetGuidance("HepRep commands.");
setFileDirCommand = new G4UIcmdWithAString("/vis/heprep/setFileDir", this);
setFileDirCommand->SetGuidance("Set directory for output.");
setFileDirCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setFileDirCommand->SetParameterName("directory",false);
if ( std::getenv( "G4HEPREPFILE_DIR" ) == NULL ) {
setFileDirCommand->SetDefaultValue("");
} else {
setFileDirCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_DIR"));
fileDir = std::getenv("G4HEPREPFILE_DIR");
}
setFileDirCommand->AvailableForStates(G4State_Idle);
setFileNameCommand = new G4UIcmdWithAString("/vis/heprep/setFileName", this);
setFileNameCommand->SetGuidance("Set file name for output.");
setFileNameCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setFileNameCommand->SetParameterName("directory",false);
if ( std::getenv( "G4HEPREPFILE_NAME" ) == NULL ) {
setFileNameCommand->SetDefaultValue("G4Data");
} else {
setFileNameCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_NAME"));
fileName = std::getenv("G4HEPREPFILE_NAME");
}
setFileNameCommand->AvailableForStates(G4State_Idle);
setFileDirCommand = new G4UIcmdWithAString("/vis/heprep/setFileDir", this);
setFileDirCommand->SetGuidance("Set directory for output.");
setFileDirCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setFileDirCommand->SetParameterName("directory", false);
if(std::getenv("G4HEPREPFILE_DIR") == NULL)
{
setFileDirCommand->SetDefaultValue("");
}
else
{
setFileDirCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_DIR"));
fileDir = std::getenv("G4HEPREPFILE_DIR");
}
setFileDirCommand->AvailableForStates(G4State_Idle);
setOverwriteCommand = new G4UIcmdWithABool("/vis/heprep/setOverwrite", this);
setOverwriteCommand->SetGuidance("Set true to write all output to exact same file name.");
setOverwriteCommand->SetGuidance("Set false to increment the file name for each new output.");
setOverwriteCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setOverwriteCommand->SetParameterName("flag",false);
if ( std::getenv( "G4HEPREPFILE_OVERWRITE" ) == NULL ) {
setOverwriteCommand->SetDefaultValue(false);
} else {
setOverwriteCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_OVERWRITE"));
overwrite = setOverwriteCommand->ConvertToBool(std::getenv("G4HEPREPFILE_OVERWRITE"));
}
setOverwriteCommand->AvailableForStates(G4State_Idle);
setCullInvisiblesCommand = new G4UIcmdWithABool("/vis/heprep/setCullInvisibles", this);
setCullInvisiblesCommand->SetGuidance("Remove invisible objects from output file.");
setCullInvisiblesCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
setCullInvisiblesCommand->SetParameterName("flag",false);
if ( std::getenv( "G4HEPREPFILE_CULL" ) == NULL ) {
setCullInvisiblesCommand->SetDefaultValue(false);
} else {
setCullInvisiblesCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_CULL"));
cullInvisibles = setCullInvisiblesCommand->ConvertToBool(std::getenv("G4HEPREPFILE_CULL"));
}
setCullInvisiblesCommand->AvailableForStates(G4State_Idle);
renderCylAsPolygonsCommand = new G4UIcmdWithABool("/vis/heprep/renderCylAsPolygons", this);
renderCylAsPolygonsCommand->SetGuidance("Render cylinders and cones as polygons.");
renderCylAsPolygonsCommand->SetGuidance("This command is used by HepRepFile, not by HepRepXML.");
renderCylAsPolygonsCommand->SetParameterName("flag",false);
renderCylAsPolygonsCommand->SetDefaultValue(false);
renderCylAsPolygonsCommand->AvailableForStates(G4State_Idle);
setScaleCommand = new G4UIcmdWithADouble("/vis/heprep/scale",this);
setScaleCommand->SetGuidance("Re-Scale coordinates.");
setScaleCommand->SetParameterName("Scale",true);
setScaleCommand->SetDefaultValue(1.);
setScaleCommand->SetRange("Scale > 0");
setCenterCommand = new G4UIcmdWith3VectorAndUnit("/vis/heprep/center",this);
setCenterCommand->SetGuidance("Re-Center coordinates.");
setCenterCommand->SetParameterName("CenterX","CenterY","CenterZ",true);
setCenterCommand->SetDefaultValue(G4ThreeVector(0.,0.,0.));
setCenterCommand->SetDefaultUnit("m");
setEventNumberSuffixCommand = new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this);
setEventNumberSuffixCommand->SetGuidance("Write separate event files, appended with given suffix.");
setEventNumberSuffixCommand->SetGuidance("Define the suffix with a pattern such as '-0000'.");
setEventNumberSuffixCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
setEventNumberSuffixCommand->SetParameterName("suffix",false);
setEventNumberSuffixCommand->SetDefaultValue("");
setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
appendGeometryCommand = new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
appendGeometryCommand->SetGuidance("Appends copy of geometry to every event.");
appendGeometryCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
appendGeometryCommand->SetParameterName("flag",false);
appendGeometryCommand->SetDefaultValue(true);
appendGeometryCommand->AvailableForStates(G4State_Idle);
setFileNameCommand = new G4UIcmdWithAString("/vis/heprep/setFileName", this);
setFileNameCommand->SetGuidance("Set file name for output.");
setFileNameCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setFileNameCommand->SetParameterName("directory", false);
if(std::getenv("G4HEPREPFILE_NAME") == NULL)
{
setFileNameCommand->SetDefaultValue("G4Data");
}
else
{
setFileNameCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_NAME"));
fileName = std::getenv("G4HEPREPFILE_NAME");
}
setFileNameCommand->AvailableForStates(G4State_Idle);
addPointAttributesCommand = new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this);
addPointAttributesCommand->SetGuidance("Adds point attributes to the points of trajectories.");
addPointAttributesCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile.");
addPointAttributesCommand->SetParameterName("flag",false);
addPointAttributesCommand->SetDefaultValue(false);
addPointAttributesCommand->AvailableForStates(G4State_Idle);
useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this);
useSolidsCommand->SetGuidance("Use HepRep Solids, rather than Geant4 Primitives.");
useSolidsCommand->SetGuidance("This command is used by HepRepXML, not by HepRepFile..");
useSolidsCommand->SetParameterName("flag",false);
useSolidsCommand->SetDefaultValue(true);
useSolidsCommand->AvailableForStates(G4State_Idle);
setOverwriteCommand = new G4UIcmdWithABool("/vis/heprep/setOverwrite", this);
setOverwriteCommand->SetGuidance(
"Set true to write all output to exact same file name.");
setOverwriteCommand->SetGuidance(
"Set false to increment the file name for each new output.");
setOverwriteCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setOverwriteCommand->SetParameterName("flag", false);
if(std::getenv("G4HEPREPFILE_OVERWRITE") == NULL)
{
setOverwriteCommand->SetDefaultValue(false);
}
else
{
setOverwriteCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_OVERWRITE"));
overwrite =
setOverwriteCommand->ConvertToBool(std::getenv("G4HEPREPFILE_OVERWRITE"));
}
setOverwriteCommand->AvailableForStates(G4State_Idle);
setCullInvisiblesCommand =
new G4UIcmdWithABool("/vis/heprep/setCullInvisibles", this);
setCullInvisiblesCommand->SetGuidance(
"Remove invisible objects from output file.");
setCullInvisiblesCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
setCullInvisiblesCommand->SetParameterName("flag", false);
if(std::getenv("G4HEPREPFILE_CULL") == NULL)
{
setCullInvisiblesCommand->SetDefaultValue(false);
}
else
{
setCullInvisiblesCommand->SetDefaultValue(std::getenv("G4HEPREPFILE_CULL"));
cullInvisibles =
setCullInvisiblesCommand->ConvertToBool(std::getenv("G4HEPREPFILE_CULL"));
}
setCullInvisiblesCommand->AvailableForStates(G4State_Idle);
renderCylAsPolygonsCommand =
new G4UIcmdWithABool("/vis/heprep/renderCylAsPolygons", this);
renderCylAsPolygonsCommand->SetGuidance(
"Render cylinders and cones as polygons.");
renderCylAsPolygonsCommand->SetGuidance(
"This command is used by HepRepFile, not by HepRepXML.");
renderCylAsPolygonsCommand->SetParameterName("flag", false);
renderCylAsPolygonsCommand->SetDefaultValue(false);
renderCylAsPolygonsCommand->AvailableForStates(G4State_Idle);
setScaleCommand = new G4UIcmdWithADouble("/vis/heprep/scale", this);
setScaleCommand->SetGuidance("Re-Scale coordinates.");
setScaleCommand->SetParameterName("Scale", true);
setScaleCommand->SetDefaultValue(1.);
setScaleCommand->SetRange("Scale > 0");
setCenterCommand = new G4UIcmdWith3VectorAndUnit("/vis/heprep/center", this);
setCenterCommand->SetGuidance("Re-Center coordinates.");
setCenterCommand->SetParameterName("CenterX", "CenterY", "CenterZ", true);
setCenterCommand->SetDefaultValue(G4ThreeVector(0., 0., 0.));
setCenterCommand->SetDefaultUnit("m");
setEventNumberSuffixCommand =
new G4UIcmdWithAString("/vis/heprep/setEventNumberSuffix", this);
setEventNumberSuffixCommand->SetGuidance(
"Write separate event files, appended with given suffix.");
setEventNumberSuffixCommand->SetGuidance(
"Define the suffix with a pattern such as '-0000'.");
setEventNumberSuffixCommand->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile.");
setEventNumberSuffixCommand->SetParameterName("suffix", false);
setEventNumberSuffixCommand->SetDefaultValue("");
setEventNumberSuffixCommand->AvailableForStates(G4State_Idle);
appendGeometryCommand =
new G4UIcmdWithABool("/vis/heprep/appendGeometry", this);
appendGeometryCommand->SetGuidance(
"Appends copy of geometry to every event.");
appendGeometryCommand->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile.");
appendGeometryCommand->SetParameterName("flag", false);
appendGeometryCommand->SetDefaultValue(true);
appendGeometryCommand->AvailableForStates(G4State_Idle);
addPointAttributesCommand =
new G4UIcmdWithABool("/vis/heprep/addPointAttributes", this);
addPointAttributesCommand->SetGuidance(
"Adds point attributes to the points of trajectories.");
addPointAttributesCommand->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile.");
addPointAttributesCommand->SetParameterName("flag", false);
addPointAttributesCommand->SetDefaultValue(false);
addPointAttributesCommand->AvailableForStates(G4State_Idle);
useSolidsCommand = new G4UIcmdWithABool("/vis/heprep/useSolids", this);
useSolidsCommand->SetGuidance(
"Use HepRep Solids, rather than Geant4 Primitives.");
useSolidsCommand->SetGuidance(
"This command is used by HepRepXML, not by HepRepFile..");
useSolidsCommand->SetParameterName("flag", false);
useSolidsCommand->SetDefaultValue(true);
useSolidsCommand->AvailableForStates(G4State_Idle);
}
G4HepRepMessenger::~G4HepRepMessenger() {
delete setFileDirCommand;
delete setFileNameCommand;
delete setOverwriteCommand;
delete setCullInvisiblesCommand;
delete renderCylAsPolygonsCommand;
delete setScaleCommand;
delete setCenterCommand;
delete setEventNumberSuffixCommand;
delete appendGeometryCommand;
delete addPointAttributesCommand;
delete useSolidsCommand;
delete heprepDirectory;
G4HepRepMessenger::~G4HepRepMessenger()
{
delete setFileDirCommand;
delete setFileNameCommand;
delete setOverwriteCommand;
delete setCullInvisiblesCommand;
delete renderCylAsPolygonsCommand;
delete setScaleCommand;
delete setCenterCommand;
delete setEventNumberSuffixCommand;
delete appendGeometryCommand;
delete addPointAttributesCommand;
delete useSolidsCommand;
delete heprepDirectory;
}
G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand * command) {
if (command==setFileDirCommand) {
return fileDir;
} else if (command==setFileNameCommand) {
return fileName;
} else if (command==setOverwriteCommand) {
return overwrite;
} else if (command==setCullInvisiblesCommand) {
return cullInvisibles;
} else if (command==renderCylAsPolygonsCommand) {
return renderCylAsPolygonsCommand->ConvertToString(cylAsPolygons);
} else if (command==setScaleCommand) {
return setScaleCommand->ConvertToString(scale);
} else if (command==setCenterCommand) {
return setCenterCommand->ConvertToString(center,"m");
} else if (command==setEventNumberSuffixCommand) {
return suffix;
} else if (command==appendGeometryCommand) {
return appendGeometryCommand->ConvertToString(geometry);
} else if (command==addPointAttributesCommand) {
return addPointAttributesCommand->ConvertToString(pointAttributes);
} else if (command==useSolidsCommand) {
return useSolidsCommand->ConvertToString(solids);
} else {
return "";
}
}
void G4HepRepMessenger::SetNewValue(G4UIcommand * command, G4String newValue) {
if (command==setFileDirCommand) {
fileDir = newValue;
} else if (command==setFileNameCommand) {
fileName = newValue;
} else if (command==setOverwriteCommand) {
overwrite = setOverwriteCommand->GetNewBoolValue(newValue);
} else if (command==setCullInvisiblesCommand) {
cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue);
} else if (command==renderCylAsPolygonsCommand) {
cylAsPolygons = renderCylAsPolygonsCommand->GetNewBoolValue(newValue);
} else if (command==setScaleCommand) {
scale = setScaleCommand->GetNewDoubleValue(newValue);
} else if (command==setCenterCommand) {
center = setCenterCommand->GetNew3VectorValue(newValue);
} else if (command==setEventNumberSuffixCommand) {
suffix = newValue;
} else if (command==appendGeometryCommand) {
geometry = appendGeometryCommand->GetNewBoolValue(newValue);
} else if (command==addPointAttributesCommand) {
pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
} else if (command==useSolidsCommand) {
solids = useSolidsCommand->GetNewBoolValue(newValue);
}
}
G4String G4HepRepMessenger::getFileDir() {
G4String G4HepRepMessenger::GetCurrentValue(G4UIcommand* command)
{
if(command == setFileDirCommand)
{
return fileDir;
}
G4String G4HepRepMessenger::getFileName() {
}
else if(command == setFileNameCommand)
{
return fileName;
}
G4bool G4HepRepMessenger::getOverwrite() {
return overwrite;
}
G4bool G4HepRepMessenger::getCullInvisibles() {
return cullInvisibles;
}
G4bool G4HepRepMessenger::renderCylAsPolygons() {
return cylAsPolygons;
}
G4double G4HepRepMessenger::getScale() {
return scale;
}
G4ThreeVector G4HepRepMessenger::getCenter() {
return center;
}
G4String G4HepRepMessenger::getEventNumberSuffix() {
}
else if(command == setOverwriteCommand)
{
return G4UIcommand::ConvertToString(overwrite);
}
else if(command == setCullInvisiblesCommand)
{
return G4UIcommand::ConvertToString(cullInvisibles);
}
else if(command == renderCylAsPolygonsCommand)
{
return renderCylAsPolygonsCommand->ConvertToString(cylAsPolygons);
}
else if(command == setScaleCommand)
{
return setScaleCommand->ConvertToString(scale);
}
else if(command == setCenterCommand)
{
return setCenterCommand->ConvertToString(center, "m");
}
else if(command == setEventNumberSuffixCommand)
{
return suffix;
}
else if(command == appendGeometryCommand)
{
return appendGeometryCommand->ConvertToString(geometry);
}
else if(command == addPointAttributesCommand)
{
return addPointAttributesCommand->ConvertToString(pointAttributes);
}
else if(command == useSolidsCommand)
{
return useSolidsCommand->ConvertToString(solids);
}
else
{
return "";
}
}
G4bool G4HepRepMessenger::appendGeometry() {
return geometry;
void G4HepRepMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if(command == setFileDirCommand)
{
fileDir = newValue;
}
else if(command == setFileNameCommand)
{
fileName = newValue;
}
else if(command == setOverwriteCommand)
{
overwrite = setOverwriteCommand->GetNewBoolValue(newValue);
}
else if(command == setCullInvisiblesCommand)
{
cullInvisibles = setCullInvisiblesCommand->GetNewBoolValue(newValue);
}
else if(command == renderCylAsPolygonsCommand)
{
cylAsPolygons = renderCylAsPolygonsCommand->GetNewBoolValue(newValue);
}
else if(command == setScaleCommand)
{
scale = setScaleCommand->GetNewDoubleValue(newValue);
}
else if(command == setCenterCommand)
{
center = setCenterCommand->GetNew3VectorValue(newValue);
}
else if(command == setEventNumberSuffixCommand)
{
suffix = newValue;
}
else if(command == appendGeometryCommand)
{
geometry = appendGeometryCommand->GetNewBoolValue(newValue);
}
else if(command == addPointAttributesCommand)
{
pointAttributes = addPointAttributesCommand->GetNewBoolValue(newValue);
}
else if(command == useSolidsCommand)
{
solids = useSolidsCommand->GetNewBoolValue(newValue);
}
}
G4bool G4HepRepMessenger::addPointAttributes() {
return pointAttributes;
}
G4String G4HepRepMessenger::getFileDir() { return fileDir; }
G4bool G4HepRepMessenger::useSolids() {
return solids;
}
G4String G4HepRepMessenger::getFileName() { return fileName; }
G4bool G4HepRepMessenger::writeInvisibles() {
return invisibles;
}
G4bool G4HepRepMessenger::getOverwrite() { return overwrite; }
G4bool G4HepRepMessenger::getCullInvisibles() { return cullInvisibles; }
G4bool G4HepRepMessenger::renderCylAsPolygons() { return cylAsPolygons; }
G4double G4HepRepMessenger::getScale() { return scale; }
G4ThreeVector G4HepRepMessenger::getCenter() { return center; }
G4String G4HepRepMessenger::getEventNumberSuffix() { return suffix; }
G4bool G4HepRepMessenger::appendGeometry() { return geometry; }
G4bool G4HepRepMessenger::addPointAttributes() { return pointAttributes; }
G4bool G4HepRepMessenger::useSolids() { return solids; }
G4bool G4HepRepMessenger::writeInvisibles() { return invisibles; }
File diff suppressed because it is too large Load Diff
@@ -1,130 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * 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. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/**
* @author Mark Donszelmann
*/
//HepRep
#include "HEPREP/HepRep.h"
//G4
#include "G4Types.hh"
//#include "G4VInteractorManager.hh"
#include "G4Scene.hh"
#include "G4HepRep.hh"
#include "G4HepRepMessenger.hh"
#include "G4HepRepSceneHandler.hh"
//This
#include "G4HepRepViewer.hh"
using namespace HEPREP;
using namespace std;
G4HepRepViewer::G4HepRepViewer (G4VSceneHandler& sceneHandler, const G4String& name)
: G4VViewer (sceneHandler, sceneHandler.IncrementViewCount(), name),
geometryIncluded(false) {
#ifdef SDEBUG
cout << "G4HepRepViewer::G4HepRepViewer " << name << endl;
#endif
// Make changes to view parameters for HepRep...
fVP.SetCulling(false);
fDefaultVP.SetCulling(false);
}
G4HepRepViewer::~G4HepRepViewer () {
#ifdef SDEBUG
cout << "G4HepRepViewer::~G4HepRepViewer" << endl;
#endif
G4HepRep* pHepRepSystem =
dynamic_cast<G4HepRep*>(GetSceneHandler()->GetGraphicsSystem());
if (pHepRepSystem) pHepRepSystem->removeViewer();
}
void G4HepRepViewer::ClearView () {
#ifdef SDEBUG
cout << "G4HepRepViewer::ClearView" << endl;
#endif
}
void G4HepRepViewer::SetView () {
#ifdef SDEBUG
cout << "G4HepRepViewer::SetView" << endl;
#endif
}
/* NOTE:
/run/beamOn calls ShowView for every event (unless accumulate is set)
/vis/viewer/flush calls /vis/viewer/refresh followed by /vis/viewer/update
/vis/viewer/refresh calls SetView, ClearView, DrawView
/vis/viewer/update calls ShowView
*/
void G4HepRepViewer::DrawView () {
#ifdef SDEBUG
cout << "G4HepRepViewer::DrawView" << endl;
#endif
if (!geometryIncluded) {
// draws the geometry
NeedKernelVisit();
ProcessView();
geometryIncluded = true;
}
}
void G4HepRepViewer::ShowView () {
#ifdef SDEBUG
cout << "G4HepRepViewer::ShowView" << endl;
#endif
G4VViewer::ShowView();
G4HepRepSceneHandler* sceneHandler = dynamic_cast<G4HepRepSceneHandler*>(GetSceneHandler());
if (sceneHandler) {
if (sceneHandler->closeHepRep()) {
sceneHandler->openHepRep();
G4HepRepMessenger* messenger = G4HepRepMessenger::GetInstance();
if (messenger->appendGeometry()) geometryIncluded = false;
}
}
}
void G4HepRepViewer::FinishView () {
#ifdef SDEBUG
cout << "G4HepRepViewer::FinishView" << endl;
#endif
G4VViewer::FinishView();
}
void G4HepRepViewer::reset() {
geometryIncluded = false;
}
@@ -1,38 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/GZIPOutputStreamBuffer.h"
#include "cheprep/GZIPOutputStream.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
using namespace std;
GZIPOutputStream::GZIPOutputStream(ostream &os)
: std::ostream(NULL) {
buffer = new GZIPOutputStreamBuffer(os.rdbuf());
init(buffer);
}
void GZIPOutputStream::setFilename(const string &filename) {
buffer->setFilename(filename);
}
void GZIPOutputStream::setComment(const string &comment) {
buffer->setComment(comment);
}
void GZIPOutputStream::close() {
buffer->close();
}
GZIPOutputStream::~GZIPOutputStream() {
delete buffer;
}
} // cheprep
@@ -1,77 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/GZIPOutputStreamBuffer.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
using namespace std;
GZIPOutputStreamBuffer::GZIPOutputStreamBuffer( streambuf *aBuffer)
: DeflateOutputStreamBuffer(aBuffer),
open(false) {
init(true);
}
void GZIPOutputStreamBuffer::setFilename( const string &name ) {
filename = name ;
}
void GZIPOutputStreamBuffer::setComment( const string &c ) {
comment = c ;
}
void GZIPOutputStreamBuffer::close() {
if (!open) return;
finish();
writeTrailer();
open = false ;
}
GZIPOutputStreamBuffer::~GZIPOutputStreamBuffer() {
close() ;
}
int GZIPOutputStreamBuffer::overflow( int c ) {
if (!open) {
writeHeader();
open = true;
}
return DeflateOutputStreamBuffer::overflow( c ) ;
}
void GZIPOutputStreamBuffer::writeHeader() {
unsigned char flag = 0x00;
flag |= (filename == "") ? 0x00 : 0x08;
flag |= (comment == "") ? 0x00 : 0x10;
putUB(0x1f); // Magic #
putUB(0x8b); // Magic #
putUB(0x08); // Deflater.DEFLATED
putUB(flag); // FLG
putUI(0x00000000); // MTIME
putUB(0x00); // XFLG
putUB(0x00); // OS
if (filename != "") {
putS(filename); // Filename
putUB(0x00);
}
if (comment != "") {
putS(comment); // Comment
putUB(0x00);
}
}
void GZIPOutputStreamBuffer::writeTrailer() {
putUI(getCRC());
putUI(getSize());
}
} // cheprep
@@ -1,88 +0,0 @@
// Copyright FreeHEP, 2005.
#include <fstream>
#include "cheprep/IndentPrintWriter.h"
using namespace std;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
IndentPrintWriter::IndentPrintWriter(ostream* outstream, int level)
: out(outstream),
closed(false),
indentLevel(level),
indented(false),
indentString(" ") {
}
IndentPrintWriter::~IndentPrintWriter() {
}
void IndentPrintWriter::close() {
if (!closed) {
out->flush();
closed = true;
}
}
IndentPrintWriter& IndentPrintWriter::operator<< (const std::string & s) {
if (!indented) doIndent();
*out << s;
return *this;
}
IndentPrintWriter& IndentPrintWriter::operator<< (ostream& (*)(ostream&)) {
*out << endl;
indented = false;
return *this;
}
void IndentPrintWriter::println(const string & s) {
*this << s << endl;
}
void IndentPrintWriter::print(const string & s) {
*this << s;
}
void IndentPrintWriter::println() {
*out << endl;
indented = false;
}
void IndentPrintWriter::doIndent() {
for (int i=0; i<indentLevel; i++) {
*out << indentString;
}
indented = true;
}
void IndentPrintWriter::indent() {
indentLevel++;
}
void IndentPrintWriter::outdent() {
indentLevel--;
}
int IndentPrintWriter::getIndent() const {
return indentLevel;
}
void IndentPrintWriter::setIndent(const int level) {
indentLevel = level;
}
string IndentPrintWriter::getIndentString() const {
return indentString;
}
void IndentPrintWriter::setIndentString(const string & anIndent) {
indentString = anIndent;
}
} // cheprep
-25
View File
@@ -1,25 +0,0 @@
Apart from the heprep1 files:
G4HepRepFile.cc
G4HepRepFileSceneHandler.cc
G4HepRepFileViewer.cc
HepRepXMLWriter.cc
and heprep2 files:
G4HepRep.cc
G4HepRepSceneHandler.cc
G4HepRepMessenger.cc
G4HepRepViewer.cc
and the zlib sources
the other sources are copies from the FreeHEP library
(java.freehep.org) and are maintained there.
The files starting with G4 are geant4 compliant, the others may not be.
Changes made here may be overwritten.
3 May 2005
Mark Donszelmann
@@ -1,39 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include <fstream>
#include "cheprep/XMLHepRepWriter.h"
#include "cheprep/XMLHepRepFactory.h"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
XMLHepRepFactory::XMLHepRepFactory() {
}
XMLHepRepFactory::~XMLHepRepFactory() {
}
HepRepReader* XMLHepRepFactory::createHepRepReader (istream*) {
cerr << "XMLHepRepFactory::createHepRepReader not implemented" << endl;
return NULL;
}
HepRepReader* XMLHepRepFactory::createHepRepReader (std::string) {
cerr << "XMLHepRepFactory::createHepRepReader not implemented" << endl;
return NULL;
}
HepRepWriter* XMLHepRepFactory::createHepRepWriter(ostream* out, bool randomAccess, bool compress) {
return new XMLHepRepWriter(out, randomAccess, compress);
}
} // cheprep
@@ -1,288 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/XMLHepRepWriter.h"
#include "cheprep/XMLWriter.h"
#include "cheprep/BHepRepWriter.h"
#include "cheprep/DefaultHepRepInstance.h"
#include "cheprep/DefaultHepRepAttValue.h"
#define NAMESPACE "heprep"
using namespace std;
using namespace HEPREP;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
XMLHepRepWriter::XMLHepRepWriter(ostream* os, bool randomAccess, bool useCompression)
: out(os),
compress(useCompression),
xml(0) {
this->nameSpace = NAMESPACE;
if (randomAccess) {
zip = new ZipOutputStream(*os);
out = zip;
gz = NULL;
} else {
zip = NULL;
if (useCompression) {
#ifndef CHEPREP_NO_ZLIB
gz = new GZIPOutputStream(*os);
out = gz;
#else
cerr << "WARNING: the .gz output stream you are creating will be a plain file," << endl;
cerr << "since compression support (ZLIB) was not compiled into the library." << endl;
cerr << "To add ZLIB support, you need to undefine CHEPREP_NO_ZLIB." << endl;
gz = NULL;
#endif
} else {
gz = NULL;
}
}
}
XMLHepRepWriter::~XMLHepRepWriter() {
delete gz;
delete zip;
}
bool XMLHepRepWriter::addProperty(std::string key, std::string value) {
properties[key] = value;
return true;
}
bool XMLHepRepWriter::close() {
if (zip != NULL) {
zip->putNextEntry("heprep.properties", true);
map<string, string>::iterator i = properties.begin();
while (i != properties.end()) {
*zip << (*i).first << "=" << (*i).second << endl;
i++;
}
zip->closeEntry();
zip->close();
}
if (gz != NULL) {
gz->close();
}
return true;
}
bool XMLHepRepWriter::write(HepRep* heprep, string name) {
if (zip != NULL) {
zip->putNextEntry(name, compress);
}
if (name.rfind(".bheprep") == name.length()-8) {
xml = new BHepRepWriter(*out);
} else {
xml = new XMLWriter(out, " ", NAMESPACE);
}
xml->openDoc();
xml->setAttribute("version", (string)"2.0");
xml->setAttribute("xmlns", (string)"http://java.freehep.org/schemas/heprep/2.0");
xml->setAttribute("xmlns", "xsi", "http://www.w3.org/2001/XMLSchema-instance");
xml->setAttribute("xsi", "schemaLocation", "http://java.freehep.org/schemas/heprep/2.0 http://java.freehep.org/schemas/heprep/2.0/HepRep.xsd");
xml->openTag(nameSpace, "heprep");
write(heprep->getLayerOrder());
vector<HepRepTypeTree*> typeTreeSet = heprep->getTypeTreeList();
for (vector<HepRepTypeTree*>::iterator i1=typeTreeSet.begin(); i1 != typeTreeSet.end(); i1++) {
write(*i1);
}
vector<HepRepInstanceTree*> instanceTreeSet = heprep->getInstanceTreeList();
for (vector<HepRepInstanceTree*>::iterator i2=instanceTreeSet.begin(); i2 != instanceTreeSet.end(); i2++) {
write(*i2);
}
xml->closeTag();
xml->closeDoc();
// xml->close();
delete xml;
if (zip != NULL) {
zip->closeEntry();
}
return true;
}
bool XMLHepRepWriter::write(vector<string> layers) {
string layerOrder = "";
bool comma = false;
for (vector<string>::iterator i=layers.begin(); i != layers.end(); i++) {
if (comma) {
layerOrder.append(", ");
}
layerOrder.append(*i);
comma = true;
}
xml->setAttribute("order", layerOrder);
xml->printTag(nameSpace, "layer");
return true;
}
bool XMLHepRepWriter::write(HepRepTypeTree* typeTree) {
xml->setAttribute("name", typeTree->getName());
xml->setAttribute("version", typeTree->getVersion());
xml->openTag(nameSpace, "typetree");
vector<HepRepType*> types = typeTree->getTypeList();
for (vector<HepRepType*>::iterator i=types.begin(); i != types.end(); i++) {
write(*i);
}
xml->closeTag();
return true;
}
bool XMLHepRepWriter::write(HepRepType* type) {
xml->setAttribute("name", type->getName());
xml->openTag(nameSpace, "type");
write((HepRepDefinition*)type);
write((HepRepAttribute*)type);
vector<HepRepType*> types = type->getTypeList();
for (vector<HepRepType*>::iterator i=types.begin(); i != types.end(); i++) {
write(*i);
}
xml->closeTag();
return true;
}
bool XMLHepRepWriter::write(HepRepTreeID* treeID) {
xml->setAttribute("qualifier", treeID->getQualifier());
xml->setAttribute("name", treeID->getName());
xml->setAttribute("version", treeID->getVersion());
xml->printTag(nameSpace, "treeid");
return true;
}
bool XMLHepRepWriter::write(HepRepAction* action) {
xml->setAttribute("name", action->getName());
xml->setAttribute("expression", action->getExpression());
xml->printTag(nameSpace, "action");
return true;
}
bool XMLHepRepWriter::write(HepRepInstanceTree* instanceTree) {
xml->setAttribute("name", instanceTree->getName());
xml->setAttribute("version", instanceTree->getVersion());
xml->setAttribute("typetreename", instanceTree->getTypeTree()->getName());
xml->setAttribute("typetreeversion", instanceTree->getTypeTree()->getVersion());
xml->openTag(nameSpace, "instancetree");
// refs
vector<HepRepTreeID*> instanceTreeSet = instanceTree->getInstanceTreeList();
for (vector<HepRepTreeID*>::iterator i1=instanceTreeSet.begin(); i1 != instanceTreeSet.end(); i1++) {
write(*i1);
}
// instances
vector<HepRepInstance*> instanceList = instanceTree->getInstances();
for (vector<HepRepInstance*>::iterator i2=instanceList.begin(); i2 != instanceList.end(); i2++) {
write(*i2);
}
xml->closeTag();
return true;
}
bool XMLHepRepWriter::write(HepRepInstance* instance) {
// FIXME FREEHEP-356
xml->setAttribute("type", instance->getType()->getFullName());
xml->openTag(nameSpace, "instance");
write((HepRepAttribute*)instance);
vector<HepRepPoint*> pointList = instance->getPoints();
for (vector<HepRepPoint*>::iterator i1=pointList.begin(); i1 != pointList.end(); i1++) {
write(*i1);
}
vector<HepRepInstance*> instanceList = instance->getInstances();
for (vector<HepRepInstance*>::iterator i2=instanceList.begin(); i2 != instanceList.end(); i2++) {
write(*i2);
}
xml->closeTag();
return true;
}
bool XMLHepRepWriter::write(HepRepPoint* point) {
xml->setAttribute("x", point->getX());
xml->setAttribute("y", point->getY());
xml->setAttribute("z", point->getZ());
if (point->getAttValuesFromNode().size() != 0) {
xml->openTag(nameSpace, "point");
write((HepRepAttribute*)point);
xml->closeTag();
} else {
xml->printTag(nameSpace, "point");
}
return true;
}
bool XMLHepRepWriter::write(HepRepAttribute* attribute) {
// BUG FIX. Do something special for layers, because these do not end
// up in the normal iteration.
HepRepAttValue* layerAtt = attribute->getAttValueFromNode("layer");
if (layerAtt != NULL) write(layerAtt);
set<HepRepAttValue*> attSet = attribute->getAttValuesFromNode();
for (set<HepRepAttValue*>::iterator i=attSet.begin(); i != attSet.end(); i++) {
write(*i);
}
return true;
}
bool XMLHepRepWriter::write(HepRepDefinition* definition) {
set<HepRepAttDef*> list = definition->getAttDefsFromNode();
for (set<HepRepAttDef*>::iterator i=list.begin(); i != list.end(); i++) {
write(*i);
}
return true;
}
bool XMLHepRepWriter::write(HepRepAttValue* attValue) {
string name = attValue->getName();
xml->setAttribute("name", name);
switch(attValue->getType()) {
default: xml->setAttribute("value", attValue->getAsString());
break;
case HepRepConstants::TYPE_STRING: xml->setAttribute("value", attValue->getString());
break;
case HepRepConstants::TYPE_LONG: xml->setAttribute("value", attValue->getLong());
break;
case HepRepConstants::TYPE_INT: xml->setAttribute("value", attValue->getInteger());
break;
case HepRepConstants::TYPE_DOUBLE: xml->setAttribute("value", attValue->getDouble());
break;
case HepRepConstants::TYPE_BOOLEAN: xml->setAttribute("value", attValue->getBoolean());
break;
case HepRepConstants::TYPE_COLOR: xml->setAttribute("value", attValue->getColor());
}
if (attValue->showLabel() != HepRepConstants::SHOW_NONE) {
xml->setAttribute("showlabel", attValue->showLabel());
}
xml->printTag(nameSpace, "attvalue");
return true;
}
bool XMLHepRepWriter::write(HepRepAttDef* attDef) {
xml->setAttribute("name", attDef->getName());
xml->setAttribute("desc", attDef->getDescription());
xml->setAttribute("category", attDef->getCategory());
xml->setAttribute("extra", attDef->getExtra());
xml->printTag(nameSpace, "attdef");
return true;
}
} // cheprep
@@ -1,285 +0,0 @@
// Copyright FreeHEP, 2005.
#include "cheprep/config.h"
#include <cstdio>
#include "cheprep/DefaultHepRepAttValue.h"
#include "cheprep/XMLWriter.h"
using namespace std;
/**
* @author Mark Donszelmann
*/
namespace cheprep {
XMLWriter::XMLWriter(ostream* out, string indentString, string aDefaultNameSpace)
: AbstractXMLWriter(aDefaultNameSpace) {
writer = new IndentPrintWriter(out);
writer->setIndentString(indentString);
closed = false;
dtdName = "";
}
XMLWriter::~XMLWriter() {
writer->close();
delete writer;
}
void XMLWriter::close() {
closeDoc();
writer->close();
}
void XMLWriter::openDoc(string version, string encoding, bool standalone) {
string indentString = writer->getIndentString();
writer->setIndentString(indentString);
// if (!XMLCharacterProperties.validVersionNum(version)) throw new RuntimeException("Invalid version number: "+version);
*writer << "<?xml version=\"" << version.c_str() << "\" ";
if (encoding.compare("") != 0) {
// if (!XMLCharacterProperties.validEncName(encoding)) throw new RuntimeException("Invalid encoding name: "+encoding);
*writer << "encoding=\"" << encoding.c_str() << "\" ";
}
if (standalone) {
*writer << "standalone=\"yes\" ";
}
*writer << "?>";
*writer << endl;
writer->setIndentString(indentString);
}
void XMLWriter::referToDTD(string name, string pid, string ref) {
if (dtdName != "") {
cerr << "XMLWriter::ReferToDTD cannot be called twice" << endl;
}
dtdName = name;
*writer << "<!DOCTYPE " << name.c_str() << " PUBLIC \"" << pid.c_str() << "\" \"" << ref.c_str() << "\">" << endl;
}
void XMLWriter::referToDTD(string name, string system) {
if (dtdName != "") {
cerr << "XMLWriter::ReferToDTD cannot be called twice";
}
dtdName = name;
*writer << "<!DOCTYPE " << name.c_str() << " SYSTEM \"" << system.c_str() << "\">" << endl;
}
void XMLWriter::closeDoc(bool force) {
if (!closed) {
if (!openTags.empty()) {
if (!force) cerr << "Not all tags were closed before closing XML document:" << endl;
while (!openTags.empty()) {
if (force) {
closeTag();
} else {
cerr << " </" << openTags.top().c_str() << ">" << endl;
openTags.pop();
}
}
}
closed = true;
}
}
void XMLWriter::printComment(string comment) {
if (comment.find("--") != string::npos) {
cerr << "XMLWriter::printComment '--' sequence not allowed in comment" << endl;
}
*writer << "<!--" << normalizeText(comment).c_str() << "-->" << endl;
}
void XMLWriter::printPlain(string text) {
*writer << text.c_str();
}
void XMLWriter::print(string text) {
*writer << normalizeText(text).c_str();
}
void XMLWriter::println(string text) {
print(text);
*writer << endl;
}
void XMLWriter::openTag(string name) {
checkNameValid(name);
if (openTags.empty() && dtdName.compare("") && dtdName.compare(name)) {
cerr << "XMLWriter::openTag(), First tag: '" << name << "' not equal to DTD id: '" << dtdName << "'" << endl;
}
*writer << "<" << name.c_str();
printAttributes(name.length());
*writer << ">" << endl;
writer->indent();
openTags.push(name);
}
void XMLWriter::closeTag() {
if (openTags.empty()) {
writer->close();
cerr << "XMLWriter::closeTag(), No open tags" << endl;
}
string name = openTags.top();
openTags.pop();
writer->outdent();
*writer << "</" << name.c_str() << ">" << endl;
}
void XMLWriter::printTag(string name) {
checkNameValid(name);
*writer << "<" << name.c_str();
printAttributes(name.length());
*writer << "/>" << endl;
}
void XMLWriter::setAttribute(string name, char* value) {
setAttribute(name, (string)value);
}
void XMLWriter::setAttribute(string name, string value) {
attributes[name] = value;
// NOTE: never set type here
}
void XMLWriter::setAttribute(std::string name, std::vector<double> value) {
if (name == "value") setAttribute("type", (std::string)"Color");
setAttribute(name, DefaultHepRepAttValue::getAsString(value));
}
void XMLWriter::setAttribute(std::string name, int64 value) {
if (name == "value") setAttribute("type", (std::string)"long");
setAttribute(name, DefaultHepRepAttValue::getAsString(value));
}
void XMLWriter::setAttribute(std::string name, int value) {
if (name == "showlabel") {
string label = DefaultHepRepAttValue::toShowLabel(value);
setAttribute("showlabel", label);
} else {
if (name == "value") setAttribute("type", (std::string)"int");
setAttribute(name, DefaultHepRepAttValue::getAsString(value));
}
}
void XMLWriter::setAttribute(std::string name, bool value) {
if (name == "value") setAttribute("type", (std::string)"boolean");
setAttribute(name, DefaultHepRepAttValue::getAsString(value));
}
void XMLWriter::setAttribute(string name, double value) {
if (name == "value") setAttribute("type", (std::string)"double");
setAttribute(name, DefaultHepRepAttValue::getAsString(value));
}
void XMLWriter::printAttributes(int tagLength) {
int width = tagLength + 1;
bool extraIndent = false;
for (map<string,string>::iterator i = attributes.begin(); i != attributes.end(); i++) {
string key = i->first;
checkNameValid(key);
string value = normalize(i->second);
int length = key.length() + value.length() + 3;
if (width > 0 && width + length + 2*writer->getIndent() > 60) {
width = 0;
*writer << endl;
if (!extraIndent) {
writer->indent();
extraIndent = true;
}
} else {
width += length;
*writer << " ";
}
*writer << key.c_str() << "=\"" << value.c_str() << "\"";
}
attributes.clear();
if (extraIndent) writer->outdent();
}
string XMLWriter::normalize(string s) {
string str = "";
char buffer[20];
int len = s.length();
for (int i = 0; i < len; i++) {
char ch = s[i];
switch (ch) {
case '<': {
str.append("&lt;");
break;
}
case '>': {
str.append("&gt;");
break;
}
case '&': {
str.append("&amp;");
break;
}
case '"': {
str.append("&quot;");
break;
}
case '\r':
case '\n': {
sprintf(buffer, "&#%ud", ch);
str.append(buffer);
str.append(";");
break;
}
default: {
// if (ch > 0x00FF) {
// sprintf(buffer, "&#x%4.4x", ch);
// str.append(buffer);
// str.append(";");
// } else {
str.append(&ch, 1);
// }
}
}
}
return str;
}
string XMLWriter::normalizeText(string s) {
string str = "";
int len = s.length();
for (int i = 0; i < len; i++) {
char ch = s[i];
switch (ch) {
case '<': {
str.append("&lt;");
break;
}
case '>': {
str.append("&gt;");
break;
}
case '&': {
str.append("&amp;");
break;
}
default: {
// if (ch > 0x00FF) {
// sprintf(buffer, "&#x%4.4x", ch);
// str.append(buffer);
// str.append(";");
// } else {
str.append(&ch, 1);
// }
}
}
}
return str;
}
void XMLWriter::checkNameValid(string) {
// Could be added.
// if (!XMLCharacterProperties.validName(s)) throw new RuntimeException("Invalid name: "+s);
}
} // cheprep
@@ -1,43 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include <ctime>
#include <vector>
#include "cheprep/ZipOutputStreamBuffer.h"
#include "cheprep/ZipOutputStream.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
ZipOutputStream::ZipOutputStream(std::ostream& os) : std::ostream(0) {
buffer = new ZipOutputStreamBuffer(os.rdbuf());
init(buffer);
}
void ZipOutputStream::closeEntry() {
buffer->closeEntry();
}
void ZipOutputStream::close() {
buffer->close();
}
void ZipOutputStream::putNextEntry(const std::string& name, bool compress) {
buffer->putNextEntry(name, compress);
}
void ZipOutputStream::setComment(const std::string& comment ) {
buffer->setComment(comment);
}
ZipOutputStream::~ZipOutputStream() {
close();
delete buffer;
}
} // cheprep
@@ -1,143 +0,0 @@
// Copyright FreeHEP, 2005.
#include <iostream>
#include <ctime>
#include <vector>
#include "cheprep/ZipOutputStream.h"
#include "cheprep/ZipOutputStreamBuffer.h"
#include "cheprep/ZipEntry.h"
/**
* @author Mark Donszelmann
*/
namespace cheprep {
ZipOutputStreamBuffer::ZipOutputStreamBuffer(std::streambuf* aBuffer)
: DeflateOutputStreamBuffer(aBuffer),
comment("") {
closed = false;
entry = NULL;
entries = new std::vector<ZipEntry*>();
}
int ZipOutputStreamBuffer::overflow(int c) {
return DeflateOutputStreamBuffer::overflow(c);
}
void ZipOutputStreamBuffer::closeEntry() {
if (closed) return;
if (entry == NULL) return;
finish();
entry->crc = getCRC();
// NOTE: pos()::operator- is ambiguous on gcc 4.0, so convert to long first
entry->csize = (long)pos() - entry->data;
entry->size = getSize();
putUI(EXTSIG);
putUI(entry->crc); // crc
putUI(entry->csize); // compressed size
putUI(entry->size); // uncompressed size
entry = NULL;
}
void ZipOutputStreamBuffer::close() {
if (closed) return;
closeEntry();
long dirStart = pos();
for (std::vector<ZipEntry*>::iterator i=entries->begin(); i != entries->end(); i++) {
entry = *i;
putUI(CENSIG);
putUS(VERSIONMADE); // made by version
putUS(VERSIONEXTRACT); // extraction version
putUS(GENFLAG); // general purpose bit flag
putUS(entry->method); // compression method
putUS(entry->time); // time
putUS(entry->date); // date
putUI(entry->crc); // crc
putUI(entry->csize); // compressed size
putUI(entry->size); // uncompressed size
putUS(entry->name.length()); // file name length
putUS(0); // extra field length
putUS(0); // file comment length
putUS(0); // disk number start
putUS(0); // internal file attributes
putUI(0); // external file attributes
putUI(entry->offset); // relative offset of local file header
putS(entry->name); // file name
// delete entry
delete entry;
entry = NULL;
}
// NOTE: pos()::operator- is ambiguous on gcc 4.0, so convert to long first
long dirSize = (long)pos() - dirStart;
putUI(ENDSIG);
putUS(0); // number of this disk
putUS(0); // number of the disk with the start of central directory
putUS(entries->size()); // total number of entries in the central directory of this disk
putUS(entries->size()); // total number of entries in the central directory
putUI(dirSize); // size of the central directory
putUI(dirStart); // offset of the start of central directory with respect to the starting disk number
putUS(comment.length()); // .ZIP file comment length
putS(comment); // .ZIP file comment
delete entries;
entries = NULL;
closed = true;
}
void ZipOutputStreamBuffer::putNextEntry(const std::string& name, bool compress) {
if (closed) return;
closeEntry();
#ifdef CHEPREP_NO_ZLIB
compress = false;
#endif
init(compress);
entry = new ZipEntry();
entries->push_back(entry);
entry->name = name;
entry->method = compress ? 8 : 0;
time_t ltime;
time( &ltime );
struct tm *utc = gmtime( &ltime );
entry->date = (utc->tm_year - 80) << 9 | (utc->tm_mon + 1) << 5 | utc->tm_mday;
entry->time = utc->tm_hour << 11 | utc->tm_min << 5 | utc->tm_sec >> 1;
entry->offset = (long)pos();
putUI(LOCSIG); // signature
putUS(VERSIONEXTRACT); // extraction version
putUS(GENFLAG); // general purpose bit flag
putUS(entry->method); // compression method
putUS(entry->time); // time
putUS(entry->date); // date
putUI(0x00000000); // crc ATEND
putUI(0x00000000); // compressed size ATEND
putUI(0x00000000); // uncompressed size ATEND
putUS(entry->name.length()); // file name length
putUS(0); // extra field length
putS(entry->name); // file name
entry->data = (long)pos();
entry->crc = 0;
}
void ZipOutputStreamBuffer::setComment(const std::string& c) {
if (closed) return;
comment = c;
}
ZipOutputStreamBuffer::~ZipOutputStreamBuffer() {
close();
}
} // cheprep