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
00038
00039
00040 #ifndef _G4GDMLWRITE_INCLUDED_
00041 #define _G4GDMLWRITE_INCLUDED_
00042
00043 #include <map>
00044
00045 #include <xercesc/dom/DOM.hpp>
00046 #include <xercesc/util/XMLString.hpp>
00047 #include <xercesc/util/PlatformUtils.hpp>
00048 #include <xercesc/framework/LocalFileFormatTarget.hpp>
00049
00050 #include "G4Transform3D.hh"
00051
00052 class G4LogicalVolume;
00053 class G4VPhysicalVolume;
00054
00055 class G4GDMLWrite
00056 {
00057 typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
00058 typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
00059 typedef std::map<G4int,G4int> DepthMapType;
00060
00061 public:
00062
00063 G4Transform3D Write(const G4String& filename,
00064 const G4LogicalVolume* const topLog,
00065 const G4String& schemaPath,
00066 const G4int depth, G4bool storeReferences=true);
00067
00068
00069
00070 void AddModule(const G4VPhysicalVolume* const topVol);
00071 void AddModule(const G4int depth);
00072
00073
00074
00075 static void SetAddPointerToName(G4bool);
00076
00077
00078
00079 virtual void DefineWrite(xercesc::DOMElement*)=0;
00080 virtual void MaterialsWrite(xercesc::DOMElement*)=0;
00081 virtual void SolidsWrite(xercesc::DOMElement*)=0;
00082 virtual void StructureWrite(xercesc::DOMElement*)=0;
00083 virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
00084 const G4int)=0;
00085 virtual void SurfacesWrite()=0;
00086 virtual void SetupWrite(xercesc::DOMElement*,
00087 const G4LogicalVolume* const)=0;
00088
00089
00090
00091 virtual void ExtensionWrite(xercesc::DOMElement*);
00092 virtual void AddExtension(xercesc::DOMElement*,
00093 const G4LogicalVolume* const);
00094
00095
00096
00097
00098
00099
00100
00101 protected:
00102
00103 G4GDMLWrite();
00104 virtual ~G4GDMLWrite();
00105
00106 VolumeMapType& VolumeMap();
00107
00108 G4String GenerateName(const G4String&,const void* const);
00109 xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
00110 xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
00111 xercesc::DOMElement* NewElement(const G4String&);
00112 G4String Modularize(const G4VPhysicalVolume* const topvol,
00113 const G4int depth);
00114
00115 G4bool FileExists(const G4String&) const;
00116 PhysVolumeMapType& PvolumeMap();
00117 DepthMapType& DepthMap();
00118
00119 protected:
00120
00121 G4String SchemaLocation;
00122 static G4bool addPointerToName;
00123 xercesc::DOMDocument* doc;
00124 xercesc::DOMElement* extElement;
00125 XMLCh tempStr[10000];
00126
00127 };
00128
00129 #endif