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
161 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
"InvalidRead",
164 if (attName==
"width") { width =
eval.
Evaluate(attValue); }
else
165 if (attName==
"offset") { offset =
eval.
Evaluate(attValue); }
else
169 if (attValue==
"kXAxis") { axis =
kXAxis; }
else
170 if (attValue==
"kYAxis") { axis =
kYAxis; }
else
171 if (attValue==
"kZAxis") { axis =
kZAxis; }
else
172 if (attValue==
"kRho") { axis =
kRho; }
else
173 if (attValue==
"kPhi") { axis =
kPhi; }
180 for (xercesc::DOMNode* iter = divisionvolElement->getFirstChild();
181 iter != 0;iter = iter->getNextSibling())
183 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
185 const xercesc::DOMElement*
const child
186 =
dynamic_cast<xercesc::DOMElement*
>(iter);
189 G4Exception(
"G4GDMLReadStructure::DivisionvolRead()",
198 if (!logvol) {
return; }
204 if ((number != 0) && (width == 0.0))
209 else if ((number == 0) && (width != 0.0))
225 FileRead(
const xercesc::DOMElement*
const fileElement)
230 const xercesc::DOMNamedNodeMap*
const attributes
231 = fileElement->getAttributes();
232 XMLSize_t attributeCount = attributes->getLength();
234 for (XMLSize_t attribute_index=0;
235 attribute_index<attributeCount; attribute_index++)
237 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
239 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
242 const xercesc::DOMAttr*
const attribute
243 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
253 if (attName==
"name") { name = attValue; }
else
254 if (attName==
"volname") { volname = attValue; }
257 const G4bool isModule =
true;
266 G4GDMLAuxMapType::const_iterator
pos;
267 for (pos = aux->begin(); pos != aux->end(); ++
pos)
269 auxMap.insert(std::make_pair(pos->first,pos->second));
295 G4int copynumber = 0;
297 const xercesc::DOMNamedNodeMap*
const attributes
298 = physvolElement->getAttributes();
299 XMLSize_t attributeCount = attributes->getLength();
301 for (XMLSize_t attribute_index=0;
302 attribute_index<attributeCount; attribute_index++)
304 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
306 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
309 const xercesc::DOMAttr*
const attribute
310 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
320 if (attName==
"name") { name = attValue; }
324 for (xercesc::DOMNode* iter = physvolElement->getFirstChild();
325 iter != 0; iter = iter->getNextSibling())
327 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
329 const xercesc::DOMElement*
const child
330 =
dynamic_cast<xercesc::DOMElement*
>(iter);
339 if (tag==
"volumeref")
343 if (!assembly) { logvol =
GetVolume(child_name); }
345 else if (tag==
"file")
347 else if (tag==
"position")
349 else if (tag==
"rotation")
351 else if (tag==
"scale")
353 else if (tag==
"positionref")
355 else if (tag==
"rotationref")
357 else if (tag==
"scaleref")
361 G4String error_msg =
"Unknown tag in physvol: " + tag;
362 G4Exception(
"G4GDMLReadStructure::PhysvolRead()",
"ReadError",
369 transform = transform*
G4Scale3D(scale.x(),scale.y(),scale.z());
373 if (!logvol) {
return; }
384 if (!logvol) {
return; }
399 for (xercesc::DOMNode* iter = replicavolElement->getFirstChild();
400 iter != 0; iter = iter->getNextSibling())
402 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
404 const xercesc::DOMElement*
const child
405 =
dynamic_cast<xercesc::DOMElement*
>(iter);
408 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
414 if (tag==
"volumeref")
418 else if (tag==
"replicate_along_axis")
424 G4String error_msg =
"Unknown tag in ReplicavolRead: " + tag;
425 G4Exception(
"G4GDMLReadStructure::ReplicavolRead()",
442 for (xercesc::DOMNode* iter = replicaElement->getFirstChild();
443 iter != 0; iter = iter->getNextSibling())
445 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
447 const xercesc::DOMElement*
const child
448 =
dynamic_cast<xercesc::DOMElement*
>(iter);
461 if (tag==
"positionref")
463 if (tag==
"rotationref")
465 if (tag==
"direction")
473 G4String error_msg =
"Unknown tag in ReplicaRead: " + tag;
474 G4Exception(
"G4GDMLReadStructure::ReplicaRead()",
"ReadError",
489 AxisRead(
const xercesc::DOMElement*
const axisElement)
493 const xercesc::DOMNamedNodeMap*
const attributes
494 = axisElement->getAttributes();
495 XMLSize_t attributeCount = attributes->getLength();
497 for (XMLSize_t attribute_index=0;
498 attribute_index<attributeCount; attribute_index++)
500 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
502 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
505 const xercesc::DOMAttr*
const attribute
506 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
517 else if (attName==
"y")
519 else if (attName==
"z")
521 else if (attName==
"rho")
523 else if (attName==
"phi")
535 const xercesc::DOMNamedNodeMap*
const attributes
536 = readElement->getAttributes();
537 XMLSize_t attributeCount = attributes->getLength();
539 for (XMLSize_t attribute_index=0;
540 attribute_index<attributeCount; attribute_index++)
542 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
544 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
546 const xercesc::DOMAttr*
const attribute
547 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
559 G4Exception(
"G4GDMLReadStructure::QuantityRead()",
"InvalidRead",
562 if (attName==
"value"){ value=
eval.
Evaluate(attValue); }
575 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
577 xercesc::XMLString::release(&name_attr);
579 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
580 iter != 0; iter = iter->getNextSibling())
582 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
584 const xercesc::DOMElement*
const child
585 =
dynamic_cast<xercesc::DOMElement*
>(iter);
594 if (tag==
"auxiliary")
596 if (tag==
"materialref")
613 XMLCh *name_attr = xercesc::XMLString::transcode(
"name");
615 xercesc::XMLString::release(&name_attr);
620 for (xercesc::DOMNode* iter = assemblyElement->getFirstChild();
621 iter != 0; iter = iter->getNextSibling())
623 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
624 const xercesc::DOMElement*
const child
625 =
dynamic_cast<xercesc::DOMElement*
>(iter);
640 G4cout <<
"Unsupported GDML tag '" << tag
641 <<
"' for Geant4 assembly structure !" <<
G4endl;
653 const xercesc::DOMNamedNodeMap*
const attributes
654 = skinsurfaceElement->getAttributes();
655 XMLSize_t attributeCount = attributes->getLength();
657 for (XMLSize_t attribute_index=0;
658 attribute_index<attributeCount; attribute_index++)
660 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
662 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
665 const xercesc::DOMAttr*
const attribute
666 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
669 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
678 if (attName==
"surfaceproperty")
682 for (xercesc::DOMNode* iter = skinsurfaceElement->getFirstChild();
683 iter != 0; iter = iter->getNextSibling())
685 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
687 const xercesc::DOMElement*
const child
688 =
dynamic_cast<xercesc::DOMElement*
>(iter);
691 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
697 if (tag==
"volumeref")
703 G4String error_msg =
"Unknown tag in skinsurface: " + tag;
704 G4Exception(
"G4GDMLReadStructure::SkinsurfaceRead()",
"ReadError",
715 for (xercesc::DOMNode* iter = volumeElement->getFirstChild();
716 iter != 0; iter = iter->getNextSibling())
718 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
720 const xercesc::DOMElement*
const child
721 =
dynamic_cast<xercesc::DOMElement*
>(iter);
724 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
730 if ((tag==
"auxiliary") || (tag==
"materialref") || (tag==
"solidref"))
734 else if (tag==
"paramvol")
738 else if (tag==
"physvol")
742 else if (tag==
"replicavol")
745 const xercesc::DOMNamedNodeMap*
const attributes
746 = child->getAttributes();
747 XMLSize_t attributeCount = attributes->getLength();
748 for (XMLSize_t attribute_index=0;
749 attribute_index<attributeCount; attribute_index++)
751 xercesc::DOMNode* attribute_node
752 = attributes->item(attribute_index);
753 if (attribute_node->getNodeType()!=xercesc::DOMNode::ATTRIBUTE_NODE)
757 const xercesc::DOMAttr*
const attribute
758 =
dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
761 G4Exception(
"G4GDMLReadStructure::Volume_contentRead()",
767 if (attName==
"number")
774 else if (tag==
"divisionvol")
778 else if (tag==
"loop")
784 G4cout <<
"Treating unknown GDML tag in volume '" << tag
785 <<
"' as GDML extension..." <<
G4endl;
795 for (xercesc::DOMNode* iter = structureElement->getFirstChild();
796 iter != 0; iter = iter->getNextSibling())
798 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) {
continue; }
800 const xercesc::DOMElement*
const child
801 =
dynamic_cast<xercesc::DOMElement*
>(iter);
804 G4Exception(
"G4GDMLReadStructure::StructureRead()",
812 if (tag==
"volume") {
VolumeRead(child); }
else
817 G4String error_msg =
"Unknown tag in structure: " + tag;
818 G4Exception(
"G4GDMLReadStructure::StructureRead()",
832 G4String error_msg =
"Referenced physvol '" + ref +
"' was not found!";
833 G4Exception(
"G4GDMLReadStructure::GetPhysvol()",
"ReadError",
848 G4String error_msg =
"Referenced volume '" + ref +
"' was not found!";
849 G4Exception(
"G4GDMLReadStructure::GetVolume()",
"ReadError",
859 G4GDMLAssemblyMapType::const_iterator
pos =
assemblyMap.find(ref);
860 if (pos !=
assemblyMap.end()) {
return pos->second; }
867 G4GDMLAuxMapType::const_iterator
pos =
auxMap.find(logvol);
868 if (pos !=
auxMap.end()) {
return pos->second; }
876 if (sname ==
"") {
return 0; }
890 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
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 &)
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)