File indexing completed on 2025-01-18 09:59:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef G4tgbGeometryDumper_hh
0035 #define G4tgbGeometryDumper_hh 1
0036
0037 #include <fstream>
0038 #include <map>
0039 #include <vector>
0040
0041 #include "globals.hh"
0042 #include "G4RotationMatrix.hh"
0043
0044 class G4Material;
0045 class G4Element;
0046 class G4Isotope;
0047 class G4VSolid;
0048 class G4LogicalVolume;
0049 class G4VPhysicalVolume;
0050 class G4PVParameterised;
0051 class G4PVReplica;
0052
0053 class G4tgbGeometryDumper
0054 {
0055 public:
0056
0057 static G4tgbGeometryDumper* GetInstance();
0058 ~G4tgbGeometryDumper();
0059
0060 void DumpGeometry(const G4String& fname);
0061 G4VPhysicalVolume* GetTopPhysVol();
0062 void DumpPhysVol(G4VPhysicalVolume* pv);
0063 void DumpPVPlacement(G4VPhysicalVolume* pv, const G4String& lvName,
0064 G4int copyNo = -999);
0065 void DumpPVParameterised(G4PVParameterised* pv);
0066 void DumpPVReplica(G4PVReplica* pv, const G4String& lvName);
0067 G4String DumpLogVol(G4LogicalVolume* lv, const G4String& extraName = "",
0068 G4VSolid* solid = nullptr, G4Material* mate = nullptr);
0069 G4String DumpMaterial(G4Material* mat);
0070 void DumpElement(G4Element* ele);
0071 void DumpIsotope(G4Isotope* ele);
0072 G4String DumpSolid(G4VSolid* solid, const G4String& extraName = "");
0073 void DumpBooleanVolume(const G4String& solidType, G4VSolid* so);
0074 void DumpMultiUnionVolume( G4VSolid* so);
0075 void DumpScaledVolume( G4VSolid* so);
0076 void DumpSolidParams(G4VSolid* so);
0077 std::vector<G4double> GetSolidParams(const G4VSolid* so);
0078 void DumpPolySections(G4int zPlanes, G4double* z, G4double* rmin,
0079 G4double* rmax);
0080 G4String DumpRotationMatrix(G4RotationMatrix* rotm);
0081
0082 private:
0083
0084 G4tgbGeometryDumper();
0085
0086 std::vector<G4VPhysicalVolume*> GetPVChildren(G4LogicalVolume* lv);
0087 G4String GetTGSolidType(const G4String& solidtype);
0088 G4double MatDeterminant(G4RotationMatrix* ro);
0089 G4double approxTo0(G4double val);
0090 G4String AddQuotes(const G4String& str);
0091
0092 G4String GetIsotopeName(G4Isotope*);
0093 template <class TYP>
0094 G4String GetObjectName(TYP* obj, std::map<G4String, TYP*> objectsDumped);
0095 G4bool CheckIfLogVolExists(const G4String& name, G4LogicalVolume* pt);
0096 G4bool CheckIfPhysVolExists(const G4String& name, G4VPhysicalVolume*);
0097 G4String LookForExistingRotation(const G4RotationMatrix* rotm);
0098 G4String SupressRefl(G4String name);
0099 G4String SubstituteRefl(G4String name);
0100 G4bool Same2G4Isotopes(G4Isotope* ele1, G4Isotope* ele2);
0101 const G4String& FindSolidName(G4VSolid* solid);
0102
0103 private:
0104
0105 static G4ThreadLocal G4tgbGeometryDumper* theInstance;
0106
0107 std::ofstream* theFile = nullptr;
0108
0109 std::map<G4String, G4Material*> theMaterials;
0110 std::map<G4String, G4Element*> theElements;
0111 std::map<G4String, G4Isotope*> theIsotopes;
0112 std::map<G4String, G4VSolid*> theSolids;
0113 std::map<G4String, G4LogicalVolume*> theLogVols;
0114 std::map<G4String, G4VPhysicalVolume*> thePhysVols;
0115 std::map<G4String, G4RotationMatrix*> theRotMats;
0116
0117 G4int theRotationNumber = 0;
0118 };
0119
0120 #endif