G4GDMLWrite.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 // class G4GDMLWrite
00031 //
00032 // Class description:
00033 //
00034 // GDML writer.
00035 
00036 // History:
00037 // - Created.                                  Zoltan Torzsok, November 2007
00038 // -------------------------------------------------------------------------
00039 
00040 #ifndef _G4GDMLWRITE_INCLUDED_
00041 #define _G4GDMLWRITE_INCLUDED_
00042 
00043 #include <map>
00044 
00045 #include <xercesc/dom/DOM.hpp>
00046 #include <xercesc/util/XMLString.hpp>
00047 #include <xercesc/util/PlatformUtils.hpp>
00048 #include <xercesc/framework/LocalFileFormatTarget.hpp>
00049 
00050 #include "G4Transform3D.hh"
00051 
00052 class G4LogicalVolume;
00053 class G4VPhysicalVolume;
00054 
00055 class G4GDMLWrite
00056 {
00057   typedef std::map<const G4LogicalVolume*,G4Transform3D> VolumeMapType;
00058   typedef std::map<const G4VPhysicalVolume*,G4String> PhysVolumeMapType;
00059   typedef std::map<G4int,G4int> DepthMapType;
00060 
00061   public:  // with description
00062 
00063     G4Transform3D Write(const G4String& filename,
00064                         const G4LogicalVolume* const topLog,
00065                         const G4String& schemaPath,
00066                         const G4int depth, G4bool storeReferences=true);
00067       //
00068       // Main method for writing GDML files.
00069 
00070     void AddModule(const G4VPhysicalVolume* const topVol);
00071     void AddModule(const G4int depth);
00072       //
00073       // Split geometry structure in modules, by volume subtree or level
00074 
00075     static void SetAddPointerToName(G4bool);
00076       //
00077       // Specify if to add or not memory addresses to IDs.
00078 
00079     virtual void DefineWrite(xercesc::DOMElement*)=0;
00080     virtual void MaterialsWrite(xercesc::DOMElement*)=0;
00081     virtual void SolidsWrite(xercesc::DOMElement*)=0;
00082     virtual void StructureWrite(xercesc::DOMElement*)=0;
00083     virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
00084                                              const G4int)=0;
00085     virtual void SurfacesWrite()=0;
00086     virtual void SetupWrite(xercesc::DOMElement*,
00087                             const G4LogicalVolume* const)=0;
00088       //
00089       // Pure virtual methods implemented in concrete writer plugin's classes
00090 
00091     virtual void ExtensionWrite(xercesc::DOMElement*);
00092     virtual void AddExtension(xercesc::DOMElement*,
00093                               const G4LogicalVolume* const);
00094       //
00095       // To be implemented in the client code for handling extensions
00096       // to the GDML schema, identified with the tag "extension".
00097       // The implementation should be placed inside a user-class
00098       // inheriting from G4GDMLWriteStructure and being registered
00099       // as argument to G4GDMLParser.
00100 
00101   protected:
00102 
00103     G4GDMLWrite();
00104     virtual ~G4GDMLWrite();
00105 
00106     VolumeMapType& VolumeMap();
00107 
00108     G4String GenerateName(const G4String&,const void* const);
00109     xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
00110     xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
00111     xercesc::DOMElement* NewElement(const G4String&);
00112     G4String Modularize(const G4VPhysicalVolume* const topvol,
00113                         const G4int depth);
00114 
00115     G4bool FileExists(const G4String&) const;
00116     PhysVolumeMapType& PvolumeMap();
00117     DepthMapType& DepthMap();
00118 
00119   protected:
00120 
00121     G4String SchemaLocation;
00122     static G4bool addPointerToName;
00123     xercesc::DOMDocument* doc;
00124     xercesc::DOMElement* extElement;
00125     XMLCh tempStr[10000];
00126 
00127 };
00128 
00129 #endif

Generated on Mon May 27 17:48:20 2013 for Geant4 by  doxygen 1.4.7