Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HepRepSceneHandler.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27
28/**
29 * @author Mark Donszelmann
30 */
31
32#ifndef G4HEPREPSCENEHANDLER_HH
33#define G4HEPREPSCENEHANDLER_HH 1
34
35#include "globals.hh"
36#include <iostream>
37#include <stack>
38#include <map>
39#include <vector>
40
41// HepRep
42#include "HEPREP/HepRep.h"
43
44//G4
45#include "G4Box.hh"
46#include "G4Cons.hh"
47#include "G4Tubs.hh"
48#include "G4Trd.hh"
49#include "G4Trap.hh"
50#include "G4Sphere.hh"
51#include "G4Para.hh"
52#include "G4Torus.hh"
53#include "G4Polycone.hh"
54#include "G4Polyhedra.hh"
55
56#include "G4VGraphicsSystem.hh"
57#include "G4VSceneHandler.hh"
58#include "G4Visible.hh"
59#include "G4Material.hh"
60#include "G4LogicalVolume.hh"
62
64
65 public:
66 G4HepRepSceneHandler (G4VGraphicsSystem& system, const G4String& name = "");
67 virtual ~G4HepRepSceneHandler ();
68
69 void AddSolid (const G4Box& box);
70 void AddSolid (const G4Cons& cons);
71 void AddSolid (const G4Tubs& tubs);
72 void AddSolid (const G4Trd& trd);
73 void AddSolid (const G4Trap& trap);
74 void AddSolid (const G4Sphere& sphere);
75 void AddSolid (const G4Para& para);
76 void AddSolid (const G4Torus& torus);
77 void AddSolid (const G4Polycone& polycone);
78 void AddSolid (const G4Polyhedra& polyhedra);
79 void AddSolid (const G4Orb& orb);
80 void AddSolid (const G4Ellipsoid& ellipsoid);
81 void AddSolid (const G4TessellatedSolid& tess);
82 void AddSolid (const G4VSolid& solid);
83
84 void AddCompound (const G4VTrajectory&);
85 void AddCompound (const G4VHit& hit);
86 void AddCompound (const G4VDigi& digi) {
88 }
89 void AddCompound (const G4THitsMap<G4double>& hits) {
91 }
94 }
95
96 void PreAddSolid (const G4Transform3D& objectTransformation, const G4VisAttributes& visAttribs);
97 void PostAddSolid ();
98
99 void AddPrimitive (const G4Polyline&);
100 void AddPrimitive (const G4Text&);
101 void AddPrimitive (const G4Circle&);
102 void AddPrimitive (const G4Square&);
103 void AddPrimitive (const G4Polyhedron&);
104
105 void AddPrimitive (const G4Polymarker&);
106 void AddPrimitive (const G4Scale& scale);
107
108 void BeginPrimitives (const G4Transform3D& objectTransformation);
109 void EndPrimitives ();
110 void BeginModeling ();
111 void EndModeling ();
112
113 void openHepRep();
114 bool closeHepRep(bool final = false);
115 void openFile(G4String name);
116 void closeFile();
117
118 private:
120 G4HepRepSceneHandler& operator= (const G4HepRepSceneHandler&);
121 static G4int sceneIdCount;
122
123 G4Transform3D transform;
124
125 std::ostream* out;
126 HEPREP::HepRepFactory* factory;
127 HEPREP::HepRepWriter* writer;
128
129 // Methods
130 G4bool dontWrite();
131
132 void setColor (HEPREP::HepRepAttribute *attribute, const G4Color& color,
133 const G4String& key = G4String("Color"));
134 G4Color getColorFor (const G4Visible& visible);
135 G4Color getColorFor (const G4VSolid& solid);
136
137 void setVisibility (HEPREP::HepRepAttribute *attribute, const G4VSolid& solid);
138 void setLine (HEPREP::HepRepAttribute *attribute, const G4VSolid& solid);
139
140 void setVisibility (HEPREP::HepRepAttribute *attribute, const G4Visible& visible);
141 void setLine (HEPREP::HepRepAttribute *attribute, const G4Visible& visible);
142
143 void setMarker (HEPREP::HepRepAttribute *attribute, const G4VMarker& marker);
144
145 inline void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, char* value) {
146 setAttribute(attribute, name, G4String(value));
147 }
148 void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, G4String value);
149 void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, bool value);
150 void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, double value);
151 void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, int value);
152 void setAttribute (HEPREP::HepRepAttribute* attribute, G4String name, double red, double green, double blue, double alpha);
153
154 bool isEventData();
155
156 void open(G4String name);
157 void close();
158
159 void writeLayers(HEPREP::HepRep* heprep);
160
161 void addAttributes(HEPREP::HepRepInstance* instance, HEPREP::HepRepType* type);
162
163 void addAttDefs(HEPREP::HepRepDefinition* definition, const std::map<G4String,G4AttDef>* attDefs);
164 void addAttVals(HEPREP::HepRepAttribute* attribute, const std::map<G4String,G4AttDef>* attDefs, std::vector<G4AttValue>* attValues);
165
166 void addTopLevelAttributes(HEPREP::HepRepType* type);
167
168 HEPREP::HepRepInstance* getGeometryOrEventInstance(HEPREP::HepRepType* type);
169
170 // Returns the particular instance/type or if not created, creates them and adds them to the HepRep
171 HEPREP::HepRep* getHepRep();
172 HEPREP::HepRep* getHepRepGeometry();
173 HEPREP::HepRepInstanceTree* getGeometryInstanceTree();
174 HEPREP::HepRepInstance* getGeometryInstance(G4LogicalVolume* volume, G4Material* material, int depth);
175 HEPREP::HepRepInstance* getGeometryInstance(G4String volumeName, int depth);
176 HEPREP::HepRepInstance* getGeometryRootInstance();
177 HEPREP::HepRepTypeTree* getGeometryTypeTree();
178 HEPREP::HepRepType* getGeometryType(G4String volumeName, int depth);
179 HEPREP::HepRepType* getGeometryRootType();
180 HEPREP::HepRepInstanceTree* getEventInstanceTree();
181 HEPREP::HepRepInstance* getEventInstance();
182 HEPREP::HepRepTypeTree* getEventTypeTree();
183 HEPREP::HepRepType* getEventType();
184 HEPREP::HepRepType* getTrajectoryType ();
185 HEPREP::HepRepType* getHitType ();
186 HEPREP::HepRepType* getCalHitType ();
187 HEPREP::HepRepType* getCalHitFaceType ();
188
189 G4String getFullTypeName(G4String volumeName, int depth);
190 G4String getParentTypeName(int currentDepth);
191
192 // initialized Member Variables
193 G4String geometryLayer, eventLayer, calHitLayer;
194 G4String trajectoryLayer, hitLayer;
195 G4String rootVolumeName;
196
197 G4String baseName;
198 G4String eventNumberPrefix;
199 G4String eventNumberSuffix;
200 G4int eventNumber;
201 G4int eventNumberWidth;
202 G4String extension;
203 G4bool writeBinary;
204 G4bool writeZip;
205 G4bool writeGZ;
206 G4bool writeMultipleFiles;
207 const G4VHit* currentHit;
208 const G4VTrajectory* currentTrack;
209
210 // DO NOT USE member vars directly, use get methods.
211 HEPREP::HepRep* _heprep;
212 HEPREP::HepRep* _heprepGeometry;
213 HEPREP::HepRepInstanceTree* _geometryInstanceTree;
214 std::vector<HEPREP::HepRepInstance*> _geometryInstance;
215 HEPREP::HepRepInstance* _geometryRootInstance;
216 HEPREP::HepRepTypeTree* _geometryTypeTree;
217 std::vector<G4String> _geometryTypeName;
218 std::map<G4String, HEPREP::HepRepType*> _geometryType;
219 HEPREP::HepRepType* _geometryRootType;
220 HEPREP::HepRepInstanceTree* _eventInstanceTree;
221 HEPREP::HepRepInstance* _eventInstance;
222 HEPREP::HepRepTypeTree* _eventTypeTree;
223 HEPREP::HepRepType* _eventType;
224 HEPREP::HepRepType* _trajectoryType;
225 HEPREP::HepRepType* _hitType;
226 HEPREP::HepRepType* _calHitType;
227 HEPREP::HepRepType* _calHitFaceType;
228
229 std::map<int, G4String> materialState;
230};
231
232#endif
233
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Definition: G4Box.hh:56
Definition: G4Cons.hh:78
void AddCompound(const G4VTrajectory &)
void openFile(G4String name)
void AddCompound(const G4VDigi &digi)
void BeginPrimitives(const G4Transform3D &objectTransformation)
void AddPrimitive(const G4Polyline &)
void AddSolid(const G4Box &box)
bool closeHepRep(bool final=false)
void AddCompound(const G4THitsMap< G4StatDouble > &hits)
void AddCompound(const G4THitsMap< G4double > &hits)
void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)
Definition: G4Orb.hh:56
Definition: G4Para.hh:79
Definition: G4Text.hh:72
Definition: G4Trd.hh:63
Definition: G4Tubs.hh:75
Definition: G4VHit.hh:48
virtual void AddCompound(const G4VTrajectory &)