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 10.2.p1)


  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 93151 2015-10-08 11:53:10Z gcosmo $
                                                   >>  27 //
                                                   >>  28 // class G4GDMLReadSolids Implementation
                                                   >>  29 //
                                                   >>  30 // Original author: Zoltan Torzsok, November 2007
 27 //                                                 31 //
 28 // Author: Zoltan Torzsok, November 2007       << 
 29 // -------------------------------------------     32 // --------------------------------------------------------------------
 30                                                    33 
 31 #include "G4GDMLReadSolids.hh"                     34 #include "G4GDMLReadSolids.hh"
 32 #include "G4Box.hh"                                35 #include "G4Box.hh"
 33 #include "G4Cons.hh"                               36 #include "G4Cons.hh"
 34 #include "G4Ellipsoid.hh"                          37 #include "G4Ellipsoid.hh"
 35 #include "G4EllipticalCone.hh"                     38 #include "G4EllipticalCone.hh"
 36 #include "G4EllipticalTube.hh"                     39 #include "G4EllipticalTube.hh"
 37 #include "G4Hype.hh"                               40 #include "G4Hype.hh"
 38 #include "G4IntersectionSolid.hh"                  41 #include "G4IntersectionSolid.hh"
 39 #include "G4Orb.hh"                                42 #include "G4Orb.hh"
 40 #include "G4Para.hh"                               43 #include "G4Para.hh"
 41 #include "G4Paraboloid.hh"                         44 #include "G4Paraboloid.hh"
 42 #include "G4Polycone.hh"                           45 #include "G4Polycone.hh"
 43 #include "G4GenericPolycone.hh"                    46 #include "G4GenericPolycone.hh"
 44 #include "G4Polyhedra.hh"                          47 #include "G4Polyhedra.hh"
 45 #include "G4QuadrangularFacet.hh"                  48 #include "G4QuadrangularFacet.hh"
 46 #include "G4ReflectedSolid.hh"                     49 #include "G4ReflectedSolid.hh"
 47 #include "G4ScaledSolid.hh"                    << 
 48 #include "G4Sphere.hh"                             50 #include "G4Sphere.hh"
 49 #include "G4SolidStore.hh"                         51 #include "G4SolidStore.hh"
 50 #include "G4SubtractionSolid.hh"                   52 #include "G4SubtractionSolid.hh"
 51 #include "G4GenericTrap.hh"                        53 #include "G4GenericTrap.hh"
 52 #include "G4TessellatedSolid.hh"                   54 #include "G4TessellatedSolid.hh"
 53 #include "G4Tet.hh"                                55 #include "G4Tet.hh"
 54 #include "G4Torus.hh"                              56 #include "G4Torus.hh"
 55 #include "G4Transform3D.hh"                        57 #include "G4Transform3D.hh"
 56 #include "G4Trap.hh"                               58 #include "G4Trap.hh"
 57 #include "G4Trd.hh"                                59 #include "G4Trd.hh"
 58 #include "G4TriangularFacet.hh"                    60 #include "G4TriangularFacet.hh"
 59 #include "G4Tubs.hh"                               61 #include "G4Tubs.hh"
 60 #include "G4CutTubs.hh"                            62 #include "G4CutTubs.hh"
 61 #include "G4TwistedBox.hh"                         63 #include "G4TwistedBox.hh"
 62 #include "G4TwistedTrap.hh"                        64 #include "G4TwistedTrap.hh"
 63 #include "G4TwistedTrd.hh"                         65 #include "G4TwistedTrd.hh"
 64 #include "G4TwistedTubs.hh"                        66 #include "G4TwistedTubs.hh"
 65 #include "G4UnionSolid.hh"                         67 #include "G4UnionSolid.hh"
 66 #include "G4OpticalSurface.hh"                     68 #include "G4OpticalSurface.hh"
 67 #include "G4UnitsTable.hh"                         69 #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 scnd;
 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") { scnd = 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(scnd));
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 = G4UnitDefinition::GetValueOf(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 = G4UnitDefinition::GetValueOf(attValue); } else
327     if(attName == "name")                      << 261       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(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 = G4UnitDefinition::GetValueOf(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
                                                   >> 320       if (attName=="zcut") { zcut = eval.Evaluate(attValue); }
                                                   >> 321    }
                                                   >> 322 
                                                   >> 323    zmax *= lunit;
                                                   >> 324    zcut *= lunit;
                                                   >> 325 
                                                   >> 326    new G4EllipticalCone(name,dx,dy,zmax,zcut);
                                                   >> 327 }
                                                   >> 328 
                                                   >> 329 void G4GDMLReadSolids::
                                                   >> 330 EllipsoidRead(const xercesc::DOMElement* const ellipsoidElement)
                                                   >> 331 {
                                                   >> 332    G4String name;
                                                   >> 333    G4double lunit = 1.0;
                                                   >> 334    G4double ax = 0.0;
                                                   >> 335    G4double by = 0.0;
                                                   >> 336    G4double cz = 0.0;
                                                   >> 337    G4double zcut1 = 0.0;
                                                   >> 338    G4double zcut2 = 0.0; 
                                                   >> 339 
                                                   >> 340    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 341          = ellipsoidElement->getAttributes();
                                                   >> 342    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 343 
                                                   >> 344    for (XMLSize_t attribute_index=0;
                                                   >> 345         attribute_index<attributeCount; attribute_index++)
                                                   >> 346    {
                                                   >> 347       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 348 
                                                   >> 349       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 350         { continue; }
                                                   >> 351 
                                                   >> 352       const xercesc::DOMAttr* const attribute
                                                   >> 353             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 354       if (!attribute)
                                                   >> 355       {
                                                   >> 356         G4Exception("G4GDMLReadSolids::EllipsoidRead()",
                                                   >> 357                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 358         return;
                                                   >> 359       }
                                                   >> 360       const G4String attName = Transcode(attribute->getName());
                                                   >> 361       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 362 
                                                   >> 363       if (attName=="name") { name  = GenerateName(attValue); } else
                                                   >> 364       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 365       if (attName=="ax") { ax = eval.Evaluate(attValue); } else
                                                   >> 366       if (attName=="by") { by = eval.Evaluate(attValue); } else
                                                   >> 367       if (attName=="cz") { cz = eval.Evaluate(attValue); } else
                                                   >> 368       if (attName=="zcut1") { zcut1 = eval.Evaluate(attValue); } else
                                                   >> 369       if (attName=="zcut2") { zcut2 = eval.Evaluate(attValue); }
                                                   >> 370    }
                                                   >> 371 
                                                   >> 372    ax *= lunit;
                                                   >> 373    by *= lunit;
                                                   >> 374    cz *= lunit;
                                                   >> 375    zcut1 *= lunit;
                                                   >> 376    zcut2 *= lunit; 
                                                   >> 377 
                                                   >> 378    new G4Ellipsoid(name,ax,by,cz,zcut1,zcut2);
                                                   >> 379 }
                                                   >> 380 
                                                   >> 381 void G4GDMLReadSolids::
                                                   >> 382 EltubeRead(const xercesc::DOMElement* const eltubeElement)
                                                   >> 383 {
                                                   >> 384    G4String name;
                                                   >> 385    G4double lunit = 1.0;
                                                   >> 386    G4double dx = 0.0;
                                                   >> 387    G4double dy = 0.0;
                                                   >> 388    G4double dz = 0.0;
                                                   >> 389 
                                                   >> 390    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 391          = eltubeElement->getAttributes();
                                                   >> 392    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 393 
                                                   >> 394    for (XMLSize_t attribute_index=0;
                                                   >> 395         attribute_index<attributeCount; attribute_index++)
                                                   >> 396    {
                                                   >> 397       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 398 
                                                   >> 399       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 400         { continue; }
                                                   >> 401 
                                                   >> 402       const xercesc::DOMAttr* const attribute
                                                   >> 403             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 404       if (!attribute)
                                                   >> 405       {
                                                   >> 406         G4Exception("G4GDMLReadSolids::EltubeRead()",
                                                   >> 407                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 408         return;
                                                   >> 409       }
                                                   >> 410       const G4String attName = Transcode(attribute->getName());
                                                   >> 411       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 412 
                                                   >> 413       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 414       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 415       if (attName=="dx") { dx = eval.Evaluate(attValue); } else
                                                   >> 416       if (attName=="dy") { dy = eval.Evaluate(attValue); } else
                                                   >> 417       if (attName=="dz") { dz = eval.Evaluate(attValue); }
                                                   >> 418    }
                                                   >> 419 
                                                   >> 420    dx *= lunit;
                                                   >> 421    dy *= lunit;
                                                   >> 422    dz *= lunit;
386                                                   423 
387   new G4Cons(name, rmin1, rmax1, rmin2, rmax2, << 424    new G4EllipticalTube(name,dx,dy,dz);
388 }                                                 425 }
389                                                   426 
390 // ------------------------------------------- << 
391 void G4GDMLReadSolids::ElconeRead(             << 
392   const xercesc::DOMElement* const elconeEleme << 
393 {                                              << 
394   G4String name;                               << 
395   G4double lunit = 1.0;                        << 
396   G4double dx    = 0.0;                        << 
397   G4double dy    = 0.0;                        << 
398   G4double zmax  = 0.0;                        << 
399   G4double zcut  = 0.0;                        << 
400                                                << 
401   const xercesc::DOMNamedNodeMap* const attrib << 
402     elconeElement->getAttributes();            << 
403   XMLSize_t attributeCount = attributes->getLe << 
404                                                << 
405   for(XMLSize_t attribute_index = 0; attribute << 
406       ++attribute_index)                       << 
407   {                                            << 
408     xercesc::DOMNode* attribute_node = attribu << 
409                                                << 
410     if(attribute_node->getNodeType() != xerces << 
411     {                                          << 
412       continue;                                << 
413     }                                          << 
414                                                << 
415     const xercesc::DOMAttr* const attribute =  << 
416       dynamic_cast<xercesc::DOMAttr*>(attribut << 
417     if(attribute == nullptr)                   << 
418     {                                          << 
419       G4Exception("G4GDMLReadSolids::ElconeRea << 
420                   FatalException, "No attribut << 
421       return;                                  << 
422     }                                          << 
423     const G4String attName  = Transcode(attrib << 
424     const G4String attValue = Transcode(attrib << 
425                                                << 
426     if(attName == "name")                      << 
427     {                                          << 
428       name = GenerateName(attValue);           << 
429     }                                          << 
430     else if(attName == "lunit")                << 
431     {                                          << 
432       lunit = G4UnitDefinition::GetValueOf(att << 
433       if(G4UnitDefinition::GetCategory(attValu << 
434       {                                        << 
435         G4Exception("G4GDMLReadSolids::ElconeR << 
436                     FatalException, "Invalid u << 
437       }                                        << 
438     }                                          << 
439     else if(attName == "dx")                   << 
440     {                                          << 
441       dx = eval.Evaluate(attValue);            << 
442     }                                          << 
443     else if(attName == "dy")                   << 
444     {                                          << 
445       dy = eval.Evaluate(attValue);            << 
446     }                                          << 
447     else if(attName == "zmax")                 << 
448     {                                          << 
449       zmax = eval.Evaluate(attValue);          << 
450     }                                          << 
451     else if(attName == "zcut")                 << 
452     {                                          << 
453       zcut = eval.Evaluate(attValue);          << 
454     }                                          << 
455   }                                            << 
456                                                << 
457   zmax *= lunit;                               << 
458   zcut *= lunit;                               << 
459                                                << 
460   new G4EllipticalCone(name, dx, dy, zmax, zcu << 
461 }                                              << 
462                                                << 
463 // ------------------------------------------- << 
464 void G4GDMLReadSolids::EllipsoidRead(          << 
465   const xercesc::DOMElement* const ellipsoidEl << 
466 {                                              << 
467   G4String name;                               << 
468   G4double lunit = 1.0;                        << 
469   G4double ax    = 0.0;                        << 
470   G4double by    = 0.0;                        << 
471   G4double cz    = 0.0;                        << 
472   G4double zcut1 = 0.0;                        << 
473   G4double zcut2 = 0.0;                        << 
474                                                << 
475   const xercesc::DOMNamedNodeMap* const attrib << 
476     ellipsoidElement->getAttributes();         << 
477   XMLSize_t attributeCount = attributes->getLe << 
478                                                << 
479   for(XMLSize_t attribute_index = 0; attribute << 
480       ++attribute_index)                       << 
481   {                                            << 
482     xercesc::DOMNode* attribute_node = attribu << 
483                                                << 
484     if(attribute_node->getNodeType() != xerces << 
485     {                                          << 
486       continue;                                << 
487     }                                          << 
488                                                << 
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                                                << 
610   new G4EllipticalTube(name, dx, dy, dz);      << 
611 }                                              << 
612                                                << 
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                                                << 
619   const xercesc::DOMNamedNodeMap* const attrib << 
620     xtruElement->getAttributes();              << 
621   XMLSize_t attributeCount = attributes->getLe << 
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                                                << 
690   new G4ExtrudedSolid(name, twoDimVertexList,  << 
691 }                                              << 
692                                                << 
693 // ------------------------------------------- << 
694 void G4GDMLReadSolids::HypeRead(const xercesc: << 
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                                                   431 
780   new G4Hype(name, rmin, rmax, inst, outst, z) << 432    const xercesc::DOMNamedNodeMap* const attributes
781 }                                              << 433          = xtruElement->getAttributes();
                                                   >> 434    XMLSize_t attributeCount = attributes->getLength();
782                                                   435 
783 // ------------------------------------------- << 436    for (XMLSize_t attribute_index=0;
784 void G4GDMLReadSolids::MultiUnionNodeRead(     << 437         attribute_index<attributeCount; attribute_index++)
785   const xercesc::DOMElement* const unionNodeEl << 438    {
786   G4MultiUnion* const multiUnionSolid)         << 439       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
787 {                                              << 
788   G4String name;                               << 
789   G4String solid;                              << 
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                                                   440 
880   const xercesc::DOMNamedNodeMap* const attrib << 441       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
881     unionElement->getAttributes();             << 442         { continue; } 
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                                                   443 
945 // ------------------------------------------- << 444       const xercesc::DOMAttr* const attribute
946 void G4GDMLReadSolids::OrbRead(const xercesc:: << 445             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
947 {                                              << 446       if (!attribute)
948   G4String name;                               << 447       {
949   G4double lunit = 1.0;                        << 448         G4Exception("G4GDMLReadSolids::XtruRead()",
950   G4double r     = 0.0;                        << 449                     "InvalidRead", FatalException, "No attribute found!");
951                                                << 450         return;
952   const xercesc::DOMNamedNodeMap* const attrib << 451       }
953     orbElement->getAttributes();               << 452       const G4String attName = Transcode(attribute->getName());
954   XMLSize_t attributeCount = attributes->getLe << 453       const G4String attValue = Transcode(attribute->getValue());
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 = G4UnitDefinition::GetValueOf(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 = G4UnitDefinition::GetValueOf(attValue); } else
1204     }                                         << 522       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(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 << 535 
1218       {                                       << 536    new G4Hype(name,rmin,rmax,inst,outst,z);
1219         G4Exception("G4GDMLReadSolids::Polyco << 537 }
1220                     FatalException, "Invalid  << 538 
1221       }                                       << 539 #if !defined(G4GEOM_USE_USOLIDS)
1222     }                                         << 540 void G4GDMLReadSolids::
1223     else if(attName == "startphi")            << 541 MultiUnionNodeRead(const xercesc::DOMElement* const,
1224     {                                         << 542                    G4MultiUnion* const)
1225       startphi = eval.Evaluate(attValue);     << 543 {
1226     }                                         << 544    G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
1227     else if(attName == "deltaphi")            << 545                "InvalidSetup", FatalException,
1228     {                                         << 546                "Installation with USolids primitives required!");
1229       deltaphi = eval.Evaluate(attValue);     << 547    return;
1230     }                                         << 548 }
1231   }                                           << 549 #else
1232                                               << 550 void G4GDMLReadSolids::
1233   startphi *= aunit;                          << 551 MultiUnionNodeRead(const xercesc::DOMElement* const unionNodeElement,
1234   deltaphi *= aunit;                          << 552                    G4MultiUnion* const multiUnionSolid)
1235                                               << 553 {
1236   std::vector<zplaneType> zplaneList;         << 554    G4String name;
1237                                               << 555    G4String solid;
1238   for(xercesc::DOMNode* iter = polyconeElemen << 556    G4ThreeVector position(0.0,0.0,0.0);
1239       iter                   = iter->getNextS << 557    G4ThreeVector rotation(0.0,0.0,0.0);
1240   {                                           << 558 
1241     if(iter->getNodeType() != xercesc::DOMNod << 559    const xercesc::DOMNamedNodeMap* const attributes
1242     {                                         << 560          = unionNodeElement->getAttributes();
1243       continue;                               << 561    XMLSize_t attributeCount = attributes->getLength();
1244     }                                         << 562 
1245                                               << 563    for (XMLSize_t attribute_index=0;
1246     const xercesc::DOMElement* const child =  << 564         attribute_index<attributeCount; attribute_index++)
1247       dynamic_cast<xercesc::DOMElement*>(iter << 565    {
1248     if(child == nullptr)                      << 566       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1249     {                                         << 567 
1250       G4Exception("G4GDMLReadSolids::Polycone << 568       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1251                   FatalException, "No child f << 569         { continue; }
1252       return;                                 << 570 
1253     }                                         << 571       const xercesc::DOMAttr* const attribute
1254     const G4String tag = Transcode(child->get << 572             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
1255                                               << 573       if (!attribute)
1256     if(tag == "zplane")                       << 574       {
1257     {                                         << 575         G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
1258       zplaneList.push_back(ZplaneRead(child)) << 576                     "InvalidRead", FatalException, "No attribute found!");
1259     }                                         << 577         return;
1260   }                                           << 578       }
1261                                               << 579       const G4String attName = Transcode(attribute->getName());
1262   std::size_t numZPlanes = zplaneList.size(); << 580       const G4String attValue = Transcode(attribute->getValue());
1263                                               << 581 
1264   G4double* rmin_array = new G4double[numZPla << 582       if (attName=="name")  { name = GenerateName(attValue); }
1265   G4double* rmax_array = new G4double[numZPla << 583    }
1266   G4double* z_array    = new G4double[numZPla << 584 
1267                                               << 585    for (xercesc::DOMNode* iter = unionNodeElement->getFirstChild();
1268   for(std::size_t i = 0; i < numZPlanes; ++i) << 586         iter != 0;iter = iter->getNextSibling())
1269   {                                           << 587    {
1270     rmin_array[i] = zplaneList[i].rmin * luni << 588       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
1271     rmax_array[i] = zplaneList[i].rmax * luni << 589 
1272     z_array[i]    = zplaneList[i].z * lunit;  << 590       const xercesc::DOMElement* const child
1273   }                                           << 591             = dynamic_cast<xercesc::DOMElement*>(iter);
1274                                               << 592       if (!child)
1275   new G4Polycone(name, startphi, deltaphi, (G << 593       {
1276                  rmin_array, rmax_array);     << 594         G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
1277                                               << 595                     "InvalidRead", FatalException, "No child found!");
1278   delete[] rmin_array;                        << 596         return;
1279   delete[] rmax_array;                        << 597       }
1280   delete[] z_array;                           << 598       const G4String tag = Transcode(child->getTagName());
                                                   >> 599 
                                                   >> 600       if (tag=="position") { VectorRead(child,position); } else
                                                   >> 601       if (tag=="rotation") { VectorRead(child,rotation); } else
                                                   >> 602       if (tag=="positionref")
                                                   >> 603         { position = GetPosition(GenerateName(RefRead(child))); } else
                                                   >> 604       if (tag=="rotationref")
                                                   >> 605         { rotation = GetRotation(GenerateName(RefRead(child))); } else
                                                   >> 606       if (tag=="solid") { solid = RefRead(child); }
                                                   >> 607       else
                                                   >> 608       {
                                                   >> 609         G4String error_msg = "Unknown tag in MultiUnion structure: " + tag;
                                                   >> 610         G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()", "ReadError",
                                                   >> 611                     FatalException, error_msg);
                                                   >> 612       }
                                                   >> 613    }
                                                   >> 614    G4VSolid* solidNode = GetSolid(GenerateName(solid));
                                                   >> 615    G4Transform3D transform(GetRotationMatrix(rotation),position);
                                                   >> 616    multiUnionSolid->AddNode(*solidNode, transform);
1281 }                                                617 }
                                                   >> 618 #endif
1282                                                  619 
1283 // ------------------------------------------ << 620 #if !defined(G4GEOM_USE_USOLIDS)
1284 void G4GDMLReadSolids::GenericPolyconeRead(   << 621 void G4GDMLReadSolids::
1285   const xercesc::DOMElement* const polyconeEl << 622 MultiUnionRead(const xercesc::DOMElement* const)
1286 {                                                623 {
1287   G4String name;                              << 624    G4Exception("G4GDMLReadSolids::MultiUnionRead()",
1288   G4double lunit    = 1.0;                    << 625                "InvalidSetup", FatalException,
1289   G4double aunit    = 1.0;                    << 626                "Installation with USolids primitives required!");
1290   G4double startphi = 0.0;                    << 627    return;
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 }                                                628 }
1394                                               << 629 #else
1395 // ------------------------------------------ << 630 void G4GDMLReadSolids::
1396 void G4GDMLReadSolids::PolyhedraRead(         << 631 MultiUnionRead(const xercesc::DOMElement* const unionElement)
1397   const xercesc::DOMElement* const polyhedraE << 
1398 {                                                632 {
1399   G4String name;                              << 633    G4String name;
1400   G4double lunit    = 1.0;                    << 
1401   G4double aunit    = 1.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                                                  634 
1517 // ------------------------------------------ << 635    const xercesc::DOMNamedNodeMap* const attributes
1518 void G4GDMLReadSolids::GenericPolyhedraRead(  << 636          = unionElement->getAttributes();
1519   const xercesc::DOMElement* const polyhedraE << 637    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                                                  638 
1629   new G4Polyhedra(name, startphi, deltaphi, n << 639    for (XMLSize_t attribute_index=0;
1630                   r_array, z_array);          << 640         attribute_index<attributeCount; attribute_index++)
                                                   >> 641    {
                                                   >> 642       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1631                                                  643 
1632   delete[] r_array;                           << 644       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1633   delete[] z_array;                           << 645         { continue; }
1634 }                                             << 
1635                                                  646 
1636 // ------------------------------------------ << 647       const xercesc::DOMAttr* const attribute
1637 G4QuadrangularFacet* G4GDMLReadSolids::Quadra << 648             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
1638   const xercesc::DOMElement* const quadrangul << 649       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       {                                          650       {
1701         type = RELATIVE;                      << 651         G4Exception("G4GDMLReadSolids::MultiUnionRead()",
                                                   >> 652                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 653         return;
1702       }                                          654       }
1703     }                                         << 655       const G4String attName = Transcode(attribute->getName());
1704   }                                           << 656       const G4String attValue = Transcode(attribute->getValue());
1705                                                  657 
1706   return new G4QuadrangularFacet(vertex1 * lu << 658       if (attName=="name")  { name = GenerateName(attValue); }
1707                                  vertex3 * lu << 659    }
1708 }                                             << 
1709                                                  660 
1710 // ------------------------------------------ << 661    G4MultiUnion* multiUnion = new G4MultiUnion(name);
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                                                  662 
1811   rotation *= aunit;                          << 663    for (xercesc::DOMNode* iter = unionElement->getFirstChild();
1812   position *= lunit;                          << 664         iter != 0;iter = iter->getNextSibling())
                                                   >> 665    {
                                                   >> 666       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
1813                                                  667 
1814   G4Transform3D transform(GetRotationMatrix(r << 668       const xercesc::DOMElement* const child
1815   transform = transform * G4Scale3D(scale.x() << 669             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 670       if (!child)
                                                   >> 671       {
                                                   >> 672         G4Exception("G4GDMLReadSolids::MultiUnionRead()",
                                                   >> 673                     "InvalidRead", FatalException, "No child found!");
                                                   >> 674         return;
                                                   >> 675       }
                                                   >> 676       const G4String tag = Transcode(child->getTagName());
1816                                                  677 
1817   new G4ReflectedSolid(name, GetSolid(solid), << 678       if (tag=="multiUnionNode") { MultiUnionNodeRead(child, multiUnion); }
                                                   >> 679       else
                                                   >> 680       {
                                                   >> 681         G4String error_msg = "Unknown tag in MultiUnion structure: " + tag;
                                                   >> 682         G4Exception("G4GDMLReadSolids::MultiUnionRead()", "ReadError",
                                                   >> 683                     FatalException, error_msg);
                                                   >> 684       }
                                                   >> 685    }
                                                   >> 686    multiUnion->Voxelize();
1818 }                                                687 }
                                                   >> 688 #endif
1819                                                  689 
1820 // ------------------------------------------ << 690 void G4GDMLReadSolids::OrbRead(const xercesc::DOMElement* const orbElement)
1821 void G4GDMLReadSolids::ScaledSolidRead(       << 
1822   const xercesc::DOMElement* const scaledSoli << 
1823 {                                                691 {
1824   G4String name;                              << 692    G4String name;
1825   G4VSolid* solid = nullptr;                  << 693    G4double lunit = 1.0;
1826   G4ThreeVector scale(1.0, 1.0, 1.0);         << 694    G4double r = 0.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                                                  695 
1898   G4Scale3D transform = G4Scale3D(scale.x(),  << 696    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 697          = orbElement->getAttributes();
                                                   >> 698    XMLSize_t attributeCount = attributes->getLength();
1899                                                  699 
1900   new G4ScaledSolid(name, solid, transform);  << 700    for (XMLSize_t attribute_index=0;
1901 }                                             << 701         attribute_index<attributeCount; attribute_index++)
                                                   >> 702    {
                                                   >> 703       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1902                                                  704 
1903 // ------------------------------------------ << 705       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1904 G4ExtrudedSolid::ZSection G4GDMLReadSolids::S << 706         { continue; }
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                                                  707 
1954   return G4ExtrudedSolid::ZSection(zPosition, << 708       const xercesc::DOMAttr* const attribute
1955 }                                             << 709             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 710       if (!attribute)
                                                   >> 711       {
                                                   >> 712         G4Exception("G4GDMLReadSolids::OrbRead()",
                                                   >> 713                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 714         return;
                                                   >> 715       }
                                                   >> 716       const G4String attName = Transcode(attribute->getName());
                                                   >> 717       const G4String attValue = Transcode(attribute->getValue());
1956                                                  718 
1957 // ------------------------------------------ << 719       if (attName=="name") { name = GenerateName(attValue); } else
1958 void G4GDMLReadSolids::SphereRead(            << 720       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
1959   const xercesc::DOMElement* const sphereElem << 721       if (attName=="r") { r = eval.Evaluate(attValue); }
1960 {                                             << 722    }
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                                                  723 
2051   new G4Sphere(name, rmin, rmax, startphi, de << 724    r *= lunit;
                                                   >> 725 
                                                   >> 726    new G4Orb(name,r);
2052 }                                                727 }
2053                                                  728 
2054 // ------------------------------------------ << 729 void G4GDMLReadSolids::ParaRead(const xercesc::DOMElement* const paraElement)
2055 void G4GDMLReadSolids::TessellatedRead(       << 
2056   const xercesc::DOMElement* const tessellate << 
2057 {                                                730 {
2058   G4String name;                              << 731    G4String name;
                                                   >> 732    G4double lunit = 1.0;
                                                   >> 733    G4double aunit = 1.0;
                                                   >> 734    G4double x = 0.0;
                                                   >> 735    G4double y = 0.0;
                                                   >> 736    G4double z = 0.0;
                                                   >> 737    G4double alpha = 0.0;
                                                   >> 738    G4double theta = 0.0;
                                                   >> 739    G4double phi = 0.0;
                                                   >> 740 
                                                   >> 741    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 742          = paraElement->getAttributes();
                                                   >> 743    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 744 
                                                   >> 745    for (XMLSize_t attribute_index=0;
                                                   >> 746         attribute_index<attributeCount; attribute_index++)
                                                   >> 747    {
                                                   >> 748       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 749 
                                                   >> 750       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 751         { continue; }
                                                   >> 752 
                                                   >> 753       const xercesc::DOMAttr* const attribute
                                                   >> 754             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 755       if (!attribute)
                                                   >> 756       {
                                                   >> 757         G4Exception("G4GDMLReadSolids::ParaRead()",
                                                   >> 758                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 759         return;
                                                   >> 760       }
                                                   >> 761       const G4String attName = Transcode(attribute->getName());
                                                   >> 762       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 763 
                                                   >> 764       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 765       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 766       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 767       if (attName=="x") { x = eval.Evaluate(attValue); } else
                                                   >> 768       if (attName=="y") { y = eval.Evaluate(attValue); } else
                                                   >> 769       if (attName=="z") { z = eval.Evaluate(attValue); } else
                                                   >> 770       if (attName=="alpha") { alpha = eval.Evaluate(attValue); } else
                                                   >> 771       if (attName=="theta") { theta = eval.Evaluate(attValue); } else
                                                   >> 772       if (attName=="phi") { phi = eval.Evaluate(attValue); }
                                                   >> 773    }
                                                   >> 774 
                                                   >> 775    x *= 0.5*lunit;
                                                   >> 776    y *= 0.5*lunit;
                                                   >> 777    z *= 0.5*lunit;
                                                   >> 778    alpha *= aunit;
                                                   >> 779    theta *= aunit;
                                                   >> 780    phi *= aunit;
                                                   >> 781 
                                                   >> 782    new G4Para(name,x,y,z,alpha,theta,phi);
                                                   >> 783 }
                                                   >> 784 
                                                   >> 785 void G4GDMLReadSolids::
                                                   >> 786 ParaboloidRead(const xercesc::DOMElement* const paraElement)
                                                   >> 787 {
                                                   >> 788    G4String name;
                                                   >> 789    G4double lunit = 1.0;
                                                   >> 790    G4double rlo = 0.0;
                                                   >> 791    G4double rhi = 0.0;
                                                   >> 792    G4double dz = 0.0;
                                                   >> 793   
                                                   >> 794    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 795          = paraElement->getAttributes();
                                                   >> 796    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 797 
                                                   >> 798    for (XMLSize_t attribute_index=0;
                                                   >> 799         attribute_index<attributeCount; attribute_index++)
                                                   >> 800    {
                                                   >> 801       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 802 
                                                   >> 803       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 804         { continue; }
                                                   >> 805 
                                                   >> 806       const xercesc::DOMAttr* const attribute
                                                   >> 807             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 808       if (!attribute)
                                                   >> 809       {
                                                   >> 810         G4Exception("G4GDMLReadSolids::ParaboloidRead()",
                                                   >> 811                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 812         return;
                                                   >> 813       }
                                                   >> 814       const G4String attName = Transcode(attribute->getName());
                                                   >> 815       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 816 
                                                   >> 817       if (attName=="name")  { name = GenerateName(attValue); } else
                                                   >> 818       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 819       if (attName=="rlo")   { rlo =  eval.Evaluate(attValue); } else
                                                   >> 820       if (attName=="rhi")   { rhi = eval.Evaluate(attValue); } else
                                                   >> 821       if (attName=="dz")    { dz = eval.Evaluate(attValue); } 
                                                   >> 822    }     
                                                   >> 823 
                                                   >> 824    rlo *= 1.*lunit;
                                                   >> 825    rhi *= 1.*lunit;
                                                   >> 826    dz *= 1.*lunit;
                                                   >> 827   
                                                   >> 828    new G4Paraboloid(name,dz,rlo,rhi);
                                                   >> 829 }
                                                   >> 830 
                                                   >> 831 void G4GDMLReadSolids::
                                                   >> 832 PolyconeRead(const xercesc::DOMElement* const polyconeElement) 
                                                   >> 833 {
                                                   >> 834    G4String name;
                                                   >> 835    G4double lunit = 1.0;
                                                   >> 836    G4double aunit = 1.0;
                                                   >> 837    G4double startphi = 0.0;
                                                   >> 838    G4double deltaphi = 0.0;
                                                   >> 839 
                                                   >> 840    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 841          = polyconeElement->getAttributes();
                                                   >> 842    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 843 
                                                   >> 844    for (XMLSize_t attribute_index=0;
                                                   >> 845         attribute_index<attributeCount; attribute_index++)
                                                   >> 846    {
                                                   >> 847       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 848 
                                                   >> 849       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 850         { continue; }
                                                   >> 851 
                                                   >> 852       const xercesc::DOMAttr* const attribute
                                                   >> 853             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 854       if (!attribute)
                                                   >> 855       {
                                                   >> 856         G4Exception("G4GDMLReadSolids::PolyconeRead()",
                                                   >> 857                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 858         return;
                                                   >> 859       }
                                                   >> 860       const G4String attName = Transcode(attribute->getName());
                                                   >> 861       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 862 
                                                   >> 863       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 864       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 865       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 866       if (attName=="startphi") { startphi = eval.Evaluate(attValue); }else
                                                   >> 867       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
                                                   >> 868    }
                                                   >> 869 
                                                   >> 870    startphi *= aunit;
                                                   >> 871    deltaphi *= aunit;
                                                   >> 872 
                                                   >> 873    std::vector<zplaneType> zplaneList;
                                                   >> 874 
                                                   >> 875    for (xercesc::DOMNode* iter = polyconeElement->getFirstChild();
                                                   >> 876         iter != 0; iter = iter->getNextSibling())
                                                   >> 877    {
                                                   >> 878       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 879 
                                                   >> 880       const xercesc::DOMElement* const child
                                                   >> 881             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 882       if (!child)
                                                   >> 883       {
                                                   >> 884         G4Exception("G4GDMLReadSolids::PolyconeRead()",
                                                   >> 885                     "InvalidRead", FatalException, "No child found!");
                                                   >> 886         return;
                                                   >> 887       }
                                                   >> 888       const G4String tag = Transcode(child->getTagName());
                                                   >> 889 
                                                   >> 890       if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
                                                   >> 891    }
                                                   >> 892 
                                                   >> 893    G4int numZPlanes = zplaneList.size();
                                                   >> 894 
                                                   >> 895    G4double* rmin_array = new G4double[numZPlanes];
                                                   >> 896    G4double* rmax_array = new G4double[numZPlanes];
                                                   >> 897    G4double* z_array    = new G4double[numZPlanes];
                                                   >> 898 
                                                   >> 899    for (G4int i=0; i<numZPlanes; i++)
                                                   >> 900    { 
                                                   >> 901       rmin_array[i] = zplaneList[i].rmin*lunit;
                                                   >> 902       rmax_array[i] = zplaneList[i].rmax*lunit;
                                                   >> 903       z_array[i]    = zplaneList[i].z*lunit;
                                                   >> 904    }
                                                   >> 905 
                                                   >> 906    new G4Polycone(name,startphi,deltaphi,numZPlanes,
                                                   >> 907                   z_array,rmin_array,rmax_array);
                                                   >> 908 
                                                   >> 909    delete [] rmin_array;
                                                   >> 910    delete [] rmax_array;
                                                   >> 911    delete [] z_array;
                                                   >> 912 }
                                                   >> 913 
                                                   >> 914 void G4GDMLReadSolids::
                                                   >> 915 GenericPolyconeRead(const xercesc::DOMElement* const polyconeElement) 
                                                   >> 916 {
                                                   >> 917    G4String name;
                                                   >> 918    G4double lunit = 1.0;
                                                   >> 919    G4double aunit = 1.0;
                                                   >> 920    G4double startphi = 0.0;
                                                   >> 921    G4double deltaphi = 0.0;
                                                   >> 922 
                                                   >> 923    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 924          = polyconeElement->getAttributes();
                                                   >> 925    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 926 
                                                   >> 927    for (XMLSize_t attribute_index=0;
                                                   >> 928         attribute_index<attributeCount; attribute_index++)
                                                   >> 929    {
                                                   >> 930       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 931 
                                                   >> 932       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 933         { continue; }
                                                   >> 934 
                                                   >> 935       const xercesc::DOMAttr* const attribute
                                                   >> 936             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 937       if (!attribute)
                                                   >> 938       {
                                                   >> 939         G4Exception("G4GDMLReadSolids::GenericPolyconeRead()",
                                                   >> 940                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 941         return;
                                                   >> 942       }
                                                   >> 943       const G4String attName = Transcode(attribute->getName());
                                                   >> 944       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 945 
                                                   >> 946       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 947       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 948       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 949       if (attName=="startphi") { startphi = eval.Evaluate(attValue); }else
                                                   >> 950       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
                                                   >> 951    }
                                                   >> 952 
                                                   >> 953    startphi *= aunit;
                                                   >> 954    deltaphi *= aunit;
                                                   >> 955 
                                                   >> 956    std::vector<rzPointType> rzPointList;
                                                   >> 957 
                                                   >> 958    for (xercesc::DOMNode* iter = polyconeElement->getFirstChild();
                                                   >> 959         iter != 0; iter = iter->getNextSibling())
                                                   >> 960    {
                                                   >> 961       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 962 
                                                   >> 963       const xercesc::DOMElement* const child
                                                   >> 964             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 965       if (!child)
                                                   >> 966       {
                                                   >> 967         G4Exception("G4GDMLReadSolids::GenericPolyconeRead()",
                                                   >> 968                     "InvalidRead", FatalException, "No child found!");
                                                   >> 969         return;
                                                   >> 970       }
                                                   >> 971       const G4String tag = Transcode(child->getTagName());
                                                   >> 972 
                                                   >> 973       if (tag=="rzpoint") { rzPointList.push_back(RZPointRead(child)); }
                                                   >> 974    }
                                                   >> 975 
                                                   >> 976    G4int numRZPoints = rzPointList.size();
                                                   >> 977 
                                                   >> 978    G4double* r_array = new G4double[numRZPoints];
                                                   >> 979    G4double* z_array = new G4double[numRZPoints];
                                                   >> 980 
                                                   >> 981    for (G4int i=0; i<numRZPoints; i++)
                                                   >> 982    { 
                                                   >> 983       r_array[i] = rzPointList[i].r*lunit;
                                                   >> 984       z_array[i] = rzPointList[i].z*lunit;
                                                   >> 985    }
                                                   >> 986    new G4GenericPolycone(name,startphi,deltaphi,numRZPoints,
                                                   >> 987                          r_array,z_array);
                                                   >> 988    delete [] r_array;
                                                   >> 989    delete [] z_array;
                                                   >> 990 }
                                                   >> 991 
                                                   >> 992 void G4GDMLReadSolids::
                                                   >> 993 PolyhedraRead(const xercesc::DOMElement* const polyhedraElement)
                                                   >> 994 {
                                                   >> 995    G4String name;
                                                   >> 996    G4double lunit = 1.0;
                                                   >> 997    G4double aunit = 1.0;
                                                   >> 998    G4double startphi = 0.0;
                                                   >> 999    G4double deltaphi = 0.0;
                                                   >> 1000    G4int numsides = 0;
                                                   >> 1001 
                                                   >> 1002    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1003          = polyhedraElement->getAttributes();
                                                   >> 1004    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1005 
                                                   >> 1006    for (XMLSize_t attribute_index=0;
                                                   >> 1007         attribute_index<attributeCount; attribute_index++)
                                                   >> 1008    {
                                                   >> 1009       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1010 
                                                   >> 1011       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1012         { continue; }
                                                   >> 1013 
                                                   >> 1014       const xercesc::DOMAttr* const attribute
                                                   >> 1015             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1016       if (!attribute)
                                                   >> 1017       {
                                                   >> 1018         G4Exception("G4GDMLReadSolids::PolyhedraRead()",
                                                   >> 1019                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1020         return;
                                                   >> 1021       }
                                                   >> 1022       const G4String attName = Transcode(attribute->getName());
                                                   >> 1023       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1024 
                                                   >> 1025       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 1026       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1027       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1028       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
                                                   >> 1029       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
                                                   >> 1030       if (attName=="numsides") { numsides = eval.EvaluateInteger(attValue); }
                                                   >> 1031    }
                                                   >> 1032 
                                                   >> 1033    startphi *= aunit;
                                                   >> 1034    deltaphi *= aunit;
                                                   >> 1035 
                                                   >> 1036    std::vector<zplaneType> zplaneList;
                                                   >> 1037 
                                                   >> 1038    for (xercesc::DOMNode* iter = polyhedraElement->getFirstChild();
                                                   >> 1039         iter != 0; iter = iter->getNextSibling())
                                                   >> 1040    {
                                                   >> 1041       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
                                                   >> 1042 
                                                   >> 1043       const xercesc::DOMElement* const child
                                                   >> 1044             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 1045       if (!child)
                                                   >> 1046       {
                                                   >> 1047         G4Exception("G4GDMLReadSolids::PolyhedraRead()",
                                                   >> 1048                     "InvalidRead", FatalException, "No child found!");
                                                   >> 1049         return;
                                                   >> 1050       }
                                                   >> 1051       const G4String tag = Transcode(child->getTagName());
                                                   >> 1052 
                                                   >> 1053       if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
                                                   >> 1054    }
                                                   >> 1055 
                                                   >> 1056    G4int numZPlanes = zplaneList.size();
                                                   >> 1057 
                                                   >> 1058    G4double* rmin_array = new G4double[numZPlanes];
                                                   >> 1059    G4double* rmax_array = new G4double[numZPlanes];
                                                   >> 1060    G4double* z_array = new G4double[numZPlanes];
                                                   >> 1061 
                                                   >> 1062    for (G4int i=0; i<numZPlanes; i++)
                                                   >> 1063    { 
                                                   >> 1064       rmin_array[i] = zplaneList[i].rmin*lunit;
                                                   >> 1065       rmax_array[i] = zplaneList[i].rmax*lunit;
                                                   >> 1066       z_array[i] = zplaneList[i].z*lunit;
                                                   >> 1067    }
                                                   >> 1068 
                                                   >> 1069    new G4Polyhedra(name,startphi,deltaphi,numsides,numZPlanes,
                                                   >> 1070                    z_array,rmin_array,rmax_array);
                                                   >> 1071 
                                                   >> 1072    delete [] rmin_array;
                                                   >> 1073    delete [] rmax_array;
                                                   >> 1074    delete [] z_array;
                                                   >> 1075 }
                                                   >> 1076 
                                                   >> 1077 void G4GDMLReadSolids::
                                                   >> 1078 GenericPolyhedraRead(const xercesc::DOMElement* const polyhedraElement)
                                                   >> 1079 {
                                                   >> 1080    G4String name;
                                                   >> 1081    G4double lunit = 1.0;
                                                   >> 1082    G4double aunit = 1.0;
                                                   >> 1083    G4double startphi = 0.0;
                                                   >> 1084    G4double deltaphi = 0.0;
                                                   >> 1085    G4int numsides = 0;
                                                   >> 1086 
                                                   >> 1087    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1088          = polyhedraElement->getAttributes();
                                                   >> 1089    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1090 
                                                   >> 1091    for (XMLSize_t attribute_index=0;
                                                   >> 1092         attribute_index<attributeCount; attribute_index++)
                                                   >> 1093    {
                                                   >> 1094       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1095 
                                                   >> 1096       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1097         { continue; }
                                                   >> 1098 
                                                   >> 1099       const xercesc::DOMAttr* const attribute
                                                   >> 1100             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1101       if (!attribute)
                                                   >> 1102       {
                                                   >> 1103         G4Exception("G4GDMLReadSolids::GenericPolyhedraRead()",
                                                   >> 1104                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1105         return;
                                                   >> 1106       }
                                                   >> 1107       const G4String attName = Transcode(attribute->getName());
                                                   >> 1108       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1109 
                                                   >> 1110       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 1111       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1112       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1113       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
                                                   >> 1114       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
                                                   >> 1115       if (attName=="numsides") { numsides = eval.EvaluateInteger(attValue); }
                                                   >> 1116    }
                                                   >> 1117 
                                                   >> 1118    startphi *= aunit;
                                                   >> 1119    deltaphi *= aunit;
                                                   >> 1120 
                                                   >> 1121    std::vector<rzPointType> rzpointList;
                                                   >> 1122 
                                                   >> 1123    for (xercesc::DOMNode* iter = polyhedraElement->getFirstChild();
                                                   >> 1124         iter != 0; iter = iter->getNextSibling())
                                                   >> 1125    {
                                                   >> 1126       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
                                                   >> 1127 
                                                   >> 1128       const xercesc::DOMElement* const child
                                                   >> 1129             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 1130       if (!child)
                                                   >> 1131       {
                                                   >> 1132         G4Exception("G4GDMLReadSolids::GenericPolyhedraRead()",
                                                   >> 1133                     "InvalidRead", FatalException, "No child found!");
                                                   >> 1134         return;
                                                   >> 1135       }
                                                   >> 1136       const G4String tag = Transcode(child->getTagName());
                                                   >> 1137 
                                                   >> 1138       if (tag=="rzpoint") { rzpointList.push_back(RZPointRead(child)); }
                                                   >> 1139    }
                                                   >> 1140 
                                                   >> 1141    G4int numRZPoints = rzpointList.size();
                                                   >> 1142 
                                                   >> 1143    G4double* r_array = new G4double[numRZPoints];
                                                   >> 1144    G4double* z_array = new G4double[numRZPoints];
                                                   >> 1145 
                                                   >> 1146    for (G4int i=0; i<numRZPoints; i++)
                                                   >> 1147    { 
                                                   >> 1148       r_array[i] = rzpointList[i].r*lunit;
                                                   >> 1149       z_array[i] = rzpointList[i].z*lunit;
                                                   >> 1150    }
                                                   >> 1151 
                                                   >> 1152    new G4Polyhedra(name,startphi,deltaphi,numsides,numRZPoints,
                                                   >> 1153                    r_array,z_array);
                                                   >> 1154 
                                                   >> 1155    delete [] r_array;
                                                   >> 1156    delete [] z_array;
                                                   >> 1157 }
                                                   >> 1158 
                                                   >> 1159 G4QuadrangularFacet* G4GDMLReadSolids::
                                                   >> 1160 QuadrangularRead(const xercesc::DOMElement* const quadrangularElement)
                                                   >> 1161 {
                                                   >> 1162    G4ThreeVector vertex1;
                                                   >> 1163    G4ThreeVector vertex2;
                                                   >> 1164    G4ThreeVector vertex3;
                                                   >> 1165    G4ThreeVector vertex4;
                                                   >> 1166    G4FacetVertexType type = ABSOLUTE;
                                                   >> 1167    G4double lunit = 1.0;
                                                   >> 1168 
                                                   >> 1169    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1170          = quadrangularElement->getAttributes();
                                                   >> 1171    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1172 
                                                   >> 1173    for (XMLSize_t attribute_index=0;
                                                   >> 1174         attribute_index<attributeCount; attribute_index++)
                                                   >> 1175    {
                                                   >> 1176       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1177 
                                                   >> 1178       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1179         { continue; }
                                                   >> 1180 
                                                   >> 1181       const xercesc::DOMAttr* const attribute
                                                   >> 1182             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1183       if (!attribute)
                                                   >> 1184       {
                                                   >> 1185         G4Exception("G4GDMLReadSolids::QuadrangularRead()",
                                                   >> 1186                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1187         return 0;
                                                   >> 1188       }
                                                   >> 1189       const G4String attName = Transcode(attribute->getName());
                                                   >> 1190       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1191 
                                                   >> 1192       if (attName=="vertex1")
                                                   >> 1193         { vertex1 = GetPosition(GenerateName(attValue)); } else
                                                   >> 1194       if (attName=="vertex2")
                                                   >> 1195         { vertex2 = GetPosition(GenerateName(attValue)); } else
                                                   >> 1196       if (attName=="vertex3")
                                                   >> 1197         { vertex3 = GetPosition(GenerateName(attValue)); } else
                                                   >> 1198       if (attName=="vertex4")
                                                   >> 1199         { vertex4 = GetPosition(GenerateName(attValue)); } else
                                                   >> 1200       if (attName=="lunit")
                                                   >> 1201         { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1202       if (attName=="type")
                                                   >> 1203         { if (attValue=="RELATIVE") { type = RELATIVE; } }
                                                   >> 1204    }
                                                   >> 1205 
                                                   >> 1206    return new G4QuadrangularFacet(vertex1*lunit,vertex2*lunit,
                                                   >> 1207                                   vertex3*lunit,vertex4*lunit,type);
                                                   >> 1208 }
                                                   >> 1209 
                                                   >> 1210 void G4GDMLReadSolids::
                                                   >> 1211 ReflectedSolidRead(const xercesc::DOMElement* const reflectedSolidElement)
                                                   >> 1212 {
                                                   >> 1213    G4String name;
                                                   >> 1214    G4double lunit = 1.0;
                                                   >> 1215    G4double aunit = 1.0;
                                                   >> 1216    G4String solid;
                                                   >> 1217    G4ThreeVector scale(1.0,1.0,1.0);
                                                   >> 1218    G4ThreeVector rotation;
                                                   >> 1219    G4ThreeVector position;
                                                   >> 1220 
                                                   >> 1221    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1222          = reflectedSolidElement->getAttributes();
                                                   >> 1223    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1224 
                                                   >> 1225    for (XMLSize_t attribute_index=0;
                                                   >> 1226         attribute_index<attributeCount; attribute_index++)
                                                   >> 1227    {
                                                   >> 1228       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1229 
                                                   >> 1230       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1231         { continue; }
                                                   >> 1232 
                                                   >> 1233       const xercesc::DOMAttr* const attribute
                                                   >> 1234             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1235       if (!attribute)
                                                   >> 1236       {
                                                   >> 1237         G4Exception("G4GDMLReadSolids::ReflectedSolidRead()",
                                                   >> 1238                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1239         return;
                                                   >> 1240       }
                                                   >> 1241       const G4String attName = Transcode(attribute->getName());
                                                   >> 1242       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1243 
                                                   >> 1244       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 1245       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1246       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1247       if (attName=="solid") { solid = GenerateName(attValue); } else
                                                   >> 1248       if (attName=="sx") { scale.setX(eval.Evaluate(attValue)); } else
                                                   >> 1249       if (attName=="sy") { scale.setY(eval.Evaluate(attValue)); } else
                                                   >> 1250       if (attName=="sz") { scale.setZ(eval.Evaluate(attValue)); } else
                                                   >> 1251       if (attName=="rx") { rotation.setX(eval.Evaluate(attValue)); } else
                                                   >> 1252       if (attName=="ry") { rotation.setY(eval.Evaluate(attValue)); } else
                                                   >> 1253       if (attName=="rz") { rotation.setZ(eval.Evaluate(attValue)); } else
                                                   >> 1254       if (attName=="dx") { position.setX(eval.Evaluate(attValue)); } else
                                                   >> 1255       if (attName=="dy") { position.setY(eval.Evaluate(attValue)); } else
                                                   >> 1256       if (attName=="dz") { position.setZ(eval.Evaluate(attValue)); }
                                                   >> 1257    }
                                                   >> 1258 
                                                   >> 1259    rotation *= aunit;
                                                   >> 1260    position *= lunit;
                                                   >> 1261 
                                                   >> 1262    G4Transform3D transform(GetRotationMatrix(rotation),position);
                                                   >> 1263    transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z());
                                                   >> 1264           
                                                   >> 1265    new G4ReflectedSolid(name,GetSolid(solid),transform);
                                                   >> 1266 }
                                                   >> 1267 
                                                   >> 1268 G4ExtrudedSolid::ZSection G4GDMLReadSolids::
                                                   >> 1269 SectionRead(const xercesc::DOMElement* const sectionElement,G4double lunit) 
                                                   >> 1270 {
                                                   >> 1271    G4double zPosition = 0.0;
                                                   >> 1272    G4TwoVector Offset;
                                                   >> 1273    G4double scalingFactor = 1.0;
                                                   >> 1274 
                                                   >> 1275    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1276          = sectionElement->getAttributes();
                                                   >> 1277    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1278 
                                                   >> 1279    for (XMLSize_t attribute_index=0;
                                                   >> 1280         attribute_index<attributeCount; attribute_index++)
                                                   >> 1281    {
                                                   >> 1282       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1283 
                                                   >> 1284       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1285         { continue; }
                                                   >> 1286 
                                                   >> 1287       const xercesc::DOMAttr* const attribute
                                                   >> 1288             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1289       if (!attribute)
                                                   >> 1290       {
                                                   >> 1291         G4Exception("G4GDMLReadSolids::SectionRead()",
                                                   >> 1292                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1293         return G4ExtrudedSolid::ZSection(zPosition,Offset,scalingFactor);
                                                   >> 1294       }
                                                   >> 1295       const G4String attName = Transcode(attribute->getName());
                                                   >> 1296       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1297 
                                                   >> 1298       if (attName=="zPosition")
                                                   >> 1299         { zPosition = eval.Evaluate(attValue)*lunit; } else
                                                   >> 1300       if (attName=="xOffset")
                                                   >> 1301         { Offset.setX(eval.Evaluate(attValue)*lunit); } else
                                                   >> 1302       if (attName=="yOffset")
                                                   >> 1303         { Offset.setY(eval.Evaluate(attValue)*lunit); } else
                                                   >> 1304       if (attName=="scalingFactor")
                                                   >> 1305         { scalingFactor = eval.Evaluate(attValue); }
                                                   >> 1306    }
                                                   >> 1307 
                                                   >> 1308    return G4ExtrudedSolid::ZSection(zPosition,Offset,scalingFactor);
                                                   >> 1309 }
                                                   >> 1310 
                                                   >> 1311 void G4GDMLReadSolids::
                                                   >> 1312 SphereRead(const xercesc::DOMElement* const sphereElement)
                                                   >> 1313 {
                                                   >> 1314    G4String name;
                                                   >> 1315    G4double lunit = 1.0;
                                                   >> 1316    G4double aunit = 1.0;
                                                   >> 1317    G4double rmin = 0.0;
                                                   >> 1318    G4double rmax = 0.0;
                                                   >> 1319    G4double startphi = 0.0;
                                                   >> 1320    G4double deltaphi = 0.0;
                                                   >> 1321    G4double starttheta = 0.0;
                                                   >> 1322    G4double deltatheta = 0.0;
                                                   >> 1323 
                                                   >> 1324    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1325          = sphereElement->getAttributes();
                                                   >> 1326    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1327 
                                                   >> 1328    for (XMLSize_t attribute_index=0;
                                                   >> 1329         attribute_index<attributeCount; attribute_index++)
                                                   >> 1330    {
                                                   >> 1331       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1332 
                                                   >> 1333       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1334         { continue; }
                                                   >> 1335 
                                                   >> 1336       const xercesc::DOMAttr* const attribute
                                                   >> 1337             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1338       if (!attribute)
                                                   >> 1339       {
                                                   >> 1340         G4Exception("G4GDMLReadSolids::SphereRead()",
                                                   >> 1341                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1342         return;
                                                   >> 1343       }
                                                   >> 1344       const G4String attName = Transcode(attribute->getName());
                                                   >> 1345       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1346 
                                                   >> 1347       if (attName=="name") { name = GenerateName(attValue); } else
                                                   >> 1348       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1349       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
                                                   >> 1350       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
                                                   >> 1351       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
                                                   >> 1352       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
                                                   >> 1353       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
                                                   >> 1354       if (attName=="starttheta") { starttheta = eval.Evaluate(attValue); } else
                                                   >> 1355       if (attName=="deltatheta") { deltatheta = eval.Evaluate(attValue); }
                                                   >> 1356    }
                                                   >> 1357 
                                                   >> 1358    rmin *= lunit;
                                                   >> 1359    rmax *= lunit;
                                                   >> 1360    startphi *= aunit;
                                                   >> 1361    deltaphi *= aunit;
                                                   >> 1362    starttheta *= aunit;
                                                   >> 1363    deltatheta *= aunit;
                                                   >> 1364 
                                                   >> 1365    new G4Sphere(name,rmin,rmax,startphi,deltaphi,starttheta,deltatheta);
                                                   >> 1366 }
                                                   >> 1367 
                                                   >> 1368 void G4GDMLReadSolids::
                                                   >> 1369 TessellatedRead(const xercesc::DOMElement* const tessellatedElement)
                                                   >> 1370 {
                                                   >> 1371    G4String name;
                                                   >> 1372 
                                                   >> 1373    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 1374          = tessellatedElement->getAttributes();
                                                   >> 1375    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 1376 
                                                   >> 1377    for (XMLSize_t attribute_index=0;
                                                   >> 1378         attribute_index<attributeCount; attribute_index++)
                                                   >> 1379    {
                                                   >> 1380       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 1381 
                                                   >> 1382       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 1383         { continue; }
                                                   >> 1384 
                                                   >> 1385       const xercesc::DOMAttr* const attribute
                                                   >> 1386             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 1387       if (!attribute)
                                                   >> 1388       {
                                                   >> 1389         G4Exception("G4GDMLReadSolids::TessellatedRead()",
                                                   >> 1390                     "InvalidRead", FatalException, "No attribute found!");
                                                   >> 1391         return;
                                                   >> 1392       }
                                                   >> 1393       const G4String attName = Transcode(attribute->getName());
                                                   >> 1394       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 1395 
                                                   >> 1396       if (attName=="name")  { name = GenerateName(attValue); }
                                                   >> 1397    }
                                                   >> 1398    
                                                   >> 1399    G4TessellatedSolid *tessellated = new G4TessellatedSolid(name);
                                                   >> 1400 
                                                   >> 1401    for (xercesc::DOMNode* iter = tessellatedElement->getFirstChild();
                                                   >> 1402         iter != 0; iter = iter->getNextSibling())
                                                   >> 1403    {
                                                   >> 1404       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
                                                   >> 1405 
                                                   >> 1406       const xercesc::DOMElement* const child
                                                   >> 1407             = dynamic_cast<xercesc::DOMElement*>(iter);
                                                   >> 1408       if (!child)
                                                   >> 1409       {
                                                   >> 1410         G4Exception("G4GDMLReadSolids::TessellatedRead()",
                                                   >> 1411                     "InvalidRead", FatalException, "No child found!");
                                                   >> 1412         return;
                                                   >> 1413       }
                                                   >> 1414       const G4String tag = Transcode(child->getTagName());
                                                   >> 1415 
                                                   >> 1416       if (tag=="triangular")
                                                   >> 1417         { tessellated->AddFacet(TriangularRead(child)); } else
                                                   >> 1418       if (tag=="quadrangular")
                                                   >> 1419         { tessellated->AddFacet(QuadrangularRead(child)); }
                                                   >> 1420    }
2059                                                  1421 
2060   const xercesc::DOMNamedNodeMap* const attri << 1422    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 }                                                1423 }
2123                                                  1424 
2124 // ------------------------------------------ << 
2125 void G4GDMLReadSolids::TetRead(const xercesc:    1425 void G4GDMLReadSolids::TetRead(const xercesc::DOMElement* const tetElement)
2126 {                                                1426 {
2127   G4String name;                              << 1427    G4String name;
2128   G4ThreeVector vertex1;                      << 1428    G4ThreeVector vertex1;
2129   G4ThreeVector vertex2;                      << 1429    G4ThreeVector vertex2;
2130   G4ThreeVector vertex3;                      << 1430    G4ThreeVector vertex3;
2131   G4ThreeVector vertex4;                      << 1431    G4ThreeVector vertex4;
2132   G4double lunit = 1.0;                       << 1432    G4double lunit = 1.0;
2133                                               << 1433    
2134   const xercesc::DOMNamedNodeMap* const attri << 1434    const xercesc::DOMNamedNodeMap* const attributes
2135     tetElement->getAttributes();              << 1435          = tetElement->getAttributes();
2136   XMLSize_t attributeCount = attributes->getL << 1436    XMLSize_t attributeCount = attributes->getLength();
2137                                               << 1437 
2138   for(XMLSize_t attribute_index = 0; attribut << 1438    for (XMLSize_t attribute_index=0;
2139       ++attribute_index)                      << 1439         attribute_index<attributeCount;attribute_index++)
2140   {                                           << 1440    {
2141     xercesc::DOMNode* attribute_node = attrib << 1441       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2142                                               << 1442 
2143     if(attribute_node->getNodeType() != xerce << 1443       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2144     {                                         << 1444         { continue; }
2145       continue;                               << 1445 
2146     }                                         << 1446       const xercesc::DOMAttr* const attribute
2147                                               << 1447             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2148     const xercesc::DOMAttr* const attribute = << 1448       if (!attribute)
2149       dynamic_cast<xercesc::DOMAttr*>(attribu << 1449       {
2150     if(attribute == nullptr)                  << 1450         G4Exception("G4GDMLReadSolids::TetRead()",
2151     {                                         << 1451                     "InvalidRead", FatalException, "No attribute found!");
2152       G4Exception("G4GDMLReadSolids::TetRead( << 1452         return;
2153                   "No attribute found!");     << 1453       }
2154       return;                                 << 1454       const G4String attName = Transcode(attribute->getName());
2155     }                                         << 1455       const G4String attValue = Transcode(attribute->getValue());
2156     const G4String attName  = Transcode(attri << 1456 
2157     const G4String attValue = Transcode(attri << 1457       if (attName=="name")
2158                                               << 1458         { name = GenerateName(attValue); } else
2159     if(attName == "name")                     << 1459       if (attName=="lunit")
2160     {                                         << 1460         { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2161       name = GenerateName(attValue);          << 1461       if (attName=="vertex1")
2162     }                                         << 1462         { vertex1 = GetPosition(GenerateName(attValue)); } else
2163     else if(attName == "lunit")               << 1463       if (attName=="vertex2")
2164     {                                         << 1464         { vertex2 = GetPosition(GenerateName(attValue)); } else
2165       lunit = G4UnitDefinition::GetValueOf(at << 1465       if (attName=="vertex3")
2166       if(G4UnitDefinition::GetCategory(attVal << 1466         { vertex3 = GetPosition(GenerateName(attValue)); } else
2167       {                                       << 1467       if (attName=="vertex4")
2168         G4Exception("G4GDMLReadSolids::TetRea << 1468         { vertex4 = GetPosition(GenerateName(attValue)); }
2169                     FatalException, "Invalid  << 1469    }
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                                                  1470 
2190   new G4Tet(name, vertex1 * lunit, vertex2 *  << 1471    new G4Tet(name,vertex1*lunit,vertex2*lunit,vertex3*lunit,vertex4*lunit);
2191             vertex4 * lunit);                 << 
2192 }                                                1472 }
2193                                                  1473 
2194 // ------------------------------------------ << 
2195 void G4GDMLReadSolids::TorusRead(const xerces    1474 void G4GDMLReadSolids::TorusRead(const xercesc::DOMElement* const torusElement)
2196 {                                                1475 {
2197   G4String name;                              << 1476    G4String name;
2198   G4double lunit    = 1.0;                    << 1477    G4double lunit = 1.0;
2199   G4double aunit    = 1.0;                    << 1478    G4double aunit = 1.0;
2200   G4double rmin     = 0.0;                    << 1479    G4double rmin = 0.0;
2201   G4double rmax     = 0.0;                    << 1480    G4double rmax = 0.0;
2202   G4double rtor     = 0.0;                    << 1481    G4double rtor = 0.0;
2203   G4double startphi = 0.0;                    << 1482    G4double startphi = 0.0;
2204   G4double deltaphi = 0.0;                    << 1483    G4double deltaphi = 0.0;
2205                                               << 1484 
2206   const xercesc::DOMNamedNodeMap* const attri << 1485    const xercesc::DOMNamedNodeMap* const attributes
2207     torusElement->getAttributes();            << 1486          = torusElement->getAttributes();
2208   XMLSize_t attributeCount = attributes->getL << 1487    XMLSize_t attributeCount = attributes->getLength();
2209                                               << 1488 
2210   for(XMLSize_t attribute_index = 0; attribut << 1489    for (XMLSize_t attribute_index=0;
2211       ++attribute_index)                      << 1490         attribute_index<attributeCount; attribute_index++)
2212   {                                           << 1491    {
2213     xercesc::DOMNode* attribute_node = attrib << 1492       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2214                                               << 1493 
2215     if(attribute_node->getNodeType() != xerce << 1494       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2216     {                                         << 1495         { continue; }
2217       continue;                               << 1496 
2218     }                                         << 1497       const xercesc::DOMAttr* const attribute
2219                                               << 1498             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2220     const xercesc::DOMAttr* const attribute = << 1499       if (!attribute)
2221       dynamic_cast<xercesc::DOMAttr*>(attribu << 1500       {
2222     if(attribute == nullptr)                  << 1501         G4Exception("G4GDMLReadSolids::TorusRead()",
2223     {                                         << 1502                     "InvalidRead", FatalException, "No attribute found!");
2224       G4Exception("G4GDMLReadSolids::TorusRea << 1503         return;
2225                   FatalException, "No attribu << 1504       }
2226       return;                                 << 1505       const G4String attName = Transcode(attribute->getName());
2227     }                                         << 1506       const G4String attValue = Transcode(attribute->getValue());
2228     const G4String attName  = Transcode(attri << 1507 
2229     const G4String attValue = Transcode(attri << 1508       if (attName=="name") { name = GenerateName(attValue); } else
2230                                               << 1509       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2231     if(attName == "name")                     << 1510       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
2232     {                                         << 1511       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
2233       name = GenerateName(attValue);          << 1512       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
2234     }                                         << 1513       if (attName=="rtor") { rtor = eval.Evaluate(attValue); } else
2235     else if(attName == "lunit")               << 1514       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
2236     {                                         << 1515       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
2237       lunit = G4UnitDefinition::GetValueOf(at << 1516    }
2238       if(G4UnitDefinition::GetCategory(attVal << 1517 
2239       {                                       << 1518    rmin *= lunit;
2240         G4Exception("G4GDMLReadSolids::TorusR << 1519    rmax *= lunit;
2241                     FatalException, "Invalid  << 1520    rtor *= lunit;
2242       }                                       << 1521    startphi *= aunit;
2243     }                                         << 1522    deltaphi *= aunit;
2244     else if(attName == "aunit")               << 1523 
2245     {                                         << 1524    new G4Torus(name,rmin,rmax,rtor,startphi,deltaphi);
2246       aunit = G4UnitDefinition::GetValueOf(at << 1525 }
2247       if(G4UnitDefinition::GetCategory(attVal << 1526 
2248       {                                       << 1527 void G4GDMLReadSolids::
2249         G4Exception("G4GDMLReadSolids::TorusR << 1528 GenTrapRead(const xercesc::DOMElement* const gtrapElement)
2250                     FatalException, "Invalid  << 1529 {
2251       }                                       << 1530    G4String name;
2252     }                                         << 1531    G4double lunit = 1.0;
2253     else if(attName == "rmin")                << 1532    G4double dz =0.0;
2254     {                                         << 1533    G4double v1x=0.0, v1y=0.0, v2x=0.0, v2y=0.0, v3x=0.0, v3y=0.0,
2255       rmin = eval.Evaluate(attValue);         << 1534       v4x=0.0, v4y=0.0, v5x=0.0, v5y=0.0, v6x=0.0, v6y=0.0,
2256     }                                         << 1535       v7x=0.0, v7y=0.0, v8x=0.0, v8y=0.0;
2257     else if(attName == "rmax")                << 1536 
2258     {                                         << 1537    const xercesc::DOMNamedNodeMap* const attributes
2259       rmax = eval.Evaluate(attValue);         << 1538          = gtrapElement->getAttributes();
2260     }                                         << 1539    XMLSize_t attributeCount = attributes->getLength();
2261     else if(attName == "rtor")                << 1540 
2262     {                                         << 1541    for (XMLSize_t attribute_index=0;
2263       rtor = eval.Evaluate(attValue);         << 1542         attribute_index<attributeCount; attribute_index++)
2264     }                                         << 1543    {
2265     else if(attName == "startphi")            << 1544       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2266     {                                         << 1545 
2267       startphi = eval.Evaluate(attValue);     << 1546       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2268     }                                         << 1547         { continue; }
2269     else if(attName == "deltaphi")            << 1548 
2270     {                                         << 1549       const xercesc::DOMAttr* const attribute
2271       deltaphi = eval.Evaluate(attValue);     << 1550             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2272     }                                         << 1551       if (!attribute)
2273   }                                           << 1552       {
2274                                               << 1553         G4Exception("G4GDMLReadSolids::GenTrapRead()",
2275   rmin *= lunit;                              << 1554                     "InvalidRead", FatalException, "No attribute found!");
2276   rmax *= lunit;                              << 1555         return;
2277   rtor *= lunit;                              << 1556       }
2278   startphi *= aunit;                          << 1557       const G4String attName = Transcode(attribute->getName());
2279   deltaphi *= aunit;                          << 1558       const G4String attValue = Transcode(attribute->getValue());
2280                                               << 1559 
2281   new G4Torus(name, rmin, rmax, rtor, startph << 1560       if (attName=="name") { name = GenerateName(attValue); } else
2282 }                                             << 1561       if (attName=="lunit") { G4UnitDefinition::GetValueOf(attValue); } else
2283                                               << 1562       if (attName=="dz") { dz = eval.Evaluate(attValue); } else
2284 // ------------------------------------------ << 1563       if (attName=="v1x") { v1x = eval.Evaluate(attValue); } else
2285 void G4GDMLReadSolids::GenTrapRead(           << 1564       if (attName=="v1y") { v1y = eval.Evaluate(attValue); } else
2286   const xercesc::DOMElement* const gtrapEleme << 1565       if (attName=="v2x") { v2x = eval.Evaluate(attValue); } else
2287 {                                             << 1566       if (attName=="v2y") { v2y = eval.Evaluate(attValue); } else
2288   G4String name;                              << 1567       if (attName=="v3x") { v3x = eval.Evaluate(attValue); } else
2289   G4double lunit = 1.0;                       << 1568       if (attName=="v3y") { v3y = eval.Evaluate(attValue); } else
2290   G4double dz    = 0.0;                       << 1569       if (attName=="v4x") { v4x = eval.Evaluate(attValue); } else
2291   G4double v1x = 0.0, v1y = 0.0, v2x = 0.0, v << 1570       if (attName=="v4y") { v4y = eval.Evaluate(attValue); } else
2292            v4x = 0.0, v4y = 0.0, v5x = 0.0, v << 1571       if (attName=="v5x") { v5x = eval.Evaluate(attValue); } else
2293            v7x = 0.0, v7y = 0.0, v8x = 0.0, v << 1572       if (attName=="v5y") { v5y = eval.Evaluate(attValue); } else
2294                                               << 1573       if (attName=="v6x") { v6x = eval.Evaluate(attValue); } else
2295   const xercesc::DOMNamedNodeMap* const attri << 1574       if (attName=="v6y") { v6y = eval.Evaluate(attValue); } else
2296     gtrapElement->getAttributes();            << 1575       if (attName=="v7x") { v7x = eval.Evaluate(attValue); } else
2297   XMLSize_t attributeCount = attributes->getL << 1576       if (attName=="v7y") { v7y = eval.Evaluate(attValue); } else
2298                                               << 1577       if (attName=="v8x") { v8x = eval.Evaluate(attValue); } else
2299   for(XMLSize_t attribute_index = 0; attribut << 1578       if (attName=="v8y") { v8y = eval.Evaluate(attValue); }
2300       ++attribute_index)                      << 1579    }
2301   {                                           << 1580 
2302     xercesc::DOMNode* attribute_node = attrib << 1581    dz *= lunit;
2303                                               << 1582    std::vector<G4TwoVector> vertices;
2304     if(attribute_node->getNodeType() != xerce << 1583    vertices.push_back(G4TwoVector(v1x*lunit,v1y*lunit));
2305     {                                         << 1584    vertices.push_back(G4TwoVector(v2x*lunit,v2y*lunit));
2306       continue;                               << 1585    vertices.push_back(G4TwoVector(v3x*lunit,v3y*lunit));
2307     }                                         << 1586    vertices.push_back(G4TwoVector(v4x*lunit,v4y*lunit));
2308                                               << 1587    vertices.push_back(G4TwoVector(v5x*lunit,v5y*lunit));
2309     const xercesc::DOMAttr* const attribute = << 1588    vertices.push_back(G4TwoVector(v6x*lunit,v6y*lunit));
2310       dynamic_cast<xercesc::DOMAttr*>(attribu << 1589    vertices.push_back(G4TwoVector(v7x*lunit,v7y*lunit));
2311     if(attribute == nullptr)                  << 1590    vertices.push_back(G4TwoVector(v8x*lunit,v8y*lunit));
2312     {                                         << 1591    new G4GenericTrap(name,dz,vertices);
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 }                                                1592 }
2415                                                  1593 
2416 // ------------------------------------------ << 
2417 void G4GDMLReadSolids::TrapRead(const xercesc    1594 void G4GDMLReadSolids::TrapRead(const xercesc::DOMElement* const trapElement)
2418 {                                                1595 {
2419   G4String name;                              << 1596    G4String name;
2420   G4double lunit  = 1.0;                      << 1597    G4double lunit = 1.0;
2421   G4double aunit  = 1.0;                      << 1598    G4double aunit = 1.0;
2422   G4double z      = 0.0;                      << 1599    G4double z = 0.0;
2423   G4double theta  = 0.0;                      << 1600    G4double theta = 0.0;
2424   G4double phi    = 0.0;                      << 1601    G4double phi = 0.0;
2425   G4double y1     = 0.0;                      << 1602    G4double y1 = 0.0;
2426   G4double x1     = 0.0;                      << 1603    G4double x1 = 0.0;
2427   G4double x2     = 0.0;                      << 1604    G4double x2 = 0.0;
2428   G4double alpha1 = 0.0;                      << 1605    G4double alpha1 = 0.0;
2429   G4double y2     = 0.0;                      << 1606    G4double y2 = 0.0;
2430   G4double x3     = 0.0;                      << 1607    G4double x3 = 0.0;
2431   G4double x4     = 0.0;                      << 1608    G4double x4 = 0.0;
2432   G4double alpha2 = 0.0;                      << 1609    G4double alpha2 = 0.0;
2433                                               << 1610 
2434   const xercesc::DOMNamedNodeMap* const attri << 1611    const xercesc::DOMNamedNodeMap* const attributes
2435     trapElement->getAttributes();             << 1612          = trapElement->getAttributes();
2436   XMLSize_t attributeCount = attributes->getL << 1613    XMLSize_t attributeCount = attributes->getLength();
2437                                               << 1614 
2438   for(XMLSize_t attribute_index = 0; attribut << 1615    for (XMLSize_t attribute_index=0;
2439       ++attribute_index)                      << 1616         attribute_index<attributeCount; attribute_index++)
2440   {                                           << 1617    {
2441     xercesc::DOMNode* attribute_node = attrib << 1618       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2442                                               << 1619 
2443     if(attribute_node->getNodeType() != xerce << 1620       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2444     {                                         << 1621         { continue; }
2445       continue;                               << 1622 
2446     }                                         << 1623       const xercesc::DOMAttr* const attribute
2447                                               << 1624             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2448     const xercesc::DOMAttr* const attribute = << 1625       if (!attribute)
2449       dynamic_cast<xercesc::DOMAttr*>(attribu << 1626       {
2450     if(attribute == nullptr)                  << 1627         G4Exception("G4GDMLReadSolids::TrapRead()",
2451     {                                         << 1628                     "InvalidRead", FatalException, "No attribute found!");
2452       G4Exception("G4GDMLReadSolids::TrapRead << 1629         return;
2453                   "No attribute found!");     << 1630       }
2454       return;                                 << 1631       const G4String attName = Transcode(attribute->getName());
2455     }                                         << 1632       const G4String attValue = Transcode(attribute->getValue());
2456     const G4String attName  = Transcode(attri << 1633 
2457     const G4String attValue = Transcode(attri << 1634       if (attName=="name") { name = GenerateName(attValue); } else
2458                                               << 1635       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2459     if(attName == "name")                     << 1636       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
2460     {                                         << 1637       if (attName=="z") { z = eval.Evaluate(attValue); } else
2461       name = GenerateName(attValue);          << 1638       if (attName=="theta") { theta = eval.Evaluate(attValue); } else
2462     }                                         << 1639       if (attName=="phi") { phi = eval.Evaluate(attValue); } else
2463     else if(attName == "lunit")               << 1640       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2464     {                                         << 1641       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2465       lunit = G4UnitDefinition::GetValueOf(at << 1642       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2466       if(G4UnitDefinition::GetCategory(attVal << 1643       if (attName=="alpha1") { alpha1 = eval.Evaluate(attValue); } else
2467       {                                       << 1644       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2468         G4Exception("G4GDMLReadSolids::TrapRe << 1645       if (attName=="x3") { x3 = eval.Evaluate(attValue); } else
2469                     FatalException, "Invalid  << 1646       if (attName=="x4") { x4 = eval.Evaluate(attValue); } else
2470       }                                       << 1647       if (attName=="alpha2") { alpha2 = eval.Evaluate(attValue); }
2471     }                                         << 1648    }
2472     else if(attName == "aunit")               << 1649 
2473     {                                         << 1650    z *= 0.5*lunit;
2474       aunit = G4UnitDefinition::GetValueOf(at << 1651    theta *= aunit;
2475       if(G4UnitDefinition::GetCategory(attVal << 1652    phi *= aunit;
2476       {                                       << 1653    y1 *= 0.5*lunit;
2477         G4Exception("G4GDMLReadSolids::TrapRe << 1654    x1 *= 0.5*lunit;
2478                     FatalException, "Invalid  << 1655    x2 *= 0.5*lunit;
2479       }                                       << 1656    alpha1 *= aunit;
2480     }                                         << 1657    y2 *= 0.5*lunit;
2481     else if(attName == "z")                   << 1658    x3 *= 0.5*lunit;
2482     {                                         << 1659    x4 *= 0.5*lunit;
2483       z = eval.Evaluate(attValue);            << 1660    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                                                  1661 
2539   new G4Trap(name, z, theta, phi, y1, x1, x2, << 1662    new G4Trap(name,z,theta,phi,y1,x1,x2,alpha1,y2,x3,x4,alpha2);
2540 }                                                1663 }
2541                                                  1664 
2542 // ------------------------------------------ << 
2543 void G4GDMLReadSolids::TrdRead(const xercesc:    1665 void G4GDMLReadSolids::TrdRead(const xercesc::DOMElement* const trdElement)
2544 {                                                1666 {
2545   G4String name;                              << 1667    G4String name;
2546   G4double lunit = 1.0;                       << 1668    G4double lunit = 1.0;
2547   G4double x1    = 0.0;                       << 1669    G4double x1 = 0.0;
2548   G4double x2    = 0.0;                       << 1670    G4double x2 = 0.0;
2549   G4double y1    = 0.0;                       << 1671    G4double y1 = 0.0;
2550   G4double y2    = 0.0;                       << 1672    G4double y2 = 0.0;
2551   G4double z     = 0.0;                       << 1673    G4double z = 0.0;
2552                                               << 1674 
2553   const xercesc::DOMNamedNodeMap* const attri << 1675    const xercesc::DOMNamedNodeMap* const attributes = trdElement->getAttributes();
2554     trdElement->getAttributes();              << 1676    XMLSize_t attributeCount = attributes->getLength();
2555   XMLSize_t attributeCount = attributes->getL << 1677 
2556                                               << 1678    for (XMLSize_t attribute_index=0;
2557   for(XMLSize_t attribute_index = 0; attribut << 1679         attribute_index<attributeCount; attribute_index++)
2558       ++attribute_index)                      << 1680    {
2559   {                                           << 1681       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2560     xercesc::DOMNode* attribute_node = attrib << 1682 
2561                                               << 1683       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2562     if(attribute_node->getNodeType() != xerce << 1684         { continue; }
2563     {                                         << 1685 
2564       continue;                               << 1686       const xercesc::DOMAttr* const attribute
2565     }                                         << 1687             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2566                                               << 1688       if (!attribute)
2567     const xercesc::DOMAttr* const attribute = << 1689       {
2568       dynamic_cast<xercesc::DOMAttr*>(attribu << 1690         G4Exception("G4GDMLReadSolids::TrdRead()",
2569     if(attribute == nullptr)                  << 1691                     "InvalidRead", FatalException, "No attribute found!");
2570     {                                         << 1692         return;
2571       G4Exception("G4GDMLReadSolids::TrdRead( << 1693       }
2572                   "No attribute found!");     << 1694       const G4String attName = Transcode(attribute->getName());
2573       return;                                 << 1695       const G4String attValue = Transcode(attribute->getValue());
2574     }                                         << 1696 
2575     const G4String attName  = Transcode(attri << 1697       if (attName=="name") { name = GenerateName(attValue); } else
2576     const G4String attValue = Transcode(attri << 1698       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2577                                               << 1699       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2578     if(attName == "name")                     << 1700       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2579     {                                         << 1701       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2580       name = GenerateName(attValue);          << 1702       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2581     }                                         << 1703       if (attName=="z") { z = eval.Evaluate(attValue); }
2582     else if(attName == "lunit")               << 1704    }
2583     {                                         << 1705 
2584       lunit = G4UnitDefinition::GetValueOf(at << 1706    x1 *= 0.5*lunit;
2585       if(G4UnitDefinition::GetCategory(attVal << 1707    x2 *= 0.5*lunit;
2586       {                                       << 1708    y1 *= 0.5*lunit;
2587         G4Exception("G4GDMLReadSolids::TrdRea << 1709    y2 *= 0.5*lunit;
2588                     FatalException, "Invalid  << 1710    z *= 0.5*lunit;
2589       }                                       << 1711 
2590     }                                         << 1712    new G4Trd(name,x1,x2,y1,y2,z);
2591     else if(attName == "x1")                  << 1713 }
2592     {                                         << 1714 
2593       x1 = eval.Evaluate(attValue);           << 1715 G4TriangularFacet* G4GDMLReadSolids::
2594     }                                         << 1716 TriangularRead(const xercesc::DOMElement* const triangularElement)
2595     else if(attName == "x2")                  << 1717 {
2596     {                                         << 1718    G4ThreeVector vertex1;
2597       x2 = eval.Evaluate(attValue);           << 1719    G4ThreeVector vertex2;
2598     }                                         << 1720    G4ThreeVector vertex3;
2599     else if(attName == "y1")                  << 1721    G4FacetVertexType type = ABSOLUTE;
2600     {                                         << 1722    G4double lunit = 1.0;
2601       y1 = eval.Evaluate(attValue);           << 1723 
2602     }                                         << 1724    const xercesc::DOMNamedNodeMap* const attributes
2603     else if(attName == "y2")                  << 1725          = triangularElement->getAttributes();
2604     {                                         << 1726    XMLSize_t attributeCount = attributes->getLength();
2605       y2 = eval.Evaluate(attValue);           << 1727 
2606     }                                         << 1728    for (XMLSize_t attribute_index=0;
2607     else if(attName == "z")                   << 1729         attribute_index<attributeCount; attribute_index++)
2608     {                                         << 1730    {
2609       z = eval.Evaluate(attValue);            << 1731       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2610     }                                         << 1732 
2611   }                                           << 1733       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2612                                               << 1734         { continue; }
2613   x1 *= 0.5 * lunit;                          << 1735 
2614   x2 *= 0.5 * lunit;                          << 1736       const xercesc::DOMAttr* const attribute
2615   y1 *= 0.5 * lunit;                          << 1737             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2616   y2 *= 0.5 * lunit;                          << 1738       if (!attribute)
2617   z *= 0.5 * lunit;                           << 1739       {
2618                                               << 1740         G4Exception("G4GDMLReadSolids::TriangularRead()",
2619   new G4Trd(name, x1, x2, y1, y2, z);         << 1741                     "InvalidRead", FatalException, "No attribute found!");
2620 }                                             << 1742         return 0;
2621                                               << 1743       }
2622 // ------------------------------------------ << 1744       const G4String attName = Transcode(attribute->getName());
2623 G4TriangularFacet* G4GDMLReadSolids::Triangul << 1745       const G4String attValue = Transcode(attribute->getValue());
2624   const xercesc::DOMElement* const triangular << 1746 
2625 {                                             << 1747       if (attName=="vertex1")
2626   G4ThreeVector vertex1;                      << 1748         { vertex1 = GetPosition(GenerateName(attValue)); } else
2627   G4ThreeVector vertex2;                      << 1749       if (attName=="vertex2")
2628   G4ThreeVector vertex3;                      << 1750         { vertex2 = GetPosition(GenerateName(attValue)); } else
2629   G4FacetVertexType type = ABSOLUTE;          << 1751       if (attName=="vertex3")
2630   G4double lunit         = 1.0;               << 1752         { vertex3 = GetPosition(GenerateName(attValue)); } else
2631                                               << 1753       if (attName=="lunit")
2632   const xercesc::DOMNamedNodeMap* const attri << 1754         { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2633     triangularElement->getAttributes();       << 1755       if (attName=="type")
2634   XMLSize_t attributeCount = attributes->getL << 1756         { if (attValue=="RELATIVE") { type = RELATIVE; } }
2635                                               << 1757    }
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                                                  1758 
2687   return new G4TriangularFacet(vertex1 * luni << 1759    return new G4TriangularFacet(vertex1*lunit,vertex2*lunit,vertex3*lunit,type);
2688                                vertex3 * luni << 
2689 }                                                1760 }
2690                                                  1761 
2691 // ------------------------------------------ << 
2692 void G4GDMLReadSolids::TubeRead(const xercesc    1762 void G4GDMLReadSolids::TubeRead(const xercesc::DOMElement* const tubeElement)
2693 {                                                1763 {
2694   G4String name;                              << 1764    G4String name;
2695   G4double lunit    = 1.0;                    << 1765    G4double lunit = 1.0;
2696   G4double aunit    = 1.0;                    << 1766    G4double aunit = 1.0;
2697   G4double rmin     = 0.0;                    << 1767    G4double rmin = 0.0;
2698   G4double rmax     = 0.0;                    << 1768    G4double rmax = 0.0;
2699   G4double z        = 0.0;                    << 1769    G4double z = 0.0;
2700   G4double startphi = 0.0;                    << 1770    G4double startphi = 0.0;
2701   G4double deltaphi = 0.0;                    << 1771    G4double deltaphi = 0.0;
2702                                               << 1772 
2703   const xercesc::DOMNamedNodeMap* const attri << 1773    const xercesc::DOMNamedNodeMap* const attributes
2704     tubeElement->getAttributes();             << 1774          = tubeElement->getAttributes();
2705   XMLSize_t attributeCount = attributes->getL << 1775    XMLSize_t attributeCount = attributes->getLength();
2706                                               << 1776 
2707   for(XMLSize_t attribute_index = 0; attribut << 1777    for (XMLSize_t attribute_index=0;
2708       ++attribute_index)                      << 1778         attribute_index<attributeCount; attribute_index++)
2709   {                                           << 1779    {
2710     xercesc::DOMNode* attribute_node = attrib << 1780       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2711                                               << 1781 
2712     if(attribute_node->getNodeType() != xerce << 1782       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2713     {                                         << 1783         { continue; }
2714       continue;                               << 1784 
2715     }                                         << 1785       const xercesc::DOMAttr* const attribute
2716                                               << 1786             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2717     const xercesc::DOMAttr* const attribute = << 1787       if (!attribute)
2718       dynamic_cast<xercesc::DOMAttr*>(attribu << 1788       {
2719     if(attribute == nullptr)                  << 1789         G4Exception("G4GDMLReadSolids::TubeRead()",
2720     {                                         << 1790                     "InvalidRead", FatalException, "No attribute found!");
2721       G4Exception("G4GDMLReadSolids::TubeRead << 1791         return;
2722                   "No attribute found!");     << 1792       }
2723       return;                                 << 1793       const G4String attName = Transcode(attribute->getName());
2724     }                                         << 1794       const G4String attValue = Transcode(attribute->getValue());
2725     const G4String attName  = Transcode(attri << 1795 
2726     const G4String attValue = Transcode(attri << 1796       if (attName=="name") { name = GenerateName(attValue); } else
2727                                               << 1797       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2728     if(attName == "name")                     << 1798       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
2729     {                                         << 1799       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
2730       name = GenerateName(attValue);          << 1800       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
2731     }                                         << 1801       if (attName=="z") { z = eval.Evaluate(attValue); } else
2732     else if(attName == "lunit")               << 1802       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
2733     {                                         << 1803       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
2734       lunit = G4UnitDefinition::GetValueOf(at << 1804    }
2735       if(G4UnitDefinition::GetCategory(attVal << 1805 
2736       {                                       << 1806    rmin *= lunit;
2737         G4Exception("G4GDMLReadSolids::TubeRe << 1807    rmax *= lunit;
2738                     FatalException, "Invalid  << 1808    z *= 0.5*lunit;
2739       }                                       << 1809    startphi *= aunit;
2740     }                                         << 1810    deltaphi *= aunit;
2741     else if(attName == "aunit")               << 1811 
2742     {                                         << 1812    new G4Tubs(name,rmin,rmax,z,startphi,deltaphi);
2743       aunit = G4UnitDefinition::GetValueOf(at << 1813 }
2744       if(G4UnitDefinition::GetCategory(attVal << 1814 
2745       {                                       << 1815 void G4GDMLReadSolids::CutTubeRead(const xercesc::DOMElement* const cuttubeElement)
2746         G4Exception("G4GDMLReadSolids::TubeRe << 1816 {
2747                     FatalException, "Invalid  << 1817    G4String name;
2748       }                                       << 1818    G4double lunit = 1.0;
2749     }                                         << 1819    G4double aunit = 1.0;
2750     else if(attName == "rmin")                << 1820    G4double rmin = 0.0;
2751     {                                         << 1821    G4double rmax = 0.0;
2752       rmin = eval.Evaluate(attValue);         << 1822    G4double z = 0.0;
2753     }                                         << 1823    G4double startphi = 0.0;
2754     else if(attName == "rmax")                << 1824    G4double deltaphi = 0.0;
2755     {                                         << 1825    G4ThreeVector lowNorm(0);
2756       rmax = eval.Evaluate(attValue);         << 1826    G4ThreeVector highNorm(0);
2757     }                                         << 1827 
2758     else if(attName == "z")                   << 1828    const xercesc::DOMNamedNodeMap* const attributes
2759     {                                         << 1829          = cuttubeElement->getAttributes();
2760       z = eval.Evaluate(attValue);            << 1830    XMLSize_t attributeCount = attributes->getLength();
2761     }                                         << 1831 
2762     else if(attName == "startphi")            << 1832    for (XMLSize_t attribute_index=0;
2763     {                                         << 1833         attribute_index<attributeCount; attribute_index++)
2764       startphi = eval.Evaluate(attValue);     << 1834    {
2765     }                                         << 1835       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2766     else if(attName == "deltaphi")            << 1836 
2767     {                                         << 1837       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2768       deltaphi = eval.Evaluate(attValue);     << 1838         { continue; }
2769     }                                         << 1839 
2770   }                                           << 1840       const xercesc::DOMAttr* const attribute
2771                                               << 1841             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2772   rmin *= lunit;                              << 1842       if (!attribute)
2773   rmax *= lunit;                              << 1843       {
2774   z *= 0.5 * lunit;                           << 1844         G4Exception("G4GDMLReadSolids::CutTubeRead()",
2775   startphi *= aunit;                          << 1845                     "InvalidRead", FatalException, "No attribute found!");
2776   deltaphi *= aunit;                          << 1846         return;
2777                                               << 1847       }
2778   new G4Tubs(name, rmin, rmax, z, startphi, d << 1848       const G4String attName = Transcode(attribute->getName());
2779 }                                             << 1849       const G4String attValue = Transcode(attribute->getValue());
2780                                               << 1850 
2781 // ------------------------------------------ << 1851       if (attName=="name") { name = GenerateName(attValue); } else
2782 void G4GDMLReadSolids::CutTubeRead(           << 1852       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2783   const xercesc::DOMElement* const cuttubeEle << 1853       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
2784 {                                             << 1854       if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
2785   G4String name;                              << 1855       if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
2786   G4double lunit    = 1.0;                    << 1856       if (attName=="z") { z = eval.Evaluate(attValue); } else
2787   G4double aunit    = 1.0;                    << 1857       if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
2788   G4double rmin     = 0.0;                    << 1858       if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
2789   G4double rmax     = 0.0;                    << 1859       if (attName=="lowX") { lowNorm.setX (eval.Evaluate(attValue)); } else
2790   G4double z        = 0.0;                    << 1860       if (attName=="lowY") { lowNorm.setY (eval.Evaluate(attValue)); } else
2791   G4double startphi = 0.0;                    << 1861       if (attName=="lowZ") { lowNorm.setZ (eval.Evaluate(attValue)); } else
2792   G4double deltaphi = 0.0;                    << 1862       if (attName=="highX") { highNorm.setX (eval.Evaluate(attValue)); } else
2793   G4ThreeVector lowNorm(0);                   << 1863       if (attName=="highY") { highNorm.setY (eval.Evaluate(attValue)); } else
2794   G4ThreeVector highNorm(0);                  << 1864       if (attName=="highZ") { highNorm.setZ (eval.Evaluate(attValue)); } 
2795                                               << 1865    
2796   const xercesc::DOMNamedNodeMap* const attri << 1866    }
2797     cuttubeElement->getAttributes();          << 1867 
2798   XMLSize_t attributeCount = attributes->getL << 1868    rmin *= lunit;
2799                                               << 1869    rmax *= lunit;
2800   for(XMLSize_t attribute_index = 0; attribut << 1870    z *= 0.5*lunit;
2801       ++attribute_index)                      << 1871    startphi *= aunit;
2802   {                                           << 1872    deltaphi *= aunit;
2803     xercesc::DOMNode* attribute_node = attrib << 1873 
2804                                               << 1874    new G4CutTubs(name,rmin,rmax,z,startphi,deltaphi,lowNorm,highNorm);
2805     if(attribute_node->getNodeType() != xerce << 1875 }
2806     {                                         << 1876 
2807       continue;                               << 1877 void G4GDMLReadSolids::
2808     }                                         << 1878 TwistedboxRead(const xercesc::DOMElement* const twistedboxElement)
2809                                               << 1879 {
2810     const xercesc::DOMAttr* const attribute = << 1880    G4String name;
2811       dynamic_cast<xercesc::DOMAttr*>(attribu << 1881    G4double lunit = 1.0;
2812     if(attribute == nullptr)                  << 1882    G4double aunit = 1.0;
2813     {                                         << 1883    G4double PhiTwist = 0.0;
2814       G4Exception("G4GDMLReadSolids::CutTubeR << 1884    G4double x = 0.0;
2815                   FatalException, "No attribu << 1885    G4double y = 0.0;
2816       return;                                 << 1886    G4double z = 0.0;
2817     }                                         << 1887 
2818     const G4String attName  = Transcode(attri << 1888    const xercesc::DOMNamedNodeMap* const attributes
2819     const G4String attValue = Transcode(attri << 1889          = twistedboxElement->getAttributes();
2820                                               << 1890    XMLSize_t attributeCount = attributes->getLength();
2821     if(attName == "name")                     << 1891 
2822     {                                         << 1892    for (XMLSize_t attribute_index=0;
2823       name = GenerateName(attValue);          << 1893         attribute_index<attributeCount; attribute_index++)
2824     }                                         << 1894    {
2825     else if(attName == "lunit")               << 1895       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2826     {                                         << 1896 
2827       lunit = G4UnitDefinition::GetValueOf(at << 1897       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2828       if(G4UnitDefinition::GetCategory(attVal << 1898         { continue; }
2829       {                                       << 1899 
2830         G4Exception("G4GDMLReadSolids::CutTub << 1900       const xercesc::DOMAttr* const attribute
2831                     FatalException, "Invalid  << 1901             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2832       }                                       << 1902       if (!attribute)
2833     }                                         << 1903       {
2834     else if(attName == "aunit")               << 1904         G4Exception("G4GDMLReadSolids::TwistedboxRead()",
2835     {                                         << 1905                     "InvalidRead", FatalException, "No attribute found!");
2836       aunit = G4UnitDefinition::GetValueOf(at << 1906         return;
2837       if(G4UnitDefinition::GetCategory(attVal << 1907       }
2838       {                                       << 1908       const G4String attName = Transcode(attribute->getName());
2839         G4Exception("G4GDMLReadSolids::CutTub << 1909       const G4String attValue = Transcode(attribute->getValue());
2840                     FatalException, "Invalid  << 1910 
2841       }                                       << 1911       if (attName=="name") { name = GenerateName(attValue); } else
2842     }                                         << 1912       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2843     else if(attName == "rmin")                << 1913       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
2844     {                                         << 1914       if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else
2845       rmin = eval.Evaluate(attValue);         << 1915       if (attName=="x") { x = eval.Evaluate(attValue); } else
2846     }                                         << 1916       if (attName=="y") { y = eval.Evaluate(attValue); } else
2847     else if(attName == "rmax")                << 1917       if (attName=="z") { z = eval.Evaluate(attValue); }
2848     {                                         << 1918    }
2849       rmax = eval.Evaluate(attValue);         << 1919 
2850     }                                         << 1920    PhiTwist *= aunit;
2851     else if(attName == "z")                   << 1921    x *= 0.5*lunit;
2852     {                                         << 1922    y *= 0.5*lunit;
2853       z = eval.Evaluate(attValue);            << 1923    z *= 0.5*lunit;
2854     }                                         << 1924 
2855     else if(attName == "startphi")            << 1925    new G4TwistedBox(name,PhiTwist,x,y,z);
2856     {                                         << 1926 }
2857       startphi = eval.Evaluate(attValue);     << 1927 
2858     }                                         << 1928 void G4GDMLReadSolids::
2859     else if(attName == "deltaphi")            << 1929 TwistedtrapRead(const xercesc::DOMElement* const twistedtrapElement)
2860     {                                         << 1930 {
2861       deltaphi = eval.Evaluate(attValue);     << 1931    G4String name;
2862     }                                         << 1932    G4double lunit = 1.0;
2863     else if(attName == "lowX")                << 1933    G4double aunit = 1.0;
2864     {                                         << 1934    G4double PhiTwist = 0.0;
2865       lowNorm.setX(eval.Evaluate(attValue));  << 1935    G4double z = 0.0;
2866     }                                         << 1936    G4double Theta = 0.0;
2867     else if(attName == "lowY")                << 1937    G4double Phi = 0.0;
2868     {                                         << 1938    G4double y1 = 0.0;
2869       lowNorm.setY(eval.Evaluate(attValue));  << 1939    G4double x1 = 0.0;
2870     }                                         << 1940    G4double x2 = 0.0;
2871     else if(attName == "lowZ")                << 1941    G4double y2 = 0.0;
2872     {                                         << 1942    G4double x3 = 0.0;
2873       lowNorm.setZ(eval.Evaluate(attValue));  << 1943    G4double x4 = 0.0;
2874     }                                         << 1944    G4double Alph = 0.0;
2875     else if(attName == "highX")               << 1945 
2876     {                                         << 1946    const xercesc::DOMNamedNodeMap* const attributes
2877       highNorm.setX(eval.Evaluate(attValue)); << 1947          = twistedtrapElement->getAttributes();
2878     }                                         << 1948    XMLSize_t attributeCount = attributes->getLength();
2879     else if(attName == "highY")               << 1949 
2880     {                                         << 1950    for (XMLSize_t attribute_index=0;
2881       highNorm.setY(eval.Evaluate(attValue)); << 1951         attribute_index<attributeCount; attribute_index++)
2882     }                                         << 1952    {
2883     else if(attName == "highZ")               << 1953       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2884     {                                         << 1954 
2885       highNorm.setZ(eval.Evaluate(attValue)); << 1955       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2886     }                                         << 1956         { continue; }
2887   }                                           << 1957 
2888                                               << 1958       const xercesc::DOMAttr* const attribute
2889   rmin *= lunit;                              << 1959             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2890   rmax *= lunit;                              << 1960       if (!attribute)
2891   z *= 0.5 * lunit;                           << 1961       {
2892   startphi *= aunit;                          << 1962         G4Exception("G4GDMLReadSolids::TwistedtrapRead()",
2893   deltaphi *= aunit;                          << 1963                     "InvalidRead", FatalException, "No attribute found!");
2894                                               << 1964         return;
2895   new G4CutTubs(name, rmin, rmax, z, startphi << 1965       }
2896 }                                             << 1966       const G4String attName = Transcode(attribute->getName());
2897                                               << 1967       const G4String attValue = Transcode(attribute->getValue());
2898 // ------------------------------------------ << 1968 
2899 void G4GDMLReadSolids::TwistedboxRead(        << 1969       if (attName=="name") { name = GenerateName(attValue); } else
2900   const xercesc::DOMElement* const twistedbox << 1970       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2901 {                                             << 1971       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
2902   G4String name;                              << 1972       if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else
2903   G4double lunit    = 1.0;                    << 1973       if (attName=="z") { z = eval.Evaluate(attValue); } else
2904   G4double aunit    = 1.0;                    << 1974       if (attName=="Theta") { Theta = eval.Evaluate(attValue); } else
2905   G4double PhiTwist = 0.0;                    << 1975       if (attName=="Phi") { Phi = eval.Evaluate(attValue); } else
2906   G4double x        = 0.0;                    << 1976       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2907   G4double y        = 0.0;                    << 1977       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2908   G4double z        = 0.0;                    << 1978       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2909                                               << 1979       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2910   const xercesc::DOMNamedNodeMap* const attri << 1980       if (attName=="x3") { x3 = eval.Evaluate(attValue); } else
2911     twistedboxElement->getAttributes();       << 1981       if (attName=="x4") { x4 = eval.Evaluate(attValue); } else
2912   XMLSize_t attributeCount = attributes->getL << 1982       if (attName=="Alph") { Alph = eval.Evaluate(attValue); }
2913                                               << 1983    }
2914   for(XMLSize_t attribute_index = 0; attribut << 1984 
2915       ++attribute_index)                      << 1985 
2916   {                                           << 1986    PhiTwist *= aunit;
2917     xercesc::DOMNode* attribute_node = attrib << 1987    z *= 0.5*lunit;
2918                                               << 1988    Theta *= aunit;
2919     if(attribute_node->getNodeType() != xerce << 1989    Phi *= aunit;
2920     {                                         << 1990    Alph *= aunit;
2921       continue;                               << 1991    y1 *= 0.5*lunit;
2922     }                                         << 1992    x1 *= 0.5*lunit;
2923                                               << 1993    x2 *= 0.5*lunit;
2924     const xercesc::DOMAttr* const attribute = << 1994    y2 *= 0.5*lunit;
2925       dynamic_cast<xercesc::DOMAttr*>(attribu << 1995    x3 *= 0.5*lunit;
2926     if(attribute == nullptr)                  << 1996    x4 *= 0.5*lunit;
2927     {                                         << 1997 
2928       G4Exception("G4GDMLReadSolids::Twistedb << 1998    new G4TwistedTrap(name,PhiTwist,z,Theta,Phi,y1,x1,x2,y2,x3,x4,Alph);
2929                   FatalException, "No attribu << 1999 }
2930       return;                                 << 2000 
2931     }                                         << 2001 void G4GDMLReadSolids::
2932     const G4String attName  = Transcode(attri << 2002 TwistedtrdRead(const xercesc::DOMElement* const twistedtrdElement)
2933     const G4String attValue = Transcode(attri << 2003 {
2934                                               << 2004    G4String name;
2935     if(attName == "name")                     << 2005    G4double lunit = 1.0;
2936     {                                         << 2006    G4double aunit = 1.0;
2937       name = GenerateName(attValue);          << 2007    G4double x1 = 0.0;
2938     }                                         << 2008    G4double x2 = 0.0;
2939     else if(attName == "lunit")               << 2009    G4double y1 = 0.0;
2940     {                                         << 2010    G4double y2 = 0.0;
2941       lunit = G4UnitDefinition::GetValueOf(at << 2011    G4double z = 0.0;
2942       if(G4UnitDefinition::GetCategory(attVal << 2012    G4double PhiTwist = 0.0;
2943       {                                       << 2013 
2944         G4Exception("G4GDMLReadSolids::Twiste << 2014    const xercesc::DOMNamedNodeMap* const attributes
2945                     FatalException, "Invalid  << 2015          = twistedtrdElement->getAttributes();
2946       }                                       << 2016    XMLSize_t attributeCount = attributes->getLength();
2947     }                                         << 2017 
2948     else if(attName == "aunit")               << 2018    for (XMLSize_t attribute_index=0;
2949     {                                         << 2019         attribute_index<attributeCount; attribute_index++)
2950       aunit = G4UnitDefinition::GetValueOf(at << 2020    {
2951       if(G4UnitDefinition::GetCategory(attVal << 2021       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2952       {                                       << 2022 
2953         G4Exception("G4GDMLReadSolids::Twiste << 2023       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2954                     FatalException, "Invalid  << 2024         { continue; }
2955       }                                       << 2025 
2956     }                                         << 2026       const xercesc::DOMAttr* const attribute
2957     else if(attName == "PhiTwist")            << 2027             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
2958     {                                         << 2028       if (!attribute)
2959       PhiTwist = eval.Evaluate(attValue);     << 2029       {
2960     }                                         << 2030         G4Exception("G4GDMLReadSolids::TwistedtrdRead()",
2961     else if(attName == "x")                   << 2031                     "InvalidRead", FatalException, "No attribute found!");
2962     {                                         << 2032         return;
2963       x = eval.Evaluate(attValue);            << 2033       }
2964     }                                         << 2034       const G4String attName = Transcode(attribute->getName());
2965     else if(attName == "y")                   << 2035       const G4String attValue = Transcode(attribute->getValue());
2966     {                                         << 2036 
2967       y = eval.Evaluate(attValue);            << 2037       if (attName=="name") { name = GenerateName(attValue); } else
2968     }                                         << 2038       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
2969     else if(attName == "z")                   << 2039       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
2970     {                                         << 2040       if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2971       z = eval.Evaluate(attValue);            << 2041       if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2972     }                                         << 2042       if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2973   }                                           << 2043       if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2974                                               << 2044       if (attName=="z") { z = eval.Evaluate(attValue); } else
2975   PhiTwist *= aunit;                          << 2045       if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); }
2976   x *= 0.5 * lunit;                           << 2046    }
2977   y *= 0.5 * lunit;                           << 2047 
2978   z *= 0.5 * lunit;                           << 2048    x1 *= 0.5*lunit;
2979                                               << 2049    x2 *= 0.5*lunit;
2980   new G4TwistedBox(name, PhiTwist, x, y, z);  << 2050    y1 *= 0.5*lunit;
2981 }                                             << 2051    y2 *= 0.5*lunit;
2982                                               << 2052    z *= 0.5*lunit;
2983 // ------------------------------------------ << 2053    PhiTwist *= aunit;
2984 void G4GDMLReadSolids::TwistedtrapRead(       << 2054 
2985   const xercesc::DOMElement* const twistedtra << 2055    new G4TwistedTrd(name,x1,x2,y1,y2,z,PhiTwist);
2986 {                                             << 2056 }
2987   G4String name;                              << 2057 
2988   G4double lunit    = 1.0;                    << 2058 void G4GDMLReadSolids::
2989   G4double aunit    = 1.0;                    << 2059 TwistedtubsRead(const xercesc::DOMElement* const twistedtubsElement)
2990   G4double PhiTwist = 0.0;                    << 2060 {
2991   G4double z        = 0.0;                    << 2061    G4String name;
2992   G4double Theta    = 0.0;                    << 2062    G4double lunit = 1.0;
2993   G4double Phi      = 0.0;                    << 2063    G4double aunit = 1.0;
2994   G4double y1       = 0.0;                    << 2064    G4double twistedangle = 0.0;
2995   G4double x1       = 0.0;                    << 2065    G4double endinnerrad = 0.0;
2996   G4double x2       = 0.0;                    << 2066    G4double endouterrad = 0.0;
2997   G4double y2       = 0.0;                    << 2067    G4double zlen = 0.0;
2998   G4double x3       = 0.0;                    << 2068    G4double phi = 0.0;
2999   G4double x4       = 0.0;                    << 2069 
3000   G4double Alph     = 0.0;                    << 2070    const xercesc::DOMNamedNodeMap* const attributes
3001                                               << 2071          = twistedtubsElement->getAttributes();
3002   const xercesc::DOMNamedNodeMap* const attri << 2072    XMLSize_t attributeCount = attributes->getLength();
3003     twistedtrapElement->getAttributes();      << 2073 
3004   XMLSize_t attributeCount = attributes->getL << 2074    for (XMLSize_t attribute_index=0;
3005                                               << 2075         attribute_index<attributeCount; attribute_index++)
3006   for(XMLSize_t attribute_index = 0; attribut << 2076    {
3007       ++attribute_index)                      << 2077       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3008   {                                           << 2078 
3009     xercesc::DOMNode* attribute_node = attrib << 2079       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3010                                               << 2080         { continue; }
3011     if(attribute_node->getNodeType() != xerce << 2081 
3012     {                                         << 2082       const xercesc::DOMAttr* const attribute
3013       continue;                               << 2083             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
3014     }                                         << 2084       if (!attribute)
3015                                               << 2085       {
3016     const xercesc::DOMAttr* const attribute = << 2086         G4Exception("G4GDMLReadSolids::TwistedtubsRead()",
3017       dynamic_cast<xercesc::DOMAttr*>(attribu << 2087                     "InvalidRead", FatalException, "No attribute found!");
3018     if(attribute == nullptr)                  << 2088         return;
3019     {                                         << 2089       }
3020       G4Exception("G4GDMLReadSolids::Twistedt << 2090       const G4String attName = Transcode(attribute->getName());
3021                   FatalException, "No attribu << 2091       const G4String attValue = Transcode(attribute->getValue());
3022       return;                                 << 2092 
3023     }                                         << 2093       if (attName=="name") { name = GenerateName(attValue); } else
3024     const G4String attName  = Transcode(attri << 2094       if (attName=="lunit") { lunit = G4UnitDefinition::GetValueOf(attValue); } else
3025     const G4String attValue = Transcode(attri << 2095       if (attName=="aunit") { aunit = G4UnitDefinition::GetValueOf(attValue); } else
3026                                               << 2096       if (attName=="twistedangle") { twistedangle=eval.Evaluate(attValue); } else
3027     if(attName == "name")                     << 2097       if (attName=="endinnerrad")  { endinnerrad=eval.Evaluate(attValue);  } else
3028     {                                         << 2098       if (attName=="endouterrad")  { endouterrad=eval.Evaluate(attValue);  } else
3029       name = GenerateName(attValue);          << 2099       if (attName=="zlen") { zlen = eval.Evaluate(attValue); } else
3030     }                                         << 2100       if (attName=="phi") { phi = eval.Evaluate(attValue); }
3031     else if(attName == "lunit")               << 2101    }
3032     {                                         << 2102 
3033       lunit = G4UnitDefinition::GetValueOf(at << 2103    twistedangle *= aunit;
3034       if(G4UnitDefinition::GetCategory(attVal << 2104    endinnerrad *= lunit;
3035       {                                       << 2105    endouterrad *= lunit;
3036         G4Exception("G4GDMLReadSolids::Twiste << 2106    zlen *= 0.5*lunit;
3037                     FatalException, "Invalid  << 2107    phi *= aunit;
3038       }                                       << 2108 
3039     }                                         << 2109    new G4TwistedTubs(name,twistedangle,endinnerrad,endouterrad,zlen,phi);
3040     else if(attName == "aunit")               << 2110 }
3041     {                                         << 2111 
3042       aunit = G4UnitDefinition::GetValueOf(at << 2112 G4TwoVector G4GDMLReadSolids::
3043       if(G4UnitDefinition::GetCategory(attVal << 2113 TwoDimVertexRead(const xercesc::DOMElement* const element, G4double lunit)
3044       {                                       << 2114 {
3045         G4Exception("G4GDMLReadSolids::Twiste << 2115    G4TwoVector vec;
3046                     FatalException, "Invalid  << 2116    
3047       }                                       << 2117    const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
3048     }                                         << 2118    XMLSize_t attributeCount = attributes->getLength();
3049     else if(attName == "PhiTwist")            << 2119 
3050     {                                         << 2120    for (XMLSize_t attribute_index=0;
3051       PhiTwist = eval.Evaluate(attValue);     << 2121         attribute_index<attributeCount; attribute_index++)
3052     }                                         << 2122    {
3053     else if(attName == "z")                   << 2123       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3054     {                                         << 2124 
3055       z = eval.Evaluate(attValue);            << 2125       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3056     }                                         << 2126         { continue; }
3057     else if(attName == "Theta")               << 2127 
3058     {                                         << 2128       const xercesc::DOMAttr* const attribute
3059       Theta = eval.Evaluate(attValue);        << 2129             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
3060     }                                         << 2130       if (!attribute)
3061     else if(attName == "Phi")                 << 2131       {
3062     {                                         << 2132         G4Exception("G4GDMLReadSolids::TwoDimVertexRead()",
3063       Phi = eval.Evaluate(attValue);          << 2133                     "InvalidRead", FatalException, "No attribute found!");
3064     }                                         << 2134         return vec;
3065     else if(attName == "y1")                  << 2135       }
3066     {                                         << 2136       const G4String attName = Transcode(attribute->getName());
3067       y1 = eval.Evaluate(attValue);           << 2137       const G4String attValue = Transcode(attribute->getValue());
3068     }                                         << 2138 
3069     else if(attName == "x1")                  << 2139       if (attName=="x") { vec.setX(eval.Evaluate(attValue)*lunit); } else
3070     {                                         << 2140       if (attName=="y") { vec.setY(eval.Evaluate(attValue)*lunit); }
3071       x1 = eval.Evaluate(attValue);           << 2141    }
3072     }                                         << 2142 
3073     else if(attName == "x2")                  << 2143    return vec;
3074     {                                         << 2144 }
3075       x2 = eval.Evaluate(attValue);           << 2145 
3076     }                                         << 2146 G4GDMLReadSolids::zplaneType G4GDMLReadSolids::
3077     else if(attName == "y2")                  << 2147 ZplaneRead(const xercesc::DOMElement* const zplaneElement)
3078     {                                         << 2148 {
3079       y2 = eval.Evaluate(attValue);           << 2149    zplaneType zplane = {0.,0.,0.};
3080     }                                         << 2150 
3081     else if(attName == "x3")                  << 2151    const xercesc::DOMNamedNodeMap* const attributes
3082     {                                         << 2152          = zplaneElement->getAttributes();
3083       x3 = eval.Evaluate(attValue);           << 2153    XMLSize_t attributeCount = attributes->getLength();
3084     }                                         << 2154 
3085     else if(attName == "x4")                  << 2155    for (XMLSize_t attribute_index=0;
3086     {                                         << 2156         attribute_index<attributeCount; attribute_index++)
3087       x4 = eval.Evaluate(attValue);           << 2157    {
3088     }                                         << 2158       xercesc::DOMNode* node = attributes->item(attribute_index);
3089     else if(attName == "Alph")                << 2159 
3090     {                                         << 2160       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
3091       Alph = eval.Evaluate(attValue);         << 2161 
3092     }                                         << 2162       const xercesc::DOMAttr* const attribute
3093   }                                           << 2163             = dynamic_cast<xercesc::DOMAttr*>(node);   
3094                                               << 2164       if (!attribute)
3095   PhiTwist *= aunit;                          << 2165       {
3096   z *= 0.5 * lunit;                           << 2166         G4Exception("G4GDMLReadSolids::ZplaneRead()",
3097   Theta *= aunit;                             << 2167                     "InvalidRead", FatalException, "No attribute found!");
3098   Phi *= aunit;                               << 2168         return zplane;
3099   Alph *= aunit;                              << 2169       }
3100   y1 *= 0.5 * lunit;                          << 2170       const G4String attName = Transcode(attribute->getName());
3101   x1 *= 0.5 * lunit;                          << 2171       const G4String attValue = Transcode(attribute->getValue());
3102   x2 *= 0.5 * lunit;                          << 2172 
3103   y2 *= 0.5 * lunit;                          << 2173       if (attName=="rmin") { zplane.rmin = eval.Evaluate(attValue); } else
3104   x3 *= 0.5 * lunit;                          << 2174       if (attName=="rmax") { zplane.rmax = eval.Evaluate(attValue); } else
3105   x4 *= 0.5 * lunit;                          << 2175       if (attName=="z") { zplane.z = eval.Evaluate(attValue); }
3106                                               << 2176    }
3107   new G4TwistedTrap(name, PhiTwist, z, Theta, << 2177 
3108                     Alph);                    << 2178    return zplane;
3109 }                                             << 2179 }
3110                                               << 2180 G4GDMLReadSolids::rzPointType G4GDMLReadSolids::
3111 // ------------------------------------------ << 2181 RZPointRead(const xercesc::DOMElement* const zplaneElement)
3112 void G4GDMLReadSolids::TwistedtrdRead(        << 2182 {
3113   const xercesc::DOMElement* const twistedtrd << 2183   rzPointType rzpoint = {0.,0.};
3114 {                                             << 2184 
3115   G4String name;                              << 2185   const xercesc::DOMNamedNodeMap* const attributes
3116   G4double lunit    = 1.0;                    << 2186          = zplaneElement->getAttributes();
3117   G4double aunit    = 1.0;                    << 2187    XMLSize_t attributeCount = attributes->getLength();
3118   G4double x1       = 0.0;                    << 2188 
3119   G4double x2       = 0.0;                    << 2189    for (XMLSize_t attribute_index=0;
3120   G4double y1       = 0.0;                    << 2190         attribute_index<attributeCount; attribute_index++)
3121   G4double y2       = 0.0;                    << 2191    {
3122   G4double z        = 0.0;                    << 2192       xercesc::DOMNode* node = attributes->item(attribute_index);
3123   G4double PhiTwist = 0.0;                    << 2193 
3124                                               << 2194       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
3125   const xercesc::DOMNamedNodeMap* const attri << 2195 
3126     twistedtrdElement->getAttributes();       << 2196       const xercesc::DOMAttr* const attribute
3127   XMLSize_t attributeCount = attributes->getL << 2197             = dynamic_cast<xercesc::DOMAttr*>(node);   
3128                                               << 2198       if (!attribute)
3129   for(XMLSize_t attribute_index = 0; attribut << 2199       {
3130       ++attribute_index)                      << 2200         G4Exception("G4GDMLReadSolids::RZPointRead()",
3131   {                                           << 2201                     "InvalidRead", FatalException, "No attribute found!");
3132     xercesc::DOMNode* attribute_node = attrib << 2202         return rzpoint;
3133                                               << 2203       }
3134     if(attribute_node->getNodeType() != xerce << 2204       const G4String attName = Transcode(attribute->getName());
3135     {                                         << 2205       const G4String attValue = Transcode(attribute->getValue());
3136       continue;                               << 2206 
3137     }                                         << 2207       if (attName=="r") { rzpoint.r = eval.Evaluate(attValue); } else
3138                                               << 2208       if (attName=="z") { rzpoint.z = eval.Evaluate(attValue); }
3139     const xercesc::DOMAttr* const attribute = << 2209    }
3140       dynamic_cast<xercesc::DOMAttr*>(attribu << 2210     
3141     if(attribute == nullptr)                  << 2211    return rzpoint;
3142     {                                         << 2212  
3143       G4Exception("G4GDMLReadSolids::Twistedt << 2213 }
3144                   FatalException, "No attribu << 2214 
3145       return;                                 << 2215 void G4GDMLReadSolids::
3146     }                                         << 2216 OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
3147     const G4String attName  = Transcode(attri << 2217 {
3148     const G4String attValue = Transcode(attri << 2218    G4String name;
3149                                               << 2219    G4String smodel;
3150     if(attName == "name")                     << 2220    G4String sfinish;
3151     {                                         << 2221    G4String stype;
3152       name = GenerateName(attValue);          << 2222    G4double value = 0.0;
3153     }                                         << 2223 
3154     else if(attName == "lunit")               << 2224    const xercesc::DOMNamedNodeMap* const attributes
3155     {                                         << 2225          = opticalsurfaceElement->getAttributes();
3156       lunit = G4UnitDefinition::GetValueOf(at << 2226    XMLSize_t attributeCount = attributes->getLength();
3157       if(G4UnitDefinition::GetCategory(attVal << 2227 
3158       {                                       << 2228    for (XMLSize_t attribute_index=0;
3159         G4Exception("G4GDMLReadSolids::Twiste << 2229         attribute_index<attributeCount; attribute_index++)
3160                     FatalException, "Invalid  << 2230    {
3161       }                                       << 2231       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
3162     }                                         << 2232 
3163     else if(attName == "aunit")               << 2233       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
3164     {                                         << 2234         { continue; }
3165       aunit = G4UnitDefinition::GetValueOf(at << 2235 
3166       if(G4UnitDefinition::GetCategory(attVal << 2236       const xercesc::DOMAttr* const attribute
3167       {                                       << 2237             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
3168         G4Exception("G4GDMLReadSolids::Twiste << 2238       if (!attribute)
3169                     FatalException, "Invalid  << 2239       {
3170       }                                       << 2240         G4Exception("G4GDMLReadSolids::OpticalSurfaceRead()",
3171     }                                         << 2241                     "InvalidRead", FatalException, "No attribute found!");
3172     else if(attName == "x1")                  << 2242         return;
3173     {                                         << 2243       }
3174       x1 = eval.Evaluate(attValue);           << 2244       const G4String attName = Transcode(attribute->getName());
3175     }                                         << 2245       const G4String attValue = Transcode(attribute->getValue());
3176     else if(attName == "x2")                  << 2246 
3177     {                                         << 2247       if (attName=="name") { name = GenerateName(attValue); } else
3178       x2 = eval.Evaluate(attValue);           << 2248       if (attName=="model") { smodel = attValue; } else
3179     }                                         << 2249       if (attName=="finish") { sfinish = attValue; } else
3180     else if(attName == "y1")                  << 2250       if (attName=="type") { stype = attValue; } else
3181     {                                         << 2251       if (attName=="value") { value = eval.Evaluate(attValue); }
3182       y1 = eval.Evaluate(attValue);           << 2252    }
3183     }                                         << 2253 
3184     else if(attName == "y2")                  << 2254    G4OpticalSurfaceModel model; 
3185     {                                         << 2255    G4OpticalSurfaceFinish finish;
3186       y2 = eval.Evaluate(attValue);           << 2256    G4SurfaceType type;   
3187     }                                         << 2257    
3188     else if(attName == "z")                   << 2258    if ((smodel=="glisur") || (smodel=="0")) { model = glisur; } else
3189     {                                         << 2259    if ((smodel=="unified") || (smodel=="1")) { model = unified; } else
3190       z = eval.Evaluate(attValue);            << 2260    if ((smodel=="LUT") || (smodel=="2")) { model = LUT; }
3191     }                                         << 2261    else { model = dichroic; }
3192     else if(attName == "PhiTwist")            << 2262 
3193     {                                         << 2263    if ((sfinish=="polished") || (sfinish=="0"))
3194       PhiTwist = eval.Evaluate(attValue);     << 2264       { finish = polished; } else
3195     }                                         << 2265    if ((sfinish=="polishedfrontpainted") || (sfinish=="1"))
3196   }                                           << 2266       { finish = polishedfrontpainted; } else
3197                                               << 2267    if ((sfinish=="polishedbackpainted") || (sfinish=="2"))
3198   x1 *= 0.5 * lunit;                          << 2268       { finish = polishedbackpainted; } else
3199   x2 *= 0.5 * lunit;                          << 2269    if ((sfinish=="ground") || (sfinish=="3"))
3200   y1 *= 0.5 * lunit;                          << 2270       { finish = ground; } else
3201   y2 *= 0.5 * lunit;                          << 2271    if ((sfinish=="groundfrontpainted") || (sfinish=="4"))
3202   z *= 0.5 * lunit;                           << 2272       { finish = groundfrontpainted; } else
3203   PhiTwist *= aunit;                          << 2273    if ((sfinish=="groundbackpainted") || (sfinish=="5"))
3204                                               << 2274       { finish = groundbackpainted; } else
3205   new G4TwistedTrd(name, x1, x2, y1, y2, z, P << 2275    if ((sfinish=="polishedlumirrorair") || (sfinish=="6"))
3206 }                                             << 2276       { finish = polishedlumirrorair; } else
3207                                               << 2277    if ((sfinish=="polishedlumirrorglue") || (sfinish=="7"))
3208 // ------------------------------------------ << 2278       { finish = polishedlumirrorglue; } else
3209 void G4GDMLReadSolids::TwistedtubsRead(       << 2279    if ((sfinish=="polishedair") || (sfinish=="8"))
3210   const xercesc::DOMElement* const twistedtub << 2280       { finish = polishedair; } else
3211 {                                             << 2281    if ((sfinish=="polishedteflonair") || (sfinish=="9"))
3212   G4String name;                              << 2282       { finish = polishedteflonair; } else
3213   G4double lunit        = 1.0;                << 2283    if ((sfinish=="polishedtioair") || (sfinish=="10"))
3214   G4double aunit        = 1.0;                << 2284       { finish = polishedtioair; } else
3215   G4double twistedangle = 0.0;                << 2285    if ((sfinish=="polishedtyvekair") || (sfinish=="11"))
3216   G4double endinnerrad  = 0.0;                << 2286       { finish = polishedtyvekair; } else
3217   G4double endouterrad  = 0.0;                << 2287    if ((sfinish=="polishedvm2000air") || (sfinish=="12"))
3218   G4double zlen         = 0.0;                << 2288       { finish = polishedvm2000air; } else
3219   G4double phi          = 0.0;                << 2289    if ((sfinish=="polishedvm2000glue") || (sfinish=="13"))
3220   G4double totphi       = 0.0;                << 2290       { finish = polishedvm2000glue; } else
3221   G4double midinnerrad  = 0.0;                << 2291    if ((sfinish=="etchedlumirrorair") || (sfinish=="14"))
3222   G4double midouterrad  = 0.0;                << 2292       { finish = etchedlumirrorair; } else
3223   G4double positiveEndz = 0.0;                << 2293    if ((sfinish=="etchedlumirrorglue") || (sfinish=="15"))
3224   G4double negativeEndz = 0.0;                << 2294       { finish = etchedlumirrorglue; } else
3225   G4int nseg            = 0;                  << 2295    if ((sfinish=="etchedair") || (sfinish=="16"))
3226                                               << 2296       { finish = etchedair; } else
3227   const xercesc::DOMNamedNodeMap* const attri << 2297    if ((sfinish=="etchedteflonair") || (sfinish=="17"))
3228     twistedtubsElement->getAttributes();      << 2298       { finish = etchedteflonair; } else
3229   XMLSize_t attributeCount = attributes->getL << 2299    if ((sfinish=="etchedtioair") || (sfinish=="18"))
3230                                               << 2300       { finish = etchedtioair; } else
3231   for(XMLSize_t attribute_index = 0; attribut << 2301    if ((sfinish=="etchedtyvekair") || (sfinish=="19"))
3232       ++attribute_index)                      << 2302       { finish = etchedtyvekair; } else
3233   {                                           << 2303    if ((sfinish=="etchedvm2000air") || (sfinish=="20"))
3234     xercesc::DOMNode* attribute_node = attrib << 2304       { finish = etchedvm2000air; } else
3235                                               << 2305    if ((sfinish=="etchedvm2000glue") || (sfinish=="21"))
3236     if(attribute_node->getNodeType() != xerce << 2306       { finish = etchedvm2000glue; } else
3237     {                                         << 2307    if ((sfinish=="groundlumirrorair") || (sfinish=="22"))
3238       continue;                               << 2308       { finish = groundlumirrorair; } else
3239     }                                         << 2309    if ((sfinish=="groundlumirrorglue") || (sfinish=="23"))
3240                                               << 2310       { finish = groundlumirrorglue; } else
3241     const xercesc::DOMAttr* const attribute = << 2311    if ((sfinish=="groundair") || (sfinish=="24"))
3242       dynamic_cast<xercesc::DOMAttr*>(attribu << 2312       { finish = groundair; } else
3243     if(attribute == nullptr)                  << 2313    if ((sfinish=="groundteflonair") || (sfinish=="25"))
3244     {                                         << 2314       { finish = groundteflonair; } else
3245       G4Exception("G4GDMLReadSolids::Twistedt << 2315    if ((sfinish=="groundtioair") || (sfinish=="26"))
3246                   FatalException, "No attribu << 2316       { finish = groundtioair; } else
3247       return;                                 << 2317    if ((sfinish=="groundtyvekair") || (sfinish=="27"))
3248     }                                         << 2318       { finish = groundtyvekair; } else
3249     const G4String attName  = Transcode(attri << 2319    if ((sfinish=="groundvm2000air") || (sfinish=="28"))
3250     const G4String attValue = Transcode(attri << 2320       { finish = groundvm2000air; }
3251                                               << 2321    else { finish = groundvm2000glue; }
3252     if(attName == "name")                     << 2322 
3253     {                                         << 2323    if ((stype=="dielectric_metal") || (stype=="0"))
3254       name = GenerateName(attValue);          << 2324       { type = dielectric_metal; } else
3255     }                                         << 2325    if ((stype=="dielectric_dielectric") || (stype=="1"))
3256     else if(attName == "lunit")               << 2326       { type = dielectric_dielectric; } else
3257     {                                         << 2327    if ((stype=="dielectric_LUT") || (stype=="2"))
3258       lunit = G4UnitDefinition::GetValueOf(at << 2328       { type = dielectric_LUT; } else
3259       if(G4UnitDefinition::GetCategory(attVal << 2329    if ((stype=="dielectric_dichroic") || (stype=="3"))
3260       {                                       << 2330       { type = dielectric_dichroic; } else
3261         G4Exception("G4GDMLReadSolids::Twiste << 2331    if ((stype=="firsov") || (stype=="4"))
3262                     FatalException, "Invalid  << 2332       { type = firsov; }
3263       }                                       << 2333    else { type = x_ray; }
3264     }                                         << 2334 
3265     else if(attName == "aunit")               << 2335    new G4OpticalSurface(name,model,finish,type,value);
3266     {                                         << 2336 }
3267       aunit = G4UnitDefinition::GetValueOf(at << 2337 
3268       if(G4UnitDefinition::GetCategory(attVal << 2338 void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement)
3269       {                                       << 2339 {
3270         G4Exception("G4GDMLReadSolids::Twiste << 2340    G4cout << "G4GDML: Reading solids..." << G4endl;
3271                     FatalException, "Invalid  << 2341 
3272       }                                       << 2342    for (xercesc::DOMNode* iter = solidsElement->getFirstChild();
3273     }                                         << 2343         iter != 0; iter = iter->getNextSibling())
3274     else if(attName == "twistedangle")        << 2344    {
3275     {                                         << 2345       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE)  { continue; }
3276       twistedangle = eval.Evaluate(attValue); << 2346 
3277     }                                         << 2347       const xercesc::DOMElement* const child
3278     else if(attName == "endinnerrad")         << 2348             = dynamic_cast<xercesc::DOMElement*>(iter);
3279     {                                         << 2349       if (!child)
3280       endinnerrad = eval.Evaluate(attValue);  << 2350       {
3281     }                                         << 2351         G4Exception("G4GDMLReadSolids::SolidsRead()",
3282     else if(attName == "endouterrad")         << 2352                     "InvalidRead", FatalException, "No child found!");
3283     {                                         << 2353         return;
3284       endouterrad = eval.Evaluate(attValue);  << 2354       }
3285     }                                         << 2355       const G4String tag = Transcode(child->getTagName());
3286     else if(attName == "zlen")                << 2356       if (tag=="define") { DefineRead(child);  }  else 
3287     {                                         << 2357       if (tag=="box")    { BoxRead(child); } else
3288       zlen = eval.Evaluate(attValue);         << 2358       if (tag=="cone")   { ConeRead(child); } else
3289     }                                         << 2359       if (tag=="elcone") { ElconeRead(child); } else
3290     else if(attName == "midinnerrad")         << 2360       if (tag=="ellipsoid") { EllipsoidRead(child); }else
3291     {                                         << 2361       if (tag=="eltube") { EltubeRead(child); } else
3292       midinnerrad = eval.Evaluate(attValue);  << 2362       if (tag=="xtru") { XtruRead(child); } else
3293     }                                         << 2363       if (tag=="hype") { HypeRead(child); } else
3294     else if(attName == "midouterrad")         << 2364       if (tag=="intersection") { BooleanRead(child,INTERSECTION); } else
3295     {                                         << 2365       if (tag=="multiUnion") { MultiUnionRead(child); } else
3296       midouterrad = eval.Evaluate(attValue);  << 2366       if (tag=="orb") { OrbRead(child); } else
3297     }                                         << 2367       if (tag=="para") { ParaRead(child); } else
3298     else if(attName == "negativeEndz")        << 2368       if (tag=="paraboloid") { ParaboloidRead(child); } else
3299     {                                         << 2369       if (tag=="polycone") { PolyconeRead(child); } else
3300       negativeEndz = eval.Evaluate(attValue); << 2370       if (tag=="genericPolycone") { GenericPolyconeRead(child); } else
3301     }                                         << 2371       if (tag=="polyhedra") { PolyhedraRead(child); } else
3302     else if(attName == "positiveEndz")        << 2372       if (tag=="genericPolyhedra") { GenericPolyhedraRead(child); } else
3303     {                                         << 2373       if (tag=="reflectedSolid") { ReflectedSolidRead(child); } else
3304       positiveEndz = eval.Evaluate(attValue); << 2374       if (tag=="sphere") { SphereRead(child); } else
3305     }                                         << 2375       if (tag=="subtraction") { BooleanRead(child,SUBTRACTION); } else
3306     else if(attName == "nseg")                << 2376       if (tag=="tessellated") { TessellatedRead(child); } else
3307     {                                         << 2377       if (tag=="tet") { TetRead(child); } else
3308       nseg = eval.Evaluate(attValue);         << 2378       if (tag=="torus") { TorusRead(child); } else
3309     }                                         << 2379       if (tag=="arb8") { GenTrapRead(child); } else
3310     else if(attName == "totphi")              << 2380       if (tag=="trap") { TrapRead(child); } else
3311     {                                         << 2381       if (tag=="trd") { TrdRead(child); } else
3312       totphi = eval.Evaluate(attValue);       << 2382       if (tag=="tube") { TubeRead(child); } else
3313     }                                         << 2383       if (tag=="cutTube") { CutTubeRead(child); } else
3314     else if(attName == "phi")                 << 2384       if (tag=="twistedbox") { TwistedboxRead(child); } else
3315     {                                         << 2385       if (tag=="twistedtrap") { TwistedtrapRead(child); } else
3316       phi = eval.Evaluate(attValue);          << 2386       if (tag=="twistedtrd") { TwistedtrdRead(child); } else
3317     }                                         << 2387       if (tag=="twistedtubs") { TwistedtubsRead(child); } else
3318   }                                           << 2388       if (tag=="union") { BooleanRead(child,UNION); } else
3319                                               << 2389       if (tag=="opticalsurface") { OpticalSurfaceRead(child); } else
3320   twistedangle *= aunit;                      << 2390       if (tag=="loop") { LoopRead(child,&G4GDMLRead::SolidsRead); }
3321   endinnerrad *= lunit;                       << 2391       else
3322   endouterrad *= lunit;                       << 2392       {
3323   zlen *= 0.5 * lunit;                        << 2393         G4String error_msg = "Unknown tag in solids: " + tag;
3324   midinnerrad *= lunit;                       << 2394         G4Exception("G4GDMLReadSolids::SolidsRead()", "ReadError",
3325   midouterrad *= lunit;                       << 2395                     FatalException, error_msg);
3326   positiveEndz *= lunit;                      << 2396       }
3327   negativeEndz *= lunit;                      << 2397    }
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 }                                                2398 }
3441                                                  2399 
3442 // ------------------------------------------ << 2400 G4VSolid* G4GDMLReadSolids::GetSolid(const G4String& ref) const
3443 G4GDMLReadSolids::rzPointType G4GDMLReadSolid << 
3444   const xercesc::DOMElement* const zplaneElem << 
3445 {                                                2401 {
3446   rzPointType rzpoint = { 0., 0. };           << 2402    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                                               << 
3486 // ------------------------------------------ << 
3487 void G4GDMLReadSolids::PropertyRead(          << 
3488   const xercesc::DOMElement* const propertyEl << 
3489   G4OpticalSurface* opticalsurface)           << 
3490 {                                             << 
3491   G4String name;                              << 
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                                                  2403 
3583 // ------------------------------------------ << 2404    if (!solidPtr)
3584 void G4GDMLReadSolids::OpticalSurfaceRead(    << 2405    {
3585   const xercesc::DOMElement* const opticalsur << 2406      G4String error_msg = "Referenced solid '" + ref + "' was not found!";
3586 {                                             << 2407      G4Exception("G4GDMLReadSolids::GetSolid()", "ReadError",
3587   G4String name;                              << 2408                  FatalException, error_msg);
3588   G4String smodel;                            << 2409    }
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                                                  2410 
3879 // ------------------------------------------ << 2411    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 }                                                2412 }
4055                                                  2413 
4056 // ------------------------------------------ << 2414 G4SurfaceProperty* G4GDMLReadSolids::
4057 G4VSolid* G4GDMLReadSolids::GetSolid(const G4 << 2415 GetSurfaceProperty(const G4String& ref) const
4058 {                                                2416 {
4059   G4VSolid* solidPtr = G4SolidStore::GetInsta << 2417    const G4SurfacePropertyTable* surfaceList
4060                                     ->GetSoli << 2418          = G4SurfaceProperty::GetSurfacePropertyTable();
4061                                               << 2419    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                                                  2420 
4069   return solidPtr;                            << 2421    for (size_t i=0; i<surfaceCount; i++)
4070 }                                             << 2422    {
                                                   >> 2423       if ((*surfaceList)[i]->GetName() == ref)  { return (*surfaceList)[i]; }
                                                   >> 2424    }
4071                                                  2425 
4072 // ------------------------------------------ << 2426    G4String error_msg = "Referenced optical surface '" + ref + "' was not found!";
4073 G4SurfaceProperty* G4GDMLReadSolids::GetSurfa << 2427    G4Exception("G4GDMLReadSolids::GetSurfaceProperty()", "ReadError",
4074   const G4String& ref) const                  << 2428                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                                                  2429 
4093   return nullptr;                             << 2430    return 0;
4094 }                                                2431 }
4095                                                  2432