File indexing completed on 2025-01-18 09:58:19
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 G4GDMLWRITE_HH
0035 #define G4GDMLWRITE_HH 1
0036
0037 #include <map>
0038
0039 #include <xercesc/dom/DOM.hpp>
0040 #include <xercesc/util/XMLString.hpp>
0041 #include <xercesc/util/PlatformUtils.hpp>
0042 #include <xercesc/framework/LocalFileFormatTarget.hpp>
0043
0044 #include "G4Transform3D.hh"
0045
0046 #include "G4GDMLAuxStructType.hh"
0047
0048 class G4LogicalVolume;
0049 class G4VPhysicalVolume;
0050
0051 class G4GDMLWrite
0052 {
0053 using VolumeMapType = std::map<const G4LogicalVolume*, G4Transform3D>;
0054 using PhysVolumeMapType = std::map<const G4VPhysicalVolume*, G4String>;
0055 using DepthMapType = std::map<G4int, G4int>;
0056
0057 public:
0058
0059 G4Transform3D Write(const G4String& filename,
0060 const G4LogicalVolume* const topLog,
0061 const G4String& schemaPath, const G4int depth,
0062 G4bool storeReferences = true);
0063
0064
0065
0066 void AddModule(const G4VPhysicalVolume* const topVol);
0067 void AddModule(const G4int depth);
0068
0069
0070
0071 void AddAuxiliary(G4GDMLAuxStructType myaux);
0072
0073
0074
0075 void SetOutputFileOverwrite(G4bool flag);
0076
0077
0078
0079 static void SetAddPointerToName(G4bool);
0080
0081
0082
0083 virtual void DefineWrite(xercesc::DOMElement*) = 0;
0084 virtual void MaterialsWrite(xercesc::DOMElement*) = 0;
0085 virtual void SolidsWrite(xercesc::DOMElement*) = 0;
0086 virtual void StructureWrite(xercesc::DOMElement*) = 0;
0087 virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
0088 const G4int) = 0;
0089 virtual void SurfacesWrite() = 0;
0090 virtual void SetupWrite(xercesc::DOMElement*,
0091 const G4LogicalVolume* const) = 0;
0092
0093
0094
0095 virtual void ExtensionWrite(xercesc::DOMElement*);
0096 virtual void UserinfoWrite(xercesc::DOMElement*);
0097 virtual void AddExtension(xercesc::DOMElement*,
0098 const G4LogicalVolume* const);
0099
0100
0101
0102
0103
0104
0105
0106 G4String GenerateName(const G4String&, const void* const);
0107
0108 protected:
0109
0110 G4GDMLWrite();
0111 virtual ~G4GDMLWrite();
0112
0113 VolumeMapType& VolumeMap();
0114
0115 xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
0116 xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
0117 xercesc::DOMElement* NewElement(const G4String&);
0118 G4String Modularize(const G4VPhysicalVolume* const topvol,
0119 const G4int depth);
0120
0121 void AddAuxInfo(G4GDMLAuxListType* auxInfoList,
0122 xercesc::DOMElement* element);
0123
0124 G4bool FileExists(const G4String&) const;
0125 PhysVolumeMapType& PvolumeMap();
0126 DepthMapType& DepthMap();
0127
0128 protected:
0129
0130 G4String SchemaLocation;
0131 static G4bool addPointerToName;
0132 xercesc::DOMDocument* doc = nullptr;
0133 xercesc::DOMElement* extElement = nullptr;
0134 xercesc::DOMElement* userinfoElement = nullptr;
0135
0136 G4GDMLAuxListType auxList;
0137 G4bool overwriteOutputFile = false;
0138 };
0139
0140 #endif