Geant4_10
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 75179 2013-10-29 10:09:31Z 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 G4VSolid& solid );
101  void AddCompound ( const G4VTrajectory& traj);
102  void AddCompound ( const G4VHit& hit);
103  void AddCompound ( const G4VDigi& hit);
104  void AddCompound ( const G4THitsMap<G4double> & hits);
105 
106 
107  void ClearTransientStore(); // Used for triggering detector re-drawing.
108 
109  //----- public methods inherent to this class
110  void GFBeginModeling () ;
111  void GFEndModeling () ;
112  G4bool GFIsInModeling () { return kFlagInModeling ; }
113 
114  G4bool IsSavingGdd ( void ) { return kFlagSaving_g4_gdd ; }
115  void BeginSavingGdd( void );
116  void EndSavingGdd ( void ) ;
117  void SetGddFileName() ;
118 
119  G4GMocrenFile& GetSystem () { return kSystem ; }
120  const char* GetGddFileName () { return kGddFileName ; }
121 
122 
123 private:
124 
125  //----- initialize all parameters
126  void InitializeParameters();
127 
128  //----- Utilities etc.
129  G4bool IsVisible();
130 
131  //
132  void AddDetector(const G4VSolid & solid);
133  void ExtractDetector();
134 
135  void GetNestedVolumeIndex(G4int, G4int[3]);
136 
137 private:
138  G4GMocrenFile& kSystem; // Graphics system for this scene.
139  G4GMocrenMessenger & kMessenger;
140  G4GMocrenIO * kgMocrenIO;
141 
142  std::map<G4int, float> kModality;
143  G4int kModalitySize[3];
144  //std::map<G4ThreeVector, float> kModalityDensities; // key: position, val: density
145  G4bool kbSetModalityVoxelSize;
146  G4bool kbModelingTrajectory;
147 
148  static G4int kSceneIdCount;
149  //std::vector<float *> fTrajectories;
150  //std::vector<unsigned char *> fTrajectoryColors;
151  G4Transform3D kVolumeTrans3D;
152 
153  class Detector {
154  public:
155  G4String name;
156  G4Polyhedron * polyhedron;
157  G4Transform3D transform3D;
158  unsigned char color[3];
159  Detector();
160  ~Detector();
161  void clear();
162  };
163  std::vector<Detector> kDetectors;
164  G4ThreeVector kVolumeSize;
165  G4ThreeVector kVoxelDimension;
166  std::vector<G4String> kNestedVolumeNames;
167  G4int kNestedVolumeDimension[3];
168  G4int kNestedVolumeDirAxis[3];
169 
170  class Index3D {
171  public:
172  G4int x, y, z;
173 
174  Index3D();
175  Index3D(const Index3D & _index3D);
176  Index3D(G4int _x, G4int _y, G4int _z);
177  ~Index3D(){;}
178  G4bool operator < (const Index3D & _right) const;
179  G4bool operator == (const Index3D & _right) const;
180  private:
181  // Private assigment operator -
182  // assignment not allowed. Keeps Coverity happy.
183  // Index3D& operator = (const Index3D&);
184  };
185 
186  std::map<Index3D, float> kNestedModality;
187  //std::map<Index3D, G4double> * fTempNestedHits;
188  std::map<G4String, std::map<Index3D, G4double> > kNestedHitsList;
189  //std::map<G4String, G4String> kNestedHitsUnit;
190 
191  std::ofstream kGddDest; // defined here
192  G4bool kFlagInModeling;
193  // true: GF_BEGIN_MODELING has sent to gMocrenFile, and
194  // GF_END_MODELING has not sent yet.
195  // false: otherwise
196  //
197  // kFlagInModeling is set to "true"
198  // in GFBeginModeling(), and to "false"
199  // in GFEndModeling().
200 
201  G4bool kFlagSaving_g4_gdd ;
202 
203  G4int kFlagParameterization; // 0: G4VNestedParameterisation based geometry
204  // 1: G4PhantomParameterisation
205  // 2: interactive scorer
206  G4bool kFlagProcessedInteractiveScorer;
207 
208  char kGddDestDir[256];
209  char kGddFileName[256];
210  G4int kMaxFileNum;
211 
212 };
213 
214 #endif
void AddCompound(const G4VTrajectory &traj)
Definition: G4Para.hh:76
virtual void AddSolid(const G4Box &)
Definition: G4Text.hh:73
virtual void BeginModeling()
void AddSolid(const G4Polycone &polycone)
Definition: G4Box.hh:63
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
const char * p
Definition: xmltok.h:285
Definition: G4Tubs.hh:84
const XML_Char * name
Definition: expat.h:151
Definition: G4VHit.hh:48
tuple x
Definition: test.py:50
Definition: G4Trd.hh:71
void hits()
Definition: readHits.C:17
int G4int
Definition: G4Types.hh:78
virtual void AddPrimitive(const G4Polyline &)=0
Double_t y
Definition: plot.C:279
bool G4bool
Definition: G4Types.hh:79
Definition: G4Cons.hh:82
virtual void EndModeling()
Double_t scale
Definition: plot.C:11
vec_iX clear()
void AddPrimitive(const G4Polymarker &polymarker)
system("rm -rf dna.root")
bool operator<(const CexmcAngularRange &left, const CexmcAngularRange &right)
void AddPrimitive(const G4Scale &scale)
tuple z
Definition: test.py:28
void AddPrimitive(const G4Polyline &line)
bool operator==(shared_ctrl_handle const &lhs, shared_ctrl_handle const &rhs)
Definition: memory.h:582
UBox box
Definition: UPolycone.cc:32
void AddSolid(const G4Polyhedra &polyhedra)
G4GMocrenFileSceneHandler(G4GMocrenFile &system, G4GMocrenMessenger &messenger, const G4String &name="")