Geant4-11
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Types
G4GDMLWrite Class Referenceabstract

#include <G4GDMLWrite.hh>

Inheritance diagram for G4GDMLWrite:
G4GDMLWriteDefine G4GDMLWriteMaterials G4GDMLWriteSolids G4GDMLWriteSetup G4GDMLWriteParamvol G4GDMLWriteStructure

Public Member Functions

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

Static Public Member Functions

static void SetAddPointerToName (G4bool)
 

Protected Member Functions

void AddAuxInfo (G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
 
DepthMapTypeDepthMap ()
 
G4bool FileExists (const G4String &) const
 
 G4GDMLWrite ()
 
G4String Modularize (const G4VPhysicalVolume *const topvol, const G4int depth)
 
xercesc::DOMAttr * NewAttribute (const G4String &, const G4double &)
 
xercesc::DOMAttr * NewAttribute (const G4String &, const G4String &)
 
xercesc::DOMElement * NewElement (const G4String &)
 
PhysVolumeMapTypePvolumeMap ()
 
VolumeMapTypeVolumeMap ()
 
virtual ~G4GDMLWrite ()
 

Protected Attributes

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

Static Protected Attributes

static G4bool addPointerToName = true
 

Private Types

using DepthMapType = std::map< G4int, G4int >
 
using PhysVolumeMapType = std::map< const G4VPhysicalVolume *, G4String >
 
using VolumeMapType = std::map< const G4LogicalVolume *, G4Transform3D >
 

Detailed Description

Definition at line 51 of file G4GDMLWrite.hh.

Member Typedef Documentation

◆ DepthMapType

using G4GDMLWrite::DepthMapType = std::map<G4int, G4int>
private

Definition at line 55 of file G4GDMLWrite.hh.

◆ PhysVolumeMapType

using G4GDMLWrite::PhysVolumeMapType = std::map<const G4VPhysicalVolume*, G4String>
private

Definition at line 54 of file G4GDMLWrite.hh.

◆ VolumeMapType

using G4GDMLWrite::VolumeMapType = std::map<const G4LogicalVolume*, G4Transform3D>
private

Definition at line 53 of file G4GDMLWrite.hh.

Constructor & Destructor Documentation

◆ G4GDMLWrite()

G4GDMLWrite::G4GDMLWrite ( )
protected

Definition at line 43 of file G4GDMLWrite.cc.

44{
45}

◆ ~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 398 of file G4GDMLWrite.cc.

399{
400 auxList.push_back(myaux);
401}
G4GDMLAuxListType auxList
Definition: G4GDMLWrite.hh:136

References 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 &)
Definition: G4GDMLWrite.cc:192
xercesc::DOMAttr * NewAttribute(const G4String &, const G4String &)
Definition: G4GDMLWrite.cc:155
void AddAuxInfo(G4GDMLAuxListType *auxInfoList, xercesc::DOMElement *element)
Definition: G4GDMLWrite.cc:94

References AddAuxInfo(), NewAttribute(), and NewElement().

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 361 of file G4GDMLWrite.cc.

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

References DepthMap(), FatalException, and G4Exception().

◆ AddModule() [2/2]

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

Definition at line 327 of file G4GDMLWrite.cc.

328{
329 G4String fname = GenerateName(physvol->GetName(), physvol);
330 G4cout << "G4GDML: Adding module '" << fname << "'..." << G4endl;
331
332 if(physvol == nullptr)
333 {
334 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
335 "Invalid NULL pointer is specified for modularization!");
336 return;
337 }
338 if(dynamic_cast<const G4PVDivision*>(physvol))
339 {
340 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
341 "It is not possible to modularize by divisionvol!");
342 return;
343 }
344 if(physvol->IsParameterised())
345 {
346 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
347 "It is not possible to modularize by parameterised volume!");
348 return;
349 }
350 if(physvol->IsReplicated())
351 {
352 G4Exception("G4GDMLWrite::AddModule()", "InvalidSetup", FatalException,
353 "It is not possible to modularize by replicated volume!");
354 return;
355 }
356
357 PvolumeMap()[physvol] = fname;
358}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4String GenerateName(const G4String &, const void *const)
Definition: G4GDMLWrite.cc:132
PhysVolumeMapType & PvolumeMap()
Definition: G4GDMLWrite.cc:66
string fname
Definition: test.py:308

References FatalException, test::fname, G4cout, G4endl, G4Exception(), GenerateName(), G4VPhysicalVolume::GetName(), G4VPhysicalVolume::IsParameterised(), G4VPhysicalVolume::IsReplicated(), and 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}
std::map< G4int, G4int > DepthMapType
Definition: G4GDMLWrite.hh:55

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}

References test::fname.

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 stream << ptr;
140 };
141
142 nameOut = G4String(stream.str());
143 std::vector<char> toremove = { ' ', '/', ':', '#', '+' };
144 for(auto c : toremove)
145 {
146 if(G4StrUtil::contains(nameOut, c))
147 {
148 std::replace(nameOut.begin(), nameOut.end(), c, '_');
149 }
150 }
151 return nameOut;
152}
static G4bool addPointerToName
Definition: G4GDMLWrite.hh:131
const char * name(G4int ptype)
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.

References addPointerToName, G4StrUtil::contains(), and G4InuclParticleNames::name().

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(), G4GDMLParser::ExportRegions(), 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 377 of file G4GDMLWrite.cc.

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

References DepthMap(), and PvolumeMap().

Referenced by G4GDMLWriteStructure::TraverseVolumeTree().

◆ NewAttribute() [1/2]

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

Definition at line 171 of file G4GDMLWrite.cc.

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

References doc, and G4InuclParticleNames::name().

◆ NewAttribute() [2/2]

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

Definition at line 155 of file G4GDMLWrite.cc.

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

References doc, and G4InuclParticleNames::name().

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 192 of file G4GDMLWrite.cc.

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

References doc, elem, and G4InuclParticleNames::name().

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}
std::map< const G4VPhysicalVolume *, G4String > PhysVolumeMapType
Definition: G4GDMLWrite.hh:54

Referenced by AddModule(), and Modularize().

◆ SetAddPointerToName()

void G4GDMLWrite::SetAddPointerToName ( G4bool  set)
static

Definition at line 410 of file G4GDMLWrite.cc.

411{
412 addPointerToName = set;
413}

References addPointerToName.

◆ SetOutputFileOverwrite()

void G4GDMLWrite::SetOutputFileOverwrite ( G4bool  flag)

Definition at line 404 of file G4GDMLWrite.cc.

405{
406 overwriteOutputFile = flag;
407}
G4bool overwriteOutputFile
Definition: G4GDMLWrite.hh:137

References 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
Definition: G4GDMLWrite.hh:134

References AddAuxInfo(), auxList, G4cout, G4endl, NewElement(), and 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}
std::map< const G4LogicalVolume *, G4Transform3D > VolumeMapType
Definition: G4GDMLWrite.hh:53

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 203 of file G4GDMLWrite.cc.

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

References addPointerToName, DefineWrite(), doc, ExtensionWrite(), FatalException, FileExists(), test::fname, G4cout, G4endl, G4Exception(), HepGeom::Transform3D::Identity, MaterialsWrite(), NewAttribute(), overwriteOutputFile, SchemaLocation, SetupWrite(), SolidsWrite(), StructureWrite(), SurfacesWrite(), TraverseVolumeTree(), UserinfoWrite(), and VolumeMap().

Referenced by G4GDMLWriteStructure::TraverseVolumeTree().

Field 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(), 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: