Geant4_10
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 69013 2013-04-15 09:41:13Z 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 class G4LogicalVolume;
53 class G4VPhysicalVolume;
54 
56 {
57  typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
58  typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
59  typedef std::map<G4int,G4int> DepthMapType;
60 
61  public: // with description
62 
63  G4Transform3D Write(const G4String& filename,
64  const G4LogicalVolume* const topLog,
65  const G4String& schemaPath,
66  const G4int depth, G4bool storeReferences=true);
67  //
68  // Main method for writing GDML files.
69 
70  void AddModule(const G4VPhysicalVolume* const topVol);
71  void AddModule(const G4int depth);
72  //
73  // Split geometry structure in modules, by volume subtree or level
74 
75  static void SetAddPointerToName(G4bool);
76  //
77  // Specify if to add or not memory addresses to IDs.
78 
79  virtual void DefineWrite(xercesc::DOMElement*)=0;
80  virtual void MaterialsWrite(xercesc::DOMElement*)=0;
81  virtual void SolidsWrite(xercesc::DOMElement*)=0;
82  virtual void StructureWrite(xercesc::DOMElement*)=0;
84  const G4int)=0;
85  virtual void SurfacesWrite()=0;
86  virtual void SetupWrite(xercesc::DOMElement*,
87  const G4LogicalVolume* const)=0;
88  //
89  // Pure virtual methods implemented in concrete writer plugin's classes
90 
91  virtual void ExtensionWrite(xercesc::DOMElement*);
92  virtual void AddExtension(xercesc::DOMElement*,
93  const G4LogicalVolume* const);
94  //
95  // To be implemented in the client code for handling extensions
96  // to the GDML schema, identified with the tag "extension".
97  // The implementation should be placed inside a user-class
98  // inheriting from G4GDMLWriteStructure and being registered
99  // as argument to G4GDMLParser.
100 
101  protected:
102 
103  G4GDMLWrite();
104  virtual ~G4GDMLWrite();
105 
106  VolumeMapType& VolumeMap();
107 
108  G4String GenerateName(const G4String&,const void* const);
109  xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
110  xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
111  xercesc::DOMElement* NewElement(const G4String&);
112  G4String Modularize(const G4VPhysicalVolume* const topvol,
113  const G4int depth);
114 
115  G4bool FileExists(const G4String&) const;
116  PhysVolumeMapType& PvolumeMap();
117  DepthMapType& DepthMap();
118 
119  protected:
120 
123  xercesc::DOMDocument* doc;
124  xercesc::DOMElement* extElement;
125  XMLCh tempStr[10000];
126 
127 };
128 
129 #endif
virtual ~G4GDMLWrite()
Definition: G4GDMLWrite.cc:50
virtual void ExtensionWrite(xercesc::DOMElement *)
Definition: G4GDMLWrite.cc:85
xercesc::DOMDocument * doc
Definition: G4GDMLWrite.hh:123
G4String SchemaLocation
Definition: G4GDMLWrite.hh:121
G4bool FileExists(const G4String &) const
Definition: G4GDMLWrite.cc:54
PhysVolumeMapType & PvolumeMap()
Definition: G4GDMLWrite.cc:66
xercesc::DOMElement * NewElement(const G4String &)
Definition: G4GDMLWrite.cc:127
int G4int
Definition: G4Types.hh:78
DepthMapType & DepthMap()
Definition: G4GDMLWrite.cc:72
G4String Modularize(const G4VPhysicalVolume *const topvol, const G4int depth)
Definition: G4GDMLWrite.cc:295
G4Transform3D Write(const G4String &filename, const G4LogicalVolume *const topLog, const G4String &schemaPath, const G4int depth, G4bool storeReferences=true)
Definition: G4GDMLWrite.cc:133
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:90
static void SetAddPointerToName(G4bool)
Definition: G4GDMLWrite.cc:315
static G4bool addPointerToName
Definition: G4GDMLWrite.hh:122
void AddModule(const G4VPhysicalVolume *const topVol)
Definition: G4GDMLWrite.cc:247
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:103
virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume *const, const G4int)=0
virtual void SolidsWrite(xercesc::DOMElement *)=0
virtual void AddExtension(xercesc::DOMElement *, const G4LogicalVolume *const)
Definition: G4GDMLWrite.cc:78
double G4double
Definition: G4Types.hh:76
virtual void SurfacesWrite()=0
XMLCh tempStr[10000]
Definition: G4GDMLWrite.hh:125
VolumeMapType & VolumeMap()
Definition: G4GDMLWrite.cc:60
xercesc::DOMElement * extElement
Definition: G4GDMLWrite.hh:124