31 #include "G4GDMLReadSolids.hh"
34 #include "G4Ellipsoid.hh"
35 #include "G4EllipticalCone.hh"
36 #include "G4EllipticalTube.hh"
38 #include "G4IntersectionSolid.hh"
41 #include "G4Paraboloid.hh"
42 #include "G4Polycone.hh"
43 #include "G4GenericPolycone.hh"
44 #include "G4Polyhedra.hh"
45 #include "G4QuadrangularFacet.hh"
46 #include "G4ReflectedSolid.hh"
47 #include "G4ScaledSolid.hh"
48 #include "G4Sphere.hh"
50 #include "G4SubtractionSolid.hh"
51 #include "G4GenericTrap.hh"
52 #include "G4TessellatedSolid.hh"
55 #include "G4Transform3D.hh"
58 #include "G4TriangularFacet.hh"
60 #include "G4CutTubs.hh"
61 #include "G4TwistedBox.hh"
62 #include "G4TwistedTrap.hh"
63 #include "G4TwistedTrd.hh"
64 #include "G4TwistedTubs.hh"
65 #include "G4UnionSolid.hh"
66 #include "G4OpticalSurface.hh"
67 #include "G4UnitsTable.hh"
68 #include "G4SurfaceProperty.hh"
71 G4GDMLReadSolids::G4GDMLReadSolids()
72 : G4GDMLReadMaterials()
77 G4GDMLReadSolids::~G4GDMLReadSolids()
82 void G4GDMLReadSolids::BooleanRead(
83 const xercesc::DOMElement*
const booleanElement,
const BooleanOp op)
88 G4ThreeVector
position(0.0, 0.0, 0.0);
89 G4ThreeVector rotation(0.0, 0.0, 0.0);
90 G4ThreeVector firstposition(0.0, 0.0, 0.0);
91 G4ThreeVector firstrotation(0.0, 0.0, 0.0);
93 const xercesc::DOMNamedNodeMap*
const attributes =
94 booleanElement->getAttributes();
95 XMLSize_t attributeCount = attributes->getLength();
97 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
100 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
102 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
107 const xercesc::DOMAttr*
const attribute =
108 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
109 if(attribute ==
nullptr)
111 G4Exception(
"G4GDMLReadSolids::BooleanRead()",
"InvalidRead",
112 FatalException,
"No attribute found!");
115 const G4String attName = Transcode(attribute->getName());
116 const G4String attValue = Transcode(attribute->getValue());
118 if(attName ==
"name")
120 name = GenerateName(attValue);
124 for(xercesc::DOMNode* iter = booleanElement->getFirstChild(); iter !=
nullptr;
125 iter = iter->getNextSibling())
127 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
132 const xercesc::DOMElement*
const child =
133 dynamic_cast<xercesc::DOMElement*
>(iter);
136 G4Exception(
"G4GDMLReadSolids::BooleanRead()",
"InvalidRead",
137 FatalException,
"No child found!");
140 const G4String
tag = Transcode(child->getTagName());
144 first = RefRead(child);
146 else if(tag ==
"second")
148 scnd = RefRead(child);
150 else if(tag ==
"position")
154 else if(tag ==
"rotation")
156 VectorRead(child, rotation);
158 else if(tag ==
"positionref")
160 position = GetPosition(GenerateName(RefRead(child)));
162 else if(tag ==
"rotationref")
164 rotation = GetRotation(GenerateName(RefRead(child)));
166 else if(tag ==
"firstposition")
168 VectorRead(child, firstposition);
170 else if(tag ==
"firstrotation")
172 VectorRead(child, firstrotation);
174 else if(tag ==
"firstpositionref")
176 firstposition = GetPosition(GenerateName(RefRead(child)));
178 else if(tag ==
"firstrotationref")
180 firstrotation = GetRotation(GenerateName(RefRead(child)));
184 G4String error_msg =
"Unknown tag in boolean solid: " +
tag;
185 G4Exception(
"G4GDMLReadSolids::BooleanRead()",
"ReadError",
186 FatalException, error_msg);
190 G4VSolid* firstSolid = GetSolid(GenerateName(first));
191 G4VSolid* secondSolid = GetSolid(GenerateName(scnd));
195 if(((firstrotation.x() != 0.0) || (firstrotation.y() != 0.0) ||
196 (firstrotation.z() != 0.0)) ||
197 ((firstposition.x() != 0.0) || (firstposition.y() != 0.0) ||
198 (firstposition.z() != 0.0)))
200 G4Transform3D firsttransform(GetRotationMatrix(firstrotation),
202 firstSolid =
new G4DisplacedSolid(GenerateName(
"displaced_" + first),
203 firstSolid, firsttransform);
208 new G4UnionSolid(name, firstSolid, secondSolid,
transform);
210 else if(op == SUBTRACTION)
212 new G4SubtractionSolid(name, firstSolid, secondSolid,
transform);
214 else if(op == INTERSECTION)
216 new G4IntersectionSolid(name, firstSolid, secondSolid,
transform);
221 void G4GDMLReadSolids::BoxRead(
const xercesc::DOMElement*
const boxElement)
224 G4double lunit = 1.0;
229 const xercesc::DOMNamedNodeMap*
const attributes =
230 boxElement->getAttributes();
231 XMLSize_t attributeCount = attributes->getLength();
233 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
236 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
238 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
243 const xercesc::DOMAttr*
const attribute =
244 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
245 if(attribute ==
nullptr)
247 G4Exception(
"G4GDMLReadSolids::BoxRead()",
"InvalidRead", FatalException,
248 "No attribute found!");
251 const G4String attName = Transcode(attribute->getName());
252 const G4String attValue = Transcode(attribute->getValue());
254 if(attName ==
"name")
256 name = GenerateName(attValue);
258 else if(attName ==
"lunit")
260 lunit = G4UnitDefinition::GetValueOf(attValue);
261 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
263 G4Exception(
"G4GDMLReadSolids::BoxRead()",
"InvalidRead",
264 FatalException,
"Invalid unit for length!");
267 else if(attName ==
"x")
269 x = eval.Evaluate(attValue);
271 else if(attName ==
"y")
273 y = eval.Evaluate(attValue);
275 else if(attName ==
"z")
277 z = eval.Evaluate(attValue);
285 new G4Box(name, x, y, z);
289 void G4GDMLReadSolids::ConeRead(
const xercesc::DOMElement*
const coneElement)
292 G4double lunit = 1.0;
293 G4double aunit = 1.0;
294 G4double rmin1 = 0.0;
295 G4double rmax1 = 0.0;
296 G4double rmin2 = 0.0;
297 G4double rmax2 = 0.0;
299 G4double startphi = 0.0;
300 G4double deltaphi = 0.0;
302 const xercesc::DOMNamedNodeMap*
const attributes =
303 coneElement->getAttributes();
304 XMLSize_t attributeCount = attributes->getLength();
306 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
309 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
311 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
316 const xercesc::DOMAttr*
const attribute =
317 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
318 if(attribute ==
nullptr)
320 G4Exception(
"G4GDMLReadSolids::ConeRead()",
"InvalidRead", FatalException,
321 "No attribute found!");
324 const G4String attName = Transcode(attribute->getName());
325 const G4String attValue = Transcode(attribute->getValue());
327 if(attName ==
"name")
329 name = GenerateName(attValue);
331 else if(attName ==
"lunit")
333 lunit = G4UnitDefinition::GetValueOf(attValue);
334 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
336 G4Exception(
"G4GDMLReadSolids::ConeRead()",
"InvalidRead",
337 FatalException,
"Invalid unit for length!");
340 else if(attName ==
"aunit")
342 aunit = G4UnitDefinition::GetValueOf(attValue);
343 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
345 G4Exception(
"G4GDMLReadSolids::ConeRead()",
"InvalidRead",
346 FatalException,
"Invalid unit for angle!");
349 else if(attName ==
"rmin1")
351 rmin1 = eval.Evaluate(attValue);
353 else if(attName ==
"rmax1")
355 rmax1 = eval.Evaluate(attValue);
357 else if(attName ==
"rmin2")
359 rmin2 = eval.Evaluate(attValue);
361 else if(attName ==
"rmax2")
363 rmax2 = eval.Evaluate(attValue);
365 else if(attName ==
"z")
367 z = eval.Evaluate(attValue);
369 else if(attName ==
"startphi")
371 startphi = eval.Evaluate(attValue);
373 else if(attName ==
"deltaphi")
375 deltaphi = eval.Evaluate(attValue);
387 new G4Cons(name, rmin1, rmax1, rmin2, rmax2, z, startphi, deltaphi);
391 void G4GDMLReadSolids::ElconeRead(
392 const xercesc::DOMElement*
const elconeElement)
395 G4double lunit = 1.0;
401 const xercesc::DOMNamedNodeMap*
const attributes =
402 elconeElement->getAttributes();
403 XMLSize_t attributeCount = attributes->getLength();
405 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
408 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
410 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
415 const xercesc::DOMAttr*
const attribute =
416 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
417 if(attribute ==
nullptr)
419 G4Exception(
"G4GDMLReadSolids::ElconeRead()",
"InvalidRead",
420 FatalException,
"No attribute found!");
423 const G4String attName = Transcode(attribute->getName());
424 const G4String attValue = Transcode(attribute->getValue());
426 if(attName ==
"name")
428 name = GenerateName(attValue);
430 else if(attName ==
"lunit")
432 lunit = G4UnitDefinition::GetValueOf(attValue);
433 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
435 G4Exception(
"G4GDMLReadSolids::ElconeRead()",
"InvalidRead",
436 FatalException,
"Invalid unit for length!");
439 else if(attName ==
"dx")
441 dx = eval.Evaluate(attValue);
443 else if(attName ==
"dy")
445 dy = eval.Evaluate(attValue);
447 else if(attName ==
"zmax")
449 zmax = eval.Evaluate(attValue);
451 else if(attName ==
"zcut")
453 zcut = eval.Evaluate(attValue);
460 new G4EllipticalCone(name, dx, dy, zmax, zcut);
464 void G4GDMLReadSolids::EllipsoidRead(
465 const xercesc::DOMElement*
const ellipsoidElement)
468 G4double lunit = 1.0;
472 G4double zcut1 = 0.0;
473 G4double zcut2 = 0.0;
475 const xercesc::DOMNamedNodeMap*
const attributes =
476 ellipsoidElement->getAttributes();
477 XMLSize_t attributeCount = attributes->getLength();
479 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
482 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
484 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
489 const xercesc::DOMAttr*
const attribute =
490 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
491 if(attribute ==
nullptr)
493 G4Exception(
"G4GDMLReadSolids::EllipsoidRead()",
"InvalidRead",
494 FatalException,
"No attribute found!");
497 const G4String attName = Transcode(attribute->getName());
498 const G4String attValue = Transcode(attribute->getValue());
500 if(attName ==
"name")
502 name = GenerateName(attValue);
504 else if(attName ==
"lunit")
506 lunit = G4UnitDefinition::GetValueOf(attValue);
507 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
509 G4Exception(
"G4GDMLReadSolids::EllipsoidRead()",
"InvalidRead",
510 FatalException,
"Invalid unit for length!");
513 else if(attName ==
"ax")
515 ax = eval.Evaluate(attValue);
517 else if(attName ==
"by")
519 by = eval.Evaluate(attValue);
521 else if(attName ==
"cz")
523 cz = eval.Evaluate(attValue);
525 else if(attName ==
"zcut1")
527 zcut1 = eval.Evaluate(attValue);
529 else if(attName ==
"zcut2")
531 zcut2 = eval.Evaluate(attValue);
541 new G4Ellipsoid(name, ax, by, cz, zcut1, zcut2);
545 void G4GDMLReadSolids::EltubeRead(
546 const xercesc::DOMElement*
const eltubeElement)
549 G4double lunit = 1.0;
554 const xercesc::DOMNamedNodeMap*
const attributes =
555 eltubeElement->getAttributes();
556 XMLSize_t attributeCount = attributes->getLength();
558 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
561 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
563 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
568 const xercesc::DOMAttr*
const attribute =
569 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
570 if(attribute ==
nullptr)
572 G4Exception(
"G4GDMLReadSolids::EltubeRead()",
"InvalidRead",
573 FatalException,
"No attribute found!");
576 const G4String attName = Transcode(attribute->getName());
577 const G4String attValue = Transcode(attribute->getValue());
579 if(attName ==
"name")
581 name = GenerateName(attValue);
583 else if(attName ==
"lunit")
585 lunit = G4UnitDefinition::GetValueOf(attValue);
586 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
588 G4Exception(
"G4GDMLReadSolids::EltubeRead()",
"InvalidRead",
589 FatalException,
"Invalid unit for length!");
592 else if(attName ==
"dx")
594 dx = eval.Evaluate(attValue);
596 else if(attName ==
"dy")
598 dy = eval.Evaluate(attValue);
600 else if(attName ==
"dz")
602 dz = eval.Evaluate(attValue);
610 new G4EllipticalTube(name, dx, dy, dz);
614 void G4GDMLReadSolids::XtruRead(
const xercesc::DOMElement*
const xtruElement)
617 G4double lunit = 1.0;
619 const xercesc::DOMNamedNodeMap*
const attributes =
620 xtruElement->getAttributes();
621 XMLSize_t attributeCount = attributes->getLength();
623 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
626 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
628 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
633 const xercesc::DOMAttr*
const attribute =
634 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
635 if(attribute ==
nullptr)
637 G4Exception(
"G4GDMLReadSolids::XtruRead()",
"InvalidRead", FatalException,
638 "No attribute found!");
641 const G4String attName = Transcode(attribute->getName());
642 const G4String attValue = Transcode(attribute->getValue());
644 if(attName ==
"name")
646 name = GenerateName(attValue);
648 else if(attName ==
"lunit")
650 lunit = G4UnitDefinition::GetValueOf(attValue);
651 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
653 G4Exception(
"G4GDMLReadSolids::XtruRead()",
"InvalidRead",
654 FatalException,
"Invalid unit for length!");
659 std::vector<G4TwoVector> twoDimVertexList;
660 std::vector<G4ExtrudedSolid::ZSection> sectionList;
662 for(xercesc::DOMNode* iter = xtruElement->getFirstChild(); iter !=
nullptr;
663 iter = iter->getNextSibling())
665 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
670 const xercesc::DOMElement*
const child =
671 dynamic_cast<xercesc::DOMElement*
>(iter);
674 G4Exception(
"G4GDMLReadSolids::XtruRead()",
"InvalidRead", FatalException,
678 const G4String tag = Transcode(child->getTagName());
680 if(tag ==
"twoDimVertex")
682 twoDimVertexList.push_back(TwoDimVertexRead(child, lunit));
684 else if(tag ==
"section")
686 sectionList.push_back(SectionRead(child, lunit));
690 new G4ExtrudedSolid(name, twoDimVertexList, sectionList);
694 void G4GDMLReadSolids::HypeRead(
const xercesc::DOMElement*
const hypeElement)
697 G4double lunit = 1.0;
698 G4double aunit = 1.0;
702 G4double outst = 0.0;
705 const xercesc::DOMNamedNodeMap*
const attributes =
706 hypeElement->getAttributes();
707 XMLSize_t attributeCount = attributes->getLength();
709 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
712 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
714 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
719 const xercesc::DOMAttr*
const attribute =
720 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
721 if(attribute ==
nullptr)
723 G4Exception(
"G4GDMLReadSolids::HypeRead()",
"InvalidRead", FatalException,
724 "No attribute found!");
727 const G4String attName = Transcode(attribute->getName());
728 const G4String attValue = Transcode(attribute->getValue());
730 if(attName ==
"name")
732 name = GenerateName(attValue);
734 else if(attName ==
"lunit")
736 lunit = G4UnitDefinition::GetValueOf(attValue);
737 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
739 G4Exception(
"G4GDMLReadSolids::HypeRead()",
"InvalidRead",
740 FatalException,
"Invalid unit for length!");
743 else if(attName ==
"aunit")
745 aunit = G4UnitDefinition::GetValueOf(attValue);
746 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
748 G4Exception(
"G4GDMLReadSolids::HypeRead()",
"InvalidRead",
749 FatalException,
"Invalid unit for angle!");
752 else if(attName ==
"rmin")
754 rmin = eval.Evaluate(attValue);
756 else if(attName ==
"rmax")
758 rmax = eval.Evaluate(attValue);
760 else if(attName ==
"inst")
762 inst = eval.Evaluate(attValue);
764 else if(attName ==
"outst")
766 outst = eval.Evaluate(attValue);
768 else if(attName ==
"z")
770 z = eval.Evaluate(attValue);
780 new G4Hype(name, rmin, rmax, inst, outst, z);
784 void G4GDMLReadSolids::MultiUnionNodeRead(
785 const xercesc::DOMElement*
const unionNodeElement,
786 G4MultiUnion*
const multiUnionSolid)
790 G4ThreeVector
position(0.0, 0.0, 0.0);
791 G4ThreeVector rotation(0.0, 0.0, 0.0);
793 const xercesc::DOMNamedNodeMap*
const attributes =
794 unionNodeElement->getAttributes();
795 XMLSize_t attributeCount = attributes->getLength();
797 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
800 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
802 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
807 const xercesc::DOMAttr*
const attribute =
808 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
809 if(attribute ==
nullptr)
811 G4Exception(
"G4GDMLReadSolids::MultiUnionNodeRead()",
"InvalidRead",
812 FatalException,
"No attribute found!");
815 const G4String attName = Transcode(attribute->getName());
816 const G4String attValue = Transcode(attribute->getValue());
818 if(attName ==
"name")
820 name = GenerateName(attValue);
824 for(xercesc::DOMNode* iter = unionNodeElement->getFirstChild();
825 iter !=
nullptr; iter = iter->getNextSibling())
827 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
832 const xercesc::DOMElement*
const child =
833 dynamic_cast<xercesc::DOMElement*
>(iter);
836 G4Exception(
"G4GDMLReadSolids::MultiUnionNodeRead()",
"InvalidRead",
837 FatalException,
"No child found!");
840 const G4String tag = Transcode(child->getTagName());
842 if(tag ==
"position")
846 else if(tag ==
"rotation")
848 VectorRead(child, rotation);
850 else if(tag ==
"positionref")
852 position = GetPosition(GenerateName(RefRead(child)));
854 else if(tag ==
"rotationref")
856 rotation = GetRotation(GenerateName(RefRead(child)));
858 else if(tag ==
"solid")
860 solid = RefRead(child);
864 G4String error_msg =
"Unknown tag in MultiUnion structure: " +
tag;
865 G4Exception(
"G4GDMLReadSolids::MultiUnionNodeRead()",
"ReadError",
866 FatalException, error_msg);
869 G4VSolid* solidNode = GetSolid(GenerateName(solid));
871 multiUnionSolid->AddNode(*solidNode,
transform);
875 void G4GDMLReadSolids::MultiUnionRead(
876 const xercesc::DOMElement*
const unionElement)
880 const xercesc::DOMNamedNodeMap*
const attributes =
881 unionElement->getAttributes();
882 XMLSize_t attributeCount = attributes->getLength();
884 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
887 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
889 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
894 const xercesc::DOMAttr*
const attribute =
895 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
896 if(attribute ==
nullptr)
898 G4Exception(
"G4GDMLReadSolids::MultiUnionRead()",
"InvalidRead",
899 FatalException,
"No attribute found!");
902 const G4String attName = Transcode(attribute->getName());
903 const G4String attValue = Transcode(attribute->getValue());
905 if(attName ==
"name")
907 name = GenerateName(attValue);
911 G4MultiUnion* multiUnion =
new G4MultiUnion(name);
913 for(xercesc::DOMNode* iter = unionElement->getFirstChild(); iter !=
nullptr;
914 iter = iter->getNextSibling())
916 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
921 const xercesc::DOMElement*
const child =
922 dynamic_cast<xercesc::DOMElement*
>(iter);
925 G4Exception(
"G4GDMLReadSolids::MultiUnionRead()",
"InvalidRead",
926 FatalException,
"No child found!");
929 const G4String tag = Transcode(child->getTagName());
931 if(tag ==
"multiUnionNode")
933 MultiUnionNodeRead(child, multiUnion);
937 G4String error_msg =
"Unknown tag in MultiUnion structure: " +
tag;
938 G4Exception(
"G4GDMLReadSolids::MultiUnionRead()",
"ReadError",
939 FatalException, error_msg);
942 multiUnion->Voxelize();
946 void G4GDMLReadSolids::OrbRead(
const xercesc::DOMElement*
const orbElement)
949 G4double lunit = 1.0;
952 const xercesc::DOMNamedNodeMap*
const attributes =
953 orbElement->getAttributes();
954 XMLSize_t attributeCount = attributes->getLength();
956 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
959 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
961 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
966 const xercesc::DOMAttr*
const attribute =
967 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
968 if(attribute ==
nullptr)
970 G4Exception(
"G4GDMLReadSolids::OrbRead()",
"InvalidRead", FatalException,
971 "No attribute found!");
974 const G4String attName = Transcode(attribute->getName());
975 const G4String attValue = Transcode(attribute->getValue());
977 if(attName ==
"name")
979 name = GenerateName(attValue);
981 else if(attName ==
"lunit")
983 lunit = G4UnitDefinition::GetValueOf(attValue);
984 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
986 G4Exception(
"G4GDMLReadSolids::OrbRead()",
"InvalidRead",
987 FatalException,
"Invalid unit for length!");
990 else if(attName ==
"r")
992 r = eval.Evaluate(attValue);
1002 void G4GDMLReadSolids::ParaRead(
const xercesc::DOMElement*
const paraElement)
1005 G4double lunit = 1.0;
1006 G4double aunit = 1.0;
1010 G4double
alpha = 0.0;
1011 G4double
theta = 0.0;
1014 const xercesc::DOMNamedNodeMap*
const attributes =
1015 paraElement->getAttributes();
1016 XMLSize_t attributeCount = attributes->getLength();
1018 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1021 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1023 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1028 const xercesc::DOMAttr*
const attribute =
1029 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1030 if(attribute ==
nullptr)
1032 G4Exception(
"G4GDMLReadSolids::ParaRead()",
"InvalidRead", FatalException,
1033 "No attribute found!");
1036 const G4String attName = Transcode(attribute->getName());
1037 const G4String attValue = Transcode(attribute->getValue());
1039 if(attName ==
"name")
1041 name = GenerateName(attValue);
1043 else if(attName ==
"lunit")
1045 lunit = G4UnitDefinition::GetValueOf(attValue);
1046 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1048 G4Exception(
"G4GDMLReadSolids::ParaRead()",
"InvalidRead",
1049 FatalException,
"Invalid unit for length!");
1052 else if(attName ==
"aunit")
1054 aunit = G4UnitDefinition::GetValueOf(attValue);
1055 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
1057 G4Exception(
"G4GDMLReadSolids::ParaRead()",
"InvalidRead",
1058 FatalException,
"Invalid unit for angle!");
1061 else if(attName ==
"x")
1063 x = eval.Evaluate(attValue);
1065 else if(attName ==
"y")
1067 y = eval.Evaluate(attValue);
1069 else if(attName ==
"z")
1071 z = eval.Evaluate(attValue);
1073 else if(attName ==
"alpha")
1075 alpha = eval.Evaluate(attValue);
1077 else if(attName ==
"theta")
1079 theta = eval.Evaluate(attValue);
1081 else if(attName ==
"phi")
1083 phi = eval.Evaluate(attValue);
1094 new G4Para(name, x, y, z, alpha, theta, phi);
1098 void G4GDMLReadSolids::ParaboloidRead(
1099 const xercesc::DOMElement*
const paraElement)
1102 G4double lunit = 1.0;
1107 const xercesc::DOMNamedNodeMap*
const attributes =
1108 paraElement->getAttributes();
1109 XMLSize_t attributeCount = attributes->getLength();
1111 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1114 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1116 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1121 const xercesc::DOMAttr*
const attribute =
1122 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1123 if(attribute ==
nullptr)
1125 G4Exception(
"G4GDMLReadSolids::ParaboloidRead()",
"InvalidRead",
1126 FatalException,
"No attribute found!");
1129 const G4String attName = Transcode(attribute->getName());
1130 const G4String attValue = Transcode(attribute->getValue());
1132 if(attName ==
"name")
1134 name = GenerateName(attValue);
1136 else if(attName ==
"lunit")
1138 lunit = G4UnitDefinition::GetValueOf(attValue);
1139 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1141 G4Exception(
"G4GDMLReadSolids::ParaboloidRead()",
"InvalidRead",
1142 FatalException,
"Invalid unit for length!");
1145 else if(attName ==
"rlo")
1147 rlo = eval.Evaluate(attValue);
1149 else if(attName ==
"rhi")
1151 rhi = eval.Evaluate(attValue);
1153 else if(attName ==
"dz")
1155 dz = eval.Evaluate(attValue);
1163 new G4Paraboloid(name, dz, rlo, rhi);
1167 void G4GDMLReadSolids::PolyconeRead(
1168 const xercesc::DOMElement*
const polyconeElement)
1171 G4double lunit = 1.0;
1172 G4double aunit = 1.0;
1173 G4double startphi = 0.0;
1174 G4double deltaphi = 0.0;
1176 const xercesc::DOMNamedNodeMap*
const attributes =
1177 polyconeElement->getAttributes();
1178 XMLSize_t attributeCount = attributes->getLength();
1180 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1183 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1185 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1190 const xercesc::DOMAttr*
const attribute =
1191 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1192 if(attribute ==
nullptr)
1194 G4Exception(
"G4GDMLReadSolids::PolyconeRead()",
"InvalidRead",
1195 FatalException,
"No attribute found!");
1198 const G4String attName = Transcode(attribute->getName());
1199 const G4String attValue = Transcode(attribute->getValue());
1201 if(attName ==
"name")
1203 name = GenerateName(attValue);
1205 else if(attName ==
"lunit")
1207 lunit = G4UnitDefinition::GetValueOf(attValue);
1208 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1210 G4Exception(
"G4GDMLReadSolids::PolyconeRead()",
"InvalidRead",
1211 FatalException,
"Invalid unit for length!");
1214 else if(attName ==
"aunit")
1216 aunit = G4UnitDefinition::GetValueOf(attValue);
1217 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
1219 G4Exception(
"G4GDMLReadSolids::PolyconeRead()",
"InvalidRead",
1220 FatalException,
"Invalid unit for angle!");
1223 else if(attName ==
"startphi")
1225 startphi = eval.Evaluate(attValue);
1227 else if(attName ==
"deltaphi")
1229 deltaphi = eval.Evaluate(attValue);
1236 std::vector<zplaneType> zplaneList;
1238 for(xercesc::DOMNode* iter = polyconeElement->getFirstChild(); iter!=
nullptr;
1239 iter = iter->getNextSibling())
1241 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
1246 const xercesc::DOMElement*
const child =
1247 dynamic_cast<xercesc::DOMElement*
>(iter);
1248 if(child ==
nullptr)
1250 G4Exception(
"G4GDMLReadSolids::PolyconeRead()",
"InvalidRead",
1251 FatalException,
"No child found!");
1254 const G4String tag = Transcode(child->getTagName());
1258 zplaneList.push_back(ZplaneRead(child));
1262 G4int numZPlanes = zplaneList.size();
1264 G4double* rmin_array =
new G4double[numZPlanes];
1265 G4double* rmax_array =
new G4double[numZPlanes];
1266 G4double* z_array =
new G4double[numZPlanes];
1268 for(G4int i = 0; i < numZPlanes; ++i)
1270 rmin_array[i] = zplaneList[i].rmin * lunit;
1271 rmax_array[i] = zplaneList[i].rmax * lunit;
1272 z_array[i] = zplaneList[i].z * lunit;
1275 new G4Polycone(name, startphi, deltaphi, numZPlanes, z_array, rmin_array,
1278 delete[] rmin_array;
1279 delete[] rmax_array;
1284 void G4GDMLReadSolids::GenericPolyconeRead(
1285 const xercesc::DOMElement*
const polyconeElement)
1288 G4double lunit = 1.0;
1289 G4double aunit = 1.0;
1290 G4double startphi = 0.0;
1291 G4double deltaphi = 0.0;
1293 const xercesc::DOMNamedNodeMap*
const attributes =
1294 polyconeElement->getAttributes();
1295 XMLSize_t attributeCount = attributes->getLength();
1297 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1300 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1302 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1307 const xercesc::DOMAttr*
const attribute =
1308 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1309 if(attribute ==
nullptr)
1311 G4Exception(
"G4GDMLReadSolids::GenericPolyconeRead()",
"InvalidRead",
1312 FatalException,
"No attribute found!");
1315 const G4String attName = Transcode(attribute->getName());
1316 const G4String attValue = Transcode(attribute->getValue());
1318 if(attName ==
"name")
1320 name = GenerateName(attValue);
1322 else if(attName ==
"lunit")
1324 lunit = G4UnitDefinition::GetValueOf(attValue);
1325 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1327 G4Exception(
"G4GDMLReadSolids::GenericPolyconeRead()",
"InvalidRead",
1328 FatalException,
"Invalid unit for length!");
1331 else if(attName ==
"aunit")
1333 aunit = G4UnitDefinition::GetValueOf(attValue);
1334 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
1336 G4Exception(
"G4GDMLReadSolids::GenericPolyconeRead()",
"InvalidRead",
1337 FatalException,
"Invalid unit for angle!");
1340 else if(attName ==
"startphi")
1342 startphi = eval.Evaluate(attValue);
1344 else if(attName ==
"deltaphi")
1346 deltaphi = eval.Evaluate(attValue);
1353 std::vector<rzPointType> rzPointList;
1355 for(xercesc::DOMNode* iter = polyconeElement->getFirstChild();
1356 iter !=
nullptr; iter = iter->getNextSibling())
1358 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
1363 const xercesc::DOMElement*
const child =
1364 dynamic_cast<xercesc::DOMElement*
>(iter);
1365 if(child ==
nullptr)
1367 G4Exception(
"G4GDMLReadSolids::GenericPolyconeRead()",
"InvalidRead",
1368 FatalException,
"No child found!");
1371 const G4String tag = Transcode(child->getTagName());
1373 if(tag ==
"rzpoint")
1375 rzPointList.push_back(RZPointRead(child));
1379 G4int numRZPoints = rzPointList.size();
1381 G4double* r_array =
new G4double[numRZPoints];
1382 G4double* z_array =
new G4double[numRZPoints];
1384 for(G4int i = 0; i < numRZPoints; ++i)
1386 r_array[i] = rzPointList[i].r * lunit;
1387 z_array[i] = rzPointList[i].z * lunit;
1389 new G4GenericPolycone(name, startphi, deltaphi, numRZPoints, r_array,
1396 void G4GDMLReadSolids::PolyhedraRead(
1397 const xercesc::DOMElement*
const polyhedraElement)
1400 G4double lunit = 1.0;
1401 G4double aunit = 1.0;
1402 G4double startphi = 0.0;
1403 G4double deltaphi = 0.0;
1406 const xercesc::DOMNamedNodeMap*
const attributes =
1407 polyhedraElement->getAttributes();
1408 XMLSize_t attributeCount = attributes->getLength();
1410 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1413 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1415 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1420 const xercesc::DOMAttr*
const attribute =
1421 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1422 if(attribute ==
nullptr)
1424 G4Exception(
"G4GDMLReadSolids::PolyhedraRead()",
"InvalidRead",
1425 FatalException,
"No attribute found!");
1428 const G4String attName = Transcode(attribute->getName());
1429 const G4String attValue = Transcode(attribute->getValue());
1431 if(attName ==
"name")
1433 name = GenerateName(attValue);
1435 else if(attName ==
"lunit")
1437 lunit = G4UnitDefinition::GetValueOf(attValue);
1438 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1440 G4Exception(
"G4GDMLReadSolids::PolyhedraRead()",
"InvalidRead",
1441 FatalException,
"Invalid unit for length!");
1444 else if(attName ==
"aunit")
1446 aunit = G4UnitDefinition::GetValueOf(attValue);
1447 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
1449 G4Exception(
"G4GDMLReadSolids::PolyhedraRead()",
"InvalidRead",
1450 FatalException,
"Invalid unit for angle!");
1453 else if(attName ==
"startphi")
1455 startphi = eval.Evaluate(attValue);
1457 else if(attName ==
"deltaphi")
1459 deltaphi = eval.Evaluate(attValue);
1461 else if(attName ==
"numsides")
1463 numsides = eval.EvaluateInteger(attValue);
1470 std::vector<zplaneType> zplaneList;
1472 for(xercesc::DOMNode* iter = polyhedraElement->getFirstChild();
1473 iter !=
nullptr; iter = iter->getNextSibling())
1475 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
1480 const xercesc::DOMElement*
const child =
1481 dynamic_cast<xercesc::DOMElement*
>(iter);
1482 if(child ==
nullptr)
1484 G4Exception(
"G4GDMLReadSolids::PolyhedraRead()",
"InvalidRead",
1485 FatalException,
"No child found!");
1488 const G4String tag = Transcode(child->getTagName());
1492 zplaneList.push_back(ZplaneRead(child));
1496 G4int numZPlanes = zplaneList.size();
1498 G4double* rmin_array =
new G4double[numZPlanes];
1499 G4double* rmax_array =
new G4double[numZPlanes];
1500 G4double* z_array =
new G4double[numZPlanes];
1502 for(G4int i = 0; i < numZPlanes; ++i)
1504 rmin_array[i] = zplaneList[i].rmin * lunit;
1505 rmax_array[i] = zplaneList[i].rmax * lunit;
1506 z_array[i] = zplaneList[i].z * lunit;
1509 new G4Polyhedra(name, startphi, deltaphi, numsides, numZPlanes, z_array,
1510 rmin_array, rmax_array);
1512 delete[] rmin_array;
1513 delete[] rmax_array;
1518 void G4GDMLReadSolids::GenericPolyhedraRead(
1519 const xercesc::DOMElement*
const polyhedraElement)
1522 G4double lunit = 1.0;
1523 G4double aunit = 1.0;
1524 G4double startphi = 0.0;
1525 G4double deltaphi = 0.0;
1528 const xercesc::DOMNamedNodeMap*
const attributes =
1529 polyhedraElement->getAttributes();
1530 XMLSize_t attributeCount = attributes->getLength();
1532 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1535 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1537 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1542 const xercesc::DOMAttr*
const attribute =
1543 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1544 if(attribute ==
nullptr)
1546 G4Exception(
"G4GDMLReadSolids::GenericPolyhedraRead()",
"InvalidRead",
1547 FatalException,
"No attribute found!");
1550 const G4String attName = Transcode(attribute->getName());
1551 const G4String attValue = Transcode(attribute->getValue());
1553 if(attName ==
"name")
1555 name = GenerateName(attValue);
1557 else if(attName ==
"lunit")
1559 lunit = G4UnitDefinition::GetValueOf(attValue);
1560 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1562 G4Exception(
"G4GDMLReadSolids::GenericPolyhedraRead()",
"InvalidRead",
1563 FatalException,
"Invalid unit for length!");
1566 else if(attName ==
"aunit")
1568 aunit = G4UnitDefinition::GetValueOf(attValue);
1569 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
1571 G4Exception(
"G4GDMLReadSolids::GenericPolyhedraRead()",
"InvalidRead",
1572 FatalException,
"Invalid unit for angle!");
1575 else if(attName ==
"startphi")
1577 startphi = eval.Evaluate(attValue);
1579 else if(attName ==
"deltaphi")
1581 deltaphi = eval.Evaluate(attValue);
1583 else if(attName ==
"numsides")
1585 numsides = eval.EvaluateInteger(attValue);
1592 std::vector<rzPointType> rzpointList;
1594 for(xercesc::DOMNode* iter = polyhedraElement->getFirstChild();
1595 iter !=
nullptr; iter = iter->getNextSibling())
1597 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
1602 const xercesc::DOMElement*
const child =
1603 dynamic_cast<xercesc::DOMElement*
>(iter);
1604 if(child ==
nullptr)
1606 G4Exception(
"G4GDMLReadSolids::GenericPolyhedraRead()",
"InvalidRead",
1607 FatalException,
"No child found!");
1610 const G4String tag = Transcode(child->getTagName());
1612 if(tag ==
"rzpoint")
1614 rzpointList.push_back(RZPointRead(child));
1618 G4int numRZPoints = rzpointList.size();
1620 G4double* r_array =
new G4double[numRZPoints];
1621 G4double* z_array =
new G4double[numRZPoints];
1623 for(G4int i = 0; i < numRZPoints; ++i)
1625 r_array[i] = rzpointList[i].r * lunit;
1626 z_array[i] = rzpointList[i].z * lunit;
1629 new G4Polyhedra(name, startphi, deltaphi, numsides, numRZPoints, r_array,
1637 G4QuadrangularFacet* G4GDMLReadSolids::QuadrangularRead(
1638 const xercesc::DOMElement*
const quadrangularElement)
1640 G4ThreeVector vertex1;
1641 G4ThreeVector vertex2;
1642 G4ThreeVector vertex3;
1643 G4ThreeVector vertex4;
1644 G4FacetVertexType type = ABSOLUTE;
1645 G4double lunit = 1.0;
1647 const xercesc::DOMNamedNodeMap*
const attributes =
1648 quadrangularElement->getAttributes();
1649 XMLSize_t attributeCount = attributes->getLength();
1651 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1654 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1656 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1661 const xercesc::DOMAttr*
const attribute =
1662 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1663 if(attribute ==
nullptr)
1665 G4Exception(
"G4GDMLReadSolids::QuadrangularRead()",
"InvalidRead",
1666 FatalException,
"No attribute found!");
1669 const G4String attName = Transcode(attribute->getName());
1670 const G4String attValue = Transcode(attribute->getValue());
1672 if(attName ==
"vertex1")
1674 vertex1 = GetPosition(GenerateName(attValue));
1676 else if(attName ==
"vertex2")
1678 vertex2 = GetPosition(GenerateName(attValue));
1680 else if(attName ==
"vertex3")
1682 vertex3 = GetPosition(GenerateName(attValue));
1684 else if(attName ==
"vertex4")
1686 vertex4 = GetPosition(GenerateName(attValue));
1688 else if(attName ==
"lunit")
1690 lunit = G4UnitDefinition::GetValueOf(attValue);
1691 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1693 G4Exception(
"G4GDMLReadSolids::QuadrangularRead()",
"InvalidRead",
1694 FatalException,
"Invalid unit for length!");
1697 else if(attName ==
"type")
1699 if(attValue ==
"RELATIVE")
1706 return new G4QuadrangularFacet(vertex1 * lunit, vertex2 * lunit,
1707 vertex3 * lunit, vertex4 * lunit, type);
1711 void G4GDMLReadSolids::ReflectedSolidRead(
1712 const xercesc::DOMElement*
const reflectedSolidElement)
1715 G4double lunit = 1.0;
1716 G4double aunit = 1.0;
1718 G4ThreeVector scale(1.0, 1.0, 1.0);
1719 G4ThreeVector rotation;
1722 const xercesc::DOMNamedNodeMap*
const attributes =
1723 reflectedSolidElement->getAttributes();
1724 XMLSize_t attributeCount = attributes->getLength();
1726 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1729 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1731 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1736 const xercesc::DOMAttr*
const attribute =
1737 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1738 if(attribute ==
nullptr)
1740 G4Exception(
"G4GDMLReadSolids::ReflectedSolidRead()",
"InvalidRead",
1741 FatalException,
"No attribute found!");
1744 const G4String attName = Transcode(attribute->getName());
1745 const G4String attValue = Transcode(attribute->getValue());
1747 if(attName ==
"name")
1749 name = GenerateName(attValue);
1751 else if(attName ==
"lunit")
1753 lunit = G4UnitDefinition::GetValueOf(attValue);
1754 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
1756 G4Exception(
"G4GDMLReadSolids::ReflectedSolidRead()",
"InvalidRead",
1757 FatalException,
"Invalid unit for length!");
1760 else if(attName ==
"aunit")
1762 aunit = G4UnitDefinition::GetValueOf(attValue);
1763 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
1765 G4Exception(
"G4GDMLReadSolids::ReflectedSolidRead()",
"InvalidRead",
1766 FatalException,
"Invalid unit for angle!");
1769 else if(attName ==
"solid")
1771 solid = GenerateName(attValue);
1773 else if(attName ==
"sx")
1775 scale.setX(eval.Evaluate(attValue));
1777 else if(attName ==
"sy")
1779 scale.setY(eval.Evaluate(attValue));
1781 else if(attName ==
"sz")
1783 scale.setZ(eval.Evaluate(attValue));
1785 else if(attName ==
"rx")
1787 rotation.setX(eval.Evaluate(attValue));
1789 else if(attName ==
"ry")
1791 rotation.setY(eval.Evaluate(attValue));
1793 else if(attName ==
"rz")
1795 rotation.setZ(eval.Evaluate(attValue));
1797 else if(attName ==
"dx")
1799 position.setX(eval.Evaluate(attValue));
1801 else if(attName ==
"dy")
1803 position.setY(eval.Evaluate(attValue));
1805 else if(attName ==
"dz")
1807 position.setZ(eval.Evaluate(attValue));
1814 G4Transform3D
transform(GetRotationMatrix(rotation), position);
1817 new G4ReflectedSolid(name, GetSolid(solid),
transform);
1821 void G4GDMLReadSolids::ScaledSolidRead(
1822 const xercesc::DOMElement*
const scaledSolidElement)
1825 G4VSolid* solid =
nullptr;
1826 G4ThreeVector scale(1.0, 1.0, 1.0);
1828 const xercesc::DOMNamedNodeMap*
const attributes =
1829 scaledSolidElement->getAttributes();
1830 XMLSize_t attributeCount = attributes->getLength();
1832 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1835 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1837 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1842 const xercesc::DOMAttr*
const attribute =
1843 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1844 if(attribute ==
nullptr)
1846 G4Exception(
"G4GDMLReadSolids::ScaledSolidRead()",
"InvalidRead",
1847 FatalException,
"No attribute found!");
1850 const G4String attName = Transcode(attribute->getName());
1851 const G4String attValue = Transcode(attribute->getValue());
1853 if(attName ==
"name")
1855 name = GenerateName(attValue);
1859 for(xercesc::DOMNode* iter = scaledSolidElement->getFirstChild();
1860 iter !=
nullptr; iter = iter->getNextSibling())
1862 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
1867 const xercesc::DOMElement*
const child =
1868 dynamic_cast<xercesc::DOMElement*
>(iter);
1869 if(child ==
nullptr)
1871 G4Exception(
"G4GDMLReadSolids::ScaledSolidRead()",
"InvalidRead",
1872 FatalException,
"No child found!");
1875 const G4String tag = Transcode(child->getTagName());
1877 if(tag ==
"solidref")
1879 solid = GetSolid(GenerateName(RefRead(child)));
1881 else if(tag ==
"scale")
1883 VectorRead(child, scale);
1885 else if(tag ==
"scaleref")
1887 scale = GetScale(GenerateName(RefRead(child)));
1891 G4String error_msg =
"Unknown tag in scaled solid: " +
tag;
1892 G4Exception(
"G4GDMLReadSolids::ScaledSolidRead()",
"ReadError",
1893 FatalException, error_msg);
1898 G4Scale3D
transform = G4Scale3D(scale.x(), scale.y(), scale.z());
1900 new G4ScaledSolid(name, solid, transform);
1904 G4ExtrudedSolid::ZSection G4GDMLReadSolids::SectionRead(
1905 const xercesc::DOMElement*
const sectionElement, G4double lunit)
1907 G4double zPosition = 0.0;
1909 G4double scalingFactor = 1.0;
1911 const xercesc::DOMNamedNodeMap*
const attributes =
1912 sectionElement->getAttributes();
1913 XMLSize_t attributeCount = attributes->getLength();
1915 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1918 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1920 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1925 const xercesc::DOMAttr*
const attribute =
1926 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1927 if(attribute ==
nullptr)
1929 G4Exception(
"G4GDMLReadSolids::SectionRead()",
"InvalidRead",
1930 FatalException,
"No attribute found!");
1931 return G4ExtrudedSolid::ZSection(zPosition, Offset, scalingFactor);
1933 const G4String attName = Transcode(attribute->getName());
1934 const G4String attValue = Transcode(attribute->getValue());
1936 if(attName ==
"zPosition")
1938 zPosition = eval.Evaluate(attValue) * lunit;
1940 else if(attName ==
"xOffset")
1942 Offset.setX(eval.Evaluate(attValue) * lunit);
1944 else if(attName ==
"yOffset")
1946 Offset.setY(eval.Evaluate(attValue) * lunit);
1948 else if(attName ==
"scalingFactor")
1950 scalingFactor = eval.Evaluate(attValue);
1954 return G4ExtrudedSolid::ZSection(zPosition, Offset, scalingFactor);
1958 void G4GDMLReadSolids::SphereRead(
1959 const xercesc::DOMElement*
const sphereElement)
1962 G4double lunit = 1.0;
1963 G4double aunit = 1.0;
1964 G4double rmin = 0.0;
1965 G4double rmax = 0.0;
1966 G4double startphi = 0.0;
1967 G4double deltaphi = 0.0;
1968 G4double starttheta = 0.0;
1969 G4double deltatheta = 0.0;
1971 const xercesc::DOMNamedNodeMap*
const attributes =
1972 sphereElement->getAttributes();
1973 XMLSize_t attributeCount = attributes->getLength();
1975 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
1978 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1980 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1985 const xercesc::DOMAttr*
const attribute =
1986 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
1987 if(attribute ==
nullptr)
1989 G4Exception(
"G4GDMLReadSolids::SphereRead()",
"InvalidRead",
1990 FatalException,
"No attribute found!");
1993 const G4String attName = Transcode(attribute->getName());
1994 const G4String attValue = Transcode(attribute->getValue());
1996 if(attName ==
"name")
1998 name = GenerateName(attValue);
2000 else if(attName ==
"lunit")
2002 lunit = G4UnitDefinition::GetValueOf(attValue);
2003 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2005 G4Exception(
"G4GDMLReadSolids::SphereRead()",
"InvalidRead",
2006 FatalException,
"Invalid unit for length!");
2009 else if(attName ==
"aunit")
2011 aunit = G4UnitDefinition::GetValueOf(attValue);
2012 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
2014 G4Exception(
"G4GDMLReadSolids::SphereRead()",
"InvalidRead",
2015 FatalException,
"Invalid unit for angle!");
2018 else if(attName ==
"rmin")
2020 rmin = eval.Evaluate(attValue);
2022 else if(attName ==
"rmax")
2024 rmax = eval.Evaluate(attValue);
2026 else if(attName ==
"startphi")
2028 startphi = eval.Evaluate(attValue);
2030 else if(attName ==
"deltaphi")
2032 deltaphi = eval.Evaluate(attValue);
2034 else if(attName ==
"starttheta")
2036 starttheta = eval.Evaluate(attValue);
2038 else if(attName ==
"deltatheta")
2040 deltatheta = eval.Evaluate(attValue);
2048 starttheta *= aunit;
2049 deltatheta *= aunit;
2051 new G4Sphere(name, rmin, rmax, startphi, deltaphi, starttheta, deltatheta);
2055 void G4GDMLReadSolids::TessellatedRead(
2056 const xercesc::DOMElement*
const tessellatedElement)
2060 const xercesc::DOMNamedNodeMap*
const attributes =
2061 tessellatedElement->getAttributes();
2062 XMLSize_t attributeCount = attributes->getLength();
2064 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2067 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2069 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2074 const xercesc::DOMAttr*
const attribute =
2075 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2076 if(attribute ==
nullptr)
2078 G4Exception(
"G4GDMLReadSolids::TessellatedRead()",
"InvalidRead",
2079 FatalException,
"No attribute found!");
2082 const G4String attName = Transcode(attribute->getName());
2083 const G4String attValue = Transcode(attribute->getValue());
2085 if(attName ==
"name")
2087 name = GenerateName(attValue);
2091 G4TessellatedSolid* tessellated =
new G4TessellatedSolid(name);
2093 for(xercesc::DOMNode* iter = tessellatedElement->getFirstChild();
2094 iter !=
nullptr; iter = iter->getNextSibling())
2096 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
2101 const xercesc::DOMElement*
const child =
2102 dynamic_cast<xercesc::DOMElement*
>(iter);
2103 if(child ==
nullptr)
2105 G4Exception(
"G4GDMLReadSolids::TessellatedRead()",
"InvalidRead",
2106 FatalException,
"No child found!");
2109 const G4String tag = Transcode(child->getTagName());
2111 if(tag ==
"triangular")
2113 tessellated->AddFacet(TriangularRead(child));
2115 else if(tag ==
"quadrangular")
2117 tessellated->AddFacet(QuadrangularRead(child));
2121 tessellated->SetSolidClosed(
true);
2125 void G4GDMLReadSolids::TetRead(
const xercesc::DOMElement*
const tetElement)
2128 G4ThreeVector vertex1;
2129 G4ThreeVector vertex2;
2130 G4ThreeVector vertex3;
2131 G4ThreeVector vertex4;
2132 G4double lunit = 1.0;
2134 const xercesc::DOMNamedNodeMap*
const attributes =
2135 tetElement->getAttributes();
2136 XMLSize_t attributeCount = attributes->getLength();
2138 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2141 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2143 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2148 const xercesc::DOMAttr*
const attribute =
2149 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2150 if(attribute ==
nullptr)
2152 G4Exception(
"G4GDMLReadSolids::TetRead()",
"InvalidRead", FatalException,
2153 "No attribute found!");
2156 const G4String attName = Transcode(attribute->getName());
2157 const G4String attValue = Transcode(attribute->getValue());
2159 if(attName ==
"name")
2161 name = GenerateName(attValue);
2163 else if(attName ==
"lunit")
2165 lunit = G4UnitDefinition::GetValueOf(attValue);
2166 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2168 G4Exception(
"G4GDMLReadSolids::TetRead()",
"InvalidRead",
2169 FatalException,
"Invalid unit for length!");
2172 else if(attName ==
"vertex1")
2174 vertex1 = GetPosition(GenerateName(attValue));
2176 else if(attName ==
"vertex2")
2178 vertex2 = GetPosition(GenerateName(attValue));
2180 else if(attName ==
"vertex3")
2182 vertex3 = GetPosition(GenerateName(attValue));
2184 else if(attName ==
"vertex4")
2186 vertex4 = GetPosition(GenerateName(attValue));
2190 new G4Tet(name, vertex1 * lunit, vertex2 * lunit, vertex3 * lunit,
2195 void G4GDMLReadSolids::TorusRead(
const xercesc::DOMElement*
const torusElement)
2198 G4double lunit = 1.0;
2199 G4double aunit = 1.0;
2200 G4double rmin = 0.0;
2201 G4double rmax = 0.0;
2202 G4double rtor = 0.0;
2203 G4double startphi = 0.0;
2204 G4double deltaphi = 0.0;
2206 const xercesc::DOMNamedNodeMap*
const attributes =
2207 torusElement->getAttributes();
2208 XMLSize_t attributeCount = attributes->getLength();
2210 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2213 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2215 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2220 const xercesc::DOMAttr*
const attribute =
2221 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2222 if(attribute ==
nullptr)
2224 G4Exception(
"G4GDMLReadSolids::TorusRead()",
"InvalidRead",
2225 FatalException,
"No attribute found!");
2228 const G4String attName = Transcode(attribute->getName());
2229 const G4String attValue = Transcode(attribute->getValue());
2231 if(attName ==
"name")
2233 name = GenerateName(attValue);
2235 else if(attName ==
"lunit")
2237 lunit = G4UnitDefinition::GetValueOf(attValue);
2238 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2240 G4Exception(
"G4GDMLReadSolids::TorusRead()",
"InvalidRead",
2241 FatalException,
"Invalid unit for length!");
2244 else if(attName ==
"aunit")
2246 aunit = G4UnitDefinition::GetValueOf(attValue);
2247 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
2249 G4Exception(
"G4GDMLReadSolids::TorusRead()",
"InvalidRead",
2250 FatalException,
"Invalid unit for angle!");
2253 else if(attName ==
"rmin")
2255 rmin = eval.Evaluate(attValue);
2257 else if(attName ==
"rmax")
2259 rmax = eval.Evaluate(attValue);
2261 else if(attName ==
"rtor")
2263 rtor = eval.Evaluate(attValue);
2265 else if(attName ==
"startphi")
2267 startphi = eval.Evaluate(attValue);
2269 else if(attName ==
"deltaphi")
2271 deltaphi = eval.Evaluate(attValue);
2281 new G4Torus(name, rmin, rmax, rtor, startphi, deltaphi);
2285 void G4GDMLReadSolids::GenTrapRead(
2286 const xercesc::DOMElement*
const gtrapElement)
2289 G4double lunit = 1.0;
2291 G4double v1x = 0.0, v1y = 0.0, v2x = 0.0, v2y = 0.0, v3x = 0.0, v3y = 0.0,
2292 v4x = 0.0, v4y = 0.0, v5x = 0.0, v5y = 0.0, v6x = 0.0, v6y = 0.0,
2293 v7x = 0.0, v7y = 0.0, v8x = 0.0, v8y = 0.0;
2295 const xercesc::DOMNamedNodeMap*
const attributes =
2296 gtrapElement->getAttributes();
2297 XMLSize_t attributeCount = attributes->getLength();
2299 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2302 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2304 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2309 const xercesc::DOMAttr*
const attribute =
2310 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2311 if(attribute ==
nullptr)
2313 G4Exception(
"G4GDMLReadSolids::GenTrapRead()",
"InvalidRead",
2314 FatalException,
"No attribute found!");
2317 const G4String attName = Transcode(attribute->getName());
2318 const G4String attValue = Transcode(attribute->getValue());
2320 if(attName ==
"name")
2322 name = GenerateName(attValue);
2324 else if(attName ==
"lunit")
2326 lunit = G4UnitDefinition::GetValueOf(attValue);
2327 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2329 G4Exception(
"G4GDMLReadSolids::GenTrapRead()",
"InvalidRead",
2330 FatalException,
"Invalid unit for length!");
2333 else if(attName ==
"dz")
2335 dz = eval.Evaluate(attValue);
2337 else if(attName ==
"v1x")
2339 v1x = eval.Evaluate(attValue);
2341 else if(attName ==
"v1y")
2343 v1y = eval.Evaluate(attValue);
2345 else if(attName ==
"v2x")
2347 v2x = eval.Evaluate(attValue);
2349 else if(attName ==
"v2y")
2351 v2y = eval.Evaluate(attValue);
2353 else if(attName ==
"v3x")
2355 v3x = eval.Evaluate(attValue);
2357 else if(attName ==
"v3y")
2359 v3y = eval.Evaluate(attValue);
2361 else if(attName ==
"v4x")
2363 v4x = eval.Evaluate(attValue);
2365 else if(attName ==
"v4y")
2367 v4y = eval.Evaluate(attValue);
2369 else if(attName ==
"v5x")
2371 v5x = eval.Evaluate(attValue);
2373 else if(attName ==
"v5y")
2375 v5y = eval.Evaluate(attValue);
2377 else if(attName ==
"v6x")
2379 v6x = eval.Evaluate(attValue);
2381 else if(attName ==
"v6y")
2383 v6y = eval.Evaluate(attValue);
2385 else if(attName ==
"v7x")
2387 v7x = eval.Evaluate(attValue);
2389 else if(attName ==
"v7y")
2391 v7y = eval.Evaluate(attValue);
2393 else if(attName ==
"v8x")
2395 v8x = eval.Evaluate(attValue);
2397 else if(attName ==
"v8y")
2399 v8y = eval.Evaluate(attValue);
2404 std::vector<G4TwoVector> vertices;
2405 vertices.push_back(G4TwoVector(v1x * lunit, v1y * lunit));
2406 vertices.push_back(G4TwoVector(v2x * lunit, v2y * lunit));
2407 vertices.push_back(G4TwoVector(v3x * lunit, v3y * lunit));
2408 vertices.push_back(G4TwoVector(v4x * lunit, v4y * lunit));
2409 vertices.push_back(G4TwoVector(v5x * lunit, v5y * lunit));
2410 vertices.push_back(G4TwoVector(v6x * lunit, v6y * lunit));
2411 vertices.push_back(G4TwoVector(v7x * lunit, v7y * lunit));
2412 vertices.push_back(G4TwoVector(v8x * lunit, v8y * lunit));
2413 new G4GenericTrap(name, dz, vertices);
2417 void G4GDMLReadSolids::TrapRead(
const xercesc::DOMElement*
const trapElement)
2420 G4double lunit = 1.0;
2421 G4double aunit = 1.0;
2423 G4double theta = 0.0;
2428 G4double alpha1 = 0.0;
2432 G4double alpha2 = 0.0;
2434 const xercesc::DOMNamedNodeMap*
const attributes =
2435 trapElement->getAttributes();
2436 XMLSize_t attributeCount = attributes->getLength();
2438 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2441 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2443 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2448 const xercesc::DOMAttr*
const attribute =
2449 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2450 if(attribute ==
nullptr)
2452 G4Exception(
"G4GDMLReadSolids::TrapRead()",
"InvalidRead", FatalException,
2453 "No attribute found!");
2456 const G4String attName = Transcode(attribute->getName());
2457 const G4String attValue = Transcode(attribute->getValue());
2459 if(attName ==
"name")
2461 name = GenerateName(attValue);
2463 else if(attName ==
"lunit")
2465 lunit = G4UnitDefinition::GetValueOf(attValue);
2466 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2468 G4Exception(
"G4GDMLReadSolids::TrapRead()",
"InvalidRead",
2469 FatalException,
"Invalid unit for length!");
2472 else if(attName ==
"aunit")
2474 aunit = G4UnitDefinition::GetValueOf(attValue);
2475 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
2477 G4Exception(
"G4GDMLReadSolids::TrapRead()",
"InvalidRead",
2478 FatalException,
"Invalid unit for angle!");
2481 else if(attName ==
"z")
2483 z = eval.Evaluate(attValue);
2485 else if(attName ==
"theta")
2487 theta = eval.Evaluate(attValue);
2489 else if(attName ==
"phi")
2491 phi = eval.Evaluate(attValue);
2493 else if(attName ==
"y1")
2495 y1 = eval.Evaluate(attValue);
2497 else if(attName ==
"x1")
2499 x1 = eval.Evaluate(attValue);
2501 else if(attName ==
"x2")
2503 x2 = eval.Evaluate(attValue);
2505 else if(attName ==
"alpha1")
2507 alpha1 = eval.Evaluate(attValue);
2509 else if(attName ==
"y2")
2511 y2 = eval.Evaluate(attValue);
2513 else if(attName ==
"x3")
2515 x3 = eval.Evaluate(attValue);
2517 else if(attName ==
"x4")
2519 x4 = eval.Evaluate(attValue);
2521 else if(attName ==
"alpha2")
2523 alpha2 = eval.Evaluate(attValue);
2539 new G4Trap(name, z, theta, phi, y1, x1, x2, alpha1, y2, x3, x4, alpha2);
2543 void G4GDMLReadSolids::TrdRead(
const xercesc::DOMElement*
const trdElement)
2546 G4double lunit = 1.0;
2553 const xercesc::DOMNamedNodeMap*
const attributes =
2554 trdElement->getAttributes();
2555 XMLSize_t attributeCount = attributes->getLength();
2557 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2560 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2562 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2567 const xercesc::DOMAttr*
const attribute =
2568 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2569 if(attribute ==
nullptr)
2571 G4Exception(
"G4GDMLReadSolids::TrdRead()",
"InvalidRead", FatalException,
2572 "No attribute found!");
2575 const G4String attName = Transcode(attribute->getName());
2576 const G4String attValue = Transcode(attribute->getValue());
2578 if(attName ==
"name")
2580 name = GenerateName(attValue);
2582 else if(attName ==
"lunit")
2584 lunit = G4UnitDefinition::GetValueOf(attValue);
2585 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2587 G4Exception(
"G4GDMLReadSolids::TrdRead()",
"InvalidRead",
2588 FatalException,
"Invalid unit for length!");
2591 else if(attName ==
"x1")
2593 x1 = eval.Evaluate(attValue);
2595 else if(attName ==
"x2")
2597 x2 = eval.Evaluate(attValue);
2599 else if(attName ==
"y1")
2601 y1 = eval.Evaluate(attValue);
2603 else if(attName ==
"y2")
2605 y2 = eval.Evaluate(attValue);
2607 else if(attName ==
"z")
2609 z = eval.Evaluate(attValue);
2619 new G4Trd(name, x1, x2, y1, y2, z);
2623 G4TriangularFacet* G4GDMLReadSolids::TriangularRead(
2624 const xercesc::DOMElement*
const triangularElement)
2626 G4ThreeVector vertex1;
2627 G4ThreeVector vertex2;
2628 G4ThreeVector vertex3;
2629 G4FacetVertexType type = ABSOLUTE;
2630 G4double lunit = 1.0;
2632 const xercesc::DOMNamedNodeMap*
const attributes =
2633 triangularElement->getAttributes();
2634 XMLSize_t attributeCount = attributes->getLength();
2636 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2639 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2641 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2646 const xercesc::DOMAttr*
const attribute =
2647 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2648 if(attribute ==
nullptr)
2650 G4Exception(
"G4GDMLReadSolids::TriangularRead()",
"InvalidRead",
2651 FatalException,
"No attribute found!");
2654 const G4String attName = Transcode(attribute->getName());
2655 const G4String attValue = Transcode(attribute->getValue());
2657 if(attName ==
"vertex1")
2659 vertex1 = GetPosition(GenerateName(attValue));
2661 else if(attName ==
"vertex2")
2663 vertex2 = GetPosition(GenerateName(attValue));
2665 else if(attName ==
"vertex3")
2667 vertex3 = GetPosition(GenerateName(attValue));
2669 else if(attName ==
"lunit")
2671 lunit = G4UnitDefinition::GetValueOf(attValue);
2672 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2674 G4Exception(
"G4GDMLReadSolids::TriangularRead()",
"InvalidRead",
2675 FatalException,
"Invalid unit for length!");
2678 else if(attName ==
"type")
2680 if(attValue ==
"RELATIVE")
2687 return new G4TriangularFacet(vertex1 * lunit, vertex2 * lunit,
2688 vertex3 * lunit, type);
2692 void G4GDMLReadSolids::TubeRead(
const xercesc::DOMElement*
const tubeElement)
2695 G4double lunit = 1.0;
2696 G4double aunit = 1.0;
2697 G4double rmin = 0.0;
2698 G4double rmax = 0.0;
2700 G4double startphi = 0.0;
2701 G4double deltaphi = 0.0;
2703 const xercesc::DOMNamedNodeMap*
const attributes =
2704 tubeElement->getAttributes();
2705 XMLSize_t attributeCount = attributes->getLength();
2707 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2710 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2712 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2717 const xercesc::DOMAttr*
const attribute =
2718 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2719 if(attribute ==
nullptr)
2721 G4Exception(
"G4GDMLReadSolids::TubeRead()",
"InvalidRead", FatalException,
2722 "No attribute found!");
2725 const G4String attName = Transcode(attribute->getName());
2726 const G4String attValue = Transcode(attribute->getValue());
2728 if(attName ==
"name")
2730 name = GenerateName(attValue);
2732 else if(attName ==
"lunit")
2734 lunit = G4UnitDefinition::GetValueOf(attValue);
2735 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2737 G4Exception(
"G4GDMLReadSolids::TubeRead()",
"InvalidRead",
2738 FatalException,
"Invalid unit for length!");
2741 else if(attName ==
"aunit")
2743 aunit = G4UnitDefinition::GetValueOf(attValue);
2744 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
2746 G4Exception(
"G4GDMLReadSolids::TubeRead()",
"InvalidRead",
2747 FatalException,
"Invalid unit for angle!");
2750 else if(attName ==
"rmin")
2752 rmin = eval.Evaluate(attValue);
2754 else if(attName ==
"rmax")
2756 rmax = eval.Evaluate(attValue);
2758 else if(attName ==
"z")
2760 z = eval.Evaluate(attValue);
2762 else if(attName ==
"startphi")
2764 startphi = eval.Evaluate(attValue);
2766 else if(attName ==
"deltaphi")
2768 deltaphi = eval.Evaluate(attValue);
2778 new G4Tubs(name, rmin, rmax, z, startphi, deltaphi);
2782 void G4GDMLReadSolids::CutTubeRead(
2783 const xercesc::DOMElement*
const cuttubeElement)
2786 G4double lunit = 1.0;
2787 G4double aunit = 1.0;
2788 G4double rmin = 0.0;
2789 G4double rmax = 0.0;
2791 G4double startphi = 0.0;
2792 G4double deltaphi = 0.0;
2793 G4ThreeVector lowNorm(0);
2794 G4ThreeVector highNorm(0);
2796 const xercesc::DOMNamedNodeMap*
const attributes =
2797 cuttubeElement->getAttributes();
2798 XMLSize_t attributeCount = attributes->getLength();
2800 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2803 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2805 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2810 const xercesc::DOMAttr*
const attribute =
2811 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2812 if(attribute ==
nullptr)
2814 G4Exception(
"G4GDMLReadSolids::CutTubeRead()",
"InvalidRead",
2815 FatalException,
"No attribute found!");
2818 const G4String attName = Transcode(attribute->getName());
2819 const G4String attValue = Transcode(attribute->getValue());
2821 if(attName ==
"name")
2823 name = GenerateName(attValue);
2825 else if(attName ==
"lunit")
2827 lunit = G4UnitDefinition::GetValueOf(attValue);
2828 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2830 G4Exception(
"G4GDMLReadSolids::CutTubeRead()",
"InvalidRead",
2831 FatalException,
"Invalid unit for length!");
2834 else if(attName ==
"aunit")
2836 aunit = G4UnitDefinition::GetValueOf(attValue);
2837 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
2839 G4Exception(
"G4GDMLReadSolids::CutTubeRead()",
"InvalidRead",
2840 FatalException,
"Invalid unit for angle!");
2843 else if(attName ==
"rmin")
2845 rmin = eval.Evaluate(attValue);
2847 else if(attName ==
"rmax")
2849 rmax = eval.Evaluate(attValue);
2851 else if(attName ==
"z")
2853 z = eval.Evaluate(attValue);
2855 else if(attName ==
"startphi")
2857 startphi = eval.Evaluate(attValue);
2859 else if(attName ==
"deltaphi")
2861 deltaphi = eval.Evaluate(attValue);
2863 else if(attName ==
"lowX")
2865 lowNorm.setX(eval.Evaluate(attValue));
2867 else if(attName ==
"lowY")
2869 lowNorm.setY(eval.Evaluate(attValue));
2871 else if(attName ==
"lowZ")
2873 lowNorm.setZ(eval.Evaluate(attValue));
2875 else if(attName ==
"highX")
2877 highNorm.setX(eval.Evaluate(attValue));
2879 else if(attName ==
"highY")
2881 highNorm.setY(eval.Evaluate(attValue));
2883 else if(attName ==
"highZ")
2885 highNorm.setZ(eval.Evaluate(attValue));
2895 new G4CutTubs(name, rmin, rmax, z, startphi, deltaphi, lowNorm, highNorm);
2899 void G4GDMLReadSolids::TwistedboxRead(
2900 const xercesc::DOMElement*
const twistedboxElement)
2903 G4double lunit = 1.0;
2904 G4double aunit = 1.0;
2905 G4double PhiTwist = 0.0;
2910 const xercesc::DOMNamedNodeMap*
const attributes =
2911 twistedboxElement->getAttributes();
2912 XMLSize_t attributeCount = attributes->getLength();
2914 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
2917 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2919 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2924 const xercesc::DOMAttr*
const attribute =
2925 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
2926 if(attribute ==
nullptr)
2928 G4Exception(
"G4GDMLReadSolids::TwistedboxRead()",
"InvalidRead",
2929 FatalException,
"No attribute found!");
2932 const G4String attName = Transcode(attribute->getName());
2933 const G4String attValue = Transcode(attribute->getValue());
2935 if(attName ==
"name")
2937 name = GenerateName(attValue);
2939 else if(attName ==
"lunit")
2941 lunit = G4UnitDefinition::GetValueOf(attValue);
2942 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
2944 G4Exception(
"G4GDMLReadSolids::TwistedBoxRead()",
"InvalidRead",
2945 FatalException,
"Invalid unit for length!");
2948 else if(attName ==
"aunit")
2950 aunit = G4UnitDefinition::GetValueOf(attValue);
2951 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
2953 G4Exception(
"G4GDMLReadSolids::TwistedboxRead()",
"InvalidRead",
2954 FatalException,
"Invalid unit for angle!");
2957 else if(attName ==
"PhiTwist")
2959 PhiTwist = eval.Evaluate(attValue);
2961 else if(attName ==
"x")
2963 x = eval.Evaluate(attValue);
2965 else if(attName ==
"y")
2967 y = eval.Evaluate(attValue);
2969 else if(attName ==
"z")
2971 z = eval.Evaluate(attValue);
2980 new G4TwistedBox(name, PhiTwist, x, y, z);
2984 void G4GDMLReadSolids::TwistedtrapRead(
2985 const xercesc::DOMElement*
const twistedtrapElement)
2988 G4double lunit = 1.0;
2989 G4double aunit = 1.0;
2990 G4double PhiTwist = 0.0;
2992 G4double Theta = 0.0;
3000 G4double Alph = 0.0;
3002 const xercesc::DOMNamedNodeMap*
const attributes =
3003 twistedtrapElement->getAttributes();
3004 XMLSize_t attributeCount = attributes->getLength();
3006 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3009 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3011 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3016 const xercesc::DOMAttr*
const attribute =
3017 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
3018 if(attribute ==
nullptr)
3020 G4Exception(
"G4GDMLReadSolids::TwistedtrapRead()",
"InvalidRead",
3021 FatalException,
"No attribute found!");
3024 const G4String attName = Transcode(attribute->getName());
3025 const G4String attValue = Transcode(attribute->getValue());
3027 if(attName ==
"name")
3029 name = GenerateName(attValue);
3031 else if(attName ==
"lunit")
3033 lunit = G4UnitDefinition::GetValueOf(attValue);
3034 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
3036 G4Exception(
"G4GDMLReadSolids::TwistedtrapRead()",
"InvalidRead",
3037 FatalException,
"Invalid unit for length!");
3040 else if(attName ==
"aunit")
3042 aunit = G4UnitDefinition::GetValueOf(attValue);
3043 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
3045 G4Exception(
"G4GDMLReadSolids::TwistedtrapRead()",
"InvalidRead",
3046 FatalException,
"Invalid unit for angle!");
3049 else if(attName ==
"PhiTwist")
3051 PhiTwist = eval.Evaluate(attValue);
3053 else if(attName ==
"z")
3055 z = eval.Evaluate(attValue);
3057 else if(attName ==
"Theta")
3059 Theta = eval.Evaluate(attValue);
3061 else if(attName ==
"Phi")
3063 Phi = eval.Evaluate(attValue);
3065 else if(attName ==
"y1")
3067 y1 = eval.Evaluate(attValue);
3069 else if(attName ==
"x1")
3071 x1 = eval.Evaluate(attValue);
3073 else if(attName ==
"x2")
3075 x2 = eval.Evaluate(attValue);
3077 else if(attName ==
"y2")
3079 y2 = eval.Evaluate(attValue);
3081 else if(attName ==
"x3")
3083 x3 = eval.Evaluate(attValue);
3085 else if(attName ==
"x4")
3087 x4 = eval.Evaluate(attValue);
3089 else if(attName ==
"Alph")
3091 Alph = eval.Evaluate(attValue);
3107 new G4TwistedTrap(name, PhiTwist, z, Theta, Phi, y1, x1, x2, y2, x3, x4,
3112 void G4GDMLReadSolids::TwistedtrdRead(
3113 const xercesc::DOMElement*
const twistedtrdElement)
3116 G4double lunit = 1.0;
3117 G4double aunit = 1.0;
3123 G4double PhiTwist = 0.0;
3125 const xercesc::DOMNamedNodeMap*
const attributes =
3126 twistedtrdElement->getAttributes();
3127 XMLSize_t attributeCount = attributes->getLength();
3129 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3132 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3134 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3139 const xercesc::DOMAttr*
const attribute =
3140 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
3141 if(attribute ==
nullptr)
3143 G4Exception(
"G4GDMLReadSolids::TwistedtrdRead()",
"InvalidRead",
3144 FatalException,
"No attribute found!");
3147 const G4String attName = Transcode(attribute->getName());
3148 const G4String attValue = Transcode(attribute->getValue());
3150 if(attName ==
"name")
3152 name = GenerateName(attValue);
3154 else if(attName ==
"lunit")
3156 lunit = G4UnitDefinition::GetValueOf(attValue);
3157 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
3159 G4Exception(
"G4GDMLReadSolids::TwistedtrdRead()",
"InvalidRead",
3160 FatalException,
"Invalid unit for length!");
3163 else if(attName ==
"aunit")
3165 aunit = G4UnitDefinition::GetValueOf(attValue);
3166 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
3168 G4Exception(
"G4GDMLReadSolids::TwistedtrdRead()",
"InvalidRead",
3169 FatalException,
"Invalid unit for angle!");
3172 else if(attName ==
"x1")
3174 x1 = eval.Evaluate(attValue);
3176 else if(attName ==
"x2")
3178 x2 = eval.Evaluate(attValue);
3180 else if(attName ==
"y1")
3182 y1 = eval.Evaluate(attValue);
3184 else if(attName ==
"y2")
3186 y2 = eval.Evaluate(attValue);
3188 else if(attName ==
"z")
3190 z = eval.Evaluate(attValue);
3192 else if(attName ==
"PhiTwist")
3194 PhiTwist = eval.Evaluate(attValue);
3205 new G4TwistedTrd(name, x1, x2, y1, y2, z, PhiTwist);
3209 void G4GDMLReadSolids::TwistedtubsRead(
3210 const xercesc::DOMElement*
const twistedtubsElement)
3213 G4double lunit = 1.0;
3214 G4double aunit = 1.0;
3215 G4double twistedangle = 0.0;
3216 G4double endinnerrad = 0.0;
3217 G4double endouterrad = 0.0;
3218 G4double zlen = 0.0;
3220 G4double totphi = 0.0;
3221 G4double midinnerrad = 0.0;
3222 G4double midouterrad = 0.0;
3223 G4double positiveEndz = 0.0;
3224 G4double negativeEndz = 0.0;
3227 const xercesc::DOMNamedNodeMap*
const attributes =
3228 twistedtubsElement->getAttributes();
3229 XMLSize_t attributeCount = attributes->getLength();
3231 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3234 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3236 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3241 const xercesc::DOMAttr*
const attribute =
3242 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
3243 if(attribute ==
nullptr)
3245 G4Exception(
"G4GDMLReadSolids::TwistedtubsRead()",
"InvalidRead",
3246 FatalException,
"No attribute found!");
3249 const G4String attName = Transcode(attribute->getName());
3250 const G4String attValue = Transcode(attribute->getValue());
3252 if(attName ==
"name")
3254 name = GenerateName(attValue);
3256 else if(attName ==
"lunit")
3258 lunit = G4UnitDefinition::GetValueOf(attValue);
3259 if(G4UnitDefinition::GetCategory(attValue) !=
"Length")
3261 G4Exception(
"G4GDMLReadSolids::TwistedtubsRead()",
"InvalidRead",
3262 FatalException,
"Invalid unit for length!");
3265 else if(attName ==
"aunit")
3267 aunit = G4UnitDefinition::GetValueOf(attValue);
3268 if(G4UnitDefinition::GetCategory(attValue) !=
"Angle")
3270 G4Exception(
"G4GDMLReadSolids::TwistedtubsRead()",
"InvalidRead",
3271 FatalException,
"Invalid unit for angle!");
3274 else if(attName ==
"twistedangle")
3276 twistedangle = eval.Evaluate(attValue);
3278 else if(attName ==
"endinnerrad")
3280 endinnerrad = eval.Evaluate(attValue);
3282 else if(attName ==
"endouterrad")
3284 endouterrad = eval.Evaluate(attValue);
3286 else if(attName ==
"zlen")
3288 zlen = eval.Evaluate(attValue);
3290 else if(attName ==
"midinnerrad")
3292 midinnerrad = eval.Evaluate(attValue);
3294 else if(attName ==
"midouterrad")
3296 midouterrad = eval.Evaluate(attValue);
3298 else if(attName ==
"negativeEndz")
3300 negativeEndz = eval.Evaluate(attValue);
3302 else if(attName ==
"positiveEndz")
3304 positiveEndz = eval.Evaluate(attValue);
3306 else if(attName ==
"nseg")
3308 nseg = eval.Evaluate(attValue);
3310 else if(attName ==
"totphi")
3312 totphi = eval.Evaluate(attValue);
3314 else if(attName ==
"phi")
3316 phi = eval.Evaluate(attValue);
3320 twistedangle *= aunit;
3321 endinnerrad *= lunit;
3322 endouterrad *= lunit;
3323 zlen *= 0.5 * lunit;
3324 midinnerrad *= lunit;
3325 midouterrad *= lunit;
3326 positiveEndz *= lunit;
3327 negativeEndz *= lunit;
3334 new G4TwistedTubs(name, twistedangle, endinnerrad, endouterrad, zlen,
3337 new G4TwistedTubs(name, twistedangle, endinnerrad, endouterrad, zlen,
3343 new G4TwistedTubs(name, twistedangle, midinnerrad, midouterrad,
3344 negativeEndz, positiveEndz, nseg, totphi);
3346 new G4TwistedTubs(name, twistedangle, midinnerrad, midouterrad,
3347 negativeEndz, positiveEndz, phi);
3352 G4TwoVector G4GDMLReadSolids::TwoDimVertexRead(
3353 const xercesc::DOMElement*
const element, G4double lunit)
3357 const xercesc::DOMNamedNodeMap*
const attributes = element->getAttributes();
3358 XMLSize_t attributeCount = attributes->getLength();
3360 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3363 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3365 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3370 const xercesc::DOMAttr*
const attribute =
3371 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
3372 if(attribute ==
nullptr)
3374 G4Exception(
"G4GDMLReadSolids::TwoDimVertexRead()",
"InvalidRead",
3375 FatalException,
"No attribute found!");
3378 const G4String attName = Transcode(attribute->getName());
3379 const G4String attValue = Transcode(attribute->getValue());
3383 vec.setX(eval.Evaluate(attValue) * lunit);
3385 else if(attName ==
"y")
3387 vec.setY(eval.Evaluate(attValue) * lunit);
3395 G4GDMLReadSolids::zplaneType G4GDMLReadSolids::ZplaneRead(
3396 const xercesc::DOMElement*
const zplaneElement)
3398 zplaneType zplane = { 0., 0., 0. };
3400 const xercesc::DOMNamedNodeMap*
const attributes =
3401 zplaneElement->getAttributes();
3402 XMLSize_t attributeCount = attributes->getLength();
3404 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3407 xercesc::DOMNode* node = attributes->item(attribute_index);
3409 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3414 const xercesc::DOMAttr*
const attribute =
3415 dynamic_cast<xercesc::DOMAttr*
>(node);
3416 if(attribute ==
nullptr)
3418 G4Exception(
"G4GDMLReadSolids::ZplaneRead()",
"InvalidRead",
3419 FatalException,
"No attribute found!");
3422 const G4String attName = Transcode(attribute->getName());
3423 const G4String attValue = Transcode(attribute->getValue());
3425 if(attName ==
"rmin")
3427 zplane.rmin = eval.Evaluate(attValue);
3429 else if(attName ==
"rmax")
3431 zplane.rmax = eval.Evaluate(attValue);
3433 else if(attName ==
"z")
3435 zplane.z = eval.Evaluate(attValue);
3443 G4GDMLReadSolids::rzPointType G4GDMLReadSolids::RZPointRead(
3444 const xercesc::DOMElement*
const zplaneElement)
3446 rzPointType rzpoint = { 0., 0. };
3448 const xercesc::DOMNamedNodeMap*
const attributes =
3449 zplaneElement->getAttributes();
3450 XMLSize_t attributeCount = attributes->getLength();
3452 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3455 xercesc::DOMNode* node = attributes->item(attribute_index);
3457 if(node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3462 const xercesc::DOMAttr*
const attribute =
3463 dynamic_cast<xercesc::DOMAttr*
>(node);
3464 if(attribute ==
nullptr)
3466 G4Exception(
"G4GDMLReadSolids::RZPointRead()",
"InvalidRead",
3467 FatalException,
"No attribute found!");
3470 const G4String attName = Transcode(attribute->getName());
3471 const G4String attValue = Transcode(attribute->getValue());
3475 rzpoint.r = eval.Evaluate(attValue);
3477 else if(attName ==
"z")
3479 rzpoint.z = eval.Evaluate(attValue);
3487 void G4GDMLReadSolids::PropertyRead(
3488 const xercesc::DOMElement*
const propertyElement,
3489 G4OpticalSurface* opticalsurface)
3495 const xercesc::DOMNamedNodeMap*
const attributes =
3496 propertyElement->getAttributes();
3497 XMLSize_t attributeCount = attributes->getLength();
3499 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3502 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3504 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3509 const xercesc::DOMAttr*
const attribute =
3510 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
3511 if(attribute ==
nullptr)
3513 G4Exception(
"G4GDMLReadSolids::PropertyRead()",
"InvalidRead",
3514 FatalException,
"No attribute found!");
3517 const G4String attName = Transcode(attribute->getName());
3518 const G4String attValue = Transcode(attribute->getValue());
3520 if(attName ==
"name")
3522 name = GenerateName(attValue);
3524 else if(attName ==
"ref")
3526 matrix = GetMatrix(ref = attValue);
3547 G4MaterialPropertiesTable* matprop =
3548 opticalsurface->GetMaterialPropertiesTable();
3549 if(matprop ==
nullptr)
3551 matprop =
new G4MaterialPropertiesTable();
3552 opticalsurface->SetMaterialPropertiesTable(matprop);
3556 matprop->AddConstProperty(Strip(name), matrix.
Get(0, 0),
true);
3560 G4MaterialPropertyVector* propvect;
3561 G4String temp = name + ref;
3563 if(mapOfMatPropVects.find(temp) == mapOfMatPropVects.end())
3566 propvect =
new G4MaterialPropertyVector();
3567 for(
size_t i = 0; i < matrix.
GetRows(); i++)
3569 propvect->InsertValues(matrix.
Get(i, 0), matrix.
Get(i, 1));
3572 mapOfMatPropVects[temp] = propvect;
3576 propvect = mapOfMatPropVects[temp];
3579 matprop->AddProperty(Strip(name), propvect,
true);
3584 void G4GDMLReadSolids::OpticalSurfaceRead(
3585 const xercesc::DOMElement*
const opticalsurfaceElement)
3591 G4double
value = 0.0;
3593 const xercesc::DOMNamedNodeMap*
const attributes =
3594 opticalsurfaceElement->getAttributes();
3595 XMLSize_t attributeCount = attributes->getLength();
3597 for(XMLSize_t attribute_index = 0; attribute_index < attributeCount;
3600 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3602 if(attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3607 const xercesc::DOMAttr*
const attribute =
3608 dynamic_cast<xercesc::DOMAttr*
>(attribute_node);
3609 if(attribute ==
nullptr)
3611 G4Exception(
"G4GDMLReadSolids::OpticalSurfaceRead()",
"InvalidRead",
3612 FatalException,
"No attribute found!");
3615 const G4String attName = Transcode(attribute->getName());
3616 const G4String attValue = Transcode(attribute->getValue());
3618 if(attName ==
"name")
3620 name = GenerateName(attValue);
3622 else if(attName ==
"model")
3626 else if(attName ==
"finish")
3630 else if(attName ==
"type")
3634 else if(attName ==
"value")
3636 value = eval.Evaluate(attValue);
3640 G4OpticalSurfaceModel model;
3641 G4OpticalSurfaceFinish finish;
3644 if((smodel ==
"glisur") || (smodel ==
"0"))
3648 else if((smodel ==
"unified") || (smodel ==
"1"))
3652 else if((smodel ==
"LUT") || (smodel ==
"2"))
3656 else if((smodel ==
"DAVIS") || (smodel ==
"3"))
3665 if((sfinish ==
"polished") || (sfinish ==
"0"))
3669 else if((sfinish ==
"polishedfrontpainted") || (sfinish ==
"1"))
3671 finish = polishedfrontpainted;
3673 else if((sfinish ==
"polishedbackpainted") || (sfinish ==
"2"))
3675 finish = polishedbackpainted;
3677 else if((sfinish ==
"ground") || (sfinish ==
"3"))
3681 else if((sfinish ==
"groundfrontpainted") || (sfinish ==
"4"))
3683 finish = groundfrontpainted;
3685 else if((sfinish ==
"groundbackpainted") || (sfinish ==
"5"))
3687 finish = groundbackpainted;
3689 else if((sfinish ==
"polishedlumirrorair") || (sfinish ==
"6"))
3691 finish = polishedlumirrorair;
3693 else if((sfinish ==
"polishedlumirrorglue") || (sfinish ==
"7"))
3695 finish = polishedlumirrorglue;
3697 else if((sfinish ==
"polishedair") || (sfinish ==
"8"))
3699 finish = polishedair;
3701 else if((sfinish ==
"polishedteflonair") || (sfinish ==
"9"))
3703 finish = polishedteflonair;
3705 else if((sfinish ==
"polishedtioair") || (sfinish ==
"10"))
3707 finish = polishedtioair;
3709 else if((sfinish ==
"polishedtyvekair") || (sfinish ==
"11"))
3711 finish = polishedtyvekair;
3713 else if((sfinish ==
"polishedvm2000air") || (sfinish ==
"12"))
3715 finish = polishedvm2000air;
3717 else if((sfinish ==
"polishedvm2000glue") || (sfinish ==
"13"))
3719 finish = polishedvm2000glue;
3721 else if((sfinish ==
"etchedlumirrorair") || (sfinish ==
"14"))
3723 finish = etchedlumirrorair;
3725 else if((sfinish ==
"etchedlumirrorglue") || (sfinish ==
"15"))
3727 finish = etchedlumirrorglue;
3729 else if((sfinish ==
"etchedair") || (sfinish ==
"16"))
3733 else if((sfinish ==
"etchedteflonair") || (sfinish ==
"17"))
3735 finish = etchedteflonair;
3737 else if((sfinish ==
"etchedtioair") || (sfinish ==
"18"))
3739 finish = etchedtioair;
3741 else if((sfinish ==
"etchedtyvekair") || (sfinish ==
"19"))
3743 finish = etchedtyvekair;
3745 else if((sfinish ==
"etchedvm2000air") || (sfinish ==
"20"))
3747 finish = etchedvm2000air;
3749 else if((sfinish ==
"etchedvm2000glue") || (sfinish ==
"21"))
3751 finish = etchedvm2000glue;
3753 else if((sfinish ==
"groundlumirrorair") || (sfinish ==
"22"))
3755 finish = groundlumirrorair;
3757 else if((sfinish ==
"groundlumirrorglue") || (sfinish ==
"23"))
3759 finish = groundlumirrorglue;
3761 else if((sfinish ==
"groundair") || (sfinish ==
"24"))
3765 else if((sfinish ==
"groundteflonair") || (sfinish ==
"25"))
3767 finish = groundteflonair;
3769 else if((sfinish ==
"groundtioair") || (sfinish ==
"26"))
3771 finish = groundtioair;
3773 else if((sfinish ==
"groundtyvekair") || (sfinish ==
"27"))
3775 finish = groundtyvekair;
3777 else if((sfinish ==
"groundvm2000air") || (sfinish ==
"28"))
3779 finish = groundvm2000air;
3781 else if((sfinish ==
"groundvm2000glue") || (sfinish ==
"29"))
3783 finish = groundvm2000glue;
3785 else if((sfinish ==
"Rough_LUT") || (sfinish ==
"30"))
3789 else if((sfinish ==
"RoughTeflon_LUT") || (sfinish ==
"31"))
3791 finish = RoughTeflon_LUT;
3793 else if((sfinish ==
"RoughESR_LUT") || (sfinish ==
"32"))
3795 finish = RoughESR_LUT;
3797 else if((sfinish ==
"RoughESRGrease_LUT") || (sfinish ==
"33"))
3799 finish = RoughESRGrease_LUT;
3801 else if((sfinish ==
"Polished_LUT") || (sfinish ==
"34"))
3803 finish = Polished_LUT;
3805 else if((sfinish ==
"PolishedTeflon_LUT") || (sfinish ==
"35"))
3807 finish = PolishedTeflon_LUT;
3809 else if((sfinish ==
"PolishedESR_LUT") || (sfinish ==
"36"))
3811 finish = PolishedESR_LUT;
3813 else if((sfinish ==
"PolishedESRGrease_LUT") || (sfinish ==
"37"))
3815 finish = PolishedESRGrease_LUT;
3819 finish = Detector_LUT;
3822 if((stype ==
"dielectric_metal") || (stype ==
"0"))
3824 type = dielectric_metal;
3826 else if((stype ==
"dielectric_dielectric") || (stype ==
"1"))
3828 type = dielectric_dielectric;
3830 else if((stype ==
"dielectric_LUT") || (stype ==
"2"))
3832 type = dielectric_LUT;
3834 else if((stype ==
"dielectric_LUTDAVIS") || (stype ==
"3"))
3836 type = dielectric_LUTDAVIS;
3838 else if((stype ==
"dielectric_dichroic") || (stype ==
"4"))
3840 type = dielectric_dichroic;
3842 else if((stype ==
"firsov") || (stype ==
"5"))
3851 G4OpticalSurface* opticalsurface =
3852 new G4OpticalSurface(name, model, finish, type, value);
3854 for(xercesc::DOMNode* iter = opticalsurfaceElement->getFirstChild();
3855 iter !=
nullptr; iter = iter->getNextSibling())
3857 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
3862 const xercesc::DOMElement*
const child =
3863 dynamic_cast<xercesc::DOMElement*
>(iter);
3864 if(child ==
nullptr)
3866 G4Exception(
"G4GDMLReadSolids::OpticalSurfaceRead()",
"InvalidRead",
3867 FatalException,
"No child found!");
3870 const G4String tag = Transcode(child->getTagName());
3872 if(tag ==
"property")
3874 PropertyRead(child, opticalsurface);
3880 void G4GDMLReadSolids::SolidsRead(
3881 const xercesc::DOMElement*
const solidsElement)
3884 G4cout <<
"G4GDML: Reading solids..." << G4endl;
3886 for(xercesc::DOMNode* iter = solidsElement->getFirstChild(); iter !=
nullptr;
3887 iter = iter->getNextSibling())
3889 if(iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)
3894 const xercesc::DOMElement*
const child =
3895 dynamic_cast<xercesc::DOMElement*
>(iter);
3896 if(child ==
nullptr)
3898 G4Exception(
"G4GDMLReadSolids::SolidsRead()",
"InvalidRead",
3899 FatalException,
"No child found!");
3902 const G4String tag = Transcode(child->getTagName());
3907 else if(tag ==
"box")
3911 else if(tag ==
"cone")
3915 else if(tag ==
"elcone")
3919 else if(tag ==
"ellipsoid")
3921 EllipsoidRead(child);
3923 else if(tag ==
"eltube")
3927 else if(tag ==
"xtru")
3931 else if(tag ==
"hype")
3935 else if(tag ==
"intersection")
3937 BooleanRead(child, INTERSECTION);
3939 else if(tag ==
"multiUnion")
3941 MultiUnionRead(child);
3943 else if(tag ==
"orb")
3947 else if(tag ==
"para")
3951 else if(tag ==
"paraboloid")
3953 ParaboloidRead(child);
3955 else if(tag ==
"polycone")
3957 PolyconeRead(child);
3959 else if(tag ==
"genericPolycone")
3961 GenericPolyconeRead(child);
3963 else if(tag ==
"polyhedra")
3965 PolyhedraRead(child);
3967 else if(tag ==
"genericPolyhedra")
3969 GenericPolyhedraRead(child);
3971 else if(tag ==
"reflectedSolid")
3973 ReflectedSolidRead(child);
3975 else if(tag ==
"scaledSolid")
3977 ScaledSolidRead(child);
3979 else if(tag ==
"sphere")
3983 else if(tag ==
"subtraction")
3985 BooleanRead(child, SUBTRACTION);
3987 else if(tag ==
"tessellated")
3989 TessellatedRead(child);
3991 else if(tag ==
"tet")
3995 else if(tag ==
"torus")
3999 else if(tag ==
"arb8")
4003 else if(tag ==
"trap")
4007 else if(tag ==
"trd")
4011 else if(tag ==
"tube")
4015 else if(tag ==
"cutTube")
4019 else if(tag ==
"twistedbox")
4021 TwistedboxRead(child);
4023 else if(tag ==
"twistedtrap")
4025 TwistedtrapRead(child);
4027 else if(tag ==
"twistedtrd")
4029 TwistedtrdRead(child);
4031 else if(tag ==
"twistedtubs")
4033 TwistedtubsRead(child);
4035 else if(tag ==
"union")
4037 BooleanRead(child, UNION);
4039 else if(tag ==
"opticalsurface")
4041 OpticalSurfaceRead(child);
4043 else if(tag ==
"loop")
4045 LoopRead(child, &G4GDMLRead::SolidsRead);
4049 G4String error_msg =
"Unknown tag in solids: " +
tag;
4050 G4Exception(
"G4GDMLReadSolids::SolidsRead()",
"ReadError", FatalException,
4057 G4VSolid* G4GDMLReadSolids::GetSolid(
const G4String& ref)
const
4060 ->
GetSolid(ref,
false,reverseSearch);
4062 if(solidPtr ==
nullptr)
4064 G4String error_msg =
"Referenced solid '" + ref +
"' was not found!";
4065 G4Exception(
"G4GDMLReadSolids::GetSolid()",
"ReadError", FatalException,
4073 G4SurfaceProperty* G4GDMLReadSolids::GetSurfaceProperty(
4074 const G4String& ref)
const
4076 const G4SurfacePropertyTable* surfaceList =
4077 G4SurfaceProperty::GetSurfacePropertyTable();
4078 const std::size_t surfaceCount = surfaceList->size();
4080 for(std::size_t i = 0; i < surfaceCount; ++i)
4082 if((*surfaceList)[i]->GetName() == ref)
4084 return (*surfaceList)[i];
4088 G4String error_msg =
4089 "Referenced optical surface '" + ref +
"' was not found!";
4090 G4Exception(
"G4GDMLReadSolids::GetSurfaceProperty()",
"ReadError",
4091 FatalException, error_msg);