Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
66 void AddPrimitive (const G4Polyline& line);
67 void AddPrimitive (const G4Polyhedron& p);
68 void AddPrimitive (const G4Text&);
69 void AddPrimitive (const G4Circle&);
70 void AddPrimitive (const G4Square&);
71
72 //----- explicitly invoke base class methods to avoid warnings about
73 //----- hiding of base class methods.
74 void AddPrimitive (const G4Polymarker& polymarker)
75 { G4VSceneHandler::AddPrimitive (polymarker); }
76 void AddPrimitive (const G4Scale& scale)
78
81
82 virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
83 virtual void EndPrimitives ();
84
85 void AddSolid ( const G4Box& box );
86 void AddSolid ( const G4Cons& cons );
87 void AddSolid ( const G4Tubs& tubs );
88 void AddSolid ( const G4Trd& trd );
89 void AddSolid ( const G4Trap& trap );
90 void AddSolid ( const G4Sphere& sphere );
91 void AddSolid ( const G4Para& para );
92 void AddSolid ( const G4Torus& torus );
93 void AddSolid ( const G4Polycone& polycone ) {
95 }
96 void AddSolid ( const G4Polyhedra& polyhedra) {
97 G4VSceneHandler::AddSolid (polyhedra);
98 }
99 void AddSolid ( const G4Orb& orb ) {
101 }
102 void AddSolid ( const G4Ellipsoid& ellipsoid) {
103 G4VSceneHandler::AddSolid (ellipsoid);
104 }
105 void AddSolid ( const G4TessellatedSolid& tess) {
107 }
108 void AddSolid ( const G4VSolid& solid );
109 void AddCompound ( const G4VTrajectory& traj);
110 void AddCompound ( const G4VHit& hit);
111 void AddCompound ( const G4VDigi& hit);
112 void AddCompound ( const G4THitsMap<G4double> & hits);
113 void AddCompound ( const G4THitsMap<G4StatDouble> & hits);
114
115
116 void ClearTransientStore(); // Used for triggering detector re-drawing.
117
118 //----- public methods inherent to this class
119 void GFBeginModeling () ;
120 void GFEndModeling () ;
121 G4bool GFIsInModeling () { return kFlagInModeling ; }
122
123 G4bool IsSavingGdd ( void ) { return kFlagSaving_g4_gdd ; }
124 void BeginSavingGdd( void );
125 void EndSavingGdd ( void ) ;
126 void SetGddFileName() ;
127
128 G4GMocrenFile& GetSystem () { return kSystem ; }
129 const char* GetGddFileName () { return kGddFileName ; }
130
131
132private:
133
134 //----- initialize all parameters
135 void InitializeParameters();
136
137 //----- Utilities etc.
138 G4bool IsVisible();
139
140 //
141 void AddDetector(const G4VSolid & solid);
142 void ExtractDetector();
143
144 void GetNestedVolumeIndex(G4int, G4int[3]);
145
146private:
147 G4GMocrenFile& kSystem; // Graphics system for this scene.
148 G4GMocrenMessenger & kMessenger;
149 G4GMocrenIO * kgMocrenIO;
150
151 std::map<G4int, float> kModality;
152 G4int kModalitySize[3];
153 //std::map<G4ThreeVector, float> kModalityDensities; // key: position, val: density
154 G4bool kbSetModalityVoxelSize;
155 G4bool kbModelingTrajectory;
156
157 static G4int kSceneIdCount;
158 //std::vector<float *> fTrajectories;
159 //std::vector<unsigned char *> fTrajectoryColors;
160 G4Transform3D kVolumeTrans3D;
161
162 class Detector {
163 public:
164 G4String name;
165 G4Polyhedron * polyhedron;
166 G4Transform3D transform3D;
167 unsigned char color[3];
168 Detector();
169 ~Detector();
170 void clear();
171 };
172 std::vector<Detector> kDetectors;
173 G4ThreeVector kVolumeSize;
174 G4ThreeVector kVoxelDimension;
175 std::vector<G4String> kNestedVolumeNames;
176 G4int kNestedVolumeDimension[3];
177 G4int kNestedVolumeDirAxis[3];
178
179 class Index3D {
180 public:
181 G4int x, y, z;
182
183 Index3D();
184 Index3D(const Index3D & _index3D);
185 Index3D(G4int _x, G4int _y, G4int _z);
186 ~Index3D(){;}
187 G4bool operator < (const Index3D & _right) const;
188 G4bool operator == (const Index3D & _right) const;
189 private:
190 // Private assigment operator -
191 // assignment not allowed. Keeps Coverity happy.
192 // Index3D& operator = (const Index3D&);
193 };
194
195 std::map<Index3D, float> kNestedModality;
196 //std::map<Index3D, G4double> * fTempNestedHits;
197 std::map<G4String, std::map<Index3D, G4double> > kNestedHitsList;
198 //std::map<G4String, G4String> kNestedHitsUnit;
199
200 std::ofstream kGddDest; // defined here
201 G4bool kFlagInModeling;
202 // true: GF_BEGIN_MODELING has sent to gMocrenFile, and
203 // GF_END_MODELING has not sent yet.
204 // false: otherwise
205 //
206 // kFlagInModeling is set to "true"
207 // in GFBeginModeling(), and to "false"
208 // in GFEndModeling().
209
210 G4bool kFlagSaving_g4_gdd ;
211
212 G4int kFlagParameterization; // 0: G4VNestedParameterisation based geometry
213 // 1: G4PhantomParameterisation
214 // 2: interactive scorer
215 G4bool kFlagProcessedInteractiveScorer;
216
217 char kGddDestDir[256];
218 char kGddFileName[256];
219 G4int kMaxFileNum;
220
221};
222
223#endif
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
Definition: G4Box.hh:56
Definition: G4Cons.hh:78
void AddPrimitive(const G4Polymarker &polymarker)
void AddCompound(const G4VTrajectory &traj)
void AddPrimitive(const G4Scale &scale)
void AddSolid(const G4Polycone &polycone)
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
void AddSolid(const G4Ellipsoid &ellipsoid)
void AddSolid(const G4TessellatedSolid &tess)
void AddSolid(const G4Polyhedra &polyhedra)
void AddPrimitive(const G4Polyline &line)
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 BeginModeling()
virtual void EndModeling()
virtual void AddSolid(const G4Box &)
virtual void AddPrimitive(const G4Polyline &)=0