Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4GDMLParser.hh
Go to the documentation of this file.
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: G4GDMLParser.hh 96673 2016-04-29 12:08:20Z gcosmo $
28 //
29 //
30 // class G4GDMLParser
31 //
32 // Class description:
33 //
34 // GDML main parser.
35 
36 // History:
37 // - Created. Zoltan Torzsok, November 2007
38 // -------------------------------------------------------------------------
39 
40 #ifndef _G4GDMLPARSER_INCLUDED_
41 #define _G4GDMLPARSER_INCLUDED_
42 
43 #include "G4GDMLReadStructure.hh"
44 #include "G4GDMLWriteStructure.hh"
45 #include "G4STRead.hh"
46 #include "G4GDMLMessenger.hh"
47 #include "G4GDMLEvaluator.hh"
48 
50 #include "G4Navigator.hh"
51 
52 
53 #define G4GDML_DEFAULT_SCHEMALOCATION G4String("http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd")
54 
56 {
57  public: // with description
58 
59  G4GDMLParser();
62  ~G4GDMLParser();
63  //
64  // Parser constructors & destructor
65 
66  inline void Read(const G4String& filename, G4bool Validate=true);
67  //
68  // Imports geometry with world-volume, specified by the GDML filename
69  // in input. Validation against schema is activated by default.
70 
71  inline void ReadModule(const G4String& filename, G4bool Validate=true);
72  //
73  // Imports a single GDML module, specified by the GDML filename
74  // in input. Validation against schema is activated by default.
75 
76  inline void Write(const G4String& filename,
77  const G4VPhysicalVolume* pvol = 0,
78  G4bool storeReferences = true,
79  const G4String& SchemaLocation = G4GDML_DEFAULT_SCHEMALOCATION);
80  //
81  // Exports on a GDML file, specified by 'filename' a geometry tree
82  // starting from 'pvol' as top volume. Uniqueness of stored entities
83  // is guaranteed by storing pointer-references by default.
84  // Alternative path for the schema location can be specified; by default
85  // the URL to the GDML web site is used.
86 
87  inline void Write(const G4String& filename,
88  const G4LogicalVolume* lvol,
89  G4bool storeReferences = true,
90  const G4String& SchemaLocation = G4GDML_DEFAULT_SCHEMALOCATION);
91  //
92  // Exports on a GDML file, specified by 'filename' a geometry tree
93  // starting from 'pvol' as top volume. Uniqueness of stored entities
94  // is guaranteed by storing pointer-references by default.
95  // Alternative path for the schema location can be specified; by default
96  // the URL to the GDML web site is used. Same as method above except
97  // that the logical volume must be provided here.
98 
99  inline G4LogicalVolume* ParseST(const G4String& name,
100  G4Material* medium,
101  G4Material* solid);
102  //
103  // Imports a tessellated geometry stored as STEP-Tools files
104  // 'name.geom' and 'name.tree'. It returns a pointer of a generated
105  // mother volume with 'medium' material associated, including the
106  // imported tessellated geometry with 'solid' material associated.
107 
108  // Methods for Reader
109  //
110  inline G4bool IsValid(const G4String& name) const;
111  inline G4double GetConstant(const G4String& name) const;
112  inline G4double GetVariable(const G4String& name) const;
113  inline G4double GetQuantity(const G4String& name) const;
114  inline G4ThreeVector GetPosition(const G4String& name) const;
115  inline G4ThreeVector GetRotation(const G4String& name) const;
116  inline G4ThreeVector GetScale(const G4String& name) const;
117  inline G4GDMLMatrix GetMatrix(const G4String& name) const;
118  inline G4LogicalVolume* GetVolume(const G4String& name) const;
119  inline G4VPhysicalVolume* GetWorldVolume(const G4String& setupName="Default") const;
121  inline const G4GDMLAuxMapType* GetAuxMap() const;
122  inline const G4GDMLAuxListType* GetAuxList() const;
123  inline void AddAuxiliary(G4GDMLAuxStructType myaux);
124  inline void StripNamePointers() const;
125  inline void SetStripFlag(G4bool);
126  inline void SetOverlapCheck(G4bool);
127  inline void SetRegionExport(G4bool);
128  inline void SetEnergyCutsExport(G4bool);
129  inline void SetSDExport(G4bool);
130 
131  inline void Clear(); // Clears the evaluator
132 
133  // Methods for Writer
134  //
135  inline void AddModule(const G4VPhysicalVolume* const physvol);
136  inline void AddModule(const G4int depth);
137  inline void SetAddPointerToName(G4bool set);
138  inline void AddVolumeAuxiliary(G4GDMLAuxStructType myaux, const G4LogicalVolume* const lvol);
139 
140  private:
141 
142  void ImportRegions();
143  void ExportRegions(G4bool storeReferences = true);
144 
145  private:
146 
147  G4GDMLEvaluator eval;
148  G4GDMLReadStructure* reader;
149  G4GDMLWriteStructure* writer;
150  G4GDMLAuxListType *rlist, *ullist;
151  G4GDMLMessenger* messenger;
152  G4bool urcode, uwcode, strip, rexp;
153 
154 };
155 
156 #include "G4GDMLParser.icc"
157 
158 #endif
const XML_Char * name
Definition: expat.h:151
G4LogicalVolume * GetVolume(const G4String &name) const
#define G4GDML_DEFAULT_SCHEMALOCATION
Definition: G4GDMLParser.hh:53
G4double GetVariable(const G4String &name) const
void AddModule(const G4VPhysicalVolume *const physvol)
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
G4GDMLAuxListType GetVolumeAuxiliaryInformation(G4LogicalVolume *lvol) const
void SetAddPointerToName(G4bool set)
int G4int
Definition: G4Types.hh:78
void SetOverlapCheck(G4bool)
void SetRegionExport(G4bool)
G4double GetConstant(const G4String &name) const
const G4GDMLAuxListType * GetAuxList() const
G4bool IsValid(const G4String &name) const
bool G4bool
Definition: G4Types.hh:79
void Write(const G4String &filename, const G4VPhysicalVolume *pvol=0, G4bool storeReferences=true, const G4String &SchemaLocation=G4GDML_DEFAULT_SCHEMALOCATION)
void AddVolumeAuxiliary(G4GDMLAuxStructType myaux, const G4LogicalVolume *const lvol)
void SetSDExport(G4bool)
G4LogicalVolume * ParseST(const G4String &name, G4Material *medium, G4Material *solid)
void SetEnergyCutsExport(G4bool)
G4ThreeVector GetRotation(const G4String &name) const
G4ThreeVector GetScale(const G4String &name) const
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
G4GDMLMatrix GetMatrix(const G4String &name) const
const G4GDMLAuxMapType * GetAuxMap() const
void Read(const G4String &filename, G4bool Validate=true)
G4double GetQuantity(const G4String &name) const
void SetStripFlag(G4bool)
void AddAuxiliary(G4GDMLAuxStructType myaux)
void ReadModule(const G4String &filename, G4bool Validate=true)
double G4double
Definition: G4Types.hh:76
std::map< G4LogicalVolume *, G4GDMLAuxListType > G4GDMLAuxMapType
G4ThreeVector GetPosition(const G4String &name) const
void StripNamePointers() const