93 xercesc::DOMElement* multiUnionElement =
NewElement(tag);
94 multiUnionElement->setAttributeNode(
NewAttribute(
"name",name));
96 for (
G4int i=0; i<numSolids; ++i)
109 rot3d.
yx(), rot3d.
yy(), rot3d.
yz(),
110 rot3d.
zx(), rot3d.
zy(), rot3d.
zz()));
115 std::ostringstream os; os << i+1;
117 xercesc::DOMElement* solidElement =
NewElement(
"solid");
118 solidElement->setAttributeNode(
NewAttribute(
"ref",solidref));
119 xercesc::DOMElement* multiUnionNodeElement =
NewElement(
"multiUnionNode");
120 multiUnionNodeElement->setAttributeNode(
NewAttribute(
"name", nodeName));
121 multiUnionNodeElement->appendChild(solidElement);
134 multiUnionElement->appendChild(multiUnionNodeElement);
137 solElement->appendChild(multiUnionElement);
148 if (dynamic_cast<const G4IntersectionSolid*>(
boolean))
149 { tag =
"intersection"; }
else
150 if (dynamic_cast<const G4SubtractionSolid*>(
boolean))
151 { tag =
"subtraction"; }
else
152 if (dynamic_cast<const G4UnionSolid*>(
boolean))
155 G4VSolid* firstPtr =
const_cast<G4VSolid*
>(
boolean->GetConstituentSolid(0));
156 G4VSolid* secondPtr =
const_cast<G4VSolid*
>(
boolean->GetConstituentSolid(1));
166 G4String ErrorMessage =
"The referenced solid '"
168 +
"in the Boolean shape '" +
169 +
boolean->GetName() +
170 +
"' was displaced too many times!";
177 firstpos += disp->GetObjectTranslation();
178 firstrot +=
GetAngles(disp->GetObjectRotation());
179 firstPtr = disp->GetConstituentMovedSolid();
190 G4String ErrorMessage =
"The referenced solid '"
192 +
"in the Boolean shape '" +
193 +
boolean->GetName() +
194 +
"' was displaced too many times!";
201 pos += disp->GetObjectTranslation();
202 rot +=
GetAngles(disp->GetObjectRotation());
203 secondPtr = disp->GetConstituentMovedSolid();
217 xercesc::DOMElement* booleanElement =
NewElement(tag);
218 booleanElement->setAttributeNode(
NewAttribute(
"name",name));
219 xercesc::DOMElement* firstElement =
NewElement(
"first");
220 firstElement->setAttributeNode(
NewAttribute(
"ref",firstref));
221 booleanElement->appendChild(firstElement);
222 xercesc::DOMElement* secondElement =
NewElement(
"second");
223 secondElement->setAttributeNode(
NewAttribute(
"ref",secondref));
224 booleanElement->appendChild(secondElement);
225 solElement->appendChild(booleanElement);
272 xercesc::DOMElement* scaledElement =
NewElement(tag);
273 scaledElement->setAttributeNode(
NewAttribute(
"name",name));
275 xercesc::DOMElement* solidElement =
NewElement(
"solidref");
276 solidElement->setAttributeNode(
NewAttribute(
"ref",solidref));
277 scaledElement->appendChild(solidElement);
283 ScaleWrite(scaledElement, name+
"_scl", sclVector);
286 solElement->appendChild(scaledElement);
295 xercesc::DOMElement* boxElement =
NewElement(
"box");
296 boxElement->setAttributeNode(
NewAttribute(
"name",name));
300 boxElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
301 solElement->appendChild(boxElement);
309 xercesc::DOMElement* coneElement =
NewElement(
"cone");
310 coneElement->setAttributeNode(
NewAttribute(
"name",name));
325 coneElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
326 coneElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
327 solElement->appendChild(coneElement);
336 xercesc::DOMElement* elconeElement =
NewElement(
"elcone");
337 elconeElement->setAttributeNode(
NewAttribute(
"name",name));
342 elconeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
343 solElement->appendChild(elconeElement);
352 xercesc::DOMElement* ellipsoidElement =
NewElement(
"ellipsoid");
353 ellipsoidElement->setAttributeNode(
NewAttribute(
"name",name));
366 solElement->appendChild(ellipsoidElement);
375 xercesc::DOMElement* eltubeElement =
NewElement(
"eltube");
376 eltubeElement->setAttributeNode(
NewAttribute(
"name",name));
380 eltubeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
381 solElement->appendChild(eltubeElement);
390 xercesc::DOMElement* xtruElement =
NewElement(
"xtru");
391 xtruElement->setAttributeNode(
NewAttribute(
"name",name));
392 xtruElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
393 solElement->appendChild(xtruElement);
397 for (
G4int i=0;i<NumVertex;i++)
399 xercesc::DOMElement* twoDimVertexElement =
NewElement(
"twoDimVertex");
400 xtruElement->appendChild(twoDimVertexElement);
404 twoDimVertexElement->setAttributeNode(
NewAttribute(
"x",vertex.
x()/
mm));
405 twoDimVertexElement->setAttributeNode(
NewAttribute(
"y",vertex.
y()/
mm));
410 for (
G4int i=0;i<NumSection;i++)
412 xercesc::DOMElement* sectionElement =
NewElement(
"section");
413 xtruElement->appendChild(sectionElement);
417 sectionElement->setAttributeNode(
NewAttribute(
"zOrder",i));
433 xercesc::DOMElement* hypeElement =
NewElement(
"hype");
434 hypeElement->setAttributeNode(
NewAttribute(
"name",name));
445 hypeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
446 hypeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
447 solElement->appendChild(hypeElement);
455 xercesc::DOMElement* orbElement =
NewElement(
"orb");
456 orbElement->setAttributeNode(
NewAttribute(
"name",name));
458 orbElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
459 solElement->appendChild(orbElement);
472 xercesc::DOMElement* paraElement =
NewElement(
"para");
473 paraElement->setAttributeNode(
NewAttribute(
"name",name));
483 paraElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
484 paraElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
485 solElement->appendChild(paraElement);
494 xercesc::DOMElement* paraboloidElement =
NewElement(
"paraboloid");
495 paraboloidElement->setAttributeNode(
NewAttribute(
"name",name));
502 paraboloidElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
503 solElement->appendChild(paraboloidElement);
511 xercesc::DOMElement* polyconeElement =
NewElement(
"polycone");
512 polyconeElement->setAttributeNode(
NewAttribute(
"name",name));
513 polyconeElement->setAttributeNode(
NewAttribute(
"startphi",
515 polyconeElement->setAttributeNode(
NewAttribute(
"deltaphi",
517 polyconeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
518 polyconeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
519 solElement->appendChild(polyconeElement);
526 for (
size_t i=0; i<num_zplanes; i++)
528 ZplaneWrite(polyconeElement,z_array[i],rmin_array[i],rmax_array[i]);
539 xercesc::DOMElement* polyconeElement =
NewElement(
"genericPolycone");
541 polyconeElement->setAttributeNode(
NewAttribute(
"name",name));
542 polyconeElement->setAttributeNode(
NewAttribute(
"startphi",
544 polyconeElement->setAttributeNode(
NewAttribute(
"deltaphi",
546 polyconeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
547 polyconeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
548 solElement->appendChild(polyconeElement);
551 for (
size_t i=0; i<num_rzpoints; i++)
566 xercesc::DOMElement* polyhedraElement =
NewElement(
"polyhedra");
567 polyhedraElement->setAttributeNode(
NewAttribute(
"name",name));
568 polyhedraElement->setAttributeNode(
NewAttribute(
"startphi",
570 polyhedraElement->setAttributeNode(
NewAttribute(
"deltaphi",
572 polyhedraElement->setAttributeNode(
NewAttribute(
"numsides",
574 polyhedraElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
575 polyhedraElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
576 solElement->appendChild(polyhedraElement);
578 const size_t num_zplanes =
589 for (
size_t i=0;i<num_zplanes;i++)
592 rmin_array[i]*convertRad, rmax_array[i]*convertRad);
597 xercesc::DOMElement* polyhedraElement =
NewElement(
"genericPolyhedra");
598 polyhedraElement->setAttributeNode(
NewAttribute(
"name",name));
599 polyhedraElement->setAttributeNode(
NewAttribute(
"startphi",
601 polyhedraElement->setAttributeNode(
NewAttribute(
"deltaphi",
603 polyhedraElement->setAttributeNode(
NewAttribute(
"numsides",
605 polyhedraElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
606 polyhedraElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
607 solElement->appendChild(polyhedraElement);
611 for (
size_t i=0;i<num_rzpoints;i++)
625 xercesc::DOMElement* sphereElement =
NewElement(
"sphere");
626 sphereElement->setAttributeNode(
NewAttribute(
"name",name));
631 sphereElement->setAttributeNode(
NewAttribute(
"startphi",
633 sphereElement->setAttributeNode(
NewAttribute(
"deltaphi",
635 sphereElement->setAttributeNode(
NewAttribute(
"starttheta",
637 sphereElement->setAttributeNode(
NewAttribute(
"deltatheta",
639 sphereElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
640 sphereElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
641 solElement->appendChild(sphereElement);
651 xercesc::DOMElement* tessellatedElement =
NewElement(
"tessellated");
652 tessellatedElement->setAttributeNode(
NewAttribute(
"name",name));
653 tessellatedElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
654 tessellatedElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
655 solElement->appendChild(tessellatedElement);
657 std::map<G4ThreeVector, G4String, G4ThreeVectorCompare> vertexMap;
660 size_t NumVertex = 0;
662 for (
size_t i=0;i<NumFacets;i++)
669 if (NumVertexPerFacet==3) { FacetTag=
"triangular"; }
else
670 if (NumVertexPerFacet==4) { FacetTag=
"quadrangular"; }
673 G4Exception(
"G4GDMLWriteSolids::TessellatedWrite()",
"InvalidSetup",
677 xercesc::DOMElement* facetElement =
NewElement(FacetTag);
678 tessellatedElement->appendChild(facetElement);
680 for (
size_t j=0; j<NumVertexPerFacet; j++)
682 std::stringstream name_stream;
683 std::stringstream ref_stream;
685 name_stream <<
"vertex" << (j+1);
686 ref_stream << solid_name <<
"_v" << NumVertex;
699 if(vertexMap.find(vertex) != vertexMap.end())
701 ref = vertexMap[vertex];
705 vertexMap.insert(std::make_pair(vertex,ref));
712 facetElement->setAttributeNode(
NewAttribute(fname,ref));
723 std::vector<G4ThreeVector> vertexList = tet->
GetVertices();
725 xercesc::DOMElement* tetElement =
NewElement(
"tet");
726 tetElement->setAttributeNode(
NewAttribute(
"name",name));
727 tetElement->setAttributeNode(
NewAttribute(
"vertex1",solid_name+
"_v1"));
728 tetElement->setAttributeNode(
NewAttribute(
"vertex2",solid_name+
"_v2"));
729 tetElement->setAttributeNode(
NewAttribute(
"vertex3",solid_name+
"_v3"));
730 tetElement->setAttributeNode(
NewAttribute(
"vertex4",solid_name+
"_v4"));
731 tetElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
732 solElement->appendChild(tetElement);
745 xercesc::DOMElement* torusElement =
NewElement(
"torus");
746 torusElement->setAttributeNode(
NewAttribute(
"name",name));
754 torusElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
755 torusElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
756 solElement->appendChild(torusElement);
765 std::vector<G4TwoVector> vertices = gtrap->
GetVertices();
767 xercesc::DOMElement* gtrapElement =
NewElement(
"arb8");
768 gtrapElement->setAttributeNode(
NewAttribute(
"name",name));
771 gtrapElement->setAttributeNode(
NewAttribute(
"v1x", vertices[0].
x()));
772 gtrapElement->setAttributeNode(
NewAttribute(
"v1y", vertices[0].
y()));
773 gtrapElement->setAttributeNode(
NewAttribute(
"v2x", vertices[1].
x()));
774 gtrapElement->setAttributeNode(
NewAttribute(
"v2y", vertices[1].
y()));
775 gtrapElement->setAttributeNode(
NewAttribute(
"v3x", vertices[2].
x()));
776 gtrapElement->setAttributeNode(
NewAttribute(
"v3y", vertices[2].
y()));
777 gtrapElement->setAttributeNode(
NewAttribute(
"v4x", vertices[3].
x()));
778 gtrapElement->setAttributeNode(
NewAttribute(
"v4y", vertices[3].
y()));
779 gtrapElement->setAttributeNode(
NewAttribute(
"v5x", vertices[4].
x()));
780 gtrapElement->setAttributeNode(
NewAttribute(
"v5y", vertices[4].
y()));
781 gtrapElement->setAttributeNode(
NewAttribute(
"v6x", vertices[5].
x()));
782 gtrapElement->setAttributeNode(
NewAttribute(
"v6y", vertices[5].
y()));
783 gtrapElement->setAttributeNode(
NewAttribute(
"v7x", vertices[6].
x()));
784 gtrapElement->setAttributeNode(
NewAttribute(
"v7y", vertices[6].
y()));
785 gtrapElement->setAttributeNode(
NewAttribute(
"v8x", vertices[7].
x()));
786 gtrapElement->setAttributeNode(
NewAttribute(
"v8y", vertices[7].
y()));
787 gtrapElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
788 solElement->appendChild(gtrapElement);
802 xercesc::DOMElement* trapElement =
NewElement(
"trap");
803 trapElement->setAttributeNode(
NewAttribute(
"name",name));
822 trapElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
823 trapElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
824 solElement->appendChild(trapElement);
832 xercesc::DOMElement* trdElement =
NewElement(
"trd");
833 trdElement->setAttributeNode(
NewAttribute(
"name",name));
844 trdElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
845 solElement->appendChild(trdElement);
853 xercesc::DOMElement* tubeElement =
NewElement(
"tube");
854 tubeElement->setAttributeNode(
NewAttribute(
"name",name));
865 tubeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
866 tubeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
867 solElement->appendChild(tubeElement);
875 xercesc::DOMElement* cuttubeElement =
NewElement(
"cutTube");
876 cuttubeElement->setAttributeNode(
NewAttribute(
"name",name));
883 cuttubeElement->setAttributeNode(
NewAttribute(
"startphi",
885 cuttubeElement->setAttributeNode(
NewAttribute(
"deltaphi",
899 cuttubeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
900 cuttubeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
901 solElement->appendChild(cuttubeElement);
910 xercesc::DOMElement* twistedboxElement =
NewElement(
"twistedbox");
911 twistedboxElement->setAttributeNode(
NewAttribute(
"name",name));
918 twistedboxElement->setAttributeNode(
NewAttribute(
"PhiTwist",
920 twistedboxElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
921 twistedboxElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
922 solElement->appendChild(twistedboxElement);
931 xercesc::DOMElement* twistedtrapElement =
NewElement(
"twistedtrap");
932 twistedtrapElement->setAttributeNode(
NewAttribute(
"name",name));
947 twistedtrapElement->setAttributeNode(
NewAttribute(
"Alph",
949 twistedtrapElement->setAttributeNode(
NewAttribute(
"Theta",
951 twistedtrapElement->setAttributeNode(
NewAttribute(
"Phi",
953 twistedtrapElement->setAttributeNode(
NewAttribute(
"PhiTwist",
955 twistedtrapElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
956 twistedtrapElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
958 solElement->appendChild(twistedtrapElement);
967 xercesc::DOMElement* twistedtrdElement =
NewElement(
"twistedtrd");
968 twistedtrdElement->setAttributeNode(
NewAttribute(
"name",name));
979 twistedtrdElement->setAttributeNode(
NewAttribute(
"PhiTwist",
981 twistedtrdElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
982 twistedtrdElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
983 solElement->appendChild(twistedtrdElement);
992 xercesc::DOMElement* twistedtubsElement =
NewElement(
"twistedtubs");
993 twistedtubsElement->setAttributeNode(
NewAttribute(
"name",name));
994 twistedtubsElement->setAttributeNode(
NewAttribute(
"twistedangle",
996 twistedtubsElement->setAttributeNode(
NewAttribute(
"midinnerrad",
998 twistedtubsElement->setAttributeNode(
NewAttribute(
"midouterrad",
1000 twistedtubsElement->setAttributeNode(
NewAttribute(
"negativeEndz",
1002 twistedtubsElement->setAttributeNode(
NewAttribute(
"positiveEndz",
1004 twistedtubsElement->setAttributeNode(
NewAttribute(
"phi",
1006 twistedtubsElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
1007 twistedtubsElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
1008 solElement->appendChild(twistedtubsElement);
1015 xercesc::DOMElement* zplaneElement =
NewElement(
"zplane");
1019 element->appendChild(zplaneElement);
1026 xercesc::DOMElement* rzpointElement =
NewElement(
"rzpoint");
1029 element->appendChild(rzpointElement);
1036 xercesc::DOMElement* optElement =
NewElement(
"opticalsurface");
1041 optElement->setAttributeNode(
NewAttribute(
"name", name));
1042 optElement->setAttributeNode(
NewAttribute(
"model", smodel));
1045 optElement->setAttributeNode(
NewAttribute(
"value", sval));
1054 solElement->appendChild(optElement);
1060 xercesc::DOMElement* propElement;
1066 std::map<
G4int, G4PhysicsOrderedFreeVector*,
1067 std::less<G4int> >::const_iterator mpos;
1069 std::less<G4int> >::const_iterator cpos;
1070 for (mpos=pmap->begin(); mpos!=pmap->end(); mpos++)
1082 optElement->appendChild(propElement);
1086 G4String warn_message =
"Null pointer for material property -"
1088 +
"- of optical surface -" + surf->
GetName() +
"- !";
1089 G4Exception(
"G4GDMLWriteSolids::PropertyWrite()",
"NullPointer",
1094 for (cpos=cmap->begin(); cpos!=cmap->end(); cpos++)
1101 xercesc::DOMElement* constElement =
NewElement(
"constant");
1104 constElement->setAttributeNode(
NewAttribute(
"value", cpos->second));
1106 optElement->appendChild(propElement);
1123 for (
size_t i=0; i<
solidList.size(); i++)
1125 if (
solidList[i] == solidPtr) {
return; }
1131 = dynamic_cast<const G4BooleanSolid*>(solidPtr))
1134 = dynamic_cast<const G4ScaledSolid*>(solidPtr))
1141 {
const G4Box*
const boxPtr
1142 =
static_cast<const G4Box*
>(solidPtr);
1145 {
const G4Cons*
const conePtr
1146 =
static_cast<const G4Cons*
>(solidPtr);
1165 {
const G4Hype*
const hypePtr
1166 =
static_cast<const G4Hype*
>(solidPtr);
1169 {
const G4Orb*
const orbPtr
1170 =
static_cast<const G4Orb*
>(solidPtr);
1173 {
const G4Para*
const paraPtr
1174 =
static_cast<const G4Para*
>(solidPtr);
1194 =
static_cast<const G4Sphere*
>(solidPtr);
1201 {
const G4Tet*
const tetPtr
1202 =
static_cast<const G4Tet*
>(solidPtr);
1205 {
const G4Torus*
const torusPtr
1206 =
static_cast<const G4Torus*
>(solidPtr);
1213 {
const G4Trap*
const trapPtr
1214 =
static_cast<const G4Trap*
>(solidPtr);
1217 {
const G4Trd*
const trdPtr
1218 =
static_cast<const G4Trd*
>(solidPtr);
1221 {
const G4Tubs*
const tubePtr
1222 =
static_cast<const G4Tubs*
>(solidPtr);
1226 =
static_cast<const G4CutTubs*
>(solidPtr);
1248 G4Exception(
"G4GDMLWriteSolids::AddSolid()",
"WriteError",