Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GDMLWrite Class Referenceabstract

#include <G4GDMLWrite.hh>

Inheritance diagram for G4GDMLWrite:

Public Member Functions

G4Transform3D Write (const G4String &filename, const G4LogicalVolume *const topLog, const G4String &schemaPath, const G4int depth, G4bool storeReferences=true)
void AddModule (const G4VPhysicalVolume *const topVol)
void AddModule (const G4int depth)
void AddAuxiliary (G4GDMLAuxStructType myaux)
void SetOutputFileOverwrite (G4bool flag)
virtual void DefineWrite (xercesc::DOMElement *)=0
virtual void MaterialsWrite (xercesc::DOMElement *)=0
virtual void SolidsWrite (xercesc::DOMElement *)=0
virtual void StructureWrite (xercesc::DOMElement *)=0
virtual G4Transform3D TraverseVolumeTree (const G4LogicalVolume *const, const G4int)=0
virtual void SurfacesWrite ()=0
virtual void SetupWrite (xercesc::DOMElement *, const G4LogicalVolume *const)=0
virtual void ExtensionWrite (xercesc::DOMElement *)
virtual void UserinfoWrite (xercesc::DOMElement *)
virtual void AddExtension (xercesc::DOMElement *, const G4LogicalVolume *const)
G4String GenerateName (const G4String &, const void *const)

Static Public Member Functions

static void SetAddPointerToName (G4bool)

Protected Member Functions

 G4GDMLWrite ()
virtual ~G4GDMLWrite ()
VolumeMapType & VolumeMap ()
xercesc::DOMAttr * NewAttribute (const G4String &, const G4String &)
xercesc::DOMAttr * NewAttribute (const G4String &, const G4double &)
xercesc::DOMElement * NewElement (const G4String &)
G4String Modularize (const G4VPhysicalVolume *const topvol, const G4int depth)
void AddAuxInfo (G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
G4bool FileExists (const G4String &) const
PhysVolumeMapType & PvolumeMap ()
DepthMapType & DepthMap ()

Protected Attributes

G4String SchemaLocation
xercesc::DOMDocument * doc = nullptr
xercesc::DOMElement * extElement = nullptr
xercesc::DOMElement * userinfoElement = nullptr
G4GDMLAuxListType auxList
G4bool overwriteOutputFile = false

Static Protected Attributes

static G4bool addPointerToName = true

Detailed Description

Definition at line 51 of file G4GDMLWrite.hh.

Constructor & Destructor Documentation

◆ G4GDMLWrite()

G4GDMLWrite::G4GDMLWrite ( )
protected

Definition at line 43 of file G4GDMLWrite.cc.

44{
45}

Referenced by G4GDMLWriteDefine::G4GDMLWriteDefine().

◆ ~G4GDMLWrite()

G4GDMLWrite::~G4GDMLWrite ( )
protectedvirtual

Definition at line 48 of file G4GDMLWrite.cc.

49{
50}

Member Function Documentation

◆ AddAuxiliary()

void G4GDMLWrite::AddAuxiliary ( G4GDMLAuxStructType myaux)

Definition at line 401 of file G4GDMLWrite.cc.

402{
403 auxList.push_back(myaux);
404}
G4GDMLAuxListType auxList

◆ AddAuxInfo()

void G4GDMLWrite::AddAuxInfo ( G4GDMLAuxListType * auxInfoList,
xercesc::DOMElement * element )
protected

Definition at line 94 of file G4GDMLWrite.cc.

96{
97 for(auto iaux = auxInfoList->cbegin(); iaux != auxInfoList->cend(); ++iaux)
98 {
99 xercesc::DOMElement* auxiliaryElement = NewElement("auxiliary");
100 element->appendChild(auxiliaryElement);
101
102 auxiliaryElement->setAttributeNode(NewAttribute("auxtype", (*iaux).type));
103 auxiliaryElement->setAttributeNode(NewAttribute("auxvalue", (*iaux).value));
104 if(((*iaux).unit) != "")
105 {
106 auxiliaryElement->setAttributeNode(NewAttribute("auxunit", (*iaux).unit));
107 }
108
109 if(iaux->auxList)
110 {
111 AddAuxInfo(iaux->auxList, auxiliaryElement);
112 }
113 }
114 return;
115}
xercesc::DOMElement * NewElement(const G4String &)
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
void AddAuxInfo(G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)

Referenced by AddAuxInfo(), G4GDMLWriteStructure::TraverseVolumeTree(), and UserinfoWrite().

◆ AddExtension()

void G4GDMLWrite::AddExtension ( xercesc::DOMElement * ,
const G4LogicalVolume * const  )
virtual

Definition at line 80 of file G4GDMLWrite.cc.

82{
83 // Empty implementation. To be overwritten by user for specific extensions
84 // related to attributes associated to volumes
85}

Referenced by G4GDMLWriteStructure::TraverseVolumeTree().

◆ AddModule() [1/2]

void G4GDMLWrite::AddModule ( const G4int depth)

Definition at line 364 of file G4GDMLWrite.cc.

365{
366 if(depth < 0)
367 {
368 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
369 "Depth must be a positive number!");
370 }
371 if(DepthMap().find(depth) != DepthMap().end())
372 {
373 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
374 "Adding module(s) at this depth is already requested!");
375 }
376 DepthMap()[depth] = 0;
377}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
DepthMapType & DepthMap()

◆ AddModule() [2/2]

void G4GDMLWrite::AddModule ( const G4VPhysicalVolume *const topVol)

Definition at line 330 of file G4GDMLWrite.cc.

331{
332 G4String fname = GenerateName(physvol->GetName(), physvol);
333 G4cout << "G4GDML: Adding module '" << fname << "'..." << G4endl;
334
335 if(physvol == nullptr)
336 {
337 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
338 "Invalid NULL pointer is specified for modularization!");
339 return;
340 }
341 if(dynamic_cast<const G4PVDivision*>(physvol))
342 {
343 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
344 "It is not possible to modularize by divisionvol!");
345 return;
346 }
347 if(physvol->IsParameterised())
348 {
349 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
350 "It is not possible to modularize by parameterised volume!");
351 return;
352 }
353 if(physvol->IsReplicated())
354 {
355 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
356 "It is not possible to modularize by replicated volume!");
357 return;
358 }
359
360 PvolumeMap()[physvol] = fname;
361}
G4PVDivision(const G4String &pName, G4LogicalVolume *pLogical, G4LogicalVolume *pMother, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset)
G4PVDivision represents many touchable detector elements differing only in their positioning....
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4String GenerateName(const G4String &, const void *const)
PhysVolumeMapType & PvolumeMap()

◆ DefineWrite()

virtual void G4GDMLWrite::DefineWrite ( xercesc::DOMElement * )
pure virtual

Implemented in G4GDMLWriteDefine.

Referenced by Write().

◆ DepthMap()

G4GDMLWrite::DepthMapType & G4GDMLWrite::DepthMap ( )
protected

Definition at line 73 of file G4GDMLWrite.cc.

74{
75 static DepthMapType instance;
76 return instance;
77}
G4TemplateRNGHelper< G4long > * G4TemplateRNGHelper< G4long >::instance

Referenced by AddModule(), and Modularize().

◆ ExtensionWrite()

void G4GDMLWrite::ExtensionWrite ( xercesc::DOMElement * )
virtual

Definition at line 88 of file G4GDMLWrite.cc.

89{
90 // Empty implementation. To be overwritten by user for specific extensions
91}

Referenced by Write().

◆ FileExists()

G4bool G4GDMLWrite::FileExists ( const G4String & fname) const
protected

Definition at line 53 of file G4GDMLWrite.cc.

54{
55 struct stat FileInfo;
56 return (stat(fname.c_str(), &FileInfo) == 0);
57}

Referenced by Write().

◆ GenerateName()

G4String G4GDMLWrite::GenerateName ( const G4String & name,
const void * const ptr )

Definition at line 132 of file G4GDMLWrite.cc.

133{
134 G4String nameOut;
135 std::stringstream stream;
136 stream << name;
138 {
139#ifdef WIN32
140 stream << "0x";
141#endif
142 stream << ptr;
143 };
144
145 nameOut = G4String(stream.str());
146 std::vector<char> toremove = { ' ', '/', ':', '#', '+' };
147 for(auto c : toremove)
148 {
149 if(G4StrUtil::contains(nameOut, c))
150 {
151 std::replace(nameOut.begin(), nameOut.end(), c, '_');
152 }
153 }
154 return nameOut;
155}
static G4bool addPointerToName
const char * name(G4int ptype)
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.

Referenced by AddModule(), G4GDMLWriteStructure::AssemblyWrite(), G4GDMLWriteSolids::BooleanWrite(), G4GDMLWriteStructure::BorderSurfaceCache(), G4GDMLWriteSolids::BoxWrite(), G4GDMLWriteSolids::ConeWrite(), G4GDMLWriteSolids::CutTubeWrite(), G4GDMLWriteStructure::DivisionvolWrite(), G4GDMLWriteSolids::ElconeWrite(), G4GDMLWriteMaterials::ElementWrite(), G4GDMLWriteSolids::EllipsoidWrite(), G4GDMLWriteSolids::EltubeWrite(), G4GDMLWriteSolids::GenericPolyconeWrite(), G4GDMLWriteSolids::GenTrapWrite(), G4GDMLWriteSolids::HypeWrite(), G4GDMLWriteMaterials::IsotopeWrite(), G4GDMLWriteMaterials::MaterialWrite(), G4GDMLWriteSolids::MultiUnionWrite(), G4GDMLWriteSolids::OpticalSurfaceWrite(), G4GDMLWriteSolids::OrbWrite(), G4GDMLWriteSolids::ParaboloidWrite(), G4GDMLWriteParamvol::ParametersWrite(), G4GDMLWriteParamvol::ParamvolAlgorithmWrite(), G4GDMLWriteParamvol::ParamvolWrite(), G4GDMLWriteSolids::ParaWrite(), G4GDMLWriteStructure::PhysvolWrite(), G4GDMLWriteSolids::PolyconeWrite(), G4GDMLWriteSolids::PolyhedraWrite(), G4GDMLWriteMaterials::PropertyConstWrite(), G4GDMLWriteMaterials::PropertyVectorWrite(), G4GDMLWriteMaterials::PropertyWrite(), G4GDMLWriteSolids::PropertyWrite(), G4GDMLWriteStructure::ReplicavolWrite(), G4GDMLWriteSolids::ScaledWrite(), G4GDMLWriteSetup::SetupWrite(), G4GDMLWriteStructure::SkinSurfaceCache(), G4GDMLWriteSolids::SphereWrite(), G4GDMLWriteSolids::TessellatedWrite(), G4GDMLWriteSolids::TetWrite(), G4GDMLWriteSolids::TorusWrite(), G4GDMLWriteSolids::TrapWrite(), G4GDMLWriteStructure::TraverseVolumeTree(), G4GDMLWriteSolids::TrdWrite(), G4GDMLWriteSolids::TubeWrite(), G4GDMLWriteSolids::TwistedboxWrite(), G4GDMLWriteSolids::TwistedtrapWrite(), G4GDMLWriteSolids::TwistedtrdWrite(), G4GDMLWriteSolids::TwistedtubsWrite(), and G4GDMLWriteSolids::XtruWrite().

◆ MaterialsWrite()

virtual void G4GDMLWrite::MaterialsWrite ( xercesc::DOMElement * )
pure virtual

Implemented in G4GDMLWriteMaterials.

Referenced by Write().

◆ Modularize()

G4String G4GDMLWrite::Modularize ( const G4VPhysicalVolume *const topvol,
const G4int depth )
protected

Definition at line 380 of file G4GDMLWrite.cc.

382{
383 if(PvolumeMap().find(physvol) != PvolumeMap().cend())
384 {
385 return PvolumeMap()[physvol]; // Modularize via physvol
386 }
387
388 if(DepthMap().find(depth) != DepthMap().cend()) // Modularize via depth
389 {
390 std::stringstream stream;
391 stream << "depth" << depth << "_module" << DepthMap()[depth] << ".gdml";
392 DepthMap()[depth]++; // There can be more modules at this depth!
393 return G4String(stream.str());
394 }
395
396 return G4String(""); // Empty string for module name = no modularization
397 // was requested at that level/physvol!
398}

Referenced by G4GDMLWriteStructure::TraverseVolumeTree().

◆ NewAttribute() [1/2]

xercesc::DOMAttr * G4GDMLWrite::NewAttribute ( const G4String & name,
const G4double & value )
protected

Definition at line 174 of file G4GDMLWrite.cc.

176{
177 XMLCh* tempStr = NULL;
178 tempStr = xercesc::XMLString::transcode(name);
179 xercesc::DOMAttr* att = doc->createAttribute(tempStr);
180 xercesc::XMLString::release(&tempStr);
181
182 std::ostringstream ostream;
183 ostream.precision(15);
184 ostream << value;
185 G4String str = ostream.str();
186
187 tempStr = xercesc::XMLString::transcode(str);
188 att->setValue(tempStr);
189 xercesc::XMLString::release(&tempStr);
190
191 return att;
192}
xercesc::DOMDocument * doc

◆ NewAttribute() [2/2]

xercesc::DOMAttr * G4GDMLWrite::NewAttribute ( const G4String & name,
const G4String & value )
protected

Definition at line 158 of file G4GDMLWrite.cc.

160{
161 XMLCh* tempStr = NULL;
162 tempStr = xercesc::XMLString::transcode(name);
163 xercesc::DOMAttr* att = doc->createAttribute(tempStr);
164 xercesc::XMLString::release(&tempStr);
165
166 tempStr = xercesc::XMLString::transcode(value);
167 att->setValue(tempStr);
168 xercesc::XMLString::release(&tempStr);
169
170 return att;
171}

Referenced by AddAuxInfo(), G4GDMLWriteStructure::AssemblyWrite(), G4GDMLWriteMaterials::AtomWrite(), G4GDMLWriteSolids::BooleanWrite(), G4GDMLWriteStructure::BorderSurfaceCache(), G4GDMLWriteParamvol::Box_dimensionsWrite(), G4GDMLWriteSolids::BoxWrite(), G4GDMLWriteParamvol::Cone_dimensionsWrite(), G4GDMLWriteSolids::ConeWrite(), G4GDMLWriteSolids::CutTubeWrite(), G4GDMLWriteStructure::DivisionvolWrite(), G4GDMLWriteMaterials::DWrite(), G4GDMLWriteSolids::ElconeWrite(), G4GDMLWriteMaterials::ElementWrite(), G4GDMLWriteParamvol::Ellipsoid_dimensionsWrite(), G4GDMLWriteSolids::EllipsoidWrite(), G4GDMLWriteSolids::EltubeWrite(), G4GDMLWriteSolids::GenericPolyconeWrite(), G4GDMLWriteSolids::GenTrapWrite(), G4GDMLWriteParamvol::Hype_dimensionsWrite(), G4GDMLWriteSolids::HypeWrite(), G4GDMLWriteMaterials::IsotopeWrite(), G4GDMLWriteMaterials::MaterialWrite(), G4GDMLWriteMaterials::MEEWrite(), G4GDMLWriteSolids::MultiUnionWrite(), G4GDMLWriteSolids::OpticalSurfaceWrite(), G4GDMLWriteParamvol::Orb_dimensionsWrite(), G4GDMLWriteSolids::OrbWrite(), G4GDMLWriteParamvol::Para_dimensionsWrite(), G4GDMLWriteSolids::ParaboloidWrite(), G4GDMLWriteParamvol::ParametersWrite(), G4GDMLWriteParamvol::ParamvolWrite(), G4GDMLWriteSolids::ParaWrite(), G4GDMLWriteStructure::PhysvolWrite(), G4GDMLWriteParamvol::Polycone_dimensionsWrite(), G4GDMLWriteSolids::PolyconeWrite(), G4GDMLWriteParamvol::Polyhedra_dimensionsWrite(), G4GDMLWriteSolids::PolyhedraWrite(), G4GDMLWriteDefine::Position_vectorWrite(), G4GDMLWriteMaterials::PropertyConstWrite(), G4GDMLWriteMaterials::PropertyVectorWrite(), G4GDMLWriteMaterials::PropertyWrite(), G4GDMLWriteSolids::PropertyWrite(), G4GDMLWriteMaterials::PWrite(), G4GDMLWriteStructure::ReplicavolWrite(), G4GDMLWriteDefine::Rotation_vectorWrite(), G4GDMLWriteSolids::RZPointWrite(), G4GDMLWriteDefine::Scale_vectorWrite(), G4GDMLWriteSolids::ScaledWrite(), G4GDMLWriteSetup::SetupWrite(), G4GDMLWriteStructure::SkinSurfaceCache(), G4GDMLWriteParamvol::Sphere_dimensionsWrite(), G4GDMLWriteSolids::SphereWrite(), G4GDMLWriteSolids::TessellatedWrite(), G4GDMLWriteSolids::TetWrite(), G4GDMLWriteParamvol::Torus_dimensionsWrite(), G4GDMLWriteSolids::TorusWrite(), G4GDMLWriteParamvol::Trap_dimensionsWrite(), G4GDMLWriteSolids::TrapWrite(), G4GDMLWriteStructure::TraverseVolumeTree(), G4GDMLWriteParamvol::Trd_dimensionsWrite(), G4GDMLWriteSolids::TrdWrite(), G4GDMLWriteParamvol::Tube_dimensionsWrite(), G4GDMLWriteSolids::TubeWrite(), G4GDMLWriteSolids::TwistedboxWrite(), G4GDMLWriteSolids::TwistedtrapWrite(), G4GDMLWriteSolids::TwistedtrdWrite(), G4GDMLWriteSolids::TwistedtubsWrite(), G4GDMLWriteMaterials::TWrite(), Write(), G4GDMLWriteSolids::XtruWrite(), and G4GDMLWriteSolids::ZplaneWrite().

◆ NewElement()

xercesc::DOMElement * G4GDMLWrite::NewElement ( const G4String & name)
protected

Definition at line 195 of file G4GDMLWrite.cc.

196{
197 XMLCh* tempStr = NULL;
198 tempStr = xercesc::XMLString::transcode(name);
199 xercesc::DOMElement* elem = doc->createElement(tempStr);
200 xercesc::XMLString::release(&tempStr);
201
202 return elem;
203}
#define elem(i, j)

Referenced by AddAuxInfo(), G4GDMLWriteStructure::AssemblyWrite(), G4GDMLWriteMaterials::AtomWrite(), G4GDMLWriteSolids::BooleanWrite(), G4GDMLWriteStructure::BorderSurfaceCache(), G4GDMLWriteParamvol::Box_dimensionsWrite(), G4GDMLWriteSolids::BoxWrite(), G4GDMLWriteParamvol::Cone_dimensionsWrite(), G4GDMLWriteSolids::ConeWrite(), G4GDMLWriteSolids::CutTubeWrite(), G4GDMLWriteDefine::DefineWrite(), G4GDMLWriteStructure::DivisionvolWrite(), G4GDMLWriteMaterials::DWrite(), G4GDMLWriteSolids::ElconeWrite(), G4GDMLWriteMaterials::ElementWrite(), G4GDMLWriteParamvol::Ellipsoid_dimensionsWrite(), G4GDMLWriteSolids::EllipsoidWrite(), G4GDMLWriteSolids::EltubeWrite(), G4GDMLWriteSolids::GenericPolyconeWrite(), G4GDMLWriteSolids::GenTrapWrite(), G4GDMLWriteParamvol::Hype_dimensionsWrite(), G4GDMLWriteSolids::HypeWrite(), G4GDMLWriteMaterials::IsotopeWrite(), G4GDMLWriteMaterials::MaterialsWrite(), G4GDMLWriteMaterials::MaterialWrite(), G4GDMLWriteMaterials::MEEWrite(), G4GDMLWriteSolids::MultiUnionWrite(), G4GDMLWriteSolids::OpticalSurfaceWrite(), G4GDMLWriteParamvol::Orb_dimensionsWrite(), G4GDMLWriteSolids::OrbWrite(), G4GDMLWriteParamvol::Para_dimensionsWrite(), G4GDMLWriteSolids::ParaboloidWrite(), G4GDMLWriteParamvol::ParametersWrite(), G4GDMLWriteParamvol::ParamvolWrite(), G4GDMLWriteSolids::ParaWrite(), G4GDMLWriteStructure::PhysvolWrite(), G4GDMLWriteParamvol::Polycone_dimensionsWrite(), G4GDMLWriteSolids::PolyconeWrite(), G4GDMLWriteParamvol::Polyhedra_dimensionsWrite(), G4GDMLWriteSolids::PolyhedraWrite(), G4GDMLWriteDefine::Position_vectorWrite(), G4GDMLWriteMaterials::PropertyConstWrite(), G4GDMLWriteMaterials::PropertyVectorWrite(), G4GDMLWriteMaterials::PropertyWrite(), G4GDMLWriteSolids::PropertyWrite(), G4GDMLWriteMaterials::PWrite(), G4GDMLWriteStructure::ReplicavolWrite(), G4GDMLWriteDefine::Rotation_vectorWrite(), G4GDMLWriteSolids::RZPointWrite(), G4GDMLWriteDefine::Scale_vectorWrite(), G4GDMLWriteSolids::ScaledWrite(), G4GDMLWriteSetup::SetupWrite(), G4GDMLWriteStructure::SkinSurfaceCache(), G4GDMLWriteSolids::SolidsWrite(), G4GDMLWriteParamvol::Sphere_dimensionsWrite(), G4GDMLWriteSolids::SphereWrite(), G4GDMLWriteStructure::StructureWrite(), G4GDMLWriteSolids::TessellatedWrite(), G4GDMLWriteSolids::TetWrite(), G4GDMLWriteParamvol::Torus_dimensionsWrite(), G4GDMLWriteSolids::TorusWrite(), G4GDMLWriteParamvol::Trap_dimensionsWrite(), G4GDMLWriteSolids::TrapWrite(), G4GDMLWriteStructure::TraverseVolumeTree(), G4GDMLWriteParamvol::Trd_dimensionsWrite(), G4GDMLWriteSolids::TrdWrite(), G4GDMLWriteParamvol::Tube_dimensionsWrite(), G4GDMLWriteSolids::TubeWrite(), G4GDMLWriteSolids::TwistedboxWrite(), G4GDMLWriteSolids::TwistedtrapWrite(), G4GDMLWriteSolids::TwistedtrdWrite(), G4GDMLWriteSolids::TwistedtubsWrite(), G4GDMLWriteMaterials::TWrite(), UserinfoWrite(), G4GDMLWriteSolids::XtruWrite(), and G4GDMLWriteSolids::ZplaneWrite().

◆ PvolumeMap()

G4GDMLWrite::PhysVolumeMapType & G4GDMLWrite::PvolumeMap ( )
protected

Definition at line 66 of file G4GDMLWrite.cc.

67{
68 static PhysVolumeMapType instance;
69 return instance;
70}

Referenced by AddModule(), and Modularize().

◆ SetAddPointerToName()

void G4GDMLWrite::SetAddPointerToName ( G4bool set)
static

Definition at line 413 of file G4GDMLWrite.cc.

414{
415 addPointerToName = set;
416}

◆ SetOutputFileOverwrite()

void G4GDMLWrite::SetOutputFileOverwrite ( G4bool flag)

Definition at line 407 of file G4GDMLWrite.cc.

408{
409 overwriteOutputFile = flag;
410}
G4bool overwriteOutputFile

◆ SetupWrite()

virtual void G4GDMLWrite::SetupWrite ( xercesc::DOMElement * ,
const G4LogicalVolume * const  )
pure virtual

Implemented in G4GDMLWriteSetup.

Referenced by Write().

◆ SolidsWrite()

virtual void G4GDMLWrite::SolidsWrite ( xercesc::DOMElement * )
pure virtual

Implemented in G4GDMLWriteSolids.

Referenced by Write().

◆ StructureWrite()

virtual void G4GDMLWrite::StructureWrite ( xercesc::DOMElement * )
pure virtual

Implemented in G4GDMLWriteStructure.

Referenced by Write().

◆ SurfacesWrite()

virtual void G4GDMLWrite::SurfacesWrite ( )
pure virtual

Implemented in G4GDMLWriteStructure.

Referenced by Write().

◆ TraverseVolumeTree()

virtual G4Transform3D G4GDMLWrite::TraverseVolumeTree ( const G4LogicalVolume * const ,
const G4int  )
pure virtual

Implemented in G4GDMLWriteStructure.

Referenced by Write().

◆ UserinfoWrite()

void G4GDMLWrite::UserinfoWrite ( xercesc::DOMElement * gdmlElement)
virtual

Definition at line 118 of file G4GDMLWrite.cc.

119{
120 if(auxList.size() > 0)
121 {
122#ifdef G4VERBOSE
123 G4cout << "G4GDML: Writing userinfo..." << G4endl;
124#endif
125 userinfoElement = NewElement("userinfo");
126 gdmlElement->appendChild(userinfoElement);
128 }
129}
xercesc::DOMElement * userinfoElement

Referenced by Write().

◆ VolumeMap()

G4GDMLWrite::VolumeMapType & G4GDMLWrite::VolumeMap ( )
protected

Definition at line 60 of file G4GDMLWrite.cc.

61{
62 static VolumeMapType instance;
63 return instance;
64}

Referenced by G4GDMLWriteStructure::TraverseVolumeTree(), and Write().

◆ Write()

G4Transform3D G4GDMLWrite::Write ( const G4String & filename,
const G4LogicalVolume *const topLog,
const G4String & schemaPath,
const G4int depth,
G4bool storeReferences = true )

Definition at line 206 of file G4GDMLWrite.cc.

210{
211 SchemaLocation = setSchemaLocation;
212 addPointerToName = refs;
213#ifdef G4VERBOSE
214 if(depth == 0)
215 {
216 G4cout << "G4GDML: Writing '" << fname << "'..." << G4endl;
217 }
218 else
219 {
220 G4cout << "G4GDML: Writing module '" << fname << "'..." << G4endl;
221 }
222#endif
223 if(!overwriteOutputFile && FileExists(fname))
224 {
225 G4String ErrorMessage = "File '" + fname + "' already exists!";
226 G4Exception("G4GDMLWrite::Write()", "InvalidSetup", FatalException,
227 ErrorMessage);
228 }
229
230 VolumeMap().clear(); // The module map is global for all modules,
231 // so clear it only at once!
232
233 XMLCh* tempStr = NULL;
234 tempStr = xercesc::XMLString::transcode("LS");
235 xercesc::DOMImplementationRegistry::getDOMImplementation(tempStr);
236 xercesc::XMLString::release(&tempStr);
237 tempStr = xercesc::XMLString::transcode("Range");
238 xercesc::DOMImplementation* impl =
239 xercesc::DOMImplementationRegistry::getDOMImplementation(tempStr);
240 xercesc::XMLString::release(&tempStr);
241 tempStr = xercesc::XMLString::transcode("gdml");
242 doc = impl->createDocument(0, tempStr, 0);
243 xercesc::XMLString::release(&tempStr);
244 xercesc::DOMElement* gdml = doc->getDocumentElement();
245
246#if XERCES_VERSION_MAJOR >= 3
247 // DOM L3 as per Xerces 3.0 API
248 xercesc::DOMLSSerializer* writer =
249 ((xercesc::DOMImplementationLS*) impl)->createLSSerializer();
250
251 xercesc::DOMConfiguration* dc = writer->getDomConfig();
252 dc->setParameter(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint, true);
253
254#else
255
256 xercesc::DOMWriter* writer =
257 ((xercesc::DOMImplementationLS*) impl)->createDOMWriter();
258
259 if(writer->canSetFeature(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint, true))
260 writer->setFeature(xercesc::XMLUni::fgDOMWRTFormatPrettyPrint, true);
261
262#endif
263
264 gdml->setAttributeNode(
265 NewAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"));
266 gdml->setAttributeNode(
267 NewAttribute("xsi:noNamespaceSchemaLocation", SchemaLocation));
268
269 ExtensionWrite(gdml);
270 DefineWrite(gdml);
271 MaterialsWrite(gdml);
272 SolidsWrite(gdml);
273 StructureWrite(gdml);
274 UserinfoWrite(gdml);
275 SetupWrite(gdml, logvol);
276
277 G4Transform3D R = TraverseVolumeTree(logvol, depth);
278
280 xercesc::XMLFormatTarget* myFormTarget =
281 new xercesc::LocalFileFormatTarget(fname.c_str());
282
283 try
284 {
285#if XERCES_VERSION_MAJOR >= 3
286 // DOM L3 as per Xerces 3.0 API
287 xercesc::DOMLSOutput* theOutput =
288 ((xercesc::DOMImplementationLS*) impl)->createLSOutput();
289 theOutput->setByteStream(myFormTarget);
290 writer->write(doc, theOutput);
291#else
292 writer->writeNode(myFormTarget, *doc);
293#endif
294 } catch(const xercesc::XMLException& toCatch)
295 {
296 char* message = xercesc::XMLString::transcode(toCatch.getMessage());
297 G4cout << "G4GDML: Exception message is: " << message << G4endl;
298 xercesc::XMLString::release(&message);
300 } catch(const xercesc::DOMException& toCatch)
301 {
302 char* message = xercesc::XMLString::transcode(toCatch.msg);
303 G4cout << "G4GDML: Exception message is: " << message << G4endl;
304 xercesc::XMLString::release(&message);
306 } catch(...)
307 {
308 G4cout << "G4GDML: Unexpected Exception!" << G4endl;
310 }
311
312 delete myFormTarget;
313 writer->release();
314
315 if(depth == 0)
316 {
317 G4cout << "G4GDML: Writing '" << fname << "' done !" << G4endl;
318 }
319 else
320 {
321#ifdef G4VERBOSE
322 G4cout << "G4GDML: Writing module '" << fname << "' done !" << G4endl;
323#endif
324 }
325
326 return R;
327}
HepGeom::Transform3D G4Transform3D
virtual void SurfacesWrite()=0
virtual void MaterialsWrite(xercesc::DOMElement *)=0
G4bool FileExists(const G4String &) const
G4String SchemaLocation
virtual void SetupWrite(xercesc::DOMElement *, const G4LogicalVolume *const)=0
virtual G4Transform3D TraverseVolumeTree(const G4LogicalVolume *const, const G4int)=0
virtual void DefineWrite(xercesc::DOMElement *)=0
virtual void UserinfoWrite(xercesc::DOMElement *)
virtual void ExtensionWrite(xercesc::DOMElement *)
virtual void SolidsWrite(xercesc::DOMElement *)=0
VolumeMapType & VolumeMap()
virtual void StructureWrite(xercesc::DOMElement *)=0
static DLL_API const Transform3D Identity

Member Data Documentation

◆ addPointerToName

G4bool G4GDMLWrite::addPointerToName = true
staticprotected

Definition at line 131 of file G4GDMLWrite.hh.

Referenced by GenerateName(), SetAddPointerToName(), and Write().

◆ auxList

G4GDMLAuxListType G4GDMLWrite::auxList
protected

Definition at line 136 of file G4GDMLWrite.hh.

Referenced by AddAuxiliary(), and UserinfoWrite().

◆ doc

xercesc::DOMDocument* G4GDMLWrite::doc = nullptr
protected

Definition at line 132 of file G4GDMLWrite.hh.

Referenced by NewAttribute(), NewAttribute(), NewElement(), and Write().

◆ extElement

xercesc::DOMElement* G4GDMLWrite::extElement = nullptr
protected

Definition at line 133 of file G4GDMLWrite.hh.

◆ overwriteOutputFile

G4bool G4GDMLWrite::overwriteOutputFile = false
protected

Definition at line 137 of file G4GDMLWrite.hh.

Referenced by SetOutputFileOverwrite(), and Write().

◆ SchemaLocation

G4String G4GDMLWrite::SchemaLocation
protected

Definition at line 130 of file G4GDMLWrite.hh.

Referenced by G4GDMLWriteStructure::TraverseVolumeTree(), and Write().

◆ userinfoElement

xercesc::DOMElement* G4GDMLWrite::userinfoElement = nullptr
protected

Definition at line 134 of file G4GDMLWrite.hh.

Referenced by UserinfoWrite().


The documentation for this class was generated from the following files: