Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/gdml/src/G4GDMLReadSolids.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /persistency/gdml/src/G4GDMLReadSolids.cc (Version 11.3.0) and /persistency/gdml/src/G4GDMLReadSolids.cc (Version 9.5)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4GDMLReadSolids implementation             <<  26 // $Id: G4GDMLReadSolids.cc,v 1.32 2010-10-14 16:19:40 gcosmo Exp $
                                                   >>  27 // GEANT4 tag $Name: not supported by cvs2svn $
                                                   >>  28 //
                                                   >>  29 // class G4GDMLReadSolids Implementation
                                                   >>  30 //
                                                   >>  31 // Original author: Zoltan Torzsok, November 2007
 27 //                                                 32 //
 28 // Author: Zoltan Torzsok, November 2007       << 
 29 // -------------------------------------------     33 // --------------------------------------------------------------------
 30                                                    34 
 31 #include "G4GDMLReadSolids.hh"                     35 #include "G4GDMLReadSolids.hh"
                                                   >>  36 
 32 #include "G4Box.hh"                                37 #include "G4Box.hh"
 33 #include "G4Cons.hh"                               38 #include "G4Cons.hh"
 34 #include "G4Ellipsoid.hh"                          39 #include "G4Ellipsoid.hh"
 35 #include "G4EllipticalCone.hh"                     40 #include "G4EllipticalCone.hh"
 36 #include "G4EllipticalTube.hh"                     41 #include "G4EllipticalTube.hh"
 37 #include "G4Hype.hh"                               42 #include "G4Hype.hh"
 38 #include "G4IntersectionSolid.hh"                  43 #include "G4IntersectionSolid.hh"
 39 #include "G4Orb.hh"                                44 #include "G4Orb.hh"
 40 #include "G4Para.hh"                               45 #include "G4Para.hh"
 41 #include "G4Paraboloid.hh"                         46 #include "G4Paraboloid.hh"
 42 #include "G4Polycone.hh"                           47 #include "G4Polycone.hh"
 43 #include "G4GenericPolycone.hh"                << 
 44 #include "G4Polyhedra.hh"                          48 #include "G4Polyhedra.hh"
 45 #include "G4QuadrangularFacet.hh"                  49 #include "G4QuadrangularFacet.hh"
 46 #include "G4ReflectedSolid.hh"                     50 #include "G4ReflectedSolid.hh"
 47 #include "G4ScaledSolid.hh"                    << 
 48 #include "G4Sphere.hh"                             51 #include "G4Sphere.hh"
 49 #include "G4SolidStore.hh"                         52 #include "G4SolidStore.hh"
 50 #include "G4SubtractionSolid.hh"                   53 #include "G4SubtractionSolid.hh"
 51 #include "G4GenericTrap.hh"                        54 #include "G4GenericTrap.hh"
 52 #include "G4TessellatedSolid.hh"                   55 #include "G4TessellatedSolid.hh"
 53 #include "G4Tet.hh"                                56 #include "G4Tet.hh"
 54 #include "G4Torus.hh"                              57 #include "G4Torus.hh"
 55 #include "G4Transform3D.hh"                        58 #include "G4Transform3D.hh"
 56 #include "G4Trap.hh"                               59 #include "G4Trap.hh"
 57 #include "G4Trd.hh"                                60 #include "G4Trd.hh"
 58 #include "G4TriangularFacet.hh"                    61 #include "G4TriangularFacet.hh"
 59 #include "G4Tubs.hh"                               62 #include "G4Tubs.hh"
 60 #include "G4CutTubs.hh"                            63 #include "G4CutTubs.hh"
 61 #include "G4TwistedBox.hh"                         64 #include "G4TwistedBox.hh"
 62 #include "G4TwistedTrap.hh"                        65 #include "G4TwistedTrap.hh"
 63 #include "G4TwistedTrd.hh"                         66 #include "G4TwistedTrd.hh"
 64 #include "G4TwistedTubs.hh"                        67 #include "G4TwistedTubs.hh"
 65 #include "G4UnionSolid.hh"                         68 #include "G4UnionSolid.hh"
 66 #include "G4OpticalSurface.hh"                     69 #include "G4OpticalSurface.hh"
 67 #include "G4UnitsTable.hh"                     << 
 68 #include "G4SurfaceProperty.hh"                    70 #include "G4SurfaceProperty.hh"
 69                                                    71 
 70 // ------------------------------------------- <<  72 G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials()
 71 G4GDMLReadSolids::G4GDMLReadSolids()           << 
 72   : G4GDMLReadMaterials()                      << 
 73 {                                                  73 {
 74 }                                                  74 }
 75                                                    75 
 76 // ------------------------------------------- << 
 77 G4GDMLReadSolids::~G4GDMLReadSolids()              76 G4GDMLReadSolids::~G4GDMLReadSolids()
 78 {                                                  77 {
 79 }                                                  78 }
 80                                                    79 
 81 // ------------------------------------------- <<  80 void G4GDMLReadSolids::
 82 void G4GDMLReadSolids::BooleanRead(            <<  81 BooleanRead(const xercesc::DOMElement* const booleanElement, const BooleanOp op)
 83   const xercesc::DOMElement* const booleanElem << 
 84 {                                                  82 {
 85   G4String name;                               <<  83    G4String name;
 86   G4String first;                              <<  84    G4String first;
 87   G4String scnd;                               <<  85    G4String second;
 88   G4ThreeVector position(0.0, 0.0, 0.0);       <<  86    G4ThreeVector position(0.0,0.0,0.0);
 89   G4ThreeVector rotation(0.0, 0.0, 0.0);       <<  87    G4ThreeVector rotation(0.0,0.0,0.0);
 90   G4ThreeVector firstposition(0.0, 0.0, 0.0);  <<  88    G4ThreeVector firstposition(0.0,0.0,0.0);
 91   G4ThreeVector firstrotation(0.0, 0.0, 0.0);  <<  89    G4ThreeVector firstrotation(0.0,0.0,0.0);
 92                                                <<  90 
 93   const xercesc::DOMNamedNodeMap* const attrib <<  91    const xercesc::DOMNamedNodeMap* const attributes
 94     booleanElement->getAttributes();           <<  92          = booleanElement->getAttributes();
 95   XMLSize_t attributeCount = attributes->getLe <<  93    XMLSize_t attributeCount = attributes->getLength();
 96                                                <<  94 
 97   for(XMLSize_t attribute_index = 0; attribute <<  95    for (XMLSize_t attribute_index=0;
 98       ++attribute_index)                       <<  96         attribute_index<attributeCount; attribute_index++)
 99   {                                            <<  97    {
100     xercesc::DOMNode* attribute_node = attribu <<  98       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
101                                                <<  99 
102     if(attribute_node->getNodeType() != xerces << 100       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
103     {                                          << 101         { continue; }
104       continue;                                << 102 
105     }                                          << 103       const xercesc::DOMAttr* const attribute
106                                                << 104             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
107     const xercesc::DOMAttr* const attribute =  << 105       if (!attribute)
108       dynamic_cast<xercesc::DOMAttr*>(attribut << 106       {
109     if(attribute == nullptr)                   << 107         G4Exception("G4GDMLReadSolids::BooleanRead()",
110     {                                          << 108                     "InvalidRead", FatalException, "No attribute found!");
111       G4Exception("G4GDMLReadSolids::BooleanRe << 109         return;
112                   FatalException, "No attribut << 110       }
113       return;                                  << 111       const G4String attName = Transcode(attribute->getName());
114     }                                          << 112       const G4String attValue = Transcode(attribute->getValue());
115     const G4String attName  = Transcode(attrib << 113 
116     const G4String attValue = Transcode(attrib << 114       if (attName=="name")  { name = GenerateName(attValue); }
117                                                << 115    }
118     if(attName == "name")                      << 116 
119     {                                          << 117    for (xercesc::DOMNode* iter = booleanElement->getFirstChild();
120       name = GenerateName(attValue);           << 118         iter != 0;iter = iter->getNextSibling())
121     }                                          << 119    {
122   }                                            << 120       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
123                                                << 121 
124   for(xercesc::DOMNode* iter = booleanElement- << 122       const xercesc::DOMElement* const child
125       iter                   = iter->getNextSi << 123             = dynamic_cast<xercesc::DOMElement*>(iter);
126   {                                            << 124       if (!child)
127     if(iter->getNodeType() != xercesc::DOMNode << 125       {
128     {                                          << 126         G4Exception("G4GDMLReadSolids::BooleanRead()",
129       continue;                                << 127                     "InvalidRead", FatalException, "No child found!");
130     }                                          << 128         return;
131                                                << 129       }
132     const xercesc::DOMElement* const child =   << 130       const G4String tag = Transcode(child->getTagName());
133       dynamic_cast<xercesc::DOMElement*>(iter) << 131 
134     if(child == nullptr)                       << 132       if (tag=="first") { first = RefRead(child); } else
135     {                                          << 133       if (tag=="second") { second = RefRead(child); } else
136       G4Exception("G4GDMLReadSolids::BooleanRe << 134       if (tag=="position") { VectorRead(child,position); } else
137                   FatalException, "No child fo << 135       if (tag=="rotation") { VectorRead(child,rotation); } else
138       return;                                  << 136       if (tag=="positionref")
139     }                                          << 137         { position = GetPosition(GenerateName(RefRead(child))); } else
140     const G4String tag = Transcode(child->getT << 138       if (tag=="rotationref")
141                                                << 139         { rotation = GetRotation(GenerateName(RefRead(child))); } else
142     if(tag == "first")                         << 140       if (tag=="firstposition") { VectorRead(child,firstposition); } else
143     {                                          << 141       if (tag=="firstrotation") { VectorRead(child,firstrotation); } else
144       first = RefRead(child);                  << 142       if (tag=="firstpositionref")
145     }                                          << 143         { firstposition = GetPosition(GenerateName(RefRead(child))); } else
146     else if(tag == "second")                   << 144       if (tag=="firstrotationref")
147     {                                          << 145         { firstrotation = GetRotation(GenerateName(RefRead(child))); } 
148       scnd = RefRead(child);                   << 146       else
149     }                                          << 147       {
150     else if(tag == "position")                 << 148         G4String error_msg = "Unknown tag in boolean solid: " + tag;
151     {                                          << 149         G4Exception("G4GDMLReadSolids::BooleanRead()", "ReadError",
152       VectorRead(child, position);             << 150                     FatalException, error_msg);
153     }                                          << 151       }
154     else if(tag == "rotation")                 << 152    }
155     {                                          << 153 
156       VectorRead(child, rotation);             << 154    G4VSolid* firstSolid = GetSolid(GenerateName(first));
157     }                                          << 155    G4VSolid* secondSolid = GetSolid(GenerateName(second));
158     else if(tag == "positionref")              << 156 
159     {                                          << 157    G4Transform3D transform(GetRotationMatrix(rotation),position);
160       position = GetPosition(GenerateName(RefR << 158 
161     }                                          << 159    if (( (firstrotation.x()!=0.0) || (firstrotation.y()!=0.0)
162     else if(tag == "rotationref")              << 160                                   || (firstrotation.z()!=0.0))
163     {                                          << 161     || ( (firstposition.x()!=0.0) || (firstposition.y()!=0.0)
164       rotation = GetRotation(GenerateName(RefR << 162                                   || (firstposition.z()!=0.0)))
165     }                                          << 163    { 
166     else if(tag == "firstposition")            << 164       G4Transform3D firsttransform(GetRotationMatrix(firstrotation),
167     {                                          << 165                                    firstposition);
168       VectorRead(child, firstposition);        << 166       firstSolid = new G4DisplacedSolid(GenerateName("displaced_"+first),
169     }                                          << 167                                         firstSolid, firsttransform);
170     else if(tag == "firstrotation")            << 168    }
171     {                                          << 169 
172       VectorRead(child, firstrotation);        << 170    if (op==UNION)
173     }                                          << 171      { new G4UnionSolid(name,firstSolid,secondSolid,transform); } else
174     else if(tag == "firstpositionref")         << 172    if (op==SUBTRACTION)
175     {                                          << 173      { new G4SubtractionSolid(name,firstSolid,secondSolid,transform); } else
176       firstposition = GetPosition(GenerateName << 174    if (op==INTERSECTION)
177     }                                          << 175      { new G4IntersectionSolid(name,firstSolid,secondSolid,transform); }
178     else if(tag == "firstrotationref")         << 
179     {                                          << 
180       firstrotation = GetRotation(GenerateName << 
181     }                                          << 
182     else                                       << 
183     {                                          << 
184       G4String error_msg = "Unknown tag in boo << 
185       G4Exception("G4GDMLReadSolids::BooleanRe << 
186                   FatalException, error_msg);  << 
187     }                                          << 
188   }                                            << 
189                                                << 
190   G4VSolid* firstSolid  = GetSolid(GenerateNam << 
191   G4VSolid* secondSolid = GetSolid(GenerateNam << 
192                                                << 
193   G4Transform3D transform(GetRotationMatrix(ro << 
194                                                << 
195   if(((firstrotation.x() != 0.0) || (firstrota << 
196       (firstrotation.z() != 0.0)) ||           << 
197      ((firstposition.x() != 0.0) || (firstposi << 
198       (firstposition.z() != 0.0)))             << 
199   {                                            << 
200     G4Transform3D firsttransform(GetRotationMa << 
201                                  firstposition << 
202     firstSolid = new G4DisplacedSolid(Generate << 
203                                       firstSol << 
204   }                                            << 
205                                                << 
206   if(op == UNION)                              << 
207   {                                            << 
208     new G4UnionSolid(name, firstSolid, secondS << 
209   }                                            << 
210   else if(op == SUBTRACTION)                   << 
211   {                                            << 
212     new G4SubtractionSolid(name, firstSolid, s << 
213   }                                            << 
214   else if(op == INTERSECTION)                  << 
215   {                                            << 
216     new G4IntersectionSolid(name, firstSolid,  << 
217   }                                            << 
218 }                                                 176 }
219                                                   177 
220 // ------------------------------------------- << 
221 void G4GDMLReadSolids::BoxRead(const xercesc::    178 void G4GDMLReadSolids::BoxRead(const xercesc::DOMElement* const boxElement)
222 {                                                 179 {
223   G4String name;                               << 180    G4String name;
224   G4double lunit = 1.0;                        << 181    G4double lunit = 1.0;
225   G4double x     = 0.0;                        << 182    G4double x = 0.0;
226   G4double y     = 0.0;                        << 183    G4double y = 0.0;
227   G4double z     = 0.0;                        << 184    G4double z = 0.0;
228                                                << 185 
229   const xercesc::DOMNamedNodeMap* const attrib << 186    const xercesc::DOMNamedNodeMap* const attributes
230     boxElement->getAttributes();               << 187          = boxElement->getAttributes();
231   XMLSize_t attributeCount = attributes->getLe << 188    XMLSize_t attributeCount = attributes->getLength();
232                                                << 189 
233   for(XMLSize_t attribute_index = 0; attribute << 190    for (XMLSize_t attribute_index=0;
234       ++attribute_index)                       << 191         attribute_index<attributeCount; attribute_index++)
235   {                                            << 192    {
236     xercesc::DOMNode* attribute_node = attribu << 193       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
237                                                << 194 
238     if(attribute_node->getNodeType() != xerces << 195       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
239     {                                          << 196         { continue; }
240       continue;                                << 197 
241     }                                          << 198       const xercesc::DOMAttr* const attribute
242                                                << 199             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
243     const xercesc::DOMAttr* const attribute =  << 200       if (!attribute)
244       dynamic_cast<xercesc::DOMAttr*>(attribut << 201       {
245     if(attribute == nullptr)                   << 202         G4Exception("G4GDMLReadSolids::BoxRead()",
246     {                                          << 203                     "InvalidRead", FatalException, "No attribute found!");
247       G4Exception("G4GDMLReadSolids::BoxRead() << 204         return;
248                   "No attribute found!");      << 205       }
249       return;                                  << 206       const G4String attName = Transcode(attribute->getName());
250     }                                          << 207       const G4String attValue = Transcode(attribute->getValue());
251     const G4String attName  = Transcode(attrib << 208 
252     const G4String attValue = Transcode(attrib << 209       if (attName=="name") { name = GenerateName(attValue); } else
253                                                << 210       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
254     if(attName == "name")                      << 211       if (attName=="x") { x = eval.Evaluate(attValue); } else
255     {                                          << 212       if (attName=="y") { y = eval.Evaluate(attValue); } else
256       name = GenerateName(attValue);           << 213       if (attName=="z") { z = eval.Evaluate(attValue); }
257     }                                          << 214    }
258     else if(attName == "lunit")                << 215 
259     {                                          << 216    x *= 0.5*lunit;
260       lunit = G4UnitDefinition::GetValueOf(att << 217    y *= 0.5*lunit;
261       if(G4UnitDefinition::GetCategory(attValu << 218    z *= 0.5*lunit;
262       {                                        << 
263         G4Exception("G4GDMLReadSolids::BoxRead << 
264                     FatalException, "Invalid u << 
265       }                                        << 
266     }                                          << 
267     else if(attName == "x")                    << 
268     {                                          << 
269       x = eval.Evaluate(attValue);             << 
270     }                                          << 
271     else if(attName == "y")                    << 
272     {                                          << 
273       y = eval.Evaluate(attValue);             << 
274     }                                          << 
275     else if(attName == "z")                    << 
276     {                                          << 
277       z = eval.Evaluate(attValue);             << 
278     }                                          << 
279   }                                            << 
280                                                << 
281   x *= 0.5 * lunit;                            << 
282   y *= 0.5 * lunit;                            << 
283   z *= 0.5 * lunit;                            << 
284                                                   219 
285   new G4Box(name, x, y, z);                    << 220    new G4Box(name,x,y,z);
286 }                                                 221 }
287                                                   222 
288 // ------------------------------------------- << 
289 void G4GDMLReadSolids::ConeRead(const xercesc:    223 void G4GDMLReadSolids::ConeRead(const xercesc::DOMElement* const coneElement)
290 {                                                 224 {
291   G4String name;                               << 225    G4String name;
292   G4double lunit    = 1.0;                     << 226    G4double lunit = 1.0;
293   G4double aunit    = 1.0;                     << 227    G4double aunit = 1.0;
294   G4double rmin1    = 0.0;                     << 228    G4double rmin1 = 0.0;
295   G4double rmax1    = 0.0;                     << 229    G4double rmax1 = 0.0;
296   G4double rmin2    = 0.0;                     << 230    G4double rmin2 = 0.0;
297   G4double rmax2    = 0.0;                     << 231    G4double rmax2 = 0.0;
298   G4double z        = 0.0;                     << 232    G4double z = 0.0;
299   G4double startphi = 0.0;                     << 233    G4double startphi = 0.0;
300   G4double deltaphi = 0.0;                     << 234    G4double deltaphi = 0.0;
301                                                << 235 
302   const xercesc::DOMNamedNodeMap* const attrib << 236    const xercesc::DOMNamedNodeMap* const attributes
303     coneElement->getAttributes();              << 237          = coneElement->getAttributes();
304   XMLSize_t attributeCount = attributes->getLe << 238    XMLSize_t attributeCount = attributes->getLength();
305                                                << 239 
306   for(XMLSize_t attribute_index = 0; attribute << 240    for (XMLSize_t attribute_index=0;
307       ++attribute_index)                       << 241         attribute_index<attributeCount; attribute_index++)
308   {                                            << 242    {
309     xercesc::DOMNode* attribute_node = attribu << 243       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
310                                                << 244 
311     if(attribute_node->getNodeType() != xerces << 245       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
312     {                                          << 246         { continue; }
313       continue;                                << 247 
314     }                                          << 248       const xercesc::DOMAttr* const attribute
315                                                << 249             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
316     const xercesc::DOMAttr* const attribute =  << 250       if (!attribute)
317       dynamic_cast<xercesc::DOMAttr*>(attribut << 251       {
318     if(attribute == nullptr)                   << 252         G4Exception("G4GDMLReadSolids::ConeRead()",
319     {                                          << 253                     "InvalidRead", FatalException, "No attribute found!");
320       G4Exception("G4GDMLReadSolids::ConeRead( << 254         return;
321                   "No attribute found!");      << 255       }
322       return;                                  << 256       const G4String attName = Transcode(attribute->getName());
323     }                                          << 257       const G4String attValue = Transcode(attribute->getValue());
324     const G4String attName  = Transcode(attrib << 258 
325     const G4String attValue = Transcode(attrib << 259       if (attName=="name") { name = GenerateName(attValue); } else
326                                                << 260       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
327     if(attName == "name")                      << 261       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
328     {                                          << 262       if (attName=="rmin1") { rmin1 = eval.Evaluate(attValue); } else
329       name = GenerateName(attValue);           << 263       if (attName=="rmax1") { rmax1 = eval.Evaluate(attValue); } else
330     }                                          << 264       if (attName=="rmin2") { rmin2 = eval.Evaluate(attValue); } else
331     else if(attName == "lunit")                << 265       if (attName=="rmax2") { rmax2 = eval.Evaluate(attValue); } else
332     {                                          << 266       if (attName=="z") { z = eval.Evaluate(attValue); } else
333       lunit = G4UnitDefinition::GetValueOf(att << 267       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
334       if(G4UnitDefinition::GetCategory(attValu << 268       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
335       {                                        << 269    }
336         G4Exception("G4GDMLReadSolids::ConeRea << 270 
337                     FatalException, "Invalid u << 271    rmin1 *= lunit;
338       }                                        << 272    rmax1 *= lunit;
339     }                                          << 273    rmin2 *= lunit;
340     else if(attName == "aunit")                << 274    rmax2 *= lunit;
341     {                                          << 275    z *= 0.5*lunit;
342       aunit = G4UnitDefinition::GetValueOf(att << 276    startphi *= aunit;
343       if(G4UnitDefinition::GetCategory(attValu << 277    deltaphi *= aunit;
344       {                                        << 278 
345         G4Exception("G4GDMLReadSolids::ConeRea << 279    new G4Cons(name,rmin1,rmax1,rmin2,rmax2,z,startphi,deltaphi);
346                     FatalException, "Invalid u << 280 }
347       }                                        << 281 
348     }                                          << 282 void G4GDMLReadSolids::
349     else if(attName == "rmin1")                << 283 ElconeRead(const xercesc::DOMElement* const elconeElement)
350     {                                          << 284 {
351       rmin1 = eval.Evaluate(attValue);         << 285    G4String name;
352     }                                          << 286    G4double lunit = 1.0;
353     else if(attName == "rmax1")                << 287    G4double dx = 0.0;
354     {                                          << 288    G4double dy = 0.0;
355       rmax1 = eval.Evaluate(attValue);         << 289    G4double zmax = 0.0;
356     }                                          << 290    G4double zcut = 0.0;
357     else if(attName == "rmin2")                << 291 
358     {                                          << 292    const xercesc::DOMNamedNodeMap* const attributes
359       rmin2 = eval.Evaluate(attValue);         << 293          = elconeElement->getAttributes();
360     }                                          << 294    XMLSize_t attributeCount = attributes->getLength();
361     else if(attName == "rmax2")                << 295 
362     {                                          << 296    for (XMLSize_t attribute_index=0;
363       rmax2 = eval.Evaluate(attValue);         << 297         attribute_index<attributeCount; attribute_index++)
364     }                                          << 298    {
365     else if(attName == "z")                    << 299       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
366     {                                          << 300 
367       z = eval.Evaluate(attValue);             << 301       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
368     }                                          << 302         { continue; }
369     else if(attName == "startphi")             << 303 
370     {                                          << 304       const xercesc::DOMAttr* const attribute
371       startphi = eval.Evaluate(attValue);      << 305             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
372     }                                          << 306       if (!attribute)
373     else if(attName == "deltaphi")             << 307       {
374     {                                          << 308         G4Exception("G4GDMLReadSolids::ElconeRead()",
375       deltaphi = eval.Evaluate(attValue);      << 309                     "InvalidRead", FatalException, "No attribute found!");
376     }                                          << 310         return;
377   }                                            << 311       }
378                                                << 312       const G4String attName = Transcode(attribute->getName());
379   rmin1 *= lunit;                              << 313       const G4String attValue = Transcode(attribute->getValue());
380   rmax1 *= lunit;                              << 314 
381   rmin2 *= lunit;                              << 315       if (attName=="name") { name = GenerateName(attValue); } else
382   rmax2 *= lunit;                              << 316       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
383   z *= 0.5 * lunit;                            << 317       if (attName=="dx") { dx = eval.Evaluate(attValue); } else
384   startphi *= aunit;                           << 318       if (attName=="dy") { dy = eval.Evaluate(attValue); } else
385   deltaphi *= aunit;                           << 319       if (attName=="zmax") { zmax = eval.Evaluate(attValue); } else
386                                                << 320       if (attName=="zcut") { zcut = eval.Evaluate(attValue); }
387   new G4Cons(name, rmin1, rmax1, rmin2, rmax2, << 321    }
388 }                                              << 322 
389                                                << 323    zmax *= lunit;
390 // ------------------------------------------- << 324    zcut *= lunit;
391 void G4GDMLReadSolids::ElconeRead(             << 325 
392   const xercesc::DOMElement* const elconeEleme << 326    new G4EllipticalCone(name,dx,dy,zmax,zcut);
393 {                                              << 327 }
394   G4String name;                               << 328 
395   G4double lunit = 1.0;                        << 329 void G4GDMLReadSolids::
396   G4double dx    = 0.0;                        << 330 EllipsoidRead(const xercesc::DOMElement* const ellipsoidElement)
397   G4double dy    = 0.0;                        << 331 {
398   G4double zmax  = 0.0;                        << 332    G4String name;
399   G4double zcut  = 0.0;                        << 333    G4double lunit = 1.0;
400                                                << 334    G4double ax = 0.0;
401   const xercesc::DOMNamedNodeMap* const attrib << 335    G4double by = 0.0;
402     elconeElement->getAttributes();            << 336    G4double cz = 0.0;
403   XMLSize_t attributeCount = attributes->getLe << 337    G4double zcut1 = 0.0;
404                                                << 338    G4double zcut2 = 0.0; 
405   for(XMLSize_t attribute_index = 0; attribute << 339 
406       ++attribute_index)                       << 340    const xercesc::DOMNamedNodeMap* const attributes
407   {                                            << 341          = ellipsoidElement->getAttributes();
408     xercesc::DOMNode* attribute_node = attribu << 342    XMLSize_t attributeCount = attributes->getLength();
409                                                << 343 
410     if(attribute_node->getNodeType() != xerces << 344    for (XMLSize_t attribute_index=0;
411     {                                          << 345         attribute_index<attributeCount; attribute_index++)
412       continue;                                << 346    {
413     }                                          << 347       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
414                                                << 348 
415     const xercesc::DOMAttr* const attribute =  << 349       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
416       dynamic_cast<xercesc::DOMAttr*>(attribut << 350         { continue; }
417     if(attribute == nullptr)                   << 351 
418     {                                          << 352       const xercesc::DOMAttr* const attribute
419       G4Exception("G4GDMLReadSolids::ElconeRea << 353             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
420                   FatalException, "No attribut << 354       if (!attribute)
421       return;                                  << 355       {
422     }                                          << 356         G4Exception("G4GDMLReadSolids::EllipsoidRead()",
423     const G4String attName  = Transcode(attrib << 357                     "InvalidRead", FatalException, "No attribute found!");
424     const G4String attValue = Transcode(attrib << 358         return;
425                                                << 359       }
426     if(attName == "name")                      << 360       const G4String attName = Transcode(attribute->getName());
427     {                                          << 361       const G4String attValue = Transcode(attribute->getValue());
428       name = GenerateName(attValue);           << 362 
429     }                                          << 363       if (attName=="name") { name  = GenerateName(attValue); } else
430     else if(attName == "lunit")                << 364       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
431     {                                          << 365       if (attName=="ax") { ax = eval.Evaluate(attValue); } else
432       lunit = G4UnitDefinition::GetValueOf(att << 366       if (attName=="by") { by = eval.Evaluate(attValue); } else
433       if(G4UnitDefinition::GetCategory(attValu << 367       if (attName=="cz") { cz = eval.Evaluate(attValue); } else
434       {                                        << 368       if (attName=="zcut1") { zcut1 = eval.Evaluate(attValue); } else
435         G4Exception("G4GDMLReadSolids::ElconeR << 369       if (attName=="zcut2") { zcut2 = eval.Evaluate(attValue); }
436                     FatalException, "Invalid u << 370    }
437       }                                        << 371 
438     }                                          << 372    ax *= lunit;
439     else if(attName == "dx")                   << 373    by *= lunit;
440     {                                          << 374    cz *= lunit;
441       dx = eval.Evaluate(attValue);            << 375    zcut1 *= lunit;
442     }                                          << 376    zcut2 *= lunit; 
443     else if(attName == "dy")                   << 377 
444     {                                          << 378    new G4Ellipsoid(name,ax,by,cz,zcut1,zcut2);
445       dy = eval.Evaluate(attValue);            << 379 }
446     }                                          << 380 
447     else if(attName == "zmax")                 << 381 void G4GDMLReadSolids::
448     {                                          << 382 EltubeRead(const xercesc::DOMElement* const eltubeElement)
449       zmax = eval.Evaluate(attValue);          << 383 {
450     }                                          << 384    G4String name;
451     else if(attName == "zcut")                 << 385    G4double lunit = 1.0;
452     {                                          << 386    G4double dx = 0.0;
453       zcut = eval.Evaluate(attValue);          << 387    G4double dy = 0.0;
454     }                                          << 388    G4double dz = 0.0;
455   }                                            << 389 
456                                                << 390    const xercesc::DOMNamedNodeMap* const attributes
457   zmax *= lunit;                               << 391          = eltubeElement->getAttributes();
458   zcut *= lunit;                               << 392    XMLSize_t attributeCount = attributes->getLength();
459                                                << 393 
460   new G4EllipticalCone(name, dx, dy, zmax, zcu << 394    for (XMLSize_t attribute_index=0;
461 }                                              << 395         attribute_index<attributeCount; attribute_index++)
462                                                << 396    {
463 // ------------------------------------------- << 397       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
464 void G4GDMLReadSolids::EllipsoidRead(          << 398 
465   const xercesc::DOMElement* const ellipsoidEl << 399       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
466 {                                              << 400         { continue; }
467   G4String name;                               << 401 
468   G4double lunit = 1.0;                        << 402       const xercesc::DOMAttr* const attribute
469   G4double ax    = 0.0;                        << 403             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
470   G4double by    = 0.0;                        << 404       if (!attribute)
471   G4double cz    = 0.0;                        << 405       {
472   G4double zcut1 = 0.0;                        << 406         G4Exception("G4GDMLReadSolids::EltubeRead()",
473   G4double zcut2 = 0.0;                        << 407                     "InvalidRead", FatalException, "No attribute found!");
474                                                << 408         return;
475   const xercesc::DOMNamedNodeMap* const attrib << 409       }
476     ellipsoidElement->getAttributes();         << 410       const G4String attName = Transcode(attribute->getName());
477   XMLSize_t attributeCount = attributes->getLe << 411       const G4String attValue = Transcode(attribute->getValue());
478                                                << 412 
479   for(XMLSize_t attribute_index = 0; attribute << 413       if (attName=="name") { name = GenerateName(attValue); } else
480       ++attribute_index)                       << 414       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
481   {                                            << 415       if (attName=="dx") { dx = eval.Evaluate(attValue); } else
482     xercesc::DOMNode* attribute_node = attribu << 416       if (attName=="dy") { dy = eval.Evaluate(attValue); } else
483                                                << 417       if (attName=="dz") { dz = eval.Evaluate(attValue); }
484     if(attribute_node->getNodeType() != xerces << 418    }
485     {                                          << 419 
486       continue;                                << 420    dx *= lunit;
487     }                                          << 421    dy *= lunit;
488                                                << 422    dz *= lunit;
489     const xercesc::DOMAttr* const attribute =  << 
490       dynamic_cast<xercesc::DOMAttr*>(attribut << 
491     if(attribute == nullptr)                   << 
492     {                                          << 
493       G4Exception("G4GDMLReadSolids::Ellipsoid << 
494                   FatalException, "No attribut << 
495       return;                                  << 
496     }                                          << 
497     const G4String attName  = Transcode(attrib << 
498     const G4String attValue = Transcode(attrib << 
499                                                << 
500     if(attName == "name")                      << 
501     {                                          << 
502       name = GenerateName(attValue);           << 
503     }                                          << 
504     else if(attName == "lunit")                << 
505     {                                          << 
506       lunit = G4UnitDefinition::GetValueOf(att << 
507       if(G4UnitDefinition::GetCategory(attValu << 
508       {                                        << 
509         G4Exception("G4GDMLReadSolids::Ellipso << 
510                     FatalException, "Invalid u << 
511       }                                        << 
512     }                                          << 
513     else if(attName == "ax")                   << 
514     {                                          << 
515       ax = eval.Evaluate(attValue);            << 
516     }                                          << 
517     else if(attName == "by")                   << 
518     {                                          << 
519       by = eval.Evaluate(attValue);            << 
520     }                                          << 
521     else if(attName == "cz")                   << 
522     {                                          << 
523       cz = eval.Evaluate(attValue);            << 
524     }                                          << 
525     else if(attName == "zcut1")                << 
526     {                                          << 
527       zcut1 = eval.Evaluate(attValue);         << 
528     }                                          << 
529     else if(attName == "zcut2")                << 
530     {                                          << 
531       zcut2 = eval.Evaluate(attValue);         << 
532     }                                          << 
533   }                                            << 
534                                                << 
535   ax *= lunit;                                 << 
536   by *= lunit;                                 << 
537   cz *= lunit;                                 << 
538   zcut1 *= lunit;                              << 
539   zcut2 *= lunit;                              << 
540                                                << 
541   new G4Ellipsoid(name, ax, by, cz, zcut1, zcu << 
542 }                                              << 
543                                                << 
544 // ------------------------------------------- << 
545 void G4GDMLReadSolids::EltubeRead(             << 
546   const xercesc::DOMElement* const eltubeEleme << 
547 {                                              << 
548   G4String name;                               << 
549   G4double lunit = 1.0;                        << 
550   G4double dx    = 0.0;                        << 
551   G4double dy    = 0.0;                        << 
552   G4double dz    = 0.0;                        << 
553                                                << 
554   const xercesc::DOMNamedNodeMap* const attrib << 
555     eltubeElement->getAttributes();            << 
556   XMLSize_t attributeCount = attributes->getLe << 
557                                                << 
558   for(XMLSize_t attribute_index = 0; attribute << 
559       ++attribute_index)                       << 
560   {                                            << 
561     xercesc::DOMNode* attribute_node = attribu << 
562                                                << 
563     if(attribute_node->getNodeType() != xerces << 
564     {                                          << 
565       continue;                                << 
566     }                                          << 
567                                                << 
568     const xercesc::DOMAttr* const attribute =  << 
569       dynamic_cast<xercesc::DOMAttr*>(attribut << 
570     if(attribute == nullptr)                   << 
571     {                                          << 
572       G4Exception("G4GDMLReadSolids::EltubeRea << 
573                   FatalException, "No attribut << 
574       return;                                  << 
575     }                                          << 
576     const G4String attName  = Transcode(attrib << 
577     const G4String attValue = Transcode(attrib << 
578                                                << 
579     if(attName == "name")                      << 
580     {                                          << 
581       name = GenerateName(attValue);           << 
582     }                                          << 
583     else if(attName == "lunit")                << 
584     {                                          << 
585       lunit = G4UnitDefinition::GetValueOf(att << 
586       if(G4UnitDefinition::GetCategory(attValu << 
587       {                                        << 
588         G4Exception("G4GDMLReadSolids::EltubeR << 
589                     FatalException, "Invalid u << 
590       }                                        << 
591     }                                          << 
592     else if(attName == "dx")                   << 
593     {                                          << 
594       dx = eval.Evaluate(attValue);            << 
595     }                                          << 
596     else if(attName == "dy")                   << 
597     {                                          << 
598       dy = eval.Evaluate(attValue);            << 
599     }                                          << 
600     else if(attName == "dz")                   << 
601     {                                          << 
602       dz = eval.Evaluate(attValue);            << 
603     }                                          << 
604   }                                            << 
605                                                << 
606   dx *= lunit;                                 << 
607   dy *= lunit;                                 << 
608   dz *= lunit;                                 << 
609                                                   423 
610   new G4EllipticalTube(name, dx, dy, dz);      << 424    new G4EllipticalTube(name,dx,dy,dz);
611 }                                                 425 }
612                                                   426 
613 // ------------------------------------------- << 
614 void G4GDMLReadSolids::XtruRead(const xercesc:    427 void G4GDMLReadSolids::XtruRead(const xercesc::DOMElement* const xtruElement)
615 {                                                 428 {
616   G4String name;                               << 429    G4String name;
617   G4double lunit = 1.0;                        << 430    G4double lunit = 1.0;
618                                                   431 
619   const xercesc::DOMNamedNodeMap* const attrib << 432    const xercesc::DOMNamedNodeMap* const attributes
620     xtruElement->getAttributes();              << 433          = xtruElement->getAttributes();
621   XMLSize_t attributeCount = attributes->getLe << 434    XMLSize_t attributeCount = attributes->getLength();
622                                                << 
623   for(XMLSize_t attribute_index = 0; attribute << 
624       ++attribute_index)                       << 
625   {                                            << 
626     xercesc::DOMNode* attribute_node = attribu << 
627                                                << 
628     if(attribute_node->getNodeType() != xerces << 
629     {                                          << 
630       continue;                                << 
631     }                                          << 
632                                                << 
633     const xercesc::DOMAttr* const attribute =  << 
634       dynamic_cast<xercesc::DOMAttr*>(attribut << 
635     if(attribute == nullptr)                   << 
636     {                                          << 
637       G4Exception("G4GDMLReadSolids::XtruRead( << 
638                   "No attribute found!");      << 
639       return;                                  << 
640     }                                          << 
641     const G4String attName  = Transcode(attrib << 
642     const G4String attValue = Transcode(attrib << 
643                                                << 
644     if(attName == "name")                      << 
645     {                                          << 
646       name = GenerateName(attValue);           << 
647     }                                          << 
648     else if(attName == "lunit")                << 
649     {                                          << 
650       lunit = G4UnitDefinition::GetValueOf(att << 
651       if(G4UnitDefinition::GetCategory(attValu << 
652       {                                        << 
653         G4Exception("G4GDMLReadSolids::XtruRea << 
654                     FatalException, "Invalid u << 
655       }                                        << 
656     }                                          << 
657   }                                            << 
658                                                << 
659   std::vector<G4TwoVector> twoDimVertexList;   << 
660   std::vector<G4ExtrudedSolid::ZSection> secti << 
661                                                << 
662   for(xercesc::DOMNode* iter = xtruElement->ge << 
663       iter                   = iter->getNextSi << 
664   {                                            << 
665     if(iter->getNodeType() != xercesc::DOMNode << 
666     {                                          << 
667       continue;                                << 
668     }                                          << 
669                                                << 
670     const xercesc::DOMElement* const child =   << 
671       dynamic_cast<xercesc::DOMElement*>(iter) << 
672     if(child == nullptr)                       << 
673     {                                          << 
674       G4Exception("G4GDMLReadSolids::XtruRead( << 
675                   "No child found!");          << 
676       return;                                  << 
677     }                                          << 
678     const G4String tag = Transcode(child->getT << 
679                                                << 
680     if(tag == "twoDimVertex")                  << 
681     {                                          << 
682       twoDimVertexList.push_back(TwoDimVertexR << 
683     }                                          << 
684     else if(tag == "section")                  << 
685     {                                          << 
686       sectionList.push_back(SectionRead(child, << 
687     }                                          << 
688   }                                            << 
689                                                   435 
690   new G4ExtrudedSolid(name, twoDimVertexList,  << 436    for (XMLSize_t attribute_index=0;
691 }                                              << 437         attribute_index<attributeCount; attribute_index++)
                                                   >> 438    {
                                                   >> 439       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
692                                                   440 
693 // ------------------------------------------- << 441       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
694 void G4GDMLReadSolids::HypeRead(const xercesc: << 442         { continue; } 
695 {                                              << 
696   G4String name;                               << 
697   G4double lunit = 1.0;                        << 
698   G4double aunit = 1.0;                        << 
699   G4double rmin  = 0.0;                        << 
700   G4double rmax  = 0.0;                        << 
701   G4double inst  = 0.0;                        << 
702   G4double outst = 0.0;                        << 
703   G4double z     = 0.0;                        << 
704                                                << 
705   const xercesc::DOMNamedNodeMap* const attrib << 
706     hypeElement->getAttributes();              << 
707   XMLSize_t attributeCount = attributes->getLe << 
708                                                << 
709   for(XMLSize_t attribute_index = 0; attribute << 
710       ++attribute_index)                       << 
711   {                                            << 
712     xercesc::DOMNode* attribute_node = attribu << 
713                                                << 
714     if(attribute_node->getNodeType() != xerces << 
715     {                                          << 
716       continue;                                << 
717     }                                          << 
718                                                << 
719     const xercesc::DOMAttr* const attribute =  << 
720       dynamic_cast<xercesc::DOMAttr*>(attribut << 
721     if(attribute == nullptr)                   << 
722     {                                          << 
723       G4Exception("G4GDMLReadSolids::HypeRead( << 
724                   "No attribute found!");      << 
725       return;                                  << 
726     }                                          << 
727     const G4String attName  = Transcode(attrib << 
728     const G4String attValue = Transcode(attrib << 
729                                                << 
730     if(attName == "name")                      << 
731     {                                          << 
732       name = GenerateName(attValue);           << 
733     }                                          << 
734     else if(attName == "lunit")                << 
735     {                                          << 
736       lunit = G4UnitDefinition::GetValueOf(att << 
737       if(G4UnitDefinition::GetCategory(attValu << 
738       {                                        << 
739         G4Exception("G4GDMLReadSolids::HypeRea << 
740                     FatalException, "Invalid u << 
741       }                                        << 
742     }                                          << 
743     else if(attName == "aunit")                << 
744     {                                          << 
745       aunit = G4UnitDefinition::GetValueOf(att << 
746       if(G4UnitDefinition::GetCategory(attValu << 
747       {                                        << 
748         G4Exception("G4GDMLReadSolids::HypeRea << 
749                     FatalException, "Invalid u << 
750       }                                        << 
751     }                                          << 
752     else if(attName == "rmin")                 << 
753     {                                          << 
754       rmin = eval.Evaluate(attValue);          << 
755     }                                          << 
756     else if(attName == "rmax")                 << 
757     {                                          << 
758       rmax = eval.Evaluate(attValue);          << 
759     }                                          << 
760     else if(attName == "inst")                 << 
761     {                                          << 
762       inst = eval.Evaluate(attValue);          << 
763     }                                          << 
764     else if(attName == "outst")                << 
765     {                                          << 
766       outst = eval.Evaluate(attValue);         << 
767     }                                          << 
768     else if(attName == "z")                    << 
769     {                                          << 
770       z = eval.Evaluate(attValue);             << 
771     }                                          << 
772   }                                            << 
773                                                << 
774   rmin *= lunit;                               << 
775   rmax *= lunit;                               << 
776   inst *= aunit;                               << 
777   outst *= aunit;                              << 
778   z *= 0.5 * lunit;                            << 
779                                                   443 
780   new G4Hype(name, rmin, rmax, inst, outst, z) << 444       const xercesc::DOMAttr* const attribute
781 }                                              << 445             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
782                                                << 446       if (!attribute)
783 // ------------------------------------------- << 447       {
784 void G4GDMLReadSolids::MultiUnionNodeRead(     << 448         G4Exception("G4GDMLReadSolids::XtruRead()",
785   const xercesc::DOMElement* const unionNodeEl << 449                     "InvalidRead", FatalException, "No attribute found!");
786   G4MultiUnion* const multiUnionSolid)         << 450         return;
787 {                                              << 451       }
788   G4String name;                               << 452       const G4String attName = Transcode(attribute->getName());
789   G4String solid;                              << 453       const G4String attValue = Transcode(attribute->getValue());
790   G4ThreeVector position(0.0, 0.0, 0.0);       << 
791   G4ThreeVector rotation(0.0, 0.0, 0.0);       << 
792                                                << 
793   const xercesc::DOMNamedNodeMap* const attrib << 
794     unionNodeElement->getAttributes();         << 
795   XMLSize_t attributeCount = attributes->getLe << 
796                                                << 
797   for(XMLSize_t attribute_index = 0; attribute << 
798       ++attribute_index)                       << 
799   {                                            << 
800     xercesc::DOMNode* attribute_node = attribu << 
801                                                << 
802     if(attribute_node->getNodeType() != xerces << 
803     {                                          << 
804       continue;                                << 
805     }                                          << 
806                                                << 
807     const xercesc::DOMAttr* const attribute =  << 
808       dynamic_cast<xercesc::DOMAttr*>(attribut << 
809     if(attribute == nullptr)                   << 
810     {                                          << 
811       G4Exception("G4GDMLReadSolids::MultiUnio << 
812                   FatalException, "No attribut << 
813       return;                                  << 
814     }                                          << 
815     const G4String attName  = Transcode(attrib << 
816     const G4String attValue = Transcode(attrib << 
817                                                << 
818     if(attName == "name")                      << 
819     {                                          << 
820       name = GenerateName(attValue);           << 
821     }                                          << 
822   }                                            << 
823                                                << 
824   for(xercesc::DOMNode* iter = unionNodeElemen << 
825                         iter != nullptr; iter  << 
826   {                                            << 
827     if(iter->getNodeType() != xercesc::DOMNode << 
828     {                                          << 
829       continue;                                << 
830     }                                          << 
831                                                << 
832     const xercesc::DOMElement* const child =   << 
833       dynamic_cast<xercesc::DOMElement*>(iter) << 
834     if(child == nullptr)                       << 
835     {                                          << 
836       G4Exception("G4GDMLReadSolids::MultiUnio << 
837                   FatalException, "No child fo << 
838       return;                                  << 
839     }                                          << 
840     const G4String tag = Transcode(child->getT << 
841                                                << 
842     if(tag == "position")                      << 
843     {                                          << 
844       VectorRead(child, position);             << 
845     }                                          << 
846     else if(tag == "rotation")                 << 
847     {                                          << 
848       VectorRead(child, rotation);             << 
849     }                                          << 
850     else if(tag == "positionref")              << 
851     {                                          << 
852       position = GetPosition(GenerateName(RefR << 
853     }                                          << 
854     else if(tag == "rotationref")              << 
855     {                                          << 
856       rotation = GetRotation(GenerateName(RefR << 
857     }                                          << 
858     else if(tag == "solid")                    << 
859     {                                          << 
860       solid = RefRead(child);                  << 
861     }                                          << 
862     else                                       << 
863     {                                          << 
864       G4String error_msg = "Unknown tag in Mul << 
865       G4Exception("G4GDMLReadSolids::MultiUnio << 
866                   FatalException, error_msg);  << 
867     }                                          << 
868   }                                            << 
869   G4VSolid* solidNode = GetSolid(GenerateName( << 
870   G4Transform3D transform(GetRotationMatrix(ro << 
871   multiUnionSolid->AddNode(*solidNode, transfo << 
872 }                                              << 
873                                                << 
874 // ------------------------------------------- << 
875 void G4GDMLReadSolids::MultiUnionRead(         << 
876   const xercesc::DOMElement* const unionElemen << 
877 {                                              << 
878   G4String name;                               << 
879                                                << 
880   const xercesc::DOMNamedNodeMap* const attrib << 
881     unionElement->getAttributes();             << 
882   XMLSize_t attributeCount = attributes->getLe << 
883                                                << 
884   for(XMLSize_t attribute_index = 0; attribute << 
885       ++attribute_index)                       << 
886   {                                            << 
887     xercesc::DOMNode* attribute_node = attribu << 
888                                                << 
889     if(attribute_node->getNodeType() != xerces << 
890     {                                          << 
891       continue;                                << 
892     }                                          << 
893                                                << 
894     const xercesc::DOMAttr* const attribute =  << 
895       dynamic_cast<xercesc::DOMAttr*>(attribut << 
896     if(attribute == nullptr)                   << 
897     {                                          << 
898       G4Exception("G4GDMLReadSolids::MultiUnio << 
899                   FatalException, "No attribut << 
900       return;                                  << 
901     }                                          << 
902     const G4String attName  = Transcode(attrib << 
903     const G4String attValue = Transcode(attrib << 
904                                                << 
905     if(attName == "name")                      << 
906     {                                          << 
907       name = GenerateName(attValue);           << 
908     }                                          << 
909   }                                            << 
910                                                << 
911   G4MultiUnion* multiUnion = new G4MultiUnion( << 
912                                                << 
913   for(xercesc::DOMNode* iter = unionElement->g << 
914       iter                   = iter->getNextSi << 
915   {                                            << 
916     if(iter->getNodeType() != xercesc::DOMNode << 
917     {                                          << 
918       continue;                                << 
919     }                                          << 
920                                                << 
921     const xercesc::DOMElement* const child =   << 
922       dynamic_cast<xercesc::DOMElement*>(iter) << 
923     if(child == nullptr)                       << 
924     {                                          << 
925       G4Exception("G4GDMLReadSolids::MultiUnio << 
926                   FatalException, "No child fo << 
927       return;                                  << 
928     }                                          << 
929     const G4String tag = Transcode(child->getT << 
930                                                << 
931     if(tag == "multiUnionNode")                << 
932     {                                          << 
933       MultiUnionNodeRead(child, multiUnion);   << 
934     }                                          << 
935     else                                       << 
936     {                                          << 
937       G4String error_msg = "Unknown tag in Mul << 
938       G4Exception("G4GDMLReadSolids::MultiUnio << 
939                   FatalException, error_msg);  << 
940     }                                          << 
941   }                                            << 
942   multiUnion->Voxelize();                      << 
943 }                                              << 
944                                                << 
945 // ------------------------------------------- << 
946 void G4GDMLReadSolids::OrbRead(const xercesc:: << 
947 {                                              << 
948   G4String name;                               << 
949   G4double lunit = 1.0;                        << 
950   G4double r     = 0.0;                        << 
951                                                << 
952   const xercesc::DOMNamedNodeMap* const attrib << 
953     orbElement->getAttributes();               << 
954   XMLSize_t attributeCount = attributes->getLe << 
955                                                << 
956   for(XMLSize_t attribute_index = 0; attribute << 
957       ++attribute_index)                       << 
958   {                                            << 
959     xercesc::DOMNode* attribute_node = attribu << 
960                                                << 
961     if(attribute_node->getNodeType() != xerces << 
962     {                                          << 
963       continue;                                << 
964     }                                          << 
965                                                << 
966     const xercesc::DOMAttr* const attribute =  << 
967       dynamic_cast<xercesc::DOMAttr*>(attribut << 
968     if(attribute == nullptr)                   << 
969     {                                          << 
970       G4Exception("G4GDMLReadSolids::OrbRead() << 
971                   "No attribute found!");      << 
972       return;                                  << 
973     }                                          << 
974     const G4String attName  = Transcode(attrib << 
975     const G4String attValue = Transcode(attrib << 
976                                                << 
977     if(attName == "name")                      << 
978     {                                          << 
979       name = GenerateName(attValue);           << 
980     }                                          << 
981     else if(attName == "lunit")                << 
982     {                                          << 
983       lunit = G4UnitDefinition::GetValueOf(att << 
984       if(G4UnitDefinition::GetCategory(attValu << 
985       {                                        << 
986         G4Exception("G4GDMLReadSolids::OrbRead << 
987                     FatalException, "Invalid u << 
988       }                                        << 
989     }                                          << 
990     else if(attName == "r")                    << 
991     {                                          << 
992       r = eval.Evaluate(attValue);             << 
993     }                                          << 
994   }                                            << 
995                                                   454 
996   r *= lunit;                                  << 455       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 456       if (attName=="lunit") { lunit = eval.Evaluate(attValue); }
                                                   >> 457    }
997                                                   458 
998   new G4Orb(name, r);                          << 459    std::vector<G4TwoVector> twoDimVertexList;
999 }                                              << 460    std::vector<G4ExtrudedSolid::ZSection> sectionList;
1000                                                  461 
1001 // ------------------------------------------ << 462    for (xercesc::DOMNode* iter = xtruElement->getFirstChild();
1002 void G4GDMLReadSolids::ParaRead(const xercesc << 463         iter != 0; iter = iter->getNextSibling())
1003 {                                             << 464    {
1004   G4String name;                              << 465       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
1005   G4double lunit = 1.0;                       << 
1006   G4double aunit = 1.0;                       << 
1007   G4double x     = 0.0;                       << 
1008   G4double y     = 0.0;                       << 
1009   G4double z     = 0.0;                       << 
1010   G4double alpha = 0.0;                       << 
1011   G4double theta = 0.0;                       << 
1012   G4double phi   = 0.0;                       << 
1013                                               << 
1014   const xercesc::DOMNamedNodeMap* const attri << 
1015     paraElement->getAttributes();             << 
1016   XMLSize_t attributeCount = attributes->getL << 
1017                                               << 
1018   for(XMLSize_t attribute_index = 0; attribut << 
1019       ++attribute_index)                      << 
1020   {                                           << 
1021     xercesc::DOMNode* attribute_node = attrib << 
1022                                               << 
1023     if(attribute_node->getNodeType() != xerce << 
1024     {                                         << 
1025       continue;                               << 
1026     }                                         << 
1027                                               << 
1028     const xercesc::DOMAttr* const attribute = << 
1029       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1030     if(attribute == nullptr)                  << 
1031     {                                         << 
1032       G4Exception("G4GDMLReadSolids::ParaRead << 
1033                   "No attribute found!");     << 
1034       return;                                 << 
1035     }                                         << 
1036     const G4String attName  = Transcode(attri << 
1037     const G4String attValue = Transcode(attri << 
1038                                               << 
1039     if(attName == "name")                     << 
1040     {                                         << 
1041       name = GenerateName(attValue);          << 
1042     }                                         << 
1043     else if(attName == "lunit")               << 
1044     {                                         << 
1045       lunit = G4UnitDefinition::GetValueOf(at << 
1046       if(G4UnitDefinition::GetCategory(attVal << 
1047       {                                       << 
1048         G4Exception("G4GDMLReadSolids::ParaRe << 
1049                     FatalException, "Invalid  << 
1050       }                                       << 
1051     }                                         << 
1052     else if(attName == "aunit")               << 
1053     {                                         << 
1054       aunit = G4UnitDefinition::GetValueOf(at << 
1055       if(G4UnitDefinition::GetCategory(attVal << 
1056       {                                       << 
1057         G4Exception("G4GDMLReadSolids::ParaRe << 
1058                     FatalException, "Invalid  << 
1059       }                                       << 
1060     }                                         << 
1061     else if(attName == "x")                   << 
1062     {                                         << 
1063       x = eval.Evaluate(attValue);            << 
1064     }                                         << 
1065     else if(attName == "y")                   << 
1066     {                                         << 
1067       y = eval.Evaluate(attValue);            << 
1068     }                                         << 
1069     else if(attName == "z")                   << 
1070     {                                         << 
1071       z = eval.Evaluate(attValue);            << 
1072     }                                         << 
1073     else if(attName == "alpha")               << 
1074     {                                         << 
1075       alpha = eval.Evaluate(attValue);        << 
1076     }                                         << 
1077     else if(attName == "theta")               << 
1078     {                                         << 
1079       theta = eval.Evaluate(attValue);        << 
1080     }                                         << 
1081     else if(attName == "phi")                 << 
1082     {                                         << 
1083       phi = eval.Evaluate(attValue);          << 
1084     }                                         << 
1085   }                                           << 
1086                                               << 
1087   x *= 0.5 * lunit;                           << 
1088   y *= 0.5 * lunit;                           << 
1089   z *= 0.5 * lunit;                           << 
1090   alpha *= aunit;                             << 
1091   theta *= aunit;                             << 
1092   phi *= aunit;                               << 
1093                                                  466 
1094   new G4Para(name, x, y, z, alpha, theta, phi << 467       const xercesc::DOMElement* const child
1095 }                                             << 468             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 469       if (!child)
                                                   >> 470       {
                                                   >> 471         G4Exception("G4GDMLReadSolids::XtruRead()",
                                                   >> 472                     "InvalidRead", FatalException, "No child found!");
                                                   >> 473         return;
                                                   >> 474       }
                                                   >> 475       const G4String tag = Transcode(child->getTagName());
1096                                                  476 
1097 // ------------------------------------------ << 477       if (tag=="twoDimVertex")
1098 void G4GDMLReadSolids::ParaboloidRead(        << 478         { twoDimVertexList.push_back(TwoDimVertexRead(child,lunit)); } else
1099   const xercesc::DOMElement* const paraElemen << 479       if (tag=="section")
1100 {                                             << 480         { sectionList.push_back(SectionRead(child,lunit)); }
1101   G4String name;                              << 481    }
1102   G4double lunit = 1.0;                       << 
1103   G4double rlo   = 0.0;                       << 
1104   G4double rhi   = 0.0;                       << 
1105   G4double dz    = 0.0;                       << 
1106                                               << 
1107   const xercesc::DOMNamedNodeMap* const attri << 
1108     paraElement->getAttributes();             << 
1109   XMLSize_t attributeCount = attributes->getL << 
1110                                               << 
1111   for(XMLSize_t attribute_index = 0; attribut << 
1112       ++attribute_index)                      << 
1113   {                                           << 
1114     xercesc::DOMNode* attribute_node = attrib << 
1115                                               << 
1116     if(attribute_node->getNodeType() != xerce << 
1117     {                                         << 
1118       continue;                               << 
1119     }                                         << 
1120                                               << 
1121     const xercesc::DOMAttr* const attribute = << 
1122       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1123     if(attribute == nullptr)                  << 
1124     {                                         << 
1125       G4Exception("G4GDMLReadSolids::Parabolo << 
1126                   FatalException, "No attribu << 
1127       return;                                 << 
1128     }                                         << 
1129     const G4String attName  = Transcode(attri << 
1130     const G4String attValue = Transcode(attri << 
1131                                               << 
1132     if(attName == "name")                     << 
1133     {                                         << 
1134       name = GenerateName(attValue);          << 
1135     }                                         << 
1136     else if(attName == "lunit")               << 
1137     {                                         << 
1138       lunit = G4UnitDefinition::GetValueOf(at << 
1139       if(G4UnitDefinition::GetCategory(attVal << 
1140       {                                       << 
1141         G4Exception("G4GDMLReadSolids::Parabo << 
1142                     FatalException, "Invalid  << 
1143       }                                       << 
1144     }                                         << 
1145     else if(attName == "rlo")                 << 
1146     {                                         << 
1147       rlo = eval.Evaluate(attValue);          << 
1148     }                                         << 
1149     else if(attName == "rhi")                 << 
1150     {                                         << 
1151       rhi = eval.Evaluate(attValue);          << 
1152     }                                         << 
1153     else if(attName == "dz")                  << 
1154     {                                         << 
1155       dz = eval.Evaluate(attValue);           << 
1156     }                                         << 
1157   }                                           << 
1158                                               << 
1159   rlo *= 1. * lunit;                          << 
1160   rhi *= 1. * lunit;                          << 
1161   dz *= 1. * lunit;                           << 
1162                                                  482 
1163   new G4Paraboloid(name, dz, rlo, rhi);       << 483    new G4ExtrudedSolid(name,twoDimVertexList,sectionList);
1164 }                                                484 }
1165                                                  485 
1166 // ------------------------------------------ << 486 void G4GDMLReadSolids::HypeRead(const xercesc::DOMElement* const hypeElement)
1167 void G4GDMLReadSolids::PolyconeRead(          << 
1168   const xercesc::DOMElement* const polyconeEl << 
1169 {                                                487 {
1170   G4String name;                              << 488    G4String name;
1171   G4double lunit    = 1.0;                    << 489    G4double lunit = 1.0;
1172   G4double aunit    = 1.0;                    << 490    G4double aunit = 1.0;
1173   G4double startphi = 0.0;                    << 491    G4double rmin = 0.0;
1174   G4double deltaphi = 0.0;                    << 492    G4double rmax = 0.0;
1175                                               << 493    G4double inst = 0.0;
1176   const xercesc::DOMNamedNodeMap* const attri << 494    G4double outst = 0.0;
1177     polyconeElement->getAttributes();         << 495    G4double z = 0.0;
1178   XMLSize_t attributeCount = attributes->getL << 496 
1179                                               << 497    const xercesc::DOMNamedNodeMap* const attributes
1180   for(XMLSize_t attribute_index = 0; attribut << 498          = hypeElement->getAttributes();
1181       ++attribute_index)                      << 499    XMLSize_t attributeCount = attributes->getLength();
1182   {                                           << 500 
1183     xercesc::DOMNode* attribute_node = attrib << 501    for (XMLSize_t attribute_index=0;
1184                                               << 502         attribute_index<attributeCount; attribute_index++)
1185     if(attribute_node->getNodeType() != xerce << 503    {
1186     {                                         << 504       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1187       continue;                               << 505 
1188     }                                         << 506       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1189                                               << 507         { continue; }
1190     const xercesc::DOMAttr* const attribute = << 508 
1191       dynamic_cast<xercesc::DOMAttr*>(attribu << 509       const xercesc::DOMAttr* const attribute
1192     if(attribute == nullptr)                  << 510             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
1193     {                                         << 511       if (!attribute)
1194       G4Exception("G4GDMLReadSolids::Polycone << 512       {
1195                   FatalException, "No attribu << 513         G4Exception("G4GDMLReadSolids::HypeRead()",
1196       return;                                 << 514                     "InvalidRead", FatalException, "No attribute found!");
1197     }                                         << 515         return;
1198     const G4String attName  = Transcode(attri << 516       }
1199     const G4String attValue = Transcode(attri << 517       const G4String attName = Transcode(attribute->getName());
1200                                               << 518       const G4String attValue = Transcode(attribute->getValue());
1201     if(attName == "name")                     << 519 
1202     {                                         << 520       if (attName=="name") { name = GenerateName(attValue); } else
1203       name = GenerateName(attValue);          << 521       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1204     }                                         << 522       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1205     else if(attName == "lunit")               << 523       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
1206     {                                         << 524       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
1207       lunit = G4UnitDefinition::GetValueOf(at << 525       if (attName=="inst") { inst = eval.Evaluate(attValue); } else
1208       if(G4UnitDefinition::GetCategory(attVal << 526       if (attName=="outst") { outst = eval.Evaluate(attValue); } else
1209       {                                       << 527       if (attName=="z") { z = eval.Evaluate(attValue); }
1210         G4Exception("G4GDMLReadSolids::Polyco << 528    }
1211                     FatalException, "Invalid  << 529 
1212       }                                       << 530    rmin *= lunit;
1213     }                                         << 531    rmax *= lunit;
1214     else if(attName == "aunit")               << 532    inst *= aunit;
1215     {                                         << 533    outst *= aunit;
1216       aunit = G4UnitDefinition::GetValueOf(at << 534    z *= 0.5*lunit;
1217       if(G4UnitDefinition::GetCategory(attVal << 
1218       {                                       << 
1219         G4Exception("G4GDMLReadSolids::Polyco << 
1220                     FatalException, "Invalid  << 
1221       }                                       << 
1222     }                                         << 
1223     else if(attName == "startphi")            << 
1224     {                                         << 
1225       startphi = eval.Evaluate(attValue);     << 
1226     }                                         << 
1227     else if(attName == "deltaphi")            << 
1228     {                                         << 
1229       deltaphi = eval.Evaluate(attValue);     << 
1230     }                                         << 
1231   }                                           << 
1232                                               << 
1233   startphi *= aunit;                          << 
1234   deltaphi *= aunit;                          << 
1235                                               << 
1236   std::vector<zplaneType> zplaneList;         << 
1237                                               << 
1238   for(xercesc::DOMNode* iter = polyconeElemen << 
1239       iter                   = iter->getNextS << 
1240   {                                           << 
1241     if(iter->getNodeType() != xercesc::DOMNod << 
1242     {                                         << 
1243       continue;                               << 
1244     }                                         << 
1245                                               << 
1246     const xercesc::DOMElement* const child =  << 
1247       dynamic_cast<xercesc::DOMElement*>(iter << 
1248     if(child == nullptr)                      << 
1249     {                                         << 
1250       G4Exception("G4GDMLReadSolids::Polycone << 
1251                   FatalException, "No child f << 
1252       return;                                 << 
1253     }                                         << 
1254     const G4String tag = Transcode(child->get << 
1255                                               << 
1256     if(tag == "zplane")                       << 
1257     {                                         << 
1258       zplaneList.push_back(ZplaneRead(child)) << 
1259     }                                         << 
1260   }                                           << 
1261                                               << 
1262   std::size_t numZPlanes = zplaneList.size(); << 
1263                                               << 
1264   G4double* rmin_array = new G4double[numZPla << 
1265   G4double* rmax_array = new G4double[numZPla << 
1266   G4double* z_array    = new G4double[numZPla << 
1267                                               << 
1268   for(std::size_t i = 0; i < numZPlanes; ++i) << 
1269   {                                           << 
1270     rmin_array[i] = zplaneList[i].rmin * luni << 
1271     rmax_array[i] = zplaneList[i].rmax * luni << 
1272     z_array[i]    = zplaneList[i].z * lunit;  << 
1273   }                                           << 
1274                                               << 
1275   new G4Polycone(name, startphi, deltaphi, (G << 
1276                  rmin_array, rmax_array);     << 
1277                                               << 
1278   delete[] rmin_array;                        << 
1279   delete[] rmax_array;                        << 
1280   delete[] z_array;                           << 
1281 }                                             << 
1282                                                  535 
1283 // ------------------------------------------ << 536    new G4Hype(name,rmin,rmax,inst,outst,z);
1284 void G4GDMLReadSolids::GenericPolyconeRead(   << 
1285   const xercesc::DOMElement* const polyconeEl << 
1286 {                                             << 
1287   G4String name;                              << 
1288   G4double lunit    = 1.0;                    << 
1289   G4double aunit    = 1.0;                    << 
1290   G4double startphi = 0.0;                    << 
1291   G4double deltaphi = 0.0;                    << 
1292                                               << 
1293   const xercesc::DOMNamedNodeMap* const attri << 
1294     polyconeElement->getAttributes();         << 
1295   XMLSize_t attributeCount = attributes->getL << 
1296                                               << 
1297   for(XMLSize_t attribute_index = 0; attribut << 
1298       ++attribute_index)                      << 
1299   {                                           << 
1300     xercesc::DOMNode* attribute_node = attrib << 
1301                                               << 
1302     if(attribute_node->getNodeType() != xerce << 
1303     {                                         << 
1304       continue;                               << 
1305     }                                         << 
1306                                               << 
1307     const xercesc::DOMAttr* const attribute = << 
1308       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1309     if(attribute == nullptr)                  << 
1310     {                                         << 
1311       G4Exception("G4GDMLReadSolids::GenericP << 
1312                   FatalException, "No attribu << 
1313       return;                                 << 
1314     }                                         << 
1315     const G4String attName  = Transcode(attri << 
1316     const G4String attValue = Transcode(attri << 
1317                                               << 
1318     if(attName == "name")                     << 
1319     {                                         << 
1320       name = GenerateName(attValue);          << 
1321     }                                         << 
1322     else if(attName == "lunit")               << 
1323     {                                         << 
1324       lunit = G4UnitDefinition::GetValueOf(at << 
1325       if(G4UnitDefinition::GetCategory(attVal << 
1326       {                                       << 
1327         G4Exception("G4GDMLReadSolids::Generi << 
1328                     FatalException, "Invalid  << 
1329       }                                       << 
1330     }                                         << 
1331     else if(attName == "aunit")               << 
1332     {                                         << 
1333       aunit = G4UnitDefinition::GetValueOf(at << 
1334       if(G4UnitDefinition::GetCategory(attVal << 
1335       {                                       << 
1336         G4Exception("G4GDMLReadSolids::Generi << 
1337                     FatalException, "Invalid  << 
1338       }                                       << 
1339     }                                         << 
1340     else if(attName == "startphi")            << 
1341     {                                         << 
1342       startphi = eval.Evaluate(attValue);     << 
1343     }                                         << 
1344     else if(attName == "deltaphi")            << 
1345     {                                         << 
1346       deltaphi = eval.Evaluate(attValue);     << 
1347     }                                         << 
1348   }                                           << 
1349                                               << 
1350   startphi *= aunit;                          << 
1351   deltaphi *= aunit;                          << 
1352                                               << 
1353   std::vector<rzPointType> rzPointList;       << 
1354                                               << 
1355   for(xercesc::DOMNode* iter = polyconeElemen << 
1356                         iter != nullptr; iter << 
1357   {                                           << 
1358     if(iter->getNodeType() != xercesc::DOMNod << 
1359     {                                         << 
1360       continue;                               << 
1361     }                                         << 
1362                                               << 
1363     const xercesc::DOMElement* const child =  << 
1364       dynamic_cast<xercesc::DOMElement*>(iter << 
1365     if(child == nullptr)                      << 
1366     {                                         << 
1367       G4Exception("G4GDMLReadSolids::GenericP << 
1368                   FatalException, "No child f << 
1369       return;                                 << 
1370     }                                         << 
1371     const G4String tag = Transcode(child->get << 
1372                                               << 
1373     if(tag == "rzpoint")                      << 
1374     {                                         << 
1375       rzPointList.push_back(RZPointRead(child << 
1376     }                                         << 
1377   }                                           << 
1378                                               << 
1379   std::size_t numRZPoints = rzPointList.size( << 
1380                                               << 
1381   G4double* r_array = new G4double[numRZPoint << 
1382   G4double* z_array = new G4double[numRZPoint << 
1383                                               << 
1384   for(std::size_t i = 0; i < numRZPoints; ++i << 
1385   {                                           << 
1386     r_array[i] = rzPointList[i].r * lunit;    << 
1387     z_array[i] = rzPointList[i].z * lunit;    << 
1388   }                                           << 
1389   new G4GenericPolycone(name, startphi, delta << 
1390                         r_array, z_array);    << 
1391   delete[] r_array;                           << 
1392   delete[] z_array;                           << 
1393 }                                                537 }
1394                                                  538 
1395 // ------------------------------------------ << 539 void G4GDMLReadSolids::OrbRead(const xercesc::DOMElement* const orbElement)
1396 void G4GDMLReadSolids::PolyhedraRead(         << 
1397   const xercesc::DOMElement* const polyhedraE << 
1398 {                                                540 {
1399   G4String name;                              << 541    G4String name;
1400   G4double lunit    = 1.0;                    << 542    G4double lunit = 1.0;
1401   G4double aunit    = 1.0;                    << 543    G4double r = 0.0;
1402   G4double startphi = 0.0;                    << 
1403   G4double deltaphi = 0.0;                    << 
1404   G4int numsides    = 0;                      << 
1405                                               << 
1406   const xercesc::DOMNamedNodeMap* const attri << 
1407     polyhedraElement->getAttributes();        << 
1408   XMLSize_t attributeCount = attributes->getL << 
1409                                               << 
1410   for(XMLSize_t attribute_index = 0; attribut << 
1411       ++attribute_index)                      << 
1412   {                                           << 
1413     xercesc::DOMNode* attribute_node = attrib << 
1414                                               << 
1415     if(attribute_node->getNodeType() != xerce << 
1416     {                                         << 
1417       continue;                               << 
1418     }                                         << 
1419                                               << 
1420     const xercesc::DOMAttr* const attribute = << 
1421       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1422     if(attribute == nullptr)                  << 
1423     {                                         << 
1424       G4Exception("G4GDMLReadSolids::Polyhedr << 
1425                   FatalException, "No attribu << 
1426       return;                                 << 
1427     }                                         << 
1428     const G4String attName  = Transcode(attri << 
1429     const G4String attValue = Transcode(attri << 
1430                                               << 
1431     if(attName == "name")                     << 
1432     {                                         << 
1433       name = GenerateName(attValue);          << 
1434     }                                         << 
1435     else if(attName == "lunit")               << 
1436     {                                         << 
1437       lunit = G4UnitDefinition::GetValueOf(at << 
1438       if(G4UnitDefinition::GetCategory(attVal << 
1439       {                                       << 
1440         G4Exception("G4GDMLReadSolids::Polyhe << 
1441                     FatalException, "Invalid  << 
1442       }                                       << 
1443     }                                         << 
1444     else if(attName == "aunit")               << 
1445     {                                         << 
1446       aunit = G4UnitDefinition::GetValueOf(at << 
1447       if(G4UnitDefinition::GetCategory(attVal << 
1448       {                                       << 
1449         G4Exception("G4GDMLReadSolids::Polyhe << 
1450                     FatalException, "Invalid  << 
1451       }                                       << 
1452     }                                         << 
1453     else if(attName == "startphi")            << 
1454     {                                         << 
1455       startphi = eval.Evaluate(attValue);     << 
1456     }                                         << 
1457     else if(attName == "deltaphi")            << 
1458     {                                         << 
1459       deltaphi = eval.Evaluate(attValue);     << 
1460     }                                         << 
1461     else if(attName == "numsides")            << 
1462     {                                         << 
1463       numsides = eval.EvaluateInteger(attValu << 
1464     }                                         << 
1465   }                                           << 
1466                                               << 
1467   startphi *= aunit;                          << 
1468   deltaphi *= aunit;                          << 
1469                                               << 
1470   std::vector<zplaneType> zplaneList;         << 
1471                                               << 
1472   for(xercesc::DOMNode* iter = polyhedraEleme << 
1473                         iter != nullptr; iter << 
1474   {                                           << 
1475     if(iter->getNodeType() != xercesc::DOMNod << 
1476     {                                         << 
1477       continue;                               << 
1478     }                                         << 
1479                                               << 
1480     const xercesc::DOMElement* const child =  << 
1481       dynamic_cast<xercesc::DOMElement*>(iter << 
1482     if(child == nullptr)                      << 
1483     {                                         << 
1484       G4Exception("G4GDMLReadSolids::Polyhedr << 
1485                   FatalException, "No child f << 
1486       return;                                 << 
1487     }                                         << 
1488     const G4String tag = Transcode(child->get << 
1489                                               << 
1490     if(tag == "zplane")                       << 
1491     {                                         << 
1492       zplaneList.push_back(ZplaneRead(child)) << 
1493     }                                         << 
1494   }                                           << 
1495                                               << 
1496   std::size_t numZPlanes = zplaneList.size(); << 
1497                                               << 
1498   G4double* rmin_array = new G4double[numZPla << 
1499   G4double* rmax_array = new G4double[numZPla << 
1500   G4double* z_array    = new G4double[numZPla << 
1501                                               << 
1502   for(std::size_t i = 0; i < numZPlanes; ++i) << 
1503   {                                           << 
1504     rmin_array[i] = zplaneList[i].rmin * luni << 
1505     rmax_array[i] = zplaneList[i].rmax * luni << 
1506     z_array[i]    = zplaneList[i].z * lunit;  << 
1507   }                                           << 
1508                                               << 
1509   new G4Polyhedra(name, startphi, deltaphi, n << 
1510                   z_array, rmin_array, rmax_a << 
1511                                               << 
1512   delete[] rmin_array;                        << 
1513   delete[] rmax_array;                        << 
1514   delete[] z_array;                           << 
1515 }                                             << 
1516                                                  544 
1517 // ------------------------------------------ << 545    const xercesc::DOMNamedNodeMap* const attributes
1518 void G4GDMLReadSolids::GenericPolyhedraRead(  << 546          = orbElement->getAttributes();
1519   const xercesc::DOMElement* const polyhedraE << 547    XMLSize_t attributeCount = attributes->getLength();
1520 {                                             << 
1521   G4String name;                              << 
1522   G4double lunit    = 1.0;                    << 
1523   G4double aunit    = 1.0;                    << 
1524   G4double startphi = 0.0;                    << 
1525   G4double deltaphi = 0.0;                    << 
1526   G4int numsides    = 0;                      << 
1527                                               << 
1528   const xercesc::DOMNamedNodeMap* const attri << 
1529     polyhedraElement->getAttributes();        << 
1530   XMLSize_t attributeCount = attributes->getL << 
1531                                               << 
1532   for(XMLSize_t attribute_index = 0; attribut << 
1533       ++attribute_index)                      << 
1534   {                                           << 
1535     xercesc::DOMNode* attribute_node = attrib << 
1536                                               << 
1537     if(attribute_node->getNodeType() != xerce << 
1538     {                                         << 
1539       continue;                               << 
1540     }                                         << 
1541                                               << 
1542     const xercesc::DOMAttr* const attribute = << 
1543       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1544     if(attribute == nullptr)                  << 
1545     {                                         << 
1546       G4Exception("G4GDMLReadSolids::GenericP << 
1547                   FatalException, "No attribu << 
1548       return;                                 << 
1549     }                                         << 
1550     const G4String attName  = Transcode(attri << 
1551     const G4String attValue = Transcode(attri << 
1552                                               << 
1553     if(attName == "name")                     << 
1554     {                                         << 
1555       name = GenerateName(attValue);          << 
1556     }                                         << 
1557     else if(attName == "lunit")               << 
1558     {                                         << 
1559       lunit = G4UnitDefinition::GetValueOf(at << 
1560       if(G4UnitDefinition::GetCategory(attVal << 
1561       {                                       << 
1562         G4Exception("G4GDMLReadSolids::Generi << 
1563                     FatalException, "Invalid  << 
1564       }                                       << 
1565     }                                         << 
1566     else if(attName == "aunit")               << 
1567     {                                         << 
1568       aunit = G4UnitDefinition::GetValueOf(at << 
1569       if(G4UnitDefinition::GetCategory(attVal << 
1570       {                                       << 
1571         G4Exception("G4GDMLReadSolids::Generi << 
1572                     FatalException, "Invalid  << 
1573       }                                       << 
1574     }                                         << 
1575     else if(attName == "startphi")            << 
1576     {                                         << 
1577       startphi = eval.Evaluate(attValue);     << 
1578     }                                         << 
1579     else if(attName == "deltaphi")            << 
1580     {                                         << 
1581       deltaphi = eval.Evaluate(attValue);     << 
1582     }                                         << 
1583     else if(attName == "numsides")            << 
1584     {                                         << 
1585       numsides = eval.EvaluateInteger(attValu << 
1586     }                                         << 
1587   }                                           << 
1588                                               << 
1589   startphi *= aunit;                          << 
1590   deltaphi *= aunit;                          << 
1591                                               << 
1592   std::vector<rzPointType> rzpointList;       << 
1593                                               << 
1594   for(xercesc::DOMNode* iter = polyhedraEleme << 
1595                         iter != nullptr; iter << 
1596   {                                           << 
1597     if(iter->getNodeType() != xercesc::DOMNod << 
1598     {                                         << 
1599       continue;                               << 
1600     }                                         << 
1601                                               << 
1602     const xercesc::DOMElement* const child =  << 
1603       dynamic_cast<xercesc::DOMElement*>(iter << 
1604     if(child == nullptr)                      << 
1605     {                                         << 
1606       G4Exception("G4GDMLReadSolids::GenericP << 
1607                   FatalException, "No child f << 
1608       return;                                 << 
1609     }                                         << 
1610     const G4String tag = Transcode(child->get << 
1611                                               << 
1612     if(tag == "rzpoint")                      << 
1613     {                                         << 
1614       rzpointList.push_back(RZPointRead(child << 
1615     }                                         << 
1616   }                                           << 
1617                                               << 
1618   std::size_t numRZPoints = rzpointList.size( << 
1619                                               << 
1620   G4double* r_array = new G4double[numRZPoint << 
1621   G4double* z_array = new G4double[numRZPoint << 
1622                                               << 
1623   for(std::size_t i = 0; i < numRZPoints; ++i << 
1624   {                                           << 
1625     r_array[i] = rzpointList[i].r * lunit;    << 
1626     z_array[i] = rzpointList[i].z * lunit;    << 
1627   }                                           << 
1628                                                  548 
1629   new G4Polyhedra(name, startphi, deltaphi, n << 549    for (XMLSize_t attribute_index=0;
1630                   r_array, z_array);          << 550         attribute_index<attributeCount; attribute_index++)
                                                   >> 551    {
                                                   >> 552       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1631                                                  553 
1632   delete[] r_array;                           << 554       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1633   delete[] z_array;                           << 555         { continue; }
1634 }                                             << 
1635                                                  556 
1636 // ------------------------------------------ << 557       const xercesc::DOMAttr* const attribute
1637 G4QuadrangularFacet* G4GDMLReadSolids::Quadra << 558             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
1638   const xercesc::DOMElement* const quadrangul << 559       if (!attribute)
1639 {                                             << 
1640   G4ThreeVector vertex1;                      << 
1641   G4ThreeVector vertex2;                      << 
1642   G4ThreeVector vertex3;                      << 
1643   G4ThreeVector vertex4;                      << 
1644   G4FacetVertexType type = ABSOLUTE;          << 
1645   G4double lunit         = 1.0;               << 
1646                                               << 
1647   const xercesc::DOMNamedNodeMap* const attri << 
1648     quadrangularElement->getAttributes();     << 
1649   XMLSize_t attributeCount = attributes->getL << 
1650                                               << 
1651   for(XMLSize_t attribute_index = 0; attribut << 
1652       ++attribute_index)                      << 
1653   {                                           << 
1654     xercesc::DOMNode* attribute_node = attrib << 
1655                                               << 
1656     if(attribute_node->getNodeType() != xerce << 
1657     {                                         << 
1658       continue;                               << 
1659     }                                         << 
1660                                               << 
1661     const xercesc::DOMAttr* const attribute = << 
1662       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1663     if(attribute == nullptr)                  << 
1664     {                                         << 
1665       G4Exception("G4GDMLReadSolids::Quadrang << 
1666                   FatalException, "No attribu << 
1667       return nullptr;                         << 
1668     }                                         << 
1669     const G4String attName  = Transcode(attri << 
1670     const G4String attValue = Transcode(attri << 
1671                                               << 
1672     if(attName == "vertex1")                  << 
1673     {                                         << 
1674       vertex1 = GetPosition(GenerateName(attV << 
1675     }                                         << 
1676     else if(attName == "vertex2")             << 
1677     {                                         << 
1678       vertex2 = GetPosition(GenerateName(attV << 
1679     }                                         << 
1680     else if(attName == "vertex3")             << 
1681     {                                         << 
1682       vertex3 = GetPosition(GenerateName(attV << 
1683     }                                         << 
1684     else if(attName == "vertex4")             << 
1685     {                                         << 
1686       vertex4 = GetPosition(GenerateName(attV << 
1687     }                                         << 
1688     else if(attName == "lunit")               << 
1689     {                                         << 
1690       lunit = G4UnitDefinition::GetValueOf(at << 
1691       if(G4UnitDefinition::GetCategory(attVal << 
1692       {                                       << 
1693         G4Exception("G4GDMLReadSolids::Quadra << 
1694                     FatalException, "Invalid  << 
1695       }                                       << 
1696     }                                         << 
1697     else if(attName == "type")                << 
1698     {                                         << 
1699       if(attValue == "RELATIVE")              << 
1700       {                                          560       {
1701         type = RELATIVE;                      << 561         G4Exception("G4GDMLReadSolids::OrbRead()",
                                                   >> 562                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 563         return;
1702       }                                          564       }
1703     }                                         << 565       const G4String attName = Transcode(attribute->getName());
1704   }                                           << 566       const G4String attValue = Transcode(attribute->getValue());
1705                                               << 
1706   return new G4QuadrangularFacet(vertex1 * lu << 
1707                                  vertex3 * lu << 
1708 }                                             << 
1709                                               << 
1710 // ------------------------------------------ << 
1711 void G4GDMLReadSolids::ReflectedSolidRead(    << 
1712   const xercesc::DOMElement* const reflectedS << 
1713 {                                             << 
1714   G4String name;                              << 
1715   G4double lunit = 1.0;                       << 
1716   G4double aunit = 1.0;                       << 
1717   G4String solid;                             << 
1718   G4ThreeVector scale(1.0, 1.0, 1.0);         << 
1719   G4ThreeVector rotation;                     << 
1720   G4ThreeVector position;                     << 
1721                                               << 
1722   const xercesc::DOMNamedNodeMap* const attri << 
1723     reflectedSolidElement->getAttributes();   << 
1724   XMLSize_t attributeCount = attributes->getL << 
1725                                               << 
1726   for(XMLSize_t attribute_index = 0; attribut << 
1727       ++attribute_index)                      << 
1728   {                                           << 
1729     xercesc::DOMNode* attribute_node = attrib << 
1730                                               << 
1731     if(attribute_node->getNodeType() != xerce << 
1732     {                                         << 
1733       continue;                               << 
1734     }                                         << 
1735                                               << 
1736     const xercesc::DOMAttr* const attribute = << 
1737       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1738     if(attribute == nullptr)                  << 
1739     {                                         << 
1740       G4Exception("G4GDMLReadSolids::Reflecte << 
1741                   FatalException, "No attribu << 
1742       return;                                 << 
1743     }                                         << 
1744     const G4String attName  = Transcode(attri << 
1745     const G4String attValue = Transcode(attri << 
1746                                               << 
1747     if(attName == "name")                     << 
1748     {                                         << 
1749       name = GenerateName(attValue);          << 
1750     }                                         << 
1751     else if(attName == "lunit")               << 
1752     {                                         << 
1753       lunit = G4UnitDefinition::GetValueOf(at << 
1754       if(G4UnitDefinition::GetCategory(attVal << 
1755       {                                       << 
1756         G4Exception("G4GDMLReadSolids::Reflec << 
1757                     FatalException, "Invalid  << 
1758       }                                       << 
1759     }                                         << 
1760     else if(attName == "aunit")               << 
1761     {                                         << 
1762       aunit = G4UnitDefinition::GetValueOf(at << 
1763       if(G4UnitDefinition::GetCategory(attVal << 
1764       {                                       << 
1765         G4Exception("G4GDMLReadSolids::Reflec << 
1766                     FatalException, "Invalid  << 
1767       }                                       << 
1768     }                                         << 
1769     else if(attName == "solid")               << 
1770     {                                         << 
1771       solid = GenerateName(attValue);         << 
1772     }                                         << 
1773     else if(attName == "sx")                  << 
1774     {                                         << 
1775       scale.setX(eval.Evaluate(attValue));    << 
1776     }                                         << 
1777     else if(attName == "sy")                  << 
1778     {                                         << 
1779       scale.setY(eval.Evaluate(attValue));    << 
1780     }                                         << 
1781     else if(attName == "sz")                  << 
1782     {                                         << 
1783       scale.setZ(eval.Evaluate(attValue));    << 
1784     }                                         << 
1785     else if(attName == "rx")                  << 
1786     {                                         << 
1787       rotation.setX(eval.Evaluate(attValue)); << 
1788     }                                         << 
1789     else if(attName == "ry")                  << 
1790     {                                         << 
1791       rotation.setY(eval.Evaluate(attValue)); << 
1792     }                                         << 
1793     else if(attName == "rz")                  << 
1794     {                                         << 
1795       rotation.setZ(eval.Evaluate(attValue)); << 
1796     }                                         << 
1797     else if(attName == "dx")                  << 
1798     {                                         << 
1799       position.setX(eval.Evaluate(attValue)); << 
1800     }                                         << 
1801     else if(attName == "dy")                  << 
1802     {                                         << 
1803       position.setY(eval.Evaluate(attValue)); << 
1804     }                                         << 
1805     else if(attName == "dz")                  << 
1806     {                                         << 
1807       position.setZ(eval.Evaluate(attValue)); << 
1808     }                                         << 
1809   }                                           << 
1810                                               << 
1811   rotation *= aunit;                          << 
1812   position *= lunit;                          << 
1813                                               << 
1814   G4Transform3D transform(GetRotationMatrix(r << 
1815   transform = transform * G4Scale3D(scale.x() << 
1816                                               << 
1817   new G4ReflectedSolid(name, GetSolid(solid), << 
1818 }                                             << 
1819                                               << 
1820 // ------------------------------------------ << 
1821 void G4GDMLReadSolids::ScaledSolidRead(       << 
1822   const xercesc::DOMElement* const scaledSoli << 
1823 {                                             << 
1824   G4String name;                              << 
1825   G4VSolid* solid = nullptr;                  << 
1826   G4ThreeVector scale(1.0, 1.0, 1.0);         << 
1827                                               << 
1828   const xercesc::DOMNamedNodeMap* const attri << 
1829     scaledSolidElement->getAttributes();      << 
1830   XMLSize_t attributeCount = attributes->getL << 
1831                                               << 
1832   for(XMLSize_t attribute_index = 0; attribut << 
1833       ++attribute_index)                      << 
1834   {                                           << 
1835     xercesc::DOMNode* attribute_node = attrib << 
1836                                               << 
1837     if(attribute_node->getNodeType() != xerce << 
1838     {                                         << 
1839       continue;                               << 
1840     }                                         << 
1841                                               << 
1842     const xercesc::DOMAttr* const attribute = << 
1843       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1844     if(attribute == nullptr)                  << 
1845     {                                         << 
1846       G4Exception("G4GDMLReadSolids::ScaledSo << 
1847                   FatalException, "No attribu << 
1848       return;                                 << 
1849     }                                         << 
1850     const G4String attName  = Transcode(attri << 
1851     const G4String attValue = Transcode(attri << 
1852                                               << 
1853     if(attName == "name")                     << 
1854     {                                         << 
1855       name = GenerateName(attValue);          << 
1856     }                                         << 
1857   }                                           << 
1858                                               << 
1859   for(xercesc::DOMNode* iter = scaledSolidEle << 
1860                         iter != nullptr; iter << 
1861   {                                           << 
1862     if(iter->getNodeType() != xercesc::DOMNod << 
1863     {                                         << 
1864       continue;                               << 
1865     }                                         << 
1866                                               << 
1867     const xercesc::DOMElement* const child =  << 
1868       dynamic_cast<xercesc::DOMElement*>(iter << 
1869     if(child == nullptr)                      << 
1870     {                                         << 
1871       G4Exception("G4GDMLReadSolids::ScaledSo << 
1872                   FatalException, "No child f << 
1873       return;                                 << 
1874     }                                         << 
1875     const G4String tag = Transcode(child->get << 
1876                                               << 
1877     if(tag == "solidref")                     << 
1878     {                                         << 
1879       solid = GetSolid(GenerateName(RefRead(c << 
1880     }                                         << 
1881     else if(tag == "scale")                   << 
1882     {                                         << 
1883       VectorRead(child, scale);               << 
1884     }                                         << 
1885     else if(tag == "scaleref")                << 
1886     {                                         << 
1887       scale = GetScale(GenerateName(RefRead(c << 
1888     }                                         << 
1889     else                                      << 
1890     {                                         << 
1891       G4String error_msg = "Unknown tag in sc << 
1892       G4Exception("G4GDMLReadSolids::ScaledSo << 
1893                   FatalException, error_msg); << 
1894       return;                                 << 
1895     }                                         << 
1896   }                                           << 
1897                                               << 
1898   G4Scale3D transform = G4Scale3D(scale.x(),  << 
1899                                               << 
1900   new G4ScaledSolid(name, solid, transform);  << 
1901 }                                             << 
1902                                               << 
1903 // ------------------------------------------ << 
1904 G4ExtrudedSolid::ZSection G4GDMLReadSolids::S << 
1905   const xercesc::DOMElement* const sectionEle << 
1906 {                                             << 
1907   G4double zPosition = 0.0;                   << 
1908   G4TwoVector Offset;                         << 
1909   G4double scalingFactor = 1.0;               << 
1910                                               << 
1911   const xercesc::DOMNamedNodeMap* const attri << 
1912     sectionElement->getAttributes();          << 
1913   XMLSize_t attributeCount = attributes->getL << 
1914                                               << 
1915   for(XMLSize_t attribute_index = 0; attribut << 
1916       ++attribute_index)                      << 
1917   {                                           << 
1918     xercesc::DOMNode* attribute_node = attrib << 
1919                                               << 
1920     if(attribute_node->getNodeType() != xerce << 
1921     {                                         << 
1922       continue;                               << 
1923     }                                         << 
1924                                               << 
1925     const xercesc::DOMAttr* const attribute = << 
1926       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1927     if(attribute == nullptr)                  << 
1928     {                                         << 
1929       G4Exception("G4GDMLReadSolids::SectionR << 
1930                   FatalException, "No attribu << 
1931       return G4ExtrudedSolid::ZSection(zPosit << 
1932     }                                         << 
1933     const G4String attName  = Transcode(attri << 
1934     const G4String attValue = Transcode(attri << 
1935                                               << 
1936     if(attName == "zPosition")                << 
1937     {                                         << 
1938       zPosition = eval.Evaluate(attValue) * l << 
1939     }                                         << 
1940     else if(attName == "xOffset")             << 
1941     {                                         << 
1942       Offset.setX(eval.Evaluate(attValue) * l << 
1943     }                                         << 
1944     else if(attName == "yOffset")             << 
1945     {                                         << 
1946       Offset.setY(eval.Evaluate(attValue) * l << 
1947     }                                         << 
1948     else if(attName == "scalingFactor")       << 
1949     {                                         << 
1950       scalingFactor = eval.Evaluate(attValue) << 
1951     }                                         << 
1952   }                                           << 
1953                                                  567 
1954   return G4ExtrudedSolid::ZSection(zPosition, << 568       if (attName=="name") { name = GenerateName(attValue); } else
1955 }                                             << 569       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 570       if (attName=="r") { r = eval.Evaluate(attValue); }
                                                   >> 571    }
1956                                                  572 
1957 // ------------------------------------------ << 573    r *= lunit;
1958 void G4GDMLReadSolids::SphereRead(            << 
1959   const xercesc::DOMElement* const sphereElem << 
1960 {                                             << 
1961   G4String name;                              << 
1962   G4double lunit      = 1.0;                  << 
1963   G4double aunit      = 1.0;                  << 
1964   G4double rmin       = 0.0;                  << 
1965   G4double rmax       = 0.0;                  << 
1966   G4double startphi   = 0.0;                  << 
1967   G4double deltaphi   = 0.0;                  << 
1968   G4double starttheta = 0.0;                  << 
1969   G4double deltatheta = 0.0;                  << 
1970                                               << 
1971   const xercesc::DOMNamedNodeMap* const attri << 
1972     sphereElement->getAttributes();           << 
1973   XMLSize_t attributeCount = attributes->getL << 
1974                                               << 
1975   for(XMLSize_t attribute_index = 0; attribut << 
1976       ++attribute_index)                      << 
1977   {                                           << 
1978     xercesc::DOMNode* attribute_node = attrib << 
1979                                               << 
1980     if(attribute_node->getNodeType() != xerce << 
1981     {                                         << 
1982       continue;                               << 
1983     }                                         << 
1984                                               << 
1985     const xercesc::DOMAttr* const attribute = << 
1986       dynamic_cast<xercesc::DOMAttr*>(attribu << 
1987     if(attribute == nullptr)                  << 
1988     {                                         << 
1989       G4Exception("G4GDMLReadSolids::SphereRe << 
1990                   FatalException, "No attribu << 
1991       return;                                 << 
1992     }                                         << 
1993     const G4String attName  = Transcode(attri << 
1994     const G4String attValue = Transcode(attri << 
1995                                               << 
1996     if(attName == "name")                     << 
1997     {                                         << 
1998       name = GenerateName(attValue);          << 
1999     }                                         << 
2000     else if(attName == "lunit")               << 
2001     {                                         << 
2002       lunit = G4UnitDefinition::GetValueOf(at << 
2003       if(G4UnitDefinition::GetCategory(attVal << 
2004       {                                       << 
2005         G4Exception("G4GDMLReadSolids::Sphere << 
2006                     FatalException, "Invalid  << 
2007       }                                       << 
2008     }                                         << 
2009     else if(attName == "aunit")               << 
2010     {                                         << 
2011       aunit = G4UnitDefinition::GetValueOf(at << 
2012       if(G4UnitDefinition::GetCategory(attVal << 
2013       {                                       << 
2014         G4Exception("G4GDMLReadSolids::Sphere << 
2015                     FatalException, "Invalid  << 
2016       }                                       << 
2017     }                                         << 
2018     else if(attName == "rmin")                << 
2019     {                                         << 
2020       rmin = eval.Evaluate(attValue);         << 
2021     }                                         << 
2022     else if(attName == "rmax")                << 
2023     {                                         << 
2024       rmax = eval.Evaluate(attValue);         << 
2025     }                                         << 
2026     else if(attName == "startphi")            << 
2027     {                                         << 
2028       startphi = eval.Evaluate(attValue);     << 
2029     }                                         << 
2030     else if(attName == "deltaphi")            << 
2031     {                                         << 
2032       deltaphi = eval.Evaluate(attValue);     << 
2033     }                                         << 
2034     else if(attName == "starttheta")          << 
2035     {                                         << 
2036       starttheta = eval.Evaluate(attValue);   << 
2037     }                                         << 
2038     else if(attName == "deltatheta")          << 
2039     {                                         << 
2040       deltatheta = eval.Evaluate(attValue);   << 
2041     }                                         << 
2042   }                                           << 
2043                                               << 
2044   rmin *= lunit;                              << 
2045   rmax *= lunit;                              << 
2046   startphi *= aunit;                          << 
2047   deltaphi *= aunit;                          << 
2048   starttheta *= aunit;                        << 
2049   deltatheta *= aunit;                        << 
2050                                                  574 
2051   new G4Sphere(name, rmin, rmax, startphi, de << 575    new G4Orb(name,r);
2052 }                                                576 }
2053                                                  577 
2054 // ------------------------------------------ << 578 void G4GDMLReadSolids::ParaRead(const xercesc::DOMElement* const paraElement)
2055 void G4GDMLReadSolids::TessellatedRead(       << 
2056   const xercesc::DOMElement* const tessellate << 
2057 {                                                579 {
2058   G4String name;                              << 580    G4String name;
                                                   >> 581    G4double lunit = 1.0;
                                                   >> 582    G4double aunit = 1.0;
                                                   >> 583    G4double x = 0.0;
                                                   >> 584    G4double y = 0.0;
                                                   >> 585    G4double z = 0.0;
                                                   >> 586    G4double alpha = 0.0;
                                                   >> 587    G4double theta = 0.0;
                                                   >> 588    G4double phi = 0.0;
                                                   >> 589 
                                                   >> 590    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 591          = paraElement->getAttributes();
                                                   >> 592    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 593 
                                                   >> 594    for (XMLSize_t attribute_index=0;
                                                   >> 595         attribute_index<attributeCount; attribute_index++)
                                                   >> 596    {
                                                   >> 597       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 598 
                                                   >> 599       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 600         { continue; }
                                                   >> 601 
                                                   >> 602       const xercesc::DOMAttr* const attribute
                                                   >> 603             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 604       if (!attribute)
                                                   >> 605       {
                                                   >> 606         G4Exception("G4GDMLReadSolids::ParaRead()",
                                                   >> 607                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 608         return;
                                                   >> 609       }
                                                   >> 610       const G4String attName = Transcode(attribute->getName());
                                                   >> 611       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 612 
                                                   >> 613       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 614       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 615       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
                                                   >> 616       if (attName=="x") { x = eval.Evaluate(attValue); } else
                                                   >> 617       if (attName=="y") { y = eval.Evaluate(attValue); } else
                                                   >> 618       if (attName=="z") { z = eval.Evaluate(attValue); } else
                                                   >> 619       if (attName=="alpha") { alpha = eval.Evaluate(attValue); } else
                                                   >> 620       if (attName=="theta") { theta = eval.Evaluate(attValue); } else
                                                   >> 621       if (attName=="phi") { phi = eval.Evaluate(attValue); }
                                                   >> 622    }
                                                   >> 623 
                                                   >> 624    x *= 0.5*lunit;
                                                   >> 625    y *= 0.5*lunit;
                                                   >> 626    z *= 0.5*lunit;
                                                   >> 627    alpha *= aunit;
                                                   >> 628    theta *= aunit;
                                                   >> 629    phi *= aunit;
                                                   >> 630 
                                                   >> 631    new G4Para(name,x,y,z,alpha,theta,phi);
                                                   >> 632 }
                                                   >> 633 
                                                   >> 634 void G4GDMLReadSolids::
                                                   >> 635 ParaboloidRead(const xercesc::DOMElement* const paraElement)
                                                   >> 636 {
                                                   >> 637    G4String name;
                                                   >> 638    G4double lunit = 1.0;
                                                   >> 639    G4double rlo = 0.0;
                                                   >> 640    G4double rhi = 0.0;
                                                   >> 641    G4double dz = 0.0;
                                                   >> 642   
                                                   >> 643    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 644          = paraElement->getAttributes();
                                                   >> 645    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 646 
                                                   >> 647    for (XMLSize_t attribute_index=0;
                                                   >> 648         attribute_index<attributeCount; attribute_index++)
                                                   >> 649    {
                                                   >> 650       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 651 
                                                   >> 652       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 653         { continue; }
                                                   >> 654 
                                                   >> 655       const xercesc::DOMAttr* const attribute
                                                   >> 656             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 657       if (!attribute)
                                                   >> 658       {
                                                   >> 659         G4Exception("G4GDMLReadSolids::ParaboloidRead()",
                                                   >> 660                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 661         return;
                                                   >> 662       }
                                                   >> 663       const G4String attName = Transcode(attribute->getName());
                                                   >> 664       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 665 
                                                   >> 666       if (attName=="name")  { name = GenerateName(attValue); } else
                                                   >> 667       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 668       if (attName=="rlo")   { rlo =  eval.Evaluate(attValue); } else
                                                   >> 669       if (attName=="rhi")   { rhi = eval.Evaluate(attValue); } else
                                                   >> 670       if (attName=="dz")    { dz = eval.Evaluate(attValue); } 
                                                   >> 671    }     
                                                   >> 672 
                                                   >> 673    rlo *= 1.*lunit;
                                                   >> 674    rhi *= 1.*lunit;
                                                   >> 675    dz *= 1.*lunit;
                                                   >> 676   
                                                   >> 677    new G4Paraboloid(name,dz,rlo,rhi);
                                                   >> 678 }
                                                   >> 679 
                                                   >> 680 void G4GDMLReadSolids::
                                                   >> 681 PolyconeRead(const xercesc::DOMElement* const polyconeElement) 
                                                   >> 682 {
                                                   >> 683    G4String name;
                                                   >> 684    G4double lunit = 1.0;
                                                   >> 685    G4double aunit = 1.0;
                                                   >> 686    G4double startphi = 0.0;
                                                   >> 687    G4double deltaphi = 0.0;
                                                   >> 688 
                                                   >> 689    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 690          = polyconeElement->getAttributes();
                                                   >> 691    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 692 
                                                   >> 693    for (XMLSize_t attribute_index=0;
                                                   >> 694         attribute_index<attributeCount; attribute_index++)
                                                   >> 695    {
                                                   >> 696       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 697 
                                                   >> 698       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 699         { continue; }
                                                   >> 700 
                                                   >> 701       const xercesc::DOMAttr* const attribute
                                                   >> 702             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 703       if (!attribute)
                                                   >> 704       {
                                                   >> 705         G4Exception("G4GDMLReadSolids::PolyconeRead()",
                                                   >> 706                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 707         return;
                                                   >> 708       }
                                                   >> 709       const G4String attName = Transcode(attribute->getName());
                                                   >> 710       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 711 
                                                   >> 712       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 713       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 714       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
                                                   >> 715       if (attName=="startphi") { startphi = eval.Evaluate(attValue); }else
                                                   >> 716       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
                                                   >> 717    }
                                                   >> 718 
                                                   >> 719    startphi *= aunit;
                                                   >> 720    deltaphi *= aunit;
                                                   >> 721 
                                                   >> 722    std::vector<zplaneType> zplaneList;
                                                   >> 723 
                                                   >> 724    for (xercesc::DOMNode* iter = polyconeElement->getFirstChild();
                                                   >> 725         iter != 0; iter = iter->getNextSibling())
                                                   >> 726    {
                                                   >> 727       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 728 
                                                   >> 729       const xercesc::DOMElement* const child
                                                   >> 730             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 731       if (!child)
                                                   >> 732       {
                                                   >> 733         G4Exception("G4GDMLReadSolids::PolyconeRead()",
                                                   >> 734                     "InvalidRead", FatalException, "No child found!");
                                                   >> 735         return;
                                                   >> 736       }
                                                   >> 737       const G4String tag = Transcode(child->getTagName());
                                                   >> 738 
                                                   >> 739       if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
                                                   >> 740    }
                                                   >> 741 
                                                   >> 742    G4int numZPlanes = zplaneList.size();
                                                   >> 743 
                                                   >> 744    G4double* rmin_array = new G4double[numZPlanes];
                                                   >> 745    G4double* rmax_array = new G4double[numZPlanes];
                                                   >> 746    G4double* z_array    = new G4double[numZPlanes];
                                                   >> 747 
                                                   >> 748    for (G4int i=0; i<numZPlanes; i++)
                                                   >> 749    { 
                                                   >> 750       rmin_array[i] = zplaneList[i].rmin*lunit;
                                                   >> 751       rmax_array[i] = zplaneList[i].rmax*lunit;
                                                   >> 752       z_array[i]    = zplaneList[i].z*lunit;
                                                   >> 753    }
                                                   >> 754 
                                                   >> 755    new G4Polycone(name,startphi,deltaphi,numZPlanes,
                                                   >> 756                   z_array,rmin_array,rmax_array);
                                                   >> 757 }
                                                   >> 758 
                                                   >> 759 void G4GDMLReadSolids::
                                                   >> 760 PolyhedraRead(const xercesc::DOMElement* const polyhedraElement)
                                                   >> 761 {
                                                   >> 762    G4String name;
                                                   >> 763    G4double lunit = 1.0;
                                                   >> 764    G4double aunit = 1.0;
                                                   >> 765    G4double startphi = 0.0;
                                                   >> 766    G4double deltaphi = 0.0;
                                                   >> 767    G4int numsides = 0;
                                                   >> 768 
                                                   >> 769    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 770          = polyhedraElement->getAttributes();
                                                   >> 771    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 772 
                                                   >> 773    for (XMLSize_t attribute_index=0;
                                                   >> 774         attribute_index<attributeCount; attribute_index++)
                                                   >> 775    {
                                                   >> 776       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 777 
                                                   >> 778       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 779         { continue; }
                                                   >> 780 
                                                   >> 781       const xercesc::DOMAttr* const attribute
                                                   >> 782             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 783       if (!attribute)
                                                   >> 784       {
                                                   >> 785         G4Exception("G4GDMLReadSolids::PolyhedraRead()",
                                                   >> 786                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 787         return;
                                                   >> 788       }
                                                   >> 789       const G4String attName = Transcode(attribute->getName());
                                                   >> 790       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 791 
                                                   >> 792       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 793       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 794       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
                                                   >> 795       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
                                                   >> 796       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
                                                   >> 797       if (attName=="numsides") { numsides = eval.EvaluateInteger(attValue); }
                                                   >> 798    }
                                                   >> 799 
                                                   >> 800    startphi *= aunit;
                                                   >> 801    deltaphi *= aunit;
                                                   >> 802 
                                                   >> 803    std::vector<zplaneType> zplaneList;
                                                   >> 804 
                                                   >> 805    for (xercesc::DOMNode* iter = polyhedraElement->getFirstChild();
                                                   >> 806         iter != 0; iter = iter->getNextSibling())
                                                   >> 807    {
                                                   >> 808       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
                                                   >> 809 
                                                   >> 810       const xercesc::DOMElement* const child
                                                   >> 811             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 812       if (!child)
                                                   >> 813       {
                                                   >> 814         G4Exception("G4GDMLReadSolids::PolyhedraRead()",
                                                   >> 815                     "InvalidRead", FatalException, "No child found!");
                                                   >> 816         return;
                                                   >> 817       }
                                                   >> 818       const G4String tag = Transcode(child->getTagName());
                                                   >> 819 
                                                   >> 820       if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
                                                   >> 821    }
                                                   >> 822 
                                                   >> 823    G4int numZPlanes = zplaneList.size();
                                                   >> 824 
                                                   >> 825    G4double* rmin_array = new G4double[numZPlanes];
                                                   >> 826    G4double* rmax_array = new G4double[numZPlanes];
                                                   >> 827    G4double* z_array = new G4double[numZPlanes];
                                                   >> 828 
                                                   >> 829    for (G4int i=0; i<numZPlanes; i++)
                                                   >> 830    { 
                                                   >> 831       rmin_array[i] = zplaneList[i].rmin*lunit;
                                                   >> 832       rmax_array[i] = zplaneList[i].rmax*lunit;
                                                   >> 833       z_array[i] = zplaneList[i].z*lunit;
                                                   >> 834    }
                                                   >> 835 
                                                   >> 836    new G4Polyhedra(name,startphi,deltaphi,numsides,numZPlanes,
                                                   >> 837                    z_array,rmin_array,rmax_array);
                                                   >> 838 
                                                   >> 839 }
                                                   >> 840 
                                                   >> 841 G4QuadrangularFacet* G4GDMLReadSolids::
                                                   >> 842 QuadrangularRead(const xercesc::DOMElement* const quadrangularElement)
                                                   >> 843 {
                                                   >> 844    G4ThreeVector vertex1;
                                                   >> 845    G4ThreeVector vertex2;
                                                   >> 846    G4ThreeVector vertex3;
                                                   >> 847    G4ThreeVector vertex4;
                                                   >> 848    G4FacetVertexType type = ABSOLUTE;
                                                   >> 849    G4double lunit = 1.0;
                                                   >> 850 
                                                   >> 851    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 852          = quadrangularElement->getAttributes();
                                                   >> 853    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 854 
                                                   >> 855    for (XMLSize_t attribute_index=0;
                                                   >> 856         attribute_index<attributeCount; attribute_index++)
                                                   >> 857    {
                                                   >> 858       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 859 
                                                   >> 860       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 861         { continue; }
                                                   >> 862 
                                                   >> 863       const xercesc::DOMAttr* const attribute
                                                   >> 864             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 865       if (!attribute)
                                                   >> 866       {
                                                   >> 867         G4Exception("G4GDMLReadSolids::QuadrangularRead()",
                                                   >> 868                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 869         return 0;
                                                   >> 870       }
                                                   >> 871       const G4String attName = Transcode(attribute->getName());
                                                   >> 872       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 873 
                                                   >> 874       if (attName=="vertex1")
                                                   >> 875         { vertex1 = GetPosition(GenerateName(attValue)); } else
                                                   >> 876       if (attName=="vertex2")
                                                   >> 877         { vertex2 = GetPosition(GenerateName(attValue)); } else
                                                   >> 878       if (attName=="vertex3")
                                                   >> 879         { vertex3 = GetPosition(GenerateName(attValue)); } else
                                                   >> 880       if (attName=="vertex4")
                                                   >> 881         { vertex4 = GetPosition(GenerateName(attValue)); } else
                                                   >> 882       if (attName=="lunit")
                                                   >> 883         { lunit = eval.Evaluate(attValue); } else
                                                   >> 884       if (attName=="type")
                                                   >> 885         { if (attValue=="RELATIVE") { type = RELATIVE; } }
                                                   >> 886    }
                                                   >> 887 
                                                   >> 888    return new G4QuadrangularFacet(vertex1*lunit,vertex2*lunit,
                                                   >> 889                                   vertex3*lunit,vertex4*lunit,type);
                                                   >> 890 }
                                                   >> 891 
                                                   >> 892 void G4GDMLReadSolids::
                                                   >> 893 ReflectedSolidRead(const xercesc::DOMElement* const reflectedSolidElement)
                                                   >> 894 {
                                                   >> 895    G4String name;
                                                   >> 896    G4double lunit = 1.0;
                                                   >> 897    G4double aunit = 1.0;
                                                   >> 898    G4String solid;
                                                   >> 899    G4ThreeVector scale(1.0,1.0,1.0);
                                                   >> 900    G4ThreeVector rotation;
                                                   >> 901    G4ThreeVector position;
                                                   >> 902 
                                                   >> 903    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 904          = reflectedSolidElement->getAttributes();
                                                   >> 905    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 906 
                                                   >> 907    for (XMLSize_t attribute_index=0;
                                                   >> 908         attribute_index<attributeCount; attribute_index++)
                                                   >> 909    {
                                                   >> 910       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 911 
                                                   >> 912       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 913         { continue; }
                                                   >> 914 
                                                   >> 915       const xercesc::DOMAttr* const attribute
                                                   >> 916             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 917       if (!attribute)
                                                   >> 918       {
                                                   >> 919         G4Exception("G4GDMLReadSolids::ReflectedSolidRead()",
                                                   >> 920                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 921         return;
                                                   >> 922       }
                                                   >> 923       const G4String attName = Transcode(attribute->getName());
                                                   >> 924       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 925 
                                                   >> 926       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 927       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 928       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
                                                   >> 929       if (attName=="solid") { solid = GenerateName(attValue); } else
                                                   >> 930       if (attName=="sx") { scale.setX(eval.Evaluate(attValue)); } else
                                                   >> 931       if (attName=="sy") { scale.setY(eval.Evaluate(attValue)); } else
                                                   >> 932       if (attName=="sz") { scale.setZ(eval.Evaluate(attValue)); } else
                                                   >> 933       if (attName=="rx") { rotation.setX(eval.Evaluate(attValue)); } else
                                                   >> 934       if (attName=="ry") { rotation.setY(eval.Evaluate(attValue)); } else
                                                   >> 935       if (attName=="rz") { rotation.setZ(eval.Evaluate(attValue)); } else
                                                   >> 936       if (attName=="dx") { position.setX(eval.Evaluate(attValue)); } else
                                                   >> 937       if (attName=="dy") { position.setY(eval.Evaluate(attValue)); } else
                                                   >> 938       if (attName=="dz") { position.setZ(eval.Evaluate(attValue)); }
                                                   >> 939    }
                                                   >> 940 
                                                   >> 941    rotation *= aunit;
                                                   >> 942    position *= lunit;
                                                   >> 943 
                                                   >> 944    G4Transform3D transform(GetRotationMatrix(rotation),position);
                                                   >> 945    transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z());
                                                   >> 946           
                                                   >> 947    new G4ReflectedSolid(name,GetSolid(solid),transform);
                                                   >> 948 }
                                                   >> 949 
                                                   >> 950 G4ExtrudedSolid::ZSection G4GDMLReadSolids::
                                                   >> 951 SectionRead(const xercesc::DOMElement* const sectionElement,G4double lunit) 
                                                   >> 952 {
                                                   >> 953    G4double zPosition = 0.0;
                                                   >> 954    G4TwoVector Offset;
                                                   >> 955    G4double scalingFactor = 1.0;
                                                   >> 956 
                                                   >> 957    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 958          = sectionElement->getAttributes();
                                                   >> 959    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 960 
                                                   >> 961    for (XMLSize_t attribute_index=0;
                                                   >> 962         attribute_index<attributeCount; attribute_index++)
                                                   >> 963    {
                                                   >> 964       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 965 
                                                   >> 966       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 967         { continue; }
                                                   >> 968 
                                                   >> 969       const xercesc::DOMAttr* const attribute
                                                   >> 970             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 971       if (!attribute)
                                                   >> 972       {
                                                   >> 973         G4Exception("G4GDMLReadSolids::SectionRead()",
                                                   >> 974                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 975         return G4ExtrudedSolid::ZSection(zPosition,Offset,scalingFactor);
                                                   >> 976       }
                                                   >> 977       const G4String attName = Transcode(attribute->getName());
                                                   >> 978       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 979 
                                                   >> 980       if (attName=="zPosition")
                                                   >> 981         { zPosition = eval.Evaluate(attValue)*lunit; } else
                                                   >> 982       if (attName=="xOffset")
                                                   >> 983         { Offset.setX(eval.Evaluate(attValue)*lunit); } else
                                                   >> 984       if (attName=="yOffset")
                                                   >> 985         { Offset.setY(eval.Evaluate(attValue)*lunit); } else
                                                   >> 986       if (attName=="scalingFactor")
                                                   >> 987         { scalingFactor = eval.Evaluate(attValue); }
                                                   >> 988    }
                                                   >> 989 
                                                   >> 990    return G4ExtrudedSolid::ZSection(zPosition,Offset,scalingFactor);
                                                   >> 991 }
                                                   >> 992 
                                                   >> 993 void G4GDMLReadSolids::
                                                   >> 994 SphereRead(const xercesc::DOMElement* const sphereElement)
                                                   >> 995 {
                                                   >> 996    G4String name;
                                                   >> 997    G4double lunit = 1.0;
                                                   >> 998    G4double aunit = 1.0;
                                                   >> 999    G4double rmin = 0.0;
                                                   >> 1000    G4double rmax = 0.0;
                                                   >> 1001    G4double startphi = 0.0;
                                                   >> 1002    G4double deltaphi = 0.0;
                                                   >> 1003    G4double starttheta = 0.0;
                                                   >> 1004    G4double deltatheta = 0.0;
                                                   >> 1005 
                                                   >> 1006    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1007          = sphereElement->getAttributes();
                                                   >> 1008    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1009 
                                                   >> 1010    for (XMLSize_t attribute_index=0;
                                                   >> 1011         attribute_index<attributeCount; attribute_index++)
                                                   >> 1012    {
                                                   >> 1013       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1014 
                                                   >> 1015       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1016         { continue; }
                                                   >> 1017 
                                                   >> 1018       const xercesc::DOMAttr* const attribute
                                                   >> 1019             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1020       if (!attribute)
                                                   >> 1021       {
                                                   >> 1022         G4Exception("G4GDMLReadSolids::SphereRead()",
                                                   >> 1023                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1024         return;
                                                   >> 1025       }
                                                   >> 1026       const G4String attName = Transcode(attribute->getName());
                                                   >> 1027       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1028 
                                                   >> 1029       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 1030       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 1031       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
                                                   >> 1032       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
                                                   >> 1033       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
                                                   >> 1034       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
                                                   >> 1035       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
                                                   >> 1036       if (attName=="starttheta") { starttheta = eval.Evaluate(attValue); } else
                                                   >> 1037       if (attName=="deltatheta") { deltatheta = eval.Evaluate(attValue); }
                                                   >> 1038    }
                                                   >> 1039 
                                                   >> 1040    rmin *= lunit;
                                                   >> 1041    rmax *= lunit;
                                                   >> 1042    startphi *= aunit;
                                                   >> 1043    deltaphi *= aunit;
                                                   >> 1044    starttheta *= aunit;
                                                   >> 1045    deltatheta *= aunit;
                                                   >> 1046 
                                                   >> 1047    new G4Sphere(name,rmin,rmax,startphi,deltaphi,starttheta,deltatheta);
                                                   >> 1048 }
                                                   >> 1049 
                                                   >> 1050 void G4GDMLReadSolids::
                                                   >> 1051 TessellatedRead(const xercesc::DOMElement* const tessellatedElement)
                                                   >> 1052 {
                                                   >> 1053    G4String name;
                                                   >> 1054 
                                                   >> 1055    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1056          = tessellatedElement->getAttributes();
                                                   >> 1057    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1058 
                                                   >> 1059    for (XMLSize_t attribute_index=0;
                                                   >> 1060         attribute_index<attributeCount; attribute_index++)
                                                   >> 1061    {
                                                   >> 1062       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1063 
                                                   >> 1064       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1065         { continue; }
                                                   >> 1066 
                                                   >> 1067       const xercesc::DOMAttr* const attribute
                                                   >> 1068             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1069       if (!attribute)
                                                   >> 1070       {
                                                   >> 1071         G4Exception("G4GDMLReadSolids::TessellatedRead()",
                                                   >> 1072                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1073         return;
                                                   >> 1074       }
                                                   >> 1075       const G4String attName = Transcode(attribute->getName());
                                                   >> 1076       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1077 
                                                   >> 1078       if (attName=="name")  { name = GenerateName(attValue); }
                                                   >> 1079    }
                                                   >> 1080    
                                                   >> 1081    G4TessellatedSolid *tessellated = new G4TessellatedSolid(name);
                                                   >> 1082 
                                                   >> 1083    for (xercesc::DOMNode* iter = tessellatedElement->getFirstChild();
                                                   >> 1084         iter != 0; iter = iter->getNextSibling())
                                                   >> 1085    {
                                                   >> 1086       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 1087 
                                                   >> 1088       const xercesc::DOMElement* const child
                                                   >> 1089             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 1090       if (!child)
                                                   >> 1091       {
                                                   >> 1092         G4Exception("G4GDMLReadSolids::TessellatedRead()",
                                                   >> 1093                     "InvalidRead", FatalException, "No child found!");
                                                   >> 1094         return;
                                                   >> 1095       }
                                                   >> 1096       const G4String tag = Transcode(child->getTagName());
                                                   >> 1097 
                                                   >> 1098       if (tag=="triangular")
                                                   >> 1099         { tessellated->AddFacet(TriangularRead(child)); } else
                                                   >> 1100       if (tag=="quadrangular")
                                                   >> 1101         { tessellated->AddFacet(QuadrangularRead(child)); }
                                                   >> 1102    }
2059                                                  1103 
2060   const xercesc::DOMNamedNodeMap* const attri << 1104    tessellated->SetSolidClosed(true);
2061     tessellatedElement->getAttributes();      << 
2062   XMLSize_t attributeCount = attributes->getL << 
2063                                               << 
2064   for(XMLSize_t attribute_index = 0; attribut << 
2065       ++attribute_index)                      << 
2066   {                                           << 
2067     xercesc::DOMNode* attribute_node = attrib << 
2068                                               << 
2069     if(attribute_node->getNodeType() != xerce << 
2070     {                                         << 
2071       continue;                               << 
2072     }                                         << 
2073                                               << 
2074     const xercesc::DOMAttr* const attribute = << 
2075       dynamic_cast<xercesc::DOMAttr*>(attribu << 
2076     if(attribute == nullptr)                  << 
2077     {                                         << 
2078       G4Exception("G4GDMLReadSolids::Tessella << 
2079                   FatalException, "No attribu << 
2080       return;                                 << 
2081     }                                         << 
2082     const G4String attName  = Transcode(attri << 
2083     const G4String attValue = Transcode(attri << 
2084                                               << 
2085     if(attName == "name")                     << 
2086     {                                         << 
2087       name = GenerateName(attValue);          << 
2088     }                                         << 
2089   }                                           << 
2090                                               << 
2091   G4TessellatedSolid* tessellated = new G4Tes << 
2092                                               << 
2093   for(xercesc::DOMNode* iter = tessellatedEle << 
2094                         iter != nullptr; iter << 
2095   {                                           << 
2096     if(iter->getNodeType() != xercesc::DOMNod << 
2097     {                                         << 
2098       continue;                               << 
2099     }                                         << 
2100                                               << 
2101     const xercesc::DOMElement* const child =  << 
2102       dynamic_cast<xercesc::DOMElement*>(iter << 
2103     if(child == nullptr)                      << 
2104     {                                         << 
2105       G4Exception("G4GDMLReadSolids::Tessella << 
2106                   FatalException, "No child f << 
2107       return;                                 << 
2108     }                                         << 
2109     const G4String tag = Transcode(child->get << 
2110                                               << 
2111     if(tag == "triangular")                   << 
2112     {                                         << 
2113       tessellated->AddFacet(TriangularRead(ch << 
2114     }                                         << 
2115     else if(tag == "quadrangular")            << 
2116     {                                         << 
2117       tessellated->AddFacet(QuadrangularRead( << 
2118     }                                         << 
2119   }                                           << 
2120                                               << 
2121   tessellated->SetSolidClosed(true);          << 
2122 }                                                1105 }
2123                                                  1106 
2124 // ------------------------------------------ << 
2125 void G4GDMLReadSolids::TetRead(const xercesc:    1107 void G4GDMLReadSolids::TetRead(const xercesc::DOMElement* const tetElement)
2126 {                                                1108 {
2127   G4String name;                              << 1109    G4String name;
2128   G4ThreeVector vertex1;                      << 1110    G4ThreeVector vertex1;
2129   G4ThreeVector vertex2;                      << 1111    G4ThreeVector vertex2;
2130   G4ThreeVector vertex3;                      << 1112    G4ThreeVector vertex3;
2131   G4ThreeVector vertex4;                      << 1113    G4ThreeVector vertex4;
2132   G4double lunit = 1.0;                       << 1114    G4double lunit = 1.0;
2133                                               << 1115    
2134   const xercesc::DOMNamedNodeMap* const attri << 1116    const xercesc::DOMNamedNodeMap* const attributes
2135     tetElement->getAttributes();              << 1117          = tetElement->getAttributes();
2136   XMLSize_t attributeCount = attributes->getL << 1118    XMLSize_t attributeCount = attributes->getLength();
2137                                               << 1119 
2138   for(XMLSize_t attribute_index = 0; attribut << 1120    for (XMLSize_t attribute_index=0;
2139       ++attribute_index)                      << 1121         attribute_index<attributeCount;attribute_index++)
2140   {                                           << 1122    {
2141     xercesc::DOMNode* attribute_node = attrib << 1123       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2142                                               << 1124 
2143     if(attribute_node->getNodeType() != xerce << 1125       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2144     {                                         << 1126         { continue; }
2145       continue;                               << 1127 
2146     }                                         << 1128       const xercesc::DOMAttr* const attribute
2147                                               << 1129             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2148     const xercesc::DOMAttr* const attribute = << 1130       if (!attribute)
2149       dynamic_cast<xercesc::DOMAttr*>(attribu << 1131       {
2150     if(attribute == nullptr)                  << 1132         G4Exception("G4GDMLReadSolids::TetRead()",
2151     {                                         << 1133                     "InvalidRead", FatalException, "No attribute found!");
2152       G4Exception("G4GDMLReadSolids::TetRead( << 1134         return;
2153                   "No attribute found!");     << 1135       }
2154       return;                                 << 1136       const G4String attName = Transcode(attribute->getName());
2155     }                                         << 1137       const G4String attValue = Transcode(attribute->getValue());
2156     const G4String attName  = Transcode(attri << 1138 
2157     const G4String attValue = Transcode(attri << 1139       if (attName=="name")
2158                                               << 1140         { name = GenerateName(attValue); } else
2159     if(attName == "name")                     << 1141       if (attName=="lunit")
2160     {                                         << 1142         { lunit = eval.Evaluate(attValue); } else
2161       name = GenerateName(attValue);          << 1143       if (attName=="vertex1")
2162     }                                         << 1144         { vertex1 = GetPosition(GenerateName(attValue)); } else
2163     else if(attName == "lunit")               << 1145       if (attName=="vertex2")
2164     {                                         << 1146         { vertex2 = GetPosition(GenerateName(attValue)); } else
2165       lunit = G4UnitDefinition::GetValueOf(at << 1147       if (attName=="vertex3")
2166       if(G4UnitDefinition::GetCategory(attVal << 1148         { vertex3 = GetPosition(GenerateName(attValue)); } else
2167       {                                       << 1149       if (attName=="vertex4")
2168         G4Exception("G4GDMLReadSolids::TetRea << 1150         { vertex4 = GetPosition(GenerateName(attValue)); }
2169                     FatalException, "Invalid  << 1151    }
2170       }                                       << 
2171     }                                         << 
2172     else if(attName == "vertex1")             << 
2173     {                                         << 
2174       vertex1 = GetPosition(GenerateName(attV << 
2175     }                                         << 
2176     else if(attName == "vertex2")             << 
2177     {                                         << 
2178       vertex2 = GetPosition(GenerateName(attV << 
2179     }                                         << 
2180     else if(attName == "vertex3")             << 
2181     {                                         << 
2182       vertex3 = GetPosition(GenerateName(attV << 
2183     }                                         << 
2184     else if(attName == "vertex4")             << 
2185     {                                         << 
2186       vertex4 = GetPosition(GenerateName(attV << 
2187     }                                         << 
2188   }                                           << 
2189                                                  1152 
2190   new G4Tet(name, vertex1 * lunit, vertex2 *  << 1153    new G4Tet(name,vertex1*lunit,vertex2*lunit,vertex3*lunit,vertex4*lunit);
2191             vertex4 * lunit);                 << 
2192 }                                                1154 }
2193                                                  1155 
2194 // ------------------------------------------ << 
2195 void G4GDMLReadSolids::TorusRead(const xerces    1156 void G4GDMLReadSolids::TorusRead(const xercesc::DOMElement* const torusElement)
2196 {                                                1157 {
2197   G4String name;                              << 1158    G4String name;
2198   G4double lunit    = 1.0;                    << 1159    G4double lunit = 1.0;
2199   G4double aunit    = 1.0;                    << 1160    G4double aunit = 1.0;
2200   G4double rmin     = 0.0;                    << 1161    G4double rmin = 0.0;
2201   G4double rmax     = 0.0;                    << 1162    G4double rmax = 0.0;
2202   G4double rtor     = 0.0;                    << 1163    G4double rtor = 0.0;
2203   G4double startphi = 0.0;                    << 1164    G4double startphi = 0.0;
2204   G4double deltaphi = 0.0;                    << 1165    G4double deltaphi = 0.0;
2205                                               << 1166 
2206   const xercesc::DOMNamedNodeMap* const attri << 1167    const xercesc::DOMNamedNodeMap* const attributes
2207     torusElement->getAttributes();            << 1168          = torusElement->getAttributes();
2208   XMLSize_t attributeCount = attributes->getL << 1169    XMLSize_t attributeCount = attributes->getLength();
2209                                               << 1170 
2210   for(XMLSize_t attribute_index = 0; attribut << 1171    for (XMLSize_t attribute_index=0;
2211       ++attribute_index)                      << 1172         attribute_index<attributeCount; attribute_index++)
2212   {                                           << 1173    {
2213     xercesc::DOMNode* attribute_node = attrib << 1174       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2214                                               << 1175 
2215     if(attribute_node->getNodeType() != xerce << 1176       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2216     {                                         << 1177         { continue; }
2217       continue;                               << 1178 
2218     }                                         << 1179       const xercesc::DOMAttr* const attribute
2219                                               << 1180             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2220     const xercesc::DOMAttr* const attribute = << 1181       if (!attribute)
2221       dynamic_cast<xercesc::DOMAttr*>(attribu << 1182       {
2222     if(attribute == nullptr)                  << 1183         G4Exception("G4GDMLReadSolids::TorusRead()",
2223     {                                         << 1184                     "InvalidRead", FatalException, "No attribute found!");
2224       G4Exception("G4GDMLReadSolids::TorusRea << 1185         return;
2225                   FatalException, "No attribu << 1186       }
2226       return;                                 << 1187       const G4String attName = Transcode(attribute->getName());
2227     }                                         << 1188       const G4String attValue = Transcode(attribute->getValue());
2228     const G4String attName  = Transcode(attri << 1189 
2229     const G4String attValue = Transcode(attri << 1190       if (attName=="name") { name = GenerateName(attValue); } else
2230                                               << 1191       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2231     if(attName == "name")                     << 1192       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2232     {                                         << 1193       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
2233       name = GenerateName(attValue);          << 1194       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
2234     }                                         << 1195       if (attName=="rtor") { rtor = eval.Evaluate(attValue); } else
2235     else if(attName == "lunit")               << 1196       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
2236     {                                         << 1197       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
2237       lunit = G4UnitDefinition::GetValueOf(at << 1198    }
2238       if(G4UnitDefinition::GetCategory(attVal << 1199 
2239       {                                       << 1200    rmin *= lunit;
2240         G4Exception("G4GDMLReadSolids::TorusR << 1201    rmax *= lunit;
2241                     FatalException, "Invalid  << 1202    rtor *= lunit;
2242       }                                       << 1203    startphi *= aunit;
2243     }                                         << 1204    deltaphi *= aunit;
2244     else if(attName == "aunit")               << 1205 
2245     {                                         << 1206    new G4Torus(name,rmin,rmax,rtor,startphi,deltaphi);
2246       aunit = G4UnitDefinition::GetValueOf(at << 1207 }
2247       if(G4UnitDefinition::GetCategory(attVal << 1208 
2248       {                                       << 1209 void G4GDMLReadSolids::
2249         G4Exception("G4GDMLReadSolids::TorusR << 1210 GenTrapRead(const xercesc::DOMElement* const gtrapElement)
2250                     FatalException, "Invalid  << 1211 {
2251       }                                       << 1212    G4String name;
2252     }                                         << 1213    G4double lunit = 1.0;
2253     else if(attName == "rmin")                << 1214    G4double dz =0.0;
2254     {                                         << 1215    G4double v1x=0.0, v1y=0.0, v2x=0.0, v2y=0.0, v3x=0.0, v3y=0.0,
2255       rmin = eval.Evaluate(attValue);         << 1216       v4x=0.0, v4y=0.0, v5x=0.0, v5y=0.0, v6x=0.0, v6y=0.0,
2256     }                                         << 1217       v7x=0.0, v7y=0.0, v8x=0.0, v8y=0.0;
2257     else if(attName == "rmax")                << 1218 
2258     {                                         << 1219    const xercesc::DOMNamedNodeMap* const attributes
2259       rmax = eval.Evaluate(attValue);         << 1220          = gtrapElement->getAttributes();
2260     }                                         << 1221    XMLSize_t attributeCount = attributes->getLength();
2261     else if(attName == "rtor")                << 1222 
2262     {                                         << 1223    for (XMLSize_t attribute_index=0;
2263       rtor = eval.Evaluate(attValue);         << 1224         attribute_index<attributeCount; attribute_index++)
2264     }                                         << 1225    {
2265     else if(attName == "startphi")            << 1226       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2266     {                                         << 1227 
2267       startphi = eval.Evaluate(attValue);     << 1228       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2268     }                                         << 1229         { continue; }
2269     else if(attName == "deltaphi")            << 1230 
2270     {                                         << 1231       const xercesc::DOMAttr* const attribute
2271       deltaphi = eval.Evaluate(attValue);     << 1232             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2272     }                                         << 1233       if (!attribute)
2273   }                                           << 1234       {
2274                                               << 1235         G4Exception("G4GDMLReadSolids::GenTrapRead()",
2275   rmin *= lunit;                              << 1236                     "InvalidRead", FatalException, "No attribute found!");
2276   rmax *= lunit;                              << 1237         return;
2277   rtor *= lunit;                              << 1238       }
2278   startphi *= aunit;                          << 1239       const G4String attName = Transcode(attribute->getName());
2279   deltaphi *= aunit;                          << 1240       const G4String attValue = Transcode(attribute->getValue());
2280                                               << 1241 
2281   new G4Torus(name, rmin, rmax, rtor, startph << 1242       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 1243       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
                                                   >> 1244       if (attName=="dz") { dz = eval.Evaluate(attValue); } else
                                                   >> 1245       if (attName=="v1x") { v1x = eval.Evaluate(attValue); } else
                                                   >> 1246       if (attName=="v1y") { v1y = eval.Evaluate(attValue); } else
                                                   >> 1247       if (attName=="v2x") { v2x = eval.Evaluate(attValue); } else
                                                   >> 1248       if (attName=="v2y") { v2y = eval.Evaluate(attValue); } else
                                                   >> 1249       if (attName=="v3x") { v3x = eval.Evaluate(attValue); } else
                                                   >> 1250       if (attName=="v3y") { v3y = eval.Evaluate(attValue); } else
                                                   >> 1251       if (attName=="v4x") { v4x = eval.Evaluate(attValue); } else
                                                   >> 1252       if (attName=="v4y") { v4y = eval.Evaluate(attValue); } else
                                                   >> 1253       if (attName=="v5x") { v5x = eval.Evaluate(attValue); } else
                                                   >> 1254       if (attName=="v5y") { v5y = eval.Evaluate(attValue); } else
                                                   >> 1255       if (attName=="v6x") { v6x = eval.Evaluate(attValue); } else
                                                   >> 1256       if (attName=="v6y") { v6y = eval.Evaluate(attValue); } else
                                                   >> 1257       if (attName=="v7x") { v7x = eval.Evaluate(attValue); } else
                                                   >> 1258       if (attName=="v7y") { v7y = eval.Evaluate(attValue); } else
                                                   >> 1259       if (attName=="v8x") { v8x = eval.Evaluate(attValue); } else
                                                   >> 1260       if (attName=="v8y") { v8y = eval.Evaluate(attValue); }
                                                   >> 1261    }
                                                   >> 1262 
                                                   >> 1263    dz *= lunit;
                                                   >> 1264    std::vector<G4TwoVector> vertices;
                                                   >> 1265    vertices.push_back(G4TwoVector(v1x*lunit,v1y*lunit));
                                                   >> 1266    vertices.push_back(G4TwoVector(v2x*lunit,v2y*lunit));
                                                   >> 1267    vertices.push_back(G4TwoVector(v3x*lunit,v3y*lunit));
                                                   >> 1268    vertices.push_back(G4TwoVector(v4x*lunit,v4y*lunit));
                                                   >> 1269    vertices.push_back(G4TwoVector(v5x*lunit,v5y*lunit));
                                                   >> 1270    vertices.push_back(G4TwoVector(v6x*lunit,v6y*lunit));
                                                   >> 1271    vertices.push_back(G4TwoVector(v7x*lunit,v7y*lunit));
                                                   >> 1272    vertices.push_back(G4TwoVector(v8x*lunit,v8y*lunit));
                                                   >> 1273    new G4GenericTrap(name,dz,vertices);
2282 }                                                1274 }
2283                                                  1275 
2284 // ------------------------------------------ << 
2285 void G4GDMLReadSolids::GenTrapRead(           << 
2286   const xercesc::DOMElement* const gtrapEleme << 
2287 {                                             << 
2288   G4String name;                              << 
2289   G4double lunit = 1.0;                       << 
2290   G4double dz    = 0.0;                       << 
2291   G4double v1x = 0.0, v1y = 0.0, v2x = 0.0, v << 
2292            v4x = 0.0, v4y = 0.0, v5x = 0.0, v << 
2293            v7x = 0.0, v7y = 0.0, v8x = 0.0, v << 
2294                                               << 
2295   const xercesc::DOMNamedNodeMap* const attri << 
2296     gtrapElement->getAttributes();            << 
2297   XMLSize_t attributeCount = attributes->getL << 
2298                                               << 
2299   for(XMLSize_t attribute_index = 0; attribut << 
2300       ++attribute_index)                      << 
2301   {                                           << 
2302     xercesc::DOMNode* attribute_node = attrib << 
2303                                               << 
2304     if(attribute_node->getNodeType() != xerce << 
2305     {                                         << 
2306       continue;                               << 
2307     }                                         << 
2308                                               << 
2309     const xercesc::DOMAttr* const attribute = << 
2310       dynamic_cast<xercesc::DOMAttr*>(attribu << 
2311     if(attribute == nullptr)                  << 
2312     {                                         << 
2313       G4Exception("G4GDMLReadSolids::GenTrapR << 
2314                   FatalException, "No attribu << 
2315       return;                                 << 
2316     }                                         << 
2317     const G4String attName  = Transcode(attri << 
2318     const G4String attValue = Transcode(attri << 
2319                                               << 
2320     if(attName == "name")                     << 
2321     {                                         << 
2322       name = GenerateName(attValue);          << 
2323     }                                         << 
2324     else if(attName == "lunit")               << 
2325     {                                         << 
2326       lunit = G4UnitDefinition::GetValueOf(at << 
2327       if(G4UnitDefinition::GetCategory(attVal << 
2328       {                                       << 
2329         G4Exception("G4GDMLReadSolids::GenTra << 
2330                     FatalException, "Invalid  << 
2331       }                                       << 
2332     }                                         << 
2333     else if(attName == "dz")                  << 
2334     {                                         << 
2335       dz = eval.Evaluate(attValue);           << 
2336     }                                         << 
2337     else if(attName == "v1x")                 << 
2338     {                                         << 
2339       v1x = eval.Evaluate(attValue);          << 
2340     }                                         << 
2341     else if(attName == "v1y")                 << 
2342     {                                         << 
2343       v1y = eval.Evaluate(attValue);          << 
2344     }                                         << 
2345     else if(attName == "v2x")                 << 
2346     {                                         << 
2347       v2x = eval.Evaluate(attValue);          << 
2348     }                                         << 
2349     else if(attName == "v2y")                 << 
2350     {                                         << 
2351       v2y = eval.Evaluate(attValue);          << 
2352     }                                         << 
2353     else if(attName == "v3x")                 << 
2354     {                                         << 
2355       v3x = eval.Evaluate(attValue);          << 
2356     }                                         << 
2357     else if(attName == "v3y")                 << 
2358     {                                         << 
2359       v3y = eval.Evaluate(attValue);          << 
2360     }                                         << 
2361     else if(attName == "v4x")                 << 
2362     {                                         << 
2363       v4x = eval.Evaluate(attValue);          << 
2364     }                                         << 
2365     else if(attName == "v4y")                 << 
2366     {                                         << 
2367       v4y = eval.Evaluate(attValue);          << 
2368     }                                         << 
2369     else if(attName == "v5x")                 << 
2370     {                                         << 
2371       v5x = eval.Evaluate(attValue);          << 
2372     }                                         << 
2373     else if(attName == "v5y")                 << 
2374     {                                         << 
2375       v5y = eval.Evaluate(attValue);          << 
2376     }                                         << 
2377     else if(attName == "v6x")                 << 
2378     {                                         << 
2379       v6x = eval.Evaluate(attValue);          << 
2380     }                                         << 
2381     else if(attName == "v6y")                 << 
2382     {                                         << 
2383       v6y = eval.Evaluate(attValue);          << 
2384     }                                         << 
2385     else if(attName == "v7x")                 << 
2386     {                                         << 
2387       v7x = eval.Evaluate(attValue);          << 
2388     }                                         << 
2389     else if(attName == "v7y")                 << 
2390     {                                         << 
2391       v7y = eval.Evaluate(attValue);          << 
2392     }                                         << 
2393     else if(attName == "v8x")                 << 
2394     {                                         << 
2395       v8x = eval.Evaluate(attValue);          << 
2396     }                                         << 
2397     else if(attName == "v8y")                 << 
2398     {                                         << 
2399       v8y = eval.Evaluate(attValue);          << 
2400     }                                         << 
2401   }                                           << 
2402                                               << 
2403   dz *= lunit;                                << 
2404   std::vector<G4TwoVector> vertices;          << 
2405   vertices.push_back(G4TwoVector(v1x * lunit, << 
2406   vertices.push_back(G4TwoVector(v2x * lunit, << 
2407   vertices.push_back(G4TwoVector(v3x * lunit, << 
2408   vertices.push_back(G4TwoVector(v4x * lunit, << 
2409   vertices.push_back(G4TwoVector(v5x * lunit, << 
2410   vertices.push_back(G4TwoVector(v6x * lunit, << 
2411   vertices.push_back(G4TwoVector(v7x * lunit, << 
2412   vertices.push_back(G4TwoVector(v8x * lunit, << 
2413   new G4GenericTrap(name, dz, vertices);      << 
2414 }                                             << 
2415                                               << 
2416 // ------------------------------------------ << 
2417 void G4GDMLReadSolids::TrapRead(const xercesc    1276 void G4GDMLReadSolids::TrapRead(const xercesc::DOMElement* const trapElement)
2418 {                                                1277 {
2419   G4String name;                              << 1278    G4String name;
2420   G4double lunit  = 1.0;                      << 1279    G4double lunit = 1.0;
2421   G4double aunit  = 1.0;                      << 1280    G4double aunit = 1.0;
2422   G4double z      = 0.0;                      << 1281    G4double z = 0.0;
2423   G4double theta  = 0.0;                      << 1282    G4double theta = 0.0;
2424   G4double phi    = 0.0;                      << 1283    G4double phi = 0.0;
2425   G4double y1     = 0.0;                      << 1284    G4double y1 = 0.0;
2426   G4double x1     = 0.0;                      << 1285    G4double x1 = 0.0;
2427   G4double x2     = 0.0;                      << 1286    G4double x2 = 0.0;
2428   G4double alpha1 = 0.0;                      << 1287    G4double alpha1 = 0.0;
2429   G4double y2     = 0.0;                      << 1288    G4double y2 = 0.0;
2430   G4double x3     = 0.0;                      << 1289    G4double x3 = 0.0;
2431   G4double x4     = 0.0;                      << 1290    G4double x4 = 0.0;
2432   G4double alpha2 = 0.0;                      << 1291    G4double alpha2 = 0.0;
2433                                               << 1292 
2434   const xercesc::DOMNamedNodeMap* const attri << 1293    const xercesc::DOMNamedNodeMap* const attributes
2435     trapElement->getAttributes();             << 1294          = trapElement->getAttributes();
2436   XMLSize_t attributeCount = attributes->getL << 1295    XMLSize_t attributeCount = attributes->getLength();
2437                                               << 1296 
2438   for(XMLSize_t attribute_index = 0; attribut << 1297    for (XMLSize_t attribute_index=0;
2439       ++attribute_index)                      << 1298         attribute_index<attributeCount; attribute_index++)
2440   {                                           << 1299    {
2441     xercesc::DOMNode* attribute_node = attrib << 1300       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2442                                               << 1301 
2443     if(attribute_node->getNodeType() != xerce << 1302       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2444     {                                         << 1303         { continue; }
2445       continue;                               << 1304 
2446     }                                         << 1305       const xercesc::DOMAttr* const attribute
2447                                               << 1306             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2448     const xercesc::DOMAttr* const attribute = << 1307       if (!attribute)
2449       dynamic_cast<xercesc::DOMAttr*>(attribu << 1308       {
2450     if(attribute == nullptr)                  << 1309         G4Exception("G4GDMLReadSolids::TrapRead()",
2451     {                                         << 1310                     "InvalidRead", FatalException, "No attribute found!");
2452       G4Exception("G4GDMLReadSolids::TrapRead << 1311         return;
2453                   "No attribute found!");     << 1312       }
2454       return;                                 << 1313       const G4String attName = Transcode(attribute->getName());
2455     }                                         << 1314       const G4String attValue = Transcode(attribute->getValue());
2456     const G4String attName  = Transcode(attri << 1315 
2457     const G4String attValue = Transcode(attri << 1316       if (attName=="name") { name = GenerateName(attValue); } else
2458                                               << 1317       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2459     if(attName == "name")                     << 1318       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2460     {                                         << 1319       if (attName=="z") { z = eval.Evaluate(attValue); } else
2461       name = GenerateName(attValue);          << 1320       if (attName=="theta") { theta = eval.Evaluate(attValue); } else
2462     }                                         << 1321       if (attName=="phi") { phi = eval.Evaluate(attValue); } else
2463     else if(attName == "lunit")               << 1322       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2464     {                                         << 1323       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2465       lunit = G4UnitDefinition::GetValueOf(at << 1324       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2466       if(G4UnitDefinition::GetCategory(attVal << 1325       if (attName=="alpha1") { alpha1 = eval.Evaluate(attValue); } else
2467       {                                       << 1326       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2468         G4Exception("G4GDMLReadSolids::TrapRe << 1327       if (attName=="x3") { x3 = eval.Evaluate(attValue); } else
2469                     FatalException, "Invalid  << 1328       if (attName=="x4") { x4 = eval.Evaluate(attValue); } else
2470       }                                       << 1329       if (attName=="alpha2") { alpha2 = eval.Evaluate(attValue); }
2471     }                                         << 1330    }
2472     else if(attName == "aunit")               << 1331 
2473     {                                         << 1332    z *= 0.5*lunit;
2474       aunit = G4UnitDefinition::GetValueOf(at << 1333    theta *= aunit;
2475       if(G4UnitDefinition::GetCategory(attVal << 1334    phi *= aunit;
2476       {                                       << 1335    y1 *= 0.5*lunit;
2477         G4Exception("G4GDMLReadSolids::TrapRe << 1336    x1 *= 0.5*lunit;
2478                     FatalException, "Invalid  << 1337    x2 *= 0.5*lunit;
2479       }                                       << 1338    alpha1 *= aunit;
2480     }                                         << 1339    y2 *= 0.5*lunit;
2481     else if(attName == "z")                   << 1340    x3 *= 0.5*lunit;
2482     {                                         << 1341    x4 *= 0.5*lunit;
2483       z = eval.Evaluate(attValue);            << 1342    alpha2 *= aunit;
2484     }                                         << 
2485     else if(attName == "theta")               << 
2486     {                                         << 
2487       theta = eval.Evaluate(attValue);        << 
2488     }                                         << 
2489     else if(attName == "phi")                 << 
2490     {                                         << 
2491       phi = eval.Evaluate(attValue);          << 
2492     }                                         << 
2493     else if(attName == "y1")                  << 
2494     {                                         << 
2495       y1 = eval.Evaluate(attValue);           << 
2496     }                                         << 
2497     else if(attName == "x1")                  << 
2498     {                                         << 
2499       x1 = eval.Evaluate(attValue);           << 
2500     }                                         << 
2501     else if(attName == "x2")                  << 
2502     {                                         << 
2503       x2 = eval.Evaluate(attValue);           << 
2504     }                                         << 
2505     else if(attName == "alpha1")              << 
2506     {                                         << 
2507       alpha1 = eval.Evaluate(attValue);       << 
2508     }                                         << 
2509     else if(attName == "y2")                  << 
2510     {                                         << 
2511       y2 = eval.Evaluate(attValue);           << 
2512     }                                         << 
2513     else if(attName == "x3")                  << 
2514     {                                         << 
2515       x3 = eval.Evaluate(attValue);           << 
2516     }                                         << 
2517     else if(attName == "x4")                  << 
2518     {                                         << 
2519       x4 = eval.Evaluate(attValue);           << 
2520     }                                         << 
2521     else if(attName == "alpha2")              << 
2522     {                                         << 
2523       alpha2 = eval.Evaluate(attValue);       << 
2524     }                                         << 
2525   }                                           << 
2526                                               << 
2527   z *= 0.5 * lunit;                           << 
2528   theta *= aunit;                             << 
2529   phi *= aunit;                               << 
2530   y1 *= 0.5 * lunit;                          << 
2531   x1 *= 0.5 * lunit;                          << 
2532   x2 *= 0.5 * lunit;                          << 
2533   alpha1 *= aunit;                            << 
2534   y2 *= 0.5 * lunit;                          << 
2535   x3 *= 0.5 * lunit;                          << 
2536   x4 *= 0.5 * lunit;                          << 
2537   alpha2 *= aunit;                            << 
2538                                                  1343 
2539   new G4Trap(name, z, theta, phi, y1, x1, x2, << 1344    new G4Trap(name,z,theta,phi,y1,x1,x2,alpha1,y2,x3,x4,alpha2);
2540 }                                                1345 }
2541                                                  1346 
2542 // ------------------------------------------ << 
2543 void G4GDMLReadSolids::TrdRead(const xercesc:    1347 void G4GDMLReadSolids::TrdRead(const xercesc::DOMElement* const trdElement)
2544 {                                                1348 {
2545   G4String name;                              << 1349    G4String name;
2546   G4double lunit = 1.0;                       << 1350    G4double lunit = 1.0;
2547   G4double x1    = 0.0;                       << 1351    G4double x1 = 0.0;
2548   G4double x2    = 0.0;                       << 1352    G4double x2 = 0.0;
2549   G4double y1    = 0.0;                       << 1353    G4double y1 = 0.0;
2550   G4double y2    = 0.0;                       << 1354    G4double y2 = 0.0;
2551   G4double z     = 0.0;                       << 1355    G4double z = 0.0;
2552                                               << 1356 
2553   const xercesc::DOMNamedNodeMap* const attri << 1357    const xercesc::DOMNamedNodeMap* const attributes = trdElement->getAttributes();
2554     trdElement->getAttributes();              << 1358    XMLSize_t attributeCount = attributes->getLength();
2555   XMLSize_t attributeCount = attributes->getL << 1359 
2556                                               << 1360    for (XMLSize_t attribute_index=0;
2557   for(XMLSize_t attribute_index = 0; attribut << 1361         attribute_index<attributeCount; attribute_index++)
2558       ++attribute_index)                      << 1362    {
2559   {                                           << 1363       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2560     xercesc::DOMNode* attribute_node = attrib << 1364 
2561                                               << 1365       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2562     if(attribute_node->getNodeType() != xerce << 1366         { continue; }
2563     {                                         << 1367 
2564       continue;                               << 1368       const xercesc::DOMAttr* const attribute
2565     }                                         << 1369             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2566                                               << 1370       if (!attribute)
2567     const xercesc::DOMAttr* const attribute = << 1371       {
2568       dynamic_cast<xercesc::DOMAttr*>(attribu << 1372         G4Exception("G4GDMLReadSolids::TrdRead()",
2569     if(attribute == nullptr)                  << 1373                     "InvalidRead", FatalException, "No attribute found!");
2570     {                                         << 1374         return;
2571       G4Exception("G4GDMLReadSolids::TrdRead( << 1375       }
2572                   "No attribute found!");     << 1376       const G4String attName = Transcode(attribute->getName());
2573       return;                                 << 1377       const G4String attValue = Transcode(attribute->getValue());
2574     }                                         << 1378 
2575     const G4String attName  = Transcode(attri << 1379       if (attName=="name") { name = GenerateName(attValue); } else
2576     const G4String attValue = Transcode(attri << 1380       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2577                                               << 1381       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2578     if(attName == "name")                     << 1382       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2579     {                                         << 1383       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2580       name = GenerateName(attValue);          << 1384       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2581     }                                         << 1385       if (attName=="z") { z = eval.Evaluate(attValue); }
2582     else if(attName == "lunit")               << 1386    }
2583     {                                         << 1387 
2584       lunit = G4UnitDefinition::GetValueOf(at << 1388    x1 *= 0.5*lunit;
2585       if(G4UnitDefinition::GetCategory(attVal << 1389    x2 *= 0.5*lunit;
2586       {                                       << 1390    y1 *= 0.5*lunit;
2587         G4Exception("G4GDMLReadSolids::TrdRea << 1391    y2 *= 0.5*lunit;
2588                     FatalException, "Invalid  << 1392    z *= 0.5*lunit;
2589       }                                       << 1393 
2590     }                                         << 1394    new G4Trd(name,x1,x2,y1,y2,z);
2591     else if(attName == "x1")                  << 1395 }
2592     {                                         << 1396 
2593       x1 = eval.Evaluate(attValue);           << 1397 G4TriangularFacet* G4GDMLReadSolids::
2594     }                                         << 1398 TriangularRead(const xercesc::DOMElement* const triangularElement)
2595     else if(attName == "x2")                  << 1399 {
2596     {                                         << 1400    G4ThreeVector vertex1;
2597       x2 = eval.Evaluate(attValue);           << 1401    G4ThreeVector vertex2;
2598     }                                         << 1402    G4ThreeVector vertex3;
2599     else if(attName == "y1")                  << 1403    G4FacetVertexType type = ABSOLUTE;
2600     {                                         << 1404    G4double lunit = 1.0;
2601       y1 = eval.Evaluate(attValue);           << 1405 
2602     }                                         << 1406    const xercesc::DOMNamedNodeMap* const attributes
2603     else if(attName == "y2")                  << 1407          = triangularElement->getAttributes();
2604     {                                         << 1408    XMLSize_t attributeCount = attributes->getLength();
2605       y2 = eval.Evaluate(attValue);           << 1409 
2606     }                                         << 1410    for (XMLSize_t attribute_index=0;
2607     else if(attName == "z")                   << 1411         attribute_index<attributeCount; attribute_index++)
2608     {                                         << 1412    {
2609       z = eval.Evaluate(attValue);            << 1413       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2610     }                                         << 1414 
2611   }                                           << 1415       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2612                                               << 1416         { continue; }
2613   x1 *= 0.5 * lunit;                          << 1417 
2614   x2 *= 0.5 * lunit;                          << 1418       const xercesc::DOMAttr* const attribute
2615   y1 *= 0.5 * lunit;                          << 1419             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2616   y2 *= 0.5 * lunit;                          << 1420       if (!attribute)
2617   z *= 0.5 * lunit;                           << 1421       {
2618                                               << 1422         G4Exception("G4GDMLReadSolids::TriangularRead()",
2619   new G4Trd(name, x1, x2, y1, y2, z);         << 1423                     "InvalidRead", FatalException, "No attribute found!");
2620 }                                             << 1424         return 0;
2621                                               << 1425       }
2622 // ------------------------------------------ << 1426       const G4String attName = Transcode(attribute->getName());
2623 G4TriangularFacet* G4GDMLReadSolids::Triangul << 1427       const G4String attValue = Transcode(attribute->getValue());
2624   const xercesc::DOMElement* const triangular << 1428 
2625 {                                             << 1429       if (attName=="vertex1")
2626   G4ThreeVector vertex1;                      << 1430         { vertex1 = GetPosition(GenerateName(attValue)); } else
2627   G4ThreeVector vertex2;                      << 1431       if (attName=="vertex2")
2628   G4ThreeVector vertex3;                      << 1432         { vertex2 = GetPosition(GenerateName(attValue)); } else
2629   G4FacetVertexType type = ABSOLUTE;          << 1433       if (attName=="vertex3")
2630   G4double lunit         = 1.0;               << 1434         { vertex3 = GetPosition(GenerateName(attValue)); } else
2631                                               << 1435       if (attName=="lunit")
2632   const xercesc::DOMNamedNodeMap* const attri << 1436         { lunit = eval.Evaluate(attValue); } else
2633     triangularElement->getAttributes();       << 1437       if (attName=="type")
2634   XMLSize_t attributeCount = attributes->getL << 1438         { if (attValue=="RELATIVE") { type = RELATIVE; } }
2635                                               << 1439    }
2636   for(XMLSize_t attribute_index = 0; attribut << 
2637       ++attribute_index)                      << 
2638   {                                           << 
2639     xercesc::DOMNode* attribute_node = attrib << 
2640                                               << 
2641     if(attribute_node->getNodeType() != xerce << 
2642     {                                         << 
2643       continue;                               << 
2644     }                                         << 
2645                                               << 
2646     const xercesc::DOMAttr* const attribute = << 
2647       dynamic_cast<xercesc::DOMAttr*>(attribu << 
2648     if(attribute == nullptr)                  << 
2649     {                                         << 
2650       G4Exception("G4GDMLReadSolids::Triangul << 
2651                   FatalException, "No attribu << 
2652       return nullptr;                         << 
2653     }                                         << 
2654     const G4String attName  = Transcode(attri << 
2655     const G4String attValue = Transcode(attri << 
2656                                               << 
2657     if(attName == "vertex1")                  << 
2658     {                                         << 
2659       vertex1 = GetPosition(GenerateName(attV << 
2660     }                                         << 
2661     else if(attName == "vertex2")             << 
2662     {                                         << 
2663       vertex2 = GetPosition(GenerateName(attV << 
2664     }                                         << 
2665     else if(attName == "vertex3")             << 
2666     {                                         << 
2667       vertex3 = GetPosition(GenerateName(attV << 
2668     }                                         << 
2669     else if(attName == "lunit")               << 
2670     {                                         << 
2671       lunit = G4UnitDefinition::GetValueOf(at << 
2672       if(G4UnitDefinition::GetCategory(attVal << 
2673       {                                       << 
2674         G4Exception("G4GDMLReadSolids::Triang << 
2675                     FatalException, "Invalid  << 
2676       }                                       << 
2677     }                                         << 
2678     else if(attName == "type")                << 
2679     {                                         << 
2680       if(attValue == "RELATIVE")              << 
2681       {                                       << 
2682         type = RELATIVE;                      << 
2683       }                                       << 
2684     }                                         << 
2685   }                                           << 
2686                                                  1440 
2687   return new G4TriangularFacet(vertex1 * luni << 1441    return new G4TriangularFacet(vertex1*lunit,vertex2*lunit,vertex3*lunit,type);
2688                                vertex3 * luni << 
2689 }                                                1442 }
2690                                                  1443 
2691 // ------------------------------------------ << 
2692 void G4GDMLReadSolids::TubeRead(const xercesc    1444 void G4GDMLReadSolids::TubeRead(const xercesc::DOMElement* const tubeElement)
2693 {                                                1445 {
2694   G4String name;                              << 1446    G4String name;
2695   G4double lunit    = 1.0;                    << 1447    G4double lunit = 1.0;
2696   G4double aunit    = 1.0;                    << 1448    G4double aunit = 1.0;
2697   G4double rmin     = 0.0;                    << 1449    G4double rmin = 0.0;
2698   G4double rmax     = 0.0;                    << 1450    G4double rmax = 0.0;
2699   G4double z        = 0.0;                    << 1451    G4double z = 0.0;
2700   G4double startphi = 0.0;                    << 1452    G4double startphi = 0.0;
2701   G4double deltaphi = 0.0;                    << 1453    G4double deltaphi = 0.0;
2702                                               << 1454 
2703   const xercesc::DOMNamedNodeMap* const attri << 1455    const xercesc::DOMNamedNodeMap* const attributes
2704     tubeElement->getAttributes();             << 1456          = tubeElement->getAttributes();
2705   XMLSize_t attributeCount = attributes->getL << 1457    XMLSize_t attributeCount = attributes->getLength();
2706                                               << 1458 
2707   for(XMLSize_t attribute_index = 0; attribut << 1459    for (XMLSize_t attribute_index=0;
2708       ++attribute_index)                      << 1460         attribute_index<attributeCount; attribute_index++)
2709   {                                           << 1461    {
2710     xercesc::DOMNode* attribute_node = attrib << 1462       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2711                                               << 1463 
2712     if(attribute_node->getNodeType() != xerce << 1464       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2713     {                                         << 1465         { continue; }
2714       continue;                               << 1466 
2715     }                                         << 1467       const xercesc::DOMAttr* const attribute
2716                                               << 1468             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2717     const xercesc::DOMAttr* const attribute = << 1469       if (!attribute)
2718       dynamic_cast<xercesc::DOMAttr*>(attribu << 1470       {
2719     if(attribute == nullptr)                  << 1471         G4Exception("G4GDMLReadSolids::TubeRead()",
2720     {                                         << 1472                     "InvalidRead", FatalException, "No attribute found!");
2721       G4Exception("G4GDMLReadSolids::TubeRead << 1473         return;
2722                   "No attribute found!");     << 1474       }
2723       return;                                 << 1475       const G4String attName = Transcode(attribute->getName());
2724     }                                         << 1476       const G4String attValue = Transcode(attribute->getValue());
2725     const G4String attName  = Transcode(attri << 1477 
2726     const G4String attValue = Transcode(attri << 1478       if (attName=="name") { name = GenerateName(attValue); } else
2727                                               << 1479       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2728     if(attName == "name")                     << 1480       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2729     {                                         << 1481       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
2730       name = GenerateName(attValue);          << 1482       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
2731     }                                         << 1483       if (attName=="z") { z = eval.Evaluate(attValue); } else
2732     else if(attName == "lunit")               << 1484       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
2733     {                                         << 1485       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
2734       lunit = G4UnitDefinition::GetValueOf(at << 1486    }
2735       if(G4UnitDefinition::GetCategory(attVal << 1487 
2736       {                                       << 1488    rmin *= lunit;
2737         G4Exception("G4GDMLReadSolids::TubeRe << 1489    rmax *= lunit;
2738                     FatalException, "Invalid  << 1490    z *= 0.5*lunit;
2739       }                                       << 1491    startphi *= aunit;
2740     }                                         << 1492    deltaphi *= aunit;
2741     else if(attName == "aunit")               << 1493 
2742     {                                         << 1494    new G4Tubs(name,rmin,rmax,z,startphi,deltaphi);
2743       aunit = G4UnitDefinition::GetValueOf(at << 1495 }
2744       if(G4UnitDefinition::GetCategory(attVal << 1496 
2745       {                                       << 1497 void G4GDMLReadSolids::CutTubeRead(const xercesc::DOMElement* const cuttubeElement)
2746         G4Exception("G4GDMLReadSolids::TubeRe << 1498 {
2747                     FatalException, "Invalid  << 1499    G4String name;
2748       }                                       << 1500    G4double lunit = 1.0;
2749     }                                         << 1501    G4double aunit = 1.0;
2750     else if(attName == "rmin")                << 1502    G4double rmin = 0.0;
2751     {                                         << 1503    G4double rmax = 0.0;
2752       rmin = eval.Evaluate(attValue);         << 1504    G4double z = 0.0;
2753     }                                         << 1505    G4double startphi = 0.0;
2754     else if(attName == "rmax")                << 1506    G4double deltaphi = 0.0;
2755     {                                         << 1507    G4ThreeVector lowNorm(0);
2756       rmax = eval.Evaluate(attValue);         << 1508    G4ThreeVector highNorm(0);
2757     }                                         << 1509 
2758     else if(attName == "z")                   << 1510    const xercesc::DOMNamedNodeMap* const attributes
2759     {                                         << 1511          = cuttubeElement->getAttributes();
2760       z = eval.Evaluate(attValue);            << 1512    XMLSize_t attributeCount = attributes->getLength();
2761     }                                         << 1513 
2762     else if(attName == "startphi")            << 1514    for (XMLSize_t attribute_index=0;
2763     {                                         << 1515         attribute_index<attributeCount; attribute_index++)
2764       startphi = eval.Evaluate(attValue);     << 1516    {
2765     }                                         << 1517       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2766     else if(attName == "deltaphi")            << 1518 
2767     {                                         << 1519       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2768       deltaphi = eval.Evaluate(attValue);     << 1520         { continue; }
2769     }                                         << 1521 
2770   }                                           << 1522       const xercesc::DOMAttr* const attribute
2771                                               << 1523             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2772   rmin *= lunit;                              << 1524       if (!attribute)
2773   rmax *= lunit;                              << 1525       {
2774   z *= 0.5 * lunit;                           << 1526         G4Exception("G4GDMLReadSolids::CutTubeRead()",
2775   startphi *= aunit;                          << 1527                     "InvalidRead", FatalException, "No attribute found!");
2776   deltaphi *= aunit;                          << 1528         return;
2777                                               << 1529       }
2778   new G4Tubs(name, rmin, rmax, z, startphi, d << 1530       const G4String attName = Transcode(attribute->getName());
2779 }                                             << 1531       const G4String attValue = Transcode(attribute->getValue());
2780                                               << 1532 
2781 // ------------------------------------------ << 1533       if (attName=="name") { name = GenerateName(attValue); } else
2782 void G4GDMLReadSolids::CutTubeRead(           << 1534       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2783   const xercesc::DOMElement* const cuttubeEle << 1535       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2784 {                                             << 1536       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
2785   G4String name;                              << 1537       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
2786   G4double lunit    = 1.0;                    << 1538       if (attName=="z") { z = eval.Evaluate(attValue); } else
2787   G4double aunit    = 1.0;                    << 1539       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
2788   G4double rmin     = 0.0;                    << 1540       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
2789   G4double rmax     = 0.0;                    << 1541       if (attName=="lowX") { lowNorm.setX (eval.Evaluate(attValue)); } else
2790   G4double z        = 0.0;                    << 1542       if (attName=="lowY") { lowNorm.setY (eval.Evaluate(attValue)); } else
2791   G4double startphi = 0.0;                    << 1543       if (attName=="lowZ") { lowNorm.setZ (eval.Evaluate(attValue)); } else
2792   G4double deltaphi = 0.0;                    << 1544       if (attName=="highX") { highNorm.setX (eval.Evaluate(attValue)); } else
2793   G4ThreeVector lowNorm(0);                   << 1545       if (attName=="highY") { highNorm.setY (eval.Evaluate(attValue)); } else
2794   G4ThreeVector highNorm(0);                  << 1546       if (attName=="highZ") { highNorm.setZ (eval.Evaluate(attValue)); } 
2795                                               << 1547    
2796   const xercesc::DOMNamedNodeMap* const attri << 1548    }
2797     cuttubeElement->getAttributes();          << 1549 
2798   XMLSize_t attributeCount = attributes->getL << 1550    rmin *= lunit;
2799                                               << 1551    rmax *= lunit;
2800   for(XMLSize_t attribute_index = 0; attribut << 1552    z *= 0.5*lunit;
2801       ++attribute_index)                      << 1553    startphi *= aunit;
2802   {                                           << 1554    deltaphi *= aunit;
2803     xercesc::DOMNode* attribute_node = attrib << 1555 
2804                                               << 1556    new G4CutTubs(name,rmin,rmax,z,startphi,deltaphi,lowNorm,highNorm);
2805     if(attribute_node->getNodeType() != xerce << 1557 }
2806     {                                         << 1558 
2807       continue;                               << 1559 void G4GDMLReadSolids::
2808     }                                         << 1560 TwistedboxRead(const xercesc::DOMElement* const twistedboxElement)
2809                                               << 1561 {
2810     const xercesc::DOMAttr* const attribute = << 1562    G4String name;
2811       dynamic_cast<xercesc::DOMAttr*>(attribu << 1563    G4double lunit = 1.0;
2812     if(attribute == nullptr)                  << 1564    G4double aunit = 1.0;
2813     {                                         << 1565    G4double PhiTwist = 0.0;
2814       G4Exception("G4GDMLReadSolids::CutTubeR << 1566    G4double x = 0.0;
2815                   FatalException, "No attribu << 1567    G4double y = 0.0;
2816       return;                                 << 1568    G4double z = 0.0;
2817     }                                         << 1569 
2818     const G4String attName  = Transcode(attri << 1570    const xercesc::DOMNamedNodeMap* const attributes
2819     const G4String attValue = Transcode(attri << 1571          = twistedboxElement->getAttributes();
2820                                               << 1572    XMLSize_t attributeCount = attributes->getLength();
2821     if(attName == "name")                     << 1573 
2822     {                                         << 1574    for (XMLSize_t attribute_index=0;
2823       name = GenerateName(attValue);          << 1575         attribute_index<attributeCount; attribute_index++)
2824     }                                         << 1576    {
2825     else if(attName == "lunit")               << 1577       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2826     {                                         << 1578 
2827       lunit = G4UnitDefinition::GetValueOf(at << 1579       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2828       if(G4UnitDefinition::GetCategory(attVal << 1580         { continue; }
2829       {                                       << 1581 
2830         G4Exception("G4GDMLReadSolids::CutTub << 1582       const xercesc::DOMAttr* const attribute
2831                     FatalException, "Invalid  << 1583             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2832       }                                       << 1584       if (!attribute)
2833     }                                         << 1585       {
2834     else if(attName == "aunit")               << 1586         G4Exception("G4GDMLReadSolids::TwistedboxRead()",
2835     {                                         << 1587                     "InvalidRead", FatalException, "No attribute found!");
2836       aunit = G4UnitDefinition::GetValueOf(at << 1588         return;
2837       if(G4UnitDefinition::GetCategory(attVal << 1589       }
2838       {                                       << 1590       const G4String attName = Transcode(attribute->getName());
2839         G4Exception("G4GDMLReadSolids::CutTub << 1591       const G4String attValue = Transcode(attribute->getValue());
2840                     FatalException, "Invalid  << 1592 
2841       }                                       << 1593       if (attName=="name") { name = GenerateName(attValue); } else
2842     }                                         << 1594       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2843     else if(attName == "rmin")                << 1595       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2844     {                                         << 1596       if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else
2845       rmin = eval.Evaluate(attValue);         << 1597       if (attName=="x") { x = eval.Evaluate(attValue); } else
2846     }                                         << 1598       if (attName=="y") { y = eval.Evaluate(attValue); } else
2847     else if(attName == "rmax")                << 1599       if (attName=="z") { z = eval.Evaluate(attValue); }
2848     {                                         << 1600    }
2849       rmax = eval.Evaluate(attValue);         << 1601 
2850     }                                         << 1602    PhiTwist *= aunit;
2851     else if(attName == "z")                   << 1603    x *= 0.5*lunit;
2852     {                                         << 1604    y *= 0.5*lunit;
2853       z = eval.Evaluate(attValue);            << 1605    z *= 0.5*lunit;
2854     }                                         << 1606 
2855     else if(attName == "startphi")            << 1607    new G4TwistedBox(name,PhiTwist,x,y,z);
2856     {                                         << 1608 }
2857       startphi = eval.Evaluate(attValue);     << 1609 
2858     }                                         << 1610 void G4GDMLReadSolids::
2859     else if(attName == "deltaphi")            << 1611 TwistedtrapRead(const xercesc::DOMElement* const twistedtrapElement)
2860     {                                         << 1612 {
2861       deltaphi = eval.Evaluate(attValue);     << 1613    G4String name;
2862     }                                         << 1614    G4double lunit = 1.0;
2863     else if(attName == "lowX")                << 1615    G4double aunit = 1.0;
2864     {                                         << 1616    G4double PhiTwist = 0.0;
2865       lowNorm.setX(eval.Evaluate(attValue));  << 1617    G4double z = 0.0;
2866     }                                         << 1618    G4double Theta = 0.0;
2867     else if(attName == "lowY")                << 1619    G4double Phi = 0.0;
2868     {                                         << 1620    G4double y1 = 0.0;
2869       lowNorm.setY(eval.Evaluate(attValue));  << 1621    G4double x1 = 0.0;
2870     }                                         << 1622    G4double x2 = 0.0;
2871     else if(attName == "lowZ")                << 1623    G4double y2 = 0.0;
2872     {                                         << 1624    G4double x3 = 0.0;
2873       lowNorm.setZ(eval.Evaluate(attValue));  << 1625    G4double x4 = 0.0;
2874     }                                         << 1626    G4double Alph = 0.0;
2875     else if(attName == "highX")               << 1627 
2876     {                                         << 1628    const xercesc::DOMNamedNodeMap* const attributes
2877       highNorm.setX(eval.Evaluate(attValue)); << 1629          = twistedtrapElement->getAttributes();
2878     }                                         << 1630    XMLSize_t attributeCount = attributes->getLength();
2879     else if(attName == "highY")               << 1631 
2880     {                                         << 1632    for (XMLSize_t attribute_index=0;
2881       highNorm.setY(eval.Evaluate(attValue)); << 1633         attribute_index<attributeCount; attribute_index++)
2882     }                                         << 1634    {
2883     else if(attName == "highZ")               << 1635       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2884     {                                         << 1636 
2885       highNorm.setZ(eval.Evaluate(attValue)); << 1637       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2886     }                                         << 1638         { continue; }
2887   }                                           << 1639 
2888                                               << 1640       const xercesc::DOMAttr* const attribute
2889   rmin *= lunit;                              << 1641             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2890   rmax *= lunit;                              << 1642       if (!attribute)
2891   z *= 0.5 * lunit;                           << 1643       {
2892   startphi *= aunit;                          << 1644         G4Exception("G4GDMLReadSolids::TwistedtrapRead()",
2893   deltaphi *= aunit;                          << 1645                     "InvalidRead", FatalException, "No attribute found!");
2894                                               << 1646         return;
2895   new G4CutTubs(name, rmin, rmax, z, startphi << 1647       }
2896 }                                             << 1648       const G4String attName = Transcode(attribute->getName());
2897                                               << 1649       const G4String attValue = Transcode(attribute->getValue());
2898 // ------------------------------------------ << 1650 
2899 void G4GDMLReadSolids::TwistedboxRead(        << 1651       if (attName=="name") { name = GenerateName(attValue); } else
2900   const xercesc::DOMElement* const twistedbox << 1652       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2901 {                                             << 1653       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2902   G4String name;                              << 1654       if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else
2903   G4double lunit    = 1.0;                    << 1655       if (attName=="z") { z = eval.Evaluate(attValue); } else
2904   G4double aunit    = 1.0;                    << 1656       if (attName=="Theta") { Theta = eval.Evaluate(attValue); } else
2905   G4double PhiTwist = 0.0;                    << 1657       if (attName=="Phi") { Phi = eval.Evaluate(attValue); } else
2906   G4double x        = 0.0;                    << 1658       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2907   G4double y        = 0.0;                    << 1659       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2908   G4double z        = 0.0;                    << 1660       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2909                                               << 1661       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2910   const xercesc::DOMNamedNodeMap* const attri << 1662       if (attName=="x3") { x3 = eval.Evaluate(attValue); } else
2911     twistedboxElement->getAttributes();       << 1663       if (attName=="x4") { x4 = eval.Evaluate(attValue); } else
2912   XMLSize_t attributeCount = attributes->getL << 1664       if (attName=="Alph") { Alph = eval.Evaluate(attValue); }
2913                                               << 1665    }
2914   for(XMLSize_t attribute_index = 0; attribut << 1666 
2915       ++attribute_index)                      << 1667 
2916   {                                           << 1668    PhiTwist *= aunit;
2917     xercesc::DOMNode* attribute_node = attrib << 1669    z *= 0.5*lunit;
2918                                               << 1670    Theta *= aunit;
2919     if(attribute_node->getNodeType() != xerce << 1671    Phi *= aunit;
2920     {                                         << 1672    Alph *= aunit;
2921       continue;                               << 1673    y1 *= 0.5*lunit;
2922     }                                         << 1674    x1 *= 0.5*lunit;
2923                                               << 1675    x2 *= 0.5*lunit;
2924     const xercesc::DOMAttr* const attribute = << 1676    y2 *= 0.5*lunit;
2925       dynamic_cast<xercesc::DOMAttr*>(attribu << 1677    x3 *= 0.5*lunit;
2926     if(attribute == nullptr)                  << 1678    x4 *= 0.5*lunit;
2927     {                                         << 1679 
2928       G4Exception("G4GDMLReadSolids::Twistedb << 1680    new G4TwistedTrap(name,PhiTwist,z,Theta,Phi,y1,x1,x2,y2,x3,x4,Alph);
2929                   FatalException, "No attribu << 1681 }
2930       return;                                 << 1682 
2931     }                                         << 1683 void G4GDMLReadSolids::
2932     const G4String attName  = Transcode(attri << 1684 TwistedtrdRead(const xercesc::DOMElement* const twistedtrdElement)
2933     const G4String attValue = Transcode(attri << 1685 {
2934                                               << 1686    G4String name;
2935     if(attName == "name")                     << 1687    G4double lunit = 1.0;
2936     {                                         << 1688    G4double aunit = 1.0;
2937       name = GenerateName(attValue);          << 1689    G4double x1 = 0.0;
2938     }                                         << 1690    G4double x2 = 0.0;
2939     else if(attName == "lunit")               << 1691    G4double y1 = 0.0;
2940     {                                         << 1692    G4double y2 = 0.0;
2941       lunit = G4UnitDefinition::GetValueOf(at << 1693    G4double z = 0.0;
2942       if(G4UnitDefinition::GetCategory(attVal << 1694    G4double PhiTwist = 0.0;
2943       {                                       << 1695 
2944         G4Exception("G4GDMLReadSolids::Twiste << 1696    const xercesc::DOMNamedNodeMap* const attributes
2945                     FatalException, "Invalid  << 1697          = twistedtrdElement->getAttributes();
2946       }                                       << 1698    XMLSize_t attributeCount = attributes->getLength();
2947     }                                         << 1699 
2948     else if(attName == "aunit")               << 1700    for (XMLSize_t attribute_index=0;
2949     {                                         << 1701         attribute_index<attributeCount; attribute_index++)
2950       aunit = G4UnitDefinition::GetValueOf(at << 1702    {
2951       if(G4UnitDefinition::GetCategory(attVal << 1703       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2952       {                                       << 1704 
2953         G4Exception("G4GDMLReadSolids::Twiste << 1705       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2954                     FatalException, "Invalid  << 1706         { continue; }
2955       }                                       << 1707 
2956     }                                         << 1708       const xercesc::DOMAttr* const attribute
2957     else if(attName == "PhiTwist")            << 1709             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2958     {                                         << 1710       if (!attribute)
2959       PhiTwist = eval.Evaluate(attValue);     << 1711       {
2960     }                                         << 1712         G4Exception("G4GDMLReadSolids::TwistedtrdRead()",
2961     else if(attName == "x")                   << 1713                     "InvalidRead", FatalException, "No attribute found!");
2962     {                                         << 1714         return;
2963       x = eval.Evaluate(attValue);            << 1715       }
2964     }                                         << 1716       const G4String attName = Transcode(attribute->getName());
2965     else if(attName == "y")                   << 1717       const G4String attValue = Transcode(attribute->getValue());
2966     {                                         << 1718 
2967       y = eval.Evaluate(attValue);            << 1719       if (attName=="name") { name = GenerateName(attValue); } else
2968     }                                         << 1720       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2969     else if(attName == "z")                   << 1721       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2970     {                                         << 1722       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2971       z = eval.Evaluate(attValue);            << 1723       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2972     }                                         << 1724       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2973   }                                           << 1725       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2974                                               << 1726       if (attName=="z") { z = eval.Evaluate(attValue); } else
2975   PhiTwist *= aunit;                          << 1727       if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); }
2976   x *= 0.5 * lunit;                           << 1728    }
2977   y *= 0.5 * lunit;                           << 1729 
2978   z *= 0.5 * lunit;                           << 1730    x1 *= 0.5*lunit;
2979                                               << 1731    x2 *= 0.5*lunit;
2980   new G4TwistedBox(name, PhiTwist, x, y, z);  << 1732    y1 *= 0.5*lunit;
2981 }                                             << 1733    y2 *= 0.5*lunit;
2982                                               << 1734    z *= 0.5*lunit;
2983 // ------------------------------------------ << 1735    PhiTwist *= aunit;
2984 void G4GDMLReadSolids::TwistedtrapRead(       << 1736 
2985   const xercesc::DOMElement* const twistedtra << 1737    new G4TwistedTrd(name,x1,x2,y1,y2,z,PhiTwist);
2986 {                                             << 1738 }
2987   G4String name;                              << 1739 
2988   G4double lunit    = 1.0;                    << 1740 void G4GDMLReadSolids::
2989   G4double aunit    = 1.0;                    << 1741 TwistedtubsRead(const xercesc::DOMElement* const twistedtubsElement)
2990   G4double PhiTwist = 0.0;                    << 1742 {
2991   G4double z        = 0.0;                    << 1743    G4String name;
2992   G4double Theta    = 0.0;                    << 1744    G4double lunit = 1.0;
2993   G4double Phi      = 0.0;                    << 1745    G4double aunit = 1.0;
2994   G4double y1       = 0.0;                    << 1746    G4double twistedangle = 0.0;
2995   G4double x1       = 0.0;                    << 1747    G4double endinnerrad = 0.0;
2996   G4double x2       = 0.0;                    << 1748    G4double endouterrad = 0.0;
2997   G4double y2       = 0.0;                    << 1749    G4double zlen = 0.0;
2998   G4double x3       = 0.0;                    << 1750    G4double phi = 0.0;
2999   G4double x4       = 0.0;                    << 1751 
3000   G4double Alph     = 0.0;                    << 1752    const xercesc::DOMNamedNodeMap* const attributes
3001                                               << 1753          = twistedtubsElement->getAttributes();
3002   const xercesc::DOMNamedNodeMap* const attri << 1754    XMLSize_t attributeCount = attributes->getLength();
3003     twistedtrapElement->getAttributes();      << 1755 
3004   XMLSize_t attributeCount = attributes->getL << 1756    for (XMLSize_t attribute_index=0;
3005                                               << 1757         attribute_index<attributeCount; attribute_index++)
3006   for(XMLSize_t attribute_index = 0; attribut << 1758    {
3007       ++attribute_index)                      << 1759       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3008   {                                           << 1760 
3009     xercesc::DOMNode* attribute_node = attrib << 1761       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3010                                               << 1762         { continue; }
3011     if(attribute_node->getNodeType() != xerce << 1763 
3012     {                                         << 1764       const xercesc::DOMAttr* const attribute
3013       continue;                               << 1765             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
3014     }                                         << 1766       if (!attribute)
3015                                               << 1767       {
3016     const xercesc::DOMAttr* const attribute = << 1768         G4Exception("G4GDMLReadSolids::TwistedtubsRead()",
3017       dynamic_cast<xercesc::DOMAttr*>(attribu << 1769                     "InvalidRead", FatalException, "No attribute found!");
3018     if(attribute == nullptr)                  << 1770         return;
3019     {                                         << 1771       }
3020       G4Exception("G4GDMLReadSolids::Twistedt << 1772       const G4String attName = Transcode(attribute->getName());
3021                   FatalException, "No attribu << 1773       const G4String attValue = Transcode(attribute->getValue());
3022       return;                                 << 1774 
3023     }                                         << 1775       if (attName=="name") { name = GenerateName(attValue); } else
3024     const G4String attName  = Transcode(attri << 1776       if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
3025     const G4String attValue = Transcode(attri << 1777       if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
3026                                               << 1778       if (attName=="twistedangle") { twistedangle=eval.Evaluate(attValue); } else
3027     if(attName == "name")                     << 1779       if (attName=="endinnerrad")  { endinnerrad=eval.Evaluate(attValue);  } else
3028     {                                         << 1780       if (attName=="endouterrad")  { endouterrad=eval.Evaluate(attValue);  } else
3029       name = GenerateName(attValue);          << 1781       if (attName=="zlen") { zlen = eval.Evaluate(attValue); } else
3030     }                                         << 1782       if (attName=="phi") { phi = eval.Evaluate(attValue); }
3031     else if(attName == "lunit")               << 1783    }
3032     {                                         << 1784 
3033       lunit = G4UnitDefinition::GetValueOf(at << 1785    twistedangle *= aunit;
3034       if(G4UnitDefinition::GetCategory(attVal << 1786    endinnerrad *= lunit;
3035       {                                       << 1787    endouterrad *= lunit;
3036         G4Exception("G4GDMLReadSolids::Twiste << 1788    zlen *= 0.5*lunit;
3037                     FatalException, "Invalid  << 1789    phi *= aunit;
3038       }                                       << 1790 
3039     }                                         << 1791    new G4TwistedTubs(name,twistedangle,endinnerrad,endouterrad,zlen,phi);
3040     else if(attName == "aunit")               << 1792 }
3041     {                                         << 1793 
3042       aunit = G4UnitDefinition::GetValueOf(at << 1794 G4TwoVector G4GDMLReadSolids::
3043       if(G4UnitDefinition::GetCategory(attVal << 1795 TwoDimVertexRead(const xercesc::DOMElement* const element, G4double lunit)
3044       {                                       << 1796 {
3045         G4Exception("G4GDMLReadSolids::Twiste << 1797    G4TwoVector vec;
3046                     FatalException, "Invalid  << 1798    
3047       }                                       << 1799    const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
3048     }                                         << 1800    XMLSize_t attributeCount = attributes->getLength();
3049     else if(attName == "PhiTwist")            << 1801 
3050     {                                         << 1802    for (XMLSize_t attribute_index=0;
3051       PhiTwist = eval.Evaluate(attValue);     << 1803         attribute_index<attributeCount; attribute_index++)
3052     }                                         << 1804    {
3053     else if(attName == "z")                   << 1805       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3054     {                                         << 1806 
3055       z = eval.Evaluate(attValue);            << 1807       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3056     }                                         << 1808         { continue; }
3057     else if(attName == "Theta")               << 1809 
3058     {                                         << 1810       const xercesc::DOMAttr* const attribute
3059       Theta = eval.Evaluate(attValue);        << 1811             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
3060     }                                         << 1812       if (!attribute)
3061     else if(attName == "Phi")                 << 1813       {
3062     {                                         << 1814         G4Exception("G4GDMLReadSolids::TwoDimVertexRead()",
3063       Phi = eval.Evaluate(attValue);          << 1815                     "InvalidRead", FatalException, "No attribute found!");
3064     }                                         << 1816         return vec;
3065     else if(attName == "y1")                  << 1817       }
3066     {                                         << 1818       const G4String attName = Transcode(attribute->getName());
3067       y1 = eval.Evaluate(attValue);           << 1819       const G4String attValue = Transcode(attribute->getValue());
3068     }                                         << 1820 
3069     else if(attName == "x1")                  << 1821       if (attName=="x") { vec.setX(eval.Evaluate(attValue)*lunit); } else
3070     {                                         << 1822       if (attName=="y") { vec.setY(eval.Evaluate(attValue)*lunit); }
3071       x1 = eval.Evaluate(attValue);           << 1823    }
3072     }                                         << 1824 
3073     else if(attName == "x2")                  << 1825    return vec;
3074     {                                         << 1826 }
3075       x2 = eval.Evaluate(attValue);           << 1827 
3076     }                                         << 1828 G4GDMLReadSolids::zplaneType G4GDMLReadSolids::
3077     else if(attName == "y2")                  << 1829 ZplaneRead(const xercesc::DOMElement* const zplaneElement)
3078     {                                         << 1830 {
3079       y2 = eval.Evaluate(attValue);           << 1831    zplaneType zplane = {0.,0.,0.};
3080     }                                         << 1832 
3081     else if(attName == "x3")                  << 1833    const xercesc::DOMNamedNodeMap* const attributes
3082     {                                         << 1834          = zplaneElement->getAttributes();
3083       x3 = eval.Evaluate(attValue);           << 1835    XMLSize_t attributeCount = attributes->getLength();
3084     }                                         << 1836 
3085     else if(attName == "x4")                  << 1837    for (XMLSize_t attribute_index=0;
3086     {                                         << 1838         attribute_index<attributeCount; attribute_index++)
3087       x4 = eval.Evaluate(attValue);           << 1839    {
3088     }                                         << 1840       xercesc::DOMNode* node = attributes->item(attribute_index);
3089     else if(attName == "Alph")                << 1841 
3090     {                                         << 1842       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
3091       Alph = eval.Evaluate(attValue);         << 1843 
3092     }                                         << 1844       const xercesc::DOMAttr* const attribute
3093   }                                           << 1845             = dynamic_cast<xercesc::DOMAttr*>(node);   
3094                                               << 1846       if (!attribute)
3095   PhiTwist *= aunit;                          << 1847       {
3096   z *= 0.5 * lunit;                           << 1848         G4Exception("G4GDMLReadSolids::ZplaneRead()",
3097   Theta *= aunit;                             << 1849                     "InvalidRead", FatalException, "No attribute found!");
3098   Phi *= aunit;                               << 1850         return zplane;
3099   Alph *= aunit;                              << 1851       }
3100   y1 *= 0.5 * lunit;                          << 1852       const G4String attName = Transcode(attribute->getName());
3101   x1 *= 0.5 * lunit;                          << 1853       const G4String attValue = Transcode(attribute->getValue());
3102   x2 *= 0.5 * lunit;                          << 1854 
3103   y2 *= 0.5 * lunit;                          << 1855       if (attName=="rmin") { zplane.rmin = eval.Evaluate(attValue); } else
3104   x3 *= 0.5 * lunit;                          << 1856       if (attName=="rmax") { zplane.rmax = eval.Evaluate(attValue); } else
3105   x4 *= 0.5 * lunit;                          << 1857       if (attName=="z") { zplane.z = eval.Evaluate(attValue); }
3106                                               << 1858    }
3107   new G4TwistedTrap(name, PhiTwist, z, Theta, << 1859 
3108                     Alph);                    << 1860    return zplane;
3109 }                                             << 1861 }
3110                                               << 1862 
3111 // ------------------------------------------ << 1863 void G4GDMLReadSolids::
3112 void G4GDMLReadSolids::TwistedtrdRead(        << 1864 OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
3113   const xercesc::DOMElement* const twistedtrd << 1865 {
3114 {                                             << 1866    G4String name;
3115   G4String name;                              << 1867    G4String smodel;
3116   G4double lunit    = 1.0;                    << 1868    G4String sfinish;
3117   G4double aunit    = 1.0;                    << 1869    G4String stype;
3118   G4double x1       = 0.0;                    << 1870    G4double value = 0.0;
3119   G4double x2       = 0.0;                    << 1871 
3120   G4double y1       = 0.0;                    << 1872    const xercesc::DOMNamedNodeMap* const attributes
3121   G4double y2       = 0.0;                    << 1873          = opticalsurfaceElement->getAttributes();
3122   G4double z        = 0.0;                    << 1874    XMLSize_t attributeCount = attributes->getLength();
3123   G4double PhiTwist = 0.0;                    << 1875 
3124                                               << 1876    for (XMLSize_t attribute_index=0;
3125   const xercesc::DOMNamedNodeMap* const attri << 1877         attribute_index<attributeCount; attribute_index++)
3126     twistedtrdElement->getAttributes();       << 1878    {
3127   XMLSize_t attributeCount = attributes->getL << 1879       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3128                                               << 1880 
3129   for(XMLSize_t attribute_index = 0; attribut << 1881       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3130       ++attribute_index)                      << 1882         { continue; }
3131   {                                           << 1883 
3132     xercesc::DOMNode* attribute_node = attrib << 1884       const xercesc::DOMAttr* const attribute
3133                                               << 1885             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
3134     if(attribute_node->getNodeType() != xerce << 1886       if (!attribute)
3135     {                                         << 1887       {
3136       continue;                               << 1888         G4Exception("G4GDMLReadSolids::OpticalSurfaceRead()",
3137     }                                         << 1889                     "InvalidRead", FatalException, "No attribute found!");
3138                                               << 1890         return;
3139     const xercesc::DOMAttr* const attribute = << 1891       }
3140       dynamic_cast<xercesc::DOMAttr*>(attribu << 1892       const G4String attName = Transcode(attribute->getName());
3141     if(attribute == nullptr)                  << 1893       const G4String attValue = Transcode(attribute->getValue());
3142     {                                         << 1894 
3143       G4Exception("G4GDMLReadSolids::Twistedt << 1895       if (attName=="name") { name = GenerateName(attValue); } else
3144                   FatalException, "No attribu << 1896       if (attName=="model") { smodel = attValue; } else
3145       return;                                 << 1897       if (attName=="finish") { sfinish = attValue; } else
3146     }                                         << 1898       if (attName=="type") { stype = attValue; } else
3147     const G4String attName  = Transcode(attri << 1899       if (attName=="value") { value = eval.Evaluate(attValue); }
3148     const G4String attValue = Transcode(attri << 1900    }
3149                                               << 1901 
3150     if(attName == "name")                     << 1902    G4OpticalSurfaceModel model; 
3151     {                                         << 1903    G4OpticalSurfaceFinish finish;
3152       name = GenerateName(attValue);          << 1904    G4SurfaceType type;   
3153     }                                         << 1905    
3154     else if(attName == "lunit")               << 1906    if ((smodel=="glisur") || (smodel=="0")) { model = glisur; } else
3155     {                                         << 1907    if ((smodel=="unified") || (smodel=="1")) { model = unified; }
3156       lunit = G4UnitDefinition::GetValueOf(at << 1908    else { model = LUT; }
3157       if(G4UnitDefinition::GetCategory(attVal << 1909 
3158       {                                       << 1910    if ((sfinish=="polished") || (sfinish=="0"))
3159         G4Exception("G4GDMLReadSolids::Twiste << 1911       { finish = polished; } else
3160                     FatalException, "Invalid  << 1912    if ((sfinish=="polishedfrontpainted") || (sfinish=="1"))
3161       }                                       << 1913       { finish = polishedfrontpainted; } else
3162     }                                         << 1914    if ((sfinish=="polishedbackpainted") || (sfinish=="2"))
3163     else if(attName == "aunit")               << 1915       { finish = polishedbackpainted; } else
3164     {                                         << 1916    if ((sfinish=="ground") || (sfinish=="3"))
3165       aunit = G4UnitDefinition::GetValueOf(at << 1917       { finish = ground; } else
3166       if(G4UnitDefinition::GetCategory(attVal << 1918    if ((sfinish=="groundfrontpainted") || (sfinish=="4"))
3167       {                                       << 1919       { finish = groundfrontpainted; } else
3168         G4Exception("G4GDMLReadSolids::Twiste << 1920    if ((sfinish=="groundbackpainted") || (sfinish=="5"))
3169                     FatalException, "Invalid  << 1921       { finish = groundbackpainted; } else
3170       }                                       << 1922    if ((sfinish=="polishedlumirrorair") || (sfinish=="6"))
3171     }                                         << 1923       { finish = polishedlumirrorair; } else
3172     else if(attName == "x1")                  << 1924    if ((sfinish=="polishedlumirrorglue") || (sfinish=="7"))
3173     {                                         << 1925       { finish = polishedlumirrorglue; } else
3174       x1 = eval.Evaluate(attValue);           << 1926    if ((sfinish=="polishedair") || (sfinish=="8"))
3175     }                                         << 1927       { finish = polishedair; } else
3176     else if(attName == "x2")                  << 1928    if ((sfinish=="polishedteflonair") || (sfinish=="9"))
3177     {                                         << 1929       { finish = polishedteflonair; } else
3178       x2 = eval.Evaluate(attValue);           << 1930    if ((sfinish=="polishedtioair") || (sfinish=="10"))
3179     }                                         << 1931       { finish = polishedtioair; } else
3180     else if(attName == "y1")                  << 1932    if ((sfinish=="polishedtyvekair") || (sfinish=="11"))
3181     {                                         << 1933       { finish = polishedtyvekair; } else
3182       y1 = eval.Evaluate(attValue);           << 1934    if ((sfinish=="polishedvm2000air") || (sfinish=="12"))
3183     }                                         << 1935       { finish = polishedvm2000air; } else
3184     else if(attName == "y2")                  << 1936    if ((sfinish=="polishedvm2000glue") || (sfinish=="13"))
3185     {                                         << 1937       { finish = polishedvm2000glue; } else
3186       y2 = eval.Evaluate(attValue);           << 1938    if ((sfinish=="etchedlumirrorair") || (sfinish=="14"))
3187     }                                         << 1939       { finish = etchedlumirrorair; } else
3188     else if(attName == "z")                   << 1940    if ((sfinish=="etchedlumirrorglue") || (sfinish=="15"))
3189     {                                         << 1941       { finish = etchedlumirrorglue; } else
3190       z = eval.Evaluate(attValue);            << 1942    if ((sfinish=="etchedair") || (sfinish=="16"))
3191     }                                         << 1943       { finish = etchedair; } else
3192     else if(attName == "PhiTwist")            << 1944    if ((sfinish=="etchedteflonair") || (sfinish=="17"))
3193     {                                         << 1945       { finish = etchedteflonair; } else
3194       PhiTwist = eval.Evaluate(attValue);     << 1946    if ((sfinish=="etchedtioair") || (sfinish=="18"))
3195     }                                         << 1947       { finish = etchedtioair; } else
3196   }                                           << 1948    if ((sfinish=="etchedtyvekair") || (sfinish=="19"))
3197                                               << 1949       { finish = etchedtyvekair; } else
3198   x1 *= 0.5 * lunit;                          << 1950    if ((sfinish=="etchedvm2000air") || (sfinish=="20"))
3199   x2 *= 0.5 * lunit;                          << 1951       { finish = etchedvm2000air; } else
3200   y1 *= 0.5 * lunit;                          << 1952    if ((sfinish=="etchedvm2000glue") || (sfinish=="21"))
3201   y2 *= 0.5 * lunit;                          << 1953       { finish = etchedvm2000glue; } else
3202   z *= 0.5 * lunit;                           << 1954    if ((sfinish=="groundlumirrorair") || (sfinish=="22"))
3203   PhiTwist *= aunit;                          << 1955       { finish = groundlumirrorair; } else
3204                                               << 1956    if ((sfinish=="groundlumirrorglue") || (sfinish=="23"))
3205   new G4TwistedTrd(name, x1, x2, y1, y2, z, P << 1957       { finish = groundlumirrorglue; } else
3206 }                                             << 1958    if ((sfinish=="groundair") || (sfinish=="24"))
3207                                               << 1959       { finish = groundair; } else
3208 // ------------------------------------------ << 1960    if ((sfinish=="groundteflonair") || (sfinish=="25"))
3209 void G4GDMLReadSolids::TwistedtubsRead(       << 1961       { finish = groundteflonair; } else
3210   const xercesc::DOMElement* const twistedtub << 1962    if ((sfinish=="groundtioair") || (sfinish=="26"))
3211 {                                             << 1963       { finish = groundtioair; } else
3212   G4String name;                              << 1964    if ((sfinish=="groundtyvekair") || (sfinish=="27"))
3213   G4double lunit        = 1.0;                << 1965       { finish = groundtyvekair; } else
3214   G4double aunit        = 1.0;                << 1966    if ((sfinish=="groundvm2000air") || (sfinish=="28"))
3215   G4double twistedangle = 0.0;                << 1967       { finish = groundvm2000air; }
3216   G4double endinnerrad  = 0.0;                << 1968    else { finish = groundvm2000glue; }
3217   G4double endouterrad  = 0.0;                << 1969 
3218   G4double zlen         = 0.0;                << 1970    if ((stype=="dielectric_metal") || (stype=="0"))
3219   G4double phi          = 0.0;                << 1971       { type = dielectric_metal; } else
3220   G4double totphi       = 0.0;                << 1972    if ((stype=="dielectric_dielectric") || (stype=="1"))
3221   G4double midinnerrad  = 0.0;                << 1973       { type = dielectric_dielectric; } else
3222   G4double midouterrad  = 0.0;                << 1974    if ((stype=="dielectric_LUT") || (stype=="2"))
3223   G4double positiveEndz = 0.0;                << 1975       { type = dielectric_LUT; } else
3224   G4double negativeEndz = 0.0;                << 1976    if ((stype=="firsov") || (stype=="3"))
3225   G4int nseg            = 0;                  << 1977       { type = firsov; }
3226                                               << 1978    else { type = x_ray; }
3227   const xercesc::DOMNamedNodeMap* const attri << 1979 
3228     twistedtubsElement->getAttributes();      << 1980    new G4OpticalSurface(name,model,finish,type,value);
3229   XMLSize_t attributeCount = attributes->getL << 1981 }
3230                                               << 1982 
3231   for(XMLSize_t attribute_index = 0; attribut << 1983 void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement)
3232       ++attribute_index)                      << 1984 {
3233   {                                           << 1985    G4cout << "G4GDML: Reading solids..." << G4endl;
3234     xercesc::DOMNode* attribute_node = attrib << 1986 
3235                                               << 1987    for (xercesc::DOMNode* iter = solidsElement->getFirstChild();
3236     if(attribute_node->getNodeType() != xerce << 1988         iter != 0; iter = iter->getNextSibling())
3237     {                                         << 1989    {
3238       continue;                               << 1990       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
3239     }                                         << 1991 
3240                                               << 1992       const xercesc::DOMElement* const child
3241     const xercesc::DOMAttr* const attribute = << 1993             = dynamic_cast<xercesc::DOMElement*>(iter);
3242       dynamic_cast<xercesc::DOMAttr*>(attribu << 1994       if (!child)
3243     if(attribute == nullptr)                  << 1995       {
3244     {                                         << 1996         G4Exception("G4GDMLReadSolids::SolidsRead()",
3245       G4Exception("G4GDMLReadSolids::Twistedt << 1997                     "InvalidRead", FatalException, "No child found!");
3246                   FatalException, "No attribu << 1998         return;
3247       return;                                 << 1999       }
3248     }                                         << 2000       const G4String tag = Transcode(child->getTagName());
3249     const G4String attName  = Transcode(attri << 2001       if (tag=="define") { DefineRead(child);  }  else 
3250     const G4String attValue = Transcode(attri << 2002       if (tag=="box")    { BoxRead(child); } else
3251                                               << 2003       if (tag=="cone")   { ConeRead(child); } else
3252     if(attName == "name")                     << 2004       if (tag=="elcone") { ElconeRead(child); } else
3253     {                                         << 2005       if (tag=="ellipsoid") { EllipsoidRead(child); }else
3254       name = GenerateName(attValue);          << 2006       if (tag=="eltube") { EltubeRead(child); } else
3255     }                                         << 2007       if (tag=="xtru") { XtruRead(child); } else
3256     else if(attName == "lunit")               << 2008       if (tag=="hype") { HypeRead(child); } else
3257     {                                         << 2009       if (tag=="intersection") { BooleanRead(child,INTERSECTION); } else
3258       lunit = G4UnitDefinition::GetValueOf(at << 2010       if (tag=="orb") { OrbRead(child); } else
3259       if(G4UnitDefinition::GetCategory(attVal << 2011       if (tag=="para") { ParaRead(child); } else
3260       {                                       << 2012       if (tag=="paraboloid") { ParaboloidRead(child); } else
3261         G4Exception("G4GDMLReadSolids::Twiste << 2013       if (tag=="polycone") { PolyconeRead(child); } else
3262                     FatalException, "Invalid  << 2014       if (tag=="polyhedra") { PolyhedraRead(child); } else
3263       }                                       << 2015       if (tag=="reflectedSolid") { ReflectedSolidRead(child); } else
3264     }                                         << 2016       if (tag=="sphere") { SphereRead(child); } else
3265     else if(attName == "aunit")               << 2017       if (tag=="subtraction") { BooleanRead(child,SUBTRACTION); } else
3266     {                                         << 2018       if (tag=="tessellated") { TessellatedRead(child); } else
3267       aunit = G4UnitDefinition::GetValueOf(at << 2019       if (tag=="tet") { TetRead(child); } else
3268       if(G4UnitDefinition::GetCategory(attVal << 2020       if (tag=="torus") { TorusRead(child); } else
3269       {                                       << 2021       if (tag=="arb8") { GenTrapRead(child); } else
3270         G4Exception("G4GDMLReadSolids::Twiste << 2022       if (tag=="trap") { TrapRead(child); } else
3271                     FatalException, "Invalid  << 2023       if (tag=="trd") { TrdRead(child); } else
3272       }                                       << 2024       if (tag=="tube") { TubeRead(child); } else
3273     }                                         << 2025       if (tag=="cutTube") { CutTubeRead(child); } else
3274     else if(attName == "twistedangle")        << 2026       if (tag=="twistedbox") { TwistedboxRead(child); } else
3275     {                                         << 2027       if (tag=="twistedtrap") { TwistedtrapRead(child); } else
3276       twistedangle = eval.Evaluate(attValue); << 2028       if (tag=="twistedtrd") { TwistedtrdRead(child); } else
3277     }                                         << 2029       if (tag=="twistedtubs") { TwistedtubsRead(child); } else
3278     else if(attName == "endinnerrad")         << 2030       if (tag=="union") { BooleanRead(child,UNION); } else
3279     {                                         << 2031       if (tag=="opticalsurface") { OpticalSurfaceRead(child); } else
3280       endinnerrad = eval.Evaluate(attValue);  << 2032       if (tag=="loop") { LoopRead(child,&G4GDMLRead::SolidsRead); }
3281     }                                         << 2033       else
3282     else if(attName == "endouterrad")         << 2034       {
3283     {                                         << 2035         G4String error_msg = "Unknown tag in solids: " + tag;
3284       endouterrad = eval.Evaluate(attValue);  << 2036         G4Exception("G4GDMLReadSolids::SolidsRead()", "ReadError",
3285     }                                         << 2037                     FatalException, error_msg);
3286     else if(attName == "zlen")                << 2038       }
3287     {                                         << 2039    }
3288       zlen = eval.Evaluate(attValue);         << 
3289     }                                         << 
3290     else if(attName == "midinnerrad")         << 
3291     {                                         << 
3292       midinnerrad = eval.Evaluate(attValue);  << 
3293     }                                         << 
3294     else if(attName == "midouterrad")         << 
3295     {                                         << 
3296       midouterrad = eval.Evaluate(attValue);  << 
3297     }                                         << 
3298     else if(attName == "negativeEndz")        << 
3299     {                                         << 
3300       negativeEndz = eval.Evaluate(attValue); << 
3301     }                                         << 
3302     else if(attName == "positiveEndz")        << 
3303     {                                         << 
3304       positiveEndz = eval.Evaluate(attValue); << 
3305     }                                         << 
3306     else if(attName == "nseg")                << 
3307     {                                         << 
3308       nseg = eval.Evaluate(attValue);         << 
3309     }                                         << 
3310     else if(attName == "totphi")              << 
3311     {                                         << 
3312       totphi = eval.Evaluate(attValue);       << 
3313     }                                         << 
3314     else if(attName == "phi")                 << 
3315     {                                         << 
3316       phi = eval.Evaluate(attValue);          << 
3317     }                                         << 
3318   }                                           << 
3319                                               << 
3320   twistedangle *= aunit;                      << 
3321   endinnerrad *= lunit;                       << 
3322   endouterrad *= lunit;                       << 
3323   zlen *= 0.5 * lunit;                        << 
3324   midinnerrad *= lunit;                       << 
3325   midouterrad *= lunit;                       << 
3326   positiveEndz *= lunit;                      << 
3327   negativeEndz *= lunit;                      << 
3328   phi *= aunit;                               << 
3329   totphi *= aunit;                            << 
3330                                               << 
3331   if(zlen != 0.0)                             << 
3332   {                                           << 
3333     if(nseg != 0)                             << 
3334       new G4TwistedTubs(name, twistedangle, e << 
3335                         nseg, totphi);        << 
3336     else                                      << 
3337       new G4TwistedTubs(name, twistedangle, e << 
3338                         phi);                 << 
3339   }                                           << 
3340   else                                        << 
3341   {                                           << 
3342     if(nseg != 0)                             << 
3343       new G4TwistedTubs(name, twistedangle, m << 
3344                         negativeEndz, positiv << 
3345     else                                      << 
3346       new G4TwistedTubs(name, twistedangle, m << 
3347                         negativeEndz, positiv << 
3348   }                                           << 
3349 }                                             << 
3350                                               << 
3351 // ------------------------------------------ << 
3352 G4TwoVector G4GDMLReadSolids::TwoDimVertexRea << 
3353   const xercesc::DOMElement* const element, G << 
3354 {                                             << 
3355   G4TwoVector vec;                            << 
3356                                               << 
3357   const xercesc::DOMNamedNodeMap* const attri << 
3358   XMLSize_t attributeCount                    << 
3359                                               << 
3360   for(XMLSize_t attribute_index = 0; attribut << 
3361       ++attribute_index)                      << 
3362   {                                           << 
3363     xercesc::DOMNode* attribute_node = attrib << 
3364                                               << 
3365     if(attribute_node->getNodeType() != xerce << 
3366     {                                         << 
3367       continue;                               << 
3368     }                                         << 
3369                                               << 
3370     const xercesc::DOMAttr* const attribute = << 
3371       dynamic_cast<xercesc::DOMAttr*>(attribu << 
3372     if(attribute == nullptr)                  << 
3373     {                                         << 
3374       G4Exception("G4GDMLReadSolids::TwoDimVe << 
3375                   FatalException, "No attribu << 
3376       return vec;                             << 
3377     }                                         << 
3378     const G4String attName  = Transcode(attri << 
3379     const G4String attValue = Transcode(attri << 
3380                                               << 
3381     if(attName == "x")                        << 
3382     {                                         << 
3383       vec.setX(eval.Evaluate(attValue) * luni << 
3384     }                                         << 
3385     else if(attName == "y")                   << 
3386     {                                         << 
3387       vec.setY(eval.Evaluate(attValue) * luni << 
3388     }                                         << 
3389   }                                           << 
3390                                               << 
3391   return vec;                                 << 
3392 }                                             << 
3393                                               << 
3394 // ------------------------------------------ << 
3395 G4GDMLReadSolids::zplaneType G4GDMLReadSolids << 
3396   const xercesc::DOMElement* const zplaneElem << 
3397 {                                             << 
3398   zplaneType zplane = { 0., 0., 0. };         << 
3399                                               << 
3400   const xercesc::DOMNamedNodeMap* const attri << 
3401     zplaneElement->getAttributes();           << 
3402   XMLSize_t attributeCount = attributes->getL << 
3403                                               << 
3404   for(XMLSize_t attribute_index = 0; attribut << 
3405       ++attribute_index)                      << 
3406   {                                           << 
3407     xercesc::DOMNode* node = attributes->item << 
3408                                               << 
3409     if(node->getNodeType() != xercesc::DOMNod << 
3410     {                                         << 
3411       continue;                               << 
3412     }                                         << 
3413                                               << 
3414     const xercesc::DOMAttr* const attribute = << 
3415       dynamic_cast<xercesc::DOMAttr*>(node);  << 
3416     if(attribute == nullptr)                  << 
3417     {                                         << 
3418       G4Exception("G4GDMLReadSolids::ZplaneRe << 
3419                   FatalException, "No attribu << 
3420       return zplane;                          << 
3421     }                                         << 
3422     const G4String attName  = Transcode(attri << 
3423     const G4String attValue = Transcode(attri << 
3424                                               << 
3425     if(attName == "rmin")                     << 
3426     {                                         << 
3427       zplane.rmin = eval.Evaluate(attValue);  << 
3428     }                                         << 
3429     else if(attName == "rmax")                << 
3430     {                                         << 
3431       zplane.rmax = eval.Evaluate(attValue);  << 
3432     }                                         << 
3433     else if(attName == "z")                   << 
3434     {                                         << 
3435       zplane.z = eval.Evaluate(attValue);     << 
3436     }                                         << 
3437   }                                           << 
3438                                               << 
3439   return zplane;                              << 
3440 }                                                2040 }
3441                                                  2041 
3442 // ------------------------------------------ << 2042 G4VSolid* G4GDMLReadSolids::GetSolid(const G4String& ref) const
3443 G4GDMLReadSolids::rzPointType G4GDMLReadSolid << 
3444   const xercesc::DOMElement* const zplaneElem << 
3445 {                                                2043 {
3446   rzPointType rzpoint = { 0., 0. };           << 2044    G4VSolid* solidPtr = G4SolidStore::GetInstance()->GetSolid(ref,false);
3447                                               << 
3448   const xercesc::DOMNamedNodeMap* const attri << 
3449     zplaneElement->getAttributes();           << 
3450   XMLSize_t attributeCount = attributes->getL << 
3451                                               << 
3452   for(XMLSize_t attribute_index = 0; attribut << 
3453       ++attribute_index)                      << 
3454   {                                           << 
3455     xercesc::DOMNode* node = attributes->item << 
3456                                               << 
3457     if(node->getNodeType() != xercesc::DOMNod << 
3458     {                                         << 
3459       continue;                               << 
3460     }                                         << 
3461                                               << 
3462     const xercesc::DOMAttr* const attribute = << 
3463       dynamic_cast<xercesc::DOMAttr*>(node);  << 
3464     if(attribute == nullptr)                  << 
3465     {                                         << 
3466       G4Exception("G4GDMLReadSolids::RZPointR << 
3467                   FatalException, "No attribu << 
3468       return rzpoint;                         << 
3469     }                                         << 
3470     const G4String attName  = Transcode(attri << 
3471     const G4String attValue = Transcode(attri << 
3472                                               << 
3473     if(attName == "r")                        << 
3474     {                                         << 
3475       rzpoint.r = eval.Evaluate(attValue);    << 
3476     }                                         << 
3477     else if(attName == "z")                   << 
3478     {                                         << 
3479       rzpoint.z = eval.Evaluate(attValue);    << 
3480     }                                         << 
3481   }                                           << 
3482                                               << 
3483   return rzpoint;                             << 
3484 }                                             << 
3485                                                  2045 
3486 // ------------------------------------------ << 2046    if (!solidPtr)
3487 void G4GDMLReadSolids::PropertyRead(          << 2047    {
3488   const xercesc::DOMElement* const propertyEl << 2048      G4String error_msg = "Referenced solid '" + ref + "' was not found!";
3489   G4OpticalSurface* opticalsurface)           << 2049      G4Exception("G4GDMLReadSolids::GetSolid()", "ReadError",
3490 {                                             << 2050                  FatalException, error_msg);
3491   G4String name;                              << 2051    }
3492   G4String ref;                               << 
3493   G4GDMLMatrix matrix;                        << 
3494                                               << 
3495   const xercesc::DOMNamedNodeMap* const attri << 
3496     propertyElement->getAttributes();         << 
3497   XMLSize_t attributeCount = attributes->getL << 
3498                                               << 
3499   for(XMLSize_t attribute_index = 0; attribut << 
3500       ++attribute_index)                      << 
3501   {                                           << 
3502     xercesc::DOMNode* attribute_node = attrib << 
3503                                               << 
3504     if(attribute_node->getNodeType() != xerce << 
3505     {                                         << 
3506       continue;                               << 
3507     }                                         << 
3508                                               << 
3509     const xercesc::DOMAttr* const attribute = << 
3510       dynamic_cast<xercesc::DOMAttr*>(attribu << 
3511     if(attribute == nullptr)                  << 
3512     {                                         << 
3513       G4Exception("G4GDMLReadSolids::Property << 
3514                   FatalException, "No attribu << 
3515       return;                                 << 
3516     }                                         << 
3517     const G4String attName  = Transcode(attri << 
3518     const G4String attValue = Transcode(attri << 
3519                                               << 
3520     if(attName == "name")                     << 
3521     {                                         << 
3522       name = GenerateName(attValue);          << 
3523     }                                         << 
3524     else if(attName == "ref")                 << 
3525     {                                         << 
3526       matrix = GetMatrix(ref = attValue);     << 
3527     }                                         << 
3528   }                                           << 
3529                                               << 
3530   /*                                          << 
3531   if (matrix.GetCols() != 2)                  << 
3532   {                                           << 
3533     G4String error_msg = "Referenced matrix ' << 
3534            + "' should have \n two columns as << 
3535   opticalsurface: "                           << 
3536            + opticalsurface->GetName();       << 
3537     G4Exception("G4GDMLReadSolids::PropertyRe << 
3538                 FatalException, error_msg);   << 
3539   }                                           << 
3540   */                                          << 
3541                                               << 
3542   if(matrix.GetRows() == 0)                   << 
3543   {                                           << 
3544     return;                                   << 
3545   }                                           << 
3546                                               << 
3547   G4MaterialPropertiesTable* matprop =        << 
3548     opticalsurface->GetMaterialPropertiesTabl << 
3549   if(matprop == nullptr)                      << 
3550   {                                           << 
3551     matprop = new G4MaterialPropertiesTable() << 
3552     opticalsurface->SetMaterialPropertiesTabl << 
3553   }                                           << 
3554   if(matrix.GetCols() == 1)  // constant prop << 
3555   {                                           << 
3556     matprop->AddConstProperty(Strip(name), ma << 
3557   }                                           << 
3558   else  // build the material properties vect << 
3559   {                                           << 
3560     G4MaterialPropertyVector* propvect;       << 
3561     G4String temp = name + ref;               << 
3562     // first check if it was already built    << 
3563     if(mapOfMatPropVects.find(temp) == mapOfM << 
3564     {                                         << 
3565       // if not create a new one              << 
3566       propvect = new G4MaterialPropertyVector << 
3567       for(size_t i = 0; i < matrix.GetRows(); << 
3568       {                                       << 
3569         propvect->InsertValues(matrix.Get(i,  << 
3570       }                                       << 
3571       // and add it to the list for potential << 
3572       mapOfMatPropVects[temp] = propvect;     << 
3573     }                                         << 
3574     else                                      << 
3575     {                                         << 
3576       propvect = mapOfMatPropVects[temp];     << 
3577     }                                         << 
3578                                               << 
3579     matprop->AddProperty(Strip(name), propvec << 
3580   }                                           << 
3581 }                                             << 
3582                                               << 
3583 // ------------------------------------------ << 
3584 void G4GDMLReadSolids::OpticalSurfaceRead(    << 
3585   const xercesc::DOMElement* const opticalsur << 
3586 {                                             << 
3587   G4String name;                              << 
3588   G4String smodel;                            << 
3589   G4String sfinish;                           << 
3590   G4String stype;                             << 
3591   G4double value = 0.0;                       << 
3592                                               << 
3593   const xercesc::DOMNamedNodeMap* const attri << 
3594     opticalsurfaceElement->getAttributes();   << 
3595   XMLSize_t attributeCount = attributes->getL << 
3596                                               << 
3597   for(XMLSize_t attribute_index = 0; attribut << 
3598       ++attribute_index)                      << 
3599   {                                           << 
3600     xercesc::DOMNode* attribute_node = attrib << 
3601                                               << 
3602     if(attribute_node->getNodeType() != xerce << 
3603     {                                         << 
3604       continue;                               << 
3605     }                                         << 
3606                                               << 
3607     const xercesc::DOMAttr* const attribute = << 
3608       dynamic_cast<xercesc::DOMAttr*>(attribu << 
3609     if(attribute == nullptr)                  << 
3610     {                                         << 
3611       G4Exception("G4GDMLReadSolids::OpticalS << 
3612                   FatalException, "No attribu << 
3613       return;                                 << 
3614     }                                         << 
3615     const G4String attName  = Transcode(attri << 
3616     const G4String attValue = Transcode(attri << 
3617                                               << 
3618     if(attName == "name")                     << 
3619     {                                         << 
3620       name = GenerateName(attValue);          << 
3621     }                                         << 
3622     else if(attName == "model")               << 
3623     {                                         << 
3624       smodel = attValue;                      << 
3625     }                                         << 
3626     else if(attName == "finish")              << 
3627     {                                         << 
3628       sfinish = attValue;                     << 
3629     }                                         << 
3630     else if(attName == "type")                << 
3631     {                                         << 
3632       stype = attValue;                       << 
3633     }                                         << 
3634     else if(attName == "value")               << 
3635     {                                         << 
3636       value = eval.Evaluate(attValue);        << 
3637     }                                         << 
3638   }                                           << 
3639                                               << 
3640   G4OpticalSurfaceModel model;                << 
3641   G4OpticalSurfaceFinish finish;              << 
3642   G4SurfaceType type;                         << 
3643                                               << 
3644   if((smodel == "glisur") || (smodel == "0")) << 
3645   {                                           << 
3646     model = glisur;                           << 
3647   }                                           << 
3648   else if((smodel == "unified") || (smodel == << 
3649   {                                           << 
3650     model = unified;                          << 
3651   }                                           << 
3652   else if((smodel == "LUT") || (smodel == "2" << 
3653   {                                           << 
3654     model = LUT;                              << 
3655   }                                           << 
3656   else if((smodel == "DAVIS") || (smodel == " << 
3657   {                                           << 
3658     model = DAVIS;                            << 
3659   }                                           << 
3660   else                                        << 
3661   {                                           << 
3662     model = dichroic;                         << 
3663   }                                           << 
3664                                               << 
3665   if((sfinish == "polished") || (sfinish == " << 
3666   {                                           << 
3667     finish = polished;                        << 
3668   }                                           << 
3669   else if((sfinish == "polishedfrontpainted") << 
3670   {                                           << 
3671     finish = polishedfrontpainted;            << 
3672   }                                           << 
3673   else if((sfinish == "polishedbackpainted")  << 
3674   {                                           << 
3675     finish = polishedbackpainted;             << 
3676   }                                           << 
3677   else if((sfinish == "ground") || (sfinish = << 
3678   {                                           << 
3679     finish = ground;                          << 
3680   }                                           << 
3681   else if((sfinish == "groundfrontpainted") | << 
3682   {                                           << 
3683     finish = groundfrontpainted;              << 
3684   }                                           << 
3685   else if((sfinish == "groundbackpainted") || << 
3686   {                                           << 
3687     finish = groundbackpainted;               << 
3688   }                                           << 
3689   else if((sfinish == "polishedlumirrorair")  << 
3690   {                                           << 
3691     finish = polishedlumirrorair;             << 
3692   }                                           << 
3693   else if((sfinish == "polishedlumirrorglue") << 
3694   {                                           << 
3695     finish = polishedlumirrorglue;            << 
3696   }                                           << 
3697   else if((sfinish == "polishedair") || (sfin << 
3698   {                                           << 
3699     finish = polishedair;                     << 
3700   }                                           << 
3701   else if((sfinish == "polishedteflonair") || << 
3702   {                                           << 
3703     finish = polishedteflonair;               << 
3704   }                                           << 
3705   else if((sfinish == "polishedtioair") || (s << 
3706   {                                           << 
3707     finish = polishedtioair;                  << 
3708   }                                           << 
3709   else if((sfinish == "polishedtyvekair") ||  << 
3710   {                                           << 
3711     finish = polishedtyvekair;                << 
3712   }                                           << 
3713   else if((sfinish == "polishedvm2000air") || << 
3714   {                                           << 
3715     finish = polishedvm2000air;               << 
3716   }                                           << 
3717   else if((sfinish == "polishedvm2000glue") | << 
3718   {                                           << 
3719     finish = polishedvm2000glue;              << 
3720   }                                           << 
3721   else if((sfinish == "etchedlumirrorair") || << 
3722   {                                           << 
3723     finish = etchedlumirrorair;               << 
3724   }                                           << 
3725   else if((sfinish == "etchedlumirrorglue") | << 
3726   {                                           << 
3727     finish = etchedlumirrorglue;              << 
3728   }                                           << 
3729   else if((sfinish == "etchedair") || (sfinis << 
3730   {                                           << 
3731     finish = etchedair;                       << 
3732   }                                           << 
3733   else if((sfinish == "etchedteflonair") || ( << 
3734   {                                           << 
3735     finish = etchedteflonair;                 << 
3736   }                                           << 
3737   else if((sfinish == "etchedtioair") || (sfi << 
3738   {                                           << 
3739     finish = etchedtioair;                    << 
3740   }                                           << 
3741   else if((sfinish == "etchedtyvekair") || (s << 
3742   {                                           << 
3743     finish = etchedtyvekair;                  << 
3744   }                                           << 
3745   else if((sfinish == "etchedvm2000air") || ( << 
3746   {                                           << 
3747     finish = etchedvm2000air;                 << 
3748   }                                           << 
3749   else if((sfinish == "etchedvm2000glue") ||  << 
3750   {                                           << 
3751     finish = etchedvm2000glue;                << 
3752   }                                           << 
3753   else if((sfinish == "groundlumirrorair") || << 
3754   {                                           << 
3755     finish = groundlumirrorair;               << 
3756   }                                           << 
3757   else if((sfinish == "groundlumirrorglue") | << 
3758   {                                           << 
3759     finish = groundlumirrorglue;              << 
3760   }                                           << 
3761   else if((sfinish == "groundair") || (sfinis << 
3762   {                                           << 
3763     finish = groundair;                       << 
3764   }                                           << 
3765   else if((sfinish == "groundteflonair") || ( << 
3766   {                                           << 
3767     finish = groundteflonair;                 << 
3768   }                                           << 
3769   else if((sfinish == "groundtioair") || (sfi << 
3770   {                                           << 
3771     finish = groundtioair;                    << 
3772   }                                           << 
3773   else if((sfinish == "groundtyvekair") || (s << 
3774   {                                           << 
3775     finish = groundtyvekair;                  << 
3776   }                                           << 
3777   else if((sfinish == "groundvm2000air") || ( << 
3778   {                                           << 
3779     finish = groundvm2000air;                 << 
3780   }                                           << 
3781   else if((sfinish == "groundvm2000glue") ||  << 
3782   {                                           << 
3783     finish = groundvm2000glue;                << 
3784   }                                           << 
3785   else if((sfinish == "Rough_LUT") || (sfinis << 
3786   {                                           << 
3787     finish = Rough_LUT;                       << 
3788   }                                           << 
3789   else if((sfinish == "RoughTeflon_LUT") || ( << 
3790   {                                           << 
3791     finish = RoughTeflon_LUT;                 << 
3792   }                                           << 
3793   else if((sfinish == "RoughESR_LUT") || (sfi << 
3794   {                                           << 
3795     finish = RoughESR_LUT;                    << 
3796   }                                           << 
3797   else if((sfinish == "RoughESRGrease_LUT") | << 
3798   {                                           << 
3799     finish = RoughESRGrease_LUT;              << 
3800   }                                           << 
3801   else if((sfinish == "Polished_LUT") || (sfi << 
3802   {                                           << 
3803     finish = Polished_LUT;                    << 
3804   }                                           << 
3805   else if((sfinish == "PolishedTeflon_LUT") | << 
3806   {                                           << 
3807     finish = PolishedTeflon_LUT;              << 
3808   }                                           << 
3809   else if((sfinish == "PolishedESR_LUT") || ( << 
3810   {                                           << 
3811     finish = PolishedESR_LUT;                 << 
3812   }                                           << 
3813   else if((sfinish == "PolishedESRGrease_LUT" << 
3814   {                                           << 
3815     finish = PolishedESRGrease_LUT;           << 
3816   }                                           << 
3817   else                                        << 
3818   {                                           << 
3819     finish = Detector_LUT;                    << 
3820   }                                           << 
3821                                               << 
3822   if((stype == "dielectric_metal") || (stype  << 
3823   {                                           << 
3824     type = dielectric_metal;                  << 
3825   }                                           << 
3826   else if((stype == "dielectric_dielectric")  << 
3827   {                                           << 
3828     type = dielectric_dielectric;             << 
3829   }                                           << 
3830   else if((stype == "dielectric_LUT") || (sty << 
3831   {                                           << 
3832     type = dielectric_LUT;                    << 
3833   }                                           << 
3834   else if((stype == "dielectric_LUTDAVIS") || << 
3835   {                                           << 
3836     type = dielectric_LUTDAVIS;               << 
3837   }                                           << 
3838   else if((stype == "dielectric_dichroic") || << 
3839   {                                           << 
3840     type = dielectric_dichroic;               << 
3841   }                                           << 
3842   else if((stype == "firsov") || (stype == "5 << 
3843   {                                           << 
3844     type = firsov;                            << 
3845   }                                           << 
3846   else                                        << 
3847   {                                           << 
3848     type = x_ray;                             << 
3849   }                                           << 
3850                                               << 
3851   G4OpticalSurface* opticalsurface =          << 
3852     new G4OpticalSurface(name, model, finish, << 
3853                                               << 
3854   for(xercesc::DOMNode* iter = opticalsurface << 
3855       iter != nullptr; iter = iter->getNextSi << 
3856   {                                           << 
3857     if(iter->getNodeType() != xercesc::DOMNod << 
3858     {                                         << 
3859       continue;                               << 
3860     }                                         << 
3861                                               << 
3862     const xercesc::DOMElement* const child =  << 
3863       dynamic_cast<xercesc::DOMElement*>(iter << 
3864     if(child == nullptr)                      << 
3865     {                                         << 
3866       G4Exception("G4GDMLReadSolids::OpticalS << 
3867                   FatalException, "No child f << 
3868       return;                                 << 
3869     }                                         << 
3870     const G4String tag = Transcode(child->get << 
3871                                               << 
3872     if(tag == "property")                     << 
3873     {                                         << 
3874       PropertyRead(child, opticalsurface);    << 
3875     }                                         << 
3876   }                                           << 
3877 }                                             << 
3878                                                  2052 
3879 // ------------------------------------------ << 2053    return solidPtr;
3880 void G4GDMLReadSolids::SolidsRead(            << 
3881   const xercesc::DOMElement* const solidsElem << 
3882 {                                             << 
3883 #ifdef G4VERBOSE                              << 
3884   G4cout << "G4GDML: Reading solids..." << G4 << 
3885 #endif                                        << 
3886   for(xercesc::DOMNode* iter = solidsElement- << 
3887       iter                   = iter->getNextS << 
3888   {                                           << 
3889     if(iter->getNodeType() != xercesc::DOMNod << 
3890     {                                         << 
3891       continue;                               << 
3892     }                                         << 
3893                                               << 
3894     const xercesc::DOMElement* const child =  << 
3895       dynamic_cast<xercesc::DOMElement*>(iter << 
3896     if(child == nullptr)                      << 
3897     {                                         << 
3898       G4Exception("G4GDMLReadSolids::SolidsRe << 
3899                   FatalException, "No child f << 
3900       return;                                 << 
3901     }                                         << 
3902     const G4String tag = Transcode(child->get << 
3903     if(tag == "define")                       << 
3904     {                                         << 
3905       DefineRead(child);                      << 
3906     }                                         << 
3907     else if(tag == "box")                     << 
3908     {                                         << 
3909       BoxRead(child);                         << 
3910     }                                         << 
3911     else if(tag == "cone")                    << 
3912     {                                         << 
3913       ConeRead(child);                        << 
3914     }                                         << 
3915     else if(tag == "elcone")                  << 
3916     {                                         << 
3917       ElconeRead(child);                      << 
3918     }                                         << 
3919     else if(tag == "ellipsoid")               << 
3920     {                                         << 
3921       EllipsoidRead(child);                   << 
3922     }                                         << 
3923     else if(tag == "eltube")                  << 
3924     {                                         << 
3925       EltubeRead(child);                      << 
3926     }                                         << 
3927     else if(tag == "xtru")                    << 
3928     {                                         << 
3929       XtruRead(child);                        << 
3930     }                                         << 
3931     else if(tag == "hype")                    << 
3932     {                                         << 
3933       HypeRead(child);                        << 
3934     }                                         << 
3935     else if(tag == "intersection")            << 
3936     {                                         << 
3937       BooleanRead(child, INTERSECTION);       << 
3938     }                                         << 
3939     else if(tag == "multiUnion")              << 
3940     {                                         << 
3941       MultiUnionRead(child);                  << 
3942     }                                         << 
3943     else if(tag == "orb")                     << 
3944     {                                         << 
3945       OrbRead(child);                         << 
3946     }                                         << 
3947     else if(tag == "para")                    << 
3948     {                                         << 
3949       ParaRead(child);                        << 
3950     }                                         << 
3951     else if(tag == "paraboloid")              << 
3952     {                                         << 
3953       ParaboloidRead(child);                  << 
3954     }                                         << 
3955     else if(tag == "polycone")                << 
3956     {                                         << 
3957       PolyconeRead(child);                    << 
3958     }                                         << 
3959     else if(tag == "genericPolycone")         << 
3960     {                                         << 
3961       GenericPolyconeRead(child);             << 
3962     }                                         << 
3963     else if(tag == "polyhedra")               << 
3964     {                                         << 
3965       PolyhedraRead(child);                   << 
3966     }                                         << 
3967     else if(tag == "genericPolyhedra")        << 
3968     {                                         << 
3969       GenericPolyhedraRead(child);            << 
3970     }                                         << 
3971     else if(tag == "reflectedSolid")          << 
3972     {                                         << 
3973       ReflectedSolidRead(child);              << 
3974     }                                         << 
3975     else if(tag == "scaledSolid")             << 
3976     {                                         << 
3977       ScaledSolidRead(child);                 << 
3978     }                                         << 
3979     else if(tag == "sphere")                  << 
3980     {                                         << 
3981       SphereRead(child);                      << 
3982     }                                         << 
3983     else if(tag == "subtraction")             << 
3984     {                                         << 
3985       BooleanRead(child, SUBTRACTION);        << 
3986     }                                         << 
3987     else if(tag == "tessellated")             << 
3988     {                                         << 
3989       TessellatedRead(child);                 << 
3990     }                                         << 
3991     else if(tag == "tet")                     << 
3992     {                                         << 
3993       TetRead(child);                         << 
3994     }                                         << 
3995     else if(tag == "torus")                   << 
3996     {                                         << 
3997       TorusRead(child);                       << 
3998     }                                         << 
3999     else if(tag == "arb8")                    << 
4000     {                                         << 
4001       GenTrapRead(child);                     << 
4002     }                                         << 
4003     else if(tag == "trap")                    << 
4004     {                                         << 
4005       TrapRead(child);                        << 
4006     }                                         << 
4007     else if(tag == "trd")                     << 
4008     {                                         << 
4009       TrdRead(child);                         << 
4010     }                                         << 
4011     else if(tag == "tube")                    << 
4012     {                                         << 
4013       TubeRead(child);                        << 
4014     }                                         << 
4015     else if(tag == "cutTube")                 << 
4016     {                                         << 
4017       CutTubeRead(child);                     << 
4018     }                                         << 
4019     else if(tag == "twistedbox")              << 
4020     {                                         << 
4021       TwistedboxRead(child);                  << 
4022     }                                         << 
4023     else if(tag == "twistedtrap")             << 
4024     {                                         << 
4025       TwistedtrapRead(child);                 << 
4026     }                                         << 
4027     else if(tag == "twistedtrd")              << 
4028     {                                         << 
4029       TwistedtrdRead(child);                  << 
4030     }                                         << 
4031     else if(tag == "twistedtubs")             << 
4032     {                                         << 
4033       TwistedtubsRead(child);                 << 
4034     }                                         << 
4035     else if(tag == "union")                   << 
4036     {                                         << 
4037       BooleanRead(child, UNION);              << 
4038     }                                         << 
4039     else if(tag == "opticalsurface")          << 
4040     {                                         << 
4041       OpticalSurfaceRead(child);              << 
4042     }                                         << 
4043     else if(tag == "loop")                    << 
4044     {                                         << 
4045       LoopRead(child, &G4GDMLRead::SolidsRead << 
4046     }                                         << 
4047     else                                      << 
4048     {                                         << 
4049       G4String error_msg = "Unknown tag in so << 
4050       G4Exception("G4GDMLReadSolids::SolidsRe << 
4051                   error_msg);                 << 
4052     }                                         << 
4053   }                                           << 
4054 }                                                2054 }
4055                                                  2055 
4056 // ------------------------------------------ << 2056 G4SurfaceProperty* G4GDMLReadSolids::
4057 G4VSolid* G4GDMLReadSolids::GetSolid(const G4 << 2057 GetSurfaceProperty(const G4String& ref) const
4058 {                                                2058 {
4059   G4VSolid* solidPtr = G4SolidStore::GetInsta << 2059    const G4SurfacePropertyTable* surfaceList
4060                                     ->GetSoli << 2060          = G4SurfaceProperty::GetSurfacePropertyTable();
4061                                               << 2061    const size_t surfaceCount = surfaceList->size();
4062   if(solidPtr == nullptr)                     << 
4063   {                                           << 
4064     G4String error_msg = "Referenced solid '" << 
4065     G4Exception("G4GDMLReadSolids::GetSolid() << 
4066                 error_msg);                   << 
4067   }                                           << 
4068                                                  2062 
4069   return solidPtr;                            << 2063    for (size_t i=0; i<surfaceCount; i++)
4070 }                                             << 2064    {
                                                   >> 2065       if ((*surfaceList)[i]->GetName() == ref)  { return (*surfaceList)[i]; }
                                                   >> 2066    }
4071                                                  2067 
4072 // ------------------------------------------ << 2068    G4String error_msg = "Referenced optical surface '" + ref + "' was not found!";
4073 G4SurfaceProperty* G4GDMLReadSolids::GetSurfa << 2069    G4Exception("G4GDMLReadSolids::GetSurfaceProperty()", "ReadError",
4074   const G4String& ref) const                  << 2070                FatalException, error_msg);
4075 {                                             << 
4076   const G4SurfacePropertyTable* surfaceList = << 
4077     G4SurfaceProperty::GetSurfacePropertyTabl << 
4078   const std::size_t surfaceCount = surfaceLis << 
4079                                               << 
4080   for(std::size_t i = 0; i < surfaceCount; ++ << 
4081   {                                           << 
4082     if((*surfaceList)[i]->GetName() == ref)   << 
4083     {                                         << 
4084       return (*surfaceList)[i];               << 
4085     }                                         << 
4086   }                                           << 
4087                                               << 
4088   G4String error_msg =                        << 
4089     "Referenced optical surface '" + ref + "' << 
4090   G4Exception("G4GDMLReadSolids::GetSurfacePr << 
4091               FatalException, error_msg);     << 
4092                                                  2071 
4093   return nullptr;                             << 2072    return 0;
4094 }                                                2073 }
4095                                                  2074