Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:19

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4GDMLWrite
0027 //
0028 // Class description:
0029 //
0030 // GDML writer.
0031 
0032 // Author: Zoltan Torzsok, November 2007
0033 // --------------------------------------------------------------------
0034 #ifndef G4GDMLWRITE_HH
0035 #define G4GDMLWRITE_HH 1
0036 
0037 #include <map>
0038 
0039 #include <xercesc/dom/DOM.hpp>
0040 #include <xercesc/util/XMLString.hpp>
0041 #include <xercesc/util/PlatformUtils.hpp>
0042 #include <xercesc/framework/LocalFileFormatTarget.hpp>
0043 
0044 #include "G4Transform3D.hh"
0045 
0046 #include "G4GDMLAuxStructType.hh"
0047 
0048 class G4LogicalVolume;
0049 class G4VPhysicalVolume;
0050 
0051 class G4GDMLWrite
0052 {
0053   using VolumeMapType = std::map<const G4LogicalVolume*, G4Transform3D>;
0054   using PhysVolumeMapType = std::map<const G4VPhysicalVolume*, G4String>;
0055   using DepthMapType = std::map<G4int, G4int>;
0056 
0057   public:
0058 
0059     G4Transform3D Write(const G4String& filename,
0060                         const G4LogicalVolume* const topLog,
0061                         const G4String& schemaPath, const G4int depth,
0062                         G4bool storeReferences = true);
0063     //
0064     // Main method for writing GDML files.
0065 
0066     void AddModule(const G4VPhysicalVolume* const topVol);
0067     void AddModule(const G4int depth);
0068     //
0069     // Split geometry structure in modules, by volume subtree or level.
0070 
0071     void AddAuxiliary(G4GDMLAuxStructType myaux);
0072     //
0073     // Import auxiliary structure.
0074 
0075     void SetOutputFileOverwrite(G4bool flag);
0076     //
0077     // Set the flag to allow overwriting of the output GDML file
0078 
0079     static void SetAddPointerToName(G4bool);
0080     //
0081     // Specify if to add or not memory addresses to IDs.
0082 
0083     virtual void DefineWrite(xercesc::DOMElement*)        = 0;
0084     virtual void MaterialsWrite(xercesc::DOMElement*)     = 0;
0085     virtual void SolidsWrite(xercesc::DOMElement*)        = 0;
0086     virtual void StructureWrite(xercesc::DOMElement*)     = 0;
0087     virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume* const,
0088                                              const G4int) = 0;
0089     virtual void SurfacesWrite()                          = 0;
0090     virtual void SetupWrite(xercesc::DOMElement*,
0091                             const G4LogicalVolume* const) = 0;
0092     //
0093     // Pure virtual methods implemented in concrete writer plugin's classes.
0094 
0095     virtual void ExtensionWrite(xercesc::DOMElement*);
0096     virtual void UserinfoWrite(xercesc::DOMElement*);
0097     virtual void AddExtension(xercesc::DOMElement*,
0098                               const G4LogicalVolume* const);
0099     //
0100     // To be implemented in the client code for handling extensions
0101     // to the GDML schema, identified with the tag "extension".
0102     // The implementation should be placed inside a user-class
0103     // inheriting from G4GDMLWriteStructure and being registered
0104     // as argument to G4GDMLParser.
0105 
0106     G4String GenerateName(const G4String&, const void* const);
0107 
0108   protected:
0109 
0110     G4GDMLWrite();
0111     virtual ~G4GDMLWrite();
0112 
0113     VolumeMapType& VolumeMap();
0114 
0115     xercesc::DOMAttr* NewAttribute(const G4String&, const G4String&);
0116     xercesc::DOMAttr* NewAttribute(const G4String&, const G4double&);
0117     xercesc::DOMElement* NewElement(const G4String&);
0118     G4String Modularize(const G4VPhysicalVolume* const topvol,
0119                         const G4int depth);
0120 
0121     void AddAuxInfo(G4GDMLAuxListType* auxInfoList,
0122                     xercesc::DOMElement* element);
0123 
0124     G4bool FileExists(const G4String&) const;
0125     PhysVolumeMapType& PvolumeMap();
0126     DepthMapType& DepthMap();
0127 
0128   protected:
0129 
0130     G4String SchemaLocation;
0131     static G4bool addPointerToName;
0132     xercesc::DOMDocument* doc = nullptr;
0133     xercesc::DOMElement* extElement = nullptr;
0134     xercesc::DOMElement* userinfoElement = nullptr;
0135 
0136     G4GDMLAuxListType auxList;
0137     G4bool overwriteOutputFile = false;
0138 };
0139 
0140 #endif