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