File indexing completed on 2025-01-18 09:58:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef G4GDMLBASE_HH
0035 #define G4GDMLBASE_HH 1
0036
0037 #include <xercesc/parsers/XercesDOMParser.hpp>
0038 #include <xercesc/util/PlatformUtils.hpp>
0039 #include <xercesc/sax/HandlerBase.hpp>
0040 #include <xercesc/util/XMLUni.hpp>
0041 #include <xercesc/dom/DOM.hpp>
0042
0043 #include "G4Types.hh"
0044
0045 #include "G4GDMLEvaluator.hh"
0046 #include "G4GDMLAuxStructType.hh"
0047
0048 class G4LogicalVolume;
0049 class G4VPhysicalVolume;
0050
0051 class G4GDMLErrorHandler : public xercesc::ErrorHandler
0052 {
0053 public:
0054
0055 G4GDMLErrorHandler(const G4bool set) { Suppress = set; }
0056
0057 void warning(const xercesc::SAXParseException& exception)
0058 {
0059 if(Suppress)
0060 {
0061 return;
0062 }
0063 char* message = xercesc::XMLString::transcode(exception.getMessage());
0064 G4cout << "G4GDML: VALIDATION WARNING! " << message
0065 << " at line: " << exception.getLineNumber() << G4endl;
0066 xercesc::XMLString::release(&message);
0067 }
0068
0069 void error(const xercesc::SAXParseException& exception)
0070 {
0071 if(Suppress)
0072 {
0073 return;
0074 }
0075 char* message = xercesc::XMLString::transcode(exception.getMessage());
0076 G4cout << "G4GDML: VALIDATION ERROR! " << message
0077 << " at line: " << exception.getLineNumber() << G4endl;
0078 xercesc::XMLString::release(&message);
0079 }
0080
0081 void fatalError(const xercesc::SAXParseException& exception)
0082 {
0083 error(exception);
0084 }
0085 void resetErrors() {}
0086
0087 private:
0088
0089 G4bool Suppress = false;
0090 };
0091
0092 class G4GDMLRead
0093 {
0094 public:
0095
0096 virtual void DefineRead(const xercesc::DOMElement* const) = 0;
0097 virtual void MaterialsRead(const xercesc::DOMElement* const) = 0;
0098 virtual void SetupRead(const xercesc::DOMElement* const) = 0;
0099 virtual void SolidsRead(const xercesc::DOMElement* const) = 0;
0100 virtual void Paramvol_contentRead(const xercesc::DOMElement* const) = 0;
0101 virtual void Volume_contentRead(const xercesc::DOMElement* const) = 0;
0102 virtual void StructureRead(const xercesc::DOMElement* const) = 0;
0103
0104
0105
0106 virtual void ExtensionRead(const xercesc::DOMElement* const);
0107
0108
0109
0110
0111
0112
0113
0114 virtual void UserinfoRead(const xercesc::DOMElement* const);
0115
0116
0117
0118
0119 virtual G4LogicalVolume* GetVolume(const G4String&) const = 0;
0120 virtual G4String GetSetup(const G4String&) = 0;
0121
0122
0123
0124 void Read(const G4String&, G4bool validation, G4bool isModule,
0125 G4bool strip = true);
0126
0127
0128
0129 void StripNames() const;
0130 void StripName(G4String&) const;
0131
0132
0133
0134 const G4String& GetSchemaFile() const;
0135 void SetSchemaFile(const G4String& schemaFile);
0136
0137
0138
0139 void OverlapCheck(G4bool);
0140
0141
0142
0143 const G4GDMLAuxListType* GetAuxList() const;
0144
0145 protected:
0146
0147 G4GDMLRead();
0148 virtual ~G4GDMLRead();
0149
0150 G4String Transcode(const XMLCh* const);
0151 G4String GenerateName(const G4String& name, G4bool strip = false);
0152 G4String Strip(const G4String&) const;
0153 void GeneratePhysvolName(const G4String&, G4VPhysicalVolume*);
0154 void LoopRead(const xercesc::DOMElement* const,
0155 void (G4GDMLRead::*)(const xercesc::DOMElement* const));
0156
0157 G4GDMLAuxStructType AuxiliaryRead(const xercesc::DOMElement* const auxElem);
0158
0159 protected:
0160
0161 G4GDMLEvaluator eval;
0162 G4bool validate = true;
0163 G4bool check = false;
0164 G4bool dostrip = true;
0165 G4String schema = "";
0166
0167 private:
0168
0169 G4int inLoop = 0, loopCount = 0;
0170 G4GDMLAuxListType auxGlobalList;
0171 };
0172
0173 #endif