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 | // class G4tgbGeometryDumper |
---|
28 | // |
---|
29 | // Class description: |
---|
30 | // |
---|
31 | // Class for dumping the whole geometry. |
---|
32 | |
---|
33 | // History: |
---|
34 | // - Created. P.Arce, CIEMAT (November 2007) |
---|
35 | // ------------------------------------------------------------------------- |
---|
36 | |
---|
37 | #ifndef G4tgbGeometryDumper_HH |
---|
38 | #define G4tgbGeometryDumper_HH |
---|
39 | |
---|
40 | #include "globals.hh" |
---|
41 | #include "G4RotationMatrix.hh" |
---|
42 | |
---|
43 | #include <fstream> |
---|
44 | #include <map> |
---|
45 | #include <vector> |
---|
46 | |
---|
47 | class G4Material; |
---|
48 | class G4Element; |
---|
49 | class G4Isotope; |
---|
50 | class G4VSolid; |
---|
51 | class G4LogicalVolume; |
---|
52 | class G4VPhysicalVolume; |
---|
53 | class G4PVParameterised; |
---|
54 | class G4PVReplica; |
---|
55 | |
---|
56 | class G4tgbGeometryDumper |
---|
57 | { |
---|
58 | |
---|
59 | public: // with description |
---|
60 | |
---|
61 | static G4tgbGeometryDumper* GetInstance(); |
---|
62 | ~G4tgbGeometryDumper(); |
---|
63 | |
---|
64 | void DumpGeometry(const G4String& fname ); |
---|
65 | G4VPhysicalVolume* GetTopPhysVol(); |
---|
66 | void DumpPhysVol( G4VPhysicalVolume* pv ); |
---|
67 | void DumpPVPlacement( G4VPhysicalVolume* pv, const G4String& lvName, |
---|
68 | G4int copyNo = -999 ); |
---|
69 | void DumpPVParameterised( G4PVParameterised* pv ); |
---|
70 | void DumpPVReplica( G4PVReplica* pv, const G4String& lvName ); |
---|
71 | G4String DumpLogVol( G4LogicalVolume* lv, G4String extraName = "", |
---|
72 | G4VSolid* solid = 0, G4Material* mate = 0); |
---|
73 | G4String DumpMaterial( G4Material* mat ); |
---|
74 | void DumpElement( G4Element* ele); |
---|
75 | void DumpIsotope( G4Isotope* ele); |
---|
76 | G4String DumpSolid( G4VSolid* solid, const G4String& extraName = "" ); |
---|
77 | void DumpBooleanVolume( const G4String& solidType, G4VSolid* so ); |
---|
78 | void DumpSolidParams(G4VSolid * so); |
---|
79 | std::vector<G4double> GetSolidParams( const G4VSolid * so); |
---|
80 | void DumpPolySections(G4int zPlanes, G4double* z, |
---|
81 | G4double *rmin, G4double *rmax); |
---|
82 | G4String DumpRotationMatrix( G4RotationMatrix* rotm ); |
---|
83 | |
---|
84 | private: |
---|
85 | |
---|
86 | G4tgbGeometryDumper(); |
---|
87 | |
---|
88 | private: |
---|
89 | |
---|
90 | std::vector<G4VPhysicalVolume*> GetPVChildren( G4LogicalVolume* lv ); |
---|
91 | G4String GetTGSolidType( const G4String& solidtype ); |
---|
92 | G4double MatDeterminant(G4RotationMatrix * ro) ; |
---|
93 | G4double approxTo0( G4double val ); |
---|
94 | G4String AddQuotes( const G4String& str ); |
---|
95 | |
---|
96 | G4String GetIsotopeName( G4Isotope* ); |
---|
97 | template< class TYP> G4String GetObjectName( TYP* obj, |
---|
98 | std::map<G4String,TYP*> objectsDumped ); |
---|
99 | G4bool CheckIfLogVolExists( const G4String& name, G4LogicalVolume* pt ); |
---|
100 | G4bool CheckIfPhysVolExists( const G4String& name, G4VPhysicalVolume* ); |
---|
101 | G4String LookForExistingRotation( const G4RotationMatrix* rotm ); |
---|
102 | G4String SupressRefl( G4String name ); |
---|
103 | G4String SubstituteRefl( G4String name ); |
---|
104 | G4bool Same2G4Isotopes( G4Isotope* ele1, G4Isotope* ele2 ); |
---|
105 | const G4String& FindSolidName( G4VSolid* solid ); |
---|
106 | |
---|
107 | private: |
---|
108 | |
---|
109 | static G4tgbGeometryDumper* theInstance; |
---|
110 | |
---|
111 | std::ofstream* theFile; |
---|
112 | |
---|
113 | std::map<G4String,G4Material*> theMaterials; |
---|
114 | std::map<G4String,G4Element*> theElements; |
---|
115 | std::map<G4String,G4Isotope*> theIsotopes; |
---|
116 | std::map<G4String,G4VSolid*> theSolids; |
---|
117 | std::map<G4String,G4LogicalVolume*> theLogVols; |
---|
118 | std::map<G4String,G4VPhysicalVolume*> thePhysVols; |
---|
119 | std::map<G4String,G4RotationMatrix*> theRotMats; |
---|
120 | |
---|
121 | G4int theRotationNumber; |
---|
122 | }; |
---|
123 | |
---|
124 | #endif |
---|