87 if (dynamic_cast<const G4IntersectionSolid*>(
boolean))
88 { tag =
"intersection"; }
else
89 if (dynamic_cast<const G4SubtractionSolid*>(
boolean))
90 { tag =
"subtraction"; }
else
91 if (dynamic_cast<const G4UnionSolid*>(
boolean))
95 G4VSolid* secondPtr =
const_cast<G4VSolid*
>(
boolean->GetConstituentSolid(1));
105 G4String ErrorMessage =
"The referenced solid '"
107 +
"in the Boolean shape '" +
108 +
boolean->GetName() +
109 +
"' was displaced too many times!";
116 firstpos += disp->GetObjectTranslation();
117 firstrot += firstrot +
GetAngles(disp->GetObjectRotation());
118 firstPtr = disp->GetConstituentMovedSolid();
129 G4String ErrorMessage =
"The referenced solid '"
131 +
"in the Boolean shape '" +
132 +
boolean->GetName() +
133 +
"' was displaced too many times!";
140 pos += disp->GetObjectTranslation();
141 rot +=
GetAngles(disp->GetObjectRotation());
142 secondPtr = disp->GetConstituentMovedSolid();
156 xercesc::DOMElement* booleanElement =
NewElement(tag);
157 booleanElement->setAttributeNode(
NewAttribute(
"name",name));
158 xercesc::DOMElement* firstElement =
NewElement(
"first");
159 firstElement->setAttributeNode(
NewAttribute(
"ref",firstref));
160 booleanElement->appendChild(firstElement);
161 xercesc::DOMElement* secondElement =
NewElement(
"second");
162 secondElement->setAttributeNode(
NewAttribute(
"ref",secondref));
163 booleanElement->appendChild(secondElement);
164 solElement->appendChild(booleanElement);
201 xercesc::DOMElement* boxElement =
NewElement(
"box");
202 boxElement->setAttributeNode(
NewAttribute(
"name",name));
206 boxElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
207 solElement->appendChild(boxElement);
215 xercesc::DOMElement* coneElement =
NewElement(
"cone");
216 coneElement->setAttributeNode(
NewAttribute(
"name",name));
231 coneElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
232 coneElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
233 solElement->appendChild(coneElement);
242 xercesc::DOMElement* elconeElement =
NewElement(
"elcone");
243 elconeElement->setAttributeNode(
NewAttribute(
"name",name));
248 elconeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
249 solElement->appendChild(elconeElement);
258 xercesc::DOMElement* ellipsoidElement =
NewElement(
"ellipsoid");
259 ellipsoidElement->setAttributeNode(
NewAttribute(
"name",name));
272 solElement->appendChild(ellipsoidElement);
281 xercesc::DOMElement* eltubeElement =
NewElement(
"eltube");
282 eltubeElement->setAttributeNode(
NewAttribute(
"name",name));
286 eltubeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
287 solElement->appendChild(eltubeElement);
296 xercesc::DOMElement* xtruElement =
NewElement(
"xtru");
297 xtruElement->setAttributeNode(
NewAttribute(
"name",name));
298 xtruElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
299 solElement->appendChild(xtruElement);
303 for (
G4int i=0;i<NumVertex;i++)
305 xercesc::DOMElement* twoDimVertexElement =
NewElement(
"twoDimVertex");
306 xtruElement->appendChild(twoDimVertexElement);
310 twoDimVertexElement->setAttributeNode(
NewAttribute(
"x",vertex.
x()/
mm));
311 twoDimVertexElement->setAttributeNode(
NewAttribute(
"y",vertex.
y()/
mm));
316 for (
G4int i=0;i<NumSection;i++)
318 xercesc::DOMElement* sectionElement =
NewElement(
"section");
319 xtruElement->appendChild(sectionElement);
323 sectionElement->setAttributeNode(
NewAttribute(
"zOrder",i));
339 xercesc::DOMElement* hypeElement =
NewElement(
"hype");
340 hypeElement->setAttributeNode(
NewAttribute(
"name",name));
351 hypeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
352 hypeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
353 solElement->appendChild(hypeElement);
361 xercesc::DOMElement* orbElement =
NewElement(
"orb");
362 orbElement->setAttributeNode(
NewAttribute(
"name",name));
364 orbElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
365 solElement->appendChild(orbElement);
375 const G4double theta = std::acos(simaxis.z());
376 const G4double phi = (simaxis.z() != 1.0)
377 ? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
379 xercesc::DOMElement* paraElement =
NewElement(
"para");
380 paraElement->setAttributeNode(
NewAttribute(
"name",name));
390 paraElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
391 paraElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
392 solElement->appendChild(paraElement);
401 xercesc::DOMElement* paraboloidElement =
NewElement(
"paraboloid");
402 paraboloidElement->setAttributeNode(
NewAttribute(
"name",name));
409 paraboloidElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
410 solElement->appendChild(paraboloidElement);
419 xercesc::DOMElement* polyconeElement =
NewElement(
"polycone");
420 polyconeElement->setAttributeNode(
NewAttribute(
"name",name));
421 polyconeElement->setAttributeNode(
NewAttribute(
"startphi",
423 polyconeElement->setAttributeNode(
NewAttribute(
"deltaphi",
425 polyconeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
426 polyconeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
427 solElement->appendChild(polyconeElement);
434 for (
size_t i=0; i<num_zplanes; i++)
436 ZplaneWrite(polyconeElement,z_array[i],rmin_array[i],rmax_array[i]);
446 xercesc::DOMElement* polyhedraElement =
NewElement(
"polyhedra");
447 polyhedraElement->setAttributeNode(
NewAttribute(
"name",name));
448 polyhedraElement->setAttributeNode(
NewAttribute(
"startphi",
450 polyhedraElement->setAttributeNode(
NewAttribute(
"deltaphi",
452 polyhedraElement->setAttributeNode(
NewAttribute(
"numsides",
454 polyhedraElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
455 polyhedraElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
456 solElement->appendChild(polyhedraElement);
467 for (
size_t i=0;i<num_zplanes;i++)
470 rmin_array[i]*convertRad, rmax_array[i]*convertRad);
479 xercesc::DOMElement* sphereElement =
NewElement(
"sphere");
480 sphereElement->setAttributeNode(
NewAttribute(
"name",name));
485 sphereElement->setAttributeNode(
NewAttribute(
"startphi",
487 sphereElement->setAttributeNode(
NewAttribute(
"deltaphi",
489 sphereElement->setAttributeNode(
NewAttribute(
"starttheta",
491 sphereElement->setAttributeNode(
NewAttribute(
"deltatheta",
493 sphereElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
494 sphereElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
495 solElement->appendChild(sphereElement);
505 xercesc::DOMElement* tessellatedElement =
NewElement(
"tessellated");
506 tessellatedElement->setAttributeNode(
NewAttribute(
"name",name));
507 tessellatedElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
508 tessellatedElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
509 solElement->appendChild(tessellatedElement);
511 std::map<G4ThreeVector, G4String> vertexMap;
514 size_t NumVertex = 0;
516 for (
size_t i=0;i<NumFacets;i++)
523 if (NumVertexPerFacet==3) { FacetTag=
"triangular"; }
else
524 if (NumVertexPerFacet==4) { FacetTag=
"quadrangular"; }
527 G4Exception(
"G4GDMLWriteSolids::TessellatedWrite()",
"InvalidSetup",
531 xercesc::DOMElement* facetElement =
NewElement(FacetTag);
532 tessellatedElement->appendChild(facetElement);
534 for (
size_t j=0; j<NumVertexPerFacet; j++)
536 std::stringstream name_stream;
537 std::stringstream ref_stream;
539 name_stream <<
"vertex" << (j+1);
540 ref_stream << solid_name <<
"_v" << NumVertex;
553 if(vertexMap.find(vertex) != vertexMap.end())
555 ref = vertexMap[vertex];
559 vertexMap.insert(std::make_pair(vertex,ref));
566 facetElement->setAttributeNode(
NewAttribute(fname,ref));
577 std::vector<G4ThreeVector> vertexList = tet->
GetVertices();
579 xercesc::DOMElement* tetElement =
NewElement(
"tet");
580 tetElement->setAttributeNode(
NewAttribute(
"name",name));
581 tetElement->setAttributeNode(
NewAttribute(
"vertex1",solid_name+
"_v1"));
582 tetElement->setAttributeNode(
NewAttribute(
"vertex2",solid_name+
"_v2"));
583 tetElement->setAttributeNode(
NewAttribute(
"vertex3",solid_name+
"_v3"));
584 tetElement->setAttributeNode(
NewAttribute(
"vertex4",solid_name+
"_v4"));
585 tetElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
586 solElement->appendChild(tetElement);
599 xercesc::DOMElement* torusElement =
NewElement(
"torus");
600 torusElement->setAttributeNode(
NewAttribute(
"name",name));
608 torusElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
609 torusElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
610 solElement->appendChild(torusElement);
619 std::vector<G4TwoVector> vertices = gtrap->
GetVertices();
621 xercesc::DOMElement* gtrapElement =
NewElement(
"arb8");
622 gtrapElement->setAttributeNode(
NewAttribute(
"name",name));
625 gtrapElement->setAttributeNode(
NewAttribute(
"v1x", vertices[0].
x()));
626 gtrapElement->setAttributeNode(
NewAttribute(
"v1y", vertices[0].
y()));
627 gtrapElement->setAttributeNode(
NewAttribute(
"v2x", vertices[1].
x()));
628 gtrapElement->setAttributeNode(
NewAttribute(
"v2y", vertices[1].
y()));
629 gtrapElement->setAttributeNode(
NewAttribute(
"v3x", vertices[2].
x()));
630 gtrapElement->setAttributeNode(
NewAttribute(
"v3y", vertices[2].
y()));
631 gtrapElement->setAttributeNode(
NewAttribute(
"v4x", vertices[3].
x()));
632 gtrapElement->setAttributeNode(
NewAttribute(
"v4y", vertices[3].
y()));
633 gtrapElement->setAttributeNode(
NewAttribute(
"v5x", vertices[4].
x()));
634 gtrapElement->setAttributeNode(
NewAttribute(
"v5y", vertices[4].
y()));
635 gtrapElement->setAttributeNode(
NewAttribute(
"v6x", vertices[5].
x()));
636 gtrapElement->setAttributeNode(
NewAttribute(
"v6y", vertices[5].
y()));
637 gtrapElement->setAttributeNode(
NewAttribute(
"v7x", vertices[6].
x()));
638 gtrapElement->setAttributeNode(
NewAttribute(
"v7y", vertices[6].
y()));
639 gtrapElement->setAttributeNode(
NewAttribute(
"v8x", vertices[7].
x()));
640 gtrapElement->setAttributeNode(
NewAttribute(
"v8y", vertices[7].
y()));
641 gtrapElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
642 solElement->appendChild(gtrapElement);
651 const G4double phi = (simaxis.z() != 1.0)
652 ? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
653 const G4double theta = std::acos(simaxis.z());
657 xercesc::DOMElement* trapElement =
NewElement(
"trap");
658 trapElement->setAttributeNode(
NewAttribute(
"name",name));
677 trapElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
678 trapElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
679 solElement->appendChild(trapElement);
687 xercesc::DOMElement* trdElement =
NewElement(
"trd");
688 trdElement->setAttributeNode(
NewAttribute(
"name",name));
699 trdElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
700 solElement->appendChild(trdElement);
708 xercesc::DOMElement* tubeElement =
NewElement(
"tube");
709 tubeElement->setAttributeNode(
NewAttribute(
"name",name));
720 tubeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
721 tubeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
722 solElement->appendChild(tubeElement);
730 xercesc::DOMElement* cuttubeElement =
NewElement(
"cutTube");
731 cuttubeElement->setAttributeNode(
NewAttribute(
"name",name));
738 cuttubeElement->setAttributeNode(
NewAttribute(
"startphi",
740 cuttubeElement->setAttributeNode(
NewAttribute(
"deltaphi",
754 cuttubeElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
755 cuttubeElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
756 solElement->appendChild(cuttubeElement);
765 xercesc::DOMElement* twistedboxElement =
NewElement(
"twistedbox");
766 twistedboxElement->setAttributeNode(
NewAttribute(
"name",name));
773 twistedboxElement->setAttributeNode(
NewAttribute(
"PhiTwist",
775 twistedboxElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
776 twistedboxElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
777 solElement->appendChild(twistedboxElement);
786 xercesc::DOMElement* twistedtrapElement =
NewElement(
"twistedtrap");
787 twistedtrapElement->setAttributeNode(
NewAttribute(
"name",name));
802 twistedtrapElement->setAttributeNode(
NewAttribute(
"Alph",
804 twistedtrapElement->setAttributeNode(
NewAttribute(
"Theta",
806 twistedtrapElement->setAttributeNode(
NewAttribute(
"Phi",
808 twistedtrapElement->setAttributeNode(
NewAttribute(
"PhiTwist",
810 twistedtrapElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
811 twistedtrapElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
813 solElement->appendChild(twistedtrapElement);
822 xercesc::DOMElement* twistedtrdElement =
NewElement(
"twistedtrd");
823 twistedtrdElement->setAttributeNode(
NewAttribute(
"name",name));
834 twistedtrdElement->setAttributeNode(
NewAttribute(
"PhiTwist",
836 twistedtrdElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
837 twistedtrdElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
838 solElement->appendChild(twistedtrdElement);
847 xercesc::DOMElement* twistedtubsElement =
NewElement(
"twistedtubs");
848 twistedtubsElement->setAttributeNode(
NewAttribute(
"name",name));
849 twistedtubsElement->setAttributeNode(
NewAttribute(
"twistedangle",
851 twistedtubsElement->setAttributeNode(
NewAttribute(
"endinnerrad",
853 twistedtubsElement->setAttributeNode(
NewAttribute(
"endouterrad",
855 twistedtubsElement->setAttributeNode(
NewAttribute(
"zlen",
857 twistedtubsElement->setAttributeNode(
NewAttribute(
"phi",
859 twistedtubsElement->setAttributeNode(
NewAttribute(
"aunit",
"deg"));
860 twistedtubsElement->setAttributeNode(
NewAttribute(
"lunit",
"mm"));
861 solElement->appendChild(twistedtubsElement);
868 xercesc::DOMElement* zplaneElement =
NewElement(
"zplane");
872 element->appendChild(zplaneElement);
879 xercesc::DOMElement* optElement =
NewElement(
"opticalsurface");
884 optElement->setAttributeNode(
NewAttribute(
"model", smodel));
887 optElement->setAttributeNode(
NewAttribute(
"value", sval));
889 solElement->appendChild(optElement);
904 for (
size_t i=0; i<
solidList.size(); i++)
906 if (
solidList[i] == solidPtr) {
return; }
912 = dynamic_cast<const G4BooleanSolid*>(solidPtr))
914 if (
const G4Box*
const boxPtr
915 = dynamic_cast<const G4Box*>(solidPtr))
917 if (
const G4Cons*
const conePtr
918 = dynamic_cast<const G4Cons*>(solidPtr))
921 = dynamic_cast<const G4EllipticalCone*>(solidPtr))
924 = dynamic_cast<const G4Ellipsoid*>(solidPtr))
927 = dynamic_cast<const G4EllipticalTube*>(solidPtr))
930 = dynamic_cast<const G4ExtrudedSolid*>(solidPtr))
932 if (
const G4Hype*
const hypePtr
933 = dynamic_cast<const G4Hype*>(solidPtr))
935 if (
const G4Orb*
const orbPtr
936 = dynamic_cast<const G4Orb*>(solidPtr))
938 if (
const G4Para*
const paraPtr
939 = dynamic_cast<const G4Para*>(solidPtr))
942 = dynamic_cast<const G4Paraboloid*>(solidPtr))
945 = dynamic_cast<const G4Polycone*>(solidPtr))
948 = dynamic_cast<const G4Polyhedra*>(solidPtr))
951 = dynamic_cast<const G4Sphere*>(solidPtr))
954 = dynamic_cast<const G4TessellatedSolid*>(solidPtr))
956 if (
const G4Tet*
const tetPtr
957 = dynamic_cast<const G4Tet*>(solidPtr))
959 if (
const G4Torus*
const torusPtr
960 = dynamic_cast<const G4Torus*>(solidPtr))
963 = dynamic_cast<const G4GenericTrap*>(solidPtr))
965 if (
const G4Trap*
const trapPtr
966 = dynamic_cast<const G4Trap*>(solidPtr))
968 if (
const G4Trd*
const trdPtr
969 = dynamic_cast<const G4Trd*>(solidPtr))
971 if (
const G4Tubs*
const tubePtr
972 = dynamic_cast<const G4Tubs*>(solidPtr))
975 = dynamic_cast<const G4CutTubs*>(solidPtr))
978 = dynamic_cast<const G4TwistedBox*>(solidPtr))
981 = dynamic_cast<const G4TwistedTrap*>(solidPtr))
984 = dynamic_cast<const G4TwistedTrd*>(solidPtr))
987 = dynamic_cast<const G4TwistedTubs*>(solidPtr))
993 G4Exception(
"G4GDMLWriteSolids::AddSolid()",
"WriteError",