Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4GDMLReadSolids implementation << 26 // $Id: G4GDMLReadSolids.cc,v 1.22.2.1 2009/08/11 08:27:49 gcosmo Exp $ >> 27 // GEANT4 tag $Name: geant4-09-02-patch-02 $ >> 28 // >> 29 // class G4GDMLReadSolids Implementation >> 30 // >> 31 // Original author: Zoltan Torzsok, November 2007 27 // 32 // 28 // Author: Zoltan Torzsok, November 2007 << 29 // ------------------------------------------- 33 // -------------------------------------------------------------------- 30 34 31 #include "G4GDMLReadSolids.hh" 35 #include "G4GDMLReadSolids.hh" 32 #include "G4Box.hh" << 33 #include "G4Cons.hh" << 34 #include "G4Ellipsoid.hh" << 35 #include "G4EllipticalCone.hh" << 36 #include "G4EllipticalTube.hh" << 37 #include "G4Hype.hh" << 38 #include "G4IntersectionSolid.hh" << 39 #include "G4Orb.hh" << 40 #include "G4Para.hh" << 41 #include "G4Paraboloid.hh" << 42 #include "G4Polycone.hh" << 43 #include "G4GenericPolycone.hh" << 44 #include "G4Polyhedra.hh" << 45 #include "G4QuadrangularFacet.hh" << 46 #include "G4ReflectedSolid.hh" << 47 #include "G4ScaledSolid.hh" << 48 #include "G4Sphere.hh" << 49 #include "G4SolidStore.hh" << 50 #include "G4SubtractionSolid.hh" << 51 #include "G4GenericTrap.hh" << 52 #include "G4TessellatedSolid.hh" << 53 #include "G4Tet.hh" << 54 #include "G4Torus.hh" << 55 #include "G4Transform3D.hh" << 56 #include "G4Trap.hh" << 57 #include "G4Trd.hh" << 58 #include "G4TriangularFacet.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 "G4UnitsTable.hh" << 68 #include "G4SurfaceProperty.hh" << 69 36 70 // ------------------------------------------- << 37 G4GDMLReadSolids::G4GDMLReadSolids() : G4GDMLReadMaterials() 71 G4GDMLReadSolids::G4GDMLReadSolids() << 72 : G4GDMLReadMaterials() << 73 { 38 { 74 } 39 } 75 40 76 // ------------------------------------------- << 77 G4GDMLReadSolids::~G4GDMLReadSolids() 41 G4GDMLReadSolids::~G4GDMLReadSolids() 78 { 42 { 79 } 43 } 80 44 81 // ------------------------------------------- << 45 void G4GDMLReadSolids:: 82 void G4GDMLReadSolids::BooleanRead( << 46 BooleanRead(const xercesc::DOMElement* const booleanElement, const BooleanOp op) 83 const xercesc::DOMElement* const booleanElem << 84 { 47 { 85 G4String name; << 48 G4String name; 86 G4String first; << 49 G4String first; 87 G4String scnd; << 50 G4String second; 88 G4ThreeVector position(0.0, 0.0, 0.0); << 51 G4ThreeVector position(0.0,0.0,0.0); 89 G4ThreeVector rotation(0.0, 0.0, 0.0); << 52 G4ThreeVector rotation(0.0,0.0,0.0); 90 G4ThreeVector firstposition(0.0, 0.0, 0.0); << 53 G4ThreeVector firstposition(0.0,0.0,0.0); 91 G4ThreeVector firstrotation(0.0, 0.0, 0.0); << 54 G4ThreeVector firstrotation(0.0,0.0,0.0); 92 << 55 93 const xercesc::DOMNamedNodeMap* const attrib << 56 const xercesc::DOMNamedNodeMap* const attributes 94 booleanElement->getAttributes(); << 57 = booleanElement->getAttributes(); 95 XMLSize_t attributeCount = attributes->getLe << 58 XMLSize_t attributeCount = attributes->getLength(); 96 << 59 97 for(XMLSize_t attribute_index = 0; attribute << 60 for (XMLSize_t attribute_index=0; 98 ++attribute_index) << 61 attribute_index<attributeCount; attribute_index++) 99 { << 62 { 100 xercesc::DOMNode* attribute_node = attribu << 63 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 101 << 64 102 if(attribute_node->getNodeType() != xerces << 65 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 103 { << 66 { continue; } 104 continue; << 67 105 } << 68 const xercesc::DOMAttr* const attribute 106 << 69 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 107 const xercesc::DOMAttr* const attribute = << 70 const G4String attName = Transcode(attribute->getName()); 108 dynamic_cast<xercesc::DOMAttr*>(attribut << 71 const G4String attValue = Transcode(attribute->getValue()); 109 if(attribute == nullptr) << 72 110 { << 73 if (attName=="name") { name = GenerateName(attValue); } 111 G4Exception("G4GDMLReadSolids::BooleanRe << 74 } 112 FatalException, "No attribut << 75 113 return; << 76 for (xercesc::DOMNode* iter = booleanElement->getFirstChild(); 114 } << 77 iter != 0;iter = iter->getNextSibling()) 115 const G4String attName = Transcode(attrib << 78 { 116 const G4String attValue = Transcode(attrib << 79 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } 117 << 80 118 if(attName == "name") << 81 const xercesc::DOMElement* const child 119 { << 82 = dynamic_cast<xercesc::DOMElement*>(iter); 120 name = GenerateName(attValue); << 83 const G4String tag = Transcode(child->getTagName()); 121 } << 84 122 } << 85 if (tag=="first") { first = RefRead(child); } else 123 << 86 if (tag=="second") { second = RefRead(child); } else 124 for(xercesc::DOMNode* iter = booleanElement- << 87 if (tag=="position") { VectorRead(child,position); } else 125 iter = iter->getNextSi << 88 if (tag=="rotation") { VectorRead(child,rotation); } else 126 { << 89 if (tag=="positionref") 127 if(iter->getNodeType() != xercesc::DOMNode << 90 { position = GetPosition(GenerateName(RefRead(child))); } else 128 { << 91 if (tag=="rotationref") 129 continue; << 92 { rotation = GetRotation(GenerateName(RefRead(child))); } else 130 } << 93 if (tag=="firstposition") { VectorRead(child,firstposition); } else 131 << 94 if (tag=="firstrotation") { VectorRead(child,firstrotation); } else 132 const xercesc::DOMElement* const child = << 95 if (tag=="firstpositionref") 133 dynamic_cast<xercesc::DOMElement*>(iter) << 96 { firstposition = GetPosition(GenerateName(RefRead(child))); } else 134 if(child == nullptr) << 97 if (tag=="firstrotationref") 135 { << 98 { firstrotation = GetRotation(GenerateName(RefRead(child))); } 136 G4Exception("G4GDMLReadSolids::BooleanRe << 99 else 137 FatalException, "No child fo << 100 { 138 return; << 101 G4String error_msg = "Unknown tag in boolean solid: " + tag; 139 } << 102 G4Exception("G4GDMLReadSolids::BooleanRead()", "ReadError", 140 const G4String tag = Transcode(child->getT << 103 FatalException, error_msg); 141 << 104 } 142 if(tag == "first") << 105 } 143 { << 106 144 first = RefRead(child); << 107 G4VSolid* firstSolid = GetSolid(GenerateName(first)); 145 } << 108 G4VSolid* secondSolid = GetSolid(GenerateName(second)); 146 else if(tag == "second") << 109 147 { << 110 G4Transform3D transform(GetRotationMatrix(rotation),position); 148 scnd = RefRead(child); << 111 149 } << 112 if (( (firstrotation.x()!=0.0) || (firstrotation.y()!=0.0) 150 else if(tag == "position") << 113 || (firstrotation.z()!=0.0)) 151 { << 114 || ( (firstposition.x()!=0.0) || (firstposition.y()!=0.0) 152 VectorRead(child, position); << 115 || (firstposition.z()!=0.0))) 153 } << 116 { 154 else if(tag == "rotation") << 117 G4Transform3D firsttransform(GetRotationMatrix(firstrotation), 155 { << 118 firstposition); 156 VectorRead(child, rotation); << 119 firstSolid = new G4DisplacedSolid(GenerateName("displaced_"+first), 157 } << 120 firstSolid, firsttransform); 158 else if(tag == "positionref") << 121 } 159 { << 122 160 position = GetPosition(GenerateName(RefR << 123 if (op==UNION) 161 } << 124 { new G4UnionSolid(name,firstSolid,secondSolid,transform); } else 162 else if(tag == "rotationref") << 125 if (op==SUBTRACTION) 163 { << 126 { new G4SubtractionSolid(name,firstSolid,secondSolid,transform); } else 164 rotation = GetRotation(GenerateName(RefR << 127 if (op==INTERSECTION) 165 } << 128 { new G4IntersectionSolid(name,firstSolid,secondSolid,transform); } 166 else if(tag == "firstposition") << 167 { << 168 VectorRead(child, firstposition); << 169 } << 170 else if(tag == "firstrotation") << 171 { << 172 VectorRead(child, firstrotation); << 173 } << 174 else if(tag == "firstpositionref") << 175 { << 176 firstposition = GetPosition(GenerateName << 177 } << 178 else if(tag == "firstrotationref") << 179 { << 180 firstrotation = GetRotation(GenerateName << 181 } << 182 else << 183 { << 184 G4String error_msg = "Unknown tag in boo << 185 G4Exception("G4GDMLReadSolids::BooleanRe << 186 FatalException, error_msg); << 187 } << 188 } << 189 << 190 G4VSolid* firstSolid = GetSolid(GenerateNam << 191 G4VSolid* secondSolid = GetSolid(GenerateNam << 192 << 193 G4Transform3D transform(GetRotationMatrix(ro << 194 << 195 if(((firstrotation.x() != 0.0) || (firstrota << 196 (firstrotation.z() != 0.0)) || << 197 ((firstposition.x() != 0.0) || (firstposi << 198 (firstposition.z() != 0.0))) << 199 { << 200 G4Transform3D firsttransform(GetRotationMa << 201 firstposition << 202 firstSolid = new G4DisplacedSolid(Generate << 203 firstSol << 204 } << 205 << 206 if(op == UNION) << 207 { << 208 new G4UnionSolid(name, firstSolid, secondS << 209 } << 210 else if(op == SUBTRACTION) << 211 { << 212 new G4SubtractionSolid(name, firstSolid, s << 213 } << 214 else if(op == INTERSECTION) << 215 { << 216 new G4IntersectionSolid(name, firstSolid, << 217 } << 218 } 129 } 219 130 220 // ------------------------------------------- << 221 void G4GDMLReadSolids::BoxRead(const xercesc:: 131 void G4GDMLReadSolids::BoxRead(const xercesc::DOMElement* const boxElement) 222 { 132 { 223 G4String name; << 133 G4String name; 224 G4double lunit = 1.0; << 134 G4double lunit = 1.0; 225 G4double x = 0.0; << 135 G4double aunit = 1.0; 226 G4double y = 0.0; << 136 G4double x = 0.0; 227 G4double z = 0.0; << 137 G4double y = 0.0; 228 << 138 G4double z = 0.0; 229 const xercesc::DOMNamedNodeMap* const attrib << 139 230 boxElement->getAttributes(); << 140 const xercesc::DOMNamedNodeMap* const attributes 231 XMLSize_t attributeCount = attributes->getLe << 141 = boxElement->getAttributes(); 232 << 142 XMLSize_t attributeCount = attributes->getLength(); 233 for(XMLSize_t attribute_index = 0; attribute << 143 234 ++attribute_index) << 144 for (XMLSize_t attribute_index=0; 235 { << 145 attribute_index<attributeCount; attribute_index++) 236 xercesc::DOMNode* attribute_node = attribu << 146 { 237 << 147 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 238 if(attribute_node->getNodeType() != xerces << 148 239 { << 149 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 240 continue; << 150 { continue; } 241 } << 151 242 << 152 const xercesc::DOMAttr* const attribute 243 const xercesc::DOMAttr* const attribute = << 153 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 244 dynamic_cast<xercesc::DOMAttr*>(attribut << 154 const G4String attName = Transcode(attribute->getName()); 245 if(attribute == nullptr) << 155 const G4String attValue = Transcode(attribute->getValue()); 246 { << 156 247 G4Exception("G4GDMLReadSolids::BoxRead() << 157 if (attName=="name") { name = GenerateName(attValue); } else 248 "No attribute found!"); << 158 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 249 return; << 159 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 250 } << 160 if (attName=="x") { x = eval.Evaluate(attValue); } else 251 const G4String attName = Transcode(attrib << 161 if (attName=="y") { y = eval.Evaluate(attValue); } else 252 const G4String attValue = Transcode(attrib << 162 if (attName=="z") { z = eval.Evaluate(attValue); } 253 << 163 } 254 if(attName == "name") << 164 255 { << 165 x *= 0.5*lunit; 256 name = GenerateName(attValue); << 166 y *= 0.5*lunit; 257 } << 167 z *= 0.5*lunit; 258 else if(attName == "lunit") << 259 { << 260 lunit = G4UnitDefinition::GetValueOf(att << 261 if(G4UnitDefinition::GetCategory(attValu << 262 { << 263 G4Exception("G4GDMLReadSolids::BoxRead << 264 FatalException, "Invalid u << 265 } << 266 } << 267 else if(attName == "x") << 268 { << 269 x = eval.Evaluate(attValue); << 270 } << 271 else if(attName == "y") << 272 { << 273 y = eval.Evaluate(attValue); << 274 } << 275 else if(attName == "z") << 276 { << 277 z = eval.Evaluate(attValue); << 278 } << 279 } << 280 << 281 x *= 0.5 * lunit; << 282 y *= 0.5 * lunit; << 283 z *= 0.5 * lunit; << 284 168 285 new G4Box(name, x, y, z); << 169 new G4Box(name,x,y,z); 286 } 170 } 287 171 288 // ------------------------------------------- << 289 void G4GDMLReadSolids::ConeRead(const xercesc: 172 void G4GDMLReadSolids::ConeRead(const xercesc::DOMElement* const coneElement) 290 { 173 { 291 G4String name; << 174 G4String name; 292 G4double lunit = 1.0; << 175 G4double lunit = 1.0; 293 G4double aunit = 1.0; << 176 G4double aunit = 1.0; 294 G4double rmin1 = 0.0; << 177 G4double rmin1 = 0.0; 295 G4double rmax1 = 0.0; << 178 G4double rmax1 = 0.0; 296 G4double rmin2 = 0.0; << 179 G4double rmin2 = 0.0; 297 G4double rmax2 = 0.0; << 180 G4double rmax2 = 0.0; 298 G4double z = 0.0; << 181 G4double z = 0.0; 299 G4double startphi = 0.0; << 182 G4double startphi = 0.0; 300 G4double deltaphi = 0.0; << 183 G4double deltaphi = 0.0; 301 << 184 302 const xercesc::DOMNamedNodeMap* const attrib << 185 const xercesc::DOMNamedNodeMap* const attributes 303 coneElement->getAttributes(); << 186 = coneElement->getAttributes(); 304 XMLSize_t attributeCount = attributes->getLe << 187 XMLSize_t attributeCount = attributes->getLength(); 305 << 188 306 for(XMLSize_t attribute_index = 0; attribute << 189 for (XMLSize_t attribute_index=0; 307 ++attribute_index) << 190 attribute_index<attributeCount; attribute_index++) 308 { << 191 { 309 xercesc::DOMNode* attribute_node = attribu << 192 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 310 << 193 311 if(attribute_node->getNodeType() != xerces << 194 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 312 { << 195 { continue; } 313 continue; << 196 314 } << 197 const xercesc::DOMAttr* const attribute 315 << 198 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 316 const xercesc::DOMAttr* const attribute = << 199 const G4String attName = Transcode(attribute->getName()); 317 dynamic_cast<xercesc::DOMAttr*>(attribut << 200 const G4String attValue = Transcode(attribute->getValue()); 318 if(attribute == nullptr) << 201 319 { << 202 if (attName=="name") { name = GenerateName(attValue); } else 320 G4Exception("G4GDMLReadSolids::ConeRead( << 203 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 321 "No attribute found!"); << 204 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 322 return; << 205 if (attName=="rmin1") { rmin1 = eval.Evaluate(attValue); } else 323 } << 206 if (attName=="rmax1") { rmax1 = eval.Evaluate(attValue); } else 324 const G4String attName = Transcode(attrib << 207 if (attName=="rmin2") { rmin2 = eval.Evaluate(attValue); } else 325 const G4String attValue = Transcode(attrib << 208 if (attName=="rmax2") { rmax2 = eval.Evaluate(attValue); } else 326 << 209 if (attName=="z") { z = eval.Evaluate(attValue); } else 327 if(attName == "name") << 210 if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else 328 { << 211 if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } 329 name = GenerateName(attValue); << 212 } 330 } << 213 331 else if(attName == "lunit") << 214 rmin1 *= lunit; 332 { << 215 rmax1 *= lunit; 333 lunit = G4UnitDefinition::GetValueOf(att << 216 rmin2 *= lunit; 334 if(G4UnitDefinition::GetCategory(attValu << 217 rmax2 *= lunit; 335 { << 218 z *= 0.5*lunit; 336 G4Exception("G4GDMLReadSolids::ConeRea << 219 startphi *= aunit; 337 FatalException, "Invalid u << 220 deltaphi *= aunit; 338 } << 221 339 } << 222 new G4Cons(name,rmin1,rmax1,rmin2,rmax2,z,startphi,deltaphi); 340 else if(attName == "aunit") << 223 } 341 { << 224 342 aunit = G4UnitDefinition::GetValueOf(att << 225 void G4GDMLReadSolids:: 343 if(G4UnitDefinition::GetCategory(attValu << 226 ElconeRead(const xercesc::DOMElement* const elconeElement) 344 { << 227 { 345 G4Exception("G4GDMLReadSolids::ConeRea << 228 G4String name; 346 FatalException, "Invalid u << 229 G4double lunit = 1.0; 347 } << 230 G4double dx = 0.0; 348 } << 231 G4double dy = 0.0; 349 else if(attName == "rmin1") << 232 G4double zmax = 0.0; 350 { << 233 G4double zcut = 0.0; 351 rmin1 = eval.Evaluate(attValue); << 234 352 } << 235 const xercesc::DOMNamedNodeMap* const attributes 353 else if(attName == "rmax1") << 236 = elconeElement->getAttributes(); 354 { << 237 XMLSize_t attributeCount = attributes->getLength(); 355 rmax1 = eval.Evaluate(attValue); << 238 356 } << 239 for (XMLSize_t attribute_index=0; 357 else if(attName == "rmin2") << 240 attribute_index<attributeCount; attribute_index++) 358 { << 241 { 359 rmin2 = eval.Evaluate(attValue); << 242 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 360 } << 243 361 else if(attName == "rmax2") << 244 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 362 { << 245 { continue; } 363 rmax2 = eval.Evaluate(attValue); << 246 364 } << 247 const xercesc::DOMAttr* const attribute 365 else if(attName == "z") << 248 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 366 { << 249 const G4String attName = Transcode(attribute->getName()); 367 z = eval.Evaluate(attValue); << 250 const G4String attValue = Transcode(attribute->getValue()); 368 } << 251 369 else if(attName == "startphi") << 252 if (attName=="name") { name = GenerateName(attValue); } else 370 { << 253 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 371 startphi = eval.Evaluate(attValue); << 254 if (attName=="dx") { dx = eval.Evaluate(attValue); } else 372 } << 255 if (attName=="dy") { dy = eval.Evaluate(attValue); } else 373 else if(attName == "deltaphi") << 256 if (attName=="zmax") { zmax = eval.Evaluate(attValue); } else 374 { << 257 if (attName=="zcut") { zcut = eval.Evaluate(attValue); } 375 deltaphi = eval.Evaluate(attValue); << 258 } 376 } << 259 377 } << 260 dx *= lunit; 378 << 261 dy *= lunit; 379 rmin1 *= lunit; << 262 zmax *= lunit; 380 rmax1 *= lunit; << 263 zcut *= lunit; 381 rmin2 *= lunit; << 264 382 rmax2 *= lunit; << 265 new G4EllipticalCone(name,dx,dy,zmax,zcut); 383 z *= 0.5 * lunit; << 266 } 384 startphi *= aunit; << 267 385 deltaphi *= aunit; << 268 void G4GDMLReadSolids:: 386 << 269 EllipsoidRead(const xercesc::DOMElement* const ellipsoidElement) 387 new G4Cons(name, rmin1, rmax1, rmin2, rmax2, << 270 { 388 } << 271 G4String name; 389 << 272 G4double lunit = 1.0; 390 // ------------------------------------------- << 273 G4double ax = 0.0; 391 void G4GDMLReadSolids::ElconeRead( << 274 G4double by = 0.0; 392 const xercesc::DOMElement* const elconeEleme << 275 G4double cz = 0.0; 393 { << 276 G4double zcut1 = 0.0; 394 G4String name; << 277 G4double zcut2 = 0.0; 395 G4double lunit = 1.0; << 278 396 G4double dx = 0.0; << 279 const xercesc::DOMNamedNodeMap* const attributes 397 G4double dy = 0.0; << 280 = ellipsoidElement->getAttributes(); 398 G4double zmax = 0.0; << 281 XMLSize_t attributeCount = attributes->getLength(); 399 G4double zcut = 0.0; << 282 400 << 283 for (XMLSize_t attribute_index=0; 401 const xercesc::DOMNamedNodeMap* const attrib << 284 attribute_index<attributeCount; attribute_index++) 402 elconeElement->getAttributes(); << 285 { 403 XMLSize_t attributeCount = attributes->getLe << 286 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 404 << 287 405 for(XMLSize_t attribute_index = 0; attribute << 288 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 406 ++attribute_index) << 289 { continue; } 407 { << 290 408 xercesc::DOMNode* attribute_node = attribu << 291 const xercesc::DOMAttr* const attribute 409 << 292 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 410 if(attribute_node->getNodeType() != xerces << 293 const G4String attName = Transcode(attribute->getName()); 411 { << 294 const G4String attValue = Transcode(attribute->getValue()); 412 continue; << 295 413 } << 296 if (attName=="name") { name = GenerateName(attValue); } else 414 << 297 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 415 const xercesc::DOMAttr* const attribute = << 298 if (attName=="ax") { ax = eval.Evaluate(attValue); } else 416 dynamic_cast<xercesc::DOMAttr*>(attribut << 299 if (attName=="by") { by = eval.Evaluate(attValue); } else 417 if(attribute == nullptr) << 300 if (attName=="cz") { cz = eval.Evaluate(attValue); } else 418 { << 301 if (attName=="zcut1") { zcut1 = eval.Evaluate(attValue); } else 419 G4Exception("G4GDMLReadSolids::ElconeRea << 302 if (attName=="zcut2") { zcut2 = eval.Evaluate(attValue); } 420 FatalException, "No attribut << 303 } 421 return; << 304 422 } << 305 ax *= lunit; 423 const G4String attName = Transcode(attrib << 306 by *= lunit; 424 const G4String attValue = Transcode(attrib << 307 cz *= lunit; 425 << 308 zcut1 *= lunit; 426 if(attName == "name") << 309 zcut2 *= lunit; 427 { << 310 428 name = GenerateName(attValue); << 311 new G4Ellipsoid(name,ax,by,cz,zcut1,zcut2); 429 } << 312 } 430 else if(attName == "lunit") << 313 431 { << 314 void G4GDMLReadSolids:: 432 lunit = G4UnitDefinition::GetValueOf(att << 315 EltubeRead(const xercesc::DOMElement* const eltubeElement) 433 if(G4UnitDefinition::GetCategory(attValu << 316 { 434 { << 317 G4String name; 435 G4Exception("G4GDMLReadSolids::ElconeR << 318 G4double lunit = 1.0; 436 FatalException, "Invalid u << 319 G4double dx = 0.0; 437 } << 320 G4double dy = 0.0; 438 } << 321 G4double dz = 0.0; 439 else if(attName == "dx") << 322 440 { << 323 const xercesc::DOMNamedNodeMap* const attributes 441 dx = eval.Evaluate(attValue); << 324 = eltubeElement->getAttributes(); 442 } << 325 XMLSize_t attributeCount = attributes->getLength(); 443 else if(attName == "dy") << 326 444 { << 327 for (XMLSize_t attribute_index=0; 445 dy = eval.Evaluate(attValue); << 328 attribute_index<attributeCount; attribute_index++) 446 } << 329 { 447 else if(attName == "zmax") << 330 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 448 { << 331 449 zmax = eval.Evaluate(attValue); << 332 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 450 } << 333 { continue; } 451 else if(attName == "zcut") << 334 452 { << 335 const xercesc::DOMAttr* const attribute 453 zcut = eval.Evaluate(attValue); << 336 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 454 } << 337 const G4String attName = Transcode(attribute->getName()); 455 } << 338 const G4String attValue = Transcode(attribute->getValue()); 456 << 339 457 zmax *= lunit; << 340 if (attName=="name") { name = GenerateName(attValue); } else 458 zcut *= lunit; << 341 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 459 << 342 if (attName=="dx") { dx = eval.Evaluate(attValue); } else 460 new G4EllipticalCone(name, dx, dy, zmax, zcu << 343 if (attName=="dy") { dy = eval.Evaluate(attValue); } else 461 } << 344 if (attName=="dz") { dz = eval.Evaluate(attValue); } 462 << 345 } 463 // ------------------------------------------- << 346 464 void G4GDMLReadSolids::EllipsoidRead( << 347 dx *= lunit; 465 const xercesc::DOMElement* const ellipsoidEl << 348 dy *= lunit; 466 { << 349 dz *= lunit; 467 G4String name; << 468 G4double lunit = 1.0; << 469 G4double ax = 0.0; << 470 G4double by = 0.0; << 471 G4double cz = 0.0; << 472 G4double zcut1 = 0.0; << 473 G4double zcut2 = 0.0; << 474 << 475 const xercesc::DOMNamedNodeMap* const attrib << 476 ellipsoidElement->getAttributes(); << 477 XMLSize_t attributeCount = attributes->getLe << 478 << 479 for(XMLSize_t attribute_index = 0; attribute << 480 ++attribute_index) << 481 { << 482 xercesc::DOMNode* attribute_node = attribu << 483 << 484 if(attribute_node->getNodeType() != xerces << 485 { << 486 continue; << 487 } << 488 << 489 const xercesc::DOMAttr* const attribute = << 490 dynamic_cast<xercesc::DOMAttr*>(attribut << 491 if(attribute == nullptr) << 492 { << 493 G4Exception("G4GDMLReadSolids::Ellipsoid << 494 FatalException, "No attribut << 495 return; << 496 } << 497 const G4String attName = Transcode(attrib << 498 const G4String attValue = Transcode(attrib << 499 << 500 if(attName == "name") << 501 { << 502 name = GenerateName(attValue); << 503 } << 504 else if(attName == "lunit") << 505 { << 506 lunit = G4UnitDefinition::GetValueOf(att << 507 if(G4UnitDefinition::GetCategory(attValu << 508 { << 509 G4Exception("G4GDMLReadSolids::Ellipso << 510 FatalException, "Invalid u << 511 } << 512 } << 513 else if(attName == "ax") << 514 { << 515 ax = eval.Evaluate(attValue); << 516 } << 517 else if(attName == "by") << 518 { << 519 by = eval.Evaluate(attValue); << 520 } << 521 else if(attName == "cz") << 522 { << 523 cz = eval.Evaluate(attValue); << 524 } << 525 else if(attName == "zcut1") << 526 { << 527 zcut1 = eval.Evaluate(attValue); << 528 } << 529 else if(attName == "zcut2") << 530 { << 531 zcut2 = eval.Evaluate(attValue); << 532 } << 533 } << 534 << 535 ax *= lunit; << 536 by *= lunit; << 537 cz *= lunit; << 538 zcut1 *= lunit; << 539 zcut2 *= lunit; << 540 << 541 new G4Ellipsoid(name, ax, by, cz, zcut1, zcu << 542 } << 543 << 544 // ------------------------------------------- << 545 void G4GDMLReadSolids::EltubeRead( << 546 const xercesc::DOMElement* const eltubeEleme << 547 { << 548 G4String name; << 549 G4double lunit = 1.0; << 550 G4double dx = 0.0; << 551 G4double dy = 0.0; << 552 G4double dz = 0.0; << 553 << 554 const xercesc::DOMNamedNodeMap* const attrib << 555 eltubeElement->getAttributes(); << 556 XMLSize_t attributeCount = attributes->getLe << 557 << 558 for(XMLSize_t attribute_index = 0; attribute << 559 ++attribute_index) << 560 { << 561 xercesc::DOMNode* attribute_node = attribu << 562 << 563 if(attribute_node->getNodeType() != xerces << 564 { << 565 continue; << 566 } << 567 << 568 const xercesc::DOMAttr* const attribute = << 569 dynamic_cast<xercesc::DOMAttr*>(attribut << 570 if(attribute == nullptr) << 571 { << 572 G4Exception("G4GDMLReadSolids::EltubeRea << 573 FatalException, "No attribut << 574 return; << 575 } << 576 const G4String attName = Transcode(attrib << 577 const G4String attValue = Transcode(attrib << 578 << 579 if(attName == "name") << 580 { << 581 name = GenerateName(attValue); << 582 } << 583 else if(attName == "lunit") << 584 { << 585 lunit = G4UnitDefinition::GetValueOf(att << 586 if(G4UnitDefinition::GetCategory(attValu << 587 { << 588 G4Exception("G4GDMLReadSolids::EltubeR << 589 FatalException, "Invalid u << 590 } << 591 } << 592 else if(attName == "dx") << 593 { << 594 dx = eval.Evaluate(attValue); << 595 } << 596 else if(attName == "dy") << 597 { << 598 dy = eval.Evaluate(attValue); << 599 } << 600 else if(attName == "dz") << 601 { << 602 dz = eval.Evaluate(attValue); << 603 } << 604 } << 605 << 606 dx *= lunit; << 607 dy *= lunit; << 608 dz *= lunit; << 609 350 610 new G4EllipticalTube(name, dx, dy, dz); << 351 new G4EllipticalTube(name,dx,dy,dz); 611 } 352 } 612 353 613 // ------------------------------------------- << 614 void G4GDMLReadSolids::XtruRead(const xercesc: 354 void G4GDMLReadSolids::XtruRead(const xercesc::DOMElement* const xtruElement) 615 { 355 { 616 G4String name; << 356 G4String name; 617 G4double lunit = 1.0; << 357 G4double lunit = 1.0; 618 358 619 const xercesc::DOMNamedNodeMap* const attrib << 359 const xercesc::DOMNamedNodeMap* const attributes 620 xtruElement->getAttributes(); << 360 = xtruElement->getAttributes(); 621 XMLSize_t attributeCount = attributes->getLe << 361 XMLSize_t attributeCount = attributes->getLength(); 622 << 362 623 for(XMLSize_t attribute_index = 0; attribute << 363 for (XMLSize_t attribute_index=0; 624 ++attribute_index) << 364 attribute_index<attributeCount; attribute_index++) 625 { << 365 { 626 xercesc::DOMNode* attribute_node = attribu << 366 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 627 << 367 628 if(attribute_node->getNodeType() != xerces << 368 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 629 { << 369 { continue; } 630 continue; << 370 631 } << 371 const xercesc::DOMAttr* const attribute 632 << 372 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 633 const xercesc::DOMAttr* const attribute = << 373 const G4String attName = Transcode(attribute->getName()); 634 dynamic_cast<xercesc::DOMAttr*>(attribut << 374 const G4String attValue = Transcode(attribute->getValue()); 635 if(attribute == nullptr) << 375 636 { << 376 if (attName=="name") { name = GenerateName(attValue); } else 637 G4Exception("G4GDMLReadSolids::XtruRead( << 377 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } 638 "No attribute found!"); << 378 } 639 return; << 379 640 } << 380 std::vector<G4TwoVector> twoDimVertexList; 641 const G4String attName = Transcode(attrib << 381 std::vector<G4ExtrudedSolid::ZSection> sectionList; 642 const G4String attValue = Transcode(attrib << 382 643 << 383 for (xercesc::DOMNode* iter = xtruElement->getFirstChild(); 644 if(attName == "name") << 384 iter != 0; iter = iter->getNextSibling()) 645 { << 385 { 646 name = GenerateName(attValue); << 386 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } 647 } << 387 648 else if(attName == "lunit") << 388 const xercesc::DOMElement* const child 649 { << 389 = dynamic_cast<xercesc::DOMElement*>(iter); 650 lunit = G4UnitDefinition::GetValueOf(att << 390 const G4String tag = Transcode(child->getTagName()); 651 if(G4UnitDefinition::GetCategory(attValu << 391 652 { << 392 if (tag=="twoDimVertex") 653 G4Exception("G4GDMLReadSolids::XtruRea << 393 { twoDimVertexList.push_back(TwoDimVertexRead(child,lunit)); } else 654 FatalException, "Invalid u << 394 if (tag=="section") 655 } << 395 { sectionList.push_back(SectionRead(child,lunit)); } 656 } << 396 } 657 } << 658 397 659 std::vector<G4TwoVector> twoDimVertexList; << 398 new G4ExtrudedSolid(name,twoDimVertexList,sectionList); 660 std::vector<G4ExtrudedSolid::ZSection> secti << 661 << 662 for(xercesc::DOMNode* iter = xtruElement->ge << 663 iter = iter->getNextSi << 664 { << 665 if(iter->getNodeType() != xercesc::DOMNode << 666 { << 667 continue; << 668 } << 669 << 670 const xercesc::DOMElement* const child = << 671 dynamic_cast<xercesc::DOMElement*>(iter) << 672 if(child == nullptr) << 673 { << 674 G4Exception("G4GDMLReadSolids::XtruRead( << 675 "No child found!"); << 676 return; << 677 } << 678 const G4String tag = Transcode(child->getT << 679 << 680 if(tag == "twoDimVertex") << 681 { << 682 twoDimVertexList.push_back(TwoDimVertexR << 683 } << 684 else if(tag == "section") << 685 { << 686 sectionList.push_back(SectionRead(child, << 687 } << 688 } << 689 << 690 new G4ExtrudedSolid(name, twoDimVertexList, << 691 } 399 } 692 400 693 // ------------------------------------------- << 694 void G4GDMLReadSolids::HypeRead(const xercesc: 401 void G4GDMLReadSolids::HypeRead(const xercesc::DOMElement* const hypeElement) 695 { 402 { 696 G4String name; << 403 G4String name; 697 G4double lunit = 1.0; << 404 G4double lunit = 1.0; 698 G4double aunit = 1.0; << 405 G4double aunit = 1.0; 699 G4double rmin = 0.0; << 406 G4double rmin = 0.0; 700 G4double rmax = 0.0; << 407 G4double rmax = 0.0; 701 G4double inst = 0.0; << 408 G4double inst = 0.0; 702 G4double outst = 0.0; << 409 G4double outst = 0.0; 703 G4double z = 0.0; << 410 G4double z = 0.0; 704 << 411 705 const xercesc::DOMNamedNodeMap* const attrib << 412 const xercesc::DOMNamedNodeMap* const attributes 706 hypeElement->getAttributes(); << 413 = hypeElement->getAttributes(); 707 XMLSize_t attributeCount = attributes->getLe << 414 XMLSize_t attributeCount = attributes->getLength(); 708 << 415 709 for(XMLSize_t attribute_index = 0; attribute << 416 for (XMLSize_t attribute_index=0; 710 ++attribute_index) << 417 attribute_index<attributeCount; attribute_index++) 711 { << 418 { 712 xercesc::DOMNode* attribute_node = attribu << 419 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 713 << 420 714 if(attribute_node->getNodeType() != xerces << 421 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 715 { << 422 { continue; } 716 continue; << 423 717 } << 424 const xercesc::DOMAttr* const attribute 718 << 425 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 719 const xercesc::DOMAttr* const attribute = << 426 const G4String attName = Transcode(attribute->getName()); 720 dynamic_cast<xercesc::DOMAttr*>(attribut << 427 const G4String attValue = Transcode(attribute->getValue()); 721 if(attribute == nullptr) << 428 722 { << 429 if (attName=="name") { name = GenerateName(attValue); } else 723 G4Exception("G4GDMLReadSolids::HypeRead( << 430 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 724 "No attribute found!"); << 431 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 725 return; << 432 if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else 726 } << 433 if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else 727 const G4String attName = Transcode(attrib << 434 if (attName=="inst") { inst = eval.Evaluate(attValue); } else 728 const G4String attValue = Transcode(attrib << 435 if (attName=="outst") { outst = eval.Evaluate(attValue); } else 729 << 436 if (attName=="z") { z = eval.Evaluate(attValue); } 730 if(attName == "name") << 437 } 731 { << 438 732 name = GenerateName(attValue); << 439 rmin *= lunit; 733 } << 440 rmax *= lunit; 734 else if(attName == "lunit") << 441 inst *= aunit; 735 { << 442 outst *= aunit; 736 lunit = G4UnitDefinition::GetValueOf(att << 443 z *= 0.5*lunit; 737 if(G4UnitDefinition::GetCategory(attValu << 738 { << 739 G4Exception("G4GDMLReadSolids::HypeRea << 740 FatalException, "Invalid u << 741 } << 742 } << 743 else if(attName == "aunit") << 744 { << 745 aunit = G4UnitDefinition::GetValueOf(att << 746 if(G4UnitDefinition::GetCategory(attValu << 747 { << 748 G4Exception("G4GDMLReadSolids::HypeRea << 749 FatalException, "Invalid u << 750 } << 751 } << 752 else if(attName == "rmin") << 753 { << 754 rmin = eval.Evaluate(attValue); << 755 } << 756 else if(attName == "rmax") << 757 { << 758 rmax = eval.Evaluate(attValue); << 759 } << 760 else if(attName == "inst") << 761 { << 762 inst = eval.Evaluate(attValue); << 763 } << 764 else if(attName == "outst") << 765 { << 766 outst = eval.Evaluate(attValue); << 767 } << 768 else if(attName == "z") << 769 { << 770 z = eval.Evaluate(attValue); << 771 } << 772 } << 773 << 774 rmin *= lunit; << 775 rmax *= lunit; << 776 inst *= aunit; << 777 outst *= aunit; << 778 z *= 0.5 * lunit; << 779 << 780 new G4Hype(name, rmin, rmax, inst, outst, z) << 781 } << 782 444 783 // ------------------------------------------- << 445 new G4Hype(name,rmin,rmax,inst,outst,z); 784 void G4GDMLReadSolids::MultiUnionNodeRead( << 785 const xercesc::DOMElement* const unionNodeEl << 786 G4MultiUnion* const multiUnionSolid) << 787 { << 788 G4String name; << 789 G4String solid; << 790 G4ThreeVector position(0.0, 0.0, 0.0); << 791 G4ThreeVector rotation(0.0, 0.0, 0.0); << 792 << 793 const xercesc::DOMNamedNodeMap* const attrib << 794 unionNodeElement->getAttributes(); << 795 XMLSize_t attributeCount = attributes->getLe << 796 << 797 for(XMLSize_t attribute_index = 0; attribute << 798 ++attribute_index) << 799 { << 800 xercesc::DOMNode* attribute_node = attribu << 801 << 802 if(attribute_node->getNodeType() != xerces << 803 { << 804 continue; << 805 } << 806 << 807 const xercesc::DOMAttr* const attribute = << 808 dynamic_cast<xercesc::DOMAttr*>(attribut << 809 if(attribute == nullptr) << 810 { << 811 G4Exception("G4GDMLReadSolids::MultiUnio << 812 FatalException, "No attribut << 813 return; << 814 } << 815 const G4String attName = Transcode(attrib << 816 const G4String attValue = Transcode(attrib << 817 << 818 if(attName == "name") << 819 { << 820 name = GenerateName(attValue); << 821 } << 822 } << 823 << 824 for(xercesc::DOMNode* iter = unionNodeElemen << 825 iter != nullptr; iter << 826 { << 827 if(iter->getNodeType() != xercesc::DOMNode << 828 { << 829 continue; << 830 } << 831 << 832 const xercesc::DOMElement* const child = << 833 dynamic_cast<xercesc::DOMElement*>(iter) << 834 if(child == nullptr) << 835 { << 836 G4Exception("G4GDMLReadSolids::MultiUnio << 837 FatalException, "No child fo << 838 return; << 839 } << 840 const G4String tag = Transcode(child->getT << 841 << 842 if(tag == "position") << 843 { << 844 VectorRead(child, position); << 845 } << 846 else if(tag == "rotation") << 847 { << 848 VectorRead(child, rotation); << 849 } << 850 else if(tag == "positionref") << 851 { << 852 position = GetPosition(GenerateName(RefR << 853 } << 854 else if(tag == "rotationref") << 855 { << 856 rotation = GetRotation(GenerateName(RefR << 857 } << 858 else if(tag == "solid") << 859 { << 860 solid = RefRead(child); << 861 } << 862 else << 863 { << 864 G4String error_msg = "Unknown tag in Mul << 865 G4Exception("G4GDMLReadSolids::MultiUnio << 866 FatalException, error_msg); << 867 } << 868 } << 869 G4VSolid* solidNode = GetSolid(GenerateName( << 870 G4Transform3D transform(GetRotationMatrix(ro << 871 multiUnionSolid->AddNode(*solidNode, transfo << 872 } 446 } 873 447 874 // ------------------------------------------- << 875 void G4GDMLReadSolids::MultiUnionRead( << 876 const xercesc::DOMElement* const unionElemen << 877 { << 878 G4String name; << 879 << 880 const xercesc::DOMNamedNodeMap* const attrib << 881 unionElement->getAttributes(); << 882 XMLSize_t attributeCount = attributes->getLe << 883 << 884 for(XMLSize_t attribute_index = 0; attribute << 885 ++attribute_index) << 886 { << 887 xercesc::DOMNode* attribute_node = attribu << 888 << 889 if(attribute_node->getNodeType() != xerces << 890 { << 891 continue; << 892 } << 893 << 894 const xercesc::DOMAttr* const attribute = << 895 dynamic_cast<xercesc::DOMAttr*>(attribut << 896 if(attribute == nullptr) << 897 { << 898 G4Exception("G4GDMLReadSolids::MultiUnio << 899 FatalException, "No attribut << 900 return; << 901 } << 902 const G4String attName = Transcode(attrib << 903 const G4String attValue = Transcode(attrib << 904 << 905 if(attName == "name") << 906 { << 907 name = GenerateName(attValue); << 908 } << 909 } << 910 << 911 G4MultiUnion* multiUnion = new G4MultiUnion( << 912 << 913 for(xercesc::DOMNode* iter = unionElement->g << 914 iter = iter->getNextSi << 915 { << 916 if(iter->getNodeType() != xercesc::DOMNode << 917 { << 918 continue; << 919 } << 920 << 921 const xercesc::DOMElement* const child = << 922 dynamic_cast<xercesc::DOMElement*>(iter) << 923 if(child == nullptr) << 924 { << 925 G4Exception("G4GDMLReadSolids::MultiUnio << 926 FatalException, "No child fo << 927 return; << 928 } << 929 const G4String tag = Transcode(child->getT << 930 << 931 if(tag == "multiUnionNode") << 932 { << 933 MultiUnionNodeRead(child, multiUnion); << 934 } << 935 else << 936 { << 937 G4String error_msg = "Unknown tag in Mul << 938 G4Exception("G4GDMLReadSolids::MultiUnio << 939 FatalException, error_msg); << 940 } << 941 } << 942 multiUnion->Voxelize(); << 943 } << 944 << 945 // ------------------------------------------- << 946 void G4GDMLReadSolids::OrbRead(const xercesc:: 448 void G4GDMLReadSolids::OrbRead(const xercesc::DOMElement* const orbElement) 947 { 449 { 948 G4String name; << 450 G4String name; 949 G4double lunit = 1.0; << 451 G4double lunit = 1.0; 950 G4double r = 0.0; << 452 G4double r = 0.0; 951 << 453 952 const xercesc::DOMNamedNodeMap* const attrib << 454 const xercesc::DOMNamedNodeMap* const attributes 953 orbElement->getAttributes(); << 455 = orbElement->getAttributes(); 954 XMLSize_t attributeCount = attributes->getLe << 456 XMLSize_t attributeCount = attributes->getLength(); 955 << 457 956 for(XMLSize_t attribute_index = 0; attribute << 458 for (XMLSize_t attribute_index=0; 957 ++attribute_index) << 459 attribute_index<attributeCount; attribute_index++) 958 { << 460 { 959 xercesc::DOMNode* attribute_node = attribu << 461 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 960 << 462 961 if(attribute_node->getNodeType() != xerces << 463 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 962 { << 464 { continue; } 963 continue; << 465 964 } << 466 const xercesc::DOMAttr* const attribute 965 << 467 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 966 const xercesc::DOMAttr* const attribute = << 468 const G4String attName = Transcode(attribute->getName()); 967 dynamic_cast<xercesc::DOMAttr*>(attribut << 469 const G4String attValue = Transcode(attribute->getValue()); 968 if(attribute == nullptr) << 470 969 { << 471 if (attName=="name") { name = GenerateName(attValue); } else 970 G4Exception("G4GDMLReadSolids::OrbRead() << 472 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 971 "No attribute found!"); << 473 if (attName=="r") { r = eval.Evaluate(attValue); } 972 return; << 474 } 973 } << 974 const G4String attName = Transcode(attrib << 975 const G4String attValue = Transcode(attrib << 976 << 977 if(attName == "name") << 978 { << 979 name = GenerateName(attValue); << 980 } << 981 else if(attName == "lunit") << 982 { << 983 lunit = G4UnitDefinition::GetValueOf(att << 984 if(G4UnitDefinition::GetCategory(attValu << 985 { << 986 G4Exception("G4GDMLReadSolids::OrbRead << 987 FatalException, "Invalid u << 988 } << 989 } << 990 else if(attName == "r") << 991 { << 992 r = eval.Evaluate(attValue); << 993 } << 994 } << 995 475 996 r *= lunit; << 476 r *= lunit; 997 477 998 new G4Orb(name, r); << 478 new G4Orb(name,r); 999 } 479 } 1000 480 1001 // ------------------------------------------ << 1002 void G4GDMLReadSolids::ParaRead(const xercesc 481 void G4GDMLReadSolids::ParaRead(const xercesc::DOMElement* const paraElement) 1003 { 482 { 1004 G4String name; << 483 G4String name; 1005 G4double lunit = 1.0; << 484 G4double lunit = 1.0; 1006 G4double aunit = 1.0; << 485 G4double aunit = 1.0; 1007 G4double x = 0.0; << 486 G4double x = 0.0; 1008 G4double y = 0.0; << 487 G4double y = 0.0; 1009 G4double z = 0.0; << 488 G4double z = 0.0; 1010 G4double alpha = 0.0; << 489 G4double alpha = 0.0; 1011 G4double theta = 0.0; << 490 G4double theta = 0.0; 1012 G4double phi = 0.0; << 491 G4double phi = 0.0; 1013 << 492 1014 const xercesc::DOMNamedNodeMap* const attri << 493 const xercesc::DOMNamedNodeMap* const attributes 1015 paraElement->getAttributes(); << 494 = paraElement->getAttributes(); 1016 XMLSize_t attributeCount = attributes->getL << 495 XMLSize_t attributeCount = attributes->getLength(); 1017 << 496 1018 for(XMLSize_t attribute_index = 0; attribut << 497 for (XMLSize_t attribute_index=0; 1019 ++attribute_index) << 498 attribute_index<attributeCount; attribute_index++) 1020 { << 499 { 1021 xercesc::DOMNode* attribute_node = attrib << 500 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1022 << 501 1023 if(attribute_node->getNodeType() != xerce << 502 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1024 { << 503 { continue; } 1025 continue; << 504 1026 } << 505 const xercesc::DOMAttr* const attribute 1027 << 506 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1028 const xercesc::DOMAttr* const attribute = << 507 const G4String attName = Transcode(attribute->getName()); 1029 dynamic_cast<xercesc::DOMAttr*>(attribu << 508 const G4String attValue = Transcode(attribute->getValue()); 1030 if(attribute == nullptr) << 509 1031 { << 510 if (attName=="name") { name = GenerateName(attValue); } else 1032 G4Exception("G4GDMLReadSolids::ParaRead << 511 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 1033 "No attribute found!"); << 512 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 1034 return; << 513 if (attName=="x") { x = eval.Evaluate(attValue); } else 1035 } << 514 if (attName=="y") { y = eval.Evaluate(attValue); } else 1036 const G4String attName = Transcode(attri << 515 if (attName=="z") { z = eval.Evaluate(attValue); } else 1037 const G4String attValue = Transcode(attri << 516 if (attName=="alpha") { alpha = eval.Evaluate(attValue); } else 1038 << 517 if (attName=="theta") { theta = eval.Evaluate(attValue); } else 1039 if(attName == "name") << 518 if (attName=="phi") { phi = eval.Evaluate(attValue); } 1040 { << 519 } 1041 name = GenerateName(attValue); << 520 1042 } << 521 x *= 0.5*lunit; 1043 else if(attName == "lunit") << 522 y *= 0.5*lunit; 1044 { << 523 z *= 0.5*lunit; 1045 lunit = G4UnitDefinition::GetValueOf(at << 524 alpha *= aunit; 1046 if(G4UnitDefinition::GetCategory(attVal << 525 theta *= aunit; 1047 { << 526 phi *= aunit; 1048 G4Exception("G4GDMLReadSolids::ParaRe << 527 1049 FatalException, "Invalid << 528 new G4Para(name,x,y,z,alpha,theta,phi); 1050 } << 529 } 1051 } << 530 1052 else if(attName == "aunit") << 531 void G4GDMLReadSolids:: 1053 { << 532 ParaboloidRead(const xercesc::DOMElement* const paraElement) 1054 aunit = G4UnitDefinition::GetValueOf(at << 533 { 1055 if(G4UnitDefinition::GetCategory(attVal << 534 G4String name; 1056 { << 535 G4double lunit = 1.0; 1057 G4Exception("G4GDMLReadSolids::ParaRe << 536 G4double aunit = 1.0; 1058 FatalException, "Invalid << 537 G4double rlo = 0.0; 1059 } << 538 G4double rhi = 0.0; 1060 } << 539 G4double dz = 0.0; 1061 else if(attName == "x") << 540 1062 { << 541 const xercesc::DOMNamedNodeMap* const attributes 1063 x = eval.Evaluate(attValue); << 542 = paraElement->getAttributes(); 1064 } << 543 XMLSize_t attributeCount = attributes->getLength(); 1065 else if(attName == "y") << 544 1066 { << 545 for (XMLSize_t attribute_index=0; 1067 y = eval.Evaluate(attValue); << 546 attribute_index<attributeCount; attribute_index++) 1068 } << 547 { 1069 else if(attName == "z") << 548 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1070 { << 549 1071 z = eval.Evaluate(attValue); << 550 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1072 } << 551 { continue; } 1073 else if(attName == "alpha") << 552 1074 { << 553 const xercesc::DOMAttr* const attribute 1075 alpha = eval.Evaluate(attValue); << 554 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1076 } << 555 const G4String attName = Transcode(attribute->getName()); 1077 else if(attName == "theta") << 556 const G4String attValue = Transcode(attribute->getValue()); 1078 { << 557 1079 theta = eval.Evaluate(attValue); << 558 if (attName=="name") { name = GenerateName(attValue); } else 1080 } << 559 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 1081 else if(attName == "phi") << 560 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 1082 { << 561 if (attName=="rlo") { rlo = eval.Evaluate(attValue); } else 1083 phi = eval.Evaluate(attValue); << 562 if (attName=="rhi") { rhi = eval.Evaluate(attValue); } else 1084 } << 563 if (attName=="dz") { dz = eval.Evaluate(attValue); } 1085 } << 564 } 1086 << 565 1087 x *= 0.5 * lunit; << 566 rlo *= 1.*lunit; 1088 y *= 0.5 * lunit; << 567 rhi *= 1.*lunit; 1089 z *= 0.5 * lunit; << 568 dz *= 1.*lunit; 1090 alpha *= aunit; << 569 1091 theta *= aunit; << 570 new G4Paraboloid(name,dz,rlo,rhi); 1092 phi *= aunit; << 571 } 1093 << 572 1094 new G4Para(name, x, y, z, alpha, theta, phi << 573 void G4GDMLReadSolids:: 1095 } << 574 PolyconeRead(const xercesc::DOMElement* const polyconeElement) 1096 << 575 { 1097 // ------------------------------------------ << 576 G4String name; 1098 void G4GDMLReadSolids::ParaboloidRead( << 577 G4double lunit = 1.0; 1099 const xercesc::DOMElement* const paraElemen << 578 G4double aunit = 1.0; 1100 { << 579 G4double startphi = 0.0; 1101 G4String name; << 580 G4double deltaphi = 0.0; 1102 G4double lunit = 1.0; << 581 1103 G4double rlo = 0.0; << 582 const xercesc::DOMNamedNodeMap* const attributes 1104 G4double rhi = 0.0; << 583 = polyconeElement->getAttributes(); 1105 G4double dz = 0.0; << 584 XMLSize_t attributeCount = attributes->getLength(); 1106 << 585 1107 const xercesc::DOMNamedNodeMap* const attri << 586 for (XMLSize_t attribute_index=0; 1108 paraElement->getAttributes(); << 587 attribute_index<attributeCount; attribute_index++) 1109 XMLSize_t attributeCount = attributes->getL << 588 { 1110 << 589 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1111 for(XMLSize_t attribute_index = 0; attribut << 590 1112 ++attribute_index) << 591 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1113 { << 592 { continue; } 1114 xercesc::DOMNode* attribute_node = attrib << 593 1115 << 594 const xercesc::DOMAttr* const attribute 1116 if(attribute_node->getNodeType() != xerce << 595 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1117 { << 596 const G4String attName = Transcode(attribute->getName()); 1118 continue; << 597 const G4String attValue = Transcode(attribute->getValue()); 1119 } << 598 1120 << 599 if (attName=="name") { name = GenerateName(attValue); } else 1121 const xercesc::DOMAttr* const attribute = << 600 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 1122 dynamic_cast<xercesc::DOMAttr*>(attribu << 601 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 1123 if(attribute == nullptr) << 602 if (attName=="startphi") { startphi = eval.Evaluate(attValue); }else 1124 { << 603 if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } 1125 G4Exception("G4GDMLReadSolids::Parabolo << 604 } 1126 FatalException, "No attribu << 605 1127 return; << 606 startphi *= aunit; 1128 } << 607 deltaphi *= aunit; 1129 const G4String attName = Transcode(attri << 608 1130 const G4String attValue = Transcode(attri << 609 std::vector<zplaneType> zplaneList; 1131 << 610 1132 if(attName == "name") << 611 for (xercesc::DOMNode* iter = polyconeElement->getFirstChild(); 1133 { << 612 iter != 0; iter = iter->getNextSibling()) 1134 name = GenerateName(attValue); << 613 { 1135 } << 614 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } 1136 else if(attName == "lunit") << 615 1137 { << 616 const xercesc::DOMElement* const child 1138 lunit = G4UnitDefinition::GetValueOf(at << 617 = dynamic_cast<xercesc::DOMElement*>(iter); 1139 if(G4UnitDefinition::GetCategory(attVal << 618 const G4String tag = Transcode(child->getTagName()); 1140 { << 619 1141 G4Exception("G4GDMLReadSolids::Parabo << 620 if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); } 1142 FatalException, "Invalid << 621 } 1143 } << 622 1144 } << 623 G4int numZPlanes = zplaneList.size(); 1145 else if(attName == "rlo") << 624 1146 { << 625 G4double* rmin_array = new G4double[numZPlanes]; 1147 rlo = eval.Evaluate(attValue); << 626 G4double* rmax_array = new G4double[numZPlanes]; 1148 } << 627 G4double* z_array = new G4double[numZPlanes]; 1149 else if(attName == "rhi") << 628 1150 { << 629 for (G4int i=0; i<numZPlanes; i++) 1151 rhi = eval.Evaluate(attValue); << 630 { 1152 } << 631 rmin_array[i] = zplaneList[i].rmin*lunit; 1153 else if(attName == "dz") << 632 rmax_array[i] = zplaneList[i].rmax*lunit; 1154 { << 633 z_array[i] = zplaneList[i].z*lunit; 1155 dz = eval.Evaluate(attValue); << 634 } 1156 } << 635 1157 } << 636 new G4Polycone(name,startphi,deltaphi,numZPlanes, 1158 << 637 z_array,rmin_array,rmax_array); 1159 rlo *= 1. * lunit; << 638 } 1160 rhi *= 1. * lunit; << 639 1161 dz *= 1. * lunit; << 640 void G4GDMLReadSolids:: 1162 << 641 PolyhedraRead(const xercesc::DOMElement* const polyhedraElement) 1163 new G4Paraboloid(name, dz, rlo, rhi); << 642 { 1164 } << 643 G4String name; 1165 << 644 G4double lunit = 1.0; 1166 // ------------------------------------------ << 645 G4double aunit = 1.0; 1167 void G4GDMLReadSolids::PolyconeRead( << 646 G4double startphi = 0.0; 1168 const xercesc::DOMElement* const polyconeEl << 647 G4double deltaphi = 0.0; 1169 { << 648 G4int numsides = 0; 1170 G4String name; << 649 1171 G4double lunit = 1.0; << 650 const xercesc::DOMNamedNodeMap* const attributes 1172 G4double aunit = 1.0; << 651 = polyhedraElement->getAttributes(); 1173 G4double startphi = 0.0; << 652 XMLSize_t attributeCount = attributes->getLength(); 1174 G4double deltaphi = 0.0; << 653 1175 << 654 for (XMLSize_t attribute_index=0; 1176 const xercesc::DOMNamedNodeMap* const attri << 655 attribute_index<attributeCount; attribute_index++) 1177 polyconeElement->getAttributes(); << 656 { 1178 XMLSize_t attributeCount = attributes->getL << 657 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1179 << 658 1180 for(XMLSize_t attribute_index = 0; attribut << 659 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1181 ++attribute_index) << 660 { continue; } 1182 { << 661 1183 xercesc::DOMNode* attribute_node = attrib << 662 const xercesc::DOMAttr* const attribute 1184 << 663 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1185 if(attribute_node->getNodeType() != xerce << 664 const G4String attName = Transcode(attribute->getName()); 1186 { << 665 const G4String attValue = Transcode(attribute->getValue()); 1187 continue; << 666 1188 } << 667 if (attName=="name") { name = GenerateName(attValue); } else 1189 << 668 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 1190 const xercesc::DOMAttr* const attribute = << 669 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 1191 dynamic_cast<xercesc::DOMAttr*>(attribu << 670 if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else 1192 if(attribute == nullptr) << 671 if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else 1193 { << 672 if (attName=="numsides") { numsides = eval.EvaluateInteger(attValue); } 1194 G4Exception("G4GDMLReadSolids::Polycone << 673 } 1195 FatalException, "No attribu << 674 1196 return; << 675 startphi *= aunit; 1197 } << 676 deltaphi *= aunit; 1198 const G4String attName = Transcode(attri << 677 1199 const G4String attValue = Transcode(attri << 678 std::vector<zplaneType> zplaneList; 1200 << 679 1201 if(attName == "name") << 680 for (xercesc::DOMNode* iter = polyhedraElement->getFirstChild(); 1202 { << 681 iter != 0; iter = iter->getNextSibling()) 1203 name = GenerateName(attValue); << 682 { 1204 } << 683 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } 1205 else if(attName == "lunit") << 684 1206 { << 685 const xercesc::DOMElement* const child 1207 lunit = G4UnitDefinition::GetValueOf(at << 686 = dynamic_cast<xercesc::DOMElement*>(iter); 1208 if(G4UnitDefinition::GetCategory(attVal << 687 const G4String tag = Transcode(child->getTagName()); 1209 { << 688 1210 G4Exception("G4GDMLReadSolids::Polyco << 689 if (tag=="zplane") { zplaneList.push_back(ZplaneRead(child)); } 1211 FatalException, "Invalid << 690 } 1212 } << 691 1213 } << 692 G4int numZPlanes = zplaneList.size(); 1214 else if(attName == "aunit") << 693 1215 { << 694 G4double* rmin_array = new G4double[numZPlanes]; 1216 aunit = G4UnitDefinition::GetValueOf(at << 695 G4double* rmax_array = new G4double[numZPlanes]; 1217 if(G4UnitDefinition::GetCategory(attVal << 696 G4double* z_array = new G4double[numZPlanes]; 1218 { << 697 1219 G4Exception("G4GDMLReadSolids::Polyco << 698 for (G4int i=0; i<numZPlanes; i++) 1220 FatalException, "Invalid << 699 { 1221 } << 700 rmin_array[i] = zplaneList[i].rmin*lunit; 1222 } << 701 rmax_array[i] = zplaneList[i].rmax*lunit; 1223 else if(attName == "startphi") << 702 z_array[i] = zplaneList[i].z*lunit; 1224 { << 703 } 1225 startphi = eval.Evaluate(attValue); << 704 1226 } << 705 new G4Polyhedra(name,startphi,deltaphi,numsides,numZPlanes, 1227 else if(attName == "deltaphi") << 706 z_array,rmin_array,rmax_array); 1228 { << 707 1229 deltaphi = eval.Evaluate(attValue); << 708 } 1230 } << 709 1231 } << 710 G4QuadrangularFacet* G4GDMLReadSolids:: 1232 << 711 QuadrangularRead(const xercesc::DOMElement* const quadrangularElement) 1233 startphi *= aunit; << 712 { 1234 deltaphi *= aunit; << 713 G4ThreeVector vertex1; 1235 << 714 G4ThreeVector vertex2; 1236 std::vector<zplaneType> zplaneList; << 715 G4ThreeVector vertex3; 1237 << 716 G4ThreeVector vertex4; 1238 for(xercesc::DOMNode* iter = polyconeElemen << 717 G4FacetVertexType type = ABSOLUTE; 1239 iter = iter->getNextS << 718 1240 { << 719 const xercesc::DOMNamedNodeMap* const attributes 1241 if(iter->getNodeType() != xercesc::DOMNod << 720 = quadrangularElement->getAttributes(); 1242 { << 721 XMLSize_t attributeCount = attributes->getLength(); 1243 continue; << 722 1244 } << 723 for (XMLSize_t attribute_index=0; 1245 << 724 attribute_index<attributeCount; attribute_index++) 1246 const xercesc::DOMElement* const child = << 725 { 1247 dynamic_cast<xercesc::DOMElement*>(iter << 726 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1248 if(child == nullptr) << 727 1249 { << 728 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1250 G4Exception("G4GDMLReadSolids::Polycone << 729 { continue; } 1251 FatalException, "No child f << 730 1252 return; << 731 const xercesc::DOMAttr* const attribute 1253 } << 732 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1254 const G4String tag = Transcode(child->get << 733 const G4String attName = Transcode(attribute->getName()); 1255 << 734 const G4String attValue = Transcode(attribute->getValue()); 1256 if(tag == "zplane") << 735 1257 { << 736 if (attName=="vertex1") 1258 zplaneList.push_back(ZplaneRead(child)) << 737 { vertex1 = GetPosition(GenerateName(attValue)); } else 1259 } << 738 if (attName=="vertex2") 1260 } << 739 { vertex2 = GetPosition(GenerateName(attValue)); } else 1261 << 740 if (attName=="vertex3") 1262 std::size_t numZPlanes = zplaneList.size(); << 741 { vertex3 = GetPosition(GenerateName(attValue)); } else 1263 << 742 if (attName=="vertex4") 1264 G4double* rmin_array = new G4double[numZPla << 743 { vertex4 = GetPosition(GenerateName(attValue)); } else 1265 G4double* rmax_array = new G4double[numZPla << 744 if (attName=="type") 1266 G4double* z_array = new G4double[numZPla << 745 { if (attValue=="RELATIVE") { type = RELATIVE; } } 1267 << 746 } 1268 for(std::size_t i = 0; i < numZPlanes; ++i) << 747 1269 { << 748 return new G4QuadrangularFacet(vertex1,vertex2,vertex3,vertex4,type); 1270 rmin_array[i] = zplaneList[i].rmin * luni << 749 } 1271 rmax_array[i] = zplaneList[i].rmax * luni << 750 1272 z_array[i] = zplaneList[i].z * lunit; << 751 void G4GDMLReadSolids:: 1273 } << 752 ReflectedSolidRead(const xercesc::DOMElement* const reflectedSolidElement) 1274 << 753 { 1275 new G4Polycone(name, startphi, deltaphi, (G << 754 G4String name; 1276 rmin_array, rmax_array); << 755 G4double lunit = 1.0; 1277 << 756 G4double aunit = 1.0; 1278 delete[] rmin_array; << 757 G4String solid; 1279 delete[] rmax_array; << 758 G4ThreeVector scale(1.0,1.0,1.0); 1280 delete[] z_array; << 759 G4ThreeVector rotation; 1281 } << 760 G4ThreeVector position; 1282 << 761 1283 // ------------------------------------------ << 762 const xercesc::DOMNamedNodeMap* const attributes 1284 void G4GDMLReadSolids::GenericPolyconeRead( << 763 = reflectedSolidElement->getAttributes(); 1285 const xercesc::DOMElement* const polyconeEl << 764 XMLSize_t attributeCount = attributes->getLength(); 1286 { << 765 1287 G4String name; << 766 for (XMLSize_t attribute_index=0; 1288 G4double lunit = 1.0; << 767 attribute_index<attributeCount; attribute_index++) 1289 G4double aunit = 1.0; << 768 { 1290 G4double startphi = 0.0; << 769 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1291 G4double deltaphi = 0.0; << 770 1292 << 771 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1293 const xercesc::DOMNamedNodeMap* const attri << 772 { continue; } 1294 polyconeElement->getAttributes(); << 773 1295 XMLSize_t attributeCount = attributes->getL << 774 const xercesc::DOMAttr* const attribute 1296 << 775 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1297 for(XMLSize_t attribute_index = 0; attribut << 776 const G4String attName = Transcode(attribute->getName()); 1298 ++attribute_index) << 777 const G4String attValue = Transcode(attribute->getValue()); 1299 { << 778 1300 xercesc::DOMNode* attribute_node = attrib << 779 if (attName=="name") { name = GenerateName(attValue); } else 1301 << 780 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 1302 if(attribute_node->getNodeType() != xerce << 781 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 1303 { << 782 if (attName=="solid") { solid = GenerateName(attValue); } else 1304 continue; << 783 if (attName=="sx") { scale.setX(eval.Evaluate(attValue)); } else 1305 } << 784 if (attName=="sy") { scale.setY(eval.Evaluate(attValue)); } else 1306 << 785 if (attName=="sz") { scale.setZ(eval.Evaluate(attValue)); } else 1307 const xercesc::DOMAttr* const attribute = << 786 if (attName=="rx") { rotation.setX(eval.Evaluate(attValue)); } else 1308 dynamic_cast<xercesc::DOMAttr*>(attribu << 787 if (attName=="ry") { rotation.setY(eval.Evaluate(attValue)); } else 1309 if(attribute == nullptr) << 788 if (attName=="rz") { rotation.setZ(eval.Evaluate(attValue)); } else 1310 { << 789 if (attName=="dx") { position.setX(eval.Evaluate(attValue)); } else 1311 G4Exception("G4GDMLReadSolids::GenericP << 790 if (attName=="dy") { position.setY(eval.Evaluate(attValue)); } else 1312 FatalException, "No attribu << 791 if (attName=="dz") { position.setZ(eval.Evaluate(attValue)); } 1313 return; << 792 } 1314 } << 793 1315 const G4String attName = Transcode(attri << 794 rotation *= aunit; 1316 const G4String attValue = Transcode(attri << 795 position *= lunit; 1317 << 796 1318 if(attName == "name") << 797 G4Transform3D transform(GetRotationMatrix(rotation),position); 1319 { << 798 transform = transform*G4Scale3D(scale.x(),scale.y(),scale.z()); 1320 name = GenerateName(attValue); << 799 1321 } << 800 new G4ReflectedSolid(name,GetSolid(solid),transform); 1322 else if(attName == "lunit") << 801 } 1323 { << 802 1324 lunit = G4UnitDefinition::GetValueOf(at << 803 G4ExtrudedSolid::ZSection G4GDMLReadSolids:: 1325 if(G4UnitDefinition::GetCategory(attVal << 804 SectionRead(const xercesc::DOMElement* const sectionElement,G4double lunit) 1326 { << 805 { 1327 G4Exception("G4GDMLReadSolids::Generi << 806 G4double zPosition = 0.0; 1328 FatalException, "Invalid << 807 G4TwoVector Offset; 1329 } << 808 G4double scalingFactor = 1.0; 1330 } << 809 1331 else if(attName == "aunit") << 810 const xercesc::DOMNamedNodeMap* const attributes 1332 { << 811 = sectionElement->getAttributes(); 1333 aunit = G4UnitDefinition::GetValueOf(at << 812 XMLSize_t attributeCount = attributes->getLength(); 1334 if(G4UnitDefinition::GetCategory(attVal << 813 1335 { << 814 for (XMLSize_t attribute_index=0; 1336 G4Exception("G4GDMLReadSolids::Generi << 815 attribute_index<attributeCount; attribute_index++) 1337 FatalException, "Invalid << 816 { 1338 } << 817 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1339 } << 818 1340 else if(attName == "startphi") << 819 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1341 { << 820 { continue; } 1342 startphi = eval.Evaluate(attValue); << 821 1343 } << 822 const xercesc::DOMAttr* const attribute 1344 else if(attName == "deltaphi") << 823 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1345 { << 824 const G4String attName = Transcode(attribute->getName()); 1346 deltaphi = eval.Evaluate(attValue); << 825 const G4String attValue = Transcode(attribute->getValue()); 1347 } << 826 1348 } << 827 if (attName=="zPosition") 1349 << 828 { zPosition = eval.Evaluate(attValue)*lunit; } else 1350 startphi *= aunit; << 829 if (attName=="xOffset") 1351 deltaphi *= aunit; << 830 { Offset.setX(eval.Evaluate(attValue)*lunit); } else 1352 << 831 if (attName=="yOffset") 1353 std::vector<rzPointType> rzPointList; << 832 { Offset.setY(eval.Evaluate(attValue)*lunit); } else 1354 << 833 if (attName=="scalingFactor") 1355 for(xercesc::DOMNode* iter = polyconeElemen << 834 { scalingFactor = eval.Evaluate(attValue); } 1356 iter != nullptr; iter << 835 } 1357 { << 836 1358 if(iter->getNodeType() != xercesc::DOMNod << 837 return G4ExtrudedSolid::ZSection(zPosition,Offset,scalingFactor); 1359 { << 838 } 1360 continue; << 839 1361 } << 840 void G4GDMLReadSolids:: 1362 << 841 SphereRead(const xercesc::DOMElement* const sphereElement) 1363 const xercesc::DOMElement* const child = << 842 { 1364 dynamic_cast<xercesc::DOMElement*>(iter << 843 G4String name; 1365 if(child == nullptr) << 844 G4double lunit = 1.0; 1366 { << 845 G4double aunit = 1.0; 1367 G4Exception("G4GDMLReadSolids::GenericP << 846 G4double rmin = 0.0; 1368 FatalException, "No child f << 847 G4double rmax = 0.0; 1369 return; << 848 G4double startphi = 0.0; 1370 } << 849 G4double deltaphi = 0.0; 1371 const G4String tag = Transcode(child->get << 850 G4double starttheta = 0.0; 1372 << 851 G4double deltatheta = 0.0; 1373 if(tag == "rzpoint") << 852 1374 { << 853 const xercesc::DOMNamedNodeMap* const attributes 1375 rzPointList.push_back(RZPointRead(child << 854 = sphereElement->getAttributes(); 1376 } << 855 XMLSize_t attributeCount = attributes->getLength(); 1377 } << 856 1378 << 857 for (XMLSize_t attribute_index=0; 1379 std::size_t numRZPoints = rzPointList.size( << 858 attribute_index<attributeCount; attribute_index++) 1380 << 859 { 1381 G4double* r_array = new G4double[numRZPoint << 860 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1382 G4double* z_array = new G4double[numRZPoint << 861 1383 << 862 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1384 for(std::size_t i = 0; i < numRZPoints; ++i << 863 { continue; } 1385 { << 864 1386 r_array[i] = rzPointList[i].r * lunit; << 865 const xercesc::DOMAttr* const attribute 1387 z_array[i] = rzPointList[i].z * lunit; << 866 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1388 } << 867 const G4String attName = Transcode(attribute->getName()); 1389 new G4GenericPolycone(name, startphi, delta << 868 const G4String attValue = Transcode(attribute->getValue()); 1390 r_array, z_array); << 869 1391 delete[] r_array; << 870 if (attName=="name") { name = GenerateName(attValue); } else 1392 delete[] z_array; << 871 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 1393 } << 872 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 1394 << 873 if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else 1395 // ------------------------------------------ << 874 if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else 1396 void G4GDMLReadSolids::PolyhedraRead( << 875 if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else 1397 const xercesc::DOMElement* const polyhedraE << 876 if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } else 1398 { << 877 if (attName=="starttheta") { starttheta = eval.Evaluate(attValue); } else 1399 G4String name; << 878 if (attName=="deltatheta") { deltatheta = eval.Evaluate(attValue); } 1400 G4double lunit = 1.0; << 879 } 1401 G4double aunit = 1.0; << 880 1402 G4double startphi = 0.0; << 881 rmin *= lunit; 1403 G4double deltaphi = 0.0; << 882 rmax *= lunit; 1404 G4int numsides = 0; << 883 startphi *= aunit; 1405 << 884 deltaphi *= aunit; 1406 const xercesc::DOMNamedNodeMap* const attri << 885 starttheta *= aunit; 1407 polyhedraElement->getAttributes(); << 886 deltatheta *= aunit; 1408 XMLSize_t attributeCount = attributes->getL << 887 1409 << 888 new G4Sphere(name,rmin,rmax,startphi,deltaphi,starttheta,deltatheta); 1410 for(XMLSize_t attribute_index = 0; attribut << 889 } 1411 ++attribute_index) << 890 1412 { << 891 void G4GDMLReadSolids:: 1413 xercesc::DOMNode* attribute_node = attrib << 892 TessellatedRead(const xercesc::DOMElement* const tessellatedElement) 1414 << 893 { 1415 if(attribute_node->getNodeType() != xerce << 894 G4String name; 1416 { << 895 1417 continue; << 896 const xercesc::DOMNamedNodeMap* const attributes 1418 } << 897 = tessellatedElement->getAttributes(); 1419 << 898 XMLSize_t attributeCount = attributes->getLength(); 1420 const xercesc::DOMAttr* const attribute = << 899 1421 dynamic_cast<xercesc::DOMAttr*>(attribu << 900 for (XMLSize_t attribute_index=0; 1422 if(attribute == nullptr) << 901 attribute_index<attributeCount; attribute_index++) 1423 { << 902 { 1424 G4Exception("G4GDMLReadSolids::Polyhedr << 903 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 1425 FatalException, "No attribu << 904 1426 return; << 905 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 1427 } << 906 { continue; } 1428 const G4String attName = Transcode(attri << 907 1429 const G4String attValue = Transcode(attri << 908 const xercesc::DOMAttr* const attribute 1430 << 909 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 1431 if(attName == "name") << 910 const G4String attName = Transcode(attribute->getName()); 1432 { << 911 const G4String attValue = Transcode(attribute->getValue()); 1433 name = GenerateName(attValue); << 912 1434 } << 913 if (attName=="name") { name = GenerateName(attValue); } 1435 else if(attName == "lunit") << 914 } 1436 { << 915 1437 lunit = G4UnitDefinition::GetValueOf(at << 916 G4TessellatedSolid *tessellated = new G4TessellatedSolid(name); 1438 if(G4UnitDefinition::GetCategory(attVal << 917 1439 { << 918 for (xercesc::DOMNode* iter = tessellatedElement->getFirstChild(); 1440 G4Exception("G4GDMLReadSolids::Polyhe << 919 iter != 0; iter = iter->getNextSibling()) 1441 FatalException, "Invalid << 920 { 1442 } << 921 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } 1443 } << 922 1444 else if(attName == "aunit") << 923 const xercesc::DOMElement* const child 1445 { << 924 = dynamic_cast<xercesc::DOMElement*>(iter); 1446 aunit = G4UnitDefinition::GetValueOf(at << 925 const G4String tag = Transcode(child->getTagName()); 1447 if(G4UnitDefinition::GetCategory(attVal << 926 1448 { << 927 if (tag=="triangular") 1449 G4Exception("G4GDMLReadSolids::Polyhe << 928 { tessellated->AddFacet(TriangularRead(child)); } else 1450 FatalException, "Invalid << 929 if (tag=="quadrangular") 1451 } << 930 { tessellated->AddFacet(QuadrangularRead(child)); } 1452 } << 931 } 1453 else if(attName == "startphi") << 1454 { << 1455 startphi = eval.Evaluate(attValue); << 1456 } << 1457 else if(attName == "deltaphi") << 1458 { << 1459 deltaphi = eval.Evaluate(attValue); << 1460 } << 1461 else if(attName == "numsides") << 1462 { << 1463 numsides = eval.EvaluateInteger(attValu << 1464 } << 1465 } << 1466 << 1467 startphi *= aunit; << 1468 deltaphi *= aunit; << 1469 << 1470 std::vector<zplaneType> zplaneList; << 1471 << 1472 for(xercesc::DOMNode* iter = polyhedraEleme << 1473 iter != nullptr; iter << 1474 { << 1475 if(iter->getNodeType() != xercesc::DOMNod << 1476 { << 1477 continue; << 1478 } << 1479 << 1480 const xercesc::DOMElement* const child = << 1481 dynamic_cast<xercesc::DOMElement*>(iter << 1482 if(child == nullptr) << 1483 { << 1484 G4Exception("G4GDMLReadSolids::Polyhedr << 1485 FatalException, "No child f << 1486 return; << 1487 } << 1488 const G4String tag = Transcode(child->get << 1489 << 1490 if(tag == "zplane") << 1491 { << 1492 zplaneList.push_back(ZplaneRead(child)) << 1493 } << 1494 } << 1495 << 1496 std::size_t numZPlanes = zplaneList.size(); << 1497 << 1498 G4double* rmin_array = new G4double[numZPla << 1499 G4double* rmax_array = new G4double[numZPla << 1500 G4double* z_array = new G4double[numZPla << 1501 << 1502 for(std::size_t i = 0; i < numZPlanes; ++i) << 1503 { << 1504 rmin_array[i] = zplaneList[i].rmin * luni << 1505 rmax_array[i] = zplaneList[i].rmax * luni << 1506 z_array[i] = zplaneList[i].z * lunit; << 1507 } << 1508 << 1509 new G4Polyhedra(name, startphi, deltaphi, n << 1510 z_array, rmin_array, rmax_a << 1511 << 1512 delete[] rmin_array; << 1513 delete[] rmax_array; << 1514 delete[] z_array; << 1515 } << 1516 << 1517 // ------------------------------------------ << 1518 void G4GDMLReadSolids::GenericPolyhedraRead( << 1519 const xercesc::DOMElement* const polyhedraE << 1520 { << 1521 G4String name; << 1522 G4double lunit = 1.0; << 1523 G4double aunit = 1.0; << 1524 G4double startphi = 0.0; << 1525 G4double deltaphi = 0.0; << 1526 G4int numsides = 0; << 1527 << 1528 const xercesc::DOMNamedNodeMap* const attri << 1529 polyhedraElement->getAttributes(); << 1530 XMLSize_t attributeCount = attributes->getL << 1531 << 1532 for(XMLSize_t attribute_index = 0; attribut << 1533 ++attribute_index) << 1534 { << 1535 xercesc::DOMNode* attribute_node = attrib << 1536 << 1537 if(attribute_node->getNodeType() != xerce << 1538 { << 1539 continue; << 1540 } << 1541 << 1542 const xercesc::DOMAttr* const attribute = << 1543 dynamic_cast<xercesc::DOMAttr*>(attribu << 1544 if(attribute == nullptr) << 1545 { << 1546 G4Exception("G4GDMLReadSolids::GenericP << 1547 FatalException, "No attribu << 1548 return; << 1549 } << 1550 const G4String attName = Transcode(attri << 1551 const G4String attValue = Transcode(attri << 1552 << 1553 if(attName == "name") << 1554 { << 1555 name = GenerateName(attValue); << 1556 } << 1557 else if(attName == "lunit") << 1558 { << 1559 lunit = G4UnitDefinition::GetValueOf(at << 1560 if(G4UnitDefinition::GetCategory(attVal << 1561 { << 1562 G4Exception("G4GDMLReadSolids::Generi << 1563 FatalException, "Invalid << 1564 } << 1565 } << 1566 else if(attName == "aunit") << 1567 { << 1568 aunit = G4UnitDefinition::GetValueOf(at << 1569 if(G4UnitDefinition::GetCategory(attVal << 1570 { << 1571 G4Exception("G4GDMLReadSolids::Generi << 1572 FatalException, "Invalid << 1573 } << 1574 } << 1575 else if(attName == "startphi") << 1576 { << 1577 startphi = eval.Evaluate(attValue); << 1578 } << 1579 else if(attName == "deltaphi") << 1580 { << 1581 deltaphi = eval.Evaluate(attValue); << 1582 } << 1583 else if(attName == "numsides") << 1584 { << 1585 numsides = eval.EvaluateInteger(attValu << 1586 } << 1587 } << 1588 << 1589 startphi *= aunit; << 1590 deltaphi *= aunit; << 1591 << 1592 std::vector<rzPointType> rzpointList; << 1593 << 1594 for(xercesc::DOMNode* iter = polyhedraEleme << 1595 iter != nullptr; iter << 1596 { << 1597 if(iter->getNodeType() != xercesc::DOMNod << 1598 { << 1599 continue; << 1600 } << 1601 << 1602 const xercesc::DOMElement* const child = << 1603 dynamic_cast<xercesc::DOMElement*>(iter << 1604 if(child == nullptr) << 1605 { << 1606 G4Exception("G4GDMLReadSolids::GenericP << 1607 FatalException, "No child f << 1608 return; << 1609 } << 1610 const G4String tag = Transcode(child->get << 1611 << 1612 if(tag == "rzpoint") << 1613 { << 1614 rzpointList.push_back(RZPointRead(child << 1615 } << 1616 } << 1617 << 1618 std::size_t numRZPoints = rzpointList.size( << 1619 << 1620 G4double* r_array = new G4double[numRZPoint << 1621 G4double* z_array = new G4double[numRZPoint << 1622 << 1623 for(std::size_t i = 0; i < numRZPoints; ++i << 1624 { << 1625 r_array[i] = rzpointList[i].r * lunit; << 1626 z_array[i] = rzpointList[i].z * lunit; << 1627 } << 1628 << 1629 new G4Polyhedra(name, startphi, deltaphi, n << 1630 r_array, z_array); << 1631 932 1632 delete[] r_array; << 933 tessellated->SetSolidClosed(true); 1633 delete[] z_array; << 1634 } 934 } 1635 935 1636 // ------------------------------------------ << 1637 G4QuadrangularFacet* G4GDMLReadSolids::Quadra << 1638 const xercesc::DOMElement* const quadrangul << 1639 { << 1640 G4ThreeVector vertex1; << 1641 G4ThreeVector vertex2; << 1642 G4ThreeVector vertex3; << 1643 G4ThreeVector vertex4; << 1644 G4FacetVertexType type = ABSOLUTE; << 1645 G4double lunit = 1.0; << 1646 << 1647 const xercesc::DOMNamedNodeMap* const attri << 1648 quadrangularElement->getAttributes(); << 1649 XMLSize_t attributeCount = attributes->getL << 1650 << 1651 for(XMLSize_t attribute_index = 0; attribut << 1652 ++attribute_index) << 1653 { << 1654 xercesc::DOMNode* attribute_node = attrib << 1655 << 1656 if(attribute_node->getNodeType() != xerce << 1657 { << 1658 continue; << 1659 } << 1660 << 1661 const xercesc::DOMAttr* const attribute = << 1662 dynamic_cast<xercesc::DOMAttr*>(attribu << 1663 if(attribute == nullptr) << 1664 { << 1665 G4Exception("G4GDMLReadSolids::Quadrang << 1666 FatalException, "No attribu << 1667 return nullptr; << 1668 } << 1669 const G4String attName = Transcode(attri << 1670 const G4String attValue = Transcode(attri << 1671 << 1672 if(attName == "vertex1") << 1673 { << 1674 vertex1 = GetPosition(GenerateName(attV << 1675 } << 1676 else if(attName == "vertex2") << 1677 { << 1678 vertex2 = GetPosition(GenerateName(attV << 1679 } << 1680 else if(attName == "vertex3") << 1681 { << 1682 vertex3 = GetPosition(GenerateName(attV << 1683 } << 1684 else if(attName == "vertex4") << 1685 { << 1686 vertex4 = GetPosition(GenerateName(attV << 1687 } << 1688 else if(attName == "lunit") << 1689 { << 1690 lunit = G4UnitDefinition::GetValueOf(at << 1691 if(G4UnitDefinition::GetCategory(attVal << 1692 { << 1693 G4Exception("G4GDMLReadSolids::Quadra << 1694 FatalException, "Invalid << 1695 } << 1696 } << 1697 else if(attName == "type") << 1698 { << 1699 if(attValue == "RELATIVE") << 1700 { << 1701 type = RELATIVE; << 1702 } << 1703 } << 1704 } << 1705 << 1706 return new G4QuadrangularFacet(vertex1 * lu << 1707 vertex3 * lu << 1708 } << 1709 << 1710 // ------------------------------------------ << 1711 void G4GDMLReadSolids::ReflectedSolidRead( << 1712 const xercesc::DOMElement* const reflectedS << 1713 { << 1714 G4String name; << 1715 G4double lunit = 1.0; << 1716 G4double aunit = 1.0; << 1717 G4String solid; << 1718 G4ThreeVector scale(1.0, 1.0, 1.0); << 1719 G4ThreeVector rotation; << 1720 G4ThreeVector position; << 1721 << 1722 const xercesc::DOMNamedNodeMap* const attri << 1723 reflectedSolidElement->getAttributes(); << 1724 XMLSize_t attributeCount = attributes->getL << 1725 << 1726 for(XMLSize_t attribute_index = 0; attribut << 1727 ++attribute_index) << 1728 { << 1729 xercesc::DOMNode* attribute_node = attrib << 1730 << 1731 if(attribute_node->getNodeType() != xerce << 1732 { << 1733 continue; << 1734 } << 1735 << 1736 const xercesc::DOMAttr* const attribute = << 1737 dynamic_cast<xercesc::DOMAttr*>(attribu << 1738 if(attribute == nullptr) << 1739 { << 1740 G4Exception("G4GDMLReadSolids::Reflecte << 1741 FatalException, "No attribu << 1742 return; << 1743 } << 1744 const G4String attName = Transcode(attri << 1745 const G4String attValue = Transcode(attri << 1746 << 1747 if(attName == "name") << 1748 { << 1749 name = GenerateName(attValue); << 1750 } << 1751 else if(attName == "lunit") << 1752 { << 1753 lunit = G4UnitDefinition::GetValueOf(at << 1754 if(G4UnitDefinition::GetCategory(attVal << 1755 { << 1756 G4Exception("G4GDMLReadSolids::Reflec << 1757 FatalException, "Invalid << 1758 } << 1759 } << 1760 else if(attName == "aunit") << 1761 { << 1762 aunit = G4UnitDefinition::GetValueOf(at << 1763 if(G4UnitDefinition::GetCategory(attVal << 1764 { << 1765 G4Exception("G4GDMLReadSolids::Reflec << 1766 FatalException, "Invalid << 1767 } << 1768 } << 1769 else if(attName == "solid") << 1770 { << 1771 solid = GenerateName(attValue); << 1772 } << 1773 else if(attName == "sx") << 1774 { << 1775 scale.setX(eval.Evaluate(attValue)); << 1776 } << 1777 else if(attName == "sy") << 1778 { << 1779 scale.setY(eval.Evaluate(attValue)); << 1780 } << 1781 else if(attName == "sz") << 1782 { << 1783 scale.setZ(eval.Evaluate(attValue)); << 1784 } << 1785 else if(attName == "rx") << 1786 { << 1787 rotation.setX(eval.Evaluate(attValue)); << 1788 } << 1789 else if(attName == "ry") << 1790 { << 1791 rotation.setY(eval.Evaluate(attValue)); << 1792 } << 1793 else if(attName == "rz") << 1794 { << 1795 rotation.setZ(eval.Evaluate(attValue)); << 1796 } << 1797 else if(attName == "dx") << 1798 { << 1799 position.setX(eval.Evaluate(attValue)); << 1800 } << 1801 else if(attName == "dy") << 1802 { << 1803 position.setY(eval.Evaluate(attValue)); << 1804 } << 1805 else if(attName == "dz") << 1806 { << 1807 position.setZ(eval.Evaluate(attValue)); << 1808 } << 1809 } << 1810 << 1811 rotation *= aunit; << 1812 position *= lunit; << 1813 << 1814 G4Transform3D transform(GetRotationMatrix(r << 1815 transform = transform * G4Scale3D(scale.x() << 1816 << 1817 new G4ReflectedSolid(name, GetSolid(solid), << 1818 } << 1819 << 1820 // ------------------------------------------ << 1821 void G4GDMLReadSolids::ScaledSolidRead( << 1822 const xercesc::DOMElement* const scaledSoli << 1823 { << 1824 G4String name; << 1825 G4VSolid* solid = nullptr; << 1826 G4ThreeVector scale(1.0, 1.0, 1.0); << 1827 << 1828 const xercesc::DOMNamedNodeMap* const attri << 1829 scaledSolidElement->getAttributes(); << 1830 XMLSize_t attributeCount = attributes->getL << 1831 << 1832 for(XMLSize_t attribute_index = 0; attribut << 1833 ++attribute_index) << 1834 { << 1835 xercesc::DOMNode* attribute_node = attrib << 1836 << 1837 if(attribute_node->getNodeType() != xerce << 1838 { << 1839 continue; << 1840 } << 1841 << 1842 const xercesc::DOMAttr* const attribute = << 1843 dynamic_cast<xercesc::DOMAttr*>(attribu << 1844 if(attribute == nullptr) << 1845 { << 1846 G4Exception("G4GDMLReadSolids::ScaledSo << 1847 FatalException, "No attribu << 1848 return; << 1849 } << 1850 const G4String attName = Transcode(attri << 1851 const G4String attValue = Transcode(attri << 1852 << 1853 if(attName == "name") << 1854 { << 1855 name = GenerateName(attValue); << 1856 } << 1857 } << 1858 << 1859 for(xercesc::DOMNode* iter = scaledSolidEle << 1860 iter != nullptr; iter << 1861 { << 1862 if(iter->getNodeType() != xercesc::DOMNod << 1863 { << 1864 continue; << 1865 } << 1866 << 1867 const xercesc::DOMElement* const child = << 1868 dynamic_cast<xercesc::DOMElement*>(iter << 1869 if(child == nullptr) << 1870 { << 1871 G4Exception("G4GDMLReadSolids::ScaledSo << 1872 FatalException, "No child f << 1873 return; << 1874 } << 1875 const G4String tag = Transcode(child->get << 1876 << 1877 if(tag == "solidref") << 1878 { << 1879 solid = GetSolid(GenerateName(RefRead(c << 1880 } << 1881 else if(tag == "scale") << 1882 { << 1883 VectorRead(child, scale); << 1884 } << 1885 else if(tag == "scaleref") << 1886 { << 1887 scale = GetScale(GenerateName(RefRead(c << 1888 } << 1889 else << 1890 { << 1891 G4String error_msg = "Unknown tag in sc << 1892 G4Exception("G4GDMLReadSolids::ScaledSo << 1893 FatalException, error_msg); << 1894 return; << 1895 } << 1896 } << 1897 << 1898 G4Scale3D transform = G4Scale3D(scale.x(), << 1899 << 1900 new G4ScaledSolid(name, solid, transform); << 1901 } << 1902 << 1903 // ------------------------------------------ << 1904 G4ExtrudedSolid::ZSection G4GDMLReadSolids::S << 1905 const xercesc::DOMElement* const sectionEle << 1906 { << 1907 G4double zPosition = 0.0; << 1908 G4TwoVector Offset; << 1909 G4double scalingFactor = 1.0; << 1910 << 1911 const xercesc::DOMNamedNodeMap* const attri << 1912 sectionElement->getAttributes(); << 1913 XMLSize_t attributeCount = attributes->getL << 1914 << 1915 for(XMLSize_t attribute_index = 0; attribut << 1916 ++attribute_index) << 1917 { << 1918 xercesc::DOMNode* attribute_node = attrib << 1919 << 1920 if(attribute_node->getNodeType() != xerce << 1921 { << 1922 continue; << 1923 } << 1924 << 1925 const xercesc::DOMAttr* const attribute = << 1926 dynamic_cast<xercesc::DOMAttr*>(attribu << 1927 if(attribute == nullptr) << 1928 { << 1929 G4Exception("G4GDMLReadSolids::SectionR << 1930 FatalException, "No attribu << 1931 return G4ExtrudedSolid::ZSection(zPosit << 1932 } << 1933 const G4String attName = Transcode(attri << 1934 const G4String attValue = Transcode(attri << 1935 << 1936 if(attName == "zPosition") << 1937 { << 1938 zPosition = eval.Evaluate(attValue) * l << 1939 } << 1940 else if(attName == "xOffset") << 1941 { << 1942 Offset.setX(eval.Evaluate(attValue) * l << 1943 } << 1944 else if(attName == "yOffset") << 1945 { << 1946 Offset.setY(eval.Evaluate(attValue) * l << 1947 } << 1948 else if(attName == "scalingFactor") << 1949 { << 1950 scalingFactor = eval.Evaluate(attValue) << 1951 } << 1952 } << 1953 << 1954 return G4ExtrudedSolid::ZSection(zPosition, << 1955 } << 1956 << 1957 // ------------------------------------------ << 1958 void G4GDMLReadSolids::SphereRead( << 1959 const xercesc::DOMElement* const sphereElem << 1960 { << 1961 G4String name; << 1962 G4double lunit = 1.0; << 1963 G4double aunit = 1.0; << 1964 G4double rmin = 0.0; << 1965 G4double rmax = 0.0; << 1966 G4double startphi = 0.0; << 1967 G4double deltaphi = 0.0; << 1968 G4double starttheta = 0.0; << 1969 G4double deltatheta = 0.0; << 1970 << 1971 const xercesc::DOMNamedNodeMap* const attri << 1972 sphereElement->getAttributes(); << 1973 XMLSize_t attributeCount = attributes->getL << 1974 << 1975 for(XMLSize_t attribute_index = 0; attribut << 1976 ++attribute_index) << 1977 { << 1978 xercesc::DOMNode* attribute_node = attrib << 1979 << 1980 if(attribute_node->getNodeType() != xerce << 1981 { << 1982 continue; << 1983 } << 1984 << 1985 const xercesc::DOMAttr* const attribute = << 1986 dynamic_cast<xercesc::DOMAttr*>(attribu << 1987 if(attribute == nullptr) << 1988 { << 1989 G4Exception("G4GDMLReadSolids::SphereRe << 1990 FatalException, "No attribu << 1991 return; << 1992 } << 1993 const G4String attName = Transcode(attri << 1994 const G4String attValue = Transcode(attri << 1995 << 1996 if(attName == "name") << 1997 { << 1998 name = GenerateName(attValue); << 1999 } << 2000 else if(attName == "lunit") << 2001 { << 2002 lunit = G4UnitDefinition::GetValueOf(at << 2003 if(G4UnitDefinition::GetCategory(attVal << 2004 { << 2005 G4Exception("G4GDMLReadSolids::Sphere << 2006 FatalException, "Invalid << 2007 } << 2008 } << 2009 else if(attName == "aunit") << 2010 { << 2011 aunit = G4UnitDefinition::GetValueOf(at << 2012 if(G4UnitDefinition::GetCategory(attVal << 2013 { << 2014 G4Exception("G4GDMLReadSolids::Sphere << 2015 FatalException, "Invalid << 2016 } << 2017 } << 2018 else if(attName == "rmin") << 2019 { << 2020 rmin = eval.Evaluate(attValue); << 2021 } << 2022 else if(attName == "rmax") << 2023 { << 2024 rmax = eval.Evaluate(attValue); << 2025 } << 2026 else if(attName == "startphi") << 2027 { << 2028 startphi = eval.Evaluate(attValue); << 2029 } << 2030 else if(attName == "deltaphi") << 2031 { << 2032 deltaphi = eval.Evaluate(attValue); << 2033 } << 2034 else if(attName == "starttheta") << 2035 { << 2036 starttheta = eval.Evaluate(attValue); << 2037 } << 2038 else if(attName == "deltatheta") << 2039 { << 2040 deltatheta = eval.Evaluate(attValue); << 2041 } << 2042 } << 2043 << 2044 rmin *= lunit; << 2045 rmax *= lunit; << 2046 startphi *= aunit; << 2047 deltaphi *= aunit; << 2048 starttheta *= aunit; << 2049 deltatheta *= aunit; << 2050 << 2051 new G4Sphere(name, rmin, rmax, startphi, de << 2052 } << 2053 << 2054 // ------------------------------------------ << 2055 void G4GDMLReadSolids::TessellatedRead( << 2056 const xercesc::DOMElement* const tessellate << 2057 { << 2058 G4String name; << 2059 << 2060 const xercesc::DOMNamedNodeMap* const attri << 2061 tessellatedElement->getAttributes(); << 2062 XMLSize_t attributeCount = attributes->getL << 2063 << 2064 for(XMLSize_t attribute_index = 0; attribut << 2065 ++attribute_index) << 2066 { << 2067 xercesc::DOMNode* attribute_node = attrib << 2068 << 2069 if(attribute_node->getNodeType() != xerce << 2070 { << 2071 continue; << 2072 } << 2073 << 2074 const xercesc::DOMAttr* const attribute = << 2075 dynamic_cast<xercesc::DOMAttr*>(attribu << 2076 if(attribute == nullptr) << 2077 { << 2078 G4Exception("G4GDMLReadSolids::Tessella << 2079 FatalException, "No attribu << 2080 return; << 2081 } << 2082 const G4String attName = Transcode(attri << 2083 const G4String attValue = Transcode(attri << 2084 << 2085 if(attName == "name") << 2086 { << 2087 name = GenerateName(attValue); << 2088 } << 2089 } << 2090 << 2091 G4TessellatedSolid* tessellated = new G4Tes << 2092 << 2093 for(xercesc::DOMNode* iter = tessellatedEle << 2094 iter != nullptr; iter << 2095 { << 2096 if(iter->getNodeType() != xercesc::DOMNod << 2097 { << 2098 continue; << 2099 } << 2100 << 2101 const xercesc::DOMElement* const child = << 2102 dynamic_cast<xercesc::DOMElement*>(iter << 2103 if(child == nullptr) << 2104 { << 2105 G4Exception("G4GDMLReadSolids::Tessella << 2106 FatalException, "No child f << 2107 return; << 2108 } << 2109 const G4String tag = Transcode(child->get << 2110 << 2111 if(tag == "triangular") << 2112 { << 2113 tessellated->AddFacet(TriangularRead(ch << 2114 } << 2115 else if(tag == "quadrangular") << 2116 { << 2117 tessellated->AddFacet(QuadrangularRead( << 2118 } << 2119 } << 2120 << 2121 tessellated->SetSolidClosed(true); << 2122 } << 2123 << 2124 // ------------------------------------------ << 2125 void G4GDMLReadSolids::TetRead(const xercesc: 936 void G4GDMLReadSolids::TetRead(const xercesc::DOMElement* const tetElement) 2126 { 937 { 2127 G4String name; << 938 G4String name; 2128 G4ThreeVector vertex1; << 939 G4ThreeVector vertex1; 2129 G4ThreeVector vertex2; << 940 G4ThreeVector vertex2; 2130 G4ThreeVector vertex3; << 941 G4ThreeVector vertex3; 2131 G4ThreeVector vertex4; << 942 G4ThreeVector vertex4; 2132 G4double lunit = 1.0; << 943 2133 << 944 const xercesc::DOMNamedNodeMap* const attributes 2134 const xercesc::DOMNamedNodeMap* const attri << 945 = tetElement->getAttributes(); 2135 tetElement->getAttributes(); << 946 XMLSize_t attributeCount = attributes->getLength(); 2136 XMLSize_t attributeCount = attributes->getL << 947 2137 << 948 for (XMLSize_t attribute_index=0; 2138 for(XMLSize_t attribute_index = 0; attribut << 949 attribute_index<attributeCount;attribute_index++) 2139 ++attribute_index) << 950 { 2140 { << 951 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 2141 xercesc::DOMNode* attribute_node = attrib << 952 2142 << 953 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 2143 if(attribute_node->getNodeType() != xerce << 954 { continue; } 2144 { << 955 2145 continue; << 956 const xercesc::DOMAttr* const attribute 2146 } << 957 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 2147 << 958 const G4String attName = Transcode(attribute->getName()); 2148 const xercesc::DOMAttr* const attribute = << 959 const G4String attValue = Transcode(attribute->getValue()); 2149 dynamic_cast<xercesc::DOMAttr*>(attribu << 960 2150 if(attribute == nullptr) << 961 if (attName=="name") 2151 { << 962 { name = GenerateName(attValue); } else 2152 G4Exception("G4GDMLReadSolids::TetRead( << 963 if (attName=="vertex1") 2153 "No attribute found!"); << 964 { vertex1 = GetPosition(GenerateName(attValue)); } else 2154 return; << 965 if (attName=="vertex2") 2155 } << 966 { vertex2 = GetPosition(GenerateName(attValue)); } else 2156 const G4String attName = Transcode(attri << 967 if (attName=="vertex3") 2157 const G4String attValue = Transcode(attri << 968 { vertex3 = GetPosition(GenerateName(attValue)); } else 2158 << 969 if (attName=="vertex4") 2159 if(attName == "name") << 970 { vertex4 = GetPosition(GenerateName(attValue)); } 2160 { << 971 } 2161 name = GenerateName(attValue); << 2162 } << 2163 else if(attName == "lunit") << 2164 { << 2165 lunit = G4UnitDefinition::GetValueOf(at << 2166 if(G4UnitDefinition::GetCategory(attVal << 2167 { << 2168 G4Exception("G4GDMLReadSolids::TetRea << 2169 FatalException, "Invalid << 2170 } << 2171 } << 2172 else if(attName == "vertex1") << 2173 { << 2174 vertex1 = GetPosition(GenerateName(attV << 2175 } << 2176 else if(attName == "vertex2") << 2177 { << 2178 vertex2 = GetPosition(GenerateName(attV << 2179 } << 2180 else if(attName == "vertex3") << 2181 { << 2182 vertex3 = GetPosition(GenerateName(attV << 2183 } << 2184 else if(attName == "vertex4") << 2185 { << 2186 vertex4 = GetPosition(GenerateName(attV << 2187 } << 2188 } << 2189 972 2190 new G4Tet(name, vertex1 * lunit, vertex2 * << 973 new G4Tet(name,vertex1,vertex2,vertex3,vertex4); 2191 vertex4 * lunit); << 2192 } 974 } 2193 975 2194 // ------------------------------------------ << 2195 void G4GDMLReadSolids::TorusRead(const xerces 976 void G4GDMLReadSolids::TorusRead(const xercesc::DOMElement* const torusElement) 2196 { 977 { 2197 G4String name; << 978 G4String name; 2198 G4double lunit = 1.0; << 979 G4double lunit = 1.0; 2199 G4double aunit = 1.0; << 980 G4double aunit = 1.0; 2200 G4double rmin = 0.0; << 981 G4double rmin = 0.0; 2201 G4double rmax = 0.0; << 982 G4double rmax = 0.0; 2202 G4double rtor = 0.0; << 983 G4double rtor = 0.0; 2203 G4double startphi = 0.0; << 984 G4double startphi = 0.0; 2204 G4double deltaphi = 0.0; << 985 G4double deltaphi = 0.0; 2205 << 986 2206 const xercesc::DOMNamedNodeMap* const attri << 987 const xercesc::DOMNamedNodeMap* const attributes 2207 torusElement->getAttributes(); << 988 = torusElement->getAttributes(); 2208 XMLSize_t attributeCount = attributes->getL << 989 XMLSize_t attributeCount = attributes->getLength(); 2209 << 990 2210 for(XMLSize_t attribute_index = 0; attribut << 991 for (XMLSize_t attribute_index=0; 2211 ++attribute_index) << 992 attribute_index<attributeCount; attribute_index++) 2212 { << 993 { 2213 xercesc::DOMNode* attribute_node = attrib << 994 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 2214 << 995 2215 if(attribute_node->getNodeType() != xerce << 996 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 2216 { << 997 { continue; } 2217 continue; << 998 2218 } << 999 const xercesc::DOMAttr* const attribute 2219 << 1000 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 2220 const xercesc::DOMAttr* const attribute = << 1001 const G4String attName = Transcode(attribute->getName()); 2221 dynamic_cast<xercesc::DOMAttr*>(attribu << 1002 const G4String attValue = Transcode(attribute->getValue()); 2222 if(attribute == nullptr) << 1003 2223 { << 1004 if (attName=="name") { name = GenerateName(attValue); } else 2224 G4Exception("G4GDMLReadSolids::TorusRea << 1005 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 2225 FatalException, "No attribu << 1006 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 2226 return; << 1007 if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else 2227 } << 1008 if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else 2228 const G4String attName = Transcode(attri << 1009 if (attName=="rtor") { rtor = eval.Evaluate(attValue); } else 2229 const G4String attValue = Transcode(attri << 1010 if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else 2230 << 1011 if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } 2231 if(attName == "name") << 1012 } 2232 { << 1013 2233 name = GenerateName(attValue); << 1014 rmin *= lunit; 2234 } << 1015 rmax *= lunit; 2235 else if(attName == "lunit") << 1016 rtor *= lunit; 2236 { << 1017 startphi *= aunit; 2237 lunit = G4UnitDefinition::GetValueOf(at << 1018 deltaphi *= aunit; 2238 if(G4UnitDefinition::GetCategory(attVal << 2239 { << 2240 G4Exception("G4GDMLReadSolids::TorusR << 2241 FatalException, "Invalid << 2242 } << 2243 } << 2244 else if(attName == "aunit") << 2245 { << 2246 aunit = G4UnitDefinition::GetValueOf(at << 2247 if(G4UnitDefinition::GetCategory(attVal << 2248 { << 2249 G4Exception("G4GDMLReadSolids::TorusR << 2250 FatalException, "Invalid << 2251 } << 2252 } << 2253 else if(attName == "rmin") << 2254 { << 2255 rmin = eval.Evaluate(attValue); << 2256 } << 2257 else if(attName == "rmax") << 2258 { << 2259 rmax = eval.Evaluate(attValue); << 2260 } << 2261 else if(attName == "rtor") << 2262 { << 2263 rtor = eval.Evaluate(attValue); << 2264 } << 2265 else if(attName == "startphi") << 2266 { << 2267 startphi = eval.Evaluate(attValue); << 2268 } << 2269 else if(attName == "deltaphi") << 2270 { << 2271 deltaphi = eval.Evaluate(attValue); << 2272 } << 2273 } << 2274 << 2275 rmin *= lunit; << 2276 rmax *= lunit; << 2277 rtor *= lunit; << 2278 startphi *= aunit; << 2279 deltaphi *= aunit; << 2280 << 2281 new G4Torus(name, rmin, rmax, rtor, startph << 2282 } << 2283 1019 2284 // ------------------------------------------ << 1020 new G4Torus(name,rmin,rmax,rtor,startphi,deltaphi); 2285 void G4GDMLReadSolids::GenTrapRead( << 2286 const xercesc::DOMElement* const gtrapEleme << 2287 { << 2288 G4String name; << 2289 G4double lunit = 1.0; << 2290 G4double dz = 0.0; << 2291 G4double v1x = 0.0, v1y = 0.0, v2x = 0.0, v << 2292 v4x = 0.0, v4y = 0.0, v5x = 0.0, v << 2293 v7x = 0.0, v7y = 0.0, v8x = 0.0, v << 2294 << 2295 const xercesc::DOMNamedNodeMap* const attri << 2296 gtrapElement->getAttributes(); << 2297 XMLSize_t attributeCount = attributes->getL << 2298 << 2299 for(XMLSize_t attribute_index = 0; attribut << 2300 ++attribute_index) << 2301 { << 2302 xercesc::DOMNode* attribute_node = attrib << 2303 << 2304 if(attribute_node->getNodeType() != xerce << 2305 { << 2306 continue; << 2307 } << 2308 << 2309 const xercesc::DOMAttr* const attribute = << 2310 dynamic_cast<xercesc::DOMAttr*>(attribu << 2311 if(attribute == nullptr) << 2312 { << 2313 G4Exception("G4GDMLReadSolids::GenTrapR << 2314 FatalException, "No attribu << 2315 return; << 2316 } << 2317 const G4String attName = Transcode(attri << 2318 const G4String attValue = Transcode(attri << 2319 << 2320 if(attName == "name") << 2321 { << 2322 name = GenerateName(attValue); << 2323 } << 2324 else if(attName == "lunit") << 2325 { << 2326 lunit = G4UnitDefinition::GetValueOf(at << 2327 if(G4UnitDefinition::GetCategory(attVal << 2328 { << 2329 G4Exception("G4GDMLReadSolids::GenTra << 2330 FatalException, "Invalid << 2331 } << 2332 } << 2333 else if(attName == "dz") << 2334 { << 2335 dz = eval.Evaluate(attValue); << 2336 } << 2337 else if(attName == "v1x") << 2338 { << 2339 v1x = eval.Evaluate(attValue); << 2340 } << 2341 else if(attName == "v1y") << 2342 { << 2343 v1y = eval.Evaluate(attValue); << 2344 } << 2345 else if(attName == "v2x") << 2346 { << 2347 v2x = eval.Evaluate(attValue); << 2348 } << 2349 else if(attName == "v2y") << 2350 { << 2351 v2y = eval.Evaluate(attValue); << 2352 } << 2353 else if(attName == "v3x") << 2354 { << 2355 v3x = eval.Evaluate(attValue); << 2356 } << 2357 else if(attName == "v3y") << 2358 { << 2359 v3y = eval.Evaluate(attValue); << 2360 } << 2361 else if(attName == "v4x") << 2362 { << 2363 v4x = eval.Evaluate(attValue); << 2364 } << 2365 else if(attName == "v4y") << 2366 { << 2367 v4y = eval.Evaluate(attValue); << 2368 } << 2369 else if(attName == "v5x") << 2370 { << 2371 v5x = eval.Evaluate(attValue); << 2372 } << 2373 else if(attName == "v5y") << 2374 { << 2375 v5y = eval.Evaluate(attValue); << 2376 } << 2377 else if(attName == "v6x") << 2378 { << 2379 v6x = eval.Evaluate(attValue); << 2380 } << 2381 else if(attName == "v6y") << 2382 { << 2383 v6y = eval.Evaluate(attValue); << 2384 } << 2385 else if(attName == "v7x") << 2386 { << 2387 v7x = eval.Evaluate(attValue); << 2388 } << 2389 else if(attName == "v7y") << 2390 { << 2391 v7y = eval.Evaluate(attValue); << 2392 } << 2393 else if(attName == "v8x") << 2394 { << 2395 v8x = eval.Evaluate(attValue); << 2396 } << 2397 else if(attName == "v8y") << 2398 { << 2399 v8y = eval.Evaluate(attValue); << 2400 } << 2401 } << 2402 << 2403 dz *= lunit; << 2404 std::vector<G4TwoVector> vertices; << 2405 vertices.push_back(G4TwoVector(v1x * lunit, << 2406 vertices.push_back(G4TwoVector(v2x * lunit, << 2407 vertices.push_back(G4TwoVector(v3x * lunit, << 2408 vertices.push_back(G4TwoVector(v4x * lunit, << 2409 vertices.push_back(G4TwoVector(v5x * lunit, << 2410 vertices.push_back(G4TwoVector(v6x * lunit, << 2411 vertices.push_back(G4TwoVector(v7x * lunit, << 2412 vertices.push_back(G4TwoVector(v8x * lunit, << 2413 new G4GenericTrap(name, dz, vertices); << 2414 } 1021 } 2415 1022 2416 // ------------------------------------------ << 2417 void G4GDMLReadSolids::TrapRead(const xercesc 1023 void G4GDMLReadSolids::TrapRead(const xercesc::DOMElement* const trapElement) 2418 { 1024 { 2419 G4String name; << 1025 G4String name; 2420 G4double lunit = 1.0; << 1026 G4double lunit = 1.0; 2421 G4double aunit = 1.0; << 1027 G4double aunit = 1.0; 2422 G4double z = 0.0; << 1028 G4double z = 0.0; 2423 G4double theta = 0.0; << 1029 G4double theta = 0.0; 2424 G4double phi = 0.0; << 1030 G4double phi = 0.0; 2425 G4double y1 = 0.0; << 1031 G4double y1 = 0.0; 2426 G4double x1 = 0.0; << 1032 G4double x1 = 0.0; 2427 G4double x2 = 0.0; << 1033 G4double x2 = 0.0; 2428 G4double alpha1 = 0.0; << 1034 G4double alpha1 = 0.0; 2429 G4double y2 = 0.0; << 1035 G4double y2 = 0.0; 2430 G4double x3 = 0.0; << 1036 G4double x3 = 0.0; 2431 G4double x4 = 0.0; << 1037 G4double x4 = 0.0; 2432 G4double alpha2 = 0.0; << 1038 G4double alpha2 = 0.0; 2433 << 1039 2434 const xercesc::DOMNamedNodeMap* const attri << 1040 const xercesc::DOMNamedNodeMap* const attributes 2435 trapElement->getAttributes(); << 1041 = trapElement->getAttributes(); 2436 XMLSize_t attributeCount = attributes->getL << 1042 XMLSize_t attributeCount = attributes->getLength(); 2437 << 1043 2438 for(XMLSize_t attribute_index = 0; attribut << 1044 for (XMLSize_t attribute_index=0; 2439 ++attribute_index) << 1045 attribute_index<attributeCount; attribute_index++) 2440 { << 1046 { 2441 xercesc::DOMNode* attribute_node = attrib << 1047 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 2442 << 1048 2443 if(attribute_node->getNodeType() != xerce << 1049 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 2444 { << 1050 { continue; } 2445 continue; << 1051 2446 } << 1052 const xercesc::DOMAttr* const attribute 2447 << 1053 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 2448 const xercesc::DOMAttr* const attribute = << 1054 const G4String attName = Transcode(attribute->getName()); 2449 dynamic_cast<xercesc::DOMAttr*>(attribu << 1055 const G4String attValue = Transcode(attribute->getValue()); 2450 if(attribute == nullptr) << 1056 2451 { << 1057 if (attName=="name") { name = GenerateName(attValue); } else 2452 G4Exception("G4GDMLReadSolids::TrapRead << 1058 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 2453 "No attribute found!"); << 1059 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 2454 return; << 1060 if (attName=="z") { z = eval.Evaluate(attValue); } else 2455 } << 1061 if (attName=="theta") { theta = eval.Evaluate(attValue); } else 2456 const G4String attName = Transcode(attri << 1062 if (attName=="phi") { phi = eval.Evaluate(attValue); } else 2457 const G4String attValue = Transcode(attri << 1063 if (attName=="y1") { y1 = eval.Evaluate(attValue); } else 2458 << 1064 if (attName=="x1") { x1 = eval.Evaluate(attValue); } else 2459 if(attName == "name") << 1065 if (attName=="x2") { x2 = eval.Evaluate(attValue); } else 2460 { << 1066 if (attName=="alpha1") { alpha1 = eval.Evaluate(attValue); } else 2461 name = GenerateName(attValue); << 1067 if (attName=="y2") { y2 = eval.Evaluate(attValue); } else 2462 } << 1068 if (attName=="x3") { x3 = eval.Evaluate(attValue); } else 2463 else if(attName == "lunit") << 1069 if (attName=="x4") { x4 = eval.Evaluate(attValue); } else 2464 { << 1070 if (attName=="alpha2") { alpha2 = eval.Evaluate(attValue); } 2465 lunit = G4UnitDefinition::GetValueOf(at << 1071 } 2466 if(G4UnitDefinition::GetCategory(attVal << 1072 2467 { << 1073 z *= 0.5*lunit; 2468 G4Exception("G4GDMLReadSolids::TrapRe << 1074 theta *= aunit; 2469 FatalException, "Invalid << 1075 phi *= aunit; 2470 } << 1076 y1 *= 0.5*lunit; 2471 } << 1077 x1 *= 0.5*lunit; 2472 else if(attName == "aunit") << 1078 x2 *= 0.5*lunit; 2473 { << 1079 alpha1 *= aunit; 2474 aunit = G4UnitDefinition::GetValueOf(at << 1080 y2 *= 0.5*lunit; 2475 if(G4UnitDefinition::GetCategory(attVal << 1081 x3 *= 0.5*lunit; 2476 { << 1082 x4 *= 0.5*lunit; 2477 G4Exception("G4GDMLReadSolids::TrapRe << 1083 alpha2 *= aunit; 2478 FatalException, "Invalid << 2479 } << 2480 } << 2481 else if(attName == "z") << 2482 { << 2483 z = eval.Evaluate(attValue); << 2484 } << 2485 else if(attName == "theta") << 2486 { << 2487 theta = eval.Evaluate(attValue); << 2488 } << 2489 else if(attName == "phi") << 2490 { << 2491 phi = eval.Evaluate(attValue); << 2492 } << 2493 else if(attName == "y1") << 2494 { << 2495 y1 = eval.Evaluate(attValue); << 2496 } << 2497 else if(attName == "x1") << 2498 { << 2499 x1 = eval.Evaluate(attValue); << 2500 } << 2501 else if(attName == "x2") << 2502 { << 2503 x2 = eval.Evaluate(attValue); << 2504 } << 2505 else if(attName == "alpha1") << 2506 { << 2507 alpha1 = eval.Evaluate(attValue); << 2508 } << 2509 else if(attName == "y2") << 2510 { << 2511 y2 = eval.Evaluate(attValue); << 2512 } << 2513 else if(attName == "x3") << 2514 { << 2515 x3 = eval.Evaluate(attValue); << 2516 } << 2517 else if(attName == "x4") << 2518 { << 2519 x4 = eval.Evaluate(attValue); << 2520 } << 2521 else if(attName == "alpha2") << 2522 { << 2523 alpha2 = eval.Evaluate(attValue); << 2524 } << 2525 } << 2526 << 2527 z *= 0.5 * lunit; << 2528 theta *= aunit; << 2529 phi *= aunit; << 2530 y1 *= 0.5 * lunit; << 2531 x1 *= 0.5 * lunit; << 2532 x2 *= 0.5 * lunit; << 2533 alpha1 *= aunit; << 2534 y2 *= 0.5 * lunit; << 2535 x3 *= 0.5 * lunit; << 2536 x4 *= 0.5 * lunit; << 2537 alpha2 *= aunit; << 2538 1084 2539 new G4Trap(name, z, theta, phi, y1, x1, x2, << 1085 new G4Trap(name,z,theta,phi,y1,x1,x2,alpha1,y2,x3,x4,alpha2); 2540 } 1086 } 2541 1087 2542 // ------------------------------------------ << 2543 void G4GDMLReadSolids::TrdRead(const xercesc: 1088 void G4GDMLReadSolids::TrdRead(const xercesc::DOMElement* const trdElement) 2544 { 1089 { 2545 G4String name; << 1090 G4String name; 2546 G4double lunit = 1.0; << 1091 G4double lunit = 1.0; 2547 G4double x1 = 0.0; << 1092 G4double aunit = 1.0; 2548 G4double x2 = 0.0; << 1093 G4double x1 = 0.0; 2549 G4double y1 = 0.0; << 1094 G4double x2 = 0.0; 2550 G4double y2 = 0.0; << 1095 G4double y1 = 0.0; 2551 G4double z = 0.0; << 1096 G4double y2 = 0.0; 2552 << 1097 G4double z = 0.0; 2553 const xercesc::DOMNamedNodeMap* const attri << 1098 2554 trdElement->getAttributes(); << 1099 const xercesc::DOMNamedNodeMap* const attributes = trdElement->getAttributes(); 2555 XMLSize_t attributeCount = attributes->getL << 1100 XMLSize_t attributeCount = attributes->getLength(); 2556 << 1101 2557 for(XMLSize_t attribute_index = 0; attribut << 1102 for (XMLSize_t attribute_index=0; 2558 ++attribute_index) << 1103 attribute_index<attributeCount; attribute_index++) 2559 { << 1104 { 2560 xercesc::DOMNode* attribute_node = attrib << 1105 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 2561 << 1106 2562 if(attribute_node->getNodeType() != xerce << 1107 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 2563 { << 1108 { continue; } 2564 continue; << 1109 2565 } << 1110 const xercesc::DOMAttr* const attribute 2566 << 1111 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 2567 const xercesc::DOMAttr* const attribute = << 1112 const G4String attName = Transcode(attribute->getName()); 2568 dynamic_cast<xercesc::DOMAttr*>(attribu << 1113 const G4String attValue = Transcode(attribute->getValue()); 2569 if(attribute == nullptr) << 1114 2570 { << 1115 if (attName=="name") { name = GenerateName(attValue); } else 2571 G4Exception("G4GDMLReadSolids::TrdRead( << 1116 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 2572 "No attribute found!"); << 1117 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 2573 return; << 1118 if (attName=="x1") { x1 = eval.Evaluate(attValue); } else 2574 } << 1119 if (attName=="x2") { x2 = eval.Evaluate(attValue); } else 2575 const G4String attName = Transcode(attri << 1120 if (attName=="y1") { y1 = eval.Evaluate(attValue); } else 2576 const G4String attValue = Transcode(attri << 1121 if (attName=="y2") { y2 = eval.Evaluate(attValue); } else 2577 << 1122 if (attName=="z") { z = eval.Evaluate(attValue); } 2578 if(attName == "name") << 1123 } 2579 { << 1124 2580 name = GenerateName(attValue); << 1125 x1 *= 0.5*lunit; 2581 } << 1126 x2 *= 0.5*lunit; 2582 else if(attName == "lunit") << 1127 y1 *= 0.5*lunit; 2583 { << 1128 y2 *= 0.5*lunit; 2584 lunit = G4UnitDefinition::GetValueOf(at << 1129 z *= 0.5*lunit; 2585 if(G4UnitDefinition::GetCategory(attVal << 1130 2586 { << 1131 new G4Trd(name,x1,x2,y1,y2,z); 2587 G4Exception("G4GDMLReadSolids::TrdRea << 1132 } 2588 FatalException, "Invalid << 1133 2589 } << 1134 G4TriangularFacet* G4GDMLReadSolids:: 2590 } << 1135 TriangularRead(const xercesc::DOMElement* const triangularElement) 2591 else if(attName == "x1") << 1136 { 2592 { << 1137 G4ThreeVector vertex1; 2593 x1 = eval.Evaluate(attValue); << 1138 G4ThreeVector vertex2; 2594 } << 1139 G4ThreeVector vertex3; 2595 else if(attName == "x2") << 1140 G4FacetVertexType type = ABSOLUTE; 2596 { << 1141 2597 x2 = eval.Evaluate(attValue); << 1142 const xercesc::DOMNamedNodeMap* const attributes 2598 } << 1143 = triangularElement->getAttributes(); 2599 else if(attName == "y1") << 1144 XMLSize_t attributeCount = attributes->getLength(); 2600 { << 1145 2601 y1 = eval.Evaluate(attValue); << 1146 for (XMLSize_t attribute_index=0; 2602 } << 1147 attribute_index<attributeCount; attribute_index++) 2603 else if(attName == "y2") << 1148 { 2604 { << 1149 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 2605 y2 = eval.Evaluate(attValue); << 1150 2606 } << 1151 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 2607 else if(attName == "z") << 1152 { continue; } 2608 { << 1153 2609 z = eval.Evaluate(attValue); << 1154 const xercesc::DOMAttr* const attribute 2610 } << 1155 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 2611 } << 1156 const G4String attName = Transcode(attribute->getName()); 2612 << 1157 const G4String attValue = Transcode(attribute->getValue()); 2613 x1 *= 0.5 * lunit; << 1158 2614 x2 *= 0.5 * lunit; << 1159 if (attName=="vertex1") 2615 y1 *= 0.5 * lunit; << 1160 { vertex1 = GetPosition(GenerateName(attValue)); } else 2616 y2 *= 0.5 * lunit; << 1161 if (attName=="vertex2") 2617 z *= 0.5 * lunit; << 1162 { vertex2 = GetPosition(GenerateName(attValue)); } else >> 1163 if (attName=="vertex3") >> 1164 { vertex3 = GetPosition(GenerateName(attValue)); } else >> 1165 if (attName=="type") >> 1166 { if (attValue=="RELATIVE") { type = RELATIVE; } } >> 1167 } 2618 1168 2619 new G4Trd(name, x1, x2, y1, y2, z); << 1169 return new G4TriangularFacet(vertex1,vertex2,vertex3,type); 2620 } 1170 } 2621 1171 2622 // ------------------------------------------ << 2623 G4TriangularFacet* G4GDMLReadSolids::Triangul << 2624 const xercesc::DOMElement* const triangular << 2625 { << 2626 G4ThreeVector vertex1; << 2627 G4ThreeVector vertex2; << 2628 G4ThreeVector vertex3; << 2629 G4FacetVertexType type = ABSOLUTE; << 2630 G4double lunit = 1.0; << 2631 << 2632 const xercesc::DOMNamedNodeMap* const attri << 2633 triangularElement->getAttributes(); << 2634 XMLSize_t attributeCount = attributes->getL << 2635 << 2636 for(XMLSize_t attribute_index = 0; attribut << 2637 ++attribute_index) << 2638 { << 2639 xercesc::DOMNode* attribute_node = attrib << 2640 << 2641 if(attribute_node->getNodeType() != xerce << 2642 { << 2643 continue; << 2644 } << 2645 << 2646 const xercesc::DOMAttr* const attribute = << 2647 dynamic_cast<xercesc::DOMAttr*>(attribu << 2648 if(attribute == nullptr) << 2649 { << 2650 G4Exception("G4GDMLReadSolids::Triangul << 2651 FatalException, "No attribu << 2652 return nullptr; << 2653 } << 2654 const G4String attName = Transcode(attri << 2655 const G4String attValue = Transcode(attri << 2656 << 2657 if(attName == "vertex1") << 2658 { << 2659 vertex1 = GetPosition(GenerateName(attV << 2660 } << 2661 else if(attName == "vertex2") << 2662 { << 2663 vertex2 = GetPosition(GenerateName(attV << 2664 } << 2665 else if(attName == "vertex3") << 2666 { << 2667 vertex3 = GetPosition(GenerateName(attV << 2668 } << 2669 else if(attName == "lunit") << 2670 { << 2671 lunit = G4UnitDefinition::GetValueOf(at << 2672 if(G4UnitDefinition::GetCategory(attVal << 2673 { << 2674 G4Exception("G4GDMLReadSolids::Triang << 2675 FatalException, "Invalid << 2676 } << 2677 } << 2678 else if(attName == "type") << 2679 { << 2680 if(attValue == "RELATIVE") << 2681 { << 2682 type = RELATIVE; << 2683 } << 2684 } << 2685 } << 2686 << 2687 return new G4TriangularFacet(vertex1 * luni << 2688 vertex3 * luni << 2689 } << 2690 << 2691 // ------------------------------------------ << 2692 void G4GDMLReadSolids::TubeRead(const xercesc 1172 void G4GDMLReadSolids::TubeRead(const xercesc::DOMElement* const tubeElement) 2693 { 1173 { 2694 G4String name; << 1174 G4String name; 2695 G4double lunit = 1.0; << 1175 G4double lunit = 1.0; 2696 G4double aunit = 1.0; << 1176 G4double aunit = 1.0; 2697 G4double rmin = 0.0; << 1177 G4double rmin = 0.0; 2698 G4double rmax = 0.0; << 1178 G4double rmax = 0.0; 2699 G4double z = 0.0; << 1179 G4double z = 0.0; 2700 G4double startphi = 0.0; << 1180 G4double startphi = 0.0; 2701 G4double deltaphi = 0.0; << 1181 G4double deltaphi = 0.0; 2702 << 1182 2703 const xercesc::DOMNamedNodeMap* const attri << 1183 const xercesc::DOMNamedNodeMap* const attributes 2704 tubeElement->getAttributes(); << 1184 = tubeElement->getAttributes(); 2705 XMLSize_t attributeCount = attributes->getL << 1185 XMLSize_t attributeCount = attributes->getLength(); 2706 << 1186 2707 for(XMLSize_t attribute_index = 0; attribut << 1187 for (XMLSize_t attribute_index=0; 2708 ++attribute_index) << 1188 attribute_index<attributeCount; attribute_index++) 2709 { << 1189 { 2710 xercesc::DOMNode* attribute_node = attrib << 1190 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 2711 << 1191 2712 if(attribute_node->getNodeType() != xerce << 1192 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 2713 { << 1193 { continue; } 2714 continue; << 1194 2715 } << 1195 const xercesc::DOMAttr* const attribute 2716 << 1196 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 2717 const xercesc::DOMAttr* const attribute = << 1197 const G4String attName = Transcode(attribute->getName()); 2718 dynamic_cast<xercesc::DOMAttr*>(attribu << 1198 const G4String attValue = Transcode(attribute->getValue()); 2719 if(attribute == nullptr) << 1199 2720 { << 1200 if (attName=="name") { name = GenerateName(attValue); } else 2721 G4Exception("G4GDMLReadSolids::TubeRead << 1201 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else 2722 "No attribute found!"); << 1202 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else 2723 return; << 1203 if (attName=="rmin") { rmin = eval.Evaluate(attValue); } else 2724 } << 1204 if (attName=="rmax") { rmax = eval.Evaluate(attValue); } else 2725 const G4String attName = Transcode(attri << 1205 if (attName=="z") { z = eval.Evaluate(attValue); } else 2726 const G4String attValue = Transcode(attri << 1206 if (attName=="startphi") { startphi = eval.Evaluate(attValue); } else 2727 << 1207 if (attName=="deltaphi") { deltaphi = eval.Evaluate(attValue); } 2728 if(attName == "name") << 1208 } 2729 { << 1209 2730 name = GenerateName(attValue); << 1210 rmin *= lunit; 2731 } << 1211 rmax *= lunit; 2732 else if(attName == "lunit") << 1212 z *= 0.5*lunit; 2733 { << 1213 startphi *= aunit; 2734 lunit = G4UnitDefinition::GetValueOf(at << 1214 deltaphi *= aunit; 2735 if(G4UnitDefinition::GetCategory(attVal << 1215 2736 { << 1216 new G4Tubs(name,rmin,rmax,z,startphi,deltaphi); 2737 G4Exception("G4GDMLReadSolids::TubeRe << 1217 } 2738 FatalException, "Invalid << 1218 >> 1219 void G4GDMLReadSolids:: >> 1220 TwistedboxRead(const xercesc::DOMElement* const twistedboxElement) >> 1221 { >> 1222 G4String name; >> 1223 G4double lunit = 1.0; >> 1224 G4double aunit = 1.0; >> 1225 G4double PhiTwist = 0.0; >> 1226 G4double x = 0.0; >> 1227 G4double y = 0.0; >> 1228 G4double z = 0.0; >> 1229 >> 1230 const xercesc::DOMNamedNodeMap* const attributes >> 1231 = twistedboxElement->getAttributes(); >> 1232 XMLSize_t attributeCount = attributes->getLength(); >> 1233 >> 1234 for (XMLSize_t attribute_index=0; >> 1235 attribute_index<attributeCount; attribute_index++) >> 1236 { >> 1237 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); >> 1238 >> 1239 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) >> 1240 { continue; } >> 1241 >> 1242 const xercesc::DOMAttr* const attribute >> 1243 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); >> 1244 const G4String attName = Transcode(attribute->getName()); >> 1245 const G4String attValue = Transcode(attribute->getValue()); >> 1246 >> 1247 if (attName=="name") { name = GenerateName(attValue); } else >> 1248 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else >> 1249 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else >> 1250 if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else >> 1251 if (attName=="x") { x = eval.Evaluate(attValue); } else >> 1252 if (attName=="y") { y = eval.Evaluate(attValue); } else >> 1253 if (attName=="z") { z = eval.Evaluate(attValue); } >> 1254 } >> 1255 >> 1256 PhiTwist *= aunit; >> 1257 x *= 0.5*lunit; >> 1258 y *= 0.5*lunit; >> 1259 z *= 0.5*lunit; >> 1260 >> 1261 new G4TwistedBox(name,PhiTwist,x,y,z); >> 1262 } >> 1263 >> 1264 void G4GDMLReadSolids:: >> 1265 TwistedtrapRead(const xercesc::DOMElement* const twistedtrapElement) >> 1266 { >> 1267 G4String name; >> 1268 G4double lunit = 1.0; >> 1269 G4double aunit = 1.0; >> 1270 G4double PhiTwist = 0.0; >> 1271 G4double z = 0.0; >> 1272 G4double Theta = 0.0; >> 1273 G4double Phi = 0.0; >> 1274 G4double y1 = 0.0; >> 1275 G4double x1 = 0.0; >> 1276 G4double x2 = 0.0; >> 1277 G4double y2 = 0.0; >> 1278 G4double x3 = 0.0; >> 1279 G4double x4 = 0.0; >> 1280 G4double Alph = 0.0; >> 1281 >> 1282 const xercesc::DOMNamedNodeMap* const attributes >> 1283 = twistedtrapElement->getAttributes(); >> 1284 XMLSize_t attributeCount = attributes->getLength(); >> 1285 >> 1286 for (XMLSize_t attribute_index=0; >> 1287 attribute_index<attributeCount; attribute_index++) >> 1288 { >> 1289 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); >> 1290 >> 1291 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) >> 1292 { continue; } >> 1293 >> 1294 const xercesc::DOMAttr* const attribute >> 1295 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); >> 1296 const G4String attName = Transcode(attribute->getName()); >> 1297 const G4String attValue = Transcode(attribute->getValue()); >> 1298 >> 1299 if (attName=="name") { name = GenerateName(attValue); } else >> 1300 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else >> 1301 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else >> 1302 if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } else >> 1303 if (attName=="z") { z = eval.Evaluate(attValue); } else >> 1304 if (attName=="Theta") { Theta = eval.Evaluate(attValue); } else >> 1305 if (attName=="Phi") { Phi = eval.Evaluate(attValue); } else >> 1306 if (attName=="y1") { y1 = eval.Evaluate(attValue); } else >> 1307 if (attName=="x1") { x1 = eval.Evaluate(attValue); } else >> 1308 if (attName=="x2") { x2 = eval.Evaluate(attValue); } else >> 1309 if (attName=="y2") { y2 = eval.Evaluate(attValue); } else >> 1310 if (attName=="x3") { x3 = eval.Evaluate(attValue); } else >> 1311 if (attName=="x4") { x4 = eval.Evaluate(attValue); } else >> 1312 if (attName=="Alph") { Alph = eval.Evaluate(attValue); } >> 1313 } >> 1314 >> 1315 >> 1316 PhiTwist *= aunit; >> 1317 z *= 0.5*lunit; >> 1318 Theta *= aunit; >> 1319 Phi *= aunit; >> 1320 Alph *= aunit; >> 1321 y1 *= 0.5*lunit; >> 1322 x1 *= 0.5*lunit; >> 1323 x2 *= 0.5*lunit; >> 1324 y2 *= 0.5*lunit; >> 1325 x3 *= 0.5*lunit; >> 1326 x4 *= 0.5*lunit; >> 1327 >> 1328 new G4TwistedTrap(name,PhiTwist,z,Theta,Phi,y1,x1,x2,y2,x3,x4,Alph); >> 1329 } >> 1330 >> 1331 void G4GDMLReadSolids:: >> 1332 TwistedtrdRead(const xercesc::DOMElement* const twistedtrdElement) >> 1333 { >> 1334 G4String name; >> 1335 G4double lunit = 1.0; >> 1336 G4double aunit = 1.0; >> 1337 G4double x1 = 0.0; >> 1338 G4double x2 = 0.0; >> 1339 G4double y1 = 0.0; >> 1340 G4double y2 = 0.0; >> 1341 G4double z = 0.0; >> 1342 G4double PhiTwist = 0.0; >> 1343 >> 1344 const xercesc::DOMNamedNodeMap* const attributes >> 1345 = twistedtrdElement->getAttributes(); >> 1346 XMLSize_t attributeCount = attributes->getLength(); >> 1347 >> 1348 for (XMLSize_t attribute_index=0; >> 1349 attribute_index<attributeCount; attribute_index++) >> 1350 { >> 1351 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); >> 1352 >> 1353 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) >> 1354 { continue; } >> 1355 >> 1356 const xercesc::DOMAttr* const attribute >> 1357 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); >> 1358 const G4String attName = Transcode(attribute->getName()); >> 1359 const G4String attValue = Transcode(attribute->getValue()); >> 1360 >> 1361 if (attName=="name") { name = GenerateName(attValue); } else >> 1362 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else >> 1363 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else >> 1364 if (attName=="x1") { x1 = eval.Evaluate(attValue); } else >> 1365 if (attName=="x2") { x2 = eval.Evaluate(attValue); } else >> 1366 if (attName=="y1") { y1 = eval.Evaluate(attValue); } else >> 1367 if (attName=="y2") { y2 = eval.Evaluate(attValue); } else >> 1368 if (attName=="z") { z = eval.Evaluate(attValue); } else >> 1369 if (attName=="PhiTwist") { PhiTwist = eval.Evaluate(attValue); } >> 1370 } >> 1371 >> 1372 x1 *= 0.5*lunit; >> 1373 x2 *= 0.5*lunit; >> 1374 y1 *= 0.5*lunit; >> 1375 y2 *= 0.5*lunit; >> 1376 z *= 0.5*lunit; >> 1377 PhiTwist *= aunit; >> 1378 >> 1379 new G4TwistedTrd(name,x1,x2,y1,y2,z,PhiTwist); >> 1380 } >> 1381 >> 1382 void G4GDMLReadSolids:: >> 1383 TwistedtubsRead(const xercesc::DOMElement* const twistedtubsElement) >> 1384 { >> 1385 G4String name; >> 1386 G4double lunit = 1.0; >> 1387 G4double aunit = 1.0; >> 1388 G4double twistedangle = 0.0; >> 1389 G4double endinnerrad = 0.0; >> 1390 G4double endouterrad = 0.0; >> 1391 G4double zlen = 0.0; >> 1392 G4double phi = 0.0; >> 1393 >> 1394 const xercesc::DOMNamedNodeMap* const attributes >> 1395 = twistedtubsElement->getAttributes(); >> 1396 XMLSize_t attributeCount = attributes->getLength(); >> 1397 >> 1398 for (XMLSize_t attribute_index=0; >> 1399 attribute_index<attributeCount; attribute_index++) >> 1400 { >> 1401 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); >> 1402 >> 1403 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) >> 1404 { continue; } >> 1405 >> 1406 const xercesc::DOMAttr* const attribute >> 1407 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); >> 1408 const G4String attName = Transcode(attribute->getName()); >> 1409 const G4String attValue = Transcode(attribute->getValue()); >> 1410 >> 1411 if (attName=="name") { name = GenerateName(attValue); } else >> 1412 if (attName=="lunit") { lunit = eval.Evaluate(attValue); } else >> 1413 if (attName=="aunit") { aunit = eval.Evaluate(attValue); } else >> 1414 if (attName=="twistedangle") { twistedangle=eval.Evaluate(attValue); } else >> 1415 if (attName=="endinnerrad") { endinnerrad=eval.Evaluate(attValue); } else >> 1416 if (attName=="endouterrad") { endouterrad=eval.Evaluate(attValue); } else >> 1417 if (attName=="zlen") { zlen = eval.Evaluate(attValue); } else >> 1418 if (attName=="phi") { phi = eval.Evaluate(attValue); } >> 1419 } >> 1420 >> 1421 twistedangle *= aunit; >> 1422 endinnerrad *= lunit; >> 1423 endouterrad *= lunit; >> 1424 zlen *= 0.5*lunit; >> 1425 phi *= aunit; >> 1426 >> 1427 new G4TwistedTubs(name,twistedangle,endinnerrad,endouterrad,zlen,phi); >> 1428 } >> 1429 >> 1430 G4TwoVector G4GDMLReadSolids:: >> 1431 TwoDimVertexRead(const xercesc::DOMElement* const element, G4double lunit) >> 1432 { >> 1433 G4TwoVector vec; >> 1434 >> 1435 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); >> 1436 XMLSize_t attributeCount = attributes->getLength(); >> 1437 >> 1438 for (XMLSize_t attribute_index=0; >> 1439 attribute_index<attributeCount; attribute_index++) >> 1440 { >> 1441 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); >> 1442 >> 1443 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) >> 1444 { continue; } >> 1445 >> 1446 const xercesc::DOMAttr* const attribute >> 1447 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); >> 1448 const G4String attName = Transcode(attribute->getName()); >> 1449 const G4String attValue = Transcode(attribute->getValue()); >> 1450 >> 1451 if (attName=="x") { vec.setX(eval.Evaluate(attValue)*lunit); } else >> 1452 if (attName=="y") { vec.setY(eval.Evaluate(attValue)*lunit); } >> 1453 } >> 1454 >> 1455 return vec; >> 1456 } >> 1457 >> 1458 G4GDMLReadSolids::zplaneType G4GDMLReadSolids:: >> 1459 ZplaneRead(const xercesc::DOMElement* const zplaneElement) >> 1460 { >> 1461 zplaneType zplane; >> 1462 >> 1463 const xercesc::DOMNamedNodeMap* const attributes >> 1464 = zplaneElement->getAttributes(); >> 1465 XMLSize_t attributeCount = attributes->getLength(); >> 1466 >> 1467 for (XMLSize_t attribute_index=0; >> 1468 attribute_index<attributeCount; attribute_index++) >> 1469 { >> 1470 xercesc::DOMNode* node = attributes->item(attribute_index); >> 1471 >> 1472 if (node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) { continue; } >> 1473 >> 1474 const xercesc::DOMAttr* const attribute >> 1475 = dynamic_cast<xercesc::DOMAttr*>(node); >> 1476 const G4String attName = Transcode(attribute->getName()); >> 1477 const G4String attValue = Transcode(attribute->getValue()); >> 1478 >> 1479 if (attName=="rmin") { zplane.rmin = eval.Evaluate(attValue); } else >> 1480 if (attName=="rmax") { zplane.rmax = eval.Evaluate(attValue); } else >> 1481 if (attName=="z") { zplane.z = eval.Evaluate(attValue); } >> 1482 } >> 1483 >> 1484 return zplane; >> 1485 } >> 1486 >> 1487 void G4GDMLReadSolids:: >> 1488 OpticalsurfaceRead(const xercesc::DOMElement* const opticalsurfaceElement) >> 1489 { >> 1490 G4String name; >> 1491 G4String smodel; >> 1492 G4String sfinish; >> 1493 G4String stype; >> 1494 G4double value = 0.0; >> 1495 >> 1496 const xercesc::DOMNamedNodeMap* const attributes >> 1497 = opticalsurfaceElement->getAttributes(); >> 1498 XMLSize_t attributeCount = attributes->getLength(); >> 1499 >> 1500 for (XMLSize_t attribute_index=0; >> 1501 attribute_index<attributeCount; attribute_index++) >> 1502 { >> 1503 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); >> 1504 >> 1505 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) >> 1506 { continue; } >> 1507 >> 1508 const xercesc::DOMAttr* const attribute >> 1509 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); >> 1510 const G4String attName = Transcode(attribute->getName()); >> 1511 const G4String attValue = Transcode(attribute->getValue()); >> 1512 >> 1513 if (attName=="name") { name = GenerateName(attValue); } else >> 1514 if (attName=="model") { smodel = attValue; } else >> 1515 if (attName=="finish") { sfinish = attValue; } else >> 1516 if (attName=="type") { stype = attValue; } else >> 1517 if (attName=="value") { value = eval.Evaluate(attValue); } >> 1518 } >> 1519 >> 1520 G4OpticalSurfaceModel model; >> 1521 G4OpticalSurfaceFinish finish; >> 1522 G4SurfaceType type; >> 1523 >> 1524 if (smodel="unified") { model = unified; } else { model = glisur; } >> 1525 >> 1526 if (sfinish=="polishedfrontpainted") { finish = polishedfrontpainted; } else >> 1527 if (sfinish=="polishedbackpainted") { finish = polishedbackpainted; } else >> 1528 if (sfinish=="groundfrontpainted") { finish = groundfrontpainted; } else >> 1529 if (sfinish=="groundbackpainted") { finish = groundbackpainted; } else >> 1530 if (sfinish=="ground") { finish = ground; } else { finish = polished; } >> 1531 >> 1532 if (stype=="dielectric_metal") { type = dielectric_metal; } else >> 1533 if (stype=="x_ray") { type = x_ray; } else >> 1534 if (stype=="firsov") { type = firsov; } else { type = dielectric_dielectric; } >> 1535 >> 1536 new G4OpticalSurface(name,model,finish,type,value); >> 1537 } >> 1538 >> 1539 void G4GDMLReadSolids::SolidsRead(const xercesc::DOMElement* const solidsElement) >> 1540 { >> 1541 G4cout << "G4GDML: Reading solids..." << G4endl; >> 1542 >> 1543 for (xercesc::DOMNode* iter = solidsElement->getFirstChild(); >> 1544 iter != 0; iter = iter->getNextSibling()) >> 1545 { >> 1546 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } >> 1547 >> 1548 const xercesc::DOMElement* const child >> 1549 = dynamic_cast<xercesc::DOMElement*>(iter); >> 1550 const G4String tag = Transcode(child->getTagName()); >> 1551 if (tag=="define") { DefineRead(child); } else >> 1552 if (tag=="box") { BoxRead(child); } else >> 1553 if (tag=="cone") { ConeRead(child); } else >> 1554 if (tag=="elcone") { ElconeRead(child); } else >> 1555 if (tag=="ellipsoid") { EllipsoidRead(child); }else >> 1556 if (tag=="eltube") { EltubeRead(child); } else >> 1557 if (tag=="xtru") { XtruRead(child); } else >> 1558 if (tag=="hype") { HypeRead(child); } else >> 1559 if (tag=="intersection") { BooleanRead(child,INTERSECTION); } else >> 1560 if (tag=="orb") { OrbRead(child); } else >> 1561 if (tag=="para") { ParaRead(child); } else >> 1562 if (tag=="paraboloid") { ParaboloidRead(child); } else >> 1563 if (tag=="polycone") { PolyconeRead(child); } else >> 1564 if (tag=="polyhedra") { PolyhedraRead(child); } else >> 1565 if (tag=="reflectedSolid") { ReflectedSolidRead(child); } else >> 1566 if (tag=="sphere") { SphereRead(child); } else >> 1567 if (tag=="subtraction") { BooleanRead(child,SUBTRACTION); } else >> 1568 if (tag=="tessellated") { TessellatedRead(child); } else >> 1569 if (tag=="tet") { TetRead(child); } else >> 1570 if (tag=="torus") { TorusRead(child); } else >> 1571 if (tag=="trap") { TrapRead(child); } else >> 1572 if (tag=="trd") { TrdRead(child); } else >> 1573 if (tag=="tube") { TubeRead(child); } else >> 1574 if (tag=="twistedbox") { TwistedboxRead(child); } else >> 1575 if (tag=="twistedtrap") { TwistedtrapRead(child); } else >> 1576 if (tag=="twistedtrd") { TwistedtrdRead(child); } else >> 1577 if (tag=="twistedtubs") { TwistedtubsRead(child); } else >> 1578 if (tag=="union") { BooleanRead(child,UNION); } else >> 1579 if (tag=="opticalsurface") { OpticalsurfaceRead(child); } else >> 1580 if (tag=="loop") { LoopRead(child,&G4GDMLRead::SolidsRead); } >> 1581 else >> 1582 { >> 1583 G4String error_msg = "Unknown tag in solids: " + tag; >> 1584 G4Exception("G4GDMLReadSolids::SolidsRead()", "ReadError", >> 1585 FatalException, error_msg); 2739 } 1586 } 2740 } << 1587 } 2741 else if(attName == "aunit") << 2742 { << 2743 aunit = G4UnitDefinition::GetValueOf(at << 2744 if(G4UnitDefinition::GetCategory(attVal << 2745 { << 2746 G4Exception("G4GDMLReadSolids::TubeRe << 2747 FatalException, "Invalid << 2748 } << 2749 } << 2750 else if(attName == "rmin") << 2751 { << 2752 rmin = eval.Evaluate(attValue); << 2753 } << 2754 else if(attName == "rmax") << 2755 { << 2756 rmax = eval.Evaluate(attValue); << 2757 } << 2758 else if(attName == "z") << 2759 { << 2760 z = eval.Evaluate(attValue); << 2761 } << 2762 else if(attName == "startphi") << 2763 { << 2764 startphi = eval.Evaluate(attValue); << 2765 } << 2766 else if(attName == "deltaphi") << 2767 { << 2768 deltaphi = eval.Evaluate(attValue); << 2769 } << 2770 } << 2771 << 2772 rmin *= lunit; << 2773 rmax *= lunit; << 2774 z *= 0.5 * lunit; << 2775 startphi *= aunit; << 2776 deltaphi *= aunit; << 2777 << 2778 new G4Tubs(name, rmin, rmax, z, startphi, d << 2779 } << 2780 << 2781 // ------------------------------------------ << 2782 void G4GDMLReadSolids::CutTubeRead( << 2783 const xercesc::DOMElement* const cuttubeEle << 2784 { << 2785 G4String name; << 2786 G4double lunit = 1.0; << 2787 G4double aunit = 1.0; << 2788 G4double rmin = 0.0; << 2789 G4double rmax = 0.0; << 2790 G4double z = 0.0; << 2791 G4double startphi = 0.0; << 2792 G4double deltaphi = 0.0; << 2793 G4ThreeVector lowNorm(0); << 2794 G4ThreeVector highNorm(0); << 2795 << 2796 const xercesc::DOMNamedNodeMap* const attri << 2797 cuttubeElement->getAttributes(); << 2798 XMLSize_t attributeCount = attributes->getL << 2799 << 2800 for(XMLSize_t attribute_index = 0; attribut << 2801 ++attribute_index) << 2802 { << 2803 xercesc::DOMNode* attribute_node = attrib << 2804 << 2805 if(attribute_node->getNodeType() != xerce << 2806 { << 2807 continue; << 2808 } << 2809 << 2810 const xercesc::DOMAttr* const attribute = << 2811 dynamic_cast<xercesc::DOMAttr*>(attribu << 2812 if(attribute == nullptr) << 2813 { << 2814 G4Exception("G4GDMLReadSolids::CutTubeR << 2815 FatalException, "No attribu << 2816 return; << 2817 } << 2818 const G4String attName = Transcode(attri << 2819 const G4String attValue = Transcode(attri << 2820 << 2821 if(attName == "name") << 2822 { << 2823 name = GenerateName(attValue); << 2824 } << 2825 else if(attName == "lunit") << 2826 { << 2827 lunit = G4UnitDefinition::GetValueOf(at << 2828 if(G4UnitDefinition::GetCategory(attVal << 2829 { << 2830 G4Exception("G4GDMLReadSolids::CutTub << 2831 FatalException, "Invalid << 2832 } << 2833 } << 2834 else if(attName == "aunit") << 2835 { << 2836 aunit = G4UnitDefinition::GetValueOf(at << 2837 if(G4UnitDefinition::GetCategory(attVal << 2838 { << 2839 G4Exception("G4GDMLReadSolids::CutTub << 2840 FatalException, "Invalid << 2841 } << 2842 } << 2843 else if(attName == "rmin") << 2844 { << 2845 rmin = eval.Evaluate(attValue); << 2846 } << 2847 else if(attName == "rmax") << 2848 { << 2849 rmax = eval.Evaluate(attValue); << 2850 } << 2851 else if(attName == "z") << 2852 { << 2853 z = eval.Evaluate(attValue); << 2854 } << 2855 else if(attName == "startphi") << 2856 { << 2857 startphi = eval.Evaluate(attValue); << 2858 } << 2859 else if(attName == "deltaphi") << 2860 { << 2861 deltaphi = eval.Evaluate(attValue); << 2862 } << 2863 else if(attName == "lowX") << 2864 { << 2865 lowNorm.setX(eval.Evaluate(attValue)); << 2866 } << 2867 else if(attName == "lowY") << 2868 { << 2869 lowNorm.setY(eval.Evaluate(attValue)); << 2870 } << 2871 else if(attName == "lowZ") << 2872 { << 2873 lowNorm.setZ(eval.Evaluate(attValue)); << 2874 } << 2875 else if(attName == "highX") << 2876 { << 2877 highNorm.setX(eval.Evaluate(attValue)); << 2878 } << 2879 else if(attName == "highY") << 2880 { << 2881 highNorm.setY(eval.Evaluate(attValue)); << 2882 } << 2883 else if(attName == "highZ") << 2884 { << 2885 highNorm.setZ(eval.Evaluate(attValue)); << 2886 } << 2887 } << 2888 << 2889 rmin *= lunit; << 2890 rmax *= lunit; << 2891 z *= 0.5 * lunit; << 2892 startphi *= aunit; << 2893 deltaphi *= aunit; << 2894 << 2895 new G4CutTubs(name, rmin, rmax, z, startphi << 2896 } 1588 } 2897 1589 2898 // ------------------------------------------ << 1590 G4VSolid* G4GDMLReadSolids::GetSolid(const G4String& ref) const 2899 void G4GDMLReadSolids::TwistedboxRead( << 2900 const xercesc::DOMElement* const twistedbox << 2901 { << 2902 G4String name; << 2903 G4double lunit = 1.0; << 2904 G4double aunit = 1.0; << 2905 G4double PhiTwist = 0.0; << 2906 G4double x = 0.0; << 2907 G4double y = 0.0; << 2908 G4double z = 0.0; << 2909 << 2910 const xercesc::DOMNamedNodeMap* const attri << 2911 twistedboxElement->getAttributes(); << 2912 XMLSize_t attributeCount = attributes->getL << 2913 << 2914 for(XMLSize_t attribute_index = 0; attribut << 2915 ++attribute_index) << 2916 { << 2917 xercesc::DOMNode* attribute_node = attrib << 2918 << 2919 if(attribute_node->getNodeType() != xerce << 2920 { << 2921 continue; << 2922 } << 2923 << 2924 const xercesc::DOMAttr* const attribute = << 2925 dynamic_cast<xercesc::DOMAttr*>(attribu << 2926 if(attribute == nullptr) << 2927 { << 2928 G4Exception("G4GDMLReadSolids::Twistedb << 2929 FatalException, "No attribu << 2930 return; << 2931 } << 2932 const G4String attName = Transcode(attri << 2933 const G4String attValue = Transcode(attri << 2934 << 2935 if(attName == "name") << 2936 { << 2937 name = GenerateName(attValue); << 2938 } << 2939 else if(attName == "lunit") << 2940 { << 2941 lunit = G4UnitDefinition::GetValueOf(at << 2942 if(G4UnitDefinition::GetCategory(attVal << 2943 { << 2944 G4Exception("G4GDMLReadSolids::Twiste << 2945 FatalException, "Invalid << 2946 } << 2947 } << 2948 else if(attName == "aunit") << 2949 { << 2950 aunit = G4UnitDefinition::GetValueOf(at << 2951 if(G4UnitDefinition::GetCategory(attVal << 2952 { << 2953 G4Exception("G4GDMLReadSolids::Twiste << 2954 FatalException, "Invalid << 2955 } << 2956 } << 2957 else if(attName == "PhiTwist") << 2958 { << 2959 PhiTwist = eval.Evaluate(attValue); << 2960 } << 2961 else if(attName == "x") << 2962 { << 2963 x = eval.Evaluate(attValue); << 2964 } << 2965 else if(attName == "y") << 2966 { << 2967 y = eval.Evaluate(attValue); << 2968 } << 2969 else if(attName == "z") << 2970 { << 2971 z = eval.Evaluate(attValue); << 2972 } << 2973 } << 2974 << 2975 PhiTwist *= aunit; << 2976 x *= 0.5 * lunit; << 2977 y *= 0.5 * lunit; << 2978 z *= 0.5 * lunit; << 2979 << 2980 new G4TwistedBox(name, PhiTwist, x, y, z); << 2981 } << 2982 << 2983 // ------------------------------------------ << 2984 void G4GDMLReadSolids::TwistedtrapRead( << 2985 const xercesc::DOMElement* const twistedtra << 2986 { << 2987 G4String name; << 2988 G4double lunit = 1.0; << 2989 G4double aunit = 1.0; << 2990 G4double PhiTwist = 0.0; << 2991 G4double z = 0.0; << 2992 G4double Theta = 0.0; << 2993 G4double Phi = 0.0; << 2994 G4double y1 = 0.0; << 2995 G4double x1 = 0.0; << 2996 G4double x2 = 0.0; << 2997 G4double y2 = 0.0; << 2998 G4double x3 = 0.0; << 2999 G4double x4 = 0.0; << 3000 G4double Alph = 0.0; << 3001 << 3002 const xercesc::DOMNamedNodeMap* const attri << 3003 twistedtrapElement->getAttributes(); << 3004 XMLSize_t attributeCount = attributes->getL << 3005 << 3006 for(XMLSize_t attribute_index = 0; attribut << 3007 ++attribute_index) << 3008 { << 3009 xercesc::DOMNode* attribute_node = attrib << 3010 << 3011 if(attribute_node->getNodeType() != xerce << 3012 { << 3013 continue; << 3014 } << 3015 << 3016 const xercesc::DOMAttr* const attribute = << 3017 dynamic_cast<xercesc::DOMAttr*>(attribu << 3018 if(attribute == nullptr) << 3019 { << 3020 G4Exception("G4GDMLReadSolids::Twistedt << 3021 FatalException, "No attribu << 3022 return; << 3023 } << 3024 const G4String attName = Transcode(attri << 3025 const G4String attValue = Transcode(attri << 3026 << 3027 if(attName == "name") << 3028 { << 3029 name = GenerateName(attValue); << 3030 } << 3031 else if(attName == "lunit") << 3032 { << 3033 lunit = G4UnitDefinition::GetValueOf(at << 3034 if(G4UnitDefinition::GetCategory(attVal << 3035 { << 3036 G4Exception("G4GDMLReadSolids::Twiste << 3037 FatalException, "Invalid << 3038 } << 3039 } << 3040 else if(attName == "aunit") << 3041 { << 3042 aunit = G4UnitDefinition::GetValueOf(at << 3043 if(G4UnitDefinition::GetCategory(attVal << 3044 { << 3045 G4Exception("G4GDMLReadSolids::Twiste << 3046 FatalException, "Invalid << 3047 } << 3048 } << 3049 else if(attName == "PhiTwist") << 3050 { << 3051 PhiTwist = eval.Evaluate(attValue); << 3052 } << 3053 else if(attName == "z") << 3054 { << 3055 z = eval.Evaluate(attValue); << 3056 } << 3057 else if(attName == "Theta") << 3058 { << 3059 Theta = eval.Evaluate(attValue); << 3060 } << 3061 else if(attName == "Phi") << 3062 { << 3063 Phi = eval.Evaluate(attValue); << 3064 } << 3065 else if(attName == "y1") << 3066 { << 3067 y1 = eval.Evaluate(attValue); << 3068 } << 3069 else if(attName == "x1") << 3070 { << 3071 x1 = eval.Evaluate(attValue); << 3072 } << 3073 else if(attName == "x2") << 3074 { << 3075 x2 = eval.Evaluate(attValue); << 3076 } << 3077 else if(attName == "y2") << 3078 { << 3079 y2 = eval.Evaluate(attValue); << 3080 } << 3081 else if(attName == "x3") << 3082 { << 3083 x3 = eval.Evaluate(attValue); << 3084 } << 3085 else if(attName == "x4") << 3086 { << 3087 x4 = eval.Evaluate(attValue); << 3088 } << 3089 else if(attName == "Alph") << 3090 { << 3091 Alph = eval.Evaluate(attValue); << 3092 } << 3093 } << 3094 << 3095 PhiTwist *= aunit; << 3096 z *= 0.5 * lunit; << 3097 Theta *= aunit; << 3098 Phi *= aunit; << 3099 Alph *= aunit; << 3100 y1 *= 0.5 * lunit; << 3101 x1 *= 0.5 * lunit; << 3102 x2 *= 0.5 * lunit; << 3103 y2 *= 0.5 * lunit; << 3104 x3 *= 0.5 * lunit; << 3105 x4 *= 0.5 * lunit; << 3106 << 3107 new G4TwistedTrap(name, PhiTwist, z, Theta, << 3108 Alph); << 3109 } << 3110 << 3111 // ------------------------------------------ << 3112 void G4GDMLReadSolids::TwistedtrdRead( << 3113 const xercesc::DOMElement* const twistedtrd << 3114 { << 3115 G4String name; << 3116 G4double lunit = 1.0; << 3117 G4double aunit = 1.0; << 3118 G4double x1 = 0.0; << 3119 G4double x2 = 0.0; << 3120 G4double y1 = 0.0; << 3121 G4double y2 = 0.0; << 3122 G4double z = 0.0; << 3123 G4double PhiTwist = 0.0; << 3124 << 3125 const xercesc::DOMNamedNodeMap* const attri << 3126 twistedtrdElement->getAttributes(); << 3127 XMLSize_t attributeCount = attributes->getL << 3128 << 3129 for(XMLSize_t attribute_index = 0; attribut << 3130 ++attribute_index) << 3131 { << 3132 xercesc::DOMNode* attribute_node = attrib << 3133 << 3134 if(attribute_node->getNodeType() != xerce << 3135 { << 3136 continue; << 3137 } << 3138 << 3139 const xercesc::DOMAttr* const attribute = << 3140 dynamic_cast<xercesc::DOMAttr*>(attribu << 3141 if(attribute == nullptr) << 3142 { << 3143 G4Exception("G4GDMLReadSolids::Twistedt << 3144 FatalException, "No attribu << 3145 return; << 3146 } << 3147 const G4String attName = Transcode(attri << 3148 const G4String attValue = Transcode(attri << 3149 << 3150 if(attName == "name") << 3151 { << 3152 name = GenerateName(attValue); << 3153 } << 3154 else if(attName == "lunit") << 3155 { << 3156 lunit = G4UnitDefinition::GetValueOf(at << 3157 if(G4UnitDefinition::GetCategory(attVal << 3158 { << 3159 G4Exception("G4GDMLReadSolids::Twiste << 3160 FatalException, "Invalid << 3161 } << 3162 } << 3163 else if(attName == "aunit") << 3164 { << 3165 aunit = G4UnitDefinition::GetValueOf(at << 3166 if(G4UnitDefinition::GetCategory(attVal << 3167 { << 3168 G4Exception("G4GDMLReadSolids::Twiste << 3169 FatalException, "Invalid << 3170 } << 3171 } << 3172 else if(attName == "x1") << 3173 { << 3174 x1 = eval.Evaluate(attValue); << 3175 } << 3176 else if(attName == "x2") << 3177 { << 3178 x2 = eval.Evaluate(attValue); << 3179 } << 3180 else if(attName == "y1") << 3181 { << 3182 y1 = eval.Evaluate(attValue); << 3183 } << 3184 else if(attName == "y2") << 3185 { << 3186 y2 = eval.Evaluate(attValue); << 3187 } << 3188 else if(attName == "z") << 3189 { << 3190 z = eval.Evaluate(attValue); << 3191 } << 3192 else if(attName == "PhiTwist") << 3193 { << 3194 PhiTwist = eval.Evaluate(attValue); << 3195 } << 3196 } << 3197 << 3198 x1 *= 0.5 * lunit; << 3199 x2 *= 0.5 * lunit; << 3200 y1 *= 0.5 * lunit; << 3201 y2 *= 0.5 * lunit; << 3202 z *= 0.5 * lunit; << 3203 PhiTwist *= aunit; << 3204 << 3205 new G4TwistedTrd(name, x1, x2, y1, y2, z, P << 3206 } << 3207 << 3208 // ------------------------------------------ << 3209 void G4GDMLReadSolids::TwistedtubsRead( << 3210 const xercesc::DOMElement* const twistedtub << 3211 { << 3212 G4String name; << 3213 G4double lunit = 1.0; << 3214 G4double aunit = 1.0; << 3215 G4double twistedangle = 0.0; << 3216 G4double endinnerrad = 0.0; << 3217 G4double endouterrad = 0.0; << 3218 G4double zlen = 0.0; << 3219 G4double phi = 0.0; << 3220 G4double totphi = 0.0; << 3221 G4double midinnerrad = 0.0; << 3222 G4double midouterrad = 0.0; << 3223 G4double positiveEndz = 0.0; << 3224 G4double negativeEndz = 0.0; << 3225 G4int nseg = 0; << 3226 << 3227 const xercesc::DOMNamedNodeMap* const attri << 3228 twistedtubsElement->getAttributes(); << 3229 XMLSize_t attributeCount = attributes->getL << 3230 << 3231 for(XMLSize_t attribute_index = 0; attribut << 3232 ++attribute_index) << 3233 { << 3234 xercesc::DOMNode* attribute_node = attrib << 3235 << 3236 if(attribute_node->getNodeType() != xerce << 3237 { << 3238 continue; << 3239 } << 3240 << 3241 const xercesc::DOMAttr* const attribute = << 3242 dynamic_cast<xercesc::DOMAttr*>(attribu << 3243 if(attribute == nullptr) << 3244 { << 3245 G4Exception("G4GDMLReadSolids::Twistedt << 3246 FatalException, "No attribu << 3247 return; << 3248 } << 3249 const G4String attName = Transcode(attri << 3250 const G4String attValue = Transcode(attri << 3251 << 3252 if(attName == "name") << 3253 { << 3254 name = GenerateName(attValue); << 3255 } << 3256 else if(attName == "lunit") << 3257 { << 3258 lunit = G4UnitDefinition::GetValueOf(at << 3259 if(G4UnitDefinition::GetCategory(attVal << 3260 { << 3261 G4Exception("G4GDMLReadSolids::Twiste << 3262 FatalException, "Invalid << 3263 } << 3264 } << 3265 else if(attName == "aunit") << 3266 { << 3267 aunit = G4UnitDefinition::GetValueOf(at << 3268 if(G4UnitDefinition::GetCategory(attVal << 3269 { << 3270 G4Exception("G4GDMLReadSolids::Twiste << 3271 FatalException, "Invalid << 3272 } << 3273 } << 3274 else if(attName == "twistedangle") << 3275 { << 3276 twistedangle = eval.Evaluate(attValue); << 3277 } << 3278 else if(attName == "endinnerrad") << 3279 { << 3280 endinnerrad = eval.Evaluate(attValue); << 3281 } << 3282 else if(attName == "endouterrad") << 3283 { << 3284 endouterrad = eval.Evaluate(attValue); << 3285 } << 3286 else if(attName == "zlen") << 3287 { << 3288 zlen = eval.Evaluate(attValue); << 3289 } << 3290 else if(attName == "midinnerrad") << 3291 { << 3292 midinnerrad = eval.Evaluate(attValue); << 3293 } << 3294 else if(attName == "midouterrad") << 3295 { << 3296 midouterrad = eval.Evaluate(attValue); << 3297 } << 3298 else if(attName == "negativeEndz") << 3299 { << 3300 negativeEndz = eval.Evaluate(attValue); << 3301 } << 3302 else if(attName == "positiveEndz") << 3303 { << 3304 positiveEndz = eval.Evaluate(attValue); << 3305 } << 3306 else if(attName == "nseg") << 3307 { << 3308 nseg = eval.Evaluate(attValue); << 3309 } << 3310 else if(attName == "totphi") << 3311 { << 3312 totphi = eval.Evaluate(attValue); << 3313 } << 3314 else if(attName == "phi") << 3315 { << 3316 phi = eval.Evaluate(attValue); << 3317 } << 3318 } << 3319 << 3320 twistedangle *= aunit; << 3321 endinnerrad *= lunit; << 3322 endouterrad *= lunit; << 3323 zlen *= 0.5 * lunit; << 3324 midinnerrad *= lunit; << 3325 midouterrad *= lunit; << 3326 positiveEndz *= lunit; << 3327 negativeEndz *= lunit; << 3328 phi *= aunit; << 3329 totphi *= aunit; << 3330 << 3331 if(zlen != 0.0) << 3332 { << 3333 if(nseg != 0) << 3334 new G4TwistedTubs(name, twistedangle, e << 3335 nseg, totphi); << 3336 else << 3337 new G4TwistedTubs(name, twistedangle, e << 3338 phi); << 3339 } << 3340 else << 3341 { << 3342 if(nseg != 0) << 3343 new G4TwistedTubs(name, twistedangle, m << 3344 negativeEndz, positiv << 3345 else << 3346 new G4TwistedTubs(name, twistedangle, m << 3347 negativeEndz, positiv << 3348 } << 3349 } << 3350 << 3351 // ------------------------------------------ << 3352 G4TwoVector G4GDMLReadSolids::TwoDimVertexRea << 3353 const xercesc::DOMElement* const element, G << 3354 { << 3355 G4TwoVector vec; << 3356 << 3357 const xercesc::DOMNamedNodeMap* const attri << 3358 XMLSize_t attributeCount << 3359 << 3360 for(XMLSize_t attribute_index = 0; attribut << 3361 ++attribute_index) << 3362 { << 3363 xercesc::DOMNode* attribute_node = attrib << 3364 << 3365 if(attribute_node->getNodeType() != xerce << 3366 { << 3367 continue; << 3368 } << 3369 << 3370 const xercesc::DOMAttr* const attribute = << 3371 dynamic_cast<xercesc::DOMAttr*>(attribu << 3372 if(attribute == nullptr) << 3373 { << 3374 G4Exception("G4GDMLReadSolids::TwoDimVe << 3375 FatalException, "No attribu << 3376 return vec; << 3377 } << 3378 const G4String attName = Transcode(attri << 3379 const G4String attValue = Transcode(attri << 3380 << 3381 if(attName == "x") << 3382 { << 3383 vec.setX(eval.Evaluate(attValue) * luni << 3384 } << 3385 else if(attName == "y") << 3386 { << 3387 vec.setY(eval.Evaluate(attValue) * luni << 3388 } << 3389 } << 3390 << 3391 return vec; << 3392 } << 3393 << 3394 // ------------------------------------------ << 3395 G4GDMLReadSolids::zplaneType G4GDMLReadSolids << 3396 const xercesc::DOMElement* const zplaneElem << 3397 { << 3398 zplaneType zplane = { 0., 0., 0. }; << 3399 << 3400 const xercesc::DOMNamedNodeMap* const attri << 3401 zplaneElement->getAttributes(); << 3402 XMLSize_t attributeCount = attributes->getL << 3403 << 3404 for(XMLSize_t attribute_index = 0; attribut << 3405 ++attribute_index) << 3406 { << 3407 xercesc::DOMNode* node = attributes->item << 3408 << 3409 if(node->getNodeType() != xercesc::DOMNod << 3410 { << 3411 continue; << 3412 } << 3413 << 3414 const xercesc::DOMAttr* const attribute = << 3415 dynamic_cast<xercesc::DOMAttr*>(node); << 3416 if(attribute == nullptr) << 3417 { << 3418 G4Exception("G4GDMLReadSolids::ZplaneRe << 3419 FatalException, "No attribu << 3420 return zplane; << 3421 } << 3422 const G4String attName = Transcode(attri << 3423 const G4String attValue = Transcode(attri << 3424 << 3425 if(attName == "rmin") << 3426 { << 3427 zplane.rmin = eval.Evaluate(attValue); << 3428 } << 3429 else if(attName == "rmax") << 3430 { << 3431 zplane.rmax = eval.Evaluate(attValue); << 3432 } << 3433 else if(attName == "z") << 3434 { << 3435 zplane.z = eval.Evaluate(attValue); << 3436 } << 3437 } << 3438 << 3439 return zplane; << 3440 } << 3441 << 3442 // ------------------------------------------ << 3443 G4GDMLReadSolids::rzPointType G4GDMLReadSolid << 3444 const xercesc::DOMElement* const zplaneElem << 3445 { 1591 { 3446 rzPointType rzpoint = { 0., 0. }; << 1592 G4VSolid* solidPtr = G4SolidStore::GetInstance()->GetSolid(ref,false); 3447 << 3448 const xercesc::DOMNamedNodeMap* const attri << 3449 zplaneElement->getAttributes(); << 3450 XMLSize_t attributeCount = attributes->getL << 3451 << 3452 for(XMLSize_t attribute_index = 0; attribut << 3453 ++attribute_index) << 3454 { << 3455 xercesc::DOMNode* node = attributes->item << 3456 << 3457 if(node->getNodeType() != xercesc::DOMNod << 3458 { << 3459 continue; << 3460 } << 3461 << 3462 const xercesc::DOMAttr* const attribute = << 3463 dynamic_cast<xercesc::DOMAttr*>(node); << 3464 if(attribute == nullptr) << 3465 { << 3466 G4Exception("G4GDMLReadSolids::RZPointR << 3467 FatalException, "No attribu << 3468 return rzpoint; << 3469 } << 3470 const G4String attName = Transcode(attri << 3471 const G4String attValue = Transcode(attri << 3472 << 3473 if(attName == "r") << 3474 { << 3475 rzpoint.r = eval.Evaluate(attValue); << 3476 } << 3477 else if(attName == "z") << 3478 { << 3479 rzpoint.z = eval.Evaluate(attValue); << 3480 } << 3481 } << 3482 << 3483 return rzpoint; << 3484 } << 3485 << 3486 // ------------------------------------------ << 3487 void G4GDMLReadSolids::PropertyRead( << 3488 const xercesc::DOMElement* const propertyEl << 3489 G4OpticalSurface* opticalsurface) << 3490 { << 3491 G4String name; << 3492 G4String ref; << 3493 G4GDMLMatrix matrix; << 3494 << 3495 const xercesc::DOMNamedNodeMap* const attri << 3496 propertyElement->getAttributes(); << 3497 XMLSize_t attributeCount = attributes->getL << 3498 << 3499 for(XMLSize_t attribute_index = 0; attribut << 3500 ++attribute_index) << 3501 { << 3502 xercesc::DOMNode* attribute_node = attrib << 3503 << 3504 if(attribute_node->getNodeType() != xerce << 3505 { << 3506 continue; << 3507 } << 3508 << 3509 const xercesc::DOMAttr* const attribute = << 3510 dynamic_cast<xercesc::DOMAttr*>(attribu << 3511 if(attribute == nullptr) << 3512 { << 3513 G4Exception("G4GDMLReadSolids::Property << 3514 FatalException, "No attribu << 3515 return; << 3516 } << 3517 const G4String attName = Transcode(attri << 3518 const G4String attValue = Transcode(attri << 3519 << 3520 if(attName == "name") << 3521 { << 3522 name = GenerateName(attValue); << 3523 } << 3524 else if(attName == "ref") << 3525 { << 3526 matrix = GetMatrix(ref = attValue); << 3527 } << 3528 } << 3529 << 3530 /* << 3531 if (matrix.GetCols() != 2) << 3532 { << 3533 G4String error_msg = "Referenced matrix ' << 3534 + "' should have \n two columns as << 3535 opticalsurface: " << 3536 + opticalsurface->GetName(); << 3537 G4Exception("G4GDMLReadSolids::PropertyRe << 3538 FatalException, error_msg); << 3539 } << 3540 */ << 3541 << 3542 if(matrix.GetRows() == 0) << 3543 { << 3544 return; << 3545 } << 3546 << 3547 G4MaterialPropertiesTable* matprop = << 3548 opticalsurface->GetMaterialPropertiesTabl << 3549 if(matprop == nullptr) << 3550 { << 3551 matprop = new G4MaterialPropertiesTable() << 3552 opticalsurface->SetMaterialPropertiesTabl << 3553 } << 3554 if(matrix.GetCols() == 1) // constant prop << 3555 { << 3556 matprop->AddConstProperty(Strip(name), ma << 3557 } << 3558 else // build the material properties vect << 3559 { << 3560 G4MaterialPropertyVector* propvect; << 3561 G4String temp = name + ref; << 3562 // first check if it was already built << 3563 if(mapOfMatPropVects.find(temp) == mapOfM << 3564 { << 3565 // if not create a new one << 3566 propvect = new G4MaterialPropertyVector << 3567 for(size_t i = 0; i < matrix.GetRows(); << 3568 { << 3569 propvect->InsertValues(matrix.Get(i, << 3570 } << 3571 // and add it to the list for potential << 3572 mapOfMatPropVects[temp] = propvect; << 3573 } << 3574 else << 3575 { << 3576 propvect = mapOfMatPropVects[temp]; << 3577 } << 3578 << 3579 matprop->AddProperty(Strip(name), propvec << 3580 } << 3581 } << 3582 1593 3583 // ------------------------------------------ << 1594 if (!solidPtr) 3584 void G4GDMLReadSolids::OpticalSurfaceRead( << 1595 { 3585 const xercesc::DOMElement* const opticalsur << 1596 G4String error_msg = "Referenced solid '" + ref + "' was not found!"; 3586 { << 1597 G4Exception("G4GDMLReadSolids::GetSolid()", "ReadError", 3587 G4String name; << 1598 FatalException, error_msg); 3588 G4String smodel; << 1599 } 3589 G4String sfinish; << 3590 G4String stype; << 3591 G4double value = 0.0; << 3592 << 3593 const xercesc::DOMNamedNodeMap* const attri << 3594 opticalsurfaceElement->getAttributes(); << 3595 XMLSize_t attributeCount = attributes->getL << 3596 << 3597 for(XMLSize_t attribute_index = 0; attribut << 3598 ++attribute_index) << 3599 { << 3600 xercesc::DOMNode* attribute_node = attrib << 3601 << 3602 if(attribute_node->getNodeType() != xerce << 3603 { << 3604 continue; << 3605 } << 3606 << 3607 const xercesc::DOMAttr* const attribute = << 3608 dynamic_cast<xercesc::DOMAttr*>(attribu << 3609 if(attribute == nullptr) << 3610 { << 3611 G4Exception("G4GDMLReadSolids::OpticalS << 3612 FatalException, "No attribu << 3613 return; << 3614 } << 3615 const G4String attName = Transcode(attri << 3616 const G4String attValue = Transcode(attri << 3617 << 3618 if(attName == "name") << 3619 { << 3620 name = GenerateName(attValue); << 3621 } << 3622 else if(attName == "model") << 3623 { << 3624 smodel = attValue; << 3625 } << 3626 else if(attName == "finish") << 3627 { << 3628 sfinish = attValue; << 3629 } << 3630 else if(attName == "type") << 3631 { << 3632 stype = attValue; << 3633 } << 3634 else if(attName == "value") << 3635 { << 3636 value = eval.Evaluate(attValue); << 3637 } << 3638 } << 3639 << 3640 G4OpticalSurfaceModel model; << 3641 G4OpticalSurfaceFinish finish; << 3642 G4SurfaceType type; << 3643 << 3644 if((smodel == "glisur") || (smodel == "0")) << 3645 { << 3646 model = glisur; << 3647 } << 3648 else if((smodel == "unified") || (smodel == << 3649 { << 3650 model = unified; << 3651 } << 3652 else if((smodel == "LUT") || (smodel == "2" << 3653 { << 3654 model = LUT; << 3655 } << 3656 else if((smodel == "DAVIS") || (smodel == " << 3657 { << 3658 model = DAVIS; << 3659 } << 3660 else << 3661 { << 3662 model = dichroic; << 3663 } << 3664 << 3665 if((sfinish == "polished") || (sfinish == " << 3666 { << 3667 finish = polished; << 3668 } << 3669 else if((sfinish == "polishedfrontpainted") << 3670 { << 3671 finish = polishedfrontpainted; << 3672 } << 3673 else if((sfinish == "polishedbackpainted") << 3674 { << 3675 finish = polishedbackpainted; << 3676 } << 3677 else if((sfinish == "ground") || (sfinish = << 3678 { << 3679 finish = ground; << 3680 } << 3681 else if((sfinish == "groundfrontpainted") | << 3682 { << 3683 finish = groundfrontpainted; << 3684 } << 3685 else if((sfinish == "groundbackpainted") || << 3686 { << 3687 finish = groundbackpainted; << 3688 } << 3689 else if((sfinish == "polishedlumirrorair") << 3690 { << 3691 finish = polishedlumirrorair; << 3692 } << 3693 else if((sfinish == "polishedlumirrorglue") << 3694 { << 3695 finish = polishedlumirrorglue; << 3696 } << 3697 else if((sfinish == "polishedair") || (sfin << 3698 { << 3699 finish = polishedair; << 3700 } << 3701 else if((sfinish == "polishedteflonair") || << 3702 { << 3703 finish = polishedteflonair; << 3704 } << 3705 else if((sfinish == "polishedtioair") || (s << 3706 { << 3707 finish = polishedtioair; << 3708 } << 3709 else if((sfinish == "polishedtyvekair") || << 3710 { << 3711 finish = polishedtyvekair; << 3712 } << 3713 else if((sfinish == "polishedvm2000air") || << 3714 { << 3715 finish = polishedvm2000air; << 3716 } << 3717 else if((sfinish == "polishedvm2000glue") | << 3718 { << 3719 finish = polishedvm2000glue; << 3720 } << 3721 else if((sfinish == "etchedlumirrorair") || << 3722 { << 3723 finish = etchedlumirrorair; << 3724 } << 3725 else if((sfinish == "etchedlumirrorglue") | << 3726 { << 3727 finish = etchedlumirrorglue; << 3728 } << 3729 else if((sfinish == "etchedair") || (sfinis << 3730 { << 3731 finish = etchedair; << 3732 } << 3733 else if((sfinish == "etchedteflonair") || ( << 3734 { << 3735 finish = etchedteflonair; << 3736 } << 3737 else if((sfinish == "etchedtioair") || (sfi << 3738 { << 3739 finish = etchedtioair; << 3740 } << 3741 else if((sfinish == "etchedtyvekair") || (s << 3742 { << 3743 finish = etchedtyvekair; << 3744 } << 3745 else if((sfinish == "etchedvm2000air") || ( << 3746 { << 3747 finish = etchedvm2000air; << 3748 } << 3749 else if((sfinish == "etchedvm2000glue") || << 3750 { << 3751 finish = etchedvm2000glue; << 3752 } << 3753 else if((sfinish == "groundlumirrorair") || << 3754 { << 3755 finish = groundlumirrorair; << 3756 } << 3757 else if((sfinish == "groundlumirrorglue") | << 3758 { << 3759 finish = groundlumirrorglue; << 3760 } << 3761 else if((sfinish == "groundair") || (sfinis << 3762 { << 3763 finish = groundair; << 3764 } << 3765 else if((sfinish == "groundteflonair") || ( << 3766 { << 3767 finish = groundteflonair; << 3768 } << 3769 else if((sfinish == "groundtioair") || (sfi << 3770 { << 3771 finish = groundtioair; << 3772 } << 3773 else if((sfinish == "groundtyvekair") || (s << 3774 { << 3775 finish = groundtyvekair; << 3776 } << 3777 else if((sfinish == "groundvm2000air") || ( << 3778 { << 3779 finish = groundvm2000air; << 3780 } << 3781 else if((sfinish == "groundvm2000glue") || << 3782 { << 3783 finish = groundvm2000glue; << 3784 } << 3785 else if((sfinish == "Rough_LUT") || (sfinis << 3786 { << 3787 finish = Rough_LUT; << 3788 } << 3789 else if((sfinish == "RoughTeflon_LUT") || ( << 3790 { << 3791 finish = RoughTeflon_LUT; << 3792 } << 3793 else if((sfinish == "RoughESR_LUT") || (sfi << 3794 { << 3795 finish = RoughESR_LUT; << 3796 } << 3797 else if((sfinish == "RoughESRGrease_LUT") | << 3798 { << 3799 finish = RoughESRGrease_LUT; << 3800 } << 3801 else if((sfinish == "Polished_LUT") || (sfi << 3802 { << 3803 finish = Polished_LUT; << 3804 } << 3805 else if((sfinish == "PolishedTeflon_LUT") | << 3806 { << 3807 finish = PolishedTeflon_LUT; << 3808 } << 3809 else if((sfinish == "PolishedESR_LUT") || ( << 3810 { << 3811 finish = PolishedESR_LUT; << 3812 } << 3813 else if((sfinish == "PolishedESRGrease_LUT" << 3814 { << 3815 finish = PolishedESRGrease_LUT; << 3816 } << 3817 else << 3818 { << 3819 finish = Detector_LUT; << 3820 } << 3821 << 3822 if((stype == "dielectric_metal") || (stype << 3823 { << 3824 type = dielectric_metal; << 3825 } << 3826 else if((stype == "dielectric_dielectric") << 3827 { << 3828 type = dielectric_dielectric; << 3829 } << 3830 else if((stype == "dielectric_LUT") || (sty << 3831 { << 3832 type = dielectric_LUT; << 3833 } << 3834 else if((stype == "dielectric_LUTDAVIS") || << 3835 { << 3836 type = dielectric_LUTDAVIS; << 3837 } << 3838 else if((stype == "dielectric_dichroic") || << 3839 { << 3840 type = dielectric_dichroic; << 3841 } << 3842 else if((stype == "firsov") || (stype == "5 << 3843 { << 3844 type = firsov; << 3845 } << 3846 else << 3847 { << 3848 type = x_ray; << 3849 } << 3850 << 3851 G4OpticalSurface* opticalsurface = << 3852 new G4OpticalSurface(name, model, finish, << 3853 << 3854 for(xercesc::DOMNode* iter = opticalsurface << 3855 iter != nullptr; iter = iter->getNextSi << 3856 { << 3857 if(iter->getNodeType() != xercesc::DOMNod << 3858 { << 3859 continue; << 3860 } << 3861 << 3862 const xercesc::DOMElement* const child = << 3863 dynamic_cast<xercesc::DOMElement*>(iter << 3864 if(child == nullptr) << 3865 { << 3866 G4Exception("G4GDMLReadSolids::OpticalS << 3867 FatalException, "No child f << 3868 return; << 3869 } << 3870 const G4String tag = Transcode(child->get << 3871 << 3872 if(tag == "property") << 3873 { << 3874 PropertyRead(child, opticalsurface); << 3875 } << 3876 } << 3877 } << 3878 1600 3879 // ------------------------------------------ << 1601 return solidPtr; 3880 void G4GDMLReadSolids::SolidsRead( << 3881 const xercesc::DOMElement* const solidsElem << 3882 { << 3883 #ifdef G4VERBOSE << 3884 G4cout << "G4GDML: Reading solids..." << G4 << 3885 #endif << 3886 for(xercesc::DOMNode* iter = solidsElement- << 3887 iter = iter->getNextS << 3888 { << 3889 if(iter->getNodeType() != xercesc::DOMNod << 3890 { << 3891 continue; << 3892 } << 3893 << 3894 const xercesc::DOMElement* const child = << 3895 dynamic_cast<xercesc::DOMElement*>(iter << 3896 if(child == nullptr) << 3897 { << 3898 G4Exception("G4GDMLReadSolids::SolidsRe << 3899 FatalException, "No child f << 3900 return; << 3901 } << 3902 const G4String tag = Transcode(child->get << 3903 if(tag == "define") << 3904 { << 3905 DefineRead(child); << 3906 } << 3907 else if(tag == "box") << 3908 { << 3909 BoxRead(child); << 3910 } << 3911 else if(tag == "cone") << 3912 { << 3913 ConeRead(child); << 3914 } << 3915 else if(tag == "elcone") << 3916 { << 3917 ElconeRead(child); << 3918 } << 3919 else if(tag == "ellipsoid") << 3920 { << 3921 EllipsoidRead(child); << 3922 } << 3923 else if(tag == "eltube") << 3924 { << 3925 EltubeRead(child); << 3926 } << 3927 else if(tag == "xtru") << 3928 { << 3929 XtruRead(child); << 3930 } << 3931 else if(tag == "hype") << 3932 { << 3933 HypeRead(child); << 3934 } << 3935 else if(tag == "intersection") << 3936 { << 3937 BooleanRead(child, INTERSECTION); << 3938 } << 3939 else if(tag == "multiUnion") << 3940 { << 3941 MultiUnionRead(child); << 3942 } << 3943 else if(tag == "orb") << 3944 { << 3945 OrbRead(child); << 3946 } << 3947 else if(tag == "para") << 3948 { << 3949 ParaRead(child); << 3950 } << 3951 else if(tag == "paraboloid") << 3952 { << 3953 ParaboloidRead(child); << 3954 } << 3955 else if(tag == "polycone") << 3956 { << 3957 PolyconeRead(child); << 3958 } << 3959 else if(tag == "genericPolycone") << 3960 { << 3961 GenericPolyconeRead(child); << 3962 } << 3963 else if(tag == "polyhedra") << 3964 { << 3965 PolyhedraRead(child); << 3966 } << 3967 else if(tag == "genericPolyhedra") << 3968 { << 3969 GenericPolyhedraRead(child); << 3970 } << 3971 else if(tag == "reflectedSolid") << 3972 { << 3973 ReflectedSolidRead(child); << 3974 } << 3975 else if(tag == "scaledSolid") << 3976 { << 3977 ScaledSolidRead(child); << 3978 } << 3979 else if(tag == "sphere") << 3980 { << 3981 SphereRead(child); << 3982 } << 3983 else if(tag == "subtraction") << 3984 { << 3985 BooleanRead(child, SUBTRACTION); << 3986 } << 3987 else if(tag == "tessellated") << 3988 { << 3989 TessellatedRead(child); << 3990 } << 3991 else if(tag == "tet") << 3992 { << 3993 TetRead(child); << 3994 } << 3995 else if(tag == "torus") << 3996 { << 3997 TorusRead(child); << 3998 } << 3999 else if(tag == "arb8") << 4000 { << 4001 GenTrapRead(child); << 4002 } << 4003 else if(tag == "trap") << 4004 { << 4005 TrapRead(child); << 4006 } << 4007 else if(tag == "trd") << 4008 { << 4009 TrdRead(child); << 4010 } << 4011 else if(tag == "tube") << 4012 { << 4013 TubeRead(child); << 4014 } << 4015 else if(tag == "cutTube") << 4016 { << 4017 CutTubeRead(child); << 4018 } << 4019 else if(tag == "twistedbox") << 4020 { << 4021 TwistedboxRead(child); << 4022 } << 4023 else if(tag == "twistedtrap") << 4024 { << 4025 TwistedtrapRead(child); << 4026 } << 4027 else if(tag == "twistedtrd") << 4028 { << 4029 TwistedtrdRead(child); << 4030 } << 4031 else if(tag == "twistedtubs") << 4032 { << 4033 TwistedtubsRead(child); << 4034 } << 4035 else if(tag == "union") << 4036 { << 4037 BooleanRead(child, UNION); << 4038 } << 4039 else if(tag == "opticalsurface") << 4040 { << 4041 OpticalSurfaceRead(child); << 4042 } << 4043 else if(tag == "loop") << 4044 { << 4045 LoopRead(child, &G4GDMLRead::SolidsRead << 4046 } << 4047 else << 4048 { << 4049 G4String error_msg = "Unknown tag in so << 4050 G4Exception("G4GDMLReadSolids::SolidsRe << 4051 error_msg); << 4052 } << 4053 } << 4054 } 1602 } 4055 1603 4056 // ------------------------------------------ << 1604 G4SurfaceProperty* G4GDMLReadSolids:: 4057 G4VSolid* G4GDMLReadSolids::GetSolid(const G4 << 1605 GetSurfaceProperty(const G4String& ref) const 4058 { 1606 { 4059 G4VSolid* solidPtr = G4SolidStore::GetInsta << 1607 const G4SurfacePropertyTable* surfaceList 4060 ->GetSoli << 1608 = G4SurfaceProperty::GetSurfacePropertyTable(); >> 1609 const size_t surfaceCount = surfaceList->size(); 4061 1610 4062 if(solidPtr == nullptr) << 1611 for (size_t i=0; i<surfaceCount; i++) 4063 { << 1612 { 4064 G4String error_msg = "Referenced solid '" << 1613 if ((*surfaceList)[i]->GetName() == ref) { return (*surfaceList)[i]; } 4065 G4Exception("G4GDMLReadSolids::GetSolid() << 1614 } 4066 error_msg); << 4067 } << 4068 1615 4069 return solidPtr; << 1616 G4String error_msg = "Referenced optical surface '" + ref + "' was not found!"; 4070 } << 1617 G4Exception("G4GDMLReadSolids::GetSurfaceProperty()", "ReadError", 4071 << 1618 FatalException, error_msg); 4072 // ------------------------------------------ << 4073 G4SurfaceProperty* G4GDMLReadSolids::GetSurfa << 4074 const G4String& ref) const << 4075 { << 4076 const G4SurfacePropertyTable* surfaceList = << 4077 G4SurfaceProperty::GetSurfacePropertyTabl << 4078 const std::size_t surfaceCount = surfaceLis << 4079 << 4080 for(std::size_t i = 0; i < surfaceCount; ++ << 4081 { << 4082 if((*surfaceList)[i]->GetName() == ref) << 4083 { << 4084 return (*surfaceList)[i]; << 4085 } << 4086 } << 4087 << 4088 G4String error_msg = << 4089 "Referenced optical surface '" + ref + "' << 4090 G4Exception("G4GDMLReadSolids::GetSurfacePr << 4091 FatalException, error_msg); << 4092 1619 4093 return nullptr; << 1620 return 0; 4094 } 1621 } 4095 1622