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