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