[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 | // |
---|
| 27 | // $Id: G4GDMLWrite.hh,v 1.37 2008/08/19 15:03:17 gcosmo Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
| 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 | |
---|
| 44 | #include <sys/stat.h> |
---|
| 45 | #include <iostream> |
---|
| 46 | |
---|
| 47 | #include <xercesc/dom/DOM.hpp> |
---|
| 48 | #include <xercesc/util/XMLString.hpp> |
---|
| 49 | #include <xercesc/util/PlatformUtils.hpp> |
---|
| 50 | #include <xercesc/framework/LocalFileFormatTarget.hpp> |
---|
| 51 | |
---|
| 52 | #include "G4LogicalVolume.hh" |
---|
| 53 | #include "G4Transform3D.hh" |
---|
| 54 | #include "G4PVDivision.hh" |
---|
| 55 | |
---|
| 56 | class G4GDMLWrite |
---|
| 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: // without description |
---|
| 63 | |
---|
| 64 | G4Transform3D Write(const G4String& filename, |
---|
| 65 | const G4LogicalVolume* const topLog, |
---|
| 66 | const G4String& schemaPath, |
---|
| 67 | const G4int depth, G4bool storeReferences=true); |
---|
| 68 | void AddModule(const G4VPhysicalVolume* const topVol); |
---|
| 69 | void AddModule(const G4int depth); |
---|
| 70 | static void SetAddPointerToName(G4bool); |
---|
| 71 | |
---|
| 72 | protected: |
---|
| 73 | |
---|
| 74 | G4String SchemaLocation; |
---|
| 75 | |
---|
| 76 | VolumeMapType& VolumeMap(); |
---|
| 77 | |
---|
| 78 | G4String GenerateName(const G4String&,const void* const); |
---|
| 79 | xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&); |
---|
| 80 | xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&); |
---|
| 81 | xercesc::DOMElement* NewElement(const G4String&); |
---|
| 82 | virtual void DefineWrite(xercesc::DOMElement*)=0; |
---|
| 83 | virtual void MaterialsWrite(xercesc::DOMElement*)=0; |
---|
| 84 | virtual void SolidsWrite(xercesc::DOMElement*)=0; |
---|
| 85 | virtual void StructureWrite(xercesc::DOMElement*)=0; |
---|
| 86 | virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const, |
---|
| 87 | const G4int)=0; |
---|
| 88 | virtual void SetupWrite(xercesc::DOMElement*, |
---|
| 89 | const G4LogicalVolume* const)=0; |
---|
| 90 | G4String Modularize(const G4VPhysicalVolume* const topvol, |
---|
| 91 | const G4int depth); |
---|
| 92 | |
---|
| 93 | private: |
---|
| 94 | |
---|
| 95 | G4bool FileExists(const G4String&) const; |
---|
| 96 | PhysVolumeMapType& PvolumeMap(); |
---|
| 97 | DepthMapType& DepthMap(); |
---|
| 98 | |
---|
| 99 | private: |
---|
| 100 | |
---|
| 101 | static G4bool addPointerToName; |
---|
| 102 | xercesc::DOMDocument* doc; |
---|
| 103 | XMLCh tempStr[100]; |
---|
| 104 | |
---|
| 105 | }; |
---|
| 106 | |
---|
| 107 | #endif |
---|