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();
140 for (XMLSize_t attribute_index=0;
141 attribute_index<attributeCount; attribute_index++)
143 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
145 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
148 const xercesc::DOMAttr*
const attribute
149 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
152 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
159 if (attName==
"name") { name = attValue; }
else
163 if (attName==
"width") { width =
eval.
Evaluate(attValue); }
else
164 if (attName==
"offset") { offset =
eval.
Evaluate(attValue); }
else
168 if (attValue==
"kXAxis") { axis =
kXAxis; }
else
169 if (attValue==
"kYAxis") { axis =
kYAxis; }
else
170 if (attValue==
"kZAxis") { axis =
kZAxis; }
else
171 if (attValue==
"kRho") { axis =
kRho; }
else
172 if (attValue==
"kPhi") { axis =
kPhi; }
177 ((axis ==
kRho || axis ==
kPhi) && unitname!=
"Angle")) {
178 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead",
184 for (xercesc::DOMNode* iter = divisionvolElement->getFirstChild();
185 iter != 0;iter = iter->getNextSibling())
187 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
189 const xercesc::DOMElement*
const child
190 =
dynamic_cast<xercesc::DOMElement*
>(iter);
193 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
202 if (!logvol) {
return; }
208 if ((number != 0) && (width == 0.0))
213 else if ((number == 0) && (width != 0.0))
229 FileRead(
const xercesc::DOMElement*
const fileElement)
234 const xercesc::DOMNamedNodeMap*
const attributes
235 = fileElement->getAttributes();
236 XMLSize_t attributeCount = attributes->getLength();
238 for (XMLSize_t attribute_index=0;
239 attribute_index<attributeCount; attribute_index++)
241 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
243 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
246 const xercesc::DOMAttr*
const attribute
247 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
257 if (attName==
"name") { name = attValue; }
else
258 if (attName==
"volname") { volname = attValue; }
261 const G4bool isModule =
true;
270 G4GDMLAuxMapType::const_iterator
pos;
271 for (pos = aux->begin(); pos != aux->end(); ++
pos)
273 auxMap.insert(std::make_pair(pos->first,pos->second));
299 G4int copynumber = 0;
301 const xercesc::DOMNamedNodeMap*
const attributes
302 = physvolElement->getAttributes();
303 XMLSize_t attributeCount = attributes->getLength();
305 for (XMLSize_t attribute_index=0;
306 attribute_index<attributeCount; attribute_index++)
308 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
310 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
313 const xercesc::DOMAttr*
const attribute
314 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
324 if (attName==
"name") { name = attValue; }
328 for (xercesc::DOMNode* iter = physvolElement->getFirstChild();
329 iter != 0; iter = iter->getNextSibling())
331 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
333 const xercesc::DOMElement*
const child
334 =
dynamic_cast<xercesc::DOMElement*
>(iter);
343 if (tag==
"volumeref")
347 if (!assembly) { logvol =
GetVolume(child_name); }
349 else if (tag==
"file")
351 else if (tag==
"position")
353 else if (tag==
"rotation")
355 else if (tag==
"scale")
357 else if (tag==
"positionref")
359 else if (tag==
"rotationref")
361 else if (tag==
"scaleref")
365 G4String error_msg =
"Unknown tag in physvol: " + tag;
366 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"ReadError",
373 transform = transform*
G4Scale3D(scale.
x(),scale.
y(),scale.
z());
377 if (!logvol) {
return; }
388 if (!logvol) {
return; }
403 for (xercesc::DOMNode* iter = replicavolElement->getFirstChild();
404 iter != 0; iter = iter->getNextSibling())
406 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
408 const xercesc::DOMElement*
const child
409 =
dynamic_cast<xercesc::DOMElement*
>(iter);
412 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
418 if (tag==
"volumeref")
422 else if (tag==
"replicate_along_axis")
428 G4String error_msg =
"Unknown tag in ReplicavolRead: " + tag;
429 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
446 for (xercesc::DOMNode* iter = replicaElement->getFirstChild();
447 iter != 0; iter = iter->getNextSibling())
449 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
451 const xercesc::DOMElement*
const child
452 =
dynamic_cast<xercesc::DOMElement*
>(iter);
465 if (tag==
"positionref")
467 if (tag==
"rotationref")
469 if (tag==
"direction")
477 G4String error_msg =
"Unknown tag in ReplicaRead: " + tag;
478 G4Exception(
"G4GDMLReadStructure::ReplicaRead()",
"ReadError",
493 AxisRead(
const xercesc::DOMElement*
const axisElement)
497 const xercesc::DOMNamedNodeMap*
const attributes
498 = axisElement->getAttributes();
499 XMLSize_t attributeCount = attributes->getLength();
501 for (XMLSize_t attribute_index=0;
502 attribute_index<attributeCount; attribute_index++)
504 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
506 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
509 const xercesc::DOMAttr*
const attribute
510 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
521 else if (attName==
"y")
523 else if (attName==
"z")
525 else if (attName==
"rho")
527 else if (attName==
"phi")
539 const xercesc::DOMNamedNodeMap*
const attributes
540 = readElement->getAttributes();
541 XMLSize_t attributeCount = attributes->getLength();
543 for (XMLSize_t attribute_index=0;
544 attribute_index<attributeCount; attribute_index++)
546 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
548 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
550 const xercesc::DOMAttr*
const attribute
551 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
563 G4Exception(
"G4GDMLReadStructure::QuantityRead()",
"InvalidRead",
564 FatalException,
"Invalid unit for lenght or angle (width, offset)!"); }
566 if (attName==
"value"){ value=
eval.
Evaluate(attValue); }
579 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
581 xercesc::XMLString::release(&name_attr);
583 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
584 iter != 0; iter = iter->getNextSibling())
586 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
588 const xercesc::DOMElement*
const child
589 =
dynamic_cast<xercesc::DOMElement*
>(iter);
598 if (tag==
"auxiliary")
600 if (tag==
"materialref")
617 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
619 xercesc::XMLString::release(&name_attr);
624 for (xercesc::DOMNode* iter = assemblyElement->getFirstChild();
625 iter != 0; iter = iter->getNextSibling())
627 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
628 const xercesc::DOMElement*
const child
629 =
dynamic_cast<xercesc::DOMElement*
>(iter);
644 G4cout <<
"Unsupported GDML tag '" << tag
645 <<
"' for Geant4 assembly structure !" <<
G4endl;
657 const xercesc::DOMNamedNodeMap*
const attributes
658 = skinsurfaceElement->getAttributes();
659 XMLSize_t attributeCount = attributes->getLength();
661 for (XMLSize_t attribute_index=0;
662 attribute_index<attributeCount; attribute_index++)
664 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
666 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
669 const xercesc::DOMAttr*
const attribute
670 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
673 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
682 if (attName==
"surfaceproperty")
686 for (xercesc::DOMNode* iter = skinsurfaceElement->getFirstChild();
687 iter != 0; iter = iter->getNextSibling())
689 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
691 const xercesc::DOMElement*
const child
692 =
dynamic_cast<xercesc::DOMElement*
>(iter);
695 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
701 if (tag==
"volumeref")
707 G4String error_msg =
"Unknown tag in skinsurface: " + tag;
708 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"ReadError",
719 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
720 iter != 0; iter = iter->getNextSibling())
722 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
724 const xercesc::DOMElement*
const child
725 =
dynamic_cast<xercesc::DOMElement*
>(iter);
728 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
734 if ((tag==
"auxiliary") || (tag==
"materialref") || (tag==
"solidref"))
738 else if (tag==
"paramvol")
742 else if (tag==
"physvol")
746 else if (tag==
"replicavol")
749 const xercesc::DOMNamedNodeMap*
const attributes
750 = child->getAttributes();
751 XMLSize_t attributeCount = attributes->getLength();
752 for (XMLSize_t attribute_index=0;
753 attribute_index<attributeCount; attribute_index++)
755 xercesc::DOMNode* attribute_node
756 = attributes->item(attribute_index);
757 if (attribute_node->getNodeType()!=xercesc::DOMNode::ATTRIBUTE_NODE)
761 const xercesc::DOMAttr*
const attribute
762 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
765 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
771 if (attName==
"number")
778 else if (tag==
"divisionvol")
782 else if (tag==
"loop")
788 G4cout <<
"Treating unknown GDML tag in volume '" << tag
789 <<
"' as GDML extension..." <<
G4endl;
799 for (xercesc::DOMNode* iter = structureElement->getFirstChild();
800 iter != 0; iter = iter->getNextSibling())
802 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
804 const xercesc::DOMElement*
const child
805 =
dynamic_cast<xercesc::DOMElement*
>(iter);
808 G4Exception(
"G4GDMLReadStructure::StructureRead()",
816 if (tag==
"volume") {
VolumeRead(child); }
else
821 G4String error_msg =
"Unknown tag in structure: " + tag;
822 G4Exception(
"G4GDMLReadStructure::StructureRead()",
836 G4String error_msg =
"Referenced physvol '" + ref +
"' was not found!";
837 G4Exception(
"G4GDMLReadStructure::GetPhysvol()",
"ReadError",
852 G4String error_msg =
"Referenced volume '" + ref +
"' was not found!";
853 G4Exception(
"G4GDMLReadStructure::GetVolume()",
"ReadError",
863 G4GDMLAssemblyMapType::const_iterator
pos =
assemblyMap.find(ref);
864 if (pos !=
assemblyMap.end()) {
return pos->second; }
871 G4GDMLAuxMapType::const_iterator
pos =
auxMap.find(logvol);
872 if (pos !=
auxMap.end()) {
return pos->second; }
880 if (sname ==
"") {
return 0; }
894 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
const XML_Char int const XML_Char * value
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
static G4String GetCategory(const G4String &)
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 &)
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
static const G4VisAttributes & GetInvisible()
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)