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 // G4GDMLParamVol implementation << 27 // 26 // 28 // Author: Zoltan Torzsok, November 2007 << 27 // >> 28 // class G4GDMLParamVol Implementation >> 29 // >> 30 // Original author: Zoltan Torzsok, November 2007 >> 31 // 29 // ------------------------------------------- 32 // -------------------------------------------------------------------- 30 33 31 #include "G4GDMLWriteParamvol.hh" 34 #include "G4GDMLWriteParamvol.hh" 32 #include "G4GDMLWriteSolids.hh" 35 #include "G4GDMLWriteSolids.hh" 33 36 34 #include "G4SystemOfUnits.hh" 37 #include "G4SystemOfUnits.hh" 35 #include "G4Box.hh" 38 #include "G4Box.hh" 36 #include "G4Trd.hh" 39 #include "G4Trd.hh" 37 #include "G4Trap.hh" 40 #include "G4Trap.hh" 38 #include "G4Tubs.hh" 41 #include "G4Tubs.hh" 39 #include "G4Cons.hh" 42 #include "G4Cons.hh" 40 #include "G4Sphere.hh" 43 #include "G4Sphere.hh" 41 #include "G4Orb.hh" 44 #include "G4Orb.hh" 42 #include "G4Torus.hh" 45 #include "G4Torus.hh" 43 #include "G4Ellipsoid.hh" 46 #include "G4Ellipsoid.hh" 44 #include "G4Para.hh" 47 #include "G4Para.hh" 45 #include "G4Hype.hh" 48 #include "G4Hype.hh" 46 #include "G4Polycone.hh" 49 #include "G4Polycone.hh" 47 #include "G4Polyhedra.hh" 50 #include "G4Polyhedra.hh" 48 #include "G4LogicalVolume.hh" 51 #include "G4LogicalVolume.hh" 49 #include "G4VPhysicalVolume.hh" 52 #include "G4VPhysicalVolume.hh" 50 #include "G4PVParameterised.hh" 53 #include "G4PVParameterised.hh" 51 #include "G4VPVParameterisation.hh" 54 #include "G4VPVParameterisation.hh" 52 55 53 // ------------------------------------------- << 56 G4GDMLWriteParamvol:: 54 G4GDMLWriteParamvol::G4GDMLWriteParamvol() << 57 G4GDMLWriteParamvol() : G4GDMLWriteSetup() 55 : G4GDMLWriteSetup() << 56 { << 57 } << 58 << 59 // ------------------------------------------- << 60 G4GDMLWriteParamvol::~G4GDMLWriteParamvol() << 61 { << 62 } << 63 << 64 // ------------------------------------------- << 65 void G4GDMLWriteParamvol::Box_dimensionsWrite( << 66 xercesc::DOMElement* parametersElement, cons << 67 { << 68 xercesc::DOMElement* box_dimensionsElement = << 69 box_dimensionsElement->setAttributeNode( << 70 NewAttribute("x", 2.0 * box->GetXHalfLengt << 71 box_dimensionsElement->setAttributeNode( << 72 NewAttribute("y", 2.0 * box->GetYHalfLengt << 73 box_dimensionsElement->setAttributeNode( << 74 NewAttribute("z", 2.0 * box->GetZHalfLengt << 75 box_dimensionsElement->setAttributeNode(NewA << 76 parametersElement->appendChild(box_dimension << 77 } << 78 << 79 // ------------------------------------------- << 80 void G4GDMLWriteParamvol::Trd_dimensionsWrite( << 81 xercesc::DOMElement* parametersElement, cons << 82 { << 83 xercesc::DOMElement* trd_dimensionsElement = << 84 trd_dimensionsElement->setAttributeNode( << 85 NewAttribute("x1", 2.0 * trd->GetXHalfLeng << 86 trd_dimensionsElement->setAttributeNode( << 87 NewAttribute("x2", 2.0 * trd->GetXHalfLeng << 88 trd_dimensionsElement->setAttributeNode( << 89 NewAttribute("y1", 2.0 * trd->GetYHalfLeng << 90 trd_dimensionsElement->setAttributeNode( << 91 NewAttribute("y2", 2.0 * trd->GetYHalfLeng << 92 trd_dimensionsElement->setAttributeNode( << 93 NewAttribute("z", 2.0 * trd->GetZHalfLengt << 94 trd_dimensionsElement->setAttributeNode(NewA << 95 parametersElement->appendChild(trd_dimension << 96 } << 97 << 98 // ------------------------------------------- << 99 void G4GDMLWriteParamvol::Trap_dimensionsWrite << 100 xercesc::DOMElement* parametersElement, cons << 101 { << 102 const G4ThreeVector simaxis = trap->GetSymAx << 103 const G4double phi = << 104 (simaxis.z() != 1.0) ? (std::atan(simaxis. << 105 const G4double theta = std::acos(simaxis.z( << 106 const G4double alpha1 = std::atan(trap->GetT << 107 const G4double alpha2 = std::atan(trap->GetT << 108 << 109 xercesc::DOMElement* trap_dimensionsElement << 110 trap_dimensionsElement->setAttributeNode( << 111 NewAttribute("z", 2.0 * trap->GetZHalfLeng << 112 trap_dimensionsElement->setAttributeNode( << 113 NewAttribute("theta", theta / degree)); << 114 trap_dimensionsElement->setAttributeNode(New << 115 trap_dimensionsElement->setAttributeNode( << 116 NewAttribute("y1", 2.0 * trap->GetYHalfLen << 117 trap_dimensionsElement->setAttributeNode( << 118 NewAttribute("x1", 2.0 * trap->GetXHalfLen << 119 trap_dimensionsElement->setAttributeNode( << 120 NewAttribute("x2", 2.0 * trap->GetXHalfLen << 121 trap_dimensionsElement->setAttributeNode( << 122 NewAttribute("alpha1", alpha1 / degree)); << 123 trap_dimensionsElement->setAttributeNode( << 124 NewAttribute("y2", 2.0 * trap->GetYHalfLen << 125 trap_dimensionsElement->setAttributeNode( << 126 NewAttribute("x3", 2.0 * trap->GetXHalfLen << 127 trap_dimensionsElement->setAttributeNode( << 128 NewAttribute("x4", 2.0 * trap->GetXHalfLen << 129 trap_dimensionsElement->setAttributeNode( << 130 NewAttribute("alpha2", alpha2 / degree)); << 131 trap_dimensionsElement->setAttributeNode(New << 132 trap_dimensionsElement->setAttributeNode(New << 133 parametersElement->appendChild(trap_dimensio << 134 } << 135 << 136 // ------------------------------------------- << 137 void G4GDMLWriteParamvol::Tube_dimensionsWrite << 138 xercesc::DOMElement* parametersElement, cons << 139 { << 140 xercesc::DOMElement* tube_dimensionsElement << 141 tube_dimensionsElement->setAttributeNode( << 142 NewAttribute("InR", tube->GetInnerRadius() << 143 tube_dimensionsElement->setAttributeNode( << 144 NewAttribute("OutR", tube->GetOuterRadius( << 145 tube_dimensionsElement->setAttributeNode( << 146 NewAttribute("hz", 2.0 * tube->GetZHalfLen << 147 tube_dimensionsElement->setAttributeNode( << 148 NewAttribute("StartPhi", tube->GetStartPhi << 149 tube_dimensionsElement->setAttributeNode( << 150 NewAttribute("DeltaPhi", tube->GetDeltaPhi << 151 tube_dimensionsElement->setAttributeNode(New << 152 tube_dimensionsElement->setAttributeNode(New << 153 parametersElement->appendChild(tube_dimensio << 154 } << 155 << 156 // ------------------------------------------- << 157 void G4GDMLWriteParamvol::Cone_dimensionsWrite << 158 xercesc::DOMElement* parametersElement, cons << 159 { << 160 xercesc::DOMElement* cone_dimensionsElement << 161 cone_dimensionsElement->setAttributeNode( << 162 NewAttribute("rmin1", cone->GetInnerRadius << 163 cone_dimensionsElement->setAttributeNode( << 164 NewAttribute("rmax1", cone->GetOuterRadius << 165 cone_dimensionsElement->setAttributeNode( << 166 NewAttribute("rmin2", cone->GetInnerRadius << 167 cone_dimensionsElement->setAttributeNode( << 168 NewAttribute("rmax2", cone->GetOuterRadius << 169 cone_dimensionsElement->setAttributeNode( << 170 NewAttribute("z", 2.0 * cone->GetZHalfLeng << 171 cone_dimensionsElement->setAttributeNode( << 172 NewAttribute("startphi", cone->GetStartPhi << 173 cone_dimensionsElement->setAttributeNode( << 174 NewAttribute("deltaphi", cone->GetDeltaPhi << 175 cone_dimensionsElement->setAttributeNode(New << 176 cone_dimensionsElement->setAttributeNode(New << 177 parametersElement->appendChild(cone_dimensio << 178 } << 179 << 180 // ------------------------------------------- << 181 void G4GDMLWriteParamvol::Sphere_dimensionsWri << 182 xercesc::DOMElement* parametersElement, cons << 183 { << 184 xercesc::DOMElement* sphere_dimensionsElemen << 185 NewElement("sphere_dimensions"); << 186 sphere_dimensionsElement->setAttributeNode( << 187 NewAttribute("rmin", sphere->GetInnerRadiu << 188 sphere_dimensionsElement->setAttributeNode( << 189 NewAttribute("rmax", sphere->GetOuterRadiu << 190 sphere_dimensionsElement->setAttributeNode( << 191 NewAttribute("startphi", sphere->GetStartP << 192 sphere_dimensionsElement->setAttributeNode( << 193 NewAttribute("deltaphi", sphere->GetDeltaP << 194 sphere_dimensionsElement->setAttributeNode( << 195 NewAttribute("starttheta", sphere->GetStar << 196 sphere_dimensionsElement->setAttributeNode( << 197 NewAttribute("deltatheta", sphere->GetDelt << 198 sphere_dimensionsElement->setAttributeNode(N << 199 sphere_dimensionsElement->setAttributeNode(N << 200 parametersElement->appendChild(sphere_dimens << 201 } << 202 << 203 // ------------------------------------------- << 204 void G4GDMLWriteParamvol::Orb_dimensionsWrite( << 205 xercesc::DOMElement* parametersElement, cons << 206 { << 207 xercesc::DOMElement* orb_dimensionsElement = << 208 orb_dimensionsElement->setAttributeNode( << 209 NewAttribute("r", orb->GetRadius() / mm)); << 210 orb_dimensionsElement->setAttributeNode(NewA << 211 parametersElement->appendChild(orb_dimension << 212 } << 213 << 214 // ------------------------------------------- << 215 void G4GDMLWriteParamvol::Torus_dimensionsWrit << 216 xercesc::DOMElement* parametersElement, cons << 217 { << 218 xercesc::DOMElement* torus_dimensionsElement << 219 torus_dimensionsElement->setAttributeNode( << 220 NewAttribute("rmin", torus->GetRmin() / mm << 221 torus_dimensionsElement->setAttributeNode( << 222 NewAttribute("rmax", torus->GetRmax() / mm << 223 torus_dimensionsElement->setAttributeNode( << 224 NewAttribute("rtor", torus->GetRtor() / mm << 225 torus_dimensionsElement->setAttributeNode( << 226 NewAttribute("startphi", torus->GetSPhi() << 227 torus_dimensionsElement->setAttributeNode( << 228 NewAttribute("deltaphi", torus->GetDPhi() << 229 torus_dimensionsElement->setAttributeNode(Ne << 230 torus_dimensionsElement->setAttributeNode(Ne << 231 parametersElement->appendChild(torus_dimensi << 232 } << 233 << 234 // ------------------------------------------- << 235 void G4GDMLWriteParamvol::Ellipsoid_dimensions << 236 xercesc::DOMElement* parametersElement, cons << 237 { << 238 xercesc::DOMElement* ellipsoid_dimensionsEle << 239 NewElement("ellipsoid_dimensions"); << 240 ellipsoid_dimensionsElement->setAttributeNod << 241 NewAttribute("ax", ellipsoid->GetSemiAxisM << 242 ellipsoid_dimensionsElement->setAttributeNod << 243 NewAttribute("by", ellipsoid->GetSemiAxisM << 244 ellipsoid_dimensionsElement->setAttributeNod << 245 NewAttribute("cz", ellipsoid->GetSemiAxisM << 246 ellipsoid_dimensionsElement->setAttributeNod << 247 NewAttribute("zcut1", ellipsoid->GetZBotto << 248 ellipsoid_dimensionsElement->setAttributeNod << 249 NewAttribute("zcut2", ellipsoid->GetZTopCu << 250 ellipsoid_dimensionsElement->setAttributeNod << 251 parametersElement->appendChild(ellipsoid_dim << 252 } << 253 << 254 // ------------------------------------------- << 255 void G4GDMLWriteParamvol::Para_dimensionsWrite << 256 xercesc::DOMElement* parametersElement, cons << 257 { << 258 const G4ThreeVector simaxis = para->GetSymAx << 259 << 260 const G4double alpha = std::atan(para->GetTa << 261 const G4double theta = std::acos(simaxis.z() << 262 const G4double phi = << 263 (simaxis.z() != 1.0) ? (std::atan(simaxis. << 264 << 265 xercesc::DOMElement* para_dimensionsElement << 266 para_dimensionsElement->setAttributeNode( << 267 NewAttribute("x", 2.0 * para->GetXHalfLeng << 268 para_dimensionsElement->setAttributeNode( << 269 NewAttribute("y", 2.0 * para->GetYHalfLeng << 270 para_dimensionsElement->setAttributeNode( << 271 NewAttribute("z", 2.0 * para->GetZHalfLeng << 272 para_dimensionsElement->setAttributeNode( << 273 NewAttribute("alpha", alpha / degree)); << 274 para_dimensionsElement->setAttributeNode( << 275 NewAttribute("theta", theta / degree)); << 276 para_dimensionsElement->setAttributeNode(New << 277 para_dimensionsElement->setAttributeNode(New << 278 para_dimensionsElement->setAttributeNode(New << 279 parametersElement->appendChild(para_dimensio << 280 } << 281 << 282 // ------------------------------------------- << 283 void G4GDMLWriteParamvol::Hype_dimensionsWrite << 284 xercesc::DOMElement* parametersElement, cons << 285 { << 286 xercesc::DOMElement* hype_dimensionsElement << 287 hype_dimensionsElement->setAttributeNode( << 288 NewAttribute("rmin", hype->GetInnerRadius( << 289 hype_dimensionsElement->setAttributeNode( << 290 NewAttribute("rmax", hype->GetOuterRadius( << 291 hype_dimensionsElement->setAttributeNode( << 292 NewAttribute("inst", hype->GetInnerStereo( << 293 hype_dimensionsElement->setAttributeNode( << 294 NewAttribute("outst", hype->GetOuterStereo << 295 hype_dimensionsElement->setAttributeNode( << 296 NewAttribute("z", 2.0 * hype->GetZHalfLeng << 297 hype_dimensionsElement->setAttributeNode(New << 298 hype_dimensionsElement->setAttributeNode(New << 299 parametersElement->appendChild(hype_dimensio << 300 } << 301 << 302 // ------------------------------------------- << 303 void G4GDMLWriteParamvol::Polycone_dimensionsW << 304 xercesc::DOMElement* parametersElement, cons << 305 { << 306 xercesc::DOMElement* pcone_dimensionsElement << 307 NewElement("polycone_dimensions"); << 308 << 309 pcone_dimensionsElement->setAttributeNode( << 310 NewAttribute("numRZ", pcone->GetOriginalPa << 311 pcone_dimensionsElement->setAttributeNode(Ne << 312 "startPhi", pcone->GetOriginalParameters() << 313 pcone_dimensionsElement->setAttributeNode(Ne << 314 "openPhi", pcone->GetOriginalParameters()- << 315 pcone_dimensionsElement->setAttributeNode(Ne << 316 pcone_dimensionsElement->setAttributeNode(Ne << 317 << 318 parametersElement->appendChild(pcone_dimensi << 319 const size_t num_zplanes = pcone->GetOrigi << 320 const G4double* z_array = pcone->GetOrigi << 321 const G4double* rmin_array = pcone->GetOrigi << 322 const G4double* rmax_array = pcone->GetOrigi << 323 << 324 for(std::size_t i = 0; i < num_zplanes; ++i) << 325 { << 326 ZplaneWrite(pcone_dimensionsElement, z_arr << 327 rmax_array[i]); << 328 } << 329 } << 330 << 331 // ------------------------------------------- << 332 void G4GDMLWriteParamvol::Polyhedra_dimensions << 333 xercesc::DOMElement* parametersElement, cons << 334 { << 335 xercesc::DOMElement* polyhedra_dimensionsEle << 336 NewElement("polyhedra_dimensions"); << 337 << 338 polyhedra_dimensionsElement->setAttributeNod << 339 NewAttribute("numRZ", polyhedra->GetOrigin << 340 polyhedra_dimensionsElement->setAttributeNod << 341 NewAttribute("numSide", polyhedra->GetOrig << 342 polyhedra_dimensionsElement->setAttributeNod << 343 "startPhi", polyhedra->GetOriginalParamete << 344 polyhedra_dimensionsElement->setAttributeNod << 345 "openPhi", polyhedra->GetOriginalParameter << 346 polyhedra_dimensionsElement->setAttributeNod << 347 polyhedra_dimensionsElement->setAttributeNod << 348 << 349 parametersElement->appendChild(polyhedra_dim << 350 const size_t num_zplanes = polyhedra->GetO << 351 const G4double* z_array = polyhedra->GetO << 352 const G4double* rmin_array = polyhedra->GetO << 353 const G4double* rmax_array = polyhedra->GetO << 354 << 355 for(std::size_t i = 0; i < num_zplanes; ++i) << 356 { << 357 ZplaneWrite(polyhedra_dimensionsElement, z << 358 rmax_array[i]); << 359 } << 360 } << 361 << 362 // ------------------------------------------- << 363 void G4GDMLWriteParamvol::ParametersWrite(xerc << 364 const G4VPhysicalVolume* co << 365 { 58 { 366 paramvol->GetParameterisation()->ComputeTran << 367 index, const_cast<G4VPhysicalVolume*>(para << 368 G4ThreeVector Angles; << 369 G4String name = GenerateName(paramvol->GetNa << 370 std::stringstream os; << 371 os.precision(15); << 372 os << index; << 373 G4String sncopie = os.str(); << 374 << 375 xercesc::DOMElement* parametersElement = New << 376 parametersElement->setAttributeNode(NewAttri << 377 << 378 PositionWrite(parametersElement, name + snco << 379 paramvol->GetObjectTranslation << 380 Angles = GetAngles(paramvol->GetObjectRotati << 381 if(Angles.mag2() > DBL_EPSILON) << 382 { << 383 RotationWrite(parametersElement, name + sn << 384 GetAngles(paramvol->GetObjec << 385 } << 386 paramvolElement->appendChild(parametersEleme << 387 << 388 G4VSolid* solid = paramvol->GetLogicalVolume << 389 << 390 if(G4Box* box = dynamic_cast<G4Box*>(solid)) << 391 { << 392 paramvol->GetParameterisation()->ComputeDi << 393 *box, index, const_cast<G4VPhysicalVolum << 394 Box_dimensionsWrite(parametersElement, box << 395 } << 396 else if(G4Trd* trd = dynamic_cast<G4Trd*>(so << 397 { << 398 paramvol->GetParameterisation()->ComputeDi << 399 *trd, index, const_cast<G4VPhysicalVolum << 400 Trd_dimensionsWrite(parametersElement, trd << 401 } << 402 else if(G4Trap* trap = dynamic_cast<G4Trap*> << 403 { << 404 paramvol->GetParameterisation()->ComputeDi << 405 *trap, index, const_cast<G4VPhysicalVolu << 406 Trap_dimensionsWrite(parametersElement, tr << 407 } << 408 else if(G4Tubs* tube = dynamic_cast<G4Tubs*> << 409 { << 410 paramvol->GetParameterisation()->ComputeDi << 411 *tube, index, const_cast<G4VPhysicalVolu << 412 Tube_dimensionsWrite(parametersElement, tu << 413 } << 414 else if(G4Cons* cone = dynamic_cast<G4Cons*> << 415 { << 416 paramvol->GetParameterisation()->ComputeDi << 417 *cone, index, const_cast<G4VPhysicalVolu << 418 Cone_dimensionsWrite(parametersElement, co << 419 } << 420 else if(G4Sphere* sphere = dynamic_cast<G4Sp << 421 { << 422 paramvol->GetParameterisation()->ComputeDi << 423 *sphere, index, const_cast<G4VPhysicalVo << 424 Sphere_dimensionsWrite(parametersElement, << 425 } << 426 else if(G4Orb* orb = dynamic_cast<G4Orb*>(so << 427 { << 428 paramvol->GetParameterisation()->ComputeDi << 429 *orb, index, const_cast<G4VPhysicalVolum << 430 Orb_dimensionsWrite(parametersElement, orb << 431 } << 432 else if(G4Torus* torus = dynamic_cast<G4Toru << 433 { << 434 paramvol->GetParameterisation()->ComputeDi << 435 *torus, index, const_cast<G4VPhysicalVol << 436 Torus_dimensionsWrite(parametersElement, t << 437 } << 438 else if(G4Ellipsoid* ellipsoid = dynamic_cas << 439 { << 440 paramvol->GetParameterisation()->ComputeDi << 441 *ellipsoid, index, const_cast<G4VPhysica << 442 Ellipsoid_dimensionsWrite(parametersElemen << 443 } << 444 else if(G4Para* para = dynamic_cast<G4Para*> << 445 { << 446 paramvol->GetParameterisation()->ComputeDi << 447 *para, index, const_cast<G4VPhysicalVolu << 448 Para_dimensionsWrite(parametersElement, pa << 449 } << 450 else if(G4Hype* hype = dynamic_cast<G4Hype*> << 451 { << 452 paramvol->GetParameterisation()->ComputeDi << 453 *hype, index, const_cast<G4VPhysicalVolu << 454 Hype_dimensionsWrite(parametersElement, hy << 455 } << 456 else if(G4Polycone* pcone = dynamic_cast<G4P << 457 { << 458 paramvol->GetParameterisation()->ComputeDi << 459 *pcone, index, const_cast<G4VPhysicalVol << 460 Polycone_dimensionsWrite(parametersElement << 461 } << 462 else if(G4Polyhedra* polyhedra = dynamic_cas << 463 { << 464 paramvol->GetParameterisation()->ComputeDi << 465 *polyhedra, index, const_cast<G4VPhysica << 466 Polyhedra_dimensionsWrite(parametersElemen << 467 } << 468 else << 469 { << 470 G4String error_msg = "Solid '" + solid->Ge << 471 "' cannot be used in << 472 G4Exception("G4GDMLWriteParamvol::Paramete << 473 FatalException, error_msg); << 474 } << 475 } 59 } 476 60 477 // ------------------------------------------- << 61 G4GDMLWriteParamvol:: 478 void G4GDMLWriteParamvol::ParamvolWrite(xerces << 62 ~G4GDMLWriteParamvol() 479 const << 480 { 63 { 481 const G4String volumeref = GenerateName( << 482 paramvol->GetLogicalVolume()->GetName(), p << 483 xercesc::DOMElement* paramvolElement = NewEl << 484 paramvolElement->setAttributeNode( << 485 NewAttribute("ncopies", paramvol->GetMulti << 486 xercesc::DOMElement* volumerefElement = NewE << 487 volumerefElement->setAttributeNode(NewAttrib << 488 << 489 xercesc::DOMElement* algorithmElement = << 490 NewElement("parameterised_position_size"); << 491 paramvolElement->appendChild(volumerefElemen << 492 paramvolElement->appendChild(algorithmElemen << 493 ParamvolAlgorithmWrite(algorithmElement, par << 494 volumeElement->appendChild(paramvolElement); << 495 } 64 } 496 65 497 // ------------------------------------------- << 66 void G4GDMLWriteParamvol:: 498 void G4GDMLWriteParamvol::ParamvolAlgorithmWri << 67 Box_dimensionsWrite(xercesc::DOMElement* parametersElement, 499 xercesc::DOMElement* paramvolElement, const << 68 const G4Box* const box) 500 { << 69 { 501 const G4String volumeref = GenerateName( << 70 xercesc::DOMElement* box_dimensionsElement = NewElement("box_dimensions"); 502 paramvol->GetLogicalVolume()->GetName(), p << 71 box_dimensionsElement-> 503 << 72 setAttributeNode(NewAttribute("x",2.0*box->GetXHalfLength()/mm)); 504 const G4int parameterCount = paramvol->GetMu << 73 box_dimensionsElement-> 505 << 74 setAttributeNode(NewAttribute("y",2.0*box->GetYHalfLength()/mm)); 506 for(G4int i = 0; i < parameterCount; ++i) << 75 box_dimensionsElement-> 507 { << 76 setAttributeNode(NewAttribute("z",2.0*box->GetZHalfLength()/mm)); 508 ParametersWrite(paramvolElement, paramvol, << 77 box_dimensionsElement-> 509 } << 78 setAttributeNode(NewAttribute("lunit","mm")); >> 79 parametersElement->appendChild(box_dimensionsElement); >> 80 } >> 81 >> 82 void G4GDMLWriteParamvol:: >> 83 Trd_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 84 const G4Trd* const trd) >> 85 { >> 86 xercesc::DOMElement* trd_dimensionsElement = NewElement("trd_dimensions"); >> 87 trd_dimensionsElement-> >> 88 setAttributeNode(NewAttribute("x1",2.0*trd->GetXHalfLength1()/mm)); >> 89 trd_dimensionsElement-> >> 90 setAttributeNode(NewAttribute("x2",2.0*trd->GetXHalfLength2()/mm)); >> 91 trd_dimensionsElement-> >> 92 setAttributeNode(NewAttribute("y1",2.0*trd->GetYHalfLength1()/mm)); >> 93 trd_dimensionsElement-> >> 94 setAttributeNode(NewAttribute("y2",2.0*trd->GetYHalfLength2()/mm)); >> 95 trd_dimensionsElement-> >> 96 setAttributeNode(NewAttribute("z",2.0*trd->GetZHalfLength()/mm)); >> 97 trd_dimensionsElement-> >> 98 setAttributeNode(NewAttribute("lunit","mm")); >> 99 parametersElement->appendChild(trd_dimensionsElement); >> 100 } >> 101 >> 102 void G4GDMLWriteParamvol:: >> 103 Trap_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 104 const G4Trap* const trap) >> 105 { >> 106 const G4ThreeVector simaxis = trap->GetSymAxis(); >> 107 const G4double phi = (simaxis.z() != 1.0) >> 108 ? (std::atan(simaxis.y()/simaxis.x())) : (0.0); >> 109 const G4double theta = std::acos(simaxis.z()); >> 110 const G4double alpha1 = std::atan(trap->GetTanAlpha1()); >> 111 const G4double alpha2 = std::atan(trap->GetTanAlpha2()); >> 112 >> 113 xercesc::DOMElement* trap_dimensionsElement = NewElement("trap"); >> 114 trap_dimensionsElement-> >> 115 setAttributeNode(NewAttribute("z",2.0*trap->GetZHalfLength()/mm)); >> 116 trap_dimensionsElement-> >> 117 setAttributeNode(NewAttribute("theta",theta/degree)); >> 118 trap_dimensionsElement-> >> 119 setAttributeNode(NewAttribute("phi",phi/degree)); >> 120 trap_dimensionsElement-> >> 121 setAttributeNode(NewAttribute("y1",2.0*trap->GetYHalfLength1()/mm)); >> 122 trap_dimensionsElement-> >> 123 setAttributeNode(NewAttribute("x1",2.0*trap->GetXHalfLength1()/mm)); >> 124 trap_dimensionsElement-> >> 125 setAttributeNode(NewAttribute("x2",2.0*trap->GetXHalfLength2()/mm)); >> 126 trap_dimensionsElement-> >> 127 setAttributeNode(NewAttribute("alpha1",alpha1/degree)); >> 128 trap_dimensionsElement-> >> 129 setAttributeNode(NewAttribute("y2",2.0*trap->GetYHalfLength2()/mm)); >> 130 trap_dimensionsElement-> >> 131 setAttributeNode(NewAttribute("x3",2.0*trap->GetXHalfLength3()/mm)); >> 132 trap_dimensionsElement-> >> 133 setAttributeNode(NewAttribute("x4",2.0*trap->GetXHalfLength4()/mm)); >> 134 trap_dimensionsElement-> >> 135 setAttributeNode(NewAttribute("alpha2",alpha2/degree)); >> 136 trap_dimensionsElement-> >> 137 setAttributeNode(NewAttribute("aunit","deg")); >> 138 trap_dimensionsElement-> >> 139 setAttributeNode(NewAttribute("lunit","mm")); >> 140 parametersElement->appendChild(trap_dimensionsElement); >> 141 } >> 142 >> 143 void G4GDMLWriteParamvol:: >> 144 Tube_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 145 const G4Tubs* const tube) >> 146 { >> 147 xercesc::DOMElement* tube_dimensionsElement = NewElement("tube_dimensions"); >> 148 tube_dimensionsElement-> >> 149 setAttributeNode(NewAttribute("InR",tube->GetInnerRadius()/mm)); >> 150 tube_dimensionsElement-> >> 151 setAttributeNode(NewAttribute("OutR",tube->GetOuterRadius()/mm)); >> 152 tube_dimensionsElement-> >> 153 setAttributeNode(NewAttribute("hz",2.0*tube->GetZHalfLength()/mm)); >> 154 tube_dimensionsElement-> >> 155 setAttributeNode(NewAttribute("StartPhi",tube->GetStartPhiAngle()/degree)); >> 156 tube_dimensionsElement-> >> 157 setAttributeNode(NewAttribute("DeltaPhi",tube->GetDeltaPhiAngle()/degree)); >> 158 tube_dimensionsElement-> >> 159 setAttributeNode(NewAttribute("aunit","deg")); >> 160 tube_dimensionsElement-> >> 161 setAttributeNode(NewAttribute("lunit","mm")); >> 162 parametersElement->appendChild(tube_dimensionsElement); >> 163 } >> 164 >> 165 >> 166 void G4GDMLWriteParamvol:: >> 167 Cone_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 168 const G4Cons* const cone) >> 169 { >> 170 xercesc::DOMElement* cone_dimensionsElement = NewElement("cone_dimensions"); >> 171 cone_dimensionsElement-> >> 172 setAttributeNode(NewAttribute("rmin1",cone->GetInnerRadiusMinusZ()/mm)); >> 173 cone_dimensionsElement-> >> 174 setAttributeNode(NewAttribute("rmax1",cone->GetOuterRadiusMinusZ()/mm)); >> 175 cone_dimensionsElement-> >> 176 setAttributeNode(NewAttribute("rmin2",cone->GetInnerRadiusPlusZ()/mm)); >> 177 cone_dimensionsElement-> >> 178 setAttributeNode(NewAttribute("rmax2",cone->GetOuterRadiusPlusZ()/mm)); >> 179 cone_dimensionsElement-> >> 180 setAttributeNode(NewAttribute("z",2.0*cone->GetZHalfLength()/mm)); >> 181 cone_dimensionsElement-> >> 182 setAttributeNode(NewAttribute("startphi",cone->GetStartPhiAngle()/degree)); >> 183 cone_dimensionsElement-> >> 184 setAttributeNode(NewAttribute("deltaphi",cone->GetDeltaPhiAngle()/degree)); >> 185 cone_dimensionsElement-> >> 186 setAttributeNode(NewAttribute("aunit","deg")); >> 187 cone_dimensionsElement-> >> 188 setAttributeNode(NewAttribute("lunit","mm")); >> 189 parametersElement->appendChild(cone_dimensionsElement); >> 190 } >> 191 >> 192 void G4GDMLWriteParamvol:: >> 193 Sphere_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 194 const G4Sphere* const sphere) >> 195 { >> 196 xercesc::DOMElement* sphere_dimensionsElement = >> 197 NewElement("sphere_dimensions"); >> 198 sphere_dimensionsElement->setAttributeNode(NewAttribute("rmin", >> 199 sphere->GetInnerRadius()/mm)); >> 200 sphere_dimensionsElement->setAttributeNode(NewAttribute("rmax", >> 201 sphere->GetOuterRadius()/mm)); >> 202 sphere_dimensionsElement->setAttributeNode(NewAttribute("startphi", >> 203 sphere->GetStartPhiAngle()/degree)); >> 204 sphere_dimensionsElement->setAttributeNode(NewAttribute("deltaphi", >> 205 sphere->GetDeltaPhiAngle()/degree)); >> 206 sphere_dimensionsElement->setAttributeNode(NewAttribute("starttheta", >> 207 sphere->GetStartThetaAngle()/degree)); >> 208 sphere_dimensionsElement->setAttributeNode(NewAttribute("deltatheta", >> 209 sphere->GetDeltaThetaAngle()/degree)); >> 210 sphere_dimensionsElement->setAttributeNode(NewAttribute("aunit","deg")); >> 211 sphere_dimensionsElement->setAttributeNode(NewAttribute("lunit","mm")); >> 212 parametersElement->appendChild(sphere_dimensionsElement); >> 213 } >> 214 >> 215 void G4GDMLWriteParamvol:: >> 216 Orb_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 217 const G4Orb* const orb) >> 218 { >> 219 xercesc::DOMElement* orb_dimensionsElement = NewElement("orb_dimensions"); >> 220 orb_dimensionsElement->setAttributeNode(NewAttribute("r", >> 221 orb->GetRadius()/mm)); >> 222 orb_dimensionsElement->setAttributeNode(NewAttribute("lunit","mm")); >> 223 parametersElement->appendChild(orb_dimensionsElement); >> 224 } >> 225 >> 226 void G4GDMLWriteParamvol:: >> 227 Torus_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 228 const G4Torus* const torus) >> 229 { >> 230 xercesc::DOMElement* torus_dimensionsElement = >> 231 NewElement("torus_dimensions"); >> 232 torus_dimensionsElement-> >> 233 setAttributeNode(NewAttribute("rmin",torus->GetRmin()/mm)); >> 234 torus_dimensionsElement-> >> 235 setAttributeNode(NewAttribute("rmax",torus->GetRmax()/mm)); >> 236 torus_dimensionsElement-> >> 237 setAttributeNode(NewAttribute("rtor",torus->GetRtor()/mm)); >> 238 torus_dimensionsElement-> >> 239 setAttributeNode(NewAttribute("startphi",torus->GetSPhi()/degree)); >> 240 torus_dimensionsElement-> >> 241 setAttributeNode(NewAttribute("deltaphi",torus->GetDPhi()/degree)); >> 242 torus_dimensionsElement-> >> 243 setAttributeNode(NewAttribute("aunit","deg")); >> 244 torus_dimensionsElement-> >> 245 setAttributeNode(NewAttribute("lunit","mm")); >> 246 parametersElement->appendChild(torus_dimensionsElement); >> 247 } >> 248 >> 249 void G4GDMLWriteParamvol:: >> 250 Ellipsoid_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 251 const G4Ellipsoid* const ellipsoid) >> 252 { >> 253 xercesc::DOMElement* ellipsoid_dimensionsElement = >> 254 NewElement("ellipsoid_dimensions"); >> 255 ellipsoid_dimensionsElement-> >> 256 setAttributeNode(NewAttribute("ax",ellipsoid->GetSemiAxisMax(0)/mm)); >> 257 ellipsoid_dimensionsElement-> >> 258 setAttributeNode(NewAttribute("by",ellipsoid->GetSemiAxisMax(1)/mm)); >> 259 ellipsoid_dimensionsElement-> >> 260 setAttributeNode(NewAttribute("cz",ellipsoid->GetSemiAxisMax(2)/mm)); >> 261 ellipsoid_dimensionsElement-> >> 262 setAttributeNode(NewAttribute("zcut1",ellipsoid->GetZBottomCut()/mm)); >> 263 ellipsoid_dimensionsElement-> >> 264 setAttributeNode(NewAttribute("zcut2",ellipsoid->GetZTopCut()/mm)); >> 265 ellipsoid_dimensionsElement-> >> 266 setAttributeNode(NewAttribute("lunit","mm")); >> 267 parametersElement->appendChild(ellipsoid_dimensionsElement); >> 268 } >> 269 >> 270 void G4GDMLWriteParamvol:: >> 271 Para_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 272 const G4Para* const para) >> 273 { >> 274 const G4ThreeVector simaxis = para->GetSymAxis(); >> 275 >> 276 const G4double alpha = std::atan(para->GetTanAlpha()); >> 277 const G4double theta = std::acos(simaxis.z()); >> 278 const G4double phi = (simaxis.z() != 1.0) >> 279 ? (std::atan(simaxis.y()/simaxis.x())) : (0.0); >> 280 >> 281 xercesc::DOMElement* para_dimensionsElement = NewElement("para_dimensions"); >> 282 para_dimensionsElement-> >> 283 setAttributeNode(NewAttribute("x",2.0*para->GetXHalfLength()/mm)); >> 284 para_dimensionsElement-> >> 285 setAttributeNode(NewAttribute("y",2.0*para->GetYHalfLength()/mm)); >> 286 para_dimensionsElement-> >> 287 setAttributeNode(NewAttribute("z",2.0*para->GetZHalfLength()/mm)); >> 288 para_dimensionsElement-> >> 289 setAttributeNode(NewAttribute("alpha",alpha/degree)); >> 290 para_dimensionsElement-> >> 291 setAttributeNode(NewAttribute("theta",theta/degree)); >> 292 para_dimensionsElement-> >> 293 setAttributeNode(NewAttribute("phi",phi/degree)); >> 294 para_dimensionsElement-> >> 295 setAttributeNode(NewAttribute("aunit","deg")); >> 296 para_dimensionsElement-> >> 297 setAttributeNode(NewAttribute("lunit","mm")); >> 298 parametersElement->appendChild(para_dimensionsElement); >> 299 } >> 300 >> 301 void G4GDMLWriteParamvol:: >> 302 Hype_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 303 const G4Hype* const hype) >> 304 { >> 305 xercesc::DOMElement* hype_dimensionsElement = NewElement("hype_dimensions"); >> 306 hype_dimensionsElement-> >> 307 setAttributeNode(NewAttribute("rmin",hype->GetInnerRadius()/mm)); >> 308 hype_dimensionsElement-> >> 309 setAttributeNode(NewAttribute("rmax",hype->GetOuterRadius()/mm)); >> 310 hype_dimensionsElement-> >> 311 setAttributeNode(NewAttribute("inst",hype->GetInnerStereo()/degree)); >> 312 hype_dimensionsElement-> >> 313 setAttributeNode(NewAttribute("outst",hype->GetOuterStereo()/degree)); >> 314 hype_dimensionsElement-> >> 315 setAttributeNode(NewAttribute("z",2.0*hype->GetZHalfLength()/mm)); >> 316 hype_dimensionsElement-> >> 317 setAttributeNode(NewAttribute("aunit","deg")); >> 318 hype_dimensionsElement-> >> 319 setAttributeNode(NewAttribute("lunit","mm")); >> 320 parametersElement->appendChild(hype_dimensionsElement); >> 321 } >> 322 >> 323 void G4GDMLWriteParamvol:: >> 324 Polycone_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 325 const G4Polycone* const pcone) >> 326 { >> 327 xercesc::DOMElement* pcone_dimensionsElement >> 328 = NewElement("polycone_dimensions"); >> 329 >> 330 pcone_dimensionsElement->setAttributeNode(NewAttribute("numRZ", >> 331 pcone->GetOriginalParameters()->Num_z_planes)); >> 332 pcone_dimensionsElement->setAttributeNode(NewAttribute("startPhi", >> 333 pcone->GetOriginalParameters()->Start_angle/degree)); >> 334 pcone_dimensionsElement->setAttributeNode(NewAttribute("openPhi", >> 335 pcone->GetOriginalParameters()->Opening_angle/degree)); >> 336 pcone_dimensionsElement->setAttributeNode(NewAttribute("aunit","deg")); >> 337 pcone_dimensionsElement->setAttributeNode(NewAttribute("lunit","mm")); >> 338 >> 339 parametersElement->appendChild(pcone_dimensionsElement); >> 340 const size_t num_zplanes = pcone->GetOriginalParameters()->Num_z_planes; >> 341 const G4double* z_array = pcone->GetOriginalParameters()->Z_values; >> 342 const G4double* rmin_array = pcone->GetOriginalParameters()->Rmin; >> 343 const G4double* rmax_array = pcone->GetOriginalParameters()->Rmax; >> 344 >> 345 for (size_t i=0; i<num_zplanes; i++) >> 346 { >> 347 ZplaneWrite(pcone_dimensionsElement,z_array[i], >> 348 rmin_array[i],rmax_array[i]); >> 349 } >> 350 } >> 351 >> 352 void G4GDMLWriteParamvol:: >> 353 Polyhedra_dimensionsWrite(xercesc::DOMElement* parametersElement, >> 354 const G4Polyhedra* const polyhedra) >> 355 { >> 356 xercesc::DOMElement* polyhedra_dimensionsElement >> 357 = NewElement("polyhedra_dimensions"); >> 358 >> 359 polyhedra_dimensionsElement->setAttributeNode(NewAttribute("numRZ", >> 360 polyhedra->GetOriginalParameters()->Num_z_planes)); >> 361 polyhedra_dimensionsElement->setAttributeNode(NewAttribute("numSide", >> 362 polyhedra->GetOriginalParameters()->numSide)); >> 363 polyhedra_dimensionsElement->setAttributeNode(NewAttribute("startPhi", >> 364 polyhedra->GetOriginalParameters()->Start_angle/degree)); >> 365 polyhedra_dimensionsElement->setAttributeNode(NewAttribute("openPhi", >> 366 polyhedra->GetOriginalParameters()->Opening_angle/degree)); >> 367 polyhedra_dimensionsElement->setAttributeNode(NewAttribute("aunit","deg")); >> 368 polyhedra_dimensionsElement->setAttributeNode(NewAttribute("lunit","mm")); >> 369 >> 370 parametersElement->appendChild(polyhedra_dimensionsElement); >> 371 const size_t num_zplanes = polyhedra->GetOriginalParameters()->Num_z_planes; >> 372 const G4double* z_array = polyhedra->GetOriginalParameters()->Z_values; >> 373 const G4double* rmin_array = polyhedra->GetOriginalParameters()->Rmin; >> 374 const G4double* rmax_array = polyhedra->GetOriginalParameters()->Rmax; >> 375 >> 376 for (size_t i=0; i<num_zplanes; i++) >> 377 { >> 378 ZplaneWrite(polyhedra_dimensionsElement,z_array[i], >> 379 rmin_array[i],rmax_array[i]); >> 380 } >> 381 } >> 382 >> 383 void G4GDMLWriteParamvol:: >> 384 ParametersWrite(xercesc::DOMElement* paramvolElement, >> 385 const G4VPhysicalVolume* const paramvol,const G4int& index) >> 386 { >> 387 paramvol->GetParameterisation() >> 388 ->ComputeTransformation(index, const_cast<G4VPhysicalVolume*>(paramvol)); >> 389 G4ThreeVector Angles; >> 390 G4String name = GenerateName(paramvol->GetName(),paramvol); >> 391 std::stringstream os; >> 392 os.precision(15); >> 393 os << index; >> 394 G4String sncopie = os.str(); >> 395 >> 396 xercesc::DOMElement* parametersElement = NewElement("parameters"); >> 397 parametersElement->setAttributeNode(NewAttribute("number",index+1)); >> 398 >> 399 PositionWrite(parametersElement, name+sncopie+"_pos", >> 400 paramvol->GetObjectTranslation()); >> 401 Angles=GetAngles(paramvol->GetObjectRotationValue()); >> 402 if (Angles.mag2()>DBL_EPSILON) >> 403 { >> 404 RotationWrite(parametersElement, name+sncopie+"_rot", >> 405 GetAngles(paramvol->GetObjectRotationValue())); >> 406 } >> 407 paramvolElement->appendChild(parametersElement); >> 408 >> 409 G4VSolid* solid = paramvol->GetLogicalVolume()->GetSolid(); >> 410 >> 411 if (G4Box* box = dynamic_cast<G4Box*>(solid)) >> 412 { >> 413 paramvol->GetParameterisation()->ComputeDimensions(*box,index, >> 414 const_cast<G4VPhysicalVolume*>(paramvol)); >> 415 Box_dimensionsWrite(parametersElement,box); >> 416 } else >> 417 if (G4Trd* trd = dynamic_cast<G4Trd*>(solid)) >> 418 { >> 419 paramvol->GetParameterisation()->ComputeDimensions(*trd,index, >> 420 const_cast<G4VPhysicalVolume*>(paramvol)); >> 421 Trd_dimensionsWrite(parametersElement,trd); >> 422 } else >> 423 if (G4Trap* trap = dynamic_cast<G4Trap*>(solid)) >> 424 { >> 425 paramvol->GetParameterisation()->ComputeDimensions(*trap,index, >> 426 const_cast<G4VPhysicalVolume*>(paramvol)); >> 427 Trap_dimensionsWrite(parametersElement,trap); >> 428 } else >> 429 if (G4Tubs* tube = dynamic_cast<G4Tubs*>(solid)) >> 430 { >> 431 paramvol->GetParameterisation()->ComputeDimensions(*tube,index, >> 432 const_cast<G4VPhysicalVolume*>(paramvol)); >> 433 Tube_dimensionsWrite(parametersElement,tube); >> 434 } else >> 435 if (G4Cons* cone = dynamic_cast<G4Cons*>(solid)) >> 436 { >> 437 paramvol->GetParameterisation()->ComputeDimensions(*cone,index, >> 438 const_cast<G4VPhysicalVolume*>(paramvol)); >> 439 Cone_dimensionsWrite(parametersElement,cone); >> 440 } else >> 441 if (G4Sphere* sphere = dynamic_cast<G4Sphere*>(solid)) >> 442 { >> 443 paramvol->GetParameterisation()->ComputeDimensions(*sphere,index, >> 444 const_cast<G4VPhysicalVolume*>(paramvol)); >> 445 Sphere_dimensionsWrite(parametersElement,sphere); >> 446 } else >> 447 if (G4Orb* orb = dynamic_cast<G4Orb*>(solid)) >> 448 { >> 449 paramvol->GetParameterisation()->ComputeDimensions(*orb,index, >> 450 const_cast<G4VPhysicalVolume*>(paramvol)); >> 451 Orb_dimensionsWrite(parametersElement,orb); >> 452 } else >> 453 if (G4Torus* torus = dynamic_cast<G4Torus*>(solid)) >> 454 { >> 455 paramvol->GetParameterisation()->ComputeDimensions(*torus,index, >> 456 const_cast<G4VPhysicalVolume*>(paramvol)); >> 457 Torus_dimensionsWrite(parametersElement,torus); >> 458 } else >> 459 if (G4Ellipsoid* ellipsoid = dynamic_cast<G4Ellipsoid*>(solid)) >> 460 { >> 461 paramvol->GetParameterisation()->ComputeDimensions(*ellipsoid,index, >> 462 const_cast<G4VPhysicalVolume*>(paramvol)); >> 463 Ellipsoid_dimensionsWrite(parametersElement,ellipsoid); >> 464 } else >> 465 if (G4Para* para = dynamic_cast<G4Para*>(solid)) >> 466 { >> 467 paramvol->GetParameterisation()->ComputeDimensions(*para,index, >> 468 const_cast<G4VPhysicalVolume*>(paramvol)); >> 469 Para_dimensionsWrite(parametersElement,para); >> 470 } else >> 471 if (G4Hype* hype = dynamic_cast<G4Hype*>(solid)) >> 472 { >> 473 paramvol->GetParameterisation()->ComputeDimensions(*hype,index, >> 474 const_cast<G4VPhysicalVolume*>(paramvol)); >> 475 Hype_dimensionsWrite(parametersElement,hype); >> 476 }else >> 477 if (G4Polycone* pcone = dynamic_cast<G4Polycone*>(solid)) >> 478 { >> 479 paramvol->GetParameterisation()->ComputeDimensions(*pcone,index, >> 480 const_cast<G4VPhysicalVolume*>(paramvol)); >> 481 Polycone_dimensionsWrite(parametersElement,pcone); >> 482 }else >> 483 if (G4Polyhedra* polyhedra = dynamic_cast<G4Polyhedra*>(solid)) >> 484 { >> 485 paramvol->GetParameterisation()->ComputeDimensions(*polyhedra,index, >> 486 const_cast<G4VPhysicalVolume*>(paramvol)); >> 487 Polyhedra_dimensionsWrite(parametersElement,polyhedra); >> 488 } >> 489 else >> 490 { >> 491 G4String error_msg = "Solid '" + solid->GetName() >> 492 + "' cannot be used in parameterised volume!"; >> 493 G4Exception("G4GDMLWriteParamvol::ParametersWrite()", >> 494 "InvalidSetup", FatalException, error_msg); >> 495 } >> 496 } >> 497 >> 498 void G4GDMLWriteParamvol:: >> 499 ParamvolWrite(xercesc::DOMElement* volumeElement, >> 500 const G4VPhysicalVolume* const paramvol) >> 501 { >> 502 const G4String volumeref = >> 503 GenerateName(paramvol->GetLogicalVolume()->GetName(), >> 504 paramvol->GetLogicalVolume()); >> 505 xercesc::DOMElement* paramvolElement = NewElement("paramvol"); >> 506 paramvolElement->setAttributeNode(NewAttribute("ncopies", >> 507 paramvol->GetMultiplicity())); >> 508 xercesc::DOMElement* volumerefElement = NewElement("volumeref"); >> 509 volumerefElement->setAttributeNode(NewAttribute("ref",volumeref)); >> 510 >> 511 xercesc::DOMElement* algorithmElement = >> 512 NewElement("parameterised_position_size"); >> 513 paramvolElement->appendChild(volumerefElement); >> 514 paramvolElement->appendChild(algorithmElement); >> 515 ParamvolAlgorithmWrite(algorithmElement,paramvol); >> 516 volumeElement->appendChild(paramvolElement); >> 517 } >> 518 >> 519 void G4GDMLWriteParamvol:: >> 520 ParamvolAlgorithmWrite(xercesc::DOMElement* paramvolElement, >> 521 const G4VPhysicalVolume* const paramvol) >> 522 { >> 523 const G4String volumeref = >> 524 GenerateName(paramvol->GetLogicalVolume()->GetName(), >> 525 paramvol->GetLogicalVolume()); >> 526 >> 527 const G4int parameterCount = paramvol->GetMultiplicity(); >> 528 >> 529 for (G4int i=0; i<parameterCount; i++) >> 530 { >> 531 ParametersWrite(paramvolElement,paramvol,i); >> 532 } 510 } 533 } 511 534