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;
800 for (xercesc::DOMNode* iter = structureElement->getFirstChild();
801 iter != 0; iter = iter->getNextSibling())
803 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
805 const xercesc::DOMElement*
const child
806 =
dynamic_cast<xercesc::DOMElement*
>(iter);
809 G4Exception(
"G4GDMLReadStructure::StructureRead()",
817 if (tag==
"volume") {
VolumeRead(child); }
else
822 G4String error_msg =
"Unknown tag in structure: " + tag;
823 G4Exception(
"G4GDMLReadStructure::StructureRead()",
837 G4String error_msg =
"Referenced physvol '" + ref +
"' was not found!";
838 G4Exception(
"G4GDMLReadStructure::GetPhysvol()",
"ReadError",
853 G4String error_msg =
"Referenced volume '" + ref +
"' was not found!";
854 G4Exception(
"G4GDMLReadStructure::GetVolume()",
"ReadError",
864 G4GDMLAssemblyMapType::const_iterator
pos =
assemblyMap.find(ref);
865 if (pos !=
assemblyMap.end()) {
return pos->second; }
872 G4GDMLAuxMapType::const_iterator
pos =
auxMap.find(logvol);
873 if (pos !=
auxMap.end()) {
return pos->second; }
881 if (sname ==
"") {
return 0; }
895 volume->
GetName()+
"_PV",0,0,0);
void ReplicavolRead(const xercesc::DOMElement *const, G4int number)
G4LogicalVolume * pMotherLogical
void BorderSurfaceRead(const xercesc::DOMElement *const)
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)
void ReplicaRead(const xercesc::DOMElement *const replicaElement, G4LogicalVolume *logvol, G4int number)
std::pair< G4VPhysicalVolume *, G4VPhysicalVolume * > G4PhysicalVolumesPair
CLHEP::Hep3Vector G4ThreeVector
std::map< std::string, G4VPhysicalVolume * > setuptoPV
static const G4double pos
EAxis AxisRead(const xercesc::DOMElement *const axisElement)
void PhysvolRead(const xercesc::DOMElement *const, G4AssemblyVolume *assembly=0)
void Read(const G4String &, G4bool validation, G4bool isModule, G4bool strip=true)
G4LogicalVolume * FileRead(const xercesc::DOMElement *const)
void DivisionvolRead(const xercesc::DOMElement *const)
void AssemblyRead(const xercesc::DOMElement *const)
G4String GetSetup(const G4String &)
void LoopRead(const xercesc::DOMElement *const, void(G4GDMLRead::*)(const xercesc::DOMElement *const))
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
G4String GenerateName(const G4String &name, G4bool strip=false)
virtual ~G4GDMLReadStructure()
G4double Evaluate(const G4String &)
void SkinSurfaceRead(const xercesc::DOMElement *const)
G4GDMLAssemblyMapType assemblyMap
G4GDMLAuxListType GetVolumeAuxiliaryInformation(G4LogicalVolume *) const
void VectorRead(const xercesc::DOMElement *const, G4ThreeVector &)
static G4PVDivisionFactory * GetInstance()
static const G4VisAttributes & GetInvisible()
const G4GDMLAuxMapType * GetAuxMap() const
virtual void StructureRead(const xercesc::DOMElement *const)=0
G4GDMLAuxStructType AuxiliaryRead(const xercesc::DOMElement *const auxElem)
virtual void Volume_contentRead(const xercesc::DOMElement *const)=0
G4String RefRead(const xercesc::DOMElement *const)
void GeneratePhysvolName(const G4String &, G4VPhysicalVolume *)
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
G4String Strip(const G4String &) const
G4SurfaceProperty * GetSurfaceProperty(const G4String &) const
G4Material * GetMaterial(const G4String &, G4bool verbose=true) const
const XML_Char int const XML_Char * value
G4String Transcode(const XMLCh *const)
G4VPhysicalVolume * GetPhysvol(const G4String &) const
G4ThreeVector GetScale(const G4String &)
virtual void ParamvolRead(const xercesc::DOMElement *const, G4LogicalVolume *)
G4RotationMatrix GetRotationMatrix(const G4ThreeVector &)
G4double QuantityRead(const xercesc::DOMElement *const readElement)
static G4double GetValueOf(const G4String &)
void SetVisAttributes(const G4VisAttributes *pVA)
std::map< G4LogicalVolume *, G4GDMLAuxListType > G4GDMLAuxMapType
virtual void Volume_contentRead(const xercesc::DOMElement *const)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4PhysicalVolumesPair Replicate(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofReplicas, G4double width, G4double offset=0)
static G4PhysicalVolumeStore * GetInstance()
G4AssemblyVolume * GetAssembly(const G4String &) const
G4VPhysicalVolume * GetWorldVolume(const G4String &)
std::vector< G4GDMLAuxStructType > G4GDMLAuxListType
G4GLOB_DLL std::ostream G4cout
static G4String GetCategory(const G4String &)
G4int EvaluateInteger(const G4String &)
G4LogicalVolume * GetVolume(const G4String &) const
G4PhysicalVolumesPair Divide(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofDivisions, G4double width, G4double offset)
G4ThreeVector GetPosition(const G4String &)
virtual void StructureRead(const xercesc::DOMElement *const)
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
static G4LogicalVolumeStore * GetInstance()
virtual void VolumeRead(const xercesc::DOMElement *const)
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
const G4String & GetName() const
G4VSolid * GetSolid(const G4String &) const
G4ThreeVector GetRotation(const G4String &)
static G4ReflectionFactory * Instance()