| [987] | 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 | //
|
|---|
| [1315] | 27 | // $Id: G4GDMLWrite.hh,v 1.42 2010/02/18 17:39:00 gcosmo Exp $
|
|---|
| [1337] | 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| [987] | 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // class G4GDMLWrite
|
|---|
| 32 | //
|
|---|
| 33 | // Class description:
|
|---|
| 34 | //
|
|---|
| 35 | // GDML writer.
|
|---|
| 36 |
|
|---|
| 37 | // History:
|
|---|
| 38 | // - Created. Zoltan Torzsok, November 2007
|
|---|
| 39 | // -------------------------------------------------------------------------
|
|---|
| 40 |
|
|---|
| 41 | #ifndef _G4GDMLWRITE_INCLUDED_
|
|---|
| 42 | #define _G4GDMLWRITE_INCLUDED_
|
|---|
| 43 |
|
|---|
| [1228] | 44 | #include <map>
|
|---|
| [987] | 45 |
|
|---|
| 46 | #include <xercesc/dom/DOM.hpp>
|
|---|
| 47 | #include <xercesc/util/XMLString.hpp>
|
|---|
| 48 | #include <xercesc/util/PlatformUtils.hpp>
|
|---|
| 49 | #include <xercesc/framework/LocalFileFormatTarget.hpp>
|
|---|
| 50 |
|
|---|
| 51 | #include "G4Transform3D.hh"
|
|---|
| 52 |
|
|---|
| [1228] | 53 | class G4LogicalVolume;
|
|---|
| 54 | class G4VPhysicalVolume;
|
|---|
| 55 |
|
|---|
| [987] | 56 | class G4GDMLWrite
|
|---|
| 57 | {
|
|---|
| [1228] | 58 | typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
|
|---|
| 59 | typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
|
|---|
| 60 | typedef std::map<G4int,G4int> DepthMapType;
|
|---|
| [987] | 61 |
|
|---|
| [1228] | 62 | public: // with description
|
|---|
| [987] | 63 |
|
|---|
| [1228] | 64 | G4Transform3D Write(const G4String& filename,
|
|---|
| 65 | const G4LogicalVolume* const topLog,
|
|---|
| 66 | const G4String& schemaPath,
|
|---|
| 67 | const G4int depth, G4bool storeReferences=true);
|
|---|
| 68 | //
|
|---|
| 69 | // Main method for writing GDML files.
|
|---|
| [987] | 70 |
|
|---|
| [1228] | 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
|
|---|
| [987] | 75 |
|
|---|
| [1228] | 76 | static void SetAddPointerToName(G4bool);
|
|---|
| 77 | //
|
|---|
| 78 | // Specify if to add or not memory addresses to IDs.
|
|---|
| [987] | 79 |
|
|---|
| [1228] | 80 | virtual void DefineWrite(xercesc::DOMElement*)=0;
|
|---|
| 81 | virtual void MaterialsWrite(xercesc::DOMElement*)=0;
|
|---|
| 82 | virtual void SolidsWrite(xercesc::DOMElement*)=0;
|
|---|
| 83 | virtual void StructureWrite(xercesc::DOMElement*)=0;
|
|---|
| 84 | virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
|
|---|
| 85 | const G4int)=0;
|
|---|
| 86 | virtual void SurfacesWrite()=0;
|
|---|
| 87 | virtual void SetupWrite(xercesc::DOMElement*,
|
|---|
| 88 | const G4LogicalVolume* const)=0;
|
|---|
| 89 | //
|
|---|
| 90 | // Pure virtual methods implemented in concrete writer plugin's classes
|
|---|
| [987] | 91 |
|
|---|
| [1228] | 92 | virtual void ExtensionWrite(xercesc::DOMElement*);
|
|---|
| 93 | virtual void AddExtension(xercesc::DOMElement*,
|
|---|
| 94 | const G4LogicalVolume* const);
|
|---|
| 95 | //
|
|---|
| 96 | // To be implemented in the client code for handling extensions
|
|---|
| 97 | // to the GDML schema, identified with the tag "extension".
|
|---|
| 98 | // The implementation should be placed inside a user-class
|
|---|
| 99 | // inheriting from G4GDMLWriteStructure and being registered
|
|---|
| 100 | // as argument to G4GDMLParser.
|
|---|
| [987] | 101 |
|
|---|
| [1228] | 102 | protected:
|
|---|
| [987] | 103 |
|
|---|
| [1228] | 104 | G4GDMLWrite();
|
|---|
| 105 | virtual ~G4GDMLWrite();
|
|---|
| [987] | 106 |
|
|---|
| [1228] | 107 | VolumeMapType& VolumeMap();
|
|---|
| [987] | 108 |
|
|---|
| [1228] | 109 | G4String GenerateName(const G4String&,const void* const);
|
|---|
| 110 | xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
|
|---|
| 111 | xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
|
|---|
| 112 | xercesc::DOMElement* NewElement(const G4String&);
|
|---|
| 113 | G4String Modularize(const G4VPhysicalVolume* const topvol,
|
|---|
| 114 | const G4int depth);
|
|---|
| [987] | 115 |
|
|---|
| [1228] | 116 | G4bool FileExists(const G4String&) const;
|
|---|
| 117 | PhysVolumeMapType& PvolumeMap();
|
|---|
| 118 | DepthMapType& DepthMap();
|
|---|
| 119 |
|
|---|
| 120 | protected:
|
|---|
| 121 |
|
|---|
| 122 | G4String SchemaLocation;
|
|---|
| 123 | static G4bool addPointerToName;
|
|---|
| 124 | xercesc::DOMDocument* doc;
|
|---|
| 125 | xercesc::DOMElement* extElement;
|
|---|
| [1315] | 126 | XMLCh tempStr[10000];
|
|---|
| [1228] | 127 |
|
|---|
| [987] | 128 | };
|
|---|
| 129 |
|
|---|
| 130 | #endif
|
|---|