G4GDMLWriteSolids Class Reference

#include <G4GDMLWriteSolids.hh>

Inheritance diagram for G4GDMLWriteSolids:

G4GDMLWriteMaterials G4GDMLWriteDefine G4GDMLWrite G4GDMLWriteSetup G4GDMLWriteParamvol G4GDMLWriteStructure

Public Member Functions

virtual void AddSolid (const G4VSolid *const)
virtual void SolidsWrite (xercesc::DOMElement *)

Protected Member Functions

 G4GDMLWriteSolids ()
virtual ~G4GDMLWriteSolids ()
void BooleanWrite (xercesc::DOMElement *, const G4BooleanSolid *const)
void BoxWrite (xercesc::DOMElement *, const G4Box *const)
void ConeWrite (xercesc::DOMElement *, const G4Cons *const)
void ElconeWrite (xercesc::DOMElement *, const G4EllipticalCone *const)
void EllipsoidWrite (xercesc::DOMElement *, const G4Ellipsoid *const)
void EltubeWrite (xercesc::DOMElement *, const G4EllipticalTube *const)
void XtruWrite (xercesc::DOMElement *, const G4ExtrudedSolid *const)
void HypeWrite (xercesc::DOMElement *, const G4Hype *const)
void OrbWrite (xercesc::DOMElement *, const G4Orb *const)
void ParaWrite (xercesc::DOMElement *, const G4Para *const)
void ParaboloidWrite (xercesc::DOMElement *, const G4Paraboloid *const)
void PolyconeWrite (xercesc::DOMElement *, const G4Polycone *const)
void PolyhedraWrite (xercesc::DOMElement *, const G4Polyhedra *const)
void SphereWrite (xercesc::DOMElement *, const G4Sphere *const)
void TessellatedWrite (xercesc::DOMElement *, const G4TessellatedSolid *const)
void TetWrite (xercesc::DOMElement *, const G4Tet *const)
void TorusWrite (xercesc::DOMElement *, const G4Torus *const)
void GenTrapWrite (xercesc::DOMElement *, const G4GenericTrap *const)
void TrapWrite (xercesc::DOMElement *, const G4Trap *const)
void TrdWrite (xercesc::DOMElement *, const G4Trd *const)
void TubeWrite (xercesc::DOMElement *, const G4Tubs *const)
void CutTubeWrite (xercesc::DOMElement *, const G4CutTubs *const)
void TwistedboxWrite (xercesc::DOMElement *, const G4TwistedBox *const)
void TwistedtrapWrite (xercesc::DOMElement *, const G4TwistedTrap *const)
void TwistedtrdWrite (xercesc::DOMElement *, const G4TwistedTrd *const)
void TwistedtubsWrite (xercesc::DOMElement *, const G4TwistedTubs *const)
void ZplaneWrite (xercesc::DOMElement *, const G4double &, const G4double &, const G4double &)
void OpticalSurfaceWrite (xercesc::DOMElement *, const G4OpticalSurface *const)

Protected Attributes

std::vector< const G4VSolid * > solidList
xercesc::DOMElement * solidsElement

Static Protected Attributes

static const G4int maxTransforms = 8

Detailed Description

Definition at line 76 of file G4GDMLWriteSolids.hh.


Constructor & Destructor Documentation

G4GDMLWriteSolids::G4GDMLWriteSolids (  )  [protected]

Definition at line 71 of file G4GDMLWriteSolids.cc.

00072   : G4GDMLWriteMaterials(), solidsElement(0)
00073 {
00074 }

G4GDMLWriteSolids::~G4GDMLWriteSolids (  )  [protected, virtual]

Definition at line 76 of file G4GDMLWriteSolids.cc.

00077 {
00078 }


Member Function Documentation

void G4GDMLWriteSolids::AddSolid ( const G4VSolid const  )  [virtual]

Definition at line 902 of file G4GDMLWriteSolids.cc.

References BooleanWrite(), BoxWrite(), ConeWrite(), CutTubeWrite(), ElconeWrite(), EllipsoidWrite(), EltubeWrite(), FatalException, G4Exception(), GenTrapWrite(), HypeWrite(), OrbWrite(), ParaboloidWrite(), ParaWrite(), PolyconeWrite(), PolyhedraWrite(), solidList, solidsElement, SphereWrite(), TessellatedWrite(), TetWrite(), TorusWrite(), TrapWrite(), TrdWrite(), TubeWrite(), TwistedboxWrite(), TwistedtrapWrite(), TwistedtrdWrite(), TwistedtubsWrite(), and XtruWrite().

Referenced by BooleanWrite(), and G4GDMLWriteStructure::TraverseVolumeTree().

00903 {
00904    for (size_t i=0; i<solidList.size(); i++)   // Check if solid is
00905    {                                           // already in the list!
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 }

void G4GDMLWriteSolids::BooleanWrite ( xercesc::DOMElement *  ,
const G4BooleanSolid const 
) [protected]

Definition at line 81 of file G4GDMLWriteSolids.cc.

References AddSolid(), FatalException, G4GDMLWriteDefine::FirstpositionWrite(), G4GDMLWriteDefine::FirstrotationWrite(), G4Exception(), G4GDMLWrite::GenerateName(), G4GDMLWriteDefine::GetAngles(), G4VSolid::GetName(), G4GDMLWriteDefine::kAngularPrecision, G4GDMLWriteDefine::kLinearPrecision, maxTransforms, G4GDMLWrite::NewAttribute(), G4GDMLWrite::NewElement(), G4GDMLWriteDefine::PositionWrite(), and G4GDMLWriteDefine::RotationWrite().

Referenced by AddSolid().

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    // Solve possible displacement of referenced solids!
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);   // At first add the constituent solids!
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      // Add the boolean solid AFTER the constituent solids!
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 }

void G4GDMLWriteSolids::BoxWrite ( xercesc::DOMElement *  ,
const G4Box const 
) [protected]

Definition at line 197 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Box::GetXHalfLength(), G4Box::GetYHalfLength(), G4Box::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::ConeWrite ( xercesc::DOMElement *  ,
const G4Cons const 
) [protected]

Definition at line 211 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4Cons::GetDeltaPhiAngle(), G4Cons::GetInnerRadiusMinusZ(), G4Cons::GetInnerRadiusPlusZ(), G4VSolid::GetName(), G4Cons::GetOuterRadiusMinusZ(), G4Cons::GetOuterRadiusPlusZ(), G4Cons::GetStartPhiAngle(), G4Cons::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::CutTubeWrite ( xercesc::DOMElement *  ,
const G4CutTubs const 
) [protected]

Definition at line 726 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4Tubs::GetDeltaPhiAngle(), G4CutTubs::GetHighNorm(), G4Tubs::GetInnerRadius(), G4CutTubs::GetLowNorm(), G4VSolid::GetName(), G4Tubs::GetOuterRadius(), G4Tubs::GetStartPhiAngle(), G4Tubs::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::ElconeWrite ( xercesc::DOMElement *  ,
const G4EllipticalCone const 
) [protected]

Definition at line 237 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4EllipticalCone::GetSemiAxisX(), G4EllipticalCone::GetSemiAxisY(), G4EllipticalCone::GetZMax(), G4EllipticalCone::GetZTopCut(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::EllipsoidWrite ( xercesc::DOMElement *  ,
const G4Ellipsoid const 
) [protected]

Definition at line 253 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Ellipsoid::GetSemiAxisMax(), G4Ellipsoid::GetZBottomCut(), G4Ellipsoid::GetZTopCut(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::EltubeWrite ( xercesc::DOMElement *  ,
const G4EllipticalTube const 
) [protected]

Definition at line 276 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4EllipticalTube::GetDx(), G4EllipticalTube::GetDy(), G4EllipticalTube::GetDz(), G4VSolid::GetName(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::GenTrapWrite ( xercesc::DOMElement *  ,
const G4GenericTrap const 
) [protected]

Definition at line 614 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4GenericTrap::GetVertices(), G4GenericTrap::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::HypeWrite ( xercesc::DOMElement *  ,
const G4Hype const 
) [protected]

Definition at line 335 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4Hype::GetInnerRadius(), G4Hype::GetInnerStereo(), G4VSolid::GetName(), G4Hype::GetOuterRadius(), G4Hype::GetOuterStereo(), G4Hype::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::OpticalSurfaceWrite ( xercesc::DOMElement *  ,
const G4OpticalSurface const 
) [protected]

Definition at line 876 of file G4GDMLWriteSolids.cc.

References G4OpticalSurface::GetFinish(), G4OpticalSurface::GetModel(), G4SurfaceProperty::GetName(), G4OpticalSurface::GetPolish(), G4OpticalSurface::GetSigmaAlpha(), G4SurfaceProperty::GetType(), glisur, G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by G4GDMLWriteStructure::BorderSurfaceCache(), and G4GDMLWriteStructure::SkinSurfaceCache().

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 }

void G4GDMLWriteSolids::OrbWrite ( xercesc::DOMElement *  ,
const G4Orb const 
) [protected]

Definition at line 357 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Orb::GetRadius(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::ParaboloidWrite ( xercesc::DOMElement *  ,
const G4Paraboloid const 
) [protected]

Definition at line 396 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Paraboloid::GetRadiusMinusZ(), G4Paraboloid::GetRadiusPlusZ(), G4Paraboloid::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::ParaWrite ( xercesc::DOMElement *  ,
const G4Para const 
) [protected]

Definition at line 369 of file G4GDMLWriteSolids.cc.

References G4InuclParticleNames::alpha, G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Para::GetSymAxis(), G4Para::GetTanAlpha(), G4Para::GetXHalfLength(), G4Para::GetYHalfLength(), G4Para::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::PolyconeWrite ( xercesc::DOMElement *  ,
const G4Polycone const 
) [protected]

Definition at line 414 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Polycone::GetOriginalParameters(), G4GDMLWrite::NewAttribute(), G4GDMLWrite::NewElement(), G4PolyconeHistorical::Num_z_planes, G4PolyconeHistorical::Opening_angle, G4PolyconeHistorical::Rmax, G4PolyconeHistorical::Rmin, G4PolyconeHistorical::Start_angle, G4PolyconeHistorical::Z_values, and ZplaneWrite().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::PolyhedraWrite ( xercesc::DOMElement *  ,
const G4Polyhedra const 
) [protected]

Definition at line 441 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Polyhedra::GetOriginalParameters(), G4GDMLWrite::NewAttribute(), G4GDMLWrite::NewElement(), G4PolyhedraHistorical::Num_z_planes, G4PolyhedraHistorical::numSide, G4PolyhedraHistorical::Opening_angle, G4PolyhedraHistorical::Rmax, G4PolyhedraHistorical::Rmin, G4PolyhedraHistorical::Start_angle, G4PolyhedraHistorical::Z_values, and ZplaneWrite().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::SolidsWrite ( xercesc::DOMElement *   )  [virtual]

Implements G4GDMLWrite.

Definition at line 892 of file G4GDMLWriteSolids.cc.

References G4cout, G4endl, G4GDMLWrite::NewElement(), solidList, and solidsElement.

00893 {
00894    G4cout << "G4GDML: Writing solids..." << G4endl;
00895 
00896    solidsElement = NewElement("solids");
00897    gdmlElement->appendChild(solidsElement);
00898 
00899    solidList.clear();
00900 }

void G4GDMLWriteSolids::SphereWrite ( xercesc::DOMElement *  ,
const G4Sphere const 
) [protected]

Definition at line 475 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4Sphere::GetDeltaPhiAngle(), G4Sphere::GetDeltaThetaAngle(), G4Sphere::GetInsideRadius(), G4VSolid::GetName(), G4Sphere::GetOuterRadius(), G4Sphere::GetStartPhiAngle(), G4Sphere::GetStartThetaAngle(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TessellatedWrite ( xercesc::DOMElement *  ,
const G4TessellatedSolid const 
) [protected]

Definition at line 499 of file G4GDMLWriteSolids.cc.

References G4GDMLWriteDefine::AddPosition(), FatalException, G4Exception(), G4GDMLWrite::GenerateName(), G4TessellatedSolid::GetFacet(), G4VSolid::GetName(), G4TessellatedSolid::GetNumberOfFacets(), G4VFacet::GetNumberOfVertices(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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();  // facet's tag variable
00543          G4String ref = ref_stream.str();     // vertex tag to be associated
00544 
00545          // Now search for the existance of the current vertex in the
00546          // map of cached vertices. If existing, do NOT store it as
00547          // position in the GDML file, so avoiding duplication; otherwise
00548          // cache it in the local map and add it as position in the
00549          // "define" section of the GDML file.
00550 
00551          const G4ThreeVector& vertex = facet->GetVertex(j);
00552 
00553          if(vertexMap.find(vertex) != vertexMap.end())  // Vertex is cached
00554          {
00555            ref = vertexMap[vertex];     // Set the proper tag for it
00556          }
00557          else                                           // Vertex not found
00558          {
00559            vertexMap.insert(std::make_pair(vertex,ref)); // Cache vertex and ...
00560            AddPosition(ref, vertex);    // ... add it to define section!
00561            NumVertex++;
00562          }
00563 
00564          // Now create association of the vertex with its facet
00565          //
00566          facetElement->setAttributeNode(NewAttribute(fname,ref));
00567       }
00568    }
00569 }

void G4GDMLWriteSolids::TetWrite ( xercesc::DOMElement *  ,
const G4Tet const 
) [protected]

Definition at line 572 of file G4GDMLWriteSolids.cc.

References G4GDMLWriteDefine::AddPosition(), G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Tet::GetVertices(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TorusWrite ( xercesc::DOMElement *  ,
const G4Torus const 
) [protected]

Definition at line 595 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4Torus::GetDPhi(), G4VSolid::GetName(), G4Torus::GetRmax(), G4Torus::GetRmin(), G4Torus::GetRtor(), G4Torus::GetSPhi(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TrapWrite ( xercesc::DOMElement *  ,
const G4Trap const 
) [protected]

Definition at line 646 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Trap::GetSymAxis(), G4Trap::GetTanAlpha1(), G4Trap::GetTanAlpha2(), G4Trap::GetXHalfLength1(), G4Trap::GetXHalfLength2(), G4Trap::GetXHalfLength3(), G4Trap::GetXHalfLength4(), G4Trap::GetYHalfLength1(), G4Trap::GetYHalfLength2(), G4Trap::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TrdWrite ( xercesc::DOMElement *  ,
const G4Trd const 
) [protected]

Definition at line 683 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4Trd::GetXHalfLength1(), G4Trd::GetXHalfLength2(), G4Trd::GetYHalfLength1(), G4Trd::GetYHalfLength2(), G4Trd::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TubeWrite ( xercesc::DOMElement *  ,
const G4Tubs const 
) [protected]

Definition at line 704 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4Tubs::GetDeltaPhiAngle(), G4Tubs::GetInnerRadius(), G4VSolid::GetName(), G4Tubs::GetOuterRadius(), G4Tubs::GetStartPhiAngle(), G4Tubs::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TwistedboxWrite ( xercesc::DOMElement *  ,
const G4TwistedBox const 
) [protected]

Definition at line 760 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4TwistedBox::GetPhiTwist(), G4TwistedBox::GetXHalfLength(), G4TwistedBox::GetYHalfLength(), G4TwistedBox::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TwistedtrapWrite ( xercesc::DOMElement *  ,
const G4TwistedTrap const 
) [protected]

Definition at line 781 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4TwistedTrap::GetAzimuthalAnglePhi(), G4VSolid::GetName(), G4TwistedTrap::GetPhiTwist(), G4TwistedTrap::GetPolarAngleTheta(), G4TwistedTrap::GetTiltAngleAlpha(), G4TwistedTrap::GetX1HalfLength(), G4TwistedTrap::GetX2HalfLength(), G4TwistedTrap::GetX3HalfLength(), G4TwistedTrap::GetX4HalfLength(), G4TwistedTrap::GetY1HalfLength(), G4TwistedTrap::GetY2HalfLength(), G4TwistedTrap::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TwistedtrdWrite ( xercesc::DOMElement *  ,
const G4TwistedTrd const 
) [protected]

Definition at line 817 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4TwistedTrd::GetPhiTwist(), G4TwistedTrd::GetX1HalfLength(), G4TwistedTrd::GetX2HalfLength(), G4TwistedTrd::GetY1HalfLength(), G4TwistedTrd::GetY2HalfLength(), G4TwistedTrd::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::TwistedtubsWrite ( xercesc::DOMElement *  ,
const G4TwistedTubs const 
) [protected]

Definition at line 842 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::GenerateName(), G4TwistedTubs::GetDPhi(), G4TwistedTubs::GetInnerRadius(), G4VSolid::GetName(), G4TwistedTubs::GetOuterRadius(), G4TwistedTubs::GetPhiTwist(), G4TwistedTubs::GetZHalfLength(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::XtruWrite ( xercesc::DOMElement *  ,
const G4ExtrudedSolid const 
) [protected]

Definition at line 291 of file G4GDMLWriteSolids.cc.

References G4ExtrudedSolid::ZSection::fOffset, G4ExtrudedSolid::ZSection::fScale, G4ExtrudedSolid::ZSection::fZ, G4GDMLWrite::GenerateName(), G4VSolid::GetName(), G4ExtrudedSolid::GetNofVertices(), G4ExtrudedSolid::GetNofZSections(), G4ExtrudedSolid::GetVertex(), G4ExtrudedSolid::GetZSection(), G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by AddSolid().

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 }

void G4GDMLWriteSolids::ZplaneWrite ( xercesc::DOMElement *  ,
const G4double ,
const G4double ,
const G4double  
) [protected]

Definition at line 865 of file G4GDMLWriteSolids.cc.

References G4GDMLWrite::NewAttribute(), and G4GDMLWrite::NewElement().

Referenced by PolyconeWrite(), and PolyhedraWrite().

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 }


Field Documentation

const G4int G4GDMLWriteSolids::maxTransforms = 8 [static, protected]

Definition at line 123 of file G4GDMLWriteSolids.hh.

Referenced by BooleanWrite(), and G4GDMLWriteStructure::TraverseVolumeTree().

std::vector<const G4VSolid*> G4GDMLWriteSolids::solidList [protected]

Definition at line 121 of file G4GDMLWriteSolids.hh.

Referenced by AddSolid(), and SolidsWrite().

xercesc::DOMElement* G4GDMLWriteSolids::solidsElement [protected]

Definition at line 122 of file G4GDMLWriteSolids.hh.

Referenced by AddSolid(), G4GDMLWriteStructure::BorderSurfaceCache(), G4GDMLWriteStructure::SkinSurfaceCache(), and SolidsWrite().


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:03 2013 for Geant4 by  doxygen 1.4.7