Geant4-11
G4GMocrenFileSceneHandler.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// Created: Mar. 31, 2009 Akinori Kimura
30//
31// Scene handler to export geometry and trajectories to a gMocren file.
32//
33#ifndef G4GMocrenFile_SCENE_HANDLER_HH
34#define G4GMocrenFile_SCENE_HANDLER_HH
35
36#include "globals.hh"
37
38#include "G4VSceneHandler.hh"
39
40#include <fstream>
41
42#include "G4THitsMap.hh"
43
44class G4VisAttributes ;
45class G4GMocrenFile;
47class G4GMocrenIO;
48class G4VSolid;
49class G4Polyhedron;
50class G4Colour;
51
52//-----
54
55 friend class G4GMocrenFileViewer;
56
57public:
58
59 //----- constructor and destructor
61 G4GMocrenMessenger & messenger,
62 const G4String& name = "");
64
65 //----- overriding base class methods
67 void AddPrimitive (const G4Polyline& line);
68 void AddPrimitive (const G4Polyhedron& p);
69 void AddPrimitive (const G4Text&);
70 void AddPrimitive (const G4Circle&);
71 void AddPrimitive (const G4Square&);
72
75
76 virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
77 virtual void EndPrimitives ();
78
80 void AddSolid ( const G4Box& box );
81 void AddSolid ( const G4Cons& cons );
82 void AddSolid ( const G4Tubs& tubs );
83 void AddSolid ( const G4Trd& trd );
84 void AddSolid ( const G4Trap& trap );
85 void AddSolid ( const G4Sphere& sphere );
86 void AddSolid ( const G4Para& para );
87 void AddSolid ( const G4Torus& torus );
88 void AddSolid ( const G4VSolid& solid );
89
91 void AddCompound ( const G4VTrajectory& traj);
92 void AddCompound ( const G4VHit& hit);
93 void AddCompound ( const G4VDigi& hit);
94 void AddCompound ( const G4THitsMap<G4double> & hits);
95 void AddCompound ( const G4THitsMap<G4StatDouble> & hits);
96
97
98 void ClearTransientStore(); // Used for triggering detector re-drawing.
99
100 //----- public methods inherent to this class
101 void GFBeginModeling () ;
102 void GFEndModeling () ;
104
106 void BeginSavingGdd( void );
107 void EndSavingGdd ( void ) ;
108 void SetGddFileName() ;
109
111 const char* GetGddFileName () { return kGddFileName ; }
112
113
114private:
115
116 //----- initialize all parameters
118
119 //----- Utilities etc.
121
122 //
123 void AddDetector(const G4VSolid & solid);
124 void ExtractDetector();
125
127
128private:
129 G4GMocrenFile& kSystem; // Graphics system for this scene.
132
133 std::map<G4int, float> kModality;
135 //std::map<G4ThreeVector, float> kModalityDensities; // key: position, val: density
138
140 //std::vector<float *> fTrajectories;
141 //std::vector<unsigned char *> fTrajectoryColors;
143
144 class Detector {
145 public:
149 unsigned char color[3];
150 Detector();
151 ~Detector();
152 void clear();
153 };
154 std::vector<Detector> kDetectors;
157 std::vector<G4String> kNestedVolumeNames;
160
161 class Index3D {
162 public:
164
165 Index3D();
166 Index3D(const Index3D & _index3D);
167 Index3D(G4int _x, G4int _y, G4int _z);
169 G4bool operator < (const Index3D & _right) const;
170 G4bool operator == (const Index3D & _right) const;
171 private:
172 // Private assigment operator -
173 // assignment not allowed. Keeps Coverity happy.
174 // Index3D& operator = (const Index3D&);
175 };
176
177 std::map<Index3D, float> kNestedModality;
178 //std::map<Index3D, G4double> * fTempNestedHits;
179 std::map<G4String, std::map<Index3D, G4double> > kNestedHitsList;
180 //std::map<G4String, G4String> kNestedHitsUnit;
181
182 std::ofstream kGddDest; // defined here
184 // true: GF_BEGIN_MODELING has sent to gMocrenFile, and
185 // GF_END_MODELING has not sent yet.
186 // false: otherwise
187 //
188 // kFlagInModeling is set to "true"
189 // in GFBeginModeling(), and to "false"
190 // in GFEndModeling().
191
193
194 G4int kFlagParameterization; // 0: G4VNestedParameterisation based geometry
195 // 1: G4PhantomParameterisation
196 // 2: interactive scorer
198
199 char kGddDestDir[256];
200 char kGddFileName[256];
202
203};
204
205#endif
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Definition: G4Box.hh:56
Definition: G4Cons.hh:78
G4bool operator==(const Index3D &_right) const
G4bool operator<(const Index3D &_right) const
G4GMocrenFileSceneHandler(G4GMocrenFile &system, G4GMocrenMessenger &messenger, const G4String &name="")
void GetNestedVolumeIndex(G4int, G4int[3])
std::map< G4int, float > kModality
void AddCompound(const G4VTrajectory &traj)
std::vector< G4String > kNestedVolumeNames
std::map< G4String, std::map< Index3D, G4double > > kNestedHitsList
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
std::vector< Detector > kDetectors
void AddDetector(const G4VSolid &solid)
void AddPrimitive(const G4Polyline &line)
std::map< Index3D, float > kNestedModality
Definition: G4Para.hh:79
Definition: G4Text.hh:72
Definition: G4Trd.hh:63
Definition: G4Tubs.hh:75
Definition: G4VHit.hh:48
virtual void BeginModeling()
virtual void EndModeling()
virtual void AddSolid(const G4Box &)
virtual void AddCompound(const G4VTrajectory &)
virtual void AddPrimitive(const G4Polyline &)=0
const char * name(G4int ptype)