00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "G4GDMLWriteSolids.hh"
00036
00037 #include "G4SystemOfUnits.hh"
00038 #include "G4BooleanSolid.hh"
00039 #include "G4Box.hh"
00040 #include "G4Cons.hh"
00041 #include "G4Ellipsoid.hh"
00042 #include "G4EllipticalCone.hh"
00043 #include "G4EllipticalTube.hh"
00044 #include "G4ExtrudedSolid.hh"
00045 #include "G4Hype.hh"
00046 #include "G4Orb.hh"
00047 #include "G4Para.hh"
00048 #include "G4Paraboloid.hh"
00049 #include "G4IntersectionSolid.hh"
00050 #include "G4Polycone.hh"
00051 #include "G4Polyhedra.hh"
00052 #include "G4ReflectedSolid.hh"
00053 #include "G4Sphere.hh"
00054 #include "G4SubtractionSolid.hh"
00055 #include "G4GenericTrap.hh"
00056 #include "G4TessellatedSolid.hh"
00057 #include "G4Tet.hh"
00058 #include "G4Torus.hh"
00059 #include "G4Trap.hh"
00060 #include "G4Trd.hh"
00061 #include "G4Tubs.hh"
00062 #include "G4CutTubs.hh"
00063 #include "G4TwistedBox.hh"
00064 #include "G4TwistedTrap.hh"
00065 #include "G4TwistedTrd.hh"
00066 #include "G4TwistedTubs.hh"
00067 #include "G4UnionSolid.hh"
00068 #include "G4OpticalSurface.hh"
00069 #include "G4SurfaceProperty.hh"
00070
00071 G4GDMLWriteSolids::G4GDMLWriteSolids()
00072 : G4GDMLWriteMaterials(), solidsElement(0)
00073 {
00074 }
00075
00076 G4GDMLWriteSolids::~G4GDMLWriteSolids()
00077 {
00078 }
00079
00080 void G4GDMLWriteSolids::
00081 BooleanWrite(xercesc::DOMElement* solElement,
00082 const G4BooleanSolid* const boolean)
00083 {
00084 G4int displaced=0;
00085
00086 G4String tag("undefined");
00087 if (dynamic_cast<const G4IntersectionSolid*>(boolean))
00088 { tag = "intersection"; } else
00089 if (dynamic_cast<const G4SubtractionSolid*>(boolean))
00090 { tag = "subtraction"; } else
00091 if (dynamic_cast<const G4UnionSolid*>(boolean))
00092 { tag = "union"; }
00093
00094 G4VSolid* firstPtr = const_cast<G4VSolid*>(boolean->GetConstituentSolid(0));
00095 G4VSolid* secondPtr = const_cast<G4VSolid*>(boolean->GetConstituentSolid(1));
00096
00097 G4ThreeVector firstpos,firstrot,pos,rot;
00098
00099
00100
00101 while (true)
00102 {
00103 if ( displaced>8 )
00104 {
00105 G4String ErrorMessage = "The referenced solid '"
00106 + firstPtr->GetName() +
00107 + "in the Boolean shape '" +
00108 + boolean->GetName() +
00109 + "' was displaced too many times!";
00110 G4Exception("G4GDMLWriteSolids::BooleanWrite()",
00111 "InvalidSetup", FatalException, ErrorMessage);
00112 }
00113
00114 if (G4DisplacedSolid* disp = dynamic_cast<G4DisplacedSolid*>(firstPtr))
00115 {
00116 firstpos += disp->GetObjectTranslation();
00117 firstrot += firstrot + GetAngles(disp->GetObjectRotation());
00118 firstPtr = disp->GetConstituentMovedSolid();
00119 displaced++;
00120 continue;
00121 }
00122 break;
00123 }
00124 displaced = 0;
00125 while (true)
00126 {
00127 if ( displaced>maxTransforms )
00128 {
00129 G4String ErrorMessage = "The referenced solid '"
00130 + secondPtr->GetName() +
00131 + "in the Boolean shape '" +
00132 + boolean->GetName() +
00133 + "' was displaced too many times!";
00134 G4Exception("G4GDMLWriteSolids::BooleanWrite()",
00135 "InvalidSetup", FatalException, ErrorMessage);
00136 }
00137
00138 if (G4DisplacedSolid* disp = dynamic_cast<G4DisplacedSolid*>(secondPtr))
00139 {
00140 pos += disp->GetObjectTranslation();
00141 rot += GetAngles(disp->GetObjectRotation());
00142 secondPtr = disp->GetConstituentMovedSolid();
00143 displaced++;
00144 continue;
00145 }
00146 break;
00147 }
00148
00149 AddSolid(firstPtr);
00150 AddSolid(secondPtr);
00151
00152 const G4String& name = GenerateName(boolean->GetName(),boolean);
00153 const G4String& firstref = GenerateName(firstPtr->GetName(),firstPtr);
00154 const G4String& secondref = GenerateName(secondPtr->GetName(),secondPtr);
00155
00156 xercesc::DOMElement* booleanElement = NewElement(tag);
00157 booleanElement->setAttributeNode(NewAttribute("name",name));
00158 xercesc::DOMElement* firstElement = NewElement("first");
00159 firstElement->setAttributeNode(NewAttribute("ref",firstref));
00160 booleanElement->appendChild(firstElement);
00161 xercesc::DOMElement* secondElement = NewElement("second");
00162 secondElement->setAttributeNode(NewAttribute("ref",secondref));
00163 booleanElement->appendChild(secondElement);
00164 solElement->appendChild(booleanElement);
00165
00166
00167 if ( (std::fabs(pos.x()) > kLinearPrecision)
00168 || (std::fabs(pos.y()) > kLinearPrecision)
00169 || (std::fabs(pos.z()) > kLinearPrecision) )
00170 {
00171 PositionWrite(booleanElement,name+"_pos",pos);
00172 }
00173
00174 if ( (std::fabs(rot.x()) > kAngularPrecision)
00175 || (std::fabs(rot.y()) > kAngularPrecision)
00176 || (std::fabs(rot.z()) > kAngularPrecision) )
00177 {
00178 RotationWrite(booleanElement,name+"_rot",rot);
00179 }
00180
00181 if ( (std::fabs(firstpos.x()) > kLinearPrecision)
00182 || (std::fabs(firstpos.y()) > kLinearPrecision)
00183 || (std::fabs(firstpos.z()) > kLinearPrecision) )
00184 {
00185 FirstpositionWrite(booleanElement,name+"_fpos",firstpos);
00186 }
00187
00188 if ( (std::fabs(firstrot.x()) > kAngularPrecision)
00189 || (std::fabs(firstrot.y()) > kAngularPrecision)
00190 || (std::fabs(firstrot.z()) > kAngularPrecision) )
00191 {
00192 FirstrotationWrite(booleanElement,name+"_frot",firstrot);
00193 }
00194 }
00195
00196 void G4GDMLWriteSolids::
00197 BoxWrite(xercesc::DOMElement* solElement, const G4Box* const box)
00198 {
00199 const G4String& name = GenerateName(box->GetName(),box);
00200
00201 xercesc::DOMElement* boxElement = NewElement("box");
00202 boxElement->setAttributeNode(NewAttribute("name",name));
00203 boxElement->setAttributeNode(NewAttribute("x",2.0*box->GetXHalfLength()/mm));
00204 boxElement->setAttributeNode(NewAttribute("y",2.0*box->GetYHalfLength()/mm));
00205 boxElement->setAttributeNode(NewAttribute("z",2.0*box->GetZHalfLength()/mm));
00206 boxElement->setAttributeNode(NewAttribute("lunit","mm"));
00207 solElement->appendChild(boxElement);
00208 }
00209
00210 void G4GDMLWriteSolids::
00211 ConeWrite(xercesc::DOMElement* solElement, const G4Cons* const cone)
00212 {
00213 const G4String& name = GenerateName(cone->GetName(),cone);
00214
00215 xercesc::DOMElement* coneElement = NewElement("cone");
00216 coneElement->setAttributeNode(NewAttribute("name",name));
00217 coneElement->
00218 setAttributeNode(NewAttribute("rmin1",cone->GetInnerRadiusMinusZ()/mm));
00219 coneElement->
00220 setAttributeNode(NewAttribute("rmax1",cone->GetOuterRadiusMinusZ()/mm));
00221 coneElement->
00222 setAttributeNode(NewAttribute("rmin2",cone->GetInnerRadiusPlusZ()/mm));
00223 coneElement->
00224 setAttributeNode(NewAttribute("rmax2",cone->GetOuterRadiusPlusZ()/mm));
00225 coneElement->
00226 setAttributeNode(NewAttribute("z",2.0*cone->GetZHalfLength()/mm));
00227 coneElement->
00228 setAttributeNode(NewAttribute("startphi",cone->GetStartPhiAngle()/degree));
00229 coneElement->
00230 setAttributeNode(NewAttribute("deltaphi",cone->GetDeltaPhiAngle()/degree));
00231 coneElement->setAttributeNode(NewAttribute("aunit","deg"));
00232 coneElement->setAttributeNode(NewAttribute("lunit","mm"));
00233 solElement->appendChild(coneElement);
00234 }
00235
00236 void G4GDMLWriteSolids::
00237 ElconeWrite(xercesc::DOMElement* solElement,
00238 const G4EllipticalCone* const elcone)
00239 {
00240 const G4String& name = GenerateName(elcone->GetName(),elcone);
00241
00242 xercesc::DOMElement* elconeElement = NewElement("elcone");
00243 elconeElement->setAttributeNode(NewAttribute("name",name));
00244 elconeElement->setAttributeNode(NewAttribute("dx",elcone->GetSemiAxisX()/mm));
00245 elconeElement->setAttributeNode(NewAttribute("dy",elcone->GetSemiAxisY()/mm));
00246 elconeElement->setAttributeNode(NewAttribute("zmax",elcone->GetZMax()/mm));
00247 elconeElement->setAttributeNode(NewAttribute("zcut",elcone->GetZTopCut()/mm));
00248 elconeElement->setAttributeNode(NewAttribute("lunit","mm"));
00249 solElement->appendChild(elconeElement);
00250 }
00251
00252 void G4GDMLWriteSolids::
00253 EllipsoidWrite(xercesc::DOMElement* solElement,
00254 const G4Ellipsoid* const ellipsoid)
00255 {
00256 const G4String& name = GenerateName(ellipsoid->GetName(),ellipsoid);
00257
00258 xercesc::DOMElement* ellipsoidElement = NewElement("ellipsoid");
00259 ellipsoidElement->setAttributeNode(NewAttribute("name",name));
00260 ellipsoidElement->
00261 setAttributeNode(NewAttribute("ax",ellipsoid->GetSemiAxisMax(0)/mm));
00262 ellipsoidElement->
00263 setAttributeNode(NewAttribute("by",ellipsoid->GetSemiAxisMax(1)/mm));
00264 ellipsoidElement->
00265 setAttributeNode(NewAttribute("cz",ellipsoid->GetSemiAxisMax(2)/mm));
00266 ellipsoidElement->
00267 setAttributeNode(NewAttribute("zcut1",ellipsoid->GetZBottomCut()/mm));
00268 ellipsoidElement->
00269 setAttributeNode(NewAttribute("zcut2",ellipsoid->GetZTopCut()/mm));
00270 ellipsoidElement->
00271 setAttributeNode(NewAttribute("lunit","mm"));
00272 solElement->appendChild(ellipsoidElement);
00273 }
00274
00275 void G4GDMLWriteSolids::
00276 EltubeWrite(xercesc::DOMElement* solElement,
00277 const G4EllipticalTube* const eltube)
00278 {
00279 const G4String& name = GenerateName(eltube->GetName(),eltube);
00280
00281 xercesc::DOMElement* eltubeElement = NewElement("eltube");
00282 eltubeElement->setAttributeNode(NewAttribute("name",name));
00283 eltubeElement->setAttributeNode(NewAttribute("dx",eltube->GetDx()/mm));
00284 eltubeElement->setAttributeNode(NewAttribute("dy",eltube->GetDy()/mm));
00285 eltubeElement->setAttributeNode(NewAttribute("dz",eltube->GetDz()/mm));
00286 eltubeElement->setAttributeNode(NewAttribute("lunit","mm"));
00287 solElement->appendChild(eltubeElement);
00288 }
00289
00290 void G4GDMLWriteSolids::
00291 XtruWrite(xercesc::DOMElement* solElement,
00292 const G4ExtrudedSolid* const xtru)
00293 {
00294 const G4String& name = GenerateName(xtru->GetName(),xtru);
00295
00296 xercesc::DOMElement* xtruElement = NewElement("xtru");
00297 xtruElement->setAttributeNode(NewAttribute("name",name));
00298 xtruElement->setAttributeNode(NewAttribute("lunit","mm"));
00299 solElement->appendChild(xtruElement);
00300
00301 const G4int NumVertex = xtru->GetNofVertices();
00302
00303 for (G4int i=0;i<NumVertex;i++)
00304 {
00305 xercesc::DOMElement* twoDimVertexElement = NewElement("twoDimVertex");
00306 xtruElement->appendChild(twoDimVertexElement);
00307
00308 const G4TwoVector& vertex = xtru->GetVertex(i);
00309
00310 twoDimVertexElement->setAttributeNode(NewAttribute("x",vertex.x()/mm));
00311 twoDimVertexElement->setAttributeNode(NewAttribute("y",vertex.y()/mm));
00312 }
00313
00314 const G4int NumSection = xtru->GetNofZSections();
00315
00316 for (G4int i=0;i<NumSection;i++)
00317 {
00318 xercesc::DOMElement* sectionElement = NewElement("section");
00319 xtruElement->appendChild(sectionElement);
00320
00321 const G4ExtrudedSolid::ZSection section = xtru->GetZSection(i);
00322
00323 sectionElement->setAttributeNode(NewAttribute("zOrder",i));
00324 sectionElement->setAttributeNode(NewAttribute("zPosition",section.fZ/mm));
00325 sectionElement->
00326 setAttributeNode(NewAttribute("xOffset",section.fOffset.x()/mm));
00327 sectionElement->
00328 setAttributeNode(NewAttribute("yOffset",section.fOffset.y()/mm));
00329 sectionElement->
00330 setAttributeNode(NewAttribute("scalingFactor",section.fScale));
00331 }
00332 }
00333
00334 void G4GDMLWriteSolids::
00335 HypeWrite(xercesc::DOMElement* solElement, const G4Hype* const hype)
00336 {
00337 const G4String& name = GenerateName(hype->GetName(),hype);
00338
00339 xercesc::DOMElement* hypeElement = NewElement("hype");
00340 hypeElement->setAttributeNode(NewAttribute("name",name));
00341 hypeElement->setAttributeNode(NewAttribute("rmin",
00342 hype->GetInnerRadius()/mm));
00343 hypeElement->setAttributeNode(NewAttribute("rmax",
00344 hype->GetOuterRadius()/mm));
00345 hypeElement->setAttributeNode(NewAttribute("inst",
00346 hype->GetInnerStereo()/degree));
00347 hypeElement->setAttributeNode(NewAttribute("outst",
00348 hype->GetOuterStereo()/degree));
00349 hypeElement->setAttributeNode(NewAttribute("z",
00350 2.0*hype->GetZHalfLength()/mm));
00351 hypeElement->setAttributeNode(NewAttribute("aunit","deg"));
00352 hypeElement->setAttributeNode(NewAttribute("lunit","mm"));
00353 solElement->appendChild(hypeElement);
00354 }
00355
00356 void G4GDMLWriteSolids::
00357 OrbWrite(xercesc::DOMElement* solElement, const G4Orb* const orb)
00358 {
00359 const G4String& name = GenerateName(orb->GetName(),orb);
00360
00361 xercesc::DOMElement* orbElement = NewElement("orb");
00362 orbElement->setAttributeNode(NewAttribute("name",name));
00363 orbElement->setAttributeNode(NewAttribute("r",orb->GetRadius()/mm));
00364 orbElement->setAttributeNode(NewAttribute("lunit","mm"));
00365 solElement->appendChild(orbElement);
00366 }
00367
00368 void G4GDMLWriteSolids::
00369 ParaWrite(xercesc::DOMElement* solElement, const G4Para* const para)
00370 {
00371 const G4String& name = GenerateName(para->GetName(),para);
00372
00373 const G4ThreeVector simaxis = para->GetSymAxis();
00374 const G4double alpha = std::atan(para->GetTanAlpha());
00375 const G4double theta = std::acos(simaxis.z());
00376 const G4double phi = (simaxis.z() != 1.0)
00377 ? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
00378
00379 xercesc::DOMElement* paraElement = NewElement("para");
00380 paraElement->setAttributeNode(NewAttribute("name",name));
00381 paraElement->setAttributeNode(NewAttribute("x",
00382 2.0*para->GetXHalfLength()/mm));
00383 paraElement->setAttributeNode(NewAttribute("y",
00384 2.0*para->GetYHalfLength()/mm));
00385 paraElement->setAttributeNode(NewAttribute("z",
00386 2.0*para->GetZHalfLength()/mm));
00387 paraElement->setAttributeNode(NewAttribute("alpha",alpha/degree));
00388 paraElement->setAttributeNode(NewAttribute("theta",theta/degree));
00389 paraElement->setAttributeNode(NewAttribute("phi",phi/degree));
00390 paraElement->setAttributeNode(NewAttribute("aunit","deg"));
00391 paraElement->setAttributeNode(NewAttribute("lunit","mm"));
00392 solElement->appendChild(paraElement);
00393 }
00394
00395 void G4GDMLWriteSolids::
00396 ParaboloidWrite(xercesc::DOMElement* solElement,
00397 const G4Paraboloid* const paraboloid)
00398 {
00399 const G4String& name = GenerateName(paraboloid->GetName(),paraboloid);
00400
00401 xercesc::DOMElement* paraboloidElement = NewElement("paraboloid");
00402 paraboloidElement->setAttributeNode(NewAttribute("name",name));
00403 paraboloidElement->setAttributeNode(NewAttribute("rlo",
00404 paraboloid->GetRadiusMinusZ()/mm));
00405 paraboloidElement->setAttributeNode(NewAttribute("rhi",
00406 paraboloid->GetRadiusPlusZ()/mm));
00407 paraboloidElement->setAttributeNode(NewAttribute("dz",
00408 paraboloid->GetZHalfLength()/mm));
00409 paraboloidElement->setAttributeNode(NewAttribute("lunit","mm"));
00410 solElement->appendChild(paraboloidElement);
00411 }
00412
00413 void G4GDMLWriteSolids::
00414 PolyconeWrite(xercesc::DOMElement* solElement,
00415 const G4Polycone* const polycone)
00416 {
00417 const G4String& name = GenerateName(polycone->GetName(),polycone);
00418
00419 xercesc::DOMElement* polyconeElement = NewElement("polycone");
00420 polyconeElement->setAttributeNode(NewAttribute("name",name));
00421 polyconeElement->setAttributeNode(NewAttribute("startphi",
00422 polycone->GetOriginalParameters()->Start_angle/degree));
00423 polyconeElement->setAttributeNode(NewAttribute("deltaphi",
00424 polycone->GetOriginalParameters()->Opening_angle/degree));
00425 polyconeElement->setAttributeNode(NewAttribute("aunit","deg"));
00426 polyconeElement->setAttributeNode(NewAttribute("lunit","mm"));
00427 solElement->appendChild(polyconeElement);
00428
00429 const size_t num_zplanes = polycone->GetOriginalParameters()->Num_z_planes;
00430 const G4double* z_array = polycone->GetOriginalParameters()->Z_values;
00431 const G4double* rmin_array = polycone->GetOriginalParameters()->Rmin;
00432 const G4double* rmax_array = polycone->GetOriginalParameters()->Rmax;
00433
00434 for (size_t i=0; i<num_zplanes; i++)
00435 {
00436 ZplaneWrite(polyconeElement,z_array[i],rmin_array[i],rmax_array[i]);
00437 }
00438 }
00439
00440 void G4GDMLWriteSolids::
00441 PolyhedraWrite(xercesc::DOMElement* solElement,
00442 const G4Polyhedra* const polyhedra)
00443 {
00444 const G4String& name = GenerateName(polyhedra->GetName(),polyhedra);
00445
00446 xercesc::DOMElement* polyhedraElement = NewElement("polyhedra");
00447 polyhedraElement->setAttributeNode(NewAttribute("name",name));
00448 polyhedraElement->setAttributeNode(NewAttribute("startphi",
00449 polyhedra->GetOriginalParameters()->Start_angle/degree));
00450 polyhedraElement->setAttributeNode(NewAttribute("deltaphi",
00451 polyhedra->GetOriginalParameters()->Opening_angle/degree));
00452 polyhedraElement->setAttributeNode(NewAttribute("numsides",
00453 polyhedra->GetOriginalParameters()->numSide));
00454 polyhedraElement->setAttributeNode(NewAttribute("aunit","deg"));
00455 polyhedraElement->setAttributeNode(NewAttribute("lunit","mm"));
00456 solElement->appendChild(polyhedraElement);
00457
00458 const size_t num_zplanes = polyhedra->GetOriginalParameters()->Num_z_planes;
00459 const G4double* z_array = polyhedra->GetOriginalParameters()->Z_values;
00460 const G4double* rmin_array = polyhedra->GetOriginalParameters()->Rmin;
00461 const G4double* rmax_array = polyhedra->GetOriginalParameters()->Rmax;
00462
00463 const G4double convertRad =
00464 std::cos(0.5*polyhedra->GetOriginalParameters()->Opening_angle
00465 / polyhedra->GetOriginalParameters()->numSide);
00466
00467 for (size_t i=0;i<num_zplanes;i++)
00468 {
00469 ZplaneWrite(polyhedraElement,z_array[i],
00470 rmin_array[i]*convertRad, rmax_array[i]*convertRad);
00471 }
00472 }
00473
00474 void G4GDMLWriteSolids::
00475 SphereWrite(xercesc::DOMElement* solElement, const G4Sphere* const sphere)
00476 {
00477 const G4String& name = GenerateName(sphere->GetName(),sphere);
00478
00479 xercesc::DOMElement* sphereElement = NewElement("sphere");
00480 sphereElement->setAttributeNode(NewAttribute("name",name));
00481 sphereElement->setAttributeNode(NewAttribute("rmin",
00482 sphere->GetInsideRadius()/mm));
00483 sphereElement->setAttributeNode(NewAttribute("rmax",
00484 sphere->GetOuterRadius()/mm));
00485 sphereElement->setAttributeNode(NewAttribute("startphi",
00486 sphere->GetStartPhiAngle()/degree));
00487 sphereElement->setAttributeNode(NewAttribute("deltaphi",
00488 sphere->GetDeltaPhiAngle()/degree));
00489 sphereElement->setAttributeNode(NewAttribute("starttheta",
00490 sphere->GetStartThetaAngle()/degree));
00491 sphereElement->setAttributeNode(NewAttribute("deltatheta",
00492 sphere->GetDeltaThetaAngle()/degree));
00493 sphereElement->setAttributeNode(NewAttribute("aunit","deg"));
00494 sphereElement->setAttributeNode(NewAttribute("lunit","mm"));
00495 solElement->appendChild(sphereElement);
00496 }
00497
00498 void G4GDMLWriteSolids::
00499 TessellatedWrite(xercesc::DOMElement* solElement,
00500 const G4TessellatedSolid* const tessellated)
00501 {
00502 const G4String& solid_name = tessellated->GetName();
00503 const G4String& name = GenerateName(solid_name, tessellated);
00504
00505 xercesc::DOMElement* tessellatedElement = NewElement("tessellated");
00506 tessellatedElement->setAttributeNode(NewAttribute("name",name));
00507 tessellatedElement->setAttributeNode(NewAttribute("aunit","deg"));
00508 tessellatedElement->setAttributeNode(NewAttribute("lunit","mm"));
00509 solElement->appendChild(tessellatedElement);
00510
00511 std::map<G4ThreeVector, G4String> vertexMap;
00512
00513 const size_t NumFacets = tessellated->GetNumberOfFacets();
00514 size_t NumVertex = 0;
00515
00516 for (size_t i=0;i<NumFacets;i++)
00517 {
00518 const G4VFacet* facet = tessellated->GetFacet(i);
00519 const size_t NumVertexPerFacet = facet->GetNumberOfVertices();
00520
00521 G4String FacetTag;
00522
00523 if (NumVertexPerFacet==3) { FacetTag="triangular"; } else
00524 if (NumVertexPerFacet==4) { FacetTag="quadrangular"; }
00525 else
00526 {
00527 G4Exception("G4GDMLWriteSolids::TessellatedWrite()", "InvalidSetup",
00528 FatalException, "Facet should contain 3 or 4 vertices!");
00529 }
00530
00531 xercesc::DOMElement* facetElement = NewElement(FacetTag);
00532 tessellatedElement->appendChild(facetElement);
00533
00534 for (size_t j=0; j<NumVertexPerFacet; j++)
00535 {
00536 std::stringstream name_stream;
00537 std::stringstream ref_stream;
00538
00539 name_stream << "vertex" << (j+1);
00540 ref_stream << solid_name << "_v" << NumVertex;
00541
00542 const G4String& fname = name_stream.str();
00543 G4String ref = ref_stream.str();
00544
00545
00546
00547
00548
00549
00550
00551 const G4ThreeVector& vertex = facet->GetVertex(j);
00552
00553 if(vertexMap.find(vertex) != vertexMap.end())
00554 {
00555 ref = vertexMap[vertex];
00556 }
00557 else
00558 {
00559 vertexMap.insert(std::make_pair(vertex,ref));
00560 AddPosition(ref, vertex);
00561 NumVertex++;
00562 }
00563
00564
00565
00566 facetElement->setAttributeNode(NewAttribute(fname,ref));
00567 }
00568 }
00569 }
00570
00571 void G4GDMLWriteSolids::
00572 TetWrite(xercesc::DOMElement* solElement, const G4Tet* const tet)
00573 {
00574 const G4String& solid_name = tet->GetName();
00575 const G4String& name = GenerateName(solid_name, tet);
00576
00577 std::vector<G4ThreeVector> vertexList = tet->GetVertices();
00578
00579 xercesc::DOMElement* tetElement = NewElement("tet");
00580 tetElement->setAttributeNode(NewAttribute("name",name));
00581 tetElement->setAttributeNode(NewAttribute("vertex1",solid_name+"_v1"));
00582 tetElement->setAttributeNode(NewAttribute("vertex2",solid_name+"_v2"));
00583 tetElement->setAttributeNode(NewAttribute("vertex3",solid_name+"_v3"));
00584 tetElement->setAttributeNode(NewAttribute("vertex4",solid_name+"_v4"));
00585 tetElement->setAttributeNode(NewAttribute("lunit","mm"));
00586 solElement->appendChild(tetElement);
00587
00588 AddPosition(solid_name+"_v1",vertexList[0]);
00589 AddPosition(solid_name+"_v2",vertexList[1]);
00590 AddPosition(solid_name+"_v3",vertexList[2]);
00591 AddPosition(solid_name+"_v4",vertexList[3]);
00592 }
00593
00594 void G4GDMLWriteSolids::
00595 TorusWrite(xercesc::DOMElement* solElement, const G4Torus* const torus)
00596 {
00597 const G4String& name = GenerateName(torus->GetName(),torus);
00598
00599 xercesc::DOMElement* torusElement = NewElement("torus");
00600 torusElement->setAttributeNode(NewAttribute("name",name));
00601 torusElement->setAttributeNode(NewAttribute("rmin",torus->GetRmin()/mm));
00602 torusElement->setAttributeNode(NewAttribute("rmax",torus->GetRmax()/mm));
00603 torusElement->setAttributeNode(NewAttribute("rtor",torus->GetRtor()/mm));
00604 torusElement->
00605 setAttributeNode(NewAttribute("startphi",torus->GetSPhi()/degree));
00606 torusElement->
00607 setAttributeNode(NewAttribute("deltaphi",torus->GetDPhi()/degree));
00608 torusElement->setAttributeNode(NewAttribute("aunit","deg"));
00609 torusElement->setAttributeNode(NewAttribute("lunit","mm"));
00610 solElement->appendChild(torusElement);
00611 }
00612
00613 void G4GDMLWriteSolids::
00614 GenTrapWrite(xercesc::DOMElement* solElement,
00615 const G4GenericTrap* const gtrap)
00616 {
00617 const G4String& name = GenerateName(gtrap->GetName(),gtrap);
00618
00619 std::vector<G4TwoVector> vertices = gtrap->GetVertices();
00620
00621 xercesc::DOMElement* gtrapElement = NewElement("arb8");
00622 gtrapElement->setAttributeNode(NewAttribute("name",name));
00623 gtrapElement->setAttributeNode(NewAttribute("dz",
00624 gtrap->GetZHalfLength()/mm));
00625 gtrapElement->setAttributeNode(NewAttribute("v1x", vertices[0].x()));
00626 gtrapElement->setAttributeNode(NewAttribute("v1y", vertices[0].y()));
00627 gtrapElement->setAttributeNode(NewAttribute("v2x", vertices[1].x()));
00628 gtrapElement->setAttributeNode(NewAttribute("v2y", vertices[1].y()));
00629 gtrapElement->setAttributeNode(NewAttribute("v3x", vertices[2].x()));
00630 gtrapElement->setAttributeNode(NewAttribute("v3y", vertices[2].y()));
00631 gtrapElement->setAttributeNode(NewAttribute("v4x", vertices[3].x()));
00632 gtrapElement->setAttributeNode(NewAttribute("v4y", vertices[3].y()));
00633 gtrapElement->setAttributeNode(NewAttribute("v5x", vertices[4].x()));
00634 gtrapElement->setAttributeNode(NewAttribute("v5y", vertices[4].y()));
00635 gtrapElement->setAttributeNode(NewAttribute("v6x", vertices[5].x()));
00636 gtrapElement->setAttributeNode(NewAttribute("v6y", vertices[5].y()));
00637 gtrapElement->setAttributeNode(NewAttribute("v7x", vertices[6].x()));
00638 gtrapElement->setAttributeNode(NewAttribute("v7y", vertices[6].y()));
00639 gtrapElement->setAttributeNode(NewAttribute("v8x", vertices[7].x()));
00640 gtrapElement->setAttributeNode(NewAttribute("v8y", vertices[7].y()));
00641 gtrapElement->setAttributeNode(NewAttribute("lunit","mm"));
00642 solElement->appendChild(gtrapElement);
00643 }
00644
00645 void G4GDMLWriteSolids::
00646 TrapWrite(xercesc::DOMElement* solElement, const G4Trap* const trap)
00647 {
00648 const G4String& name = GenerateName(trap->GetName(),trap);
00649
00650 const G4ThreeVector& simaxis = trap->GetSymAxis();
00651 const G4double phi = (simaxis.z() != 1.0)
00652 ? (std::atan(simaxis.y()/simaxis.x())) : (0.0);
00653 const G4double theta = std::acos(simaxis.z());
00654 const G4double alpha1 = std::atan(trap->GetTanAlpha1());
00655 const G4double alpha2 = std::atan(trap->GetTanAlpha2());
00656
00657 xercesc::DOMElement* trapElement = NewElement("trap");
00658 trapElement->setAttributeNode(NewAttribute("name",name));
00659 trapElement->setAttributeNode(NewAttribute("z",
00660 2.0*trap->GetZHalfLength()/mm));
00661 trapElement->setAttributeNode(NewAttribute("theta",theta/degree));
00662 trapElement->setAttributeNode(NewAttribute("phi",phi/degree));
00663 trapElement->setAttributeNode(NewAttribute("y1",
00664 2.0*trap->GetYHalfLength1()/mm));
00665 trapElement->setAttributeNode(NewAttribute("x1",
00666 2.0*trap->GetXHalfLength1()/mm));
00667 trapElement->setAttributeNode(NewAttribute("x2",
00668 2.0*trap->GetXHalfLength2()/mm));
00669 trapElement->setAttributeNode(NewAttribute("alpha1",alpha1/degree));
00670 trapElement->setAttributeNode(NewAttribute("y2",
00671 2.0*trap->GetYHalfLength2()/mm));
00672 trapElement->setAttributeNode(NewAttribute("x3",
00673 2.0*trap->GetXHalfLength3()/mm));
00674 trapElement->setAttributeNode(NewAttribute("x4",
00675 2.0*trap->GetXHalfLength4()/mm));
00676 trapElement->setAttributeNode(NewAttribute("alpha2",alpha2/degree));
00677 trapElement->setAttributeNode(NewAttribute("aunit","deg"));
00678 trapElement->setAttributeNode(NewAttribute("lunit","mm"));
00679 solElement->appendChild(trapElement);
00680 }
00681
00682 void G4GDMLWriteSolids::
00683 TrdWrite(xercesc::DOMElement* solElement, const G4Trd* const trd)
00684 {
00685 const G4String& name = GenerateName(trd->GetName(),trd);
00686
00687 xercesc::DOMElement* trdElement = NewElement("trd");
00688 trdElement->setAttributeNode(NewAttribute("name",name));
00689 trdElement->setAttributeNode(NewAttribute("x1",
00690 2.0*trd->GetXHalfLength1()/mm));
00691 trdElement->setAttributeNode(NewAttribute("x2",
00692 2.0*trd->GetXHalfLength2()/mm));
00693 trdElement->setAttributeNode(NewAttribute("y1",
00694 2.0*trd->GetYHalfLength1()/mm));
00695 trdElement->setAttributeNode(NewAttribute("y2",
00696 2.0*trd->GetYHalfLength2()/mm));
00697 trdElement->setAttributeNode(NewAttribute("z",
00698 2.0*trd->GetZHalfLength()/mm));
00699 trdElement->setAttributeNode(NewAttribute("lunit","mm"));
00700 solElement->appendChild(trdElement);
00701 }
00702
00703 void G4GDMLWriteSolids::
00704 TubeWrite(xercesc::DOMElement* solElement, const G4Tubs* const tube)
00705 {
00706 const G4String& name = GenerateName(tube->GetName(),tube);
00707
00708 xercesc::DOMElement* tubeElement = NewElement("tube");
00709 tubeElement->setAttributeNode(NewAttribute("name",name));
00710 tubeElement->setAttributeNode(NewAttribute("rmin",
00711 tube->GetInnerRadius()/mm));
00712 tubeElement->setAttributeNode(NewAttribute("rmax",
00713 tube->GetOuterRadius()/mm));
00714 tubeElement->setAttributeNode(NewAttribute("z",
00715 2.0*tube->GetZHalfLength()/mm));
00716 tubeElement->setAttributeNode(NewAttribute("startphi",
00717 tube->GetStartPhiAngle()/degree));
00718 tubeElement->setAttributeNode(NewAttribute("deltaphi",
00719 tube->GetDeltaPhiAngle()/degree));
00720 tubeElement->setAttributeNode(NewAttribute("aunit","deg"));
00721 tubeElement->setAttributeNode(NewAttribute("lunit","mm"));
00722 solElement->appendChild(tubeElement);
00723 }
00724
00725 void G4GDMLWriteSolids::
00726 CutTubeWrite(xercesc::DOMElement* solElement, const G4CutTubs* const cuttube)
00727 {
00728 const G4String& name = GenerateName(cuttube->GetName(),cuttube);
00729
00730 xercesc::DOMElement* cuttubeElement = NewElement("cutTube");
00731 cuttubeElement->setAttributeNode(NewAttribute("name",name));
00732 cuttubeElement->setAttributeNode(NewAttribute("rmin",
00733 cuttube->GetInnerRadius()/mm));
00734 cuttubeElement->setAttributeNode(NewAttribute("rmax",
00735 cuttube->GetOuterRadius()/mm));
00736 cuttubeElement->setAttributeNode(NewAttribute("z",
00737 2.0*cuttube->GetZHalfLength()/mm));
00738 cuttubeElement->setAttributeNode(NewAttribute("startphi",
00739 cuttube->GetStartPhiAngle()/degree));
00740 cuttubeElement->setAttributeNode(NewAttribute("deltaphi",
00741 cuttube->GetDeltaPhiAngle()/degree));
00742 cuttubeElement->setAttributeNode(NewAttribute("lowX",
00743 cuttube->GetLowNorm().getX()/mm));
00744 cuttubeElement->setAttributeNode(NewAttribute("lowY",
00745 cuttube->GetLowNorm().getY()/mm));
00746 cuttubeElement->setAttributeNode(NewAttribute("lowZ",
00747 cuttube->GetLowNorm().getZ()/mm));
00748 cuttubeElement->setAttributeNode(NewAttribute("highX",
00749 cuttube->GetHighNorm().getX()/mm));
00750 cuttubeElement->setAttributeNode(NewAttribute("highY",
00751 cuttube->GetHighNorm().getY()/mm));
00752 cuttubeElement->setAttributeNode(NewAttribute("highZ",
00753 cuttube->GetHighNorm().getZ()/mm));
00754 cuttubeElement->setAttributeNode(NewAttribute("aunit","deg"));
00755 cuttubeElement->setAttributeNode(NewAttribute("lunit","mm"));
00756 solElement->appendChild(cuttubeElement);
00757 }
00758
00759 void G4GDMLWriteSolids::
00760 TwistedboxWrite(xercesc::DOMElement* solElement,
00761 const G4TwistedBox* const twistedbox)
00762 {
00763 const G4String& name = GenerateName(twistedbox->GetName(),twistedbox);
00764
00765 xercesc::DOMElement* twistedboxElement = NewElement("twistedbox");
00766 twistedboxElement->setAttributeNode(NewAttribute("name",name));
00767 twistedboxElement->setAttributeNode(NewAttribute("x",
00768 2.0*twistedbox->GetXHalfLength()/mm));
00769 twistedboxElement->setAttributeNode(NewAttribute("y",
00770 2.0*twistedbox->GetYHalfLength()/mm));
00771 twistedboxElement->setAttributeNode(NewAttribute("z",
00772 2.0*twistedbox->GetZHalfLength()/mm));
00773 twistedboxElement->setAttributeNode(NewAttribute("PhiTwist",
00774 twistedbox->GetPhiTwist()/degree));
00775 twistedboxElement->setAttributeNode(NewAttribute("aunit","deg"));
00776 twistedboxElement->setAttributeNode(NewAttribute("lunit","mm"));
00777 solElement->appendChild(twistedboxElement);
00778 }
00779
00780 void G4GDMLWriteSolids::
00781 TwistedtrapWrite(xercesc::DOMElement* solElement,
00782 const G4TwistedTrap* const twistedtrap)
00783 {
00784 const G4String& name = GenerateName(twistedtrap->GetName(),twistedtrap);
00785
00786 xercesc::DOMElement* twistedtrapElement = NewElement("twistedtrap");
00787 twistedtrapElement->setAttributeNode(NewAttribute("name",name));
00788 twistedtrapElement->setAttributeNode(NewAttribute("y1",
00789 2.0*twistedtrap->GetY1HalfLength()/mm));
00790 twistedtrapElement->setAttributeNode(NewAttribute("x1",
00791 2.0*twistedtrap->GetX1HalfLength()/mm));
00792 twistedtrapElement->setAttributeNode(NewAttribute("x2",
00793 2.0*twistedtrap->GetX2HalfLength()/mm));
00794 twistedtrapElement->setAttributeNode(NewAttribute("y2",
00795 2.0*twistedtrap->GetY2HalfLength()/mm));
00796 twistedtrapElement->setAttributeNode(NewAttribute("x3",
00797 2.0*twistedtrap->GetX3HalfLength()/mm));
00798 twistedtrapElement->setAttributeNode(NewAttribute("x4",
00799 2.0*twistedtrap->GetX4HalfLength()/mm));
00800 twistedtrapElement->setAttributeNode(NewAttribute("z",
00801 2.0*twistedtrap->GetZHalfLength()/mm));
00802 twistedtrapElement->setAttributeNode(NewAttribute("Alph",
00803 twistedtrap->GetTiltAngleAlpha()/degree));
00804 twistedtrapElement->setAttributeNode(NewAttribute("Theta",
00805 twistedtrap->GetPolarAngleTheta()/degree));
00806 twistedtrapElement->setAttributeNode(NewAttribute("Phi",
00807 twistedtrap->GetAzimuthalAnglePhi()/degree));
00808 twistedtrapElement->setAttributeNode(NewAttribute("PhiTwist",
00809 twistedtrap->GetPhiTwist()/degree));
00810 twistedtrapElement->setAttributeNode(NewAttribute("aunit","deg"));
00811 twistedtrapElement->setAttributeNode(NewAttribute("lunit","mm"));
00812
00813 solElement->appendChild(twistedtrapElement);
00814 }
00815
00816 void G4GDMLWriteSolids::
00817 TwistedtrdWrite(xercesc::DOMElement* solElement,
00818 const G4TwistedTrd* const twistedtrd)
00819 {
00820 const G4String& name = GenerateName(twistedtrd->GetName(),twistedtrd);
00821
00822 xercesc::DOMElement* twistedtrdElement = NewElement("twistedtrd");
00823 twistedtrdElement->setAttributeNode(NewAttribute("name",name));
00824 twistedtrdElement->setAttributeNode(NewAttribute("x1",
00825 2.0*twistedtrd->GetX1HalfLength()/mm));
00826 twistedtrdElement->setAttributeNode(NewAttribute("x2",
00827 2.0*twistedtrd->GetX2HalfLength()/mm));
00828 twistedtrdElement->setAttributeNode(NewAttribute("y1",
00829 2.0*twistedtrd->GetY1HalfLength()/mm));
00830 twistedtrdElement->setAttributeNode(NewAttribute("y2",
00831 2.0*twistedtrd->GetY2HalfLength()/mm));
00832 twistedtrdElement->setAttributeNode(NewAttribute("z",
00833 2.0*twistedtrd->GetZHalfLength()/mm));
00834 twistedtrdElement->setAttributeNode(NewAttribute("PhiTwist",
00835 twistedtrd->GetPhiTwist()/degree));
00836 twistedtrdElement->setAttributeNode(NewAttribute("aunit","deg"));
00837 twistedtrdElement->setAttributeNode(NewAttribute("lunit","mm"));
00838 solElement->appendChild(twistedtrdElement);
00839 }
00840
00841 void G4GDMLWriteSolids::
00842 TwistedtubsWrite(xercesc::DOMElement* solElement,
00843 const G4TwistedTubs* const twistedtubs)
00844 {
00845 const G4String& name = GenerateName(twistedtubs->GetName(),twistedtubs);
00846
00847 xercesc::DOMElement* twistedtubsElement = NewElement("twistedtubs");
00848 twistedtubsElement->setAttributeNode(NewAttribute("name",name));
00849 twistedtubsElement->setAttributeNode(NewAttribute("twistedangle",
00850 twistedtubs->GetPhiTwist()/degree));
00851 twistedtubsElement->setAttributeNode(NewAttribute("endinnerrad",
00852 twistedtubs->GetInnerRadius()/mm));
00853 twistedtubsElement->setAttributeNode(NewAttribute("endouterrad",
00854 twistedtubs->GetOuterRadius()/mm));
00855 twistedtubsElement->setAttributeNode(NewAttribute("zlen",
00856 2.0*twistedtubs->GetZHalfLength()/mm));
00857 twistedtubsElement->setAttributeNode(NewAttribute("phi",
00858 twistedtubs->GetDPhi()/degree));
00859 twistedtubsElement->setAttributeNode(NewAttribute("aunit","deg"));
00860 twistedtubsElement->setAttributeNode(NewAttribute("lunit","mm"));
00861 solElement->appendChild(twistedtubsElement);
00862 }
00863
00864 void G4GDMLWriteSolids::
00865 ZplaneWrite(xercesc::DOMElement* element, const G4double& z,
00866 const G4double& rmin, const G4double& rmax)
00867 {
00868 xercesc::DOMElement* zplaneElement = NewElement("zplane");
00869 zplaneElement->setAttributeNode(NewAttribute("z",z/mm));
00870 zplaneElement->setAttributeNode(NewAttribute("rmin",rmin/mm));
00871 zplaneElement->setAttributeNode(NewAttribute("rmax",rmax/mm));
00872 element->appendChild(zplaneElement);
00873 }
00874
00875 void G4GDMLWriteSolids::
00876 OpticalSurfaceWrite(xercesc::DOMElement* solElement,
00877 const G4OpticalSurface* const surf)
00878 {
00879 xercesc::DOMElement* optElement = NewElement("opticalsurface");
00880 G4OpticalSurfaceModel smodel = surf->GetModel();
00881 G4double sval = (smodel==glisur) ? surf->GetPolish() : surf->GetSigmaAlpha();
00882
00883 optElement->setAttributeNode(NewAttribute("name", surf->GetName()));
00884 optElement->setAttributeNode(NewAttribute("model", smodel));
00885 optElement->setAttributeNode(NewAttribute("finish", surf->GetFinish()));
00886 optElement->setAttributeNode(NewAttribute("type", surf->GetType()));
00887 optElement->setAttributeNode(NewAttribute("value", sval));
00888
00889 solElement->appendChild(optElement);
00890 }
00891
00892 void G4GDMLWriteSolids::SolidsWrite(xercesc::DOMElement* gdmlElement)
00893 {
00894 G4cout << "G4GDML: Writing solids..." << G4endl;
00895
00896 solidsElement = NewElement("solids");
00897 gdmlElement->appendChild(solidsElement);
00898
00899 solidList.clear();
00900 }
00901
00902 void G4GDMLWriteSolids::AddSolid(const G4VSolid* const solidPtr)
00903 {
00904 for (size_t i=0; i<solidList.size(); i++)
00905 {
00906 if (solidList[i] == solidPtr) { return; }
00907 }
00908
00909 solidList.push_back(solidPtr);
00910
00911 if (const G4BooleanSolid* const booleanPtr
00912 = dynamic_cast<const G4BooleanSolid*>(solidPtr))
00913 { BooleanWrite(solidsElement,booleanPtr); } else
00914 if (const G4Box* const boxPtr
00915 = dynamic_cast<const G4Box*>(solidPtr))
00916 { BoxWrite(solidsElement,boxPtr); } else
00917 if (const G4Cons* const conePtr
00918 = dynamic_cast<const G4Cons*>(solidPtr))
00919 { ConeWrite(solidsElement,conePtr); } else
00920 if (const G4EllipticalCone* const elconePtr
00921 = dynamic_cast<const G4EllipticalCone*>(solidPtr))
00922 { ElconeWrite(solidsElement,elconePtr); } else
00923 if (const G4Ellipsoid* const ellipsoidPtr
00924 = dynamic_cast<const G4Ellipsoid*>(solidPtr))
00925 { EllipsoidWrite(solidsElement,ellipsoidPtr); } else
00926 if (const G4EllipticalTube* const eltubePtr
00927 = dynamic_cast<const G4EllipticalTube*>(solidPtr))
00928 { EltubeWrite(solidsElement,eltubePtr); } else
00929 if (const G4ExtrudedSolid* const xtruPtr
00930 = dynamic_cast<const G4ExtrudedSolid*>(solidPtr))
00931 { XtruWrite(solidsElement,xtruPtr); } else
00932 if (const G4Hype* const hypePtr
00933 = dynamic_cast<const G4Hype*>(solidPtr))
00934 { HypeWrite(solidsElement,hypePtr); } else
00935 if (const G4Orb* const orbPtr
00936 = dynamic_cast<const G4Orb*>(solidPtr))
00937 { OrbWrite(solidsElement,orbPtr); } else
00938 if (const G4Para* const paraPtr
00939 = dynamic_cast<const G4Para*>(solidPtr))
00940 { ParaWrite(solidsElement,paraPtr); } else
00941 if (const G4Paraboloid* const paraboloidPtr
00942 = dynamic_cast<const G4Paraboloid*>(solidPtr))
00943 { ParaboloidWrite(solidsElement,paraboloidPtr); } else
00944 if (const G4Polycone* const polyconePtr
00945 = dynamic_cast<const G4Polycone*>(solidPtr))
00946 { PolyconeWrite(solidsElement,polyconePtr); } else
00947 if (const G4Polyhedra* const polyhedraPtr
00948 = dynamic_cast<const G4Polyhedra*>(solidPtr))
00949 { PolyhedraWrite(solidsElement,polyhedraPtr); } else
00950 if (const G4Sphere* const spherePtr
00951 = dynamic_cast<const G4Sphere*>(solidPtr))
00952 { SphereWrite(solidsElement,spherePtr); } else
00953 if (const G4TessellatedSolid* const tessellatedPtr
00954 = dynamic_cast<const G4TessellatedSolid*>(solidPtr))
00955 { TessellatedWrite(solidsElement,tessellatedPtr); } else
00956 if (const G4Tet* const tetPtr
00957 = dynamic_cast<const G4Tet*>(solidPtr))
00958 { TetWrite(solidsElement,tetPtr); } else
00959 if (const G4Torus* const torusPtr
00960 = dynamic_cast<const G4Torus*>(solidPtr))
00961 { TorusWrite(solidsElement,torusPtr); } else
00962 if (const G4GenericTrap* const gtrapPtr
00963 = dynamic_cast<const G4GenericTrap*>(solidPtr))
00964 { GenTrapWrite(solidsElement,gtrapPtr); } else
00965 if (const G4Trap* const trapPtr
00966 = dynamic_cast<const G4Trap*>(solidPtr))
00967 { TrapWrite(solidsElement,trapPtr); } else
00968 if (const G4Trd* const trdPtr
00969 = dynamic_cast<const G4Trd*>(solidPtr))
00970 { TrdWrite(solidsElement,trdPtr); } else
00971 if (const G4Tubs* const tubePtr
00972 = dynamic_cast<const G4Tubs*>(solidPtr))
00973 { TubeWrite(solidsElement,tubePtr); } else
00974 if (const G4CutTubs* const cuttubePtr
00975 = dynamic_cast<const G4CutTubs*>(solidPtr))
00976 { CutTubeWrite(solidsElement,cuttubePtr); } else
00977 if (const G4TwistedBox* const twistedboxPtr
00978 = dynamic_cast<const G4TwistedBox*>(solidPtr))
00979 { TwistedboxWrite(solidsElement,twistedboxPtr); } else
00980 if (const G4TwistedTrap* const twistedtrapPtr
00981 = dynamic_cast<const G4TwistedTrap*>(solidPtr))
00982 { TwistedtrapWrite(solidsElement,twistedtrapPtr); } else
00983 if (const G4TwistedTrd* const twistedtrdPtr
00984 = dynamic_cast<const G4TwistedTrd*>(solidPtr))
00985 { TwistedtrdWrite(solidsElement,twistedtrdPtr); } else
00986 if (const G4TwistedTubs* const twistedtubsPtr
00987 = dynamic_cast<const G4TwistedTubs*>(solidPtr))
00988 { TwistedtubsWrite(solidsElement,twistedtubsPtr); }
00989 else
00990 {
00991 G4String error_msg = "Unknown solid: " + solidPtr->GetName()
00992 + "; Type: " + solidPtr->GetEntityType();
00993 G4Exception("G4GDMLWriteSolids::AddSolid()", "WriteError",
00994 FatalException, error_msg);
00995 }
00996 }