ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GDMLRead.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4GDMLRead.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 //
27 //
28 // class G4GDMLRead
29 //
30 // Class description:
31 //
32 // GDML reader.
33 
34 // History:
35 // - Created. Zoltan Torzsok, November 2007
36 // -------------------------------------------------------------------------
37 
38 #ifndef _G4GDMLBASE_INCLUDED_
39 #define _G4GDMLBASE_INCLUDED_
40 
41 #include <xercesc/parsers/XercesDOMParser.hpp>
42 #include <xercesc/util/PlatformUtils.hpp>
43 #include <xercesc/sax/HandlerBase.hpp>
44 #include <xercesc/util/XMLUni.hpp>
45 #include <xercesc/dom/DOM.hpp>
46 
47 #include "G4Types.hh"
48 
49 #include "G4GDMLEvaluator.hh"
50 #include "G4GDMLAuxStructType.hh"
51 
52 class G4LogicalVolume;
53 class G4VPhysicalVolume;
54 
55 class G4GDMLErrorHandler : public xercesc::ErrorHandler
56 {
58 
59  public:
60 
61  G4GDMLErrorHandler(const G4bool set) { Suppress = set; }
62 
63  void warning(const xercesc::SAXParseException& exception)
64  {
65  if (Suppress) { return; }
66  char* message = xercesc::XMLString::transcode(exception.getMessage());
67  G4cout << "G4GDML: VALIDATION WARNING! " << message
68  << " at line: " << exception.getLineNumber() << G4endl;
69  xercesc::XMLString::release(&message);
70  }
71 
72  void error(const xercesc::SAXParseException& exception)
73  {
74  if (Suppress) { return; }
75  char* message = xercesc::XMLString::transcode(exception.getMessage());
76  G4cout << "G4GDML: VALIDATION ERROR! " << message
77  << " at line: " << exception.getLineNumber() << G4endl;
78  xercesc::XMLString::release(&message);
79  }
80 
81  void fatalError(const xercesc::SAXParseException& exception)
82  {
83  error(exception);
84  }
85  void resetErrors() {}
86 };
87 
89 {
90 
91  public: // with description
92 
93  virtual void DefineRead(const xercesc::DOMElement* const)=0;
94  virtual void MaterialsRead(const xercesc::DOMElement* const)=0;
95  virtual void SetupRead(const xercesc::DOMElement* const)=0;
96  virtual void SolidsRead(const xercesc::DOMElement* const)=0;
97  virtual void Paramvol_contentRead(const xercesc::DOMElement* const)=0;
98  virtual void Volume_contentRead(const xercesc::DOMElement* const)=0;
99  virtual void StructureRead(const xercesc::DOMElement* const)=0;
100  //
101  // Pure virtual methods implemented in concrete reader plugin's classes
102 
103  virtual void ExtensionRead(const xercesc::DOMElement* const);
104  //
105  // To be implemented in the client code for handling extensions
106  // to the GDML schema, identified with the tag "extension".
107  // The implementation should be placed inside a user-class
108  // inheriting from G4GDMLReadStructure and being registered
109  // as argument to G4GDMLParser.
110 
111  virtual void UserinfoRead(const xercesc::DOMElement* const);
112  //
113  // Customisable by user to handle "userinfo" extensions to the
114  // GDML schema, identified by the tag "userinfo".
115 
116  virtual G4LogicalVolume* GetVolume(const G4String&) const=0;
117  virtual G4String GetSetup(const G4String&)=0;
118  //
119  // More pure virtual methods implemented in the reader plugin.
120 
121  void Read(const G4String&, G4bool validation,
122  G4bool isModule, G4bool strip=true);
123  //
124  // Main method for reading GDML files.
125 
126  void StripNames() const;
127  void StripName(G4String&) const;
128  //
129  // Strip off pointers from entity IDs.
130 
131  void OverlapCheck(G4bool);
132  //
133  // Activate/de-activate surface check for overlaps (default is off)
134 
135  const G4GDMLAuxListType* GetAuxList() const;
136 
137 
138  protected:
139 
140  G4GDMLRead();
141  virtual ~G4GDMLRead();
142 
143  G4String Transcode(const XMLCh* const);
144  G4String GenerateName(const G4String& name, G4bool strip=false);
145  G4String Strip(const G4String&) const;
147  void LoopRead(const xercesc::DOMElement* const,
148  void(G4GDMLRead::*)(const xercesc::DOMElement* const));
149 
150  G4GDMLAuxStructType AuxiliaryRead(const xercesc::DOMElement* const auxElem);
151 
152  protected:
153 
158 
159  private:
160 
163 
164 };
165 
166 #endif