68 const xercesc::DOMNamedNodeMap*
const attributes
69 = bordersurfaceElement->getAttributes();
70 XMLSize_t attributeCount = attributes->getLength();
72 for (XMLSize_t attribute_index=0;
73 attribute_index<attributeCount; attribute_index++)
75 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
77 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
80 const xercesc::DOMAttr*
const attribute
81 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
84 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
93 if (attName==
"surfaceproperty")
97 for (xercesc::DOMNode* iter = bordersurfaceElement->getFirstChild();
98 iter != 0; iter = iter->getNextSibling())
100 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
102 const xercesc::DOMElement*
const child
103 =
dynamic_cast<xercesc::DOMElement*
>(iter);
106 G4Exception(
"G4GDMLReadStructure::BorderSurfaceRead()",
112 if (tag !=
"physvolref") {
continue; }
135 const xercesc::DOMNamedNodeMap*
const attributes
136 = divisionvolElement->getAttributes();
137 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
160 if (attName==
"width") { width =
eval.
Evaluate(attValue); }
else
161 if (attName==
"offset") { offset =
eval.
Evaluate(attValue); }
else
165 if (attValue==
"kXAxis") { axis =
kXAxis; }
else
166 if (attValue==
"kYAxis") { axis =
kYAxis; }
else
167 if (attValue==
"kZAxis") { axis =
kZAxis; }
else
168 if (attValue==
"kRho") { axis =
kRho; }
else
169 if (attValue==
"kPhi") { axis =
kPhi; }
176 for (xercesc::DOMNode* iter = divisionvolElement->getFirstChild();
177 iter != 0;iter = iter->getNextSibling())
179 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
181 const xercesc::DOMElement*
const child
182 =
dynamic_cast<xercesc::DOMElement*
>(iter);
185 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
194 if (!logvol) {
return; }
200 if ((number != 0) && (width == 0.0))
205 else if ((number == 0) && (width != 0.0))
221 FileRead(
const xercesc::DOMElement*
const fileElement)
226 const xercesc::DOMNamedNodeMap*
const attributes
227 = fileElement->getAttributes();
228 XMLSize_t attributeCount = attributes->getLength();
230 for (XMLSize_t attribute_index=0;
231 attribute_index<attributeCount; attribute_index++)
233 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
235 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
238 const xercesc::DOMAttr*
const attribute
239 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
249 if (attName==
"name") { name = attValue; }
else
250 if (attName==
"volname") { volname = attValue; }
253 const G4bool isModule =
true;
262 G4GDMLAuxMapType::const_iterator
pos;
263 for (pos = aux->begin(); pos != aux->end(); ++
pos)
265 auxMap.insert(std::make_pair(pos->first,pos->second));
291 G4int copynumber = 0;
293 const xercesc::DOMNamedNodeMap*
const attributes
294 = physvolElement->getAttributes();
295 XMLSize_t attributeCount = attributes->getLength();
297 for (XMLSize_t attribute_index=0;
298 attribute_index<attributeCount; attribute_index++)
300 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
302 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
305 const xercesc::DOMAttr*
const attribute
306 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
316 if (attName==
"name") { name = attValue; }
320 for (xercesc::DOMNode* iter = physvolElement->getFirstChild();
321 iter != 0; iter = iter->getNextSibling())
323 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
325 const xercesc::DOMElement*
const child
326 =
dynamic_cast<xercesc::DOMElement*
>(iter);
335 if (tag==
"volumeref")
339 if (!assembly) { logvol =
GetVolume(child_name); }
341 else if (tag==
"file")
343 else if (tag==
"position")
345 else if (tag==
"rotation")
347 else if (tag==
"scale")
349 else if (tag==
"positionref")
351 else if (tag==
"rotationref")
353 else if (tag==
"scaleref")
357 G4String error_msg =
"Unknown tag in physvol: " + tag;
358 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"ReadError",
365 transform = transform*
G4Scale3D(scale.x(),scale.y(),scale.z());
369 if (!logvol) {
return; }
380 if (!logvol) {
return; }
395 for (xercesc::DOMNode* iter = replicavolElement->getFirstChild();
396 iter != 0; iter = iter->getNextSibling())
398 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
400 const xercesc::DOMElement*
const child
401 =
dynamic_cast<xercesc::DOMElement*
>(iter);
404 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
410 if (tag==
"volumeref")
414 else if (tag==
"replicate_along_axis")
420 G4String error_msg =
"Unknown tag in ReplicavolRead: " + tag;
421 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
438 for (xercesc::DOMNode* iter = replicaElement->getFirstChild();
439 iter != 0; iter = iter->getNextSibling())
441 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
443 const xercesc::DOMElement*
const child
444 =
dynamic_cast<xercesc::DOMElement*
>(iter);
457 if (tag==
"positionref")
459 if (tag==
"rotationref")
461 if (tag==
"direction")
469 G4String error_msg =
"Unknown tag in ReplicaRead: " + tag;
470 G4Exception(
"G4GDMLReadStructure::ReplicaRead()",
"ReadError",
485 AxisRead(
const xercesc::DOMElement*
const axisElement)
489 const xercesc::DOMNamedNodeMap*
const attributes
490 = axisElement->getAttributes();
491 XMLSize_t attributeCount = attributes->getLength();
493 for (XMLSize_t attribute_index=0;
494 attribute_index<attributeCount; attribute_index++)
496 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
498 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
501 const xercesc::DOMAttr*
const attribute
502 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
513 else if (attName==
"y")
515 else if (attName==
"z")
517 else if (attName==
"rho")
519 else if (attName==
"phi")
531 const xercesc::DOMNamedNodeMap*
const attributes
532 = readElement->getAttributes();
533 XMLSize_t attributeCount = attributes->getLength();
535 for (XMLSize_t attribute_index=0;
536 attribute_index<attributeCount; attribute_index++)
538 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
540 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
542 const xercesc::DOMAttr*
const attribute
543 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
554 if (attName==
"value"){ value=
eval.
Evaluate(attValue); }
567 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
569 xercesc::XMLString::release(&name_attr);
571 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
572 iter != 0; iter = iter->getNextSibling())
574 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
576 const xercesc::DOMElement*
const child
577 =
dynamic_cast<xercesc::DOMElement*
>(iter);
586 if (tag==
"auxiliary")
588 if (tag==
"materialref")
605 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
607 xercesc::XMLString::release(&name_attr);
612 for (xercesc::DOMNode* iter = assemblyElement->getFirstChild();
613 iter != 0; iter = iter->getNextSibling())
615 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
616 const xercesc::DOMElement*
const child
617 =
dynamic_cast<xercesc::DOMElement*
>(iter);
632 G4cout <<
"Unsupported GDML tag '" << tag
633 <<
"' for Geant4 assembly structure !" <<
G4endl;
645 const xercesc::DOMNamedNodeMap*
const attributes
646 = skinsurfaceElement->getAttributes();
647 XMLSize_t attributeCount = attributes->getLength();
649 for (XMLSize_t attribute_index=0;
650 attribute_index<attributeCount; attribute_index++)
652 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
654 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
657 const xercesc::DOMAttr*
const attribute
658 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
661 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
670 if (attName==
"surfaceproperty")
674 for (xercesc::DOMNode* iter = skinsurfaceElement->getFirstChild();
675 iter != 0; iter = iter->getNextSibling())
677 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
679 const xercesc::DOMElement*
const child
680 =
dynamic_cast<xercesc::DOMElement*
>(iter);
683 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
689 if (tag==
"volumeref")
695 G4String error_msg =
"Unknown tag in skinsurface: " + tag;
696 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"ReadError",
707 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
708 iter != 0; iter = iter->getNextSibling())
710 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
712 const xercesc::DOMElement*
const child
713 =
dynamic_cast<xercesc::DOMElement*
>(iter);
716 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
722 if ((tag==
"auxiliary") || (tag==
"materialref") || (tag==
"solidref"))
726 else if (tag==
"paramvol")
730 else if (tag==
"physvol")
734 else if (tag==
"replicavol")
737 const xercesc::DOMNamedNodeMap*
const attributes
738 = child->getAttributes();
739 XMLSize_t attributeCount = attributes->getLength();
740 for (XMLSize_t attribute_index=0;
741 attribute_index<attributeCount; attribute_index++)
743 xercesc::DOMNode* attribute_node
744 = attributes->item(attribute_index);
745 if (attribute_node->getNodeType()!=xercesc::DOMNode::ATTRIBUTE_NODE)
749 const xercesc::DOMAttr*
const attribute
750 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
753 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
759 if (attName==
"number")
766 else if (tag==
"divisionvol")
770 else if (tag==
"loop")
776 G4cout <<
"Treating unknown GDML tag in volume '" << tag
777 <<
"' as GDML extension..." <<
G4endl;
787 for (xercesc::DOMNode* iter = structureElement->getFirstChild();
788 iter != 0; iter = iter->getNextSibling())
790 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
792 const xercesc::DOMElement*
const child
793 =
dynamic_cast<xercesc::DOMElement*
>(iter);
796 G4Exception(
"G4GDMLReadStructure::StructureRead()",
804 if (tag==
"volume") {
VolumeRead(child); }
else
809 G4String error_msg =
"Unknown tag in structure: " + tag;
810 G4Exception(
"G4GDMLReadStructure::StructureRead()",
824 G4String error_msg =
"Referenced physvol '" + ref +
"' was not found!";
825 G4Exception(
"G4GDMLReadStructure::GetPhysvol()",
"ReadError",
840 G4String error_msg =
"Referenced volume '" + ref +
"' was not found!";
841 G4Exception(
"G4GDMLReadStructure::GetVolume()",
"ReadError",
851 G4GDMLAssemblyMapType::const_iterator
pos =
assemblyMap.find(ref);
852 if (pos !=
assemblyMap.end()) {
return pos->second; }
859 G4GDMLAuxMapType::const_iterator
pos =
auxMap.find(logvol);
860 if (pos !=
auxMap.end()) {
return pos->second; }
868 if (sname ==
"") {
return 0; }
882 volume->
GetName()+
"_PV",0,0,0);
G4PhysicalVolumesPair Divide(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofDivisions, G4double width, G4double offset)
G4AssemblyVolume * GetAssembly(const G4String &) const
G4LogicalVolume * FileRead(const xercesc::DOMElement *const)
G4int EvaluateInteger(const G4String &)
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
virtual void ParamvolRead(const xercesc::DOMElement *const, G4LogicalVolume *)
CLHEP::Hep3Vector G4ThreeVector
const G4GDMLAuxMapType * GetAuxMap() const
G4Material * GetMaterial(const G4String &, G4bool verbose=true) const
virtual void Volume_contentRead(const xercesc::DOMElement *const)=0
G4double QuantityRead(const xercesc::DOMElement *const readElement)
void DivisionvolRead(const xercesc::DOMElement *const)
G4String Transcode(const XMLCh *const)
G4ThreeVector GetScale(const G4String &)
G4SurfaceProperty * GetSurfaceProperty(const G4String &) const
void ReplicavolRead(const xercesc::DOMElement *const, G4int number)
G4PhysicalVolumesPair Replicate(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofReplicas, G4double width, G4double offset=0)
void GeneratePhysvolName(const G4String &, G4VPhysicalVolume *)
virtual ~G4GDMLReadStructure()
G4VPhysicalVolume * GetPhysvol(const G4String &) const
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
static G4ReflectionFactory * Instance()
G4VSolid * GetSolid(const G4String &) const
virtual void StructureRead(const xercesc::DOMElement *const)=0
static G4PhysicalVolumeStore * GetInstance()
G4String RefRead(const xercesc::DOMElement *const)
static G4PVDivisionFactory * GetInstance()
void LoopRead(const xercesc::DOMElement *const, void(G4GDMLRead::*)(const xercesc::DOMElement *const))
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4GDMLAssemblyMapType assemblyMap
G4LogicalVolume * GetVolume(const G4String &) const
void ReplicaRead(const xercesc::DOMElement *const replicaElement, G4LogicalVolume *logvol, G4int number)
static G4LogicalVolumeStore * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4LogicalVolume * pMotherLogical
G4String GenerateName(const G4String &name, G4bool strip=false)
std::map< std::string, G4VPhysicalVolume * > setuptoPV
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
void BorderSurfaceRead(const xercesc::DOMElement *const)
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)
G4String Strip(const G4String &) const
G4VPhysicalVolume * GetWorldVolume(const G4String &)
EAxis AxisRead(const xercesc::DOMElement *const axisElement)
void SkinSurfaceRead(const xercesc::DOMElement *const)
G4GDMLAuxStructType AuxiliaryRead(const xercesc::DOMElement *const auxElem)
void VectorRead(const xercesc::DOMElement *const, G4ThreeVector &)
static const G4VisAttributes Invisible
virtual void Volume_contentRead(const xercesc::DOMElement *const)
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
G4ThreeVector GetRotation(const G4String &)
G4GDMLAuxListType GetVolumeAuxiliaryInformation(G4LogicalVolume *) const
G4RotationMatrix GetRotationMatrix(const G4ThreeVector &)
const G4String & GetName() const
std::map< G4LogicalVolume *, G4GDMLAuxListType > G4GDMLAuxMapType
virtual void StructureRead(const xercesc::DOMElement *const)
void AssemblyRead(const xercesc::DOMElement *const)
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
void SetVisAttributes(const G4VisAttributes *pVA)
static const G4double pos
G4String GetSetup(const G4String &)
void Read(const G4String &, G4bool validation, G4bool isModule, G4bool strip=true)
G4double Evaluate(const G4String &)
void PhysvolRead(const xercesc::DOMElement *const, G4AssemblyVolume *assembly=0)
G4ThreeVector GetPosition(const G4String &)
virtual void VolumeRead(const xercesc::DOMElement *const)