Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4GDMLWrite.hh
Go to the documentation of this file.
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 // $Id: G4GDMLWrite.hh 89243 2015-03-27 16:24:39Z gcosmo $
28 //
29 //
30 // class G4GDMLWrite
31 //
32 // Class description:
33 //
34 // GDML writer.
35 
36 // History:
37 // - Created. Zoltan Torzsok, November 2007
38 // -------------------------------------------------------------------------
39 
40 #ifndef _G4GDMLWRITE_INCLUDED_
41 #define _G4GDMLWRITE_INCLUDED_
42 
43 #include <map>
44 
45 #include <xercesc/dom/DOM.hpp>
46 #include <xercesc/util/XMLString.hpp>
47 #include <xercesc/util/PlatformUtils.hpp>
48 #include <xercesc/framework/LocalFileFormatTarget.hpp>
49 
50 #include "G4Transform3D.hh"
51 
52 #include "G4GDMLAuxStructType.hh"
53 
54 class G4LogicalVolume;
55 class G4VPhysicalVolume;
56 
58 {
59  typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
60  typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
61  typedef std::map<G4int,G4int> DepthMapType;
62 
63  public: // with description
64 
65  G4Transform3D Write(const G4String& filename,
66  const G4LogicalVolume* const topLog,
67  const G4String& schemaPath,
68  const G4int depth, G4bool storeReferences=true);
69  //
70  // Main method for writing GDML files.
71 
72  void AddModule(const G4VPhysicalVolume* const topVol);
73  void AddModule(const G4int depth);
74  //
75  // Split geometry structure in modules, by volume subtree or level
76 
78  //
79  // Import auxiliary structure
80 
81  static void SetAddPointerToName(G4bool);
82  //
83  // Specify if to add or not memory addresses to IDs.
84 
85  virtual void DefineWrite(xercesc::DOMElement*)=0;
86  virtual void MaterialsWrite(xercesc::DOMElement*)=0;
87  virtual void SolidsWrite(xercesc::DOMElement*)=0;
88  virtual void StructureWrite(xercesc::DOMElement*)=0;
90  const G4int)=0;
91  virtual void SurfacesWrite()=0;
92  virtual void SetupWrite(xercesc::DOMElement*,
93  const G4LogicalVolume* const)=0;
94  //
95  // Pure virtual methods implemented in concrete writer plugin's classes
96 
97  virtual void ExtensionWrite(xercesc::DOMElement*);
98  virtual void UserinfoWrite(xercesc::DOMElement*);
99  virtual void AddExtension(xercesc::DOMElement*,
100  const G4LogicalVolume* const);
101  //
102  // To be implemented in the client code for handling extensions
103  // to the GDML schema, identified with the tag "extension".
104  // The implementation should be placed inside a user-class
105  // inheriting from G4GDMLWriteStructure and being registered
106  // as argument to G4GDMLParser.
107 
108  G4String GenerateName(const G4String&,const void* const);
109 
110  protected:
111 
112  G4GDMLWrite();
113  virtual ~G4GDMLWrite();
114 
115  VolumeMapType& VolumeMap();
116 
117  xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
118  xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
119  xercesc::DOMElement* NewElement(const G4String&);
120  G4String Modularize(const G4VPhysicalVolume* const topvol,
121  const G4int depth);
122 
123  void AddAuxInfo(G4GDMLAuxListType* auxInfoList, xercesc::DOMElement* element);
124 
125  G4bool FileExists(const G4String&) const;
126  PhysVolumeMapType& PvolumeMap();
127  DepthMapType& DepthMap();
128 
129  protected:
130 
133  xercesc::DOMDocument* doc;
134  xercesc::DOMElement* extElement;
135  xercesc::DOMElement* userinfoElement;
136  XMLCh tempStr[10000];
138 };
139 
140 #endif
virtual ~G4GDMLWrite()
Definition: G4GDMLWrite.cc:50
virtual void ExtensionWrite(xercesc::DOMElement *)
Definition: G4GDMLWrite.cc:85
void AddAuxiliary(G4GDMLAuxStructType myaux)
Definition: G4GDMLWrite.cc:349
void AddAuxInfo(G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
Definition: G4GDMLWrite.cc:90
xercesc::DOMDocument * doc
Definition: G4GDMLWrite.hh:133
G4String SchemaLocation
Definition: G4GDMLWrite.hh:131
G4bool FileExists(const G4String &) const
Definition: G4GDMLWrite.cc:54
PhysVolumeMapType & PvolumeMap()
Definition: G4GDMLWrite.cc:66
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:160
int G4int
Definition: G4Types.hh:78
DepthMapType & DepthMap()
Definition: G4GDMLWrite.cc:72
G4String Modularize(const G4VPhysicalVolume *const topvol, const G4int depth)
Definition: G4GDMLWrite.cc:329
G4Transform3D Write(const G4String &filename, const G4LogicalVolume *const topLog, const G4String &schemaPath, const G4int depth, G4bool storeReferences=true)
Definition: G4GDMLWrite.cc:166
virtual void SetupWrite(xercesc::DOMElement *, const G4LogicalVolume *const)=0
virtual void StructureWrite(xercesc::DOMElement *)=0
bool G4bool
Definition: G4Types.hh:79
virtual void DefineWrite(xercesc::DOMElement *)=0
virtual void MaterialsWrite(xercesc::DOMElement *)=0
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:123
static void SetAddPointerToName(G4bool)
Definition: G4GDMLWrite.cc:354
static G4bool addPointerToName
Definition: G4GDMLWrite.hh:132
void AddModule(const G4VPhysicalVolume *const topVol)
Definition: G4GDMLWrite.cc:281
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:136
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume *const, const G4int)=0
virtual void UserinfoWrite(xercesc::DOMElement *)
Definition: G4GDMLWrite.cc:111
virtual void SolidsWrite(xercesc::DOMElement *)=0
virtual void AddExtension(xercesc::DOMElement *, const G4LogicalVolume *const)
Definition: G4GDMLWrite.cc:78
G4GDMLAuxListType auxList
Definition: G4GDMLWrite.hh:137
double G4double
Definition: G4Types.hh:76
virtual void SurfacesWrite()=0
XMLCh tempStr[10000]
Definition: G4GDMLWrite.hh:136
VolumeMapType & VolumeMap()
Definition: G4GDMLWrite.cc:60
xercesc::DOMElement * extElement
Definition: G4GDMLWrite.hh:134
xercesc::DOMElement * userinfoElement
Definition: G4GDMLWrite.hh:135