Geant4 Cross Reference

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

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

Diff markup

Differences between /persistency/gdml/src/G4GDMLWriteSolids.cc (Version 11.3.0) and /persistency/gdml/src/G4GDMLWriteSolids.cc (Version 7.0.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // G4GDMLWriteSolids implementation               
 27 //                                                
 28 // Author: Zoltan Torzsok, November 2007          
 29 // -------------------------------------------    
 30                                                   
 31 #include "G4GDMLWriteSolids.hh"                   
 32                                                   
 33 #include "G4SystemOfUnits.hh"                     
 34 #include "G4BooleanSolid.hh"                      
 35 #include "G4ScaledSolid.hh"                       
 36 #include "G4Box.hh"                               
 37 #include "G4Cons.hh"                              
 38 #include "G4Ellipsoid.hh"                         
 39 #include "G4EllipticalCone.hh"                    
 40 #include "G4EllipticalTube.hh"                    
 41 #include "G4ExtrudedSolid.hh"                     
 42 #include "G4Hype.hh"                              
 43 #include "G4Orb.hh"                               
 44 #include "G4Para.hh"                              
 45 #include "G4Paraboloid.hh"                        
 46 #include "G4IntersectionSolid.hh"                 
 47 #include "G4Polycone.hh"                          
 48 #include "G4GenericPolycone.hh"                   
 49 #include "G4Polyhedra.hh"                         
 50 #include "G4ReflectedSolid.hh"                    
 51 #include "G4Sphere.hh"                            
 52 #include "G4SubtractionSolid.hh"                  
 53 #include "G4GenericTrap.hh"                       
 54 #include "G4TessellatedSolid.hh"                  
 55 #include "G4Tet.hh"                               
 56 #include "G4Torus.hh"                             
 57 #include "G4Trap.hh"                              
 58 #include "G4Trd.hh"                               
 59 #include "G4Tubs.hh"                              
 60 #include "G4CutTubs.hh"                           
 61 #include "G4TwistedBox.hh"                        
 62 #include "G4TwistedTrap.hh"                       
 63 #include "G4TwistedTrd.hh"                        
 64 #include "G4TwistedTubs.hh"                       
 65 #include "G4UnionSolid.hh"                        
 66 #include "G4OpticalSurface.hh"                    
 67 #include "G4SurfaceProperty.hh"                   
 68 #include "G4MaterialPropertiesTable.hh"           
 69                                                   
 70 // -------------------------------------------    
 71 G4GDMLWriteSolids::G4GDMLWriteSolids()            
 72   : G4GDMLWriteMaterials()                        
 73 {                                                 
 74 }                                                 
 75                                                   
 76 // -------------------------------------------    
 77 G4GDMLWriteSolids::~G4GDMLWriteSolids()           
 78 {                                                 
 79 }                                                 
 80                                                   
 81 // -------------------------------------------    
 82 void G4GDMLWriteSolids::MultiUnionWrite(xerces    
 83                                         const     
 84 {                                                 
 85   G4int numSolids = munionSolid->GetNumberOfSo    
 86   G4String tag("multiUnion");                     
 87                                                   
 88   G4VSolid* solid;                                
 89   G4Transform3D transform;                        
 90                                                   
 91   const G4String& name = GenerateName(munionSo    
 92   xercesc::DOMElement* multiUnionElement = New    
 93   multiUnionElement->setAttributeNode(NewAttri    
 94                                                   
 95   for(G4int i = 0; i < numSolids; ++i)            
 96   {                                               
 97     solid     = munionSolid->GetSolid(i);         
 98     transform = munionSolid->GetTransformation    
 99                                                   
100     HepGeom::Rotate3D rot3d;                      
101     HepGeom::Translate3D transl;                  
102     HepGeom::Scale3D scale;                       
103     transform.getDecomposition(scale, rot3d, t    
104                                                   
105     G4ThreeVector pos = transl.getTranslation(    
106     G4RotationMatrix rotm(CLHEP::HepRep3x3(rot    
107                                            rot    
108                                            rot    
109     G4ThreeVector rot = GetAngles(rotm);          
110                                                   
111     AddSolid(solid);                              
112     const G4String& solidref = GenerateName(so    
113     std::ostringstream os;                        
114     os << i + 1;                                  
115     const G4String& nodeName          = "Node-    
116     xercesc::DOMElement* solidElement = NewEle    
117     solidElement->setAttributeNode(NewAttribut    
118     xercesc::DOMElement* multiUnionNodeElement    
119     multiUnionNodeElement->setAttributeNode(Ne    
120     multiUnionNodeElement->appendChild(solidEl    
121     if((std::fabs(pos.x()) > kLinearPrecision)    
122        (std::fabs(pos.y()) > kLinearPrecision)    
123        (std::fabs(pos.z()) > kLinearPrecision)    
124     {                                             
125       PositionWrite(multiUnionNodeElement,name    
126     }                                             
127     if((std::fabs(rot.x()) > kAngularPrecision    
128        (std::fabs(rot.y()) > kAngularPrecision    
129        (std::fabs(rot.z()) > kAngularPrecision    
130     {                                             
131       RotationWrite(multiUnionNodeElement,name    
132     }                                             
133     multiUnionElement->appendChild(multiUnionN    
134   }                                               
135                                                   
136   solElement->appendChild(multiUnionElement);     
137   // Add the multiUnion solid AFTER the consti    
138 }                                                 
139                                                   
140 // -------------------------------------------    
141 void G4GDMLWriteSolids::BooleanWrite(xercesc::    
142                                      const G4B    
143 {                                                 
144   G4int displaced = 0;                            
145                                                   
146   G4String tag("undefined");                      
147   if(dynamic_cast<const G4IntersectionSolid*>(    
148   {                                               
149     tag = "intersection";                         
150   }                                               
151   else if(dynamic_cast<const G4SubtractionSoli    
152   {                                               
153     tag = "subtraction";                          
154   }                                               
155   else if(dynamic_cast<const G4UnionSolid*>(bo    
156   {                                               
157     tag = "union";                                
158   }                                               
159                                                   
160   G4VSolid* firstPtr  = const_cast<G4VSolid*>(    
161   G4VSolid* secondPtr = const_cast<G4VSolid*>(    
162                                                   
163   G4ThreeVector firstpos, firstrot, pos, rot;     
164                                                   
165   // Solve possible displacement of referenced    
166   //                                              
167   while(true)                                     
168   {                                               
169     if(displaced > 8)                             
170     {                                             
171       G4String ErrorMessage = "The referenced     
172                               +"in the Boolean    
173                               +"' was displace    
174       G4Exception("G4GDMLWriteSolids::BooleanW    
175                   FatalException, ErrorMessage    
176     }                                             
177                                                   
178     if(G4DisplacedSolid* disp = dynamic_cast<G    
179     {                                             
180       firstpos += disp->GetObjectTranslation()    
181       firstrot += GetAngles(disp->GetObjectRot    
182       firstPtr = disp->GetConstituentMovedSoli    
183       ++displaced;                                
184       continue;                                   
185     }                                             
186     break;                                        
187   }                                               
188   displaced = 0;                                  
189   while(true)                                     
190   {                                               
191     if(displaced > maxTransforms)                 
192     {                                             
193       G4String ErrorMessage = "The referenced     
194                               +"in the Boolean    
195                               +"' was displace    
196       G4Exception("G4GDMLWriteSolids::BooleanW    
197                   FatalException, ErrorMessage    
198     }                                             
199                                                   
200     if(G4DisplacedSolid* disp = dynamic_cast<G    
201     {                                             
202       pos += disp->GetObjectTranslation();        
203       rot += GetAngles(disp->GetObjectRotation    
204       secondPtr = disp->GetConstituentMovedSol    
205       ++displaced;                                
206       continue;                                   
207     }                                             
208     break;                                        
209   }                                               
210                                                   
211   AddSolid(firstPtr);  // At first add the con    
212   AddSolid(secondPtr);                            
213                                                   
214   const G4String& name      = GenerateName(boo    
215   const G4String& firstref  = GenerateName(fir    
216   const G4String& secondref = GenerateName(sec    
217                                                   
218   xercesc::DOMElement* booleanElement = NewEle    
219   booleanElement->setAttributeNode(NewAttribut    
220   xercesc::DOMElement* firstElement = NewEleme    
221   firstElement->setAttributeNode(NewAttribute(    
222   booleanElement->appendChild(firstElement);      
223   xercesc::DOMElement* secondElement = NewElem    
224   secondElement->setAttributeNode(NewAttribute    
225   booleanElement->appendChild(secondElement);     
226   solElement->appendChild(booleanElement);        
227   // Add the boolean solid AFTER the constitue    
228                                                   
229   if((std::fabs(pos.x()) > kLinearPrecision) |    
230      (std::fabs(pos.y()) > kLinearPrecision) |    
231      (std::fabs(pos.z()) > kLinearPrecision))     
232   {                                               
233     PositionWrite(booleanElement, name + "_pos    
234   }                                               
235                                                   
236   if((std::fabs(rot.x()) > kAngularPrecision)     
237      (std::fabs(rot.y()) > kAngularPrecision)     
238      (std::fabs(rot.z()) > kAngularPrecision))    
239   {                                               
240     RotationWrite(booleanElement, name + "_rot    
241   }                                               
242                                                   
243   if((std::fabs(firstpos.x()) > kLinearPrecisi    
244      (std::fabs(firstpos.y()) > kLinearPrecisi    
245      (std::fabs(firstpos.z()) > kLinearPrecisi    
246   {                                               
247     FirstpositionWrite(booleanElement, name +     
248   }                                               
249                                                   
250   if((std::fabs(firstrot.x()) > kAngularPrecis    
251      (std::fabs(firstrot.y()) > kAngularPrecis    
252      (std::fabs(firstrot.z()) > kAngularPrecis    
253   {                                               
254     FirstrotationWrite(booleanElement, name +     
255   }                                               
256 }                                                 
257                                                   
258 // -------------------------------------------    
259 void G4GDMLWriteSolids::ScaledWrite(xercesc::D    
260                                     const G4Sc    
261 {                                                 
262   G4String tag("scaledSolid");                    
263                                                   
264   G4VSolid* solid         = const_cast<G4VSoli    
265   G4Scale3D scale         = scaled->GetScaleTr    
266   G4ThreeVector sclVector = G4ThreeVector(scal    
267                                                   
268   AddSolid(solid);  // Add the constituent sol    
269                                                   
270   const G4String& name     = GenerateName(scal    
271   const G4String& solidref = GenerateName(soli    
272                                                   
273   xercesc::DOMElement* scaledElement = NewElem    
274   scaledElement->setAttributeNode(NewAttribute    
275                                                   
276   xercesc::DOMElement* solidElement = NewEleme    
277   solidElement->setAttributeNode(NewAttribute(    
278   scaledElement->appendChild(solidElement);       
279                                                   
280   if((std::fabs(scale.xx()) > kLinearPrecision    
281      (std::fabs(scale.yy()) > kLinearPrecision    
282      (std::fabs(scale.zz()) > kLinearPrecision    
283   {                                               
284     ScaleWrite(scaledElement, name + "_scl", s    
285   }                                               
286                                                   
287   solElement->appendChild(scaledElement);         
288   // Add the scaled solid AFTER its constituen    
289 }                                                 
290                                                   
291 // -------------------------------------------    
292 void G4GDMLWriteSolids::BoxWrite(xercesc::DOME    
293                                  const G4Box*     
294 {                                                 
295   const G4String& name = GenerateName(box->Get    
296                                                   
297   xercesc::DOMElement* boxElement = NewElement    
298   boxElement->setAttributeNode(NewAttribute("n    
299   boxElement->setAttributeNode(                   
300     NewAttribute("x", 2.0 * box->GetXHalfLengt    
301   boxElement->setAttributeNode(                   
302     NewAttribute("y", 2.0 * box->GetYHalfLengt    
303   boxElement->setAttributeNode(                   
304     NewAttribute("z", 2.0 * box->GetZHalfLengt    
305   boxElement->setAttributeNode(NewAttribute("l    
306   solElement->appendChild(boxElement);            
307 }                                                 
308                                                   
309 // -------------------------------------------    
310 void G4GDMLWriteSolids::ConeWrite(xercesc::DOM    
311                                   const G4Cons    
312 {                                                 
313   const G4String& name = GenerateName(cone->Ge    
314                                                   
315   xercesc::DOMElement* coneElement = NewElemen    
316   coneElement->setAttributeNode(NewAttribute("    
317   coneElement->setAttributeNode(                  
318     NewAttribute("rmin1", cone->GetInnerRadius    
319   coneElement->setAttributeNode(                  
320     NewAttribute("rmax1", cone->GetOuterRadius    
321   coneElement->setAttributeNode(                  
322     NewAttribute("rmin2", cone->GetInnerRadius    
323   coneElement->setAttributeNode(                  
324     NewAttribute("rmax2", cone->GetOuterRadius    
325   coneElement->setAttributeNode(                  
326     NewAttribute("z", 2.0 * cone->GetZHalfLeng    
327   coneElement->setAttributeNode(                  
328     NewAttribute("startphi", cone->GetStartPhi    
329   coneElement->setAttributeNode(                  
330     NewAttribute("deltaphi", cone->GetDeltaPhi    
331   coneElement->setAttributeNode(NewAttribute("    
332   coneElement->setAttributeNode(NewAttribute("    
333   solElement->appendChild(coneElement);           
334 }                                                 
335                                                   
336 // -------------------------------------------    
337 void G4GDMLWriteSolids::ElconeWrite(xercesc::D    
338                                     const G4El    
339 {                                                 
340   const G4String& name = GenerateName(elcone->    
341                                                   
342   xercesc::DOMElement* elconeElement = NewElem    
343   elconeElement->setAttributeNode(NewAttribute    
344   elconeElement->setAttributeNode(                
345     NewAttribute("dx", elcone->GetSemiAxisX()     
346   elconeElement->setAttributeNode(                
347     NewAttribute("dy", elcone->GetSemiAxisY()     
348   elconeElement->setAttributeNode(NewAttribute    
349   elconeElement->setAttributeNode(                
350     NewAttribute("zcut", elcone->GetZTopCut()     
351   elconeElement->setAttributeNode(NewAttribute    
352   solElement->appendChild(elconeElement);         
353 }                                                 
354                                                   
355 // -------------------------------------------    
356 void G4GDMLWriteSolids::EllipsoidWrite(xercesc    
357                                        const G    
358 {                                                 
359   const G4String& name = GenerateName(ellipsoi    
360                                                   
361   xercesc::DOMElement* ellipsoidElement = NewE    
362   ellipsoidElement->setAttributeNode(NewAttrib    
363   ellipsoidElement->setAttributeNode(             
364     NewAttribute("ax", ellipsoid->GetSemiAxisM    
365   ellipsoidElement->setAttributeNode(             
366     NewAttribute("by", ellipsoid->GetSemiAxisM    
367   ellipsoidElement->setAttributeNode(             
368     NewAttribute("cz", ellipsoid->GetSemiAxisM    
369   ellipsoidElement->setAttributeNode(             
370     NewAttribute("zcut1", ellipsoid->GetZBotto    
371   ellipsoidElement->setAttributeNode(             
372     NewAttribute("zcut2", ellipsoid->GetZTopCu    
373   ellipsoidElement->setAttributeNode(NewAttrib    
374   solElement->appendChild(ellipsoidElement);      
375 }                                                 
376                                                   
377 // -------------------------------------------    
378 void G4GDMLWriteSolids::EltubeWrite(xercesc::D    
379                                     const G4El    
380 {                                                 
381   const G4String& name = GenerateName(eltube->    
382                                                   
383   xercesc::DOMElement* eltubeElement = NewElem    
384   eltubeElement->setAttributeNode(NewAttribute    
385   eltubeElement->setAttributeNode(NewAttribute    
386   eltubeElement->setAttributeNode(NewAttribute    
387   eltubeElement->setAttributeNode(NewAttribute    
388   eltubeElement->setAttributeNode(NewAttribute    
389   solElement->appendChild(eltubeElement);         
390 }                                                 
391                                                   
392 // -------------------------------------------    
393 void G4GDMLWriteSolids::XtruWrite(xercesc::DOM    
394                                   const G4Extr    
395 {                                                 
396   const G4String& name = GenerateName(xtru->Ge    
397                                                   
398   xercesc::DOMElement* xtruElement = NewElemen    
399   xtruElement->setAttributeNode(NewAttribute("    
400   xtruElement->setAttributeNode(NewAttribute("    
401   solElement->appendChild(xtruElement);           
402                                                   
403   const G4int NumVertex = xtru->GetNofVertices    
404                                                   
405   for(G4int i = 0; i < NumVertex; ++i)            
406   {                                               
407     xercesc::DOMElement* twoDimVertexElement =    
408     xtruElement->appendChild(twoDimVertexEleme    
409                                                   
410     const G4TwoVector& vertex = xtru->GetVerte    
411                                                   
412     twoDimVertexElement->setAttributeNode(NewA    
413     twoDimVertexElement->setAttributeNode(NewA    
414   }                                               
415                                                   
416   const G4int NumSection = xtru->GetNofZSectio    
417                                                   
418   for(G4int i = 0; i < NumSection; ++i)           
419   {                                               
420     xercesc::DOMElement* sectionElement = NewE    
421     xtruElement->appendChild(sectionElement);     
422                                                   
423     const G4ExtrudedSolid::ZSection section =     
424                                                   
425     sectionElement->setAttributeNode(NewAttrib    
426     sectionElement->setAttributeNode(             
427       NewAttribute("zPosition", section.fZ / m    
428     sectionElement->setAttributeNode(             
429       NewAttribute("xOffset", section.fOffset.    
430     sectionElement->setAttributeNode(             
431       NewAttribute("yOffset", section.fOffset.    
432     sectionElement->setAttributeNode(             
433       NewAttribute("scalingFactor", section.fS    
434   }                                               
435 }                                                 
436                                                   
437 // -------------------------------------------    
438 void G4GDMLWriteSolids::HypeWrite(xercesc::DOM    
439                                   const G4Hype    
440 {                                                 
441   const G4String& name = GenerateName(hype->Ge    
442                                                   
443   xercesc::DOMElement* hypeElement = NewElemen    
444   hypeElement->setAttributeNode(NewAttribute("    
445   hypeElement->setAttributeNode(                  
446     NewAttribute("rmin", hype->GetInnerRadius(    
447   hypeElement->setAttributeNode(                  
448     NewAttribute("rmax", hype->GetOuterRadius(    
449   hypeElement->setAttributeNode(                  
450     NewAttribute("inst", hype->GetInnerStereo(    
451   hypeElement->setAttributeNode(                  
452     NewAttribute("outst", hype->GetOuterStereo    
453   hypeElement->setAttributeNode(                  
454     NewAttribute("z", 2.0 * hype->GetZHalfLeng    
455   hypeElement->setAttributeNode(NewAttribute("    
456   hypeElement->setAttributeNode(NewAttribute("    
457   solElement->appendChild(hypeElement);           
458 }                                                 
459                                                   
460 // -------------------------------------------    
461 void G4GDMLWriteSolids::OrbWrite(xercesc::DOME    
462                                  const G4Orb*     
463 {                                                 
464   const G4String& name = GenerateName(orb->Get    
465                                                   
466   xercesc::DOMElement* orbElement = NewElement    
467   orbElement->setAttributeNode(NewAttribute("n    
468   orbElement->setAttributeNode(NewAttribute("r    
469   orbElement->setAttributeNode(NewAttribute("l    
470   solElement->appendChild(orbElement);            
471 }                                                 
472                                                   
473 // -------------------------------------------    
474 void G4GDMLWriteSolids::ParaWrite(xercesc::DOM    
475                                   const G4Para    
476 {                                                 
477   const G4String& name = GenerateName(para->Ge    
478                                                   
479   const G4ThreeVector simaxis = para->GetSymAx    
480   const G4double alpha        = std::atan(para    
481   const G4double phi          = simaxis.phi();    
482   const G4double theta        = simaxis.theta(    
483                                                   
484   xercesc::DOMElement* paraElement = NewElemen    
485   paraElement->setAttributeNode(NewAttribute("    
486   paraElement->setAttributeNode(                  
487     NewAttribute("x", 2.0 * para->GetXHalfLeng    
488   paraElement->setAttributeNode(                  
489     NewAttribute("y", 2.0 * para->GetYHalfLeng    
490   paraElement->setAttributeNode(                  
491     NewAttribute("z", 2.0 * para->GetZHalfLeng    
492   paraElement->setAttributeNode(NewAttribute("    
493   paraElement->setAttributeNode(NewAttribute("    
494   paraElement->setAttributeNode(NewAttribute("    
495   paraElement->setAttributeNode(NewAttribute("    
496   paraElement->setAttributeNode(NewAttribute("    
497   solElement->appendChild(paraElement);           
498 }                                                 
499                                                   
500 // -------------------------------------------    
501 void G4GDMLWriteSolids::ParaboloidWrite(xerces    
502                                         const     
503 {                                                 
504   const G4String& name = GenerateName(parabolo    
505                                                   
506   xercesc::DOMElement* paraboloidElement = New    
507   paraboloidElement->setAttributeNode(NewAttri    
508   paraboloidElement->setAttributeNode(            
509     NewAttribute("rlo", paraboloid->GetRadiusM    
510   paraboloidElement->setAttributeNode(            
511     NewAttribute("rhi", paraboloid->GetRadiusP    
512   paraboloidElement->setAttributeNode(            
513     NewAttribute("dz", paraboloid->GetZHalfLen    
514   paraboloidElement->setAttributeNode(NewAttri    
515   solElement->appendChild(paraboloidElement);     
516 }                                                 
517                                                   
518 // -------------------------------------------    
519 void G4GDMLWriteSolids::PolyconeWrite(xercesc:    
520                                       const G4    
521 {                                                 
522   const G4String& name = GenerateName(polycone    
523                                                   
524   xercesc::DOMElement* polyconeElement = NewEl    
525   polyconeElement->setAttributeNode(NewAttribu    
526   polyconeElement->setAttributeNode(NewAttribu    
527     "startphi", polycone->GetOriginalParameter    
528   polyconeElement->setAttributeNode(NewAttribu    
529     "deltaphi", polycone->GetOriginalParameter    
530   polyconeElement->setAttributeNode(NewAttribu    
531   polyconeElement->setAttributeNode(NewAttribu    
532   solElement->appendChild(polyconeElement);       
533                                                   
534   const std::size_t num_zplanes                   
535         = polycone->GetOriginalParameters()->N    
536   const G4double* z_array    = polycone->GetOr    
537   const G4double* rmin_array = polycone->GetOr    
538   const G4double* rmax_array = polycone->GetOr    
539                                                   
540   for(std::size_t i = 0; i < num_zplanes; ++i)    
541   {                                               
542     ZplaneWrite(polyconeElement, z_array[i], r    
543   }                                               
544 }                                                 
545                                                   
546 // -------------------------------------------    
547 void G4GDMLWriteSolids::GenericPolyconeWrite(     
548   xercesc::DOMElement* solElement, const G4Gen    
549 {                                                 
550   const G4String& name = GenerateName(polycone    
551   xercesc::DOMElement* polyconeElement = NewEl    
552   const G4double startPhi              = polyc    
553   polyconeElement->setAttributeNode(NewAttribu    
554   polyconeElement->setAttributeNode(              
555     NewAttribute("startphi", startPhi / degree    
556   polyconeElement->setAttributeNode(              
557     NewAttribute("deltaphi", (polycone->GetEnd    
558   polyconeElement->setAttributeNode(NewAttribu    
559   polyconeElement->setAttributeNode(NewAttribu    
560   solElement->appendChild(polyconeElement);       
561                                                   
562   const G4int num_rzpoints = (G4int)polycone->    
563   for(G4int i = 0; i < num_rzpoints; ++i)         
564   {                                               
565     const G4double r_point = polycone->GetCorn    
566     const G4double z_point = polycone->GetCorn    
567     RZPointWrite(polyconeElement, r_point, z_p    
568   }                                               
569 }                                                 
570                                                   
571 // -------------------------------------------    
572 void G4GDMLWriteSolids::PolyhedraWrite(xercesc    
573                                        const G    
574 {                                                 
575   const G4String& name = GenerateName(polyhedr    
576   if(polyhedra->IsGeneric() == false)             
577   {                                               
578     xercesc::DOMElement* polyhedraElement = Ne    
579     polyhedraElement->setAttributeNode(NewAttr    
580     polyhedraElement->setAttributeNode(NewAttr    
581       "startphi", polyhedra->GetOriginalParame    
582     polyhedraElement->setAttributeNode(NewAttr    
583       "deltaphi", polyhedra->GetOriginalParame    
584     polyhedraElement->setAttributeNode(           
585       NewAttribute("numsides", polyhedra->GetO    
586     polyhedraElement->setAttributeNode(NewAttr    
587     polyhedraElement->setAttributeNode(NewAttr    
588     solElement->appendChild(polyhedraElement);    
589                                                   
590     const std::size_t num_zplanes                 
591           = polyhedra->GetOriginalParameters()    
592     const G4double* z_array  = polyhedra->GetO    
593     const G4double* rmin_array = polyhedra->Ge    
594     const G4double* rmax_array = polyhedra->Ge    
595                                                   
596     const G4double convertRad =                   
597       std::cos(0.5 * polyhedra->GetOriginalPar    
598                polyhedra->GetOriginalParameter    
599                                                   
600     for(std::size_t i = 0; i < num_zplanes; ++    
601     {                                             
602       ZplaneWrite(polyhedraElement, z_array[i]    
603                   rmax_array[i] * convertRad);    
604     }                                             
605   }                                               
606   else  // generic polyhedra                      
607   {                                               
608     xercesc::DOMElement* polyhedraElement = Ne    
609     polyhedraElement->setAttributeNode(NewAttr    
610     polyhedraElement->setAttributeNode(NewAttr    
611       "startphi", polyhedra->GetOriginalParame    
612     polyhedraElement->setAttributeNode(NewAttr    
613       "deltaphi", polyhedra->GetOriginalParame    
614     polyhedraElement->setAttributeNode(           
615       NewAttribute("numsides", polyhedra->GetO    
616     polyhedraElement->setAttributeNode(NewAttr    
617     polyhedraElement->setAttributeNode(NewAttr    
618     solElement->appendChild(polyhedraElement);    
619                                                   
620     const G4int num_rzpoints = (G4int)polyhedr    
621                                                   
622     for(G4int i = 0; i < num_rzpoints; ++i)       
623     {                                             
624       const G4double r_point = polyhedra->GetC    
625       const G4double z_point = polyhedra->GetC    
626       RZPointWrite(polyhedraElement, r_point,     
627     }                                             
628   }                                               
629 }                                                 
630                                                   
631 // -------------------------------------------    
632 void G4GDMLWriteSolids::SphereWrite(xercesc::D    
633                                     const G4Sp    
634 {                                                 
635   const G4String& name = GenerateName(sphere->    
636                                                   
637   xercesc::DOMElement* sphereElement = NewElem    
638   sphereElement->setAttributeNode(NewAttribute    
639   sphereElement->setAttributeNode(                
640     NewAttribute("rmin", sphere->GetInnerRadiu    
641   sphereElement->setAttributeNode(                
642     NewAttribute("rmax", sphere->GetOuterRadiu    
643   sphereElement->setAttributeNode(                
644     NewAttribute("startphi", sphere->GetStartP    
645   sphereElement->setAttributeNode(                
646     NewAttribute("deltaphi", sphere->GetDeltaP    
647   sphereElement->setAttributeNode(                
648     NewAttribute("starttheta", sphere->GetStar    
649   sphereElement->setAttributeNode(                
650     NewAttribute("deltatheta", sphere->GetDelt    
651   sphereElement->setAttributeNode(NewAttribute    
652   sphereElement->setAttributeNode(NewAttribute    
653   solElement->appendChild(sphereElement);         
654 }                                                 
655                                                   
656 // -------------------------------------------    
657 void G4GDMLWriteSolids::TessellatedWrite(         
658   xercesc::DOMElement* solElement, const G4Tes    
659 {                                                 
660   const G4String& solid_name = tessellated->Ge    
661   const G4String& name       = GenerateName(so    
662                                                   
663   xercesc::DOMElement* tessellatedElement = Ne    
664   tessellatedElement->setAttributeNode(NewAttr    
665   tessellatedElement->setAttributeNode(NewAttr    
666   tessellatedElement->setAttributeNode(NewAttr    
667   solElement->appendChild(tessellatedElement);    
668                                                   
669   std::map<G4ThreeVector, G4String, G4ThreeVec    
670                                                   
671   const std::size_t NumFacets = tessellated->G    
672   std::size_t NumVertex = 0;                      
673                                                   
674   for(std::size_t i = 0; i < NumFacets; ++i)      
675   {                                               
676     const G4VFacet* facet          = tessellat    
677     const size_t NumVertexPerFacet = facet->Ge    
678                                                   
679     G4String FacetTag;                            
680                                                   
681     if(NumVertexPerFacet == 3)                    
682     {                                             
683       FacetTag = "triangular";                    
684     }                                             
685     else if(NumVertexPerFacet == 4)               
686     {                                             
687       FacetTag = "quadrangular";                  
688     }                                             
689     else                                          
690     {                                             
691       G4Exception("G4GDMLWriteSolids::Tessella    
692                   FatalException, "Facet shoul    
693     }                                             
694                                                   
695     xercesc::DOMElement* facetElement = NewEle    
696     tessellatedElement->appendChild(facetEleme    
697                                                   
698     for(std::size_t j = 0; j < NumVertexPerFac    
699     {                                             
700       std::stringstream name_stream;              
701       std::stringstream ref_stream;               
702                                                   
703       name_stream << "vertex" << (j + 1);         
704       ref_stream << solid_name << "_v" << NumV    
705                                                   
706       const G4String& fname = name_stream.str(    
707       G4String ref          = ref_stream.str()    
708                                                   
709       // Now search for the existance of the c    
710       // map of cached vertices. If existing,     
711       // position in the GDML file, so avoidin    
712       // cache it in the local map and add it     
713       // "define" section of the GDML file.       
714                                                   
715       const G4ThreeVector& vertex = facet->Get    
716                                                   
717       if(vertexMap.find(vertex) != vertexMap.c    
718       {                                           
719         ref = vertexMap[vertex];  // Set the p    
720       }                                           
721       else  // Vertex not found                   
722       {                                           
723         if ( ! vertexMap.insert(std::make_pair    
724         {                                         
725           G4ExceptionDescription description;     
726           description << "Failed to insert [ve    
727                       << ref << " in map.";       
728           G4Exception("G4GDMLWriteSolids::Tess    
729                        JustWarning, descriptio    
730         }                                         
731         AddPosition(ref, vertex);  // ... add     
732         ++NumVertex;                              
733       }                                           
734                                                   
735       // Now create association of the vertex     
736       //                                          
737       facetElement->setAttributeNode(NewAttrib    
738     }                                             
739   }                                               
740 }                                                 
741                                                   
742 // -------------------------------------------    
743 void G4GDMLWriteSolids::TetWrite(xercesc::DOME    
744                                  const G4Tet*     
745 {                                                 
746   const G4String& solid_name = tet->GetName();    
747   const G4String& name       = GenerateName(so    
748                                                   
749   std::vector<G4ThreeVector> vertexList = tet-    
750                                                   
751   xercesc::DOMElement* tetElement = NewElement    
752   tetElement->setAttributeNode(NewAttribute("n    
753   tetElement->setAttributeNode(NewAttribute("v    
754   tetElement->setAttributeNode(NewAttribute("v    
755   tetElement->setAttributeNode(NewAttribute("v    
756   tetElement->setAttributeNode(NewAttribute("v    
757   tetElement->setAttributeNode(NewAttribute("l    
758   solElement->appendChild(tetElement);            
759                                                   
760   AddPosition(solid_name + "_v1", vertexList[0    
761   AddPosition(solid_name + "_v2", vertexList[1    
762   AddPosition(solid_name + "_v3", vertexList[2    
763   AddPosition(solid_name + "_v4", vertexList[3    
764 }                                                 
765                                                   
766 // -------------------------------------------    
767 void G4GDMLWriteSolids::TorusWrite(xercesc::DO    
768                                    const G4Tor    
769 {                                                 
770   const G4String& name = GenerateName(torus->G    
771                                                   
772   xercesc::DOMElement* torusElement = NewEleme    
773   torusElement->setAttributeNode(NewAttribute(    
774   torusElement->setAttributeNode(NewAttribute(    
775   torusElement->setAttributeNode(NewAttribute(    
776   torusElement->setAttributeNode(NewAttribute(    
777   torusElement->setAttributeNode(                 
778     NewAttribute("startphi", torus->GetSPhi()     
779   torusElement->setAttributeNode(                 
780     NewAttribute("deltaphi", torus->GetDPhi()     
781   torusElement->setAttributeNode(NewAttribute(    
782   torusElement->setAttributeNode(NewAttribute(    
783   solElement->appendChild(torusElement);          
784 }                                                 
785                                                   
786 // -------------------------------------------    
787 void G4GDMLWriteSolids::GenTrapWrite(xercesc::    
788                                      const G4G    
789 {                                                 
790   const G4String& name = GenerateName(gtrap->G    
791                                                   
792   std::vector<G4TwoVector> vertices = gtrap->G    
793                                                   
794   xercesc::DOMElement* gtrapElement = NewEleme    
795   gtrapElement->setAttributeNode(NewAttribute(    
796   gtrapElement->setAttributeNode(                 
797     NewAttribute("dz", gtrap->GetZHalfLength()    
798   gtrapElement->setAttributeNode(NewAttribute(    
799   gtrapElement->setAttributeNode(NewAttribute(    
800   gtrapElement->setAttributeNode(NewAttribute(    
801   gtrapElement->setAttributeNode(NewAttribute(    
802   gtrapElement->setAttributeNode(NewAttribute(    
803   gtrapElement->setAttributeNode(NewAttribute(    
804   gtrapElement->setAttributeNode(NewAttribute(    
805   gtrapElement->setAttributeNode(NewAttribute(    
806   gtrapElement->setAttributeNode(NewAttribute(    
807   gtrapElement->setAttributeNode(NewAttribute(    
808   gtrapElement->setAttributeNode(NewAttribute(    
809   gtrapElement->setAttributeNode(NewAttribute(    
810   gtrapElement->setAttributeNode(NewAttribute(    
811   gtrapElement->setAttributeNode(NewAttribute(    
812   gtrapElement->setAttributeNode(NewAttribute(    
813   gtrapElement->setAttributeNode(NewAttribute(    
814   gtrapElement->setAttributeNode(NewAttribute(    
815   solElement->appendChild(gtrapElement);          
816 }                                                 
817                                                   
818 // -------------------------------------------    
819 void G4GDMLWriteSolids::TrapWrite(xercesc::DOM    
820                                   const G4Trap    
821 {                                                 
822   const G4String& name = GenerateName(trap->Ge    
823                                                   
824   const G4ThreeVector& simaxis = trap->GetSymA    
825   const G4double phi           = simaxis.phi()    
826   const G4double theta         = simaxis.theta    
827   const G4double alpha1        = std::atan(tra    
828   const G4double alpha2        = std::atan(tra    
829                                                   
830   xercesc::DOMElement* trapElement = NewElemen    
831   trapElement->setAttributeNode(NewAttribute("    
832   trapElement->setAttributeNode(                  
833     NewAttribute("z", 2.0 * trap->GetZHalfLeng    
834   trapElement->setAttributeNode(NewAttribute("    
835   trapElement->setAttributeNode(NewAttribute("    
836   trapElement->setAttributeNode(                  
837     NewAttribute("y1", 2.0 * trap->GetYHalfLen    
838   trapElement->setAttributeNode(                  
839     NewAttribute("x1", 2.0 * trap->GetXHalfLen    
840   trapElement->setAttributeNode(                  
841     NewAttribute("x2", 2.0 * trap->GetXHalfLen    
842   trapElement->setAttributeNode(NewAttribute("    
843   trapElement->setAttributeNode(                  
844     NewAttribute("y2", 2.0 * trap->GetYHalfLen    
845   trapElement->setAttributeNode(                  
846     NewAttribute("x3", 2.0 * trap->GetXHalfLen    
847   trapElement->setAttributeNode(                  
848     NewAttribute("x4", 2.0 * trap->GetXHalfLen    
849   trapElement->setAttributeNode(NewAttribute("    
850   trapElement->setAttributeNode(NewAttribute("    
851   trapElement->setAttributeNode(NewAttribute("    
852   solElement->appendChild(trapElement);           
853 }                                                 
854                                                   
855 // -------------------------------------------    
856 void G4GDMLWriteSolids::TrdWrite(xercesc::DOME    
857                                  const G4Trd*     
858 {                                                 
859   const G4String& name = GenerateName(trd->Get    
860                                                   
861   xercesc::DOMElement* trdElement = NewElement    
862   trdElement->setAttributeNode(NewAttribute("n    
863   trdElement->setAttributeNode(                   
864     NewAttribute("x1", 2.0 * trd->GetXHalfLeng    
865   trdElement->setAttributeNode(                   
866     NewAttribute("x2", 2.0 * trd->GetXHalfLeng    
867   trdElement->setAttributeNode(                   
868     NewAttribute("y1", 2.0 * trd->GetYHalfLeng    
869   trdElement->setAttributeNode(                   
870     NewAttribute("y2", 2.0 * trd->GetYHalfLeng    
871   trdElement->setAttributeNode(                   
872     NewAttribute("z", 2.0 * trd->GetZHalfLengt    
873   trdElement->setAttributeNode(NewAttribute("l    
874   solElement->appendChild(trdElement);            
875 }                                                 
876                                                   
877 // -------------------------------------------    
878 void G4GDMLWriteSolids::TubeWrite(xercesc::DOM    
879                                   const G4Tubs    
880 {                                                 
881   const G4String& name = GenerateName(tube->Ge    
882                                                   
883   xercesc::DOMElement* tubeElement = NewElemen    
884   tubeElement->setAttributeNode(NewAttribute("    
885   tubeElement->setAttributeNode(                  
886     NewAttribute("rmin", tube->GetInnerRadius(    
887   tubeElement->setAttributeNode(                  
888     NewAttribute("rmax", tube->GetOuterRadius(    
889   tubeElement->setAttributeNode(                  
890     NewAttribute("z", 2.0 * tube->GetZHalfLeng    
891   tubeElement->setAttributeNode(                  
892     NewAttribute("startphi", tube->GetStartPhi    
893   tubeElement->setAttributeNode(                  
894     NewAttribute("deltaphi", tube->GetDeltaPhi    
895   tubeElement->setAttributeNode(NewAttribute("    
896   tubeElement->setAttributeNode(NewAttribute("    
897   solElement->appendChild(tubeElement);           
898 }                                                 
899                                                   
900 // -------------------------------------------    
901 void G4GDMLWriteSolids::CutTubeWrite(xercesc::    
902                                      const G4C    
903 {                                                 
904   const G4String& name = GenerateName(cuttube-    
905                                                   
906   xercesc::DOMElement* cuttubeElement = NewEle    
907   cuttubeElement->setAttributeNode(NewAttribut    
908   cuttubeElement->setAttributeNode(               
909     NewAttribute("rmin", cuttube->GetInnerRadi    
910   cuttubeElement->setAttributeNode(               
911     NewAttribute("rmax", cuttube->GetOuterRadi    
912   cuttubeElement->setAttributeNode(               
913     NewAttribute("z", 2.0 * cuttube->GetZHalfL    
914   cuttubeElement->setAttributeNode(               
915     NewAttribute("startphi", cuttube->GetStart    
916   cuttubeElement->setAttributeNode(               
917     NewAttribute("deltaphi", cuttube->GetDelta    
918   cuttubeElement->setAttributeNode(               
919     NewAttribute("lowX", cuttube->GetLowNorm()    
920   cuttubeElement->setAttributeNode(               
921     NewAttribute("lowY", cuttube->GetLowNorm()    
922   cuttubeElement->setAttributeNode(               
923     NewAttribute("lowZ", cuttube->GetLowNorm()    
924   cuttubeElement->setAttributeNode(               
925     NewAttribute("highX", cuttube->GetHighNorm    
926   cuttubeElement->setAttributeNode(               
927     NewAttribute("highY", cuttube->GetHighNorm    
928   cuttubeElement->setAttributeNode(               
929     NewAttribute("highZ", cuttube->GetHighNorm    
930   cuttubeElement->setAttributeNode(NewAttribut    
931   cuttubeElement->setAttributeNode(NewAttribut    
932   solElement->appendChild(cuttubeElement);        
933 }                                                 
934                                                   
935 // -------------------------------------------    
936 void G4GDMLWriteSolids::TwistedboxWrite(xerces    
937                                         const     
938 {                                                 
939   const G4String& name = GenerateName(twistedb    
940                                                   
941   xercesc::DOMElement* twistedboxElement = New    
942   twistedboxElement->setAttributeNode(NewAttri    
943   twistedboxElement->setAttributeNode(            
944     NewAttribute("x", 2.0 * twistedbox->GetXHa    
945   twistedboxElement->setAttributeNode(            
946     NewAttribute("y", 2.0 * twistedbox->GetYHa    
947   twistedboxElement->setAttributeNode(            
948     NewAttribute("z", 2.0 * twistedbox->GetZHa    
949   twistedboxElement->setAttributeNode(            
950     NewAttribute("PhiTwist", twistedbox->GetPh    
951   twistedboxElement->setAttributeNode(NewAttri    
952   twistedboxElement->setAttributeNode(NewAttri    
953   solElement->appendChild(twistedboxElement);     
954 }                                                 
955                                                   
956 // -------------------------------------------    
957 void G4GDMLWriteSolids::TwistedtrapWrite(xerce    
958                                          const    
959 {                                                 
960   const G4String& name = GenerateName(twistedt    
961                                                   
962   xercesc::DOMElement* twistedtrapElement = Ne    
963   twistedtrapElement->setAttributeNode(NewAttr    
964   twistedtrapElement->setAttributeNode(           
965     NewAttribute("y1", 2.0 * twistedtrap->GetY    
966   twistedtrapElement->setAttributeNode(           
967     NewAttribute("x1", 2.0 * twistedtrap->GetX    
968   twistedtrapElement->setAttributeNode(           
969     NewAttribute("x2", 2.0 * twistedtrap->GetX    
970   twistedtrapElement->setAttributeNode(           
971     NewAttribute("y2", 2.0 * twistedtrap->GetY    
972   twistedtrapElement->setAttributeNode(           
973     NewAttribute("x3", 2.0 * twistedtrap->GetX    
974   twistedtrapElement->setAttributeNode(           
975     NewAttribute("x4", 2.0 * twistedtrap->GetX    
976   twistedtrapElement->setAttributeNode(           
977     NewAttribute("z", 2.0 * twistedtrap->GetZH    
978   twistedtrapElement->setAttributeNode(           
979     NewAttribute("Alph", twistedtrap->GetTiltA    
980   twistedtrapElement->setAttributeNode(           
981     NewAttribute("Theta", twistedtrap->GetPola    
982   twistedtrapElement->setAttributeNode(           
983     NewAttribute("Phi", twistedtrap->GetAzimut    
984   twistedtrapElement->setAttributeNode(           
985     NewAttribute("PhiTwist", twistedtrap->GetP    
986   twistedtrapElement->setAttributeNode(NewAttr    
987   twistedtrapElement->setAttributeNode(NewAttr    
988                                                   
989   solElement->appendChild(twistedtrapElement);    
990 }                                                 
991                                                   
992 // -------------------------------------------    
993 void G4GDMLWriteSolids::TwistedtrdWrite(xerces    
994                                         const     
995 {                                                 
996   const G4String& name = GenerateName(twistedt    
997                                                   
998   xercesc::DOMElement* twistedtrdElement = New    
999   twistedtrdElement->setAttributeNode(NewAttri    
1000   twistedtrdElement->setAttributeNode(           
1001     NewAttribute("x1", 2.0 * twistedtrd->GetX    
1002   twistedtrdElement->setAttributeNode(           
1003     NewAttribute("x2", 2.0 * twistedtrd->GetX    
1004   twistedtrdElement->setAttributeNode(           
1005     NewAttribute("y1", 2.0 * twistedtrd->GetY    
1006   twistedtrdElement->setAttributeNode(           
1007     NewAttribute("y2", 2.0 * twistedtrd->GetY    
1008   twistedtrdElement->setAttributeNode(           
1009     NewAttribute("z", 2.0 * twistedtrd->GetZH    
1010   twistedtrdElement->setAttributeNode(           
1011     NewAttribute("PhiTwist", twistedtrd->GetP    
1012   twistedtrdElement->setAttributeNode(NewAttr    
1013   twistedtrdElement->setAttributeNode(NewAttr    
1014   solElement->appendChild(twistedtrdElement);    
1015 }                                                
1016                                                  
1017 // ------------------------------------------    
1018 void G4GDMLWriteSolids::TwistedtubsWrite(xerc    
1019                                          cons    
1020 {                                                
1021   const G4String& name = GenerateName(twisted    
1022                                                  
1023   xercesc::DOMElement* twistedtubsElement = N    
1024   twistedtubsElement->setAttributeNode(NewAtt    
1025   twistedtubsElement->setAttributeNode(          
1026     NewAttribute("twistedangle", twistedtubs-    
1027   twistedtubsElement->setAttributeNode(          
1028     NewAttribute("midinnerrad", twistedtubs->    
1029   twistedtubsElement->setAttributeNode(          
1030     NewAttribute("midouterrad", twistedtubs->    
1031   twistedtubsElement->setAttributeNode(          
1032     NewAttribute("negativeEndz", twistedtubs-    
1033   twistedtubsElement->setAttributeNode(          
1034     NewAttribute("positiveEndz", twistedtubs-    
1035   twistedtubsElement->setAttributeNode(          
1036     NewAttribute("phi", twistedtubs->GetDPhi(    
1037   twistedtubsElement->setAttributeNode(NewAtt    
1038   twistedtubsElement->setAttributeNode(NewAtt    
1039   solElement->appendChild(twistedtubsElement)    
1040 }                                                
1041                                                  
1042 // ------------------------------------------    
1043 void G4GDMLWriteSolids::ZplaneWrite(xercesc::    
1044                                     const G4d    
1045                                     const G4d    
1046 {                                                
1047   xercesc::DOMElement* zplaneElement = NewEle    
1048   zplaneElement->setAttributeNode(NewAttribut    
1049   zplaneElement->setAttributeNode(NewAttribut    
1050   zplaneElement->setAttributeNode(NewAttribut    
1051   element->appendChild(zplaneElement);           
1052 }                                                
1053                                                  
1054 // ------------------------------------------    
1055 void G4GDMLWriteSolids::RZPointWrite(xercesc:    
1056                                      const G4    
1057 {                                                
1058   xercesc::DOMElement* rzpointElement = NewEl    
1059   rzpointElement->setAttributeNode(NewAttribu    
1060   rzpointElement->setAttributeNode(NewAttribu    
1061   element->appendChild(rzpointElement);          
1062 }                                                
1063                                                  
1064 // ------------------------------------------    
1065 void G4GDMLWriteSolids::OpticalSurfaceWrite(x    
1066                                             c    
1067 {                                                
1068   xercesc::DOMElement* optElement = NewElemen    
1069   G4OpticalSurfaceModel smodel    = surf->Get    
1070   G4double sval =                                
1071     (smodel == glisur) ? surf->GetPolish() :     
1072   const G4String& name = GenerateName(surf->G    
1073                                                  
1074   optElement->setAttributeNode(NewAttribute("    
1075   optElement->setAttributeNode(NewAttribute("    
1076   optElement->setAttributeNode(NewAttribute("    
1077   optElement->setAttributeNode(NewAttribute("    
1078   optElement->setAttributeNode(NewAttribute("    
1079                                                  
1080   // Write any property attached to the optic    
1081   //                                             
1082   if(surf->GetMaterialPropertiesTable())         
1083   {                                              
1084     PropertyWrite(optElement, surf);             
1085   }                                              
1086                                                  
1087   solElement->appendChild(optElement);           
1088 }                                                
1089                                                  
1090 // ------------------------------------------    
1091 void G4GDMLWriteSolids::PropertyWrite(xercesc    
1092                                       const G    
1093 {                                                
1094   xercesc::DOMElement* propElement;              
1095   G4MaterialPropertiesTable* ptable = surf->G    
1096   auto pvec = ptable->GetProperties();           
1097   auto cvec = ptable->GetConstProperties();      
1098                                                  
1099   for(size_t i = 0; i < pvec.size(); ++i)        
1100   {                                              
1101     if(pvec[i] != nullptr) {                     
1102       propElement = NewElement("property");      
1103       propElement->setAttributeNode(             
1104         NewAttribute("name", ptable->GetMater    
1105       propElement->setAttributeNode(NewAttrib    
1106         "ref", GenerateName(ptable->GetMateri    
1107                             pvec[i])));          
1108       PropertyVectorWrite(ptable->GetMaterial    
1109                           pvec[i]);              
1110       optElement->appendChild(propElement);      
1111     }                                            
1112   }                                              
1113   for(size_t i = 0; i < cvec.size(); ++i)        
1114   {                                              
1115     if (cvec[i].second == true) {                
1116       propElement = NewElement("property");      
1117       propElement->setAttributeNode(NewAttrib    
1118         "name", ptable->GetMaterialConstPrope    
1119       propElement->setAttributeNode(NewAttrib    
1120         "ref", ptable->GetMaterialConstProper    
1121       xercesc::DOMElement* constElement = New    
1122       constElement->setAttributeNode(NewAttri    
1123         "name", ptable->GetMaterialConstPrope    
1124       constElement->setAttributeNode(NewAttri    
1125       defineElement->appendChild(constElement    
1126       optElement->appendChild(propElement);      
1127     }                                            
1128   }                                              
1129 }                                                
1130                                                  
1131 // ------------------------------------------    
1132 void G4GDMLWriteSolids::SolidsWrite(xercesc::    
1133 {                                                
1134 #ifdef G4VERBOSE                                 
1135   G4cout << "G4GDML: Writing solids..." << G4    
1136 #endif                                           
1137   solidsElement = NewElement("solids");          
1138   gdmlElement->appendChild(solidsElement);       
1139                                                  
1140   solidList.clear();                             
1141 }                                                
1142                                                  
1143 // ------------------------------------------    
1144 void G4GDMLWriteSolids::AddSolid(const G4VSol    
1145 {                                                
1146   for(std::size_t i = 0; i < solidList.size()    
1147   {                                              
1148     if(solidList[i] == solidPtr)                 
1149     {                                            
1150       return;                                    
1151     }                                            
1152   }                                              
1153                                                  
1154   solidList.push_back(solidPtr);                 
1155                                                  
1156   if(const G4BooleanSolid* const booleanPtr =    
1157        dynamic_cast<const G4BooleanSolid*>(so    
1158   {                                              
1159     BooleanWrite(solidsElement, booleanPtr);     
1160   }                                              
1161   else if(const G4ScaledSolid* const scaledPt    
1162             dynamic_cast<const G4ScaledSolid*    
1163   {                                              
1164     ScaledWrite(solidsElement, scaledPtr);       
1165   }                                              
1166   else if(solidPtr->GetEntityType() == "G4Mul    
1167   {                                              
1168     const G4MultiUnion* const munionPtr =        
1169       static_cast<const G4MultiUnion*>(solidP    
1170     MultiUnionWrite(solidsElement, munionPtr)    
1171   }                                              
1172   else if(solidPtr->GetEntityType() == "G4Box    
1173   {                                              
1174     const G4Box* const boxPtr = static_cast<c    
1175     BoxWrite(solidsElement, boxPtr);             
1176   }                                              
1177   else if(solidPtr->GetEntityType() == "G4Con    
1178   {                                              
1179     const G4Cons* const conePtr = static_cast    
1180     ConeWrite(solidsElement, conePtr);           
1181   }                                              
1182   else if(solidPtr->GetEntityType() == "G4Ell    
1183   {                                              
1184     const G4EllipticalCone* const elconePtr =    
1185       static_cast<const G4EllipticalCone*>(so    
1186     ElconeWrite(solidsElement, elconePtr);       
1187   }                                              
1188   else if(solidPtr->GetEntityType() == "G4Ell    
1189   {                                              
1190     const G4Ellipsoid* const ellipsoidPtr =      
1191       static_cast<const G4Ellipsoid*>(solidPt    
1192     EllipsoidWrite(solidsElement, ellipsoidPt    
1193   }                                              
1194   else if(solidPtr->GetEntityType() == "G4Ell    
1195   {                                              
1196     const G4EllipticalTube* const eltubePtr =    
1197       static_cast<const G4EllipticalTube*>(so    
1198     EltubeWrite(solidsElement, eltubePtr);       
1199   }                                              
1200   else if(solidPtr->GetEntityType() == "G4Ext    
1201   {                                              
1202     const G4ExtrudedSolid* const xtruPtr =       
1203       static_cast<const G4ExtrudedSolid*>(sol    
1204     XtruWrite(solidsElement, xtruPtr);           
1205   }                                              
1206   else if(solidPtr->GetEntityType() == "G4Hyp    
1207   {                                              
1208     const G4Hype* const hypePtr = static_cast    
1209     HypeWrite(solidsElement, hypePtr);           
1210   }                                              
1211   else if(solidPtr->GetEntityType() == "G4Orb    
1212   {                                              
1213     const G4Orb* const orbPtr = static_cast<c    
1214     OrbWrite(solidsElement, orbPtr);             
1215   }                                              
1216   else if(solidPtr->GetEntityType() == "G4Par    
1217   {                                              
1218     const G4Para* const paraPtr = static_cast    
1219     ParaWrite(solidsElement, paraPtr);           
1220   }                                              
1221   else if(solidPtr->GetEntityType() == "G4Par    
1222   {                                              
1223     const G4Paraboloid* const paraboloidPtr =    
1224       static_cast<const G4Paraboloid*>(solidP    
1225     ParaboloidWrite(solidsElement, paraboloid    
1226   }                                              
1227   else if(solidPtr->GetEntityType() == "G4Pol    
1228   {                                              
1229     const G4Polycone* const polyconePtr =        
1230       static_cast<const G4Polycone*>(solidPtr    
1231     PolyconeWrite(solidsElement, polyconePtr)    
1232   }                                              
1233   else if(solidPtr->GetEntityType() == "G4Gen    
1234   {                                              
1235     const G4GenericPolycone* const genpolycon    
1236       static_cast<const G4GenericPolycone*>(s    
1237     GenericPolyconeWrite(solidsElement, genpo    
1238   }                                              
1239   else if(solidPtr->GetEntityType() == "G4Pol    
1240   {                                              
1241     const G4Polyhedra* const polyhedraPtr =      
1242       static_cast<const G4Polyhedra*>(solidPt    
1243     PolyhedraWrite(solidsElement, polyhedraPt    
1244   }                                              
1245   else if(solidPtr->GetEntityType() == "G4Sph    
1246   {                                              
1247     const G4Sphere* const spherePtr = static_    
1248     SphereWrite(solidsElement, spherePtr);       
1249   }                                              
1250   else if(solidPtr->GetEntityType() == "G4Tes    
1251   {                                              
1252     const G4TessellatedSolid* const tessellat    
1253       static_cast<const G4TessellatedSolid*>(    
1254     TessellatedWrite(solidsElement, tessellat    
1255   }                                              
1256   else if(solidPtr->GetEntityType() == "G4Tet    
1257   {                                              
1258     const G4Tet* const tetPtr = static_cast<c    
1259     TetWrite(solidsElement, tetPtr);             
1260   }                                              
1261   else if(solidPtr->GetEntityType() == "G4Tor    
1262   {                                              
1263     const G4Torus* const torusPtr = static_ca    
1264     TorusWrite(solidsElement, torusPtr);         
1265   }                                              
1266   else if(solidPtr->GetEntityType() == "G4Gen    
1267   {                                              
1268     const G4GenericTrap* const gtrapPtr =        
1269       static_cast<const G4GenericTrap*>(solid    
1270     GenTrapWrite(solidsElement, gtrapPtr);       
1271   }                                              
1272   else if(solidPtr->GetEntityType() == "G4Tra    
1273   {                                              
1274     const G4Trap* const trapPtr = static_cast    
1275     TrapWrite(solidsElement, trapPtr);           
1276   }                                              
1277   else if(solidPtr->GetEntityType() == "G4Trd    
1278   {                                              
1279     const G4Trd* const trdPtr = static_cast<c    
1280     TrdWrite(solidsElement, trdPtr);             
1281   }                                              
1282   else if(solidPtr->GetEntityType() == "G4Tub    
1283   {                                              
1284     const G4Tubs* const tubePtr = static_cast    
1285     TubeWrite(solidsElement, tubePtr);           
1286   }                                              
1287   else if(solidPtr->GetEntityType() == "G4Cut    
1288   {                                              
1289     const G4CutTubs* const cuttubePtr = stati    
1290     CutTubeWrite(solidsElement, cuttubePtr);     
1291   }                                              
1292   else if(solidPtr->GetEntityType() == "G4Twi    
1293   {                                              
1294     const G4TwistedBox* const twistedboxPtr =    
1295       static_cast<const G4TwistedBox*>(solidP    
1296     TwistedboxWrite(solidsElement, twistedbox    
1297   }                                              
1298   else if(solidPtr->GetEntityType() == "G4Twi    
1299   {                                              
1300     const G4TwistedTrap* const twistedtrapPtr    
1301       static_cast<const G4TwistedTrap*>(solid    
1302     TwistedtrapWrite(solidsElement, twistedtr    
1303   }                                              
1304   else if(solidPtr->GetEntityType() == "G4Twi    
1305   {                                              
1306     const G4TwistedTrd* const twistedtrdPtr =    
1307       static_cast<const G4TwistedTrd*>(solidP    
1308     TwistedtrdWrite(solidsElement, twistedtrd    
1309   }                                              
1310   else if(solidPtr->GetEntityType() == "G4Twi    
1311   {                                              
1312     const G4TwistedTubs* const twistedtubsPtr    
1313       static_cast<const G4TwistedTubs*>(solid    
1314     TwistedtubsWrite(solidsElement, twistedtu    
1315   }                                              
1316   else                                           
1317   {                                              
1318     G4String error_msg = "Unknown solid: " +     
1319                          "; Type: " + solidPt    
1320     G4Exception("G4GDMLWriteSolids::AddSolid(    
1321                 error_msg);                      
1322   }                                              
1323 }                                                
1324