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