00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef G4tgbGeometryDumper_HH
00038 #define G4tgbGeometryDumper_HH
00039
00040 #include "globals.hh"
00041 #include "G4RotationMatrix.hh"
00042
00043 #include <fstream>
00044 #include <map>
00045 #include <vector>
00046
00047 class G4Material;
00048 class G4Element;
00049 class G4Isotope;
00050 class G4VSolid;
00051 class G4LogicalVolume;
00052 class G4VPhysicalVolume;
00053 class G4PVParameterised;
00054 class G4PVReplica;
00055
00056 class G4tgbGeometryDumper
00057 {
00058
00059 public:
00060
00061 static G4tgbGeometryDumper* GetInstance();
00062 ~G4tgbGeometryDumper();
00063
00064 void DumpGeometry(const G4String& fname );
00065 G4VPhysicalVolume* GetTopPhysVol();
00066 void DumpPhysVol( G4VPhysicalVolume* pv );
00067 void DumpPVPlacement( G4VPhysicalVolume* pv, const G4String& lvName,
00068 G4int copyNo = -999 );
00069 void DumpPVParameterised( G4PVParameterised* pv );
00070 void DumpPVReplica( G4PVReplica* pv, const G4String& lvName );
00071 G4String DumpLogVol( G4LogicalVolume* lv, G4String extraName = "",
00072 G4VSolid* solid = 0, G4Material* mate = 0);
00073 G4String DumpMaterial( G4Material* mat );
00074 void DumpElement( G4Element* ele);
00075 void DumpIsotope( G4Isotope* ele);
00076 G4String DumpSolid( G4VSolid* solid, const G4String& extraName = "" );
00077 void DumpBooleanVolume( const G4String& solidType, G4VSolid* so );
00078 void DumpSolidParams(G4VSolid * so);
00079 std::vector<G4double> GetSolidParams( const G4VSolid * so);
00080 void DumpPolySections(G4int zPlanes, G4double* z,
00081 G4double *rmin, G4double *rmax);
00082 G4String DumpRotationMatrix( G4RotationMatrix* rotm );
00083
00084 private:
00085
00086 G4tgbGeometryDumper();
00087
00088 private:
00089
00090 std::vector<G4VPhysicalVolume*> GetPVChildren( G4LogicalVolume* lv );
00091 G4String GetTGSolidType( const G4String& solidtype );
00092 G4double MatDeterminant(G4RotationMatrix * ro) ;
00093 G4double approxTo0( G4double val );
00094 G4String AddQuotes( const G4String& str );
00095
00096 G4String GetIsotopeName( G4Isotope* );
00097 template< class TYP> G4String GetObjectName( TYP* obj,
00098 std::map<G4String,TYP*> objectsDumped );
00099 G4bool CheckIfLogVolExists( const G4String& name, G4LogicalVolume* pt );
00100 G4bool CheckIfPhysVolExists( const G4String& name, G4VPhysicalVolume* );
00101 G4String LookForExistingRotation( const G4RotationMatrix* rotm );
00102 G4String SupressRefl( G4String name );
00103 G4String SubstituteRefl( G4String name );
00104 G4bool Same2G4Isotopes( G4Isotope* ele1, G4Isotope* ele2 );
00105 const G4String& FindSolidName( G4VSolid* solid );
00106
00107 private:
00108
00109 static G4tgbGeometryDumper* theInstance;
00110
00111 std::ofstream* theFile;
00112
00113 std::map<G4String,G4Material*> theMaterials;
00114 std::map<G4String,G4Element*> theElements;
00115 std::map<G4String,G4Isotope*> theIsotopes;
00116 std::map<G4String,G4VSolid*> theSolids;
00117 std::map<G4String,G4LogicalVolume*> theLogVols;
00118 std::map<G4String,G4VPhysicalVolume*> thePhysVols;
00119 std::map<G4String,G4RotationMatrix*> theRotMats;
00120
00121 G4int theRotationNumber;
00122 };
00123
00124 #endif