Geant4  10.01.p01
G4GDMLReadSolids.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4GDMLReadSolids.cc 86814 2014-11-18 14:47:24Z gcosmo $
27 //
28 // class G4GDMLReadSolids Implementation
29 //
30 // Original author: Zoltan Torzsok, November 2007
31 //
32 // --------------------------------------------------------------------
33 
34 #include "G4GDMLReadSolids.hh"
35 #include "G4Box.hh"
36 #include "G4Cons.hh"
37 #include "G4Ellipsoid.hh"
38 #include "G4EllipticalCone.hh"
39 #include "G4EllipticalTube.hh"
40 #include "G4Hype.hh"
41 #include "G4IntersectionSolid.hh"
42 #include "G4Orb.hh"
43 #include "G4Para.hh"
44 #include "G4Paraboloid.hh"
45 #include "G4Polycone.hh"
46 #include "G4GenericPolycone.hh"
47 #include "G4Polyhedra.hh"
48 #include "G4QuadrangularFacet.hh"
49 #include "G4ReflectedSolid.hh"
50 #include "G4Sphere.hh"
51 #include "G4SolidStore.hh"
52 #include "G4SubtractionSolid.hh"
53 #include "G4GenericTrap.hh"
54 #include "G4TessellatedSolid.hh"
55 #include "G4Tet.hh"
56 #include "G4Torus.hh"
57 #include "G4Transform3D.hh"
58 #include "G4Trap.hh"
59 #include "G4Trd.hh"
60 #include "G4TriangularFacet.hh"
61 #include "G4Tubs.hh"
62 #include "G4CutTubs.hh"
63 #include "G4TwistedBox.hh"
64 #include "G4TwistedTrap.hh"
65 #include "G4TwistedTrd.hh"
66 #include "G4TwistedTubs.hh"
67 #include "G4UnionSolid.hh"
68 #include "G4OpticalSurface.hh"
69 #include "G4SurfaceProperty.hh"
70 
72 {
73 }
74 
76 {
77 }
78 
80 BooleanRead(const xercesc::DOMElement* const booleanElement, const BooleanOp op)
81 {
82  G4String name;
83  G4String first;
84  G4String scnd;
85  G4ThreeVector position(0.0,0.0,0.0);
86  G4ThreeVector rotation(0.0,0.0,0.0);
87  G4ThreeVector firstposition(0.0,0.0,0.0);
88  G4ThreeVector firstrotation(0.0,0.0,0.0);
89 
90  const xercesc::DOMNamedNodeMap* const attributes
91  = booleanElement->getAttributes();
92  XMLSize_t attributeCount = attributes->getLength();
93 
94  for (XMLSize_t attribute_index=0;
95  attribute_index<attributeCount; attribute_index++)
96  {
97  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
98 
99  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
100  { continue; }
101 
102  const xercesc::DOMAttr* const attribute
103  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
104  if (!attribute)
105  {
106  G4Exception("G4GDMLReadSolids::BooleanRead()",
107  "InvalidRead", FatalException, "No attribute found!");
108  return;
109  }
110  const G4String attName = Transcode(attribute->getName());
111  const G4String attValue = Transcode(attribute->getValue());
112 
113  if (attName=="name") { name = GenerateName(attValue); }
114  }
115 
116  for (xercesc::DOMNode* iter = booleanElement->getFirstChild();
117  iter != 0;iter = iter->getNextSibling())
118  {
119  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
120 
121  const xercesc::DOMElement* const child
122  = dynamic_cast<xercesc::DOMElement*>(iter);
123  if (!child)
124  {
125  G4Exception("G4GDMLReadSolids::BooleanRead()",
126  "InvalidRead", FatalException, "No child found!");
127  return;
128  }
129  const G4String tag = Transcode(child->getTagName());
130 
131  if (tag=="first") { first = RefRead(child); } else
132  if (tag=="second") { scnd = RefRead(child); } else
133  if (tag=="position") { VectorRead(child,position); } else
134  if (tag=="rotation") { VectorRead(child,rotation); } else
135  if (tag=="positionref")
136  { position = GetPosition(GenerateName(RefRead(child))); } else
137  if (tag=="rotationref")
138  { rotation = GetRotation(GenerateName(RefRead(child))); } else
139  if (tag=="firstposition") { VectorRead(child,firstposition); } else
140  if (tag=="firstrotation") { VectorRead(child,firstrotation); } else
141  if (tag=="firstpositionref")
142  { firstposition = GetPosition(GenerateName(RefRead(child))); } else
143  if (tag=="firstrotationref")
144  { firstrotation = GetRotation(GenerateName(RefRead(child))); }
145  else
146  {
147  G4String error_msg = "Unknown tag in boolean solid: " + tag;
148  G4Exception("G4GDMLReadSolids::BooleanRead()", "ReadError",
149  FatalException, error_msg);
150  }
151  }
152 
153  G4VSolid* firstSolid = GetSolid(GenerateName(first));
154  G4VSolid* secondSolid = GetSolid(GenerateName(scnd));
155 
156  G4Transform3D transform(GetRotationMatrix(rotation),position);
157 
158  if (( (firstrotation.x()!=0.0) || (firstrotation.y()!=0.0)
159  || (firstrotation.z()!=0.0))
160  || ( (firstposition.x()!=0.0) || (firstposition.y()!=0.0)
161  || (firstposition.z()!=0.0)))
162  {
163  G4Transform3D firsttransform(GetRotationMatrix(firstrotation),
164  firstposition);
165  firstSolid = new G4DisplacedSolid(GenerateName("displaced_"+first),
166  firstSolid, firsttransform);
167  }
168 
169  if (op==UNION)
170  { new G4UnionSolid(name,firstSolid,secondSolid,transform); } else
171  if (op==SUBTRACTION)
172  { new G4SubtractionSolid(name,firstSolid,secondSolid,transform); } else
173  if (op==INTERSECTION)
174  { new G4IntersectionSolid(name,firstSolid,secondSolid,transform); }
175 }
176 
177 void G4GDMLReadSolids::BoxRead(const xercesc::DOMElement* const boxElement)
178 {
179  G4String name;
180  G4double lunit = 1.0;
181  G4double x = 0.0;
182  G4double y = 0.0;
183  G4double z = 0.0;
184 
185  const xercesc::DOMNamedNodeMap* const attributes
186  = boxElement->getAttributes();
187  XMLSize_t attributeCount = attributes->getLength();
188 
189  for (XMLSize_t attribute_index=0;
190  attribute_index<attributeCount; attribute_index++)
191  {
192  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
193 
194  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
195  { continue; }
196 
197  const xercesc::DOMAttr* const attribute
198  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
199  if (!attribute)
200  {
201  G4Exception("G4GDMLReadSolids::BoxRead()",
202  "InvalidRead", FatalException, "No attribute found!");
203  return;
204  }
205  const G4String attName = Transcode(attribute->getName());
206  const G4String attValue = Transcode(attribute->getValue());
207 
208  if (attName=="name") { name = GenerateName(attValue); } else
209  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
210  if (attName=="x") { x = eval.Evaluate(attValue); } else
211  if (attName=="y") { y = eval.Evaluate(attValue); } else
212  if (attName=="z") { z = eval.Evaluate(attValue); }
213  }
214 
215  x *= 0.5*lunit;
216  y *= 0.5*lunit;
217  z *= 0.5*lunit;
218 
219  new G4Box(name,x,y,z);
220 }
221 
222 void G4GDMLReadSolids::ConeRead(const xercesc::DOMElement* const coneElement)
223 {
224  G4String name;
225  G4double lunit = 1.0;
226  G4double aunit = 1.0;
227  G4double rmin1 = 0.0;
228  G4double rmax1 = 0.0;
229  G4double rmin2 = 0.0;
230  G4double rmax2 = 0.0;
231  G4double z = 0.0;
232  G4double startphi = 0.0;
233  G4double deltaphi = 0.0;
234 
235  const xercesc::DOMNamedNodeMap* const attributes
236  = coneElement->getAttributes();
237  XMLSize_t attributeCount = attributes->getLength();
238 
239  for (XMLSize_t attribute_index=0;
240  attribute_index<attributeCount; attribute_index++)
241  {
242  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
243 
244  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
245  { continue; }
246 
247  const xercesc::DOMAttr* const attribute
248  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
249  if (!attribute)
250  {
251  G4Exception("G4GDMLReadSolids::ConeRead()",
252  "InvalidRead", FatalException, "No attribute found!");
253  return;
254  }
255  const G4String attName = Transcode(attribute->getName());
256  const G4String attValue = Transcode(attribute->getValue());
257 
258  if (attName=="name") { name = GenerateName(attValue); } else
259  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
260  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
261  if (attName=="rmin1") { rmin1 = eval.Evaluate(attValue); } else
262  if (attName=="rmax1") { rmax1 = eval.Evaluate(attValue); } else
263  if (attName=="rmin2") { rmin2 = eval.Evaluate(attValue); } else
264  if (attName=="rmax2") { rmax2 = eval.Evaluate(attValue); } else
265  if (attName=="z") { z = eval.Evaluate(attValue); } else
266  if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
267  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
268  }
269 
270  rmin1 *= lunit;
271  rmax1 *= lunit;
272  rmin2 *= lunit;
273  rmax2 *= lunit;
274  z *= 0.5*lunit;
275  startphi *= aunit;
276  deltaphi *= aunit;
277 
278  new G4Cons(name,rmin1,rmax1,rmin2,rmax2,z,startphi,deltaphi);
279 }
280 
282 ElconeRead(const xercesc::DOMElement* const elconeElement)
283 {
284  G4String name;
285  G4double lunit = 1.0;
286  G4double dx = 0.0;
287  G4double dy = 0.0;
288  G4double zmax = 0.0;
289  G4double zcut = 0.0;
290 
291  const xercesc::DOMNamedNodeMap* const attributes
292  = elconeElement->getAttributes();
293  XMLSize_t attributeCount = attributes->getLength();
294 
295  for (XMLSize_t attribute_index=0;
296  attribute_index<attributeCount; attribute_index++)
297  {
298  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
299 
300  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
301  { continue; }
302 
303  const xercesc::DOMAttr* const attribute
304  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
305  if (!attribute)
306  {
307  G4Exception("G4GDMLReadSolids::ElconeRead()",
308  "InvalidRead", FatalException, "No attribute found!");
309  return;
310  }
311  const G4String attName = Transcode(attribute->getName());
312  const G4String attValue = Transcode(attribute->getValue());
313 
314  if (attName=="name") { name = GenerateName(attValue); } else
315  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
316  if (attName=="dx") { dx = eval.Evaluate(attValue); } else
317  if (attName=="dy") { dy = eval.Evaluate(attValue); } else
318  if (attName=="zmax") { zmax = eval.Evaluate(attValue); } else
319  if (attName=="zcut") { zcut = eval.Evaluate(attValue); }
320  }
321 
322  zmax *= lunit;
323  zcut *= lunit;
324 
325  new G4EllipticalCone(name,dx,dy,zmax,zcut);
326 }
327 
329 EllipsoidRead(const xercesc::DOMElement* const ellipsoidElement)
330 {
331  G4String name;
332  G4double lunit = 1.0;
333  G4double ax = 0.0;
334  G4double by = 0.0;
335  G4double cz = 0.0;
336  G4double zcut1 = 0.0;
337  G4double zcut2 = 0.0;
338 
339  const xercesc::DOMNamedNodeMap* const attributes
340  = ellipsoidElement->getAttributes();
341  XMLSize_t attributeCount = attributes->getLength();
342 
343  for (XMLSize_t attribute_index=0;
344  attribute_index<attributeCount; attribute_index++)
345  {
346  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
347 
348  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
349  { continue; }
350 
351  const xercesc::DOMAttr* const attribute
352  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
353  if (!attribute)
354  {
355  G4Exception("G4GDMLReadSolids::EllipsoidRead()",
356  "InvalidRead", FatalException, "No attribute found!");
357  return;
358  }
359  const G4String attName = Transcode(attribute->getName());
360  const G4String attValue = Transcode(attribute->getValue());
361 
362  if (attName=="name") { name = GenerateName(attValue); } else
363  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
364  if (attName=="ax") { ax = eval.Evaluate(attValue); } else
365  if (attName=="by") { by = eval.Evaluate(attValue); } else
366  if (attName=="cz") { cz = eval.Evaluate(attValue); } else
367  if (attName=="zcut1") { zcut1 = eval.Evaluate(attValue); } else
368  if (attName=="zcut2") { zcut2 = eval.Evaluate(attValue); }
369  }
370 
371  ax *= lunit;
372  by *= lunit;
373  cz *= lunit;
374  zcut1 *= lunit;
375  zcut2 *= lunit;
376 
377  new G4Ellipsoid(name,ax,by,cz,zcut1,zcut2);
378 }
379 
381 EltubeRead(const xercesc::DOMElement* const eltubeElement)
382 {
383  G4String name;
384  G4double lunit = 1.0;
385  G4double dx = 0.0;
386  G4double dy = 0.0;
387  G4double dz = 0.0;
388 
389  const xercesc::DOMNamedNodeMap* const attributes
390  = eltubeElement->getAttributes();
391  XMLSize_t attributeCount = attributes->getLength();
392 
393  for (XMLSize_t attribute_index=0;
394  attribute_index<attributeCount; attribute_index++)
395  {
396  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
397 
398  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
399  { continue; }
400 
401  const xercesc::DOMAttr* const attribute
402  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
403  if (!attribute)
404  {
405  G4Exception("G4GDMLReadSolids::EltubeRead()",
406  "InvalidRead", FatalException, "No attribute found!");
407  return;
408  }
409  const G4String attName = Transcode(attribute->getName());
410  const G4String attValue = Transcode(attribute->getValue());
411 
412  if (attName=="name") { name = GenerateName(attValue); } else
413  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
414  if (attName=="dx") { dx = eval.Evaluate(attValue); } else
415  if (attName=="dy") { dy = eval.Evaluate(attValue); } else
416  if (attName=="dz") { dz = eval.Evaluate(attValue); }
417  }
418 
419  dx *= lunit;
420  dy *= lunit;
421  dz *= lunit;
422 
423  new G4EllipticalTube(name,dx,dy,dz);
424 }
425 
426 void G4GDMLReadSolids::XtruRead(const xercesc::DOMElement* const xtruElement)
427 {
428  G4String name;
429  G4double lunit = 1.0;
430 
431  const xercesc::DOMNamedNodeMap* const attributes
432  = xtruElement->getAttributes();
433  XMLSize_t attributeCount = attributes->getLength();
434 
435  for (XMLSize_t attribute_index=0;
436  attribute_index<attributeCount; attribute_index++)
437  {
438  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
439 
440  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
441  { continue; }
442 
443  const xercesc::DOMAttr* const attribute
444  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
445  if (!attribute)
446  {
447  G4Exception("G4GDMLReadSolids::XtruRead()",
448  "InvalidRead", FatalException, "No attribute found!");
449  return;
450  }
451  const G4String attName = Transcode(attribute->getName());
452  const G4String attValue = Transcode(attribute->getValue());
453 
454  if (attName=="name") { name = GenerateName(attValue); } else
455  if (attName=="lunit") { lunit = eval.Evaluate(attValue); }
456  }
457 
458  std::vector<G4TwoVector> twoDimVertexList;
459  std::vector<G4ExtrudedSolid::ZSection> sectionList;
460 
461  for (xercesc::DOMNode* iter = xtruElement->getFirstChild();
462  iter != 0; iter = iter->getNextSibling())
463  {
464  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
465 
466  const xercesc::DOMElement* const child
467  = dynamic_cast<xercesc::DOMElement*>(iter);
468  if (!child)
469  {
470  G4Exception("G4GDMLReadSolids::XtruRead()",
471  "InvalidRead", FatalException, "No child found!");
472  return;
473  }
474  const G4String tag = Transcode(child->getTagName());
475 
476  if (tag=="twoDimVertex")
477  { twoDimVertexList.push_back(TwoDimVertexRead(child,lunit)); } else
478  if (tag=="section")
479  { sectionList.push_back(SectionRead(child,lunit)); }
480  }
481 
482  new G4ExtrudedSolid(name,twoDimVertexList,sectionList);
483 }
484 
485 void G4GDMLReadSolids::HypeRead(const xercesc::DOMElement* const hypeElement)
486 {
487  G4String name;
488  G4double lunit = 1.0;
489  G4double aunit = 1.0;
490  G4double rmin = 0.0;
491  G4double rmax = 0.0;
492  G4double inst = 0.0;
493  G4double outst = 0.0;
494  G4double z = 0.0;
495 
496  const xercesc::DOMNamedNodeMap* const attributes
497  = hypeElement->getAttributes();
498  XMLSize_t attributeCount = attributes->getLength();
499 
500  for (XMLSize_t attribute_index=0;
501  attribute_index<attributeCount; attribute_index++)
502  {
503  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
504 
505  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
506  { continue; }
507 
508  const xercesc::DOMAttr* const attribute
509  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
510  if (!attribute)
511  {
512  G4Exception("G4GDMLReadSolids::HypeRead()",
513  "InvalidRead", FatalException, "No attribute found!");
514  return;
515  }
516  const G4String attName = Transcode(attribute->getName());
517  const G4String attValue = Transcode(attribute->getValue());
518 
519  if (attName=="name") { name = GenerateName(attValue); } else
520  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
521  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
522  if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
523  if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
524  if (attName=="inst") { inst = eval.Evaluate(attValue); } else
525  if (attName=="outst") { outst = eval.Evaluate(attValue); } else
526  if (attName=="z") { z = eval.Evaluate(attValue); }
527  }
528 
529  rmin *= lunit;
530  rmax *= lunit;
531  inst *= aunit;
532  outst *= aunit;
533  z *= 0.5*lunit;
534 
535  new G4Hype(name,rmin,rmax,inst,outst,z);
536 }
537 
539 MultiUnionNodeRead(const xercesc::DOMElement* const unionNodeElement,
540  G4MultiUnion* const multiUnionSolid)
541 {
542 #if !defined(G4GEOM_USE_USOLIDS)
543  G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
544  "InvalidSetup", FatalException,
545  "Installation with USolids primitives required!");
546  return;
547 #endif
548  G4String name;
549  G4String solid;
550  G4ThreeVector position(0.0,0.0,0.0);
551  G4ThreeVector rotation(0.0,0.0,0.0);
552 
553  const xercesc::DOMNamedNodeMap* const attributes
554  = unionNodeElement->getAttributes();
555  XMLSize_t attributeCount = attributes->getLength();
556 
557  for (XMLSize_t attribute_index=0;
558  attribute_index<attributeCount; attribute_index++)
559  {
560  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
561 
562  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
563  { continue; }
564 
565  const xercesc::DOMAttr* const attribute
566  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
567  if (!attribute)
568  {
569  G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
570  "InvalidRead", FatalException, "No attribute found!");
571  return;
572  }
573  const G4String attName = Transcode(attribute->getName());
574  const G4String attValue = Transcode(attribute->getValue());
575 
576  if (attName=="name") { name = GenerateName(attValue); }
577  }
578 
579  for (xercesc::DOMNode* iter = unionNodeElement->getFirstChild();
580  iter != 0;iter = iter->getNextSibling())
581  {
582  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
583 
584  const xercesc::DOMElement* const child
585  = dynamic_cast<xercesc::DOMElement*>(iter);
586  if (!child)
587  {
588  G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()",
589  "InvalidRead", FatalException, "No child found!");
590  return;
591  }
592  const G4String tag = Transcode(child->getTagName());
593 
594  if (tag=="position") { VectorRead(child,position); } else
595  if (tag=="rotation") { VectorRead(child,rotation); } else
596  if (tag=="positionref")
597  { position = GetPosition(GenerateName(RefRead(child))); } else
598  if (tag=="rotationref")
599  { rotation = GetRotation(GenerateName(RefRead(child))); } else
600  if (tag=="solid") { solid = RefRead(child); }
601  else
602  {
603  G4String error_msg = "Unknown tag in MultiUnion structure: " + tag;
604  G4Exception("G4GDMLReadSolids::MultiUnionNodeRead()", "ReadError",
605  FatalException, error_msg);
606  }
607  }
608  G4VSolid* solidNode = GetSolid(GenerateName(solid));
609  G4Transform3D transform(GetRotationMatrix(rotation),position);
610  multiUnionSolid->AddNode(*solidNode, transform);
611 }
612 
614 MultiUnionRead(const xercesc::DOMElement* const unionElement)
615 {
616 #if !defined(G4GEOM_USE_USOLIDS)
617  G4Exception("G4GDMLReadSolids::MultiUnionRead()",
618  "InvalidSetup", FatalException,
619  "Installation with USolids primitives required!");
620  return;
621 #endif
622  G4String name;
623 
624  const xercesc::DOMNamedNodeMap* const attributes
625  = unionElement->getAttributes();
626  XMLSize_t attributeCount = attributes->getLength();
627 
628  for (XMLSize_t attribute_index=0;
629  attribute_index<attributeCount; attribute_index++)
630  {
631  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
632 
633  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
634  { continue; }
635 
636  const xercesc::DOMAttr* const attribute
637  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
638  if (!attribute)
639  {
640  G4Exception("G4GDMLReadSolids::MultiUnionRead()",
641  "InvalidRead", FatalException, "No attribute found!");
642  return;
643  }
644  const G4String attName = Transcode(attribute->getName());
645  const G4String attValue = Transcode(attribute->getValue());
646 
647  if (attName=="name") { name = GenerateName(attValue); }
648  }
649 
650  G4MultiUnion* multiUnion = new G4MultiUnion(name);
651 
652  for (xercesc::DOMNode* iter = unionElement->getFirstChild();
653  iter != 0;iter = iter->getNextSibling())
654  {
655  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
656 
657  const xercesc::DOMElement* const child
658  = dynamic_cast<xercesc::DOMElement*>(iter);
659  if (!child)
660  {
661  G4Exception("G4GDMLReadSolids::MultiUnionRead()",
662  "InvalidRead", FatalException, "No child found!");
663  return;
664  }
665  const G4String tag = Transcode(child->getTagName());
666 
667  if (tag=="multiUnionNode") { MultiUnionNodeRead(child, multiUnion); }
668  else
669  {
670  G4String error_msg = "Unknown tag in MultiUnion structure: " + tag;
671  G4Exception("G4GDMLReadSolids::MultiUnionRead()", "ReadError",
672  FatalException, error_msg);
673  }
674  }
675  multiUnion->Voxelize();
676 }
677 
678 void G4GDMLReadSolids::OrbRead(const xercesc::DOMElement* const orbElement)
679 {
680  G4String name;
681  G4double lunit = 1.0;
682  G4double r = 0.0;
683 
684  const xercesc::DOMNamedNodeMap* const attributes
685  = orbElement->getAttributes();
686  XMLSize_t attributeCount = attributes->getLength();
687 
688  for (XMLSize_t attribute_index=0;
689  attribute_index<attributeCount; attribute_index++)
690  {
691  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
692 
693  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
694  { continue; }
695 
696  const xercesc::DOMAttr* const attribute
697  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
698  if (!attribute)
699  {
700  G4Exception("G4GDMLReadSolids::OrbRead()",
701  "InvalidRead", FatalException, "No attribute found!");
702  return;
703  }
704  const G4String attName = Transcode(attribute->getName());
705  const G4String attValue = Transcode(attribute->getValue());
706 
707  if (attName=="name") { name = GenerateName(attValue); } else
708  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
709  if (attName=="r") { r = eval.Evaluate(attValue); }
710  }
711 
712  r *= lunit;
713 
714  new G4Orb(name,r);
715 }
716 
717 void G4GDMLReadSolids::ParaRead(const xercesc::DOMElement* const paraElement)
718 {
719  G4String name;
720  G4double lunit = 1.0;
721  G4double aunit = 1.0;
722  G4double x = 0.0;
723  G4double y = 0.0;
724  G4double z = 0.0;
725  G4double alpha = 0.0;
726  G4double theta = 0.0;
727  G4double phi = 0.0;
728 
729  const xercesc::DOMNamedNodeMap* const attributes
730  = paraElement->getAttributes();
731  XMLSize_t attributeCount = attributes->getLength();
732 
733  for (XMLSize_t attribute_index=0;
734  attribute_index<attributeCount; attribute_index++)
735  {
736  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
737 
738  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
739  { continue; }
740 
741  const xercesc::DOMAttr* const attribute
742  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
743  if (!attribute)
744  {
745  G4Exception("G4GDMLReadSolids::ParaRead()",
746  "InvalidRead", FatalException, "No attribute found!");
747  return;
748  }
749  const G4String attName = Transcode(attribute->getName());
750  const G4String attValue = Transcode(attribute->getValue());
751 
752  if (attName=="name") { name = GenerateName(attValue); } else
753  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
754  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
755  if (attName=="x") { x = eval.Evaluate(attValue); } else
756  if (attName=="y") { y = eval.Evaluate(attValue); } else
757  if (attName=="z") { z = eval.Evaluate(attValue); } else
758  if (attName=="alpha") { alpha = eval.Evaluate(attValue); } else
759  if (attName=="theta") { theta = eval.Evaluate(attValue); } else
760  if (attName=="phi") { phi = eval.Evaluate(attValue); }
761  }
762 
763  x *= 0.5*lunit;
764  y *= 0.5*lunit;
765  z *= 0.5*lunit;
766  alpha *= aunit;
767  theta *= aunit;
768  phi *= aunit;
769 
770  new G4Para(name,x,y,z,alpha,theta,phi);
771 }
772 
774 ParaboloidRead(const xercesc::DOMElement* const paraElement)
775 {
776  G4String name;
777  G4double lunit = 1.0;
778  G4double rlo = 0.0;
779  G4double rhi = 0.0;
780  G4double dz = 0.0;
781 
782  const xercesc::DOMNamedNodeMap* const attributes
783  = paraElement->getAttributes();
784  XMLSize_t attributeCount = attributes->getLength();
785 
786  for (XMLSize_t attribute_index=0;
787  attribute_index<attributeCount; attribute_index++)
788  {
789  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
790 
791  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
792  { continue; }
793 
794  const xercesc::DOMAttr* const attribute
795  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
796  if (!attribute)
797  {
798  G4Exception("G4GDMLReadSolids::ParaboloidRead()",
799  "InvalidRead", FatalException, "No attribute found!");
800  return;
801  }
802  const G4String attName = Transcode(attribute->getName());
803  const G4String attValue = Transcode(attribute->getValue());
804 
805  if (attName=="name") { name = GenerateName(attValue); } else
806  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
807  if (attName=="rlo") { rlo = eval.Evaluate(attValue); } else
808  if (attName=="rhi") { rhi = eval.Evaluate(attValue); } else
809  if (attName=="dz") { dz = eval.Evaluate(attValue); }
810  }
811 
812  rlo *= 1.*lunit;
813  rhi *= 1.*lunit;
814  dz *= 1.*lunit;
815 
816  new G4Paraboloid(name,dz,rlo,rhi);
817 }
818 
820 PolyconeRead(const xercesc::DOMElement* const polyconeElement)
821 {
822  G4String name;
823  G4double lunit = 1.0;
824  G4double aunit = 1.0;
825  G4double startphi = 0.0;
826  G4double deltaphi = 0.0;
827 
828  const xercesc::DOMNamedNodeMap* const attributes
829  = polyconeElement->getAttributes();
830  XMLSize_t attributeCount = attributes->getLength();
831 
832  for (XMLSize_t attribute_index=0;
833  attribute_index<attributeCount; attribute_index++)
834  {
835  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
836 
837  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
838  { continue; }
839 
840  const xercesc::DOMAttr* const attribute
841  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
842  if (!attribute)
843  {
844  G4Exception("G4GDMLReadSolids::PolyconeRead()",
845  "InvalidRead", FatalException, "No attribute found!");
846  return;
847  }
848  const G4String attName = Transcode(attribute->getName());
849  const G4String attValue = Transcode(attribute->getValue());
850 
851  if (attName=="name") { name = GenerateName(attValue); } else
852  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
853  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
854  if (attName=="startphi") { startphi = eval.Evaluate(attValue); }else
855  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
856  }
857 
858  startphi *= aunit;
859  deltaphi *= aunit;
860 
861  std::vector<zplaneType> zplaneList;
862 
863  for (xercesc::DOMNode* iter = polyconeElement->getFirstChild();
864  iter != 0; iter = iter->getNextSibling())
865  {
866  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
867 
868  const xercesc::DOMElement* const child
869  = dynamic_cast<xercesc::DOMElement*>(iter);
870  if (!child)
871  {
872  G4Exception("G4GDMLReadSolids::PolyconeRead()",
873  "InvalidRead", FatalException, "No child found!");
874  return;
875  }
876  const G4String tag = Transcode(child->getTagName());
877 
878  if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
879  }
880 
881  G4int numZPlanes = zplaneList.size();
882 
883  G4double* rmin_array = new G4double[numZPlanes];
884  G4double* rmax_array = new G4double[numZPlanes];
885  G4double* z_array = new G4double[numZPlanes];
886 
887  for (G4int i=0; i<numZPlanes; i++)
888  {
889  rmin_array[i] = zplaneList[i].rmin*lunit;
890  rmax_array[i] = zplaneList[i].rmax*lunit;
891  z_array[i] = zplaneList[i].z*lunit;
892  }
893 
894  new G4Polycone(name,startphi,deltaphi,numZPlanes,
895  z_array,rmin_array,rmax_array);
896 
897  delete [] rmin_array;
898  delete [] rmax_array;
899  delete [] z_array;
900 }
901 
903 GenericPolyconeRead(const xercesc::DOMElement* const polyconeElement)
904 {
905  G4String name;
906  G4double lunit = 1.0;
907  G4double aunit = 1.0;
908  G4double startphi = 0.0;
909  G4double deltaphi = 0.0;
910 
911  const xercesc::DOMNamedNodeMap* const attributes
912  = polyconeElement->getAttributes();
913  XMLSize_t attributeCount = attributes->getLength();
914 
915  for (XMLSize_t attribute_index=0;
916  attribute_index<attributeCount; attribute_index++)
917  {
918  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
919 
920  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
921  { continue; }
922 
923  const xercesc::DOMAttr* const attribute
924  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
925  if (!attribute)
926  {
927  G4Exception("G4GDMLReadSolids::GenericPolyconeRead()",
928  "InvalidRead", FatalException, "No attribute found!");
929  return;
930  }
931  const G4String attName = Transcode(attribute->getName());
932  const G4String attValue = Transcode(attribute->getValue());
933 
934  if (attName=="name") { name = GenerateName(attValue); } else
935  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
936  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
937  if (attName=="startphi") { startphi = eval.Evaluate(attValue); }else
938  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
939  }
940 
941  startphi *= aunit;
942  deltaphi *= aunit;
943 
944  std::vector<rzPointType> rzPointList;
945 
946  for (xercesc::DOMNode* iter = polyconeElement->getFirstChild();
947  iter != 0; iter = iter->getNextSibling())
948  {
949  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
950 
951  const xercesc::DOMElement* const child
952  = dynamic_cast<xercesc::DOMElement*>(iter);
953  if (!child)
954  {
955  G4Exception("G4GDMLReadSolids::GenericPolyconeRead()",
956  "InvalidRead", FatalException, "No child found!");
957  return;
958  }
959  const G4String tag = Transcode(child->getTagName());
960 
961  if (tag=="rzpoint") { rzPointList.push_back(RZPointRead(child)); }
962  }
963 
964  G4int numRZPoints = rzPointList.size();
965 
966  G4double* r_array = new G4double[numRZPoints];
967  G4double* z_array = new G4double[numRZPoints];
968 
969  for (G4int i=0; i<numRZPoints; i++)
970  {
971  r_array[i] = rzPointList[i].r*lunit;
972  z_array[i] = rzPointList[i].z*lunit;
973  }
974  new G4GenericPolycone(name,startphi,deltaphi,numRZPoints,
975  r_array,z_array);
976  delete [] r_array;
977  delete [] z_array;
978 }
979 
981 PolyhedraRead(const xercesc::DOMElement* const polyhedraElement)
982 {
983  G4String name;
984  G4double lunit = 1.0;
985  G4double aunit = 1.0;
986  G4double startphi = 0.0;
987  G4double deltaphi = 0.0;
988  G4int numsides = 0;
989 
990  const xercesc::DOMNamedNodeMap* const attributes
991  = polyhedraElement->getAttributes();
992  XMLSize_t attributeCount = attributes->getLength();
993 
994  for (XMLSize_t attribute_index=0;
995  attribute_index<attributeCount; attribute_index++)
996  {
997  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
998 
999  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1000  { continue; }
1001 
1002  const xercesc::DOMAttr* const attribute
1003  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1004  if (!attribute)
1005  {
1006  G4Exception("G4GDMLReadSolids::PolyhedraRead()",
1007  "InvalidRead", FatalException, "No attribute found!");
1008  return;
1009  }
1010  const G4String attName = Transcode(attribute->getName());
1011  const G4String attValue = Transcode(attribute->getValue());
1012 
1013  if (attName=="name") { name = GenerateName(attValue); } else
1014  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1015  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1016  if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
1017  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
1018  if (attName=="numsides") { numsides = eval.EvaluateInteger(attValue); }
1019  }
1020 
1021  startphi *= aunit;
1022  deltaphi *= aunit;
1023 
1024  std::vector<zplaneType> zplaneList;
1025 
1026  for (xercesc::DOMNode* iter = polyhedraElement->getFirstChild();
1027  iter != 0; iter = iter->getNextSibling())
1028  {
1029  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
1030 
1031  const xercesc::DOMElement* const child
1032  = dynamic_cast<xercesc::DOMElement*>(iter);
1033  if (!child)
1034  {
1035  G4Exception("G4GDMLReadSolids::PolyhedraRead()",
1036  "InvalidRead", FatalException, "No child found!");
1037  return;
1038  }
1039  const G4String tag = Transcode(child->getTagName());
1040 
1041  if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); }
1042  }
1043 
1044  G4int numZPlanes = zplaneList.size();
1045 
1046  G4double* rmin_array = new G4double[numZPlanes];
1047  G4double* rmax_array = new G4double[numZPlanes];
1048  G4double* z_array = new G4double[numZPlanes];
1049 
1050  for (G4int i=0; i<numZPlanes; i++)
1051  {
1052  rmin_array[i] = zplaneList[i].rmin*lunit;
1053  rmax_array[i] = zplaneList[i].rmax*lunit;
1054  z_array[i] = zplaneList[i].z*lunit;
1055  }
1056 
1057  new G4Polyhedra(name,startphi,deltaphi,numsides,numZPlanes,
1058  z_array,rmin_array,rmax_array);
1059 
1060  delete [] rmin_array;
1061  delete [] rmax_array;
1062  delete [] z_array;
1063 }
1064 
1065 void G4GDMLReadSolids::
1066 GenericPolyhedraRead(const xercesc::DOMElement* const polyhedraElement)
1067 {
1068  G4String name;
1069  G4double lunit = 1.0;
1070  G4double aunit = 1.0;
1071  G4double startphi = 0.0;
1072  G4double deltaphi = 0.0;
1073  G4int numsides = 0;
1074 
1075  const xercesc::DOMNamedNodeMap* const attributes
1076  = polyhedraElement->getAttributes();
1077  XMLSize_t attributeCount = attributes->getLength();
1078 
1079  for (XMLSize_t attribute_index=0;
1080  attribute_index<attributeCount; attribute_index++)
1081  {
1082  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1083 
1084  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1085  { continue; }
1086 
1087  const xercesc::DOMAttr* const attribute
1088  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1089  if (!attribute)
1090  {
1091  G4Exception("G4GDMLReadSolids::GenericPolyhedraRead()",
1092  "InvalidRead", FatalException, "No attribute found!");
1093  return;
1094  }
1095  const G4String attName = Transcode(attribute->getName());
1096  const G4String attValue = Transcode(attribute->getValue());
1097 
1098  if (attName=="name") { name = GenerateName(attValue); } else
1099  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1100  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1101  if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
1102  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
1103  if (attName=="numsides") { numsides = eval.EvaluateInteger(attValue); }
1104  }
1105 
1106  startphi *= aunit;
1107  deltaphi *= aunit;
1108 
1109  std::vector<rzPointType> rzpointList;
1110 
1111  for (xercesc::DOMNode* iter = polyhedraElement->getFirstChild();
1112  iter != 0; iter = iter->getNextSibling())
1113  {
1114  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
1115 
1116  const xercesc::DOMElement* const child
1117  = dynamic_cast<xercesc::DOMElement*>(iter);
1118  if (!child)
1119  {
1120  G4Exception("G4GDMLReadSolids::GenericPolyhedraRead()",
1121  "InvalidRead", FatalException, "No child found!");
1122  return;
1123  }
1124  const G4String tag = Transcode(child->getTagName());
1125 
1126  if (tag=="rzpoint") { rzpointList.push_back(RZPointRead(child)); }
1127  }
1128 
1129  G4int numRZPoints = rzpointList.size();
1130 
1131  G4double* r_array = new G4double[numRZPoints];
1132  G4double* z_array = new G4double[numRZPoints];
1133 
1134  for (G4int i=0; i<numRZPoints; i++)
1135  {
1136  r_array[i] = rzpointList[i].r*lunit;
1137  z_array[i] = rzpointList[i].z*lunit;
1138  }
1139 
1140  new G4Polyhedra(name,startphi,deltaphi,numsides,numRZPoints,
1141  r_array,z_array);
1142 
1143  delete [] r_array;
1144  delete [] z_array;
1145 }
1146 
1148 QuadrangularRead(const xercesc::DOMElement* const quadrangularElement)
1149 {
1150  G4ThreeVector vertex1;
1151  G4ThreeVector vertex2;
1152  G4ThreeVector vertex3;
1153  G4ThreeVector vertex4;
1154  G4FacetVertexType type = ABSOLUTE;
1155  G4double lunit = 1.0;
1156 
1157  const xercesc::DOMNamedNodeMap* const attributes
1158  = quadrangularElement->getAttributes();
1159  XMLSize_t attributeCount = attributes->getLength();
1160 
1161  for (XMLSize_t attribute_index=0;
1162  attribute_index<attributeCount; attribute_index++)
1163  {
1164  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1165 
1166  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1167  { continue; }
1168 
1169  const xercesc::DOMAttr* const attribute
1170  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1171  if (!attribute)
1172  {
1173  G4Exception("G4GDMLReadSolids::QuadrangularRead()",
1174  "InvalidRead", FatalException, "No attribute found!");
1175  return 0;
1176  }
1177  const G4String attName = Transcode(attribute->getName());
1178  const G4String attValue = Transcode(attribute->getValue());
1179 
1180  if (attName=="vertex1")
1181  { vertex1 = GetPosition(GenerateName(attValue)); } else
1182  if (attName=="vertex2")
1183  { vertex2 = GetPosition(GenerateName(attValue)); } else
1184  if (attName=="vertex3")
1185  { vertex3 = GetPosition(GenerateName(attValue)); } else
1186  if (attName=="vertex4")
1187  { vertex4 = GetPosition(GenerateName(attValue)); } else
1188  if (attName=="lunit")
1189  { lunit = eval.Evaluate(attValue); } else
1190  if (attName=="type")
1191  { if (attValue=="RELATIVE") { type = RELATIVE; } }
1192  }
1193 
1194  return new G4QuadrangularFacet(vertex1*lunit,vertex2*lunit,
1195  vertex3*lunit,vertex4*lunit,type);
1196 }
1197 
1198 void G4GDMLReadSolids::
1199 ReflectedSolidRead(const xercesc::DOMElement* const reflectedSolidElement)
1200 {
1201  G4String name;
1202  G4double lunit = 1.0;
1203  G4double aunit = 1.0;
1204  G4String solid;
1205  G4ThreeVector scale(1.0,1.0,1.0);
1206  G4ThreeVector rotation;
1208 
1209  const xercesc::DOMNamedNodeMap* const attributes
1210  = reflectedSolidElement->getAttributes();
1211  XMLSize_t attributeCount = attributes->getLength();
1212 
1213  for (XMLSize_t attribute_index=0;
1214  attribute_index<attributeCount; attribute_index++)
1215  {
1216  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1217 
1218  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1219  { continue; }
1220 
1221  const xercesc::DOMAttr* const attribute
1222  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1223  if (!attribute)
1224  {
1225  G4Exception("G4GDMLReadSolids::ReflectedSolidRead()",
1226  "InvalidRead", FatalException, "No attribute found!");
1227  return;
1228  }
1229  const G4String attName = Transcode(attribute->getName());
1230  const G4String attValue = Transcode(attribute->getValue());
1231 
1232  if (attName=="name") { name = GenerateName(attValue); } else
1233  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1234  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1235  if (attName=="solid") { solid = GenerateName(attValue); } else
1236  if (attName=="sx") { scale.setX(eval.Evaluate(attValue)); } else
1237  if (attName=="sy") { scale.setY(eval.Evaluate(attValue)); } else
1238  if (attName=="sz") { scale.setZ(eval.Evaluate(attValue)); } else
1239  if (attName=="rx") { rotation.setX(eval.Evaluate(attValue)); } else
1240  if (attName=="ry") { rotation.setY(eval.Evaluate(attValue)); } else
1241  if (attName=="rz") { rotation.setZ(eval.Evaluate(attValue)); } else
1242  if (attName=="dx") { position.setX(eval.Evaluate(attValue)); } else
1243  if (attName=="dy") { position.setY(eval.Evaluate(attValue)); } else
1244  if (attName=="dz") { position.setZ(eval.Evaluate(attValue)); }
1245  }
1246 
1247  rotation *= aunit;
1248  position *= lunit;
1249 
1250  G4Transform3D transform(GetRotationMatrix(rotation),position);
1251  transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z());
1252 
1253  new G4ReflectedSolid(name,GetSolid(solid),transform);
1254 }
1255 
1257 SectionRead(const xercesc::DOMElement* const sectionElement,G4double lunit)
1258 {
1259  G4double zPosition = 0.0;
1260  G4TwoVector Offset;
1261  G4double scalingFactor = 1.0;
1262 
1263  const xercesc::DOMNamedNodeMap* const attributes
1264  = sectionElement->getAttributes();
1265  XMLSize_t attributeCount = attributes->getLength();
1266 
1267  for (XMLSize_t attribute_index=0;
1268  attribute_index<attributeCount; attribute_index++)
1269  {
1270  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1271 
1272  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1273  { continue; }
1274 
1275  const xercesc::DOMAttr* const attribute
1276  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1277  if (!attribute)
1278  {
1279  G4Exception("G4GDMLReadSolids::SectionRead()",
1280  "InvalidRead", FatalException, "No attribute found!");
1281  return G4ExtrudedSolid::ZSection(zPosition,Offset,scalingFactor);
1282  }
1283  const G4String attName = Transcode(attribute->getName());
1284  const G4String attValue = Transcode(attribute->getValue());
1285 
1286  if (attName=="zPosition")
1287  { zPosition = eval.Evaluate(attValue)*lunit; } else
1288  if (attName=="xOffset")
1289  { Offset.setX(eval.Evaluate(attValue)*lunit); } else
1290  if (attName=="yOffset")
1291  { Offset.setY(eval.Evaluate(attValue)*lunit); } else
1292  if (attName=="scalingFactor")
1293  { scalingFactor = eval.Evaluate(attValue); }
1294  }
1295 
1296  return G4ExtrudedSolid::ZSection(zPosition,Offset,scalingFactor);
1297 }
1298 
1299 void G4GDMLReadSolids::
1300 SphereRead(const xercesc::DOMElement* const sphereElement)
1301 {
1302  G4String name;
1303  G4double lunit = 1.0;
1304  G4double aunit = 1.0;
1305  G4double rmin = 0.0;
1306  G4double rmax = 0.0;
1307  G4double startphi = 0.0;
1308  G4double deltaphi = 0.0;
1309  G4double starttheta = 0.0;
1310  G4double deltatheta = 0.0;
1311 
1312  const xercesc::DOMNamedNodeMap* const attributes
1313  = sphereElement->getAttributes();
1314  XMLSize_t attributeCount = attributes->getLength();
1315 
1316  for (XMLSize_t attribute_index=0;
1317  attribute_index<attributeCount; attribute_index++)
1318  {
1319  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1320 
1321  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1322  { continue; }
1323 
1324  const xercesc::DOMAttr* const attribute
1325  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1326  if (!attribute)
1327  {
1328  G4Exception("G4GDMLReadSolids::SphereRead()",
1329  "InvalidRead", FatalException, "No attribute found!");
1330  return;
1331  }
1332  const G4String attName = Transcode(attribute->getName());
1333  const G4String attValue = Transcode(attribute->getValue());
1334 
1335  if (attName=="name") { name = GenerateName(attValue); } else
1336  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1337  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1338  if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
1339  if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
1340  if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
1341  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
1342  if (attName=="starttheta") { starttheta = eval.Evaluate(attValue); } else
1343  if (attName=="deltatheta") { deltatheta = eval.Evaluate(attValue); }
1344  }
1345 
1346  rmin *= lunit;
1347  rmax *= lunit;
1348  startphi *= aunit;
1349  deltaphi *= aunit;
1350  starttheta *= aunit;
1351  deltatheta *= aunit;
1352 
1353  new G4Sphere(name,rmin,rmax,startphi,deltaphi,starttheta,deltatheta);
1354 }
1355 
1356 void G4GDMLReadSolids::
1357 TessellatedRead(const xercesc::DOMElement* const tessellatedElement)
1358 {
1359  G4String name;
1360 
1361  const xercesc::DOMNamedNodeMap* const attributes
1362  = tessellatedElement->getAttributes();
1363  XMLSize_t attributeCount = attributes->getLength();
1364 
1365  for (XMLSize_t attribute_index=0;
1366  attribute_index<attributeCount; attribute_index++)
1367  {
1368  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1369 
1370  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1371  { continue; }
1372 
1373  const xercesc::DOMAttr* const attribute
1374  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1375  if (!attribute)
1376  {
1377  G4Exception("G4GDMLReadSolids::TessellatedRead()",
1378  "InvalidRead", FatalException, "No attribute found!");
1379  return;
1380  }
1381  const G4String attName = Transcode(attribute->getName());
1382  const G4String attValue = Transcode(attribute->getValue());
1383 
1384  if (attName=="name") { name = GenerateName(attValue); }
1385  }
1386 
1387  G4TessellatedSolid *tessellated = new G4TessellatedSolid(name);
1388 
1389  for (xercesc::DOMNode* iter = tessellatedElement->getFirstChild();
1390  iter != 0; iter = iter->getNextSibling())
1391  {
1392  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
1393 
1394  const xercesc::DOMElement* const child
1395  = dynamic_cast<xercesc::DOMElement*>(iter);
1396  if (!child)
1397  {
1398  G4Exception("G4GDMLReadSolids::TessellatedRead()",
1399  "InvalidRead", FatalException, "No child found!");
1400  return;
1401  }
1402  const G4String tag = Transcode(child->getTagName());
1403 
1404  if (tag=="triangular")
1405  { tessellated->AddFacet(TriangularRead(child)); } else
1406  if (tag=="quadrangular")
1407  { tessellated->AddFacet(QuadrangularRead(child)); }
1408  }
1409 
1410  tessellated->SetSolidClosed(true);
1411 }
1412 
1413 void G4GDMLReadSolids::TetRead(const xercesc::DOMElement* const tetElement)
1414 {
1415  G4String name;
1416  G4ThreeVector vertex1;
1417  G4ThreeVector vertex2;
1418  G4ThreeVector vertex3;
1419  G4ThreeVector vertex4;
1420  G4double lunit = 1.0;
1421 
1422  const xercesc::DOMNamedNodeMap* const attributes
1423  = tetElement->getAttributes();
1424  XMLSize_t attributeCount = attributes->getLength();
1425 
1426  for (XMLSize_t attribute_index=0;
1427  attribute_index<attributeCount;attribute_index++)
1428  {
1429  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1430 
1431  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1432  { continue; }
1433 
1434  const xercesc::DOMAttr* const attribute
1435  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1436  if (!attribute)
1437  {
1438  G4Exception("G4GDMLReadSolids::TetRead()",
1439  "InvalidRead", FatalException, "No attribute found!");
1440  return;
1441  }
1442  const G4String attName = Transcode(attribute->getName());
1443  const G4String attValue = Transcode(attribute->getValue());
1444 
1445  if (attName=="name")
1446  { name = GenerateName(attValue); } else
1447  if (attName=="lunit")
1448  { lunit = eval.Evaluate(attValue); } else
1449  if (attName=="vertex1")
1450  { vertex1 = GetPosition(GenerateName(attValue)); } else
1451  if (attName=="vertex2")
1452  { vertex2 = GetPosition(GenerateName(attValue)); } else
1453  if (attName=="vertex3")
1454  { vertex3 = GetPosition(GenerateName(attValue)); } else
1455  if (attName=="vertex4")
1456  { vertex4 = GetPosition(GenerateName(attValue)); }
1457  }
1458 
1459  new G4Tet(name,vertex1*lunit,vertex2*lunit,vertex3*lunit,vertex4*lunit);
1460 }
1461 
1462 void G4GDMLReadSolids::TorusRead(const xercesc::DOMElement* const torusElement)
1463 {
1464  G4String name;
1465  G4double lunit = 1.0;
1466  G4double aunit = 1.0;
1467  G4double rmin = 0.0;
1468  G4double rmax = 0.0;
1469  G4double rtor = 0.0;
1470  G4double startphi = 0.0;
1471  G4double deltaphi = 0.0;
1472 
1473  const xercesc::DOMNamedNodeMap* const attributes
1474  = torusElement->getAttributes();
1475  XMLSize_t attributeCount = attributes->getLength();
1476 
1477  for (XMLSize_t attribute_index=0;
1478  attribute_index<attributeCount; attribute_index++)
1479  {
1480  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1481 
1482  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1483  { continue; }
1484 
1485  const xercesc::DOMAttr* const attribute
1486  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1487  if (!attribute)
1488  {
1489  G4Exception("G4GDMLReadSolids::TorusRead()",
1490  "InvalidRead", FatalException, "No attribute found!");
1491  return;
1492  }
1493  const G4String attName = Transcode(attribute->getName());
1494  const G4String attValue = Transcode(attribute->getValue());
1495 
1496  if (attName=="name") { name = GenerateName(attValue); } else
1497  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1498  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1499  if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
1500  if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
1501  if (attName=="rtor") { rtor = eval.Evaluate(attValue); } else
1502  if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
1503  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
1504  }
1505 
1506  rmin *= lunit;
1507  rmax *= lunit;
1508  rtor *= lunit;
1509  startphi *= aunit;
1510  deltaphi *= aunit;
1511 
1512  new G4Torus(name,rmin,rmax,rtor,startphi,deltaphi);
1513 }
1514 
1515 void G4GDMLReadSolids::
1516 GenTrapRead(const xercesc::DOMElement* const gtrapElement)
1517 {
1518  G4String name;
1519  G4double lunit = 1.0;
1520  G4double dz =0.0;
1521  G4double v1x=0.0, v1y=0.0, v2x=0.0, v2y=0.0, v3x=0.0, v3y=0.0,
1522  v4x=0.0, v4y=0.0, v5x=0.0, v5y=0.0, v6x=0.0, v6y=0.0,
1523  v7x=0.0, v7y=0.0, v8x=0.0, v8y=0.0;
1524 
1525  const xercesc::DOMNamedNodeMap* const attributes
1526  = gtrapElement->getAttributes();
1527  XMLSize_t attributeCount = attributes->getLength();
1528 
1529  for (XMLSize_t attribute_index=0;
1530  attribute_index<attributeCount; attribute_index++)
1531  {
1532  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1533 
1534  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1535  { continue; }
1536 
1537  const xercesc::DOMAttr* const attribute
1538  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1539  if (!attribute)
1540  {
1541  G4Exception("G4GDMLReadSolids::GenTrapRead()",
1542  "InvalidRead", FatalException, "No attribute found!");
1543  return;
1544  }
1545  const G4String attName = Transcode(attribute->getName());
1546  const G4String attValue = Transcode(attribute->getValue());
1547 
1548  if (attName=="name") { name = GenerateName(attValue); } else
1549  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1550  if (attName=="dz") { dz = eval.Evaluate(attValue); } else
1551  if (attName=="v1x") { v1x = eval.Evaluate(attValue); } else
1552  if (attName=="v1y") { v1y = eval.Evaluate(attValue); } else
1553  if (attName=="v2x") { v2x = eval.Evaluate(attValue); } else
1554  if (attName=="v2y") { v2y = eval.Evaluate(attValue); } else
1555  if (attName=="v3x") { v3x = eval.Evaluate(attValue); } else
1556  if (attName=="v3y") { v3y = eval.Evaluate(attValue); } else
1557  if (attName=="v4x") { v4x = eval.Evaluate(attValue); } else
1558  if (attName=="v4y") { v4y = eval.Evaluate(attValue); } else
1559  if (attName=="v5x") { v5x = eval.Evaluate(attValue); } else
1560  if (attName=="v5y") { v5y = eval.Evaluate(attValue); } else
1561  if (attName=="v6x") { v6x = eval.Evaluate(attValue); } else
1562  if (attName=="v6y") { v6y = eval.Evaluate(attValue); } else
1563  if (attName=="v7x") { v7x = eval.Evaluate(attValue); } else
1564  if (attName=="v7y") { v7y = eval.Evaluate(attValue); } else
1565  if (attName=="v8x") { v8x = eval.Evaluate(attValue); } else
1566  if (attName=="v8y") { v8y = eval.Evaluate(attValue); }
1567  }
1568 
1569  dz *= lunit;
1570  std::vector<G4TwoVector> vertices;
1571  vertices.push_back(G4TwoVector(v1x*lunit,v1y*lunit));
1572  vertices.push_back(G4TwoVector(v2x*lunit,v2y*lunit));
1573  vertices.push_back(G4TwoVector(v3x*lunit,v3y*lunit));
1574  vertices.push_back(G4TwoVector(v4x*lunit,v4y*lunit));
1575  vertices.push_back(G4TwoVector(v5x*lunit,v5y*lunit));
1576  vertices.push_back(G4TwoVector(v6x*lunit,v6y*lunit));
1577  vertices.push_back(G4TwoVector(v7x*lunit,v7y*lunit));
1578  vertices.push_back(G4TwoVector(v8x*lunit,v8y*lunit));
1579  new G4GenericTrap(name,dz,vertices);
1580 }
1581 
1582 void G4GDMLReadSolids::TrapRead(const xercesc::DOMElement* const trapElement)
1583 {
1584  G4String name;
1585  G4double lunit = 1.0;
1586  G4double aunit = 1.0;
1587  G4double z = 0.0;
1588  G4double theta = 0.0;
1589  G4double phi = 0.0;
1590  G4double y1 = 0.0;
1591  G4double x1 = 0.0;
1592  G4double x2 = 0.0;
1593  G4double alpha1 = 0.0;
1594  G4double y2 = 0.0;
1595  G4double x3 = 0.0;
1596  G4double x4 = 0.0;
1597  G4double alpha2 = 0.0;
1598 
1599  const xercesc::DOMNamedNodeMap* const attributes
1600  = trapElement->getAttributes();
1601  XMLSize_t attributeCount = attributes->getLength();
1602 
1603  for (XMLSize_t attribute_index=0;
1604  attribute_index<attributeCount; attribute_index++)
1605  {
1606  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1607 
1608  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1609  { continue; }
1610 
1611  const xercesc::DOMAttr* const attribute
1612  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1613  if (!attribute)
1614  {
1615  G4Exception("G4GDMLReadSolids::TrapRead()",
1616  "InvalidRead", FatalException, "No attribute found!");
1617  return;
1618  }
1619  const G4String attName = Transcode(attribute->getName());
1620  const G4String attValue = Transcode(attribute->getValue());
1621 
1622  if (attName=="name") { name = GenerateName(attValue); } else
1623  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1624  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1625  if (attName=="z") { z = eval.Evaluate(attValue); } else
1626  if (attName=="theta") { theta = eval.Evaluate(attValue); } else
1627  if (attName=="phi") { phi = eval.Evaluate(attValue); } else
1628  if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
1629  if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
1630  if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
1631  if (attName=="alpha1") { alpha1 = eval.Evaluate(attValue); } else
1632  if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
1633  if (attName=="x3") { x3 = eval.Evaluate(attValue); } else
1634  if (attName=="x4") { x4 = eval.Evaluate(attValue); } else
1635  if (attName=="alpha2") { alpha2 = eval.Evaluate(attValue); }
1636  }
1637 
1638  z *= 0.5*lunit;
1639  theta *= aunit;
1640  phi *= aunit;
1641  y1 *= 0.5*lunit;
1642  x1 *= 0.5*lunit;
1643  x2 *= 0.5*lunit;
1644  alpha1 *= aunit;
1645  y2 *= 0.5*lunit;
1646  x3 *= 0.5*lunit;
1647  x4 *= 0.5*lunit;
1648  alpha2 *= aunit;
1649 
1650  new G4Trap(name,z,theta,phi,y1,x1,x2,alpha1,y2,x3,x4,alpha2);
1651 }
1652 
1653 void G4GDMLReadSolids::TrdRead(const xercesc::DOMElement* const trdElement)
1654 {
1655  G4String name;
1656  G4double lunit = 1.0;
1657  G4double x1 = 0.0;
1658  G4double x2 = 0.0;
1659  G4double y1 = 0.0;
1660  G4double y2 = 0.0;
1661  G4double z = 0.0;
1662 
1663  const xercesc::DOMNamedNodeMap* const attributes = trdElement->getAttributes();
1664  XMLSize_t attributeCount = attributes->getLength();
1665 
1666  for (XMLSize_t attribute_index=0;
1667  attribute_index<attributeCount; attribute_index++)
1668  {
1669  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1670 
1671  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1672  { continue; }
1673 
1674  const xercesc::DOMAttr* const attribute
1675  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1676  if (!attribute)
1677  {
1678  G4Exception("G4GDMLReadSolids::TrdRead()",
1679  "InvalidRead", FatalException, "No attribute found!");
1680  return;
1681  }
1682  const G4String attName = Transcode(attribute->getName());
1683  const G4String attValue = Transcode(attribute->getValue());
1684 
1685  if (attName=="name") { name = GenerateName(attValue); } else
1686  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1687  if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
1688  if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
1689  if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
1690  if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
1691  if (attName=="z") { z = eval.Evaluate(attValue); }
1692  }
1693 
1694  x1 *= 0.5*lunit;
1695  x2 *= 0.5*lunit;
1696  y1 *= 0.5*lunit;
1697  y2 *= 0.5*lunit;
1698  z *= 0.5*lunit;
1699 
1700  new G4Trd(name,x1,x2,y1,y2,z);
1701 }
1702 
1704 TriangularRead(const xercesc::DOMElement* const triangularElement)
1705 {
1706  G4ThreeVector vertex1;
1707  G4ThreeVector vertex2;
1708  G4ThreeVector vertex3;
1709  G4FacetVertexType type = ABSOLUTE;
1710  G4double lunit = 1.0;
1711 
1712  const xercesc::DOMNamedNodeMap* const attributes
1713  = triangularElement->getAttributes();
1714  XMLSize_t attributeCount = attributes->getLength();
1715 
1716  for (XMLSize_t attribute_index=0;
1717  attribute_index<attributeCount; attribute_index++)
1718  {
1719  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1720 
1721  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1722  { continue; }
1723 
1724  const xercesc::DOMAttr* const attribute
1725  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1726  if (!attribute)
1727  {
1728  G4Exception("G4GDMLReadSolids::TriangularRead()",
1729  "InvalidRead", FatalException, "No attribute found!");
1730  return 0;
1731  }
1732  const G4String attName = Transcode(attribute->getName());
1733  const G4String attValue = Transcode(attribute->getValue());
1734 
1735  if (attName=="vertex1")
1736  { vertex1 = GetPosition(GenerateName(attValue)); } else
1737  if (attName=="vertex2")
1738  { vertex2 = GetPosition(GenerateName(attValue)); } else
1739  if (attName=="vertex3")
1740  { vertex3 = GetPosition(GenerateName(attValue)); } else
1741  if (attName=="lunit")
1742  { lunit = eval.Evaluate(attValue); } else
1743  if (attName=="type")
1744  { if (attValue=="RELATIVE") { type = RELATIVE; } }
1745  }
1746 
1747  return new G4TriangularFacet(vertex1*lunit,vertex2*lunit,vertex3*lunit,type);
1748 }
1749 
1750 void G4GDMLReadSolids::TubeRead(const xercesc::DOMElement* const tubeElement)
1751 {
1752  G4String name;
1753  G4double lunit = 1.0;
1754  G4double aunit = 1.0;
1755  G4double rmin = 0.0;
1756  G4double rmax = 0.0;
1757  G4double z = 0.0;
1758  G4double startphi = 0.0;
1759  G4double deltaphi = 0.0;
1760 
1761  const xercesc::DOMNamedNodeMap* const attributes
1762  = tubeElement->getAttributes();
1763  XMLSize_t attributeCount = attributes->getLength();
1764 
1765  for (XMLSize_t attribute_index=0;
1766  attribute_index<attributeCount; attribute_index++)
1767  {
1768  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1769 
1770  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1771  { continue; }
1772 
1773  const xercesc::DOMAttr* const attribute
1774  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1775  if (!attribute)
1776  {
1777  G4Exception("G4GDMLReadSolids::TubeRead()",
1778  "InvalidRead", FatalException, "No attribute found!");
1779  return;
1780  }
1781  const G4String attName = Transcode(attribute->getName());
1782  const G4String attValue = Transcode(attribute->getValue());
1783 
1784  if (attName=="name") { name = GenerateName(attValue); } else
1785  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1786  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1787  if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
1788  if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
1789  if (attName=="z") { z = eval.Evaluate(attValue); } else
1790  if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
1791  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); }
1792  }
1793 
1794  rmin *= lunit;
1795  rmax *= lunit;
1796  z *= 0.5*lunit;
1797  startphi *= aunit;
1798  deltaphi *= aunit;
1799 
1800  new G4Tubs(name,rmin,rmax,z,startphi,deltaphi);
1801 }
1802 
1803 void G4GDMLReadSolids::CutTubeRead(const xercesc::DOMElement* const cuttubeElement)
1804 {
1805  G4String name;
1806  G4double lunit = 1.0;
1807  G4double aunit = 1.0;
1808  G4double rmin = 0.0;
1809  G4double rmax = 0.0;
1810  G4double z = 0.0;
1811  G4double startphi = 0.0;
1812  G4double deltaphi = 0.0;
1813  G4ThreeVector lowNorm(0);
1814  G4ThreeVector highNorm(0);
1815 
1816  const xercesc::DOMNamedNodeMap* const attributes
1817  = cuttubeElement->getAttributes();
1818  XMLSize_t attributeCount = attributes->getLength();
1819 
1820  for (XMLSize_t attribute_index=0;
1821  attribute_index<attributeCount; attribute_index++)
1822  {
1823  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1824 
1825  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1826  { continue; }
1827 
1828  const xercesc::DOMAttr* const attribute
1829  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1830  if (!attribute)
1831  {
1832  G4Exception("G4GDMLReadSolids::CutTubeRead()",
1833  "InvalidRead", FatalException, "No attribute found!");
1834  return;
1835  }
1836  const G4String attName = Transcode(attribute->getName());
1837  const G4String attValue = Transcode(attribute->getValue());
1838 
1839  if (attName=="name") { name = GenerateName(attValue); } else
1840  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1841  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1842  if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else
1843  if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else
1844  if (attName=="z") { z = eval.Evaluate(attValue); } else
1845  if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else
1846  if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else
1847  if (attName=="lowX") { lowNorm.setX (eval.Evaluate(attValue)); } else
1848  if (attName=="lowY") { lowNorm.setY (eval.Evaluate(attValue)); } else
1849  if (attName=="lowZ") { lowNorm.setZ (eval.Evaluate(attValue)); } else
1850  if (attName=="highX") { highNorm.setX (eval.Evaluate(attValue)); } else
1851  if (attName=="highY") { highNorm.setY (eval.Evaluate(attValue)); } else
1852  if (attName=="highZ") { highNorm.setZ (eval.Evaluate(attValue)); }
1853 
1854  }
1855 
1856  rmin *= lunit;
1857  rmax *= lunit;
1858  z *= 0.5*lunit;
1859  startphi *= aunit;
1860  deltaphi *= aunit;
1861 
1862  new G4CutTubs(name,rmin,rmax,z,startphi,deltaphi,lowNorm,highNorm);
1863 }
1864 
1865 void G4GDMLReadSolids::
1866 TwistedboxRead(const xercesc::DOMElement* const twistedboxElement)
1867 {
1868  G4String name;
1869  G4double lunit = 1.0;
1870  G4double aunit = 1.0;
1871  G4double PhiTwist = 0.0;
1872  G4double x = 0.0;
1873  G4double y = 0.0;
1874  G4double z = 0.0;
1875 
1876  const xercesc::DOMNamedNodeMap* const attributes
1877  = twistedboxElement->getAttributes();
1878  XMLSize_t attributeCount = attributes->getLength();
1879 
1880  for (XMLSize_t attribute_index=0;
1881  attribute_index<attributeCount; attribute_index++)
1882  {
1883  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1884 
1885  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1886  { continue; }
1887 
1888  const xercesc::DOMAttr* const attribute
1889  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1890  if (!attribute)
1891  {
1892  G4Exception("G4GDMLReadSolids::TwistedboxRead()",
1893  "InvalidRead", FatalException, "No attribute found!");
1894  return;
1895  }
1896  const G4String attName = Transcode(attribute->getName());
1897  const G4String attValue = Transcode(attribute->getValue());
1898 
1899  if (attName=="name") { name = GenerateName(attValue); } else
1900  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1901  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1902  if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else
1903  if (attName=="x") { x = eval.Evaluate(attValue); } else
1904  if (attName=="y") { y = eval.Evaluate(attValue); } else
1905  if (attName=="z") { z = eval.Evaluate(attValue); }
1906  }
1907 
1908  PhiTwist *= aunit;
1909  x *= 0.5*lunit;
1910  y *= 0.5*lunit;
1911  z *= 0.5*lunit;
1912 
1913  new G4TwistedBox(name,PhiTwist,x,y,z);
1914 }
1915 
1916 void G4GDMLReadSolids::
1917 TwistedtrapRead(const xercesc::DOMElement* const twistedtrapElement)
1918 {
1919  G4String name;
1920  G4double lunit = 1.0;
1921  G4double aunit = 1.0;
1922  G4double PhiTwist = 0.0;
1923  G4double z = 0.0;
1924  G4double Theta = 0.0;
1925  G4double Phi = 0.0;
1926  G4double y1 = 0.0;
1927  G4double x1 = 0.0;
1928  G4double x2 = 0.0;
1929  G4double y2 = 0.0;
1930  G4double x3 = 0.0;
1931  G4double x4 = 0.0;
1932  G4double Alph = 0.0;
1933 
1934  const xercesc::DOMNamedNodeMap* const attributes
1935  = twistedtrapElement->getAttributes();
1936  XMLSize_t attributeCount = attributes->getLength();
1937 
1938  for (XMLSize_t attribute_index=0;
1939  attribute_index<attributeCount; attribute_index++)
1940  {
1941  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
1942 
1943  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
1944  { continue; }
1945 
1946  const xercesc::DOMAttr* const attribute
1947  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
1948  if (!attribute)
1949  {
1950  G4Exception("G4GDMLReadSolids::TwistedtrapRead()",
1951  "InvalidRead", FatalException, "No attribute found!");
1952  return;
1953  }
1954  const G4String attName = Transcode(attribute->getName());
1955  const G4String attValue = Transcode(attribute->getValue());
1956 
1957  if (attName=="name") { name = GenerateName(attValue); } else
1958  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
1959  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
1960  if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else
1961  if (attName=="z") { z = eval.Evaluate(attValue); } else
1962  if (attName=="Theta") { Theta = eval.Evaluate(attValue); } else
1963  if (attName=="Phi") { Phi = eval.Evaluate(attValue); } else
1964  if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
1965  if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
1966  if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
1967  if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
1968  if (attName=="x3") { x3 = eval.Evaluate(attValue); } else
1969  if (attName=="x4") { x4 = eval.Evaluate(attValue); } else
1970  if (attName=="Alph") { Alph = eval.Evaluate(attValue); }
1971  }
1972 
1973 
1974  PhiTwist *= aunit;
1975  z *= 0.5*lunit;
1976  Theta *= aunit;
1977  Phi *= aunit;
1978  Alph *= aunit;
1979  y1 *= 0.5*lunit;
1980  x1 *= 0.5*lunit;
1981  x2 *= 0.5*lunit;
1982  y2 *= 0.5*lunit;
1983  x3 *= 0.5*lunit;
1984  x4 *= 0.5*lunit;
1985 
1986  new G4TwistedTrap(name,PhiTwist,z,Theta,Phi,y1,x1,x2,y2,x3,x4,Alph);
1987 }
1988 
1989 void G4GDMLReadSolids::
1990 TwistedtrdRead(const xercesc::DOMElement* const twistedtrdElement)
1991 {
1992  G4String name;
1993  G4double lunit = 1.0;
1994  G4double aunit = 1.0;
1995  G4double x1 = 0.0;
1996  G4double x2 = 0.0;
1997  G4double y1 = 0.0;
1998  G4double y2 = 0.0;
1999  G4double z = 0.0;
2000  G4double PhiTwist = 0.0;
2001 
2002  const xercesc::DOMNamedNodeMap* const attributes
2003  = twistedtrdElement->getAttributes();
2004  XMLSize_t attributeCount = attributes->getLength();
2005 
2006  for (XMLSize_t attribute_index=0;
2007  attribute_index<attributeCount; attribute_index++)
2008  {
2009  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2010 
2011  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2012  { continue; }
2013 
2014  const xercesc::DOMAttr* const attribute
2015  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
2016  if (!attribute)
2017  {
2018  G4Exception("G4GDMLReadSolids::TwistedtrdRead()",
2019  "InvalidRead", FatalException, "No attribute found!");
2020  return;
2021  }
2022  const G4String attName = Transcode(attribute->getName());
2023  const G4String attValue = Transcode(attribute->getValue());
2024 
2025  if (attName=="name") { name = GenerateName(attValue); } else
2026  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2027  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2028  if (attName=="x1") { x1 = eval.Evaluate(attValue); } else
2029  if (attName=="x2") { x2 = eval.Evaluate(attValue); } else
2030  if (attName=="y1") { y1 = eval.Evaluate(attValue); } else
2031  if (attName=="y2") { y2 = eval.Evaluate(attValue); } else
2032  if (attName=="z") { z = eval.Evaluate(attValue); } else
2033  if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); }
2034  }
2035 
2036  x1 *= 0.5*lunit;
2037  x2 *= 0.5*lunit;
2038  y1 *= 0.5*lunit;
2039  y2 *= 0.5*lunit;
2040  z *= 0.5*lunit;
2041  PhiTwist *= aunit;
2042 
2043  new G4TwistedTrd(name,x1,x2,y1,y2,z,PhiTwist);
2044 }
2045 
2046 void G4GDMLReadSolids::
2047 TwistedtubsRead(const xercesc::DOMElement* const twistedtubsElement)
2048 {
2049  G4String name;
2050  G4double lunit = 1.0;
2051  G4double aunit = 1.0;
2052  G4double twistedangle = 0.0;
2053  G4double endinnerrad = 0.0;
2054  G4double endouterrad = 0.0;
2055  G4double zlen = 0.0;
2056  G4double phi = 0.0;
2057 
2058  const xercesc::DOMNamedNodeMap* const attributes
2059  = twistedtubsElement->getAttributes();
2060  XMLSize_t attributeCount = attributes->getLength();
2061 
2062  for (XMLSize_t attribute_index=0;
2063  attribute_index<attributeCount; attribute_index++)
2064  {
2065  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2066 
2067  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2068  { continue; }
2069 
2070  const xercesc::DOMAttr* const attribute
2071  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
2072  if (!attribute)
2073  {
2074  G4Exception("G4GDMLReadSolids::TwistedtubsRead()",
2075  "InvalidRead", FatalException, "No attribute found!");
2076  return;
2077  }
2078  const G4String attName = Transcode(attribute->getName());
2079  const G4String attValue = Transcode(attribute->getValue());
2080 
2081  if (attName=="name") { name = GenerateName(attValue); } else
2082  if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else
2083  if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else
2084  if (attName=="twistedangle") { twistedangle=eval.Evaluate(attValue); } else
2085  if (attName=="endinnerrad") { endinnerrad=eval.Evaluate(attValue); } else
2086  if (attName=="endouterrad") { endouterrad=eval.Evaluate(attValue); } else
2087  if (attName=="zlen") { zlen = eval.Evaluate(attValue); } else
2088  if (attName=="phi") { phi = eval.Evaluate(attValue); }
2089  }
2090 
2091  twistedangle *= aunit;
2092  endinnerrad *= lunit;
2093  endouterrad *= lunit;
2094  zlen *= 0.5*lunit;
2095  phi *= aunit;
2096 
2097  new G4TwistedTubs(name,twistedangle,endinnerrad,endouterrad,zlen,phi);
2098 }
2099 
2101 TwoDimVertexRead(const xercesc::DOMElement* const element, G4double lunit)
2102 {
2103  G4TwoVector vec;
2104 
2105  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
2106  XMLSize_t attributeCount = attributes->getLength();
2107 
2108  for (XMLSize_t attribute_index=0;
2109  attribute_index<attributeCount; attribute_index++)
2110  {
2111  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2112 
2113  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2114  { continue; }
2115 
2116  const xercesc::DOMAttr* const attribute
2117  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
2118  if (!attribute)
2119  {
2120  G4Exception("G4GDMLReadSolids::TwoDimVertexRead()",
2121  "InvalidRead", FatalException, "No attribute found!");
2122  return vec;
2123  }
2124  const G4String attName = Transcode(attribute->getName());
2125  const G4String attValue = Transcode(attribute->getValue());
2126 
2127  if (attName=="x") { vec.setX(eval.Evaluate(attValue)*lunit); } else
2128  if (attName=="y") { vec.setY(eval.Evaluate(attValue)*lunit); }
2129  }
2130 
2131  return vec;
2132 }
2133 
2135 ZplaneRead(const xercesc::DOMElement* const zplaneElement)
2136 {
2137  zplaneType zplane = {0.,0.,0.};
2138 
2139  const xercesc::DOMNamedNodeMap* const attributes
2140  = zplaneElement->getAttributes();
2141  XMLSize_t attributeCount = attributes->getLength();
2142 
2143  for (XMLSize_t attribute_index=0;
2144  attribute_index<attributeCount; attribute_index++)
2145  {
2146  xercesc::DOMNode* node = attributes->item(attribute_index);
2147 
2148  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
2149 
2150  const xercesc::DOMAttr* const attribute
2151  = dynamic_cast<xercesc::DOMAttr*>(node);
2152  if (!attribute)
2153  {
2154  G4Exception("G4GDMLReadSolids::ZplaneRead()",
2155  "InvalidRead", FatalException, "No attribute found!");
2156  return zplane;
2157  }
2158  const G4String attName = Transcode(attribute->getName());
2159  const G4String attValue = Transcode(attribute->getValue());
2160 
2161  if (attName=="rmin") { zplane.rmin = eval.Evaluate(attValue); } else
2162  if (attName=="rmax") { zplane.rmax = eval.Evaluate(attValue); } else
2163  if (attName=="z") { zplane.z = eval.Evaluate(attValue); }
2164  }
2165 
2166  return zplane;
2167 }
2169 RZPointRead(const xercesc::DOMElement* const zplaneElement)
2170 {
2171  rzPointType rzpoint = {0.,0.};
2172 
2173  const xercesc::DOMNamedNodeMap* const attributes
2174  = zplaneElement->getAttributes();
2175  XMLSize_t attributeCount = attributes->getLength();
2176 
2177  for (XMLSize_t attribute_index=0;
2178  attribute_index<attributeCount; attribute_index++)
2179  {
2180  xercesc::DOMNode* node = attributes->item(attribute_index);
2181 
2182  if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; }
2183 
2184  const xercesc::DOMAttr* const attribute
2185  = dynamic_cast<xercesc::DOMAttr*>(node);
2186  if (!attribute)
2187  {
2188  G4Exception("G4GDMLReadSolids::RZPointRead()",
2189  "InvalidRead", FatalException, "No attribute found!");
2190  return rzpoint;
2191  }
2192  const G4String attName = Transcode(attribute->getName());
2193  const G4String attValue = Transcode(attribute->getValue());
2194 
2195  if (attName=="r") { rzpoint.r = eval.Evaluate(attValue); } else
2196  if (attName=="z") { rzpoint.z = eval.Evaluate(attValue); }
2197  }
2198 
2199  return rzpoint;
2200 
2201 }
2202 
2203 void G4GDMLReadSolids::
2204 OpticalSurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement)
2205 {
2206  G4String name;
2207  G4String smodel;
2208  G4String sfinish;
2209  G4String stype;
2210  G4double value = 0.0;
2211 
2212  const xercesc::DOMNamedNodeMap* const attributes
2213  = opticalsurfaceElement->getAttributes();
2214  XMLSize_t attributeCount = attributes->getLength();
2215 
2216  for (XMLSize_t attribute_index=0;
2217  attribute_index<attributeCount; attribute_index++)
2218  {
2219  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
2220 
2221  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
2222  { continue; }
2223 
2224  const xercesc::DOMAttr* const attribute
2225  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
2226  if (!attribute)
2227  {
2228  G4Exception("G4GDMLReadSolids::OpticalSurfaceRead()",
2229  "InvalidRead", FatalException, "No attribute found!");
2230  return;
2231  }
2232  const G4String attName = Transcode(attribute->getName());
2233  const G4String attValue = Transcode(attribute->getValue());
2234 
2235  if (attName=="name") { name = GenerateName(attValue); } else
2236  if (attName=="model") { smodel = attValue; } else
2237  if (attName=="finish") { sfinish = attValue; } else
2238  if (attName=="type") { stype = attValue; } else
2239  if (attName=="value") { value = eval.Evaluate(attValue); }
2240  }
2241 
2242  G4OpticalSurfaceModel model;
2243  G4OpticalSurfaceFinish finish;
2244  G4SurfaceType type;
2245 
2246  if ((smodel=="glisur") || (smodel=="0")) { model = glisur; } else
2247  if ((smodel=="unified") || (smodel=="1")) { model = unified; }
2248  else { model = LUT; }
2249 
2250  if ((sfinish=="polished") || (sfinish=="0"))
2251  { finish = polished; } else
2252  if ((sfinish=="polishedfrontpainted") || (sfinish=="1"))
2253  { finish = polishedfrontpainted; } else
2254  if ((sfinish=="polishedbackpainted") || (sfinish=="2"))
2255  { finish = polishedbackpainted; } else
2256  if ((sfinish=="ground") || (sfinish=="3"))
2257  { finish = ground; } else
2258  if ((sfinish=="groundfrontpainted") || (sfinish=="4"))
2259  { finish = groundfrontpainted; } else
2260  if ((sfinish=="groundbackpainted") || (sfinish=="5"))
2261  { finish = groundbackpainted; } else
2262  if ((sfinish=="polishedlumirrorair") || (sfinish=="6"))
2263  { finish = polishedlumirrorair; } else
2264  if ((sfinish=="polishedlumirrorglue") || (sfinish=="7"))
2265  { finish = polishedlumirrorglue; } else
2266  if ((sfinish=="polishedair") || (sfinish=="8"))
2267  { finish = polishedair; } else
2268  if ((sfinish=="polishedteflonair") || (sfinish=="9"))
2269  { finish = polishedteflonair; } else
2270  if ((sfinish=="polishedtioair") || (sfinish=="10"))
2271  { finish = polishedtioair; } else
2272  if ((sfinish=="polishedtyvekair") || (sfinish=="11"))
2273  { finish = polishedtyvekair; } else
2274  if ((sfinish=="polishedvm2000air") || (sfinish=="12"))
2275  { finish = polishedvm2000air; } else
2276  if ((sfinish=="polishedvm2000glue") || (sfinish=="13"))
2277  { finish = polishedvm2000glue; } else
2278  if ((sfinish=="etchedlumirrorair") || (sfinish=="14"))
2279  { finish = etchedlumirrorair; } else
2280  if ((sfinish=="etchedlumirrorglue") || (sfinish=="15"))
2281  { finish = etchedlumirrorglue; } else
2282  if ((sfinish=="etchedair") || (sfinish=="16"))
2283  { finish = etchedair; } else
2284  if ((sfinish=="etchedteflonair") || (sfinish=="17"))
2285  { finish = etchedteflonair; } else
2286  if ((sfinish=="etchedtioair") || (sfinish=="18"))
2287  { finish = etchedtioair; } else
2288  if ((sfinish=="etchedtyvekair") || (sfinish=="19"))
2289  { finish = etchedtyvekair; } else
2290  if ((sfinish=="etchedvm2000air") || (sfinish=="20"))
2291  { finish = etchedvm2000air; } else
2292  if ((sfinish=="etchedvm2000glue") || (sfinish=="21"))
2293  { finish = etchedvm2000glue; } else
2294  if ((sfinish=="groundlumirrorair") || (sfinish=="22"))
2295  { finish = groundlumirrorair; } else
2296  if ((sfinish=="groundlumirrorglue") || (sfinish=="23"))
2297  { finish = groundlumirrorglue; } else
2298  if ((sfinish=="groundair") || (sfinish=="24"))
2299  { finish = groundair; } else
2300  if ((sfinish=="groundteflonair") || (sfinish=="25"))
2301  { finish = groundteflonair; } else
2302  if ((sfinish=="groundtioair") || (sfinish=="26"))
2303  { finish = groundtioair; } else
2304  if ((sfinish=="groundtyvekair") || (sfinish=="27"))
2305  { finish = groundtyvekair; } else
2306  if ((sfinish=="groundvm2000air") || (sfinish=="28"))
2307  { finish = groundvm2000air; }
2308  else { finish = groundvm2000glue; }
2309 
2310  if ((stype=="dielectric_metal") || (stype=="0"))
2311  { type = dielectric_metal; } else
2312  if ((stype=="dielectric_dielectric") || (stype=="1"))
2313  { type = dielectric_dielectric; } else
2314  if ((stype=="dielectric_LUT") || (stype=="2"))
2315  { type = dielectric_LUT; } else
2316  if ((stype=="firsov") || (stype=="3"))
2317  { type = firsov; }
2318  else { type = x_ray; }
2319 
2320  new G4OpticalSurface(name,model,finish,type,value);
2321 }
2322 
2323 void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement)
2324 {
2325  G4cout << "G4GDML: Reading solids..." << G4endl;
2326 
2327  for (xercesc::DOMNode* iter = solidsElement->getFirstChild();
2328  iter != 0; iter = iter->getNextSibling())
2329  {
2330  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
2331 
2332  const xercesc::DOMElement* const child
2333  = dynamic_cast<xercesc::DOMElement*>(iter);
2334  if (!child)
2335  {
2336  G4Exception("G4GDMLReadSolids::SolidsRead()",
2337  "InvalidRead", FatalException, "No child found!");
2338  return;
2339  }
2340  const G4String tag = Transcode(child->getTagName());
2341  if (tag=="define") { DefineRead(child); } else
2342  if (tag=="box") { BoxRead(child); } else
2343  if (tag=="cone") { ConeRead(child); } else
2344  if (tag=="elcone") { ElconeRead(child); } else
2345  if (tag=="ellipsoid") { EllipsoidRead(child); }else
2346  if (tag=="eltube") { EltubeRead(child); } else
2347  if (tag=="xtru") { XtruRead(child); } else
2348  if (tag=="hype") { HypeRead(child); } else
2349  if (tag=="intersection") { BooleanRead(child,INTERSECTION); } else
2350  if (tag=="multiUnion") { MultiUnionRead(child); } else
2351  if (tag=="orb") { OrbRead(child); } else
2352  if (tag=="para") { ParaRead(child); } else
2353  if (tag=="paraboloid") { ParaboloidRead(child); } else
2354  if (tag=="polycone") { PolyconeRead(child); } else
2355  if (tag=="genericPolycone") { GenericPolyconeRead(child); } else
2356  if (tag=="polyhedra") { PolyhedraRead(child); } else
2357  if (tag=="genericPolyhedra") { GenericPolyhedraRead(child); } else
2358  if (tag=="reflectedSolid") { ReflectedSolidRead(child); } else
2359  if (tag=="sphere") { SphereRead(child); } else
2360  if (tag=="subtraction") { BooleanRead(child,SUBTRACTION); } else
2361  if (tag=="tessellated") { TessellatedRead(child); } else
2362  if (tag=="tet") { TetRead(child); } else
2363  if (tag=="torus") { TorusRead(child); } else
2364  if (tag=="arb8") { GenTrapRead(child); } else
2365  if (tag=="trap") { TrapRead(child); } else
2366  if (tag=="trd") { TrdRead(child); } else
2367  if (tag=="tube") { TubeRead(child); } else
2368  if (tag=="cutTube") { CutTubeRead(child); } else
2369  if (tag=="twistedbox") { TwistedboxRead(child); } else
2370  if (tag=="twistedtrap") { TwistedtrapRead(child); } else
2371  if (tag=="twistedtrd") { TwistedtrdRead(child); } else
2372  if (tag=="twistedtubs") { TwistedtubsRead(child); } else
2373  if (tag=="union") { BooleanRead(child,UNION); } else
2374  if (tag=="opticalsurface") { OpticalSurfaceRead(child); } else
2375  if (tag=="loop") { LoopRead(child,&G4GDMLRead::SolidsRead); }
2376  else
2377  {
2378  G4String error_msg = "Unknown tag in solids: " + tag;
2379  G4Exception("G4GDMLReadSolids::SolidsRead()", "ReadError",
2380  FatalException, error_msg);
2381  }
2382  }
2383 }
2384 
2386 {
2387  G4VSolid* solidPtr = G4SolidStore::GetInstance()->GetSolid(ref,false);
2388 
2389  if (!solidPtr)
2390  {
2391  G4String error_msg = "Referenced solid '" + ref + "' was not found!";
2392  G4Exception("G4GDMLReadSolids::GetSolid()", "ReadError",
2393  FatalException, error_msg);
2394  }
2395 
2396  return solidPtr;
2397 }
2398 
2400 GetSurfaceProperty(const G4String& ref) const
2401 {
2402  const G4SurfacePropertyTable* surfaceList
2404  const size_t surfaceCount = surfaceList->size();
2405 
2406  for (size_t i=0; i<surfaceCount; i++)
2407  {
2408  if ((*surfaceList)[i]->GetName() == ref) { return (*surfaceList)[i]; }
2409  }
2410 
2411  G4String error_msg = "Referenced optical surface '" + ref + "' was not found!";
2412  G4Exception("G4GDMLReadSolids::GetSurfaceProperty()", "ReadError",
2413  FatalException, error_msg);
2414 
2415  return 0;
2416 }
zplaneType ZplaneRead(const xercesc::DOMElement *const)
void TubeRead(const xercesc::DOMElement *const)
void TwistedtrapRead(const xercesc::DOMElement *const)
G4int EvaluateInteger(const G4String &)
Definition: G4Para.hh:77
void SetSolidClosed(const G4bool t)
void BoxRead(const xercesc::DOMElement *const)
G4VSolid * GetSolid(const G4String &name, G4bool verbose=true) const
G4GDMLEvaluator eval
Definition: G4GDMLRead.hh:144
void OpticalSurfaceRead(const xercesc::DOMElement *const)
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
virtual void DefineRead(const xercesc::DOMElement *const)
Definition: G4Box.hh:64
void TwistedboxRead(const xercesc::DOMElement *const)
G4String name
Definition: TRTMaterials.hh:40
G4UMultiUnion G4MultiUnion
Definition: G4MultiUnion.hh:47
Definition: G4Tubs.hh:85
Definition: xmlparse.cc:179
void MultiUnionRead(const xercesc::DOMElement *const)
void TorusRead(const xercesc::DOMElement *const)
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
void TetRead(const xercesc::DOMElement *const)
G4TwoVector TwoDimVertexRead(const xercesc::DOMElement *const, G4double)
G4SurfaceProperty * GetSurfaceProperty(const G4String &) const
void GenericPolyhedraRead(const xercesc::DOMElement *const)
Definition: G4Trd.hh:72
G4SurfaceType
G4TriangularFacet * TriangularRead(const xercesc::DOMElement *const)
int G4int
Definition: G4Types.hh:78
G4VSolid * GetSolid(const G4String &) const
void TwistedtubsRead(const xercesc::DOMElement *const)
void TrapRead(const xercesc::DOMElement *const)
void ConeRead(const xercesc::DOMElement *const)
G4String RefRead(const xercesc::DOMElement *const)
void LoopRead(const xercesc::DOMElement *const, void(G4GDMLRead::*)(const xercesc::DOMElement *const))
Definition: G4GDMLRead.cc:179
void SphereRead(const xercesc::DOMElement *const)
void OrbRead(const xercesc::DOMElement *const)
#define position
Definition: xmlparse.cc:605
G4ExtrudedSolid::ZSection SectionRead(const xercesc::DOMElement *const, G4double)
G4GLOB_DLL std::ostream G4cout
void BooleanRead(const xercesc::DOMElement *const, const BooleanOp)
G4FacetVertexType
Definition: G4VFacet.hh:56
Definition: G4Tet.hh:65
Definition: G4Hype.hh:67
void ReflectedSolidRead(const xercesc::DOMElement *const)
void EllipsoidRead(const xercesc::DOMElement *const)
Definition: G4Cons.hh:83
G4bool AddFacet(G4VFacet *aFacet)
void GenTrapRead(const xercesc::DOMElement *const)
static G4SolidStore * GetInstance()
void TrdRead(const xercesc::DOMElement *const)
virtual ~G4GDMLReadSolids()
HepGeom::Transform3D G4Transform3D
HepGeom::Scale3D G4Scale3D
Definition: G4Orb.hh:61
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual void SolidsRead(const xercesc::DOMElement *const)
void EltubeRead(const xercesc::DOMElement *const)
rzPointType RZPointRead(const xercesc::DOMElement *const)
std::vector< G4SurfaceProperty * > G4SurfacePropertyTable
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:68
void TessellatedRead(const xercesc::DOMElement *const)
void PolyhedraRead(const xercesc::DOMElement *const)
void XtruRead(const xercesc::DOMElement *const)
void CutTubeRead(const xercesc::DOMElement *const)
G4OpticalSurfaceFinish
void VectorRead(const xercesc::DOMElement *const, G4ThreeVector &)
void ParaboloidRead(const xercesc::DOMElement *const)
CLHEP::Hep2Vector G4TwoVector
Definition: G4TwoVector.hh:42
void GenericPolyconeRead(const xercesc::DOMElement *const)
G4OpticalSurfaceModel
void ElconeRead(const xercesc::DOMElement *const)
#define G4endl
Definition: G4ios.hh:61
G4ThreeVector GetRotation(const G4String &)
G4RotationMatrix GetRotationMatrix(const G4ThreeVector &)
void ParaRead(const xercesc::DOMElement *const)
double G4double
Definition: G4Types.hh:76
void HypeRead(const xercesc::DOMElement *const)
static const G4double alpha
void PolyconeRead(const xercesc::DOMElement *const)
G4QuadrangularFacet * QuadrangularRead(const xercesc::DOMElement *const)
void MultiUnionNodeRead(const xercesc::DOMElement *const, G4MultiUnion *const)
static const G4SurfacePropertyTable * GetSurfacePropertyTable()
void AddNode(G4VSolid &solid, G4Transform3D &trans)
virtual void SolidsRead(const xercesc::DOMElement *const)=0
void TwistedtrdRead(const xercesc::DOMElement *const)
G4double Evaluate(const G4String &)
G4ThreeVector GetPosition(const G4String &)