BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSGDMLPreprocessor.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifdef USE_GDML
20
21#ifndef BDSGDMLPREPROCESSOR_H
22#define BDSGDMLPREPROCESSOR_H
23
24#include "G4String.hh"
25
26#include <vector>
27#include <map>
28
29#include "xercesc/dom/DOM.hpp"
30#include "xercesc/dom/DOMNodeList.hpp"
31
32namespace BDS
33{
34 G4String PreprocessGDML(const G4String& file,
35 const G4String& prefix,
36 G4bool preprocessSchema = true);
37
38 G4String PreprocessGDMLSchemaOnly(const G4String& file);
39
41 G4String GDMLSchemaLocation();
42}
43
55{
56public:
59
60 G4String PreprocessFile(const G4String& file,
61 const G4String& prefix,
62 G4bool preprocessSchema = true);
63
66 static G4String ProcessedNodeName(const G4String& nodeName,
67 const G4String& prefix);
68private:
69
70 void ReadDoc(xercesc::DOMNodeIterator* docIterator, G4bool processSchema);
71 void ReadNode(xercesc::DOMNode* node, G4bool processSchema);
72 void ProcessGDMLNode(xercesc::DOMNamedNodeMap* attributeMap);
73 void ReadAttributes(xercesc::DOMNamedNodeMap* attributeMap);
74 void ProcessDoc(xercesc::DOMNodeIterator* dotIterator, const G4String& prefix);
75 void ProcessNode(xercesc::DOMNode* node, const G4String& prefix);
76 void ProcessAttributes(xercesc::DOMNamedNodeMap* attributeMap, const G4String& prefix);
77
78 G4String parentDir;
79 std::vector<std::string> ignoreNodes;
80 std::vector<std::string> ignoreAttrs;
81 std::vector<std::string> names;
82 std::map<std::string, int> count;
83
84};
85
86#endif
87
88#endif
Process a GDML file to allow multiple file loading.
static G4String ProcessedNodeName(const G4String &nodeName, const G4String &prefix)
std::vector< std::string > ignoreNodes
Nodes to ignore.
G4String PreprocessFile(const G4String &file, const G4String &prefix, G4bool preprocessSchema=true)
std::vector< std::string > names
Names to replace.
std::map< std::string, int > count
Debugging.
std::vector< std::string > ignoreAttrs
Attributes to ignore.
G4String parentDir
Directory of main gdml file.
Return either G4Tubs or G4CutTubs depending on flat face.
G4String GDMLSchemaLocation()
Get GDML Schema location included with BDSIM.