67 const xercesc::DOMNamedNodeMap*
const attributes
68 = bordersurfaceElement->getAttributes();
69 XMLSize_t attributeCount = attributes->getLength();
71 for (XMLSize_t attribute_index=0;
72 attribute_index<attributeCount; attribute_index++)
74 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
76 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
79 const xercesc::DOMAttr*
const attribute
80 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
83 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
92 if (attName==
"surfaceproperty")
96 for (xercesc::DOMNode* iter = bordersurfaceElement->getFirstChild();
97 iter != 0; iter = iter->getNextSibling())
99 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
101 const xercesc::DOMElement*
const child
102 =
dynamic_cast<xercesc::DOMElement*
>(iter);
105 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
111 if (tag !=
"physvolref") {
continue; }
134 const xercesc::DOMNamedNodeMap*
const attributes
135 = divisionvolElement->getAttributes();
136 XMLSize_t attributeCount = attributes->getLength();
139 for (XMLSize_t attribute_index=0;
140 attribute_index<attributeCount; attribute_index++)
142 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
144 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
147 const xercesc::DOMAttr*
const attribute
148 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
151 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
158 if (attName==
"name") { name = attValue; }
else
162 if (attName==
"width") { width =
eval.
Evaluate(attValue); }
else
163 if (attName==
"offset") { offset =
eval.
Evaluate(attValue); }
else
167 if (attValue==
"kXAxis") { axis =
kXAxis; }
else
168 if (attValue==
"kYAxis") { axis =
kYAxis; }
else
169 if (attValue==
"kZAxis") { axis =
kZAxis; }
else
170 if (attValue==
"kRho") { axis =
kRho; }
else
171 if (attValue==
"kPhi") { axis =
kPhi; }
176 ((axis ==
kRho || axis ==
kPhi) && unitname!=
"Angle")) {
177 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead",
183 for (xercesc::DOMNode* iter = divisionvolElement->getFirstChild();
184 iter != 0;iter = iter->getNextSibling())
186 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
188 const xercesc::DOMElement*
const child
189 =
dynamic_cast<xercesc::DOMElement*
>(iter);
192 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
201 if (!logvol) {
return; }
207 if ((number != 0) && (width == 0.0))
212 else if ((number == 0) && (width != 0.0))
228 FileRead(
const xercesc::DOMElement*
const fileElement)
233 const xercesc::DOMNamedNodeMap*
const attributes
234 = fileElement->getAttributes();
235 XMLSize_t attributeCount = attributes->getLength();
237 for (XMLSize_t attribute_index=0;
238 attribute_index<attributeCount; attribute_index++)
240 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
242 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
245 const xercesc::DOMAttr*
const attribute
246 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
256 if (attName==
"name") { name = attValue; }
else
257 if (attName==
"volname") { volname = attValue; }
260 const G4bool isModule =
true;
269 G4GDMLAuxMapType::const_iterator
pos;
270 for (pos = aux->begin(); pos != aux->end(); ++
pos)
272 auxMap.insert(std::make_pair(pos->first,pos->second));
298 G4int copynumber = 0;
300 const xercesc::DOMNamedNodeMap*
const attributes
301 = physvolElement->getAttributes();
302 XMLSize_t attributeCount = attributes->getLength();
304 for (XMLSize_t attribute_index=0;
305 attribute_index<attributeCount; attribute_index++)
307 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
309 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
312 const xercesc::DOMAttr*
const attribute
313 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
323 if (attName==
"name") { name = attValue; }
327 for (xercesc::DOMNode* iter = physvolElement->getFirstChild();
328 iter != 0; iter = iter->getNextSibling())
330 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
332 const xercesc::DOMElement*
const child
333 =
dynamic_cast<xercesc::DOMElement*
>(iter);
342 if (tag==
"volumeref")
346 if (!assembly) { logvol =
GetVolume(child_name); }
348 else if (tag==
"file")
350 else if (tag==
"position")
352 else if (tag==
"rotation")
354 else if (tag==
"scale")
356 else if (tag==
"positionref")
358 else if (tag==
"rotationref")
360 else if (tag==
"scaleref")
364 G4String error_msg =
"Unknown tag in physvol: " + tag;
365 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"ReadError",
372 transform = transform*
G4Scale3D(scale.
x(),scale.
y(),scale.
z());
380 if (!logvol) {
return; }
391 if (!logvol) {
return; }
406 for (xercesc::DOMNode* iter = replicavolElement->getFirstChild();
407 iter != 0; iter = iter->getNextSibling())
409 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
411 const xercesc::DOMElement*
const child
412 =
dynamic_cast<xercesc::DOMElement*
>(iter);
415 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
421 if (tag==
"volumeref")
425 else if (tag==
"replicate_along_axis")
431 G4String error_msg =
"Unknown tag in ReplicavolRead: " + tag;
432 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
449 for (xercesc::DOMNode* iter = replicaElement->getFirstChild();
450 iter != 0; iter = iter->getNextSibling())
452 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
454 const xercesc::DOMElement*
const child
455 =
dynamic_cast<xercesc::DOMElement*
>(iter);
468 if (tag==
"positionref")
470 if (tag==
"rotationref")
472 if (tag==
"direction")
480 G4String error_msg =
"Unknown tag in ReplicaRead: " + tag;
481 G4Exception(
"G4GDMLReadStructure::ReplicaRead()",
"ReadError",
496 AxisRead(
const xercesc::DOMElement*
const axisElement)
500 const xercesc::DOMNamedNodeMap*
const attributes
501 = axisElement->getAttributes();
502 XMLSize_t attributeCount = attributes->getLength();
504 for (XMLSize_t attribute_index=0;
505 attribute_index<attributeCount; attribute_index++)
507 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
509 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
512 const xercesc::DOMAttr*
const attribute
513 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
524 else if (attName==
"y")
526 else if (attName==
"z")
528 else if (attName==
"rho")
530 else if (attName==
"phi")
542 const xercesc::DOMNamedNodeMap*
const attributes
543 = readElement->getAttributes();
544 XMLSize_t attributeCount = attributes->getLength();
546 for (XMLSize_t attribute_index=0;
547 attribute_index<attributeCount; attribute_index++)
549 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
551 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
553 const xercesc::DOMAttr*
const attribute
554 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
566 G4Exception(
"G4GDMLReadStructure::QuantityRead()",
"InvalidRead",
567 FatalException,
"Invalid unit for lenght or angle (width, offset)!"); }
569 if (attName==
"value"){ value=
eval.
Evaluate(attValue); }
582 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
584 xercesc::XMLString::release(&name_attr);
586 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
587 iter != 0; iter = iter->getNextSibling())
589 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
591 const xercesc::DOMElement*
const child
592 =
dynamic_cast<xercesc::DOMElement*
>(iter);
601 if (tag==
"auxiliary")
603 if (tag==
"materialref")
620 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
622 xercesc::XMLString::release(&name_attr);
627 for (xercesc::DOMNode* iter = assemblyElement->getFirstChild();
628 iter != 0; iter = iter->getNextSibling())
630 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
631 const xercesc::DOMElement*
const child
632 =
dynamic_cast<xercesc::DOMElement*
>(iter);
647 G4cout <<
"Unsupported GDML tag '" << tag
648 <<
"' for Geant4 assembly structure !" <<
G4endl;
660 const xercesc::DOMNamedNodeMap*
const attributes
661 = skinsurfaceElement->getAttributes();
662 XMLSize_t attributeCount = attributes->getLength();
664 for (XMLSize_t attribute_index=0;
665 attribute_index<attributeCount; attribute_index++)
667 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
669 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
672 const xercesc::DOMAttr*
const attribute
673 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
676 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
685 if (attName==
"surfaceproperty")
689 for (xercesc::DOMNode* iter = skinsurfaceElement->getFirstChild();
690 iter != 0; iter = iter->getNextSibling())
692 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
694 const xercesc::DOMElement*
const child
695 =
dynamic_cast<xercesc::DOMElement*
>(iter);
698 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
704 if (tag==
"volumeref")
710 G4String error_msg =
"Unknown tag in skinsurface: " + tag;
711 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"ReadError",
722 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
723 iter != 0; iter = iter->getNextSibling())
725 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
727 const xercesc::DOMElement*
const child
728 =
dynamic_cast<xercesc::DOMElement*
>(iter);
731 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
737 if ((tag==
"auxiliary") || (tag==
"materialref") || (tag==
"solidref"))
741 else if (tag==
"paramvol")
745 else if (tag==
"physvol")
749 else if (tag==
"replicavol")
752 const xercesc::DOMNamedNodeMap*
const attributes
753 = child->getAttributes();
754 XMLSize_t attributeCount = attributes->getLength();
755 for (XMLSize_t attribute_index=0;
756 attribute_index<attributeCount; attribute_index++)
758 xercesc::DOMNode* attribute_node
759 = attributes->item(attribute_index);
760 if (attribute_node->getNodeType()!=xercesc::DOMNode::ATTRIBUTE_NODE)
764 const xercesc::DOMAttr*
const attribute
765 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
768 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
774 if (attName==
"number")
781 else if (tag==
"divisionvol")
785 else if (tag==
"loop")
791 G4cout <<
"Treating unknown GDML tag in volume '" << tag
792 <<
"' as GDML extension..." <<
G4endl;
803 for (xercesc::DOMNode* iter = structureElement->getFirstChild();
804 iter != 0; iter = iter->getNextSibling())
806 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
808 const xercesc::DOMElement*
const child
809 =
dynamic_cast<xercesc::DOMElement*
>(iter);
812 G4Exception(
"G4GDMLReadStructure::StructureRead()",
820 if (tag==
"volume") {
VolumeRead(child); }
else
825 G4String error_msg =
"Unknown tag in structure: " + tag;
826 G4Exception(
"G4GDMLReadStructure::StructureRead()",
840 G4String error_msg =
"Referenced physvol '" + ref +
"' was not found!";
841 G4Exception(
"G4GDMLReadStructure::GetPhysvol()",
"ReadError",
856 G4String error_msg =
"Referenced volume '" + ref +
"' was not found!";
857 G4Exception(
"G4GDMLReadStructure::GetVolume()",
"ReadError",
867 G4GDMLAssemblyMapType::const_iterator
pos =
assemblyMap.find(ref);
868 if (pos !=
assemblyMap.end()) {
return pos->second; }
875 G4GDMLAuxMapType::const_iterator
pos =
auxMap.find(logvol);
876 if (pos !=
auxMap.end()) {
return pos->second; }
884 if (sname ==
"") {
return 0; }
898 volume->
GetName()+
"_PV",0,0,0);