00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _G4GDMLBASE_INCLUDED_
00040 #define _G4GDMLBASE_INCLUDED_
00041
00042 #include <xercesc/parsers/XercesDOMParser.hpp>
00043 #include <xercesc/util/PlatformUtils.hpp>
00044 #include <xercesc/sax/HandlerBase.hpp>
00045 #include <xercesc/util/XMLUni.hpp>
00046 #include <xercesc/dom/DOM.hpp>
00047
00048 #include "G4Types.hh"
00049
00050 #include "G4GDMLEvaluator.hh"
00051
00052 class G4LogicalVolume;
00053 class G4VPhysicalVolume;
00054
00055 class G4GDMLErrorHandler : public xercesc::ErrorHandler
00056 {
00057 G4bool Suppress;
00058
00059 public:
00060
00061 G4GDMLErrorHandler(const G4bool set) { Suppress = set; }
00062
00063 void warning(const xercesc::SAXParseException& exception)
00064 {
00065 if (Suppress) { return; }
00066 char* message = xercesc::XMLString::transcode(exception.getMessage());
00067 G4cout << "G4GDML: VALIDATION WARNING! " << message
00068 << " at line: " << exception.getLineNumber() << G4endl;
00069 xercesc::XMLString::release(&message);
00070 }
00071
00072 void error(const xercesc::SAXParseException& exception)
00073 {
00074 if (Suppress) { return; }
00075 char* message = xercesc::XMLString::transcode(exception.getMessage());
00076 G4cout << "G4GDML: VALIDATION ERROR! " << message
00077 << " at line: " << exception.getLineNumber() << G4endl;
00078 xercesc::XMLString::release(&message);
00079 }
00080
00081 void fatalError(const xercesc::SAXParseException& exception)
00082 {
00083 error(exception);
00084 }
00085 void resetErrors() {}
00086 };
00087
00088 class G4GDMLRead
00089 {
00090
00091 public:
00092
00093 virtual void DefineRead(const xercesc::DOMElement* const)=0;
00094 virtual void MaterialsRead(const xercesc::DOMElement* const)=0;
00095 virtual void SetupRead(const xercesc::DOMElement* const)=0;
00096 virtual void SolidsRead(const xercesc::DOMElement* const)=0;
00097 virtual void Paramvol_contentRead(const xercesc::DOMElement* const)=0;
00098 virtual void Volume_contentRead(const xercesc::DOMElement* const)=0;
00099 virtual void StructureRead(const xercesc::DOMElement* const)=0;
00100
00101
00102
00103 virtual void ExtensionRead(const xercesc::DOMElement* const);
00104
00105
00106
00107
00108
00109
00110
00111 virtual G4LogicalVolume* GetVolume(const G4String&) const=0;
00112 virtual G4String GetSetup(const G4String&)=0;
00113
00114
00115
00116 void Read(const G4String&, G4bool validation,
00117 G4bool isModule, G4bool strip=true);
00118
00119
00120
00121 void StripNames() const;
00122
00123
00124
00125 void OverlapCheck(G4bool);
00126
00127
00128
00129 protected:
00130
00131 G4GDMLRead();
00132 virtual ~G4GDMLRead();
00133
00134 G4String Transcode(const XMLCh* const);
00135 G4String GenerateName(const G4String& name, G4bool strip=false);
00136 G4String Strip(const G4String&) const;
00137 void StripName(G4String&) const;
00138 void GeneratePhysvolName(const G4String&,G4VPhysicalVolume*);
00139 void LoopRead(const xercesc::DOMElement* const,
00140 void(G4GDMLRead::*)(const xercesc::DOMElement* const));
00141
00142 protected:
00143
00144 G4GDMLEvaluator eval;
00145 G4bool validate;
00146 G4bool check;
00147
00148 private:
00149
00150 G4int inLoop, loopCount;
00151
00152 };
00153
00154 #endif