source: trunk/source/visualization/gMocren/include/G4GMocrenFileSceneHandler.hh @ 1347

Last change on this file since 1347 was 1347, checked in by garnier, 13 years ago

geant4 tag 9.4

File size: 6.9 KB
Line 
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,v 1.6 2010/05/30 10:04:16 allison Exp $
28// GEANT4 tag $Name: geant4-09-04-ref-00 $
29//
30//
31// Created:  Mar. 31, 2009  Akinori Kimura 
32//
33// Scene handler to export geometry and trajectories to a gMocren file.
34//
35#ifndef G4GMocrenFile_SCENE_HANDLER_HH
36#define G4GMocrenFile_SCENE_HANDLER_HH
37
38#include "globals.hh"
39
40#include "G4VSceneHandler.hh"
41
42#include <fstream>
43
44#include "G4THitsMap.hh"
45
46class G4VisAttributes ;
47class G4GMocrenFile;
48class G4GMocrenMessenger;
49class G4GMocrenIO;
50class G4VSolid;
51class G4Polyhedron;
52class G4Colour;
53
54//-----
55class G4GMocrenFileSceneHandler: public G4VSceneHandler {
56
57  friend class G4GMocrenFileViewer;
58
59public:
60
61        //----- constructor and destructor
62  G4GMocrenFileSceneHandler (G4GMocrenFile& system,
63                             G4GMocrenMessenger & messenger,
64                             const G4String& name = "");
65  virtual ~G4GMocrenFileSceneHandler ();
66
67        //----- overriding base class methods
68  void AddPrimitive (const G4Polyline& line);
69  void AddPrimitive (const G4Polyhedron& p);
70  void AddPrimitive (const G4NURBS& nurb);
71  void AddPrimitive (const G4Text&);
72  void AddPrimitive (const G4Circle&);
73  void AddPrimitive (const G4Square&);
74
75        //----- explicitly invoke base class methods to avoid warnings about
76        //----- hiding of base class methods.
77  void AddPrimitive (const G4Polymarker& polymarker) 
78       { G4VSceneHandler::AddPrimitive (polymarker); }
79  void AddPrimitive (const G4Scale& scale) 
80       { G4VSceneHandler::AddPrimitive (scale); }
81
82  virtual void BeginModeling () { G4VSceneHandler::BeginModeling ();} 
83  virtual void EndModeling   () { G4VSceneHandler::EndModeling   ();}
84
85  virtual void BeginPrimitives (const G4Transform3D& objectTransformation);
86  virtual void EndPrimitives ();
87
88  void AddSolid ( const G4Box&    box    );
89  void AddSolid ( const G4Cons&   cons   );
90  void AddSolid ( const G4Tubs&   tubs   );
91  void AddSolid ( const G4Trd&    trd    );
92  void AddSolid ( const G4Trap&   trap   );
93  void AddSolid ( const G4Sphere& sphere );
94  void AddSolid ( const G4Para&   para   );
95  void AddSolid ( const G4Torus&  torus  );
96  void AddSolid ( const G4Polycone& polycone ) {
97    G4VSceneHandler::AddSolid (polycone);
98  }
99  void AddSolid ( const G4Polyhedra& polyhedra) {
100    G4VSceneHandler::AddSolid (polyhedra);
101  }
102  void AddSolid ( const G4VSolid& solid  );
103  void AddCompound ( const G4VTrajectory& traj);
104  void AddCompound ( const G4VHit& hit);
105  void AddCompound ( const G4VDigi& hit);
106  void AddCompound ( const G4THitsMap<G4double> & hits);
107
108
109  void ClearTransientStore();  // Used for triggering detector re-drawing.
110
111  //----- public methods inherent to this class
112  void         GFBeginModeling () ;
113  void         GFEndModeling   () ;
114  G4bool       GFIsInModeling  () { return kFlagInModeling ; }
115
116  G4bool IsSavingGdd   ( void ) { return kFlagSaving_g4_gdd ;   }
117  void  BeginSavingGdd( void ); 
118  void  EndSavingGdd  ( void ) ;
119  void  SetGddFileName() ;
120
121  G4GMocrenFile&  GetSystem   () { return kSystem   ; }
122  const char*  GetGddFileName () { return kGddFileName ; }
123
124
125private:
126
127  //----- initialize all parameters
128  void InitializeParameters();
129
130  //----- Utilities etc.
131  G4bool IsVisible();
132
133  //
134  void AddDetector(const G4VSolid & solid);
135  void ExtractDetector();
136
137  void GetNestedVolumeIndex(G4int, G4int[3]);
138
139private:
140  G4GMocrenFile&        kSystem;     // Graphics system for this scene.
141  G4GMocrenMessenger & kMessenger;
142  G4GMocrenIO * kgMocrenIO;
143
144  std::map<G4int, float> kModality;
145  G4int kModalitySize[3];
146  //std::map<G4ThreeVector, float> kModalityDensities; // key: position, val: density
147  G4bool kbSetModalityVoxelSize;
148  G4bool kbModelingTrajectory;
149
150  static G4int  kSceneIdCount;
151  //std::vector<float *> fTrajectories;
152  //std::vector<unsigned char *> fTrajectoryColors;
153  G4Transform3D kVolumeTrans3D;
154
155  class Detector {
156  public:
157    G4String name;
158    G4Polyhedron * polyhedron;
159    G4Transform3D transform3D;
160    unsigned char color[3];
161    Detector();
162    ~Detector();
163    void clear();
164  };
165  std::vector<Detector> kDetectors;
166  G4ThreeVector kVolumeSize;
167  G4ThreeVector kVoxelDimension;
168  std::vector<G4String> kNestedVolumeNames;
169  G4int kNestedVolumeDimension[3];
170  G4int kNestedVolumeDirAxis[3];
171
172  class Index3D {
173  public:
174    G4int x, y, z;
175
176    Index3D();
177    Index3D(const Index3D & _index3D);
178    Index3D(G4int _x, G4int _y, G4int _z);
179    ~Index3D(){;}
180    G4bool operator < (const Index3D & _right) const;
181    G4bool operator == (const Index3D & _right) const;
182  };
183
184  std::map<Index3D, float> kNestedModality;
185  std::map<Index3D, G4double> * fTempNestedHits;
186  std::map<G4String, std::map<Index3D, G4double> > kNestedHitsList;
187  //std::map<G4String, G4String> kNestedHitsUnit;
188
189  std::ofstream kGddDest;  // defined here
190  G4bool kFlagInModeling;       
191                // true:  GF_BEGIN_MODELING has sent to gMocrenFile, and
192                //        GF_END_MODELING   has not sent yet.
193                // false:  otherwise
194                //
195                // kFlagInModeling is set to "true"
196                // in GFBeginModeling(), and to "false"
197                // in GFEndModeling().
198
199  G4bool kFlagSaving_g4_gdd ;   
200
201  G4int kFlagParameterization; // 0: G4VNestedParameterisation based geometry
202                               // 1: G4PhantomParameterisation
203                               // 2: interactive scorer
204  G4bool kFLagProcessedInteractiveScorer;
205
206  char kGddDestDir[256]; 
207  char kGddFileName[256];
208  G4int kMaxFileNum;
209
210};
211
212#endif
Note: See TracBrowser for help on using the repository browser.