Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: G4GMocrenFileSceneHandler.hh 99152 2016-09-07 08:04:30Z gcosmo $
28 //
29 //
30 // Created: Mar. 31, 2009 Akinori Kimura
31 //
32 // Scene handler to export geometry and trajectories to a gMocren file.
33 //
34 #ifndef G4GMocrenFile_SCENE_HANDLER_HH
35 #define G4GMocrenFile_SCENE_HANDLER_HH
36 
37 #include "globals.hh"
38 
39 #include "G4VSceneHandler.hh"
40 
41 #include <fstream>
42 
43 #include "G4THitsMap.hh"
44 
45 class G4VisAttributes ;
46 class G4GMocrenFile;
47 class G4GMocrenMessenger;
48 class G4GMocrenIO;
49 class G4VSolid;
50 class G4Polyhedron;
51 class G4Colour;
52 
53 //-----
55 
56  friend class G4GMocrenFileViewer;
57 
58 public:
59 
60  //----- constructor and destructor
62  G4GMocrenMessenger & messenger,
63  const G4String& name = "");
64  virtual ~G4GMocrenFileSceneHandler ();
65 
66  //----- 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 
73  //----- explicitly invoke base class methods to avoid warnings about
74  //----- hiding of base class methods.
75  void AddPrimitive (const G4Polymarker& polymarker)
76  { G4VSceneHandler::AddPrimitive (polymarker); }
77  void AddPrimitive (const G4Scale& scale)
79 
82 
83  virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
84  virtual void EndPrimitives ();
85 
86  void AddSolid ( const G4Box& box );
87  void AddSolid ( const G4Cons& cons );
88  void AddSolid ( const G4Tubs& tubs );
89  void AddSolid ( const G4Trd& trd );
90  void AddSolid ( const G4Trap& trap );
91  void AddSolid ( const G4Sphere& sphere );
92  void AddSolid ( const G4Para& para );
93  void AddSolid ( const G4Torus& torus );
94  void AddSolid ( const G4Polycone& polycone ) {
95  G4VSceneHandler::AddSolid (polycone);
96  }
97  void AddSolid ( const G4Polyhedra& polyhedra) {
98  G4VSceneHandler::AddSolid (polyhedra);
99  }
100  void AddSolid ( const G4Orb& orb ) {
102  }
103  void AddSolid ( const G4Ellipsoid& ellipsoid) {
104  G4VSceneHandler::AddSolid (ellipsoid);
105  }
106  void AddSolid ( const G4VSolid& solid );
107  void AddCompound ( const G4VTrajectory& traj);
108  void AddCompound ( const G4VHit& hit);
109  void AddCompound ( const G4VDigi& hit);
110  void AddCompound ( const G4THitsMap<G4double> & hits);
111  void AddCompound ( const G4THitsMap<G4StatDouble> & hits);
112 
113 
114  void ClearTransientStore(); // Used for triggering detector re-drawing.
115 
116  //----- public methods inherent to this class
117  void GFBeginModeling () ;
118  void GFEndModeling () ;
119  G4bool GFIsInModeling () { return kFlagInModeling ; }
120 
121  G4bool IsSavingGdd ( void ) { return kFlagSaving_g4_gdd ; }
122  void BeginSavingGdd( void );
123  void EndSavingGdd ( void ) ;
124  void SetGddFileName() ;
125 
126  G4GMocrenFile& GetSystem () { return kSystem ; }
127  const char* GetGddFileName () { return kGddFileName ; }
128 
129 
130 private:
131 
132  //----- initialize all parameters
133  void InitializeParameters();
134 
135  //----- Utilities etc.
136  G4bool IsVisible();
137 
138  //
139  void AddDetector(const G4VSolid & solid);
140  void ExtractDetector();
141 
142  void GetNestedVolumeIndex(G4int, G4int[3]);
143 
144 private:
145  G4GMocrenFile& kSystem; // Graphics system for this scene.
146  G4GMocrenMessenger & kMessenger;
147  G4GMocrenIO * kgMocrenIO;
148 
149  std::map<G4int, float> kModality;
150  G4int kModalitySize[3];
151  //std::map<G4ThreeVector, float> kModalityDensities; // key: position, val: density
152  G4bool kbSetModalityVoxelSize;
153  G4bool kbModelingTrajectory;
154 
155  static G4int kSceneIdCount;
156  //std::vector<float *> fTrajectories;
157  //std::vector<unsigned char *> fTrajectoryColors;
158  G4Transform3D kVolumeTrans3D;
159 
160  class Detector {
161  public:
162  G4String name;
163  G4Polyhedron * polyhedron;
164  G4Transform3D transform3D;
165  unsigned char color[3];
166  Detector();
167  ~Detector();
168  void clear();
169  };
170  std::vector<Detector> kDetectors;
171  G4ThreeVector kVolumeSize;
172  G4ThreeVector kVoxelDimension;
173  std::vector<G4String> kNestedVolumeNames;
174  G4int kNestedVolumeDimension[3];
175  G4int kNestedVolumeDirAxis[3];
176 
177  class Index3D {
178  public:
179  G4int x, y, z;
180 
181  Index3D();
182  Index3D(const Index3D & _index3D);
183  Index3D(G4int _x, G4int _y, G4int _z);
184  ~Index3D(){;}
185  G4bool operator < (const Index3D & _right) const;
186  G4bool operator == (const Index3D & _right) const;
187  private:
188  // Private assigment operator -
189  // assignment not allowed. Keeps Coverity happy.
190  // Index3D& operator = (const Index3D&);
191  };
192 
193  std::map<Index3D, float> kNestedModality;
194  //std::map<Index3D, G4double> * fTempNestedHits;
195  std::map<G4String, std::map<Index3D, G4double> > kNestedHitsList;
196  //std::map<G4String, G4String> kNestedHitsUnit;
197 
198  std::ofstream kGddDest; // defined here
199  G4bool kFlagInModeling;
200  // true: GF_BEGIN_MODELING has sent to gMocrenFile, and
201  // GF_END_MODELING has not sent yet.
202  // false: otherwise
203  //
204  // kFlagInModeling is set to "true"
205  // in GFBeginModeling(), and to "false"
206  // in GFEndModeling().
207 
208  G4bool kFlagSaving_g4_gdd ;
209 
210  G4int kFlagParameterization; // 0: G4VNestedParameterisation based geometry
211  // 1: G4PhantomParameterisation
212  // 2: interactive scorer
213  G4bool kFlagProcessedInteractiveScorer;
214 
215  char kGddDestDir[256];
216  char kGddFileName[256];
217  G4int kMaxFileNum;
218 
219 };
220 
221 #endif
void AddCompound(const G4VTrajectory &traj)
const XML_Char * name
Definition: expat.h:151
bool operator==(const HepRotation &r, const HepLorentzRotation &lt)
Definition: G4Para.hh:77
virtual void AddSolid(const G4Box &)
Definition: G4Text.hh:73
virtual void BeginModeling()
void AddSolid(const G4Polycone &polycone)
Definition: G4Box.hh:64
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
const char * p
Definition: xmltok.h:285
Definition: G4Tubs.hh:85
Definition: G4VHit.hh:48
tuple x
Definition: test.py:50
Definition: G4Trd.hh:72
int G4int
Definition: G4Types.hh:78
virtual void AddPrimitive(const G4Polyline &)=0
bool G4bool
Definition: G4Types.hh:79
Definition: G4Cons.hh:83
virtual void EndModeling()
Definition: G4Orb.hh:61
void AddSolid(const G4Ellipsoid &ellipsoid)
void AddPrimitive(const G4Polymarker &polymarker)
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)
void AddPrimitive(const G4Scale &scale)
tuple z
Definition: test.py:28
void AddPrimitive(const G4Polyline &line)
void AddSolid(const G4Polyhedra &polyhedra)
G4GMocrenFileSceneHandler(G4GMocrenFile &system, G4GMocrenMessenger &messenger, const G4String &name="")