Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/gdml/src/G4GDMLReadDefine.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/G4GDMLReadDefine.cc (Version 11.3.0) and /persistency/gdml/src/G4GDMLReadDefine.cc (Version 9.5.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 // G4GDMLReadDefine implementation             <<  26 // $Id: G4GDMLReadDefine.cc,v 1.26 2010-10-14 16:19:40 gcosmo Exp $
                                                   >>  27 // GEANT4 tag $Name: not supported by cvs2svn $
                                                   >>  28 //
                                                   >>  29 // class G4GDMLReadDefine Implementation
                                                   >>  30 //
                                                   >>  31 // Original author: Zoltan Torzsok, November 2007
 27 //                                                 32 //
 28 // Author: Zoltan Torzsok, November 2007       << 
 29 // -------------------------------------------     33 // --------------------------------------------------------------------
 30                                                    34 
 31 #include "G4GDMLReadDefine.hh"                     35 #include "G4GDMLReadDefine.hh"
 32 #include "G4UnitsTable.hh"                     << 
 33                                                    36 
 34 // G4GDMLMatrix ------------------------------ << 
 35                                                << 
 36 // ------------------------------------------- << 
 37 G4GDMLMatrix::G4GDMLMatrix()                       37 G4GDMLMatrix::G4GDMLMatrix()
                                                   >>  38   : m(0), rows(0), cols(0)
 38 {                                                  39 {
 39 }                                                  40 }
 40                                                    41 
 41 // ------------------------------------------- <<  42 G4GDMLMatrix::G4GDMLMatrix(size_t rows0, size_t cols0)
 42 G4GDMLMatrix::G4GDMLMatrix(std::size_t rows0,  <<  43 {   
 43 {                                              <<  44    if ((rows0==0) || (cols0==0))
 44   if((rows0 == 0) || (cols0 == 0))             <<  45    {
 45   {                                            <<  46      G4Exception("G4GDMLMatrix::G4GDMLMatrix(r,c)", "InvalidSetup",
 46     G4Exception("G4GDMLMatrix::G4GDMLMatrix(r, <<  47                  FatalException, "Zero indeces as arguments!?");
 47                 FatalException, "Zero indices  <<  48    }
 48   }                                            <<  49    rows = rows0;
 49   rows = rows0;                                <<  50    cols = cols0;
 50   cols = cols0;                                <<  51    m = new G4double[rows*cols];
 51   m    = new G4double[rows * cols];            << 
 52 }                                                  52 }
 53                                                    53 
 54 // ------------------------------------------- << 
 55 G4GDMLMatrix::G4GDMLMatrix(const G4GDMLMatrix&     54 G4GDMLMatrix::G4GDMLMatrix(const G4GDMLMatrix& rhs)
                                                   >>  55   : m(0), rows(0), cols(0)
 56 {                                                  56 {
 57   if(rhs.m)                                    <<  57    if (rhs.m)
 58   {                                            <<  58    {
 59     rows = rhs.rows;                           <<  59      rows = rhs.rows;
 60     cols = rhs.cols;                           <<  60      cols = rhs.cols;
 61     m    = new G4double[rows * cols];          <<  61      m = new G4double[rows*cols];
 62     for(std::size_t i = 0; i < rows * cols; ++ <<  62      for (size_t i=0; i<rows*cols; i++)  { m[i] = rhs.m[i]; }
 63     {                                          <<  63    }
 64       m[i] = rhs.m[i];                         << 
 65     }                                          << 
 66   }                                            << 
 67 }                                                  64 }
 68                                                    65 
 69 // ------------------------------------------- << 
 70 G4GDMLMatrix& G4GDMLMatrix::operator=(const G4     66 G4GDMLMatrix& G4GDMLMatrix::operator=(const G4GDMLMatrix& rhs)
 71 {                                                  67 {
 72   // Check assignment to self                  <<  68    // Check assignment to self
 73   //                                           <<  69    //
 74   if(this == &rhs)                             <<  70    if (this == &rhs)  { return *this; }
 75   {                                            <<  71 
 76     return *this;                              <<  72    // Copy data
 77   }                                            <<  73    //
 78                                                <<  74    rows = rhs.rows;
 79   // Copy data                                 <<  75    cols = rhs.cols;
 80   //                                           <<  76    if (rhs.m)
 81   rows = rhs.rows;                             <<  77    {
 82   cols = rhs.cols;                             <<  78      m = new G4double[rows*cols];
 83   if(rhs.m)                                    <<  79      for (size_t i=0; i<rows*cols; i++)  { m[i] = rhs.m[i]; }
 84   {                                            <<  80    }
 85     m = new G4double[rows * cols];             <<  81    else
 86     for(std::size_t i = 0; i < rows * cols; ++ <<  82    {
 87     {                                          <<  83      m = 0;
 88       m[i] = rhs.m[i];                         <<  84    }
 89     }                                          << 
 90   }                                            << 
 91   else                                         << 
 92   {                                            << 
 93     m = nullptr;                               << 
 94   }                                            << 
 95                                                    85 
 96   return *this;                                <<  86    return *this;
 97 }                                                  87 }
 98                                                    88 
 99 // ------------------------------------------- << 
100 G4GDMLMatrix::~G4GDMLMatrix()                      89 G4GDMLMatrix::~G4GDMLMatrix()
101 {                                                  90 {
102   delete[] m;                                  <<  91    delete [] m;
103 }                                                  92 }
104                                                    93 
105 // ------------------------------------------- <<  94 void G4GDMLMatrix::Set(size_t r,size_t c,G4double a)
106 void G4GDMLMatrix::Set(std::size_t r, std::siz <<  95 {   
107 {                                              <<  96    if (r>=rows || c>=cols)
108   if(r >= rows || c >= cols)                   <<  97    {
109   {                                            <<  98      G4Exception("G4GDMLMatrix::set()", "InvalidSetup",
110     G4Exception("G4GDMLMatrix::set()", "Invali <<  99                  FatalException, "Index out of range!");
111                 "Index out of range!");        << 100    }
112   }                                            << 101    m[cols*r+c] = a;
113   m[cols * r + c] = a;                         << 
114 }                                                 102 }
115                                                   103 
116 // ------------------------------------------- << 104 G4double G4GDMLMatrix::Get(size_t r,size_t c) const
117 G4double G4GDMLMatrix::Get(std::size_t r, std: << 105 {   
118 {                                              << 106    if (r>=rows || c>=cols)
119   if(r >= rows || c >= cols)                   << 107    {
120   {                                            << 108      G4Exception("G4GDMLMatrix::get()", "InvalidSetup",
121     G4Exception("G4GDMLMatrix::get()", "Invali << 109                  FatalException, "Index out of range!");
122                 "Index out of range!");        << 110    }
123   }                                            << 111    return m[cols*r+c];
124   return m[cols * r + c];                      << 
125 }                                                 112 }
126                                                   113 
127 // ------------------------------------------- << 114 size_t G4GDMLMatrix::GetRows() const
128 std::size_t G4GDMLMatrix::GetRows() const      << 
129 {                                                 115 {
130   return rows;                                 << 116    return rows;
131 }                                                 117 }
132                                                   118 
133 // ------------------------------------------- << 119 size_t G4GDMLMatrix::GetCols() const
134 std::size_t G4GDMLMatrix::GetCols() const      << 
135 {                                                 120 {
136   return cols;                                 << 121    return cols;
137 }                                                 122 }
138                                                   123 
139 // G4GDMLReadDefine -------------------------- << 124 G4GDMLReadDefine::G4GDMLReadDefine() : G4GDMLRead()
140                                                << 
141 // ------------------------------------------- << 
142 G4GDMLReadDefine::G4GDMLReadDefine()           << 
143   : G4GDMLRead()                               << 
144 {                                                 125 {
145 }                                                 126 }
146                                                   127 
147 // ------------------------------------------- << 
148 G4GDMLReadDefine::~G4GDMLReadDefine()             128 G4GDMLReadDefine::~G4GDMLReadDefine()
149 {                                                 129 {
150 }                                                 130 }
151                                                   131 
152 // ------------------------------------------- << 132 G4RotationMatrix
153 G4RotationMatrix G4GDMLReadDefine::GetRotation << 133 G4GDMLReadDefine::GetRotationMatrix(const G4ThreeVector& angles)
154   const G4ThreeVector& angles)                 << 
155 {                                                 134 {
156   G4RotationMatrix rot;                        << 135    G4RotationMatrix rot;
157                                                   136 
158   rot.rotateX(angles.x());                     << 137    rot.rotateX(angles.x());
159   rot.rotateY(angles.y());                     << 138    rot.rotateY(angles.y());
160   rot.rotateZ(angles.z());                     << 139    rot.rotateZ(angles.z());
161   rot.rectify();  // Rectify matrix from possi << 
162                                                   140 
163   return rot;                                  << 141    return rot;
164 }                                                 142 }
165                                                   143 
166 // ------------------------------------------- << 144 void
167 void G4GDMLReadDefine::ConstantRead(           << 145 G4GDMLReadDefine::ConstantRead(const xercesc::DOMElement* const constantElement)
168   const xercesc::DOMElement* const constantEle << 
169 {                                                 146 {
170   G4String name  = "";                         << 147    G4String name  = "";
171   G4double value = 0.0;                        << 148    G4double value = 0.0;
                                                   >> 149 
                                                   >> 150    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 151          = constantElement->getAttributes();
                                                   >> 152    XMLSize_t attributeCount = attributes->getLength();
172                                                   153 
173   const xercesc::DOMNamedNodeMap* const attrib << 154    for (XMLSize_t attribute_index=0;
174     constantElement->getAttributes();          << 155         attribute_index<attributeCount; attribute_index++)
175   XMLSize_t attributeCount = attributes->getLe << 156    {
176                                                << 157       xercesc::DOMNode* node = attributes->item(attribute_index);
177   for(XMLSize_t attribute_index = 0; attribute << 
178       ++attribute_index)                       << 
179   {                                            << 
180     xercesc::DOMNode* node = attributes->item( << 
181                                                << 
182     if(node->getNodeType() != xercesc::DOMNode << 
183     {                                          << 
184       continue;                                << 
185     }                                          << 
186                                                << 
187     const xercesc::DOMAttr* const attribute =  << 
188       dynamic_cast<xercesc::DOMAttr*>(node);   << 
189     if(attribute == nullptr)                   << 
190     {                                          << 
191       G4Exception("G4GDMLRead::ConstantRead()" << 
192                   "No attribute found!");      << 
193       return;                                  << 
194     }                                          << 
195     const G4String attName  = Transcode(attrib << 
196     const G4String attValue = Transcode(attrib << 
197                                                << 
198     if(attName == "name")                      << 
199     {                                          << 
200       name = attValue;                         << 
201     }                                          << 
202     else if(attName == "value")                << 
203     {                                          << 
204       value = eval.Evaluate(attValue);         << 
205     }                                          << 
206   }                                            << 
207                                                   158 
208   eval.DefineConstant(name, value);            << 159       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
                                                   >> 160 
                                                   >> 161       const xercesc::DOMAttr* const attribute
                                                   >> 162             = dynamic_cast<xercesc::DOMAttr*>(node);   
                                                   >> 163       if (!attribute)
                                                   >> 164       {
                                                   >> 165         G4Exception("G4GDMLRead::ConstantRead()", "InvalidRead",
                                                   >> 166                     FatalException, "No attribute found!");
                                                   >> 167         return;
                                                   >> 168       }
                                                   >> 169       const G4String attName = Transcode(attribute->getName());
                                                   >> 170       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 171 
                                                   >> 172       if (attName=="name")  { name = attValue; }  else
                                                   >> 173       if (attName=="value") { value = eval.Evaluate(attValue); }
                                                   >> 174    }
                                                   >> 175 
                                                   >> 176    eval.DefineConstant(name,value);
209 }                                                 177 }
210                                                   178 
211 // ------------------------------------------- << 179 void
212 void G4GDMLReadDefine::ExpressionRead(         << 180 G4GDMLReadDefine::ExpressionRead(const xercesc::DOMElement* const expElement)
213   const xercesc::DOMElement* const expElement) << 
214 {                                                 181 {
215   G4String name  = "";                         << 182    G4String name  = "";
216   G4double value = 0.0;                        << 183    G4double value = 0.0;
217                                                   184 
218   const xercesc::DOMNamedNodeMap* const attrib << 185    const xercesc::DOMNamedNodeMap* const attributes
219     expElement->getAttributes();               << 186          = expElement->getAttributes();
220   XMLSize_t attributeCount = attributes->getLe << 187    XMLSize_t attributeCount = attributes->getLength();
221                                                << 188 
222   for(XMLSize_t attribute_index = 0; attribute << 189    for (XMLSize_t attribute_index=0;
223       ++attribute_index)                       << 190         attribute_index<attributeCount; attribute_index++)
224   {                                            << 191    {
225     xercesc::DOMNode* node = attributes->item( << 192       xercesc::DOMNode* node = attributes->item(attribute_index);
226                                                << 193 
227     if(node->getNodeType() != xercesc::DOMNode << 194       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
228     {                                          << 195 
229       continue;                                << 196       const xercesc::DOMAttr* const attribute
230     }                                          << 197             = dynamic_cast<xercesc::DOMAttr*>(node);   
231                                                << 198       if (!attribute)
232     const xercesc::DOMAttr* const attribute =  << 199       {
233       dynamic_cast<xercesc::DOMAttr*>(node);   << 200         G4Exception("G4GDMLRead::ExpressionRead()", "InvalidRead",
234     if(attribute == nullptr)                   << 201                     FatalException, "No attribute found!");
235     {                                          << 202         return;
236       G4Exception("G4GDMLRead::ExpressionRead( << 203       }
237                   "No attribute found!");      << 204       const G4String attName = Transcode(attribute->getName());
238       return;                                  << 205       const G4String attValue = Transcode(attribute->getValue());
239     }                                          << 206 
240     const G4String attName  = Transcode(attrib << 207       if (attName=="name")  { name = attValue; }
241     const G4String attValue = Transcode(attrib << 208    }
242                                                << 209 
243     if(attName == "name")                      << 210    const G4String expValue = Transcode(expElement->getTextContent());
244     {                                          << 211    value = eval.Evaluate(expValue);
245       name = attValue;                         << 212    eval.DefineConstant(name,value);
246     }                                          << 
247   }                                            << 
248                                                << 
249   const G4String expValue = Transcode(expEleme << 
250   value                   = eval.Evaluate(expV << 
251   eval.DefineConstant(name, value);            << 
252 }                                                 213 }
253                                                   214 
254 // ------------------------------------------- << 215 void
255 void G4GDMLReadDefine::MatrixRead(             << 216 G4GDMLReadDefine::MatrixRead(const xercesc::DOMElement* const matrixElement) 
256   const xercesc::DOMElement* const matrixEleme << 
257 {                                                 217 {
258   G4String name   = "";                        << 218    G4String name = "";
259   G4int coldim    = 0;                         << 219    G4int coldim  = 0;
260   G4String values = "";                        << 220    G4String values = "";
261                                                << 221 
262   const xercesc::DOMNamedNodeMap* const attrib << 222    const xercesc::DOMNamedNodeMap* const attributes
263     matrixElement->getAttributes();            << 223          = matrixElement->getAttributes();
264   XMLSize_t attributeCount = attributes->getLe << 224    XMLSize_t attributeCount = attributes->getLength();
265                                                << 225 
266   for(XMLSize_t attribute_index = 0; attribute << 226    for (XMLSize_t attribute_index=0;
267       ++attribute_index)                       << 227         attribute_index<attributeCount; attribute_index++)
268   {                                            << 228    {
269     xercesc::DOMNode* node = attributes->item( << 229       xercesc::DOMNode* node = attributes->item(attribute_index);
270                                                << 230 
271     if(node->getNodeType() != xercesc::DOMNode << 231       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
272     {                                          << 232 
273       continue;                                << 233       const xercesc::DOMAttr* const attribute
274     }                                          << 234             = dynamic_cast<xercesc::DOMAttr*>(node);   
275                                                << 235       if (!attribute)
276     const xercesc::DOMAttr* const attribute =  << 236       {
277       dynamic_cast<xercesc::DOMAttr*>(node);   << 237         G4Exception("G4GDMLRead::MatrixRead()", "InvalidRead",
278     if(attribute == nullptr)                   << 238                     FatalException, "No attribute found!");
279     {                                          << 239         return;
280       G4Exception("G4GDMLRead::MatrixRead()",  << 240       }
281                   "No attribute found!");      << 241       const G4String attName = Transcode(attribute->getName());
282       return;                                  << 242       const G4String attValue = Transcode(attribute->getValue());
283     }                                          << 243 
284     const G4String attName  = Transcode(attrib << 244       if (attName=="name")   { name  = GenerateName(attValue); } else
285     const G4String attValue = Transcode(attrib << 245       if (attName=="coldim") { coldim = eval.EvaluateInteger(attValue); } else
286                                                << 246       if (attName=="values") { values = attValue; }
287     if(attName == "name")                      << 247    }
288     {                                          << 248 
289       name = GenerateName(attValue);           << 249    std::stringstream MatrixValueStream(values);
290     }                                          << 250    std::vector<G4double> valueList;
291     else if(attName == "coldim")               << 251 
292     {                                          << 252    while (!MatrixValueStream.eof())
293       coldim = eval.EvaluateInteger(attValue); << 253    {
294     }                                          << 254       G4String MatrixValue;
295     else if(attName == "values")               << 255       MatrixValueStream >> MatrixValue;
296     {                                          << 256       valueList.push_back(eval.Evaluate(MatrixValue));
297       values = attValue;                       << 257    }
298     }                                          << 258 
299   }                                            << 259    eval.DefineMatrix(name,coldim,valueList);
300                                                << 260 
301   std::stringstream MatrixValueStream(values); << 261    G4GDMLMatrix matrix(valueList.size()/coldim,coldim);
302   std::vector<G4double> valueList;             << 262 
303                                                << 263    for (size_t i=0;i<valueList.size();i++)
304   while(!MatrixValueStream.eof())              << 264    {
305   {                                            << 265       matrix.Set(i/coldim,i%coldim,valueList[i]);
306     G4String MatrixValue;                      << 266    }
307     MatrixValueStream >> MatrixValue;          << 
308     valueList.push_back(eval.Evaluate(MatrixVa << 
309   }                                            << 
310                                                << 
311   eval.DefineMatrix(name, coldim, valueList);  << 
312                                                << 
313   G4GDMLMatrix matrix(valueList.size() / coldi << 
314                                                << 
315   for(std::size_t i = 0; i < valueList.size(); << 
316   {                                            << 
317     matrix.Set(i / coldim, i % coldim, valueLi << 
318   }                                            << 
319                                                   267 
320   matrixMap[name] = matrix;                    << 268    matrixMap[name] = matrix;
321 }                                                 269 }
322                                                   270 
323 // ------------------------------------------- << 271 void
324 void G4GDMLReadDefine::PositionRead(           << 272 G4GDMLReadDefine::PositionRead(const xercesc::DOMElement* const positionElement)
325   const xercesc::DOMElement* const positionEle << 
326 {                                                 273 {
327   G4String name = "";                          << 274    G4String name = "";
328   G4double unit = 1.0;                         << 275    G4double unit = 1.0;
329   G4ThreeVector position(0., 0., 0.);          << 276    G4ThreeVector position(0.,0.,0.);
330                                                << 277 
331   const xercesc::DOMNamedNodeMap* const attrib << 278    const xercesc::DOMNamedNodeMap* const attributes
332     positionElement->getAttributes();          << 279          = positionElement->getAttributes();
333   XMLSize_t attributeCount = attributes->getLe << 280    XMLSize_t attributeCount = attributes->getLength();
334                                                << 281 
335   for(XMLSize_t attribute_index = 0; attribute << 282    for (XMLSize_t attribute_index=0;
336       ++attribute_index)                       << 283         attribute_index<attributeCount; attribute_index++)
337   {                                            << 284    {
338     xercesc::DOMNode* node = attributes->item( << 285       xercesc::DOMNode* node = attributes->item(attribute_index);
339                                                << 
340     if(node->getNodeType() != xercesc::DOMNode << 
341     {                                          << 
342       continue;                                << 
343     }                                          << 
344                                                << 
345     const xercesc::DOMAttr* const attribute =  << 
346       dynamic_cast<xercesc::DOMAttr*>(node);   << 
347     if(attribute == nullptr)                   << 
348     {                                          << 
349       G4Exception("G4GDMLRead::PositionRead()" << 
350                   "No attribute found!");      << 
351       return;                                  << 
352     }                                          << 
353     const G4String attName  = Transcode(attrib << 
354     const G4String attValue = Transcode(attrib << 
355                                                << 
356     if(attName == "name")                      << 
357     {                                          << 
358       name = GenerateName(attValue);           << 
359     }                                          << 
360     else if(attName == "unit")                 << 
361     {                                          << 
362       unit = G4UnitDefinition::GetValueOf(attV << 
363       if(G4UnitDefinition::GetCategory(attValu << 
364       {                                        << 
365         G4Exception("G4GDMLReadDefine::Positio << 
366                     FatalException, "Invalid u << 
367       }                                        << 
368     }                                          << 
369     else if(attName == "x")                    << 
370     {                                          << 
371       position.setX(eval.Evaluate(attValue));  << 
372     }                                          << 
373     else if(attName == "y")                    << 
374     {                                          << 
375       position.setY(eval.Evaluate(attValue));  << 
376     }                                          << 
377     else if(attName == "z")                    << 
378     {                                          << 
379       position.setZ(eval.Evaluate(attValue));  << 
380     }                                          << 
381   }                                            << 
382                                                   286 
383   positionMap[name] = position * unit;         << 287       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
                                                   >> 288 
                                                   >> 289       const xercesc::DOMAttr* const attribute
                                                   >> 290             = dynamic_cast<xercesc::DOMAttr*>(node);   
                                                   >> 291       if (!attribute)
                                                   >> 292       {
                                                   >> 293         G4Exception("G4GDMLRead::PositionRead()", "InvalidRead",
                                                   >> 294                     FatalException, "No attribute found!");
                                                   >> 295         return;
                                                   >> 296       }
                                                   >> 297       const G4String attName = Transcode(attribute->getName());
                                                   >> 298       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 299 
                                                   >> 300       if (attName=="name") { name = GenerateName(attValue); }  else
                                                   >> 301       if (attName=="unit") { unit = eval.Evaluate(attValue); } else
                                                   >> 302       if (attName=="x") { position.setX(eval.Evaluate(attValue)); } else
                                                   >> 303       if (attName=="y") { position.setY(eval.Evaluate(attValue)); } else
                                                   >> 304       if (attName=="z") { position.setZ(eval.Evaluate(attValue)); }
                                                   >> 305    }
                                                   >> 306 
                                                   >> 307    positionMap[name] = position*unit;
384 }                                                 308 }
385                                                   309 
386 // ------------------------------------------- << 310 void
387 void G4GDMLReadDefine::RotationRead(           << 311 G4GDMLReadDefine::RotationRead(const xercesc::DOMElement* const rotationElement)
388   const xercesc::DOMElement* const rotationEle << 
389 {                                                 312 {
390   G4String name = "";                          << 313    G4String name = "";
391   G4double unit = 1.0;                         << 314    G4double unit = 1.0;
392   G4ThreeVector rotation(0., 0., 0.);          << 315    G4ThreeVector rotation(0.,0.,0.);
393                                                << 316 
394   const xercesc::DOMNamedNodeMap* const attrib << 317    const xercesc::DOMNamedNodeMap* const attributes
395     rotationElement->getAttributes();          << 318          = rotationElement->getAttributes();
396   XMLSize_t attributeCount = attributes->getLe << 319    XMLSize_t attributeCount = attributes->getLength();
397                                                << 
398   for(XMLSize_t attribute_index = 0; attribute << 
399       ++attribute_index)                       << 
400   {                                            << 
401     xercesc::DOMNode* node = attributes->item( << 
402                                                << 
403     if(node->getNodeType() != xercesc::DOMNode << 
404     {                                          << 
405       continue;                                << 
406     }                                          << 
407                                                << 
408     const xercesc::DOMAttr* const attribute =  << 
409       dynamic_cast<xercesc::DOMAttr*>(node);   << 
410     if(attribute == nullptr)                   << 
411     {                                          << 
412       G4Exception("G4GDMLRead::RotationRead()" << 
413                   "No attribute found!");      << 
414       return;                                  << 
415     }                                          << 
416     const G4String attName  = Transcode(attrib << 
417     const G4String attValue = Transcode(attrib << 
418                                                << 
419     if(attName == "name")                      << 
420     {                                          << 
421       name = GenerateName(attValue);           << 
422     }                                          << 
423     else if(attName == "unit")                 << 
424     {                                          << 
425       unit = G4UnitDefinition::GetValueOf(attV << 
426       if(G4UnitDefinition::GetCategory(attValu << 
427       {                                        << 
428         G4Exception("G4GDMLReadDefine::Rotatio << 
429                     FatalException, "Invalid u << 
430       }                                        << 
431     }                                          << 
432     else if(attName == "x")                    << 
433     {                                          << 
434       rotation.setX(eval.Evaluate(attValue));  << 
435     }                                          << 
436     else if(attName == "y")                    << 
437     {                                          << 
438       rotation.setY(eval.Evaluate(attValue));  << 
439     }                                          << 
440     else if(attName == "z")                    << 
441     {                                          << 
442       rotation.setZ(eval.Evaluate(attValue));  << 
443     }                                          << 
444   }                                            << 
445                                                   320 
446   rotationMap[name] = rotation * unit;         << 321    for (XMLSize_t attribute_index=0;
                                                   >> 322         attribute_index<attributeCount; attribute_index++)
                                                   >> 323    {
                                                   >> 324       xercesc::DOMNode* node = attributes->item(attribute_index);
                                                   >> 325 
                                                   >> 326       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
                                                   >> 327 
                                                   >> 328       const xercesc::DOMAttr* const attribute
                                                   >> 329             = dynamic_cast<xercesc::DOMAttr*>(node);   
                                                   >> 330       if (!attribute)
                                                   >> 331       {
                                                   >> 332         G4Exception("G4GDMLRead::RotationRead()", "InvalidRead",
                                                   >> 333                     FatalException, "No attribute found!");
                                                   >> 334         return;
                                                   >> 335       }
                                                   >> 336       const G4String attName = Transcode(attribute->getName());
                                                   >> 337       const G4String attValue = Transcode(attribute->getValue());
                                                   >> 338 
                                                   >> 339       if (attName=="name") { name = GenerateName(attValue); }  else
                                                   >> 340       if (attName=="unit") { unit = eval.Evaluate(attValue); } else
                                                   >> 341       if (attName=="x") { rotation.setX(eval.Evaluate(attValue)); } else
                                                   >> 342       if (attName=="y") { rotation.setY(eval.Evaluate(attValue)); } else
                                                   >> 343       if (attName=="z") { rotation.setZ(eval.Evaluate(attValue)); }
                                                   >> 344    }
                                                   >> 345 
                                                   >> 346    rotationMap[name] = rotation*unit;
447 }                                                 347 }
448                                                   348 
449 // ------------------------------------------- << 
450 void G4GDMLReadDefine::ScaleRead(const xercesc    349 void G4GDMLReadDefine::ScaleRead(const xercesc::DOMElement* const scaleElement)
451 {                                                 350 {
452   G4String name = "";                          << 351    G4String name = "";
453   G4ThreeVector scale(1.0, 1.0, 1.0);          << 352    G4ThreeVector scale(1.0,1.0,1.0);
                                                   >> 353 
                                                   >> 354    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 355          = scaleElement->getAttributes();
                                                   >> 356    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 357 
                                                   >> 358    for (XMLSize_t attribute_index=0;
                                                   >> 359         attribute_index<attributeCount; attribute_index++)
                                                   >> 360    {
                                                   >> 361       xercesc::DOMNode* node = attributes->item(attribute_index);
                                                   >> 362 
                                                   >> 363       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
                                                   >> 364 
                                                   >> 365       const xercesc::DOMAttr* const attribute
                                                   >> 366             = dynamic_cast<xercesc::DOMAttr*>(node);   
                                                   >> 367       if (!attribute)
                                                   >> 368       {
                                                   >> 369         G4Exception("G4GDMLRead::ScaleRead()", "InvalidRead",
                                                   >> 370                     FatalException, "No attribute found!");
                                                   >> 371         return;
                                                   >> 372       }
                                                   >> 373       const G4String attName = Transcode(attribute->getName());
                                                   >> 374       const G4String attValue = Transcode(attribute->getValue());
454                                                   375 
455   const xercesc::DOMNamedNodeMap* const attrib << 376       if (attName=="name") { name = GenerateName(attValue); }    else
456     scaleElement->getAttributes();             << 377       if (attName=="x") { scale.setX(eval.Evaluate(attValue)); } else
457   XMLSize_t attributeCount = attributes->getLe << 378       if (attName=="y") { scale.setY(eval.Evaluate(attValue)); } else
458                                                << 379       if (attName=="z") { scale.setZ(eval.Evaluate(attValue)); }
459   for(XMLSize_t attribute_index = 0; attribute << 380    }
460       ++attribute_index)                       << 
461   {                                            << 
462     xercesc::DOMNode* node = attributes->item( << 
463                                                << 
464     if(node->getNodeType() != xercesc::DOMNode << 
465     {                                          << 
466       continue;                                << 
467     }                                          << 
468                                                << 
469     const xercesc::DOMAttr* const attribute =  << 
470       dynamic_cast<xercesc::DOMAttr*>(node);   << 
471     if(attribute == nullptr)                   << 
472     {                                          << 
473       G4Exception("G4GDMLRead::ScaleRead()", " << 
474                   "No attribute found!");      << 
475       return;                                  << 
476     }                                          << 
477     const G4String attName  = Transcode(attrib << 
478     const G4String attValue = Transcode(attrib << 
479                                                << 
480     if(attName == "name")                      << 
481     {                                          << 
482       name = GenerateName(attValue);           << 
483     }                                          << 
484     else if(attName == "x")                    << 
485     {                                          << 
486       scale.setX(eval.Evaluate(attValue));     << 
487     }                                          << 
488     else if(attName == "y")                    << 
489     {                                          << 
490       scale.setY(eval.Evaluate(attValue));     << 
491     }                                          << 
492     else if(attName == "z")                    << 
493     {                                          << 
494       scale.setZ(eval.Evaluate(attValue));     << 
495     }                                          << 
496   }                                            << 
497                                                   381 
498   scaleMap[name] = scale;                      << 382    scaleMap[name] = scale;
499 }                                                 383 }
500                                                   384 
501 // ------------------------------------------- << 385 void
502 void G4GDMLReadDefine::VariableRead(           << 386 G4GDMLReadDefine::VariableRead(const xercesc::DOMElement* const variableElement)
503   const xercesc::DOMElement* const variableEle << 
504 {                                                 387 {
505   G4String name  = "";                         << 388    G4String name  = "";
506   G4double value = 0.0;                        << 389    G4double value = 0.0;
                                                   >> 390 
                                                   >> 391    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 392          = variableElement->getAttributes();
                                                   >> 393    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 394 
                                                   >> 395    for (XMLSize_t attribute_index=0;
                                                   >> 396         attribute_index<attributeCount; attribute_index++)
                                                   >> 397    {
                                                   >> 398       xercesc::DOMNode* node = attributes->item(attribute_index);
507                                                   399 
508   const xercesc::DOMNamedNodeMap* const attrib << 400       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
509     variableElement->getAttributes();          << 401 
510   XMLSize_t attributeCount = attributes->getLe << 402       const xercesc::DOMAttr* const attribute
511                                                << 403             = dynamic_cast<xercesc::DOMAttr*>(node);   
512   for(XMLSize_t attribute_index = 0; attribute << 404       if (!attribute)
513       ++attribute_index)                       << 405       {
514   {                                            << 406         G4Exception("G4GDMLRead::VariableRead()", "InvalidRead",
515     xercesc::DOMNode* node = attributes->item( << 407                     FatalException, "No attribute found!");
516                                                << 408         return;
517     if(node->getNodeType() != xercesc::DOMNode << 409       }
518     {                                          << 410       const G4String attName = Transcode(attribute->getName());
519       continue;                                << 411       const G4String attValue = Transcode(attribute->getValue());
520     }                                          << 
521                                                << 
522     const xercesc::DOMAttr* const attribute =  << 
523       dynamic_cast<xercesc::DOMAttr*>(node);   << 
524     if(attribute == nullptr)                   << 
525     {                                          << 
526       G4Exception("G4GDMLRead::VariableRead()" << 
527                   "No attribute found!");      << 
528       return;                                  << 
529     }                                          << 
530     const G4String attName  = Transcode(attrib << 
531     const G4String attValue = Transcode(attrib << 
532                                                << 
533     if(attName == "name")                      << 
534     {                                          << 
535       name = attValue;                         << 
536     }                                          << 
537     else if(attName == "value")                << 
538     {                                          << 
539       value = eval.Evaluate(attValue);         << 
540     }                                          << 
541   }                                            << 
542                                                   412 
543   eval.DefineVariable(name, value);            << 413       if (attName=="name")  { name = attValue; } else
                                                   >> 414       if (attName=="value") { value = eval.Evaluate(attValue); }
                                                   >> 415    }
                                                   >> 416 
                                                   >> 417    eval.DefineVariable(name,value);
544 }                                                 418 }
545                                                   419 
546 // ------------------------------------------- << 
547 void G4GDMLReadDefine::QuantityRead(const xerc    420 void G4GDMLReadDefine::QuantityRead(const xercesc::DOMElement* const element)
548 {                                                 421 {
549   G4String name  = "";                         << 422    G4String name = "";
550   G4double unit  = 1.0;                        << 423    G4double unit = 1.0;
551   G4double value = 0.0;                        << 424    G4double value = 0.0;
552                                                << 425 
553   const xercesc::DOMNamedNodeMap* const attrib << 426    const xercesc::DOMNamedNodeMap* const attributes
554   XMLSize_t attributeCount                     << 427          = element->getAttributes();
555                                                << 428    XMLSize_t attributeCount = attributes->getLength();
556   for(XMLSize_t attribute_index = 0; attribute << 429 
557       ++attribute_index)                       << 430    for (XMLSize_t attribute_index=0;
558   {                                            << 431         attribute_index<attributeCount; attribute_index++)
559     xercesc::DOMNode* node = attributes->item( << 432    {
560                                                << 433       xercesc::DOMNode* node = attributes->item(attribute_index);
561     if(node->getNodeType() != xercesc::DOMNode << 434 
562     {                                          << 435       if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
563       continue;                                << 436 
564     }                                          << 437       const xercesc::DOMAttr* const attribute
565                                                << 438             = dynamic_cast<xercesc::DOMAttr*>(node);   
566     const xercesc::DOMAttr* const attribute =  << 439       if (!attribute)
567       dynamic_cast<xercesc::DOMAttr*>(node);   << 440       {
568     if(attribute == nullptr)                   << 441         G4Exception("G4GDMLRead::QuantityRead()", "InvalidRead",
569     {                                          << 442                     FatalException, "No attribute found!");
570       G4Exception("G4GDMLRead::QuantityRead()" << 443         return;
571                   "No attribute found!");      << 444       }
572       return;                                  << 445       const G4String attName = Transcode(attribute->getName());
573     }                                          << 446       const G4String attValue = Transcode(attribute->getValue());
574     const G4String attName  = Transcode(attrib << 447 
575     const G4String attValue = Transcode(attrib << 448       if (attName=="name") { name = attValue; } else
576                                                << 449       if (attName=="value") { value = eval.Evaluate(attValue); } else
577     if(attName == "name")                      << 450       if (attName=="unit") { unit = eval.Evaluate(attValue); }
578     {                                          << 451    }
579       name = attValue;                         << 
580     }                                          << 
581     else if(attName == "value")                << 
582     {                                          << 
583       value = eval.Evaluate(attValue);         << 
584     }                                          << 
585     else if(attName == "unit")                 << 
586     {                                          << 
587       unit = G4UnitDefinition::GetValueOf(attV << 
588     }                                          << 
589   }                                            << 
590                                                   452 
591   quantityMap[name] = value * unit;            << 453    quantityMap[name] = value*unit;
592   eval.DefineConstant(name, value * unit);     << 454    eval.DefineConstant(name,value*unit);
593 }                                                 455 }
594                                                   456 
595 // ------------------------------------------- << 457 void
596 void G4GDMLReadDefine::DefineRead(             << 458 G4GDMLReadDefine::DefineRead(const xercesc::DOMElement* const defineElement)
597   const xercesc::DOMElement* const defineEleme << 
598 {                                                 459 {
599 #ifdef G4VERBOSE                               << 460    G4cout << "G4GDML: Reading definitions..." << G4endl;
600   G4cout << "G4GDML: Reading definitions..." < << 461 
601 #endif                                         << 462    for (xercesc::DOMNode* iter = defineElement->getFirstChild();
602   for(xercesc::DOMNode* iter = defineElement-> << 463         iter != 0;iter = iter->getNextSibling())
603       iter                   = iter->getNextSi << 464    {
604   {                                            << 465       if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
605     if(iter->getNodeType() != xercesc::DOMNode << 466 
606     {                                          << 467       const xercesc::DOMElement* const child
607       continue;                                << 468             = dynamic_cast<xercesc::DOMElement*>(iter);
608     }                                          << 469       if (!child)
609                                                << 470       {
610     const xercesc::DOMElement* const child =   << 471         G4Exception("G4GDMLRead::DefineRead()", "InvalidRead",
611       dynamic_cast<xercesc::DOMElement*>(iter) << 472                     FatalException, "No child found!");
612     if(child == nullptr)                       << 473         return;
613     {                                          << 474       }
614       G4Exception("G4GDMLRead::DefineRead()",  << 475       const G4String tag = Transcode(child->getTagName());
615                   "No child found!");          << 476 
616       return;                                  << 477       if (tag=="constant") { ConstantRead(child); } else
617     }                                          << 478       if (tag=="matrix")   { MatrixRead(child); }   else
618     const G4String tag = Transcode(child->getT << 479       if (tag=="position") { PositionRead(child); } else
619                                                << 480       if (tag=="rotation") { RotationRead(child); } else
620     if(tag == "constant")                      << 481       if (tag=="scale")    { ScaleRead(child); }    else
621     {                                          << 482       if (tag=="variable") { VariableRead(child); } else
622       ConstantRead(child);                     << 483       if (tag=="quantity") { QuantityRead(child); } else
623     }                                          << 484       if (tag=="expression") { ExpressionRead(child); }
624     else if(tag == "matrix")                   << 485       else
625     {                                          << 486       {
626       MatrixRead(child);                       << 487         G4String error_msg = "Unknown tag in define: "+tag;
627     }                                          << 488         G4Exception("G4GDMLReadDefine::defineRead()", "ReadError",
628     else if(tag == "position")                 << 489                     FatalException, error_msg);
629     {                                          << 490       }
630       PositionRead(child);                     << 491    }
631     }                                          << 
632     else if(tag == "rotation")                 << 
633     {                                          << 
634       RotationRead(child);                     << 
635     }                                          << 
636     else if(tag == "scale")                    << 
637     {                                          << 
638       ScaleRead(child);                        << 
639     }                                          << 
640     else if(tag == "variable")                 << 
641     {                                          << 
642       VariableRead(child);                     << 
643     }                                          << 
644     else if(tag == "quantity")                 << 
645     {                                          << 
646       QuantityRead(child);                     << 
647     }                                          << 
648     else if(tag == "expression")               << 
649     {                                          << 
650       ExpressionRead(child);                   << 
651     }                                          << 
652     else                                       << 
653     {                                          << 
654       G4String error_msg = "Unknown tag in def << 
655       G4Exception("G4GDMLReadDefine::defineRea << 
656                   error_msg);                  << 
657     }                                          << 
658   }                                            << 
659 }                                                 492 }
660                                                   493 
661 // ------------------------------------------- << 494 void
662 void G4GDMLReadDefine::VectorRead(             << 495 G4GDMLReadDefine::VectorRead(const xercesc::DOMElement* const vectorElement,
663   const xercesc::DOMElement* const vectorEleme << 496                              G4ThreeVector& vec)
664 {                                                 497 {
665   G4double unit = 1.0;                         << 498    G4double unit = 1.0;
                                                   >> 499 
                                                   >> 500    const xercesc::DOMNamedNodeMap* const attributes
                                                   >> 501          = vectorElement->getAttributes();
                                                   >> 502    XMLSize_t attributeCount = attributes->getLength();
                                                   >> 503 
                                                   >> 504    for (XMLSize_t attribute_index=0;
                                                   >> 505         attribute_index<attributeCount; attribute_index++)
                                                   >> 506    {
                                                   >> 507       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
                                                   >> 508 
                                                   >> 509       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
                                                   >> 510       { continue; }
                                                   >> 511 
                                                   >> 512       const xercesc::DOMAttr* const attribute
                                                   >> 513             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
                                                   >> 514       if (!attribute)
                                                   >> 515       {
                                                   >> 516         G4Exception("G4GDMLRead::VectorRead()", "InvalidRead",
                                                   >> 517                     FatalException, "No attribute found!");
                                                   >> 518         return;
                                                   >> 519       }
                                                   >> 520       const G4String attName = Transcode(attribute->getName());
                                                   >> 521       const G4String attValue = Transcode(attribute->getValue());
666                                                   522 
667   const xercesc::DOMNamedNodeMap* const attrib << 523       if (attName=="unit") { unit = eval.Evaluate(attValue); } else
668     vectorElement->getAttributes();            << 524       if (attName=="x") { vec.setX(eval.Evaluate(attValue)); } else
669   XMLSize_t attributeCount = attributes->getLe << 525       if (attName=="y") { vec.setY(eval.Evaluate(attValue)); } else
670                                                << 526       if (attName=="z") { vec.setZ(eval.Evaluate(attValue)); }
671   for(XMLSize_t attribute_index = 0; attribute << 527    }
672       ++attribute_index)                       << 
673   {                                            << 
674     xercesc::DOMNode* attribute_node = attribu << 
675                                                << 
676     if(attribute_node->getNodeType() != xerces << 
677     {                                          << 
678       continue;                                << 
679     }                                          << 
680                                                << 
681     const xercesc::DOMAttr* const attribute =  << 
682       dynamic_cast<xercesc::DOMAttr*>(attribut << 
683     if(attribute == nullptr)                   << 
684     {                                          << 
685       G4Exception("G4GDMLRead::VectorRead()",  << 
686                   "No attribute found!");      << 
687       return;                                  << 
688     }                                          << 
689     const G4String attName  = Transcode(attrib << 
690     const G4String attValue = Transcode(attrib << 
691                                                << 
692     if(attName == "unit")                      << 
693     {                                          << 
694       unit = G4UnitDefinition::GetValueOf(attV << 
695     }                                          << 
696     else if(attName == "x")                    << 
697     {                                          << 
698       vec.setX(eval.Evaluate(attValue));       << 
699     }                                          << 
700     else if(attName == "y")                    << 
701     {                                          << 
702       vec.setY(eval.Evaluate(attValue));       << 
703     }                                          << 
704     else if(attName == "z")                    << 
705     {                                          << 
706       vec.setZ(eval.Evaluate(attValue));       << 
707     }                                          << 
708   }                                            << 
709                                                   528 
710   vec *= unit;                                 << 529    vec *= unit;
711 }                                                 530 }
712                                                   531 
713 // ------------------------------------------- << 
714 G4String G4GDMLReadDefine::RefRead(const xerce    532 G4String G4GDMLReadDefine::RefRead(const xercesc::DOMElement* const element)
715 {                                                 533 {
716   G4String ref;                                << 534    G4String ref;
717                                                   535 
718   const xercesc::DOMNamedNodeMap* const attrib << 536    const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
719   XMLSize_t attributeCount                     << 537    XMLSize_t attributeCount = attributes->getLength();
720                                                   538 
721   for(XMLSize_t attribute_index = 0; attribute << 539    for (XMLSize_t attribute_index=0;
722       ++attribute_index)                       << 540         attribute_index<attributeCount; attribute_index++)
723   {                                            << 541    {
724     xercesc::DOMNode* attribute_node = attribu << 542       xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
725                                                << 543 
726     if(attribute_node->getNodeType() != xerces << 544       if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
727     {                                          << 545       { continue; }
728       continue;                                << 546 
729     }                                          << 547       const xercesc::DOMAttr* const attribute
730                                                << 548             = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
731     const xercesc::DOMAttr* const attribute =  << 549       if (!attribute)
732       dynamic_cast<xercesc::DOMAttr*>(attribut << 550       {
733     if(attribute == nullptr)                   << 551         G4Exception("G4GDMLRead::Read()", "InvalidRead",
734     {                                          << 552                     FatalException, "No attribute found!");
735       G4Exception("G4GDMLRead::Read()", "Inval << 553         return ref;
736                   "No attribute found!");      << 554       }
737       return ref;                              << 555       const G4String attName = Transcode(attribute->getName());
738     }                                          << 556       const G4String attValue = Transcode(attribute->getValue());
739     const G4String attName  = Transcode(attrib << 
740     const G4String attValue = Transcode(attrib << 
741                                                << 
742     if(attName == "ref")                       << 
743     {                                          << 
744       ref = attValue;                          << 
745     }                                          << 
746   }                                            << 
747                                                   557 
748   return ref;                                  << 558       if (attName=="ref") { ref = attValue; }
                                                   >> 559    }
                                                   >> 560 
                                                   >> 561    return ref;
749 }                                                 562 }
750                                                   563 
751 // ------------------------------------------- << 
752 G4bool G4GDMLReadDefine::IsValidID(const G4Str    564 G4bool G4GDMLReadDefine::IsValidID(const G4String& ref) const
753 {                                                 565 {
754   return eval.IsVariable(ref);                 << 566    return eval.IsVariable(ref);
755 }                                                 567 }
756                                                   568 
757 // ------------------------------------------- << 
758 G4double G4GDMLReadDefine::GetConstant(const G    569 G4double G4GDMLReadDefine::GetConstant(const G4String& ref)
759 {                                                 570 {
760   return eval.GetConstant(ref);                << 571    return eval.GetConstant(ref);
761 }                                                 572 }
762                                                   573 
763 // ------------------------------------------- << 
764 G4double G4GDMLReadDefine::GetVariable(const G    574 G4double G4GDMLReadDefine::GetVariable(const G4String& ref)
765 {                                                 575 {
766   return eval.GetVariable(ref);                << 576    return eval.GetVariable(ref);
767 }                                                 577 }
768                                                   578 
769 // ------------------------------------------- << 
770 G4double G4GDMLReadDefine::GetQuantity(const G    579 G4double G4GDMLReadDefine::GetQuantity(const G4String& ref)
771 {                                                 580 {
772   if(quantityMap.find(ref) == quantityMap.cend << 581    if (quantityMap.find(ref) == quantityMap.end())
773   {                                            << 582    {
774     G4String error_msg = "Quantity '" + ref +  << 583      G4String error_msg = "Quantity '"+ref+"' was not found!";
775     G4Exception("G4GDMLReadDefine::getQuantity << 584      G4Exception("G4GDMLReadDefine::getQuantity()", "ReadError",
776                 error_msg);                    << 585                  FatalException, error_msg);
777   }                                            << 586    }
778   return quantityMap[ref];                     << 587    return quantityMap[ref];
779 }                                                 588 }
780                                                   589 
781 // ------------------------------------------- << 
782 G4ThreeVector G4GDMLReadDefine::GetPosition(co    590 G4ThreeVector G4GDMLReadDefine::GetPosition(const G4String& ref)
783 {                                                 591 {
784   if(positionMap.find(ref) == positionMap.cend << 592    if (positionMap.find(ref) == positionMap.end())
785   {                                            << 593    {
786     G4String error_msg = "Position '" + ref +  << 594      G4String error_msg = "Position '"+ref+"' was not found!";
787     G4Exception("G4GDMLReadDefine::getPosition << 595      G4Exception("G4GDMLReadDefine::getPosition()", "ReadError",
788                 error_msg);                    << 596                  FatalException, error_msg);
789   }                                            << 597    }
790   return positionMap[ref];                     << 598    return positionMap[ref];
791 }                                                 599 }
792                                                   600 
793 // ------------------------------------------- << 
794 G4ThreeVector G4GDMLReadDefine::GetRotation(co    601 G4ThreeVector G4GDMLReadDefine::GetRotation(const G4String& ref)
795 {                                                 602 {
796   if(rotationMap.find(ref) == rotationMap.cend << 603    if (rotationMap.find(ref) == rotationMap.end())
797   {                                            << 604    {
798     G4String error_msg = "Rotation '" + ref +  << 605      G4String error_msg = "Rotation '"+ref+"' was not found!";
799     G4Exception("G4GDMLReadDefine::getRotation << 606      G4Exception("G4GDMLReadDefine::getRotation()", "ReadError",
800                 error_msg);                    << 607                  FatalException, error_msg);
801   }                                            << 608    }
802   return rotationMap[ref];                     << 609    return rotationMap[ref];
803 }                                                 610 }
804                                                   611 
805 // ------------------------------------------- << 
806 G4ThreeVector G4GDMLReadDefine::GetScale(const    612 G4ThreeVector G4GDMLReadDefine::GetScale(const G4String& ref)
807 {                                                 613 {
808   if(scaleMap.find(ref) == scaleMap.end())     << 614    if (scaleMap.find(ref) == scaleMap.end())
809   {                                            << 615    {
810     G4String error_msg = "Scale '" + ref + "'  << 616      G4String error_msg = "Scale '"+ref+"' was not found!";
811     G4Exception("G4GDMLReadDefine::getScale()" << 617      G4Exception("G4GDMLReadDefine::getScale()", "ReadError",
812                 error_msg);                    << 618                  FatalException, error_msg);
813   }                                            << 619    }
814   return scaleMap[ref];                        << 620    return scaleMap[ref];
815 }                                                 621 }
816                                                   622 
817 // ------------------------------------------- << 
818 G4GDMLMatrix G4GDMLReadDefine::GetMatrix(const    623 G4GDMLMatrix G4GDMLReadDefine::GetMatrix(const G4String& ref)
819 {                                                 624 {
820   if(matrixMap.find(ref) == matrixMap.end())   << 625    if (matrixMap.find(ref) == matrixMap.end())
821   {                                            << 626    {
822     G4String error_msg = "Matrix '" + ref + "' << 627      G4String error_msg = "Matrix '"+ref+"' was not found!";
823     G4Exception("G4GDMLReadDefine::getMatrix() << 628      G4Exception("G4GDMLReadDefine::getMatrix()", "ReadError",
824                 error_msg);                    << 629                  FatalException, error_msg);
825   }                                            << 630    }
826   return matrixMap[ref];                       << 631    return matrixMap[ref];
827 }                                                 632 }
828                                                   633