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