218 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid():" <<
G4endl
236 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid() - "
241 std::vector<G4double> solParam;
257 solid =
new G4Box(sname, solParam[0], solParam[1], solParam[2]);
259 else if(stype ==
"TUBE")
262 solid =
new G4Tubs(sname, solParam[0], solParam[1], solParam[2], 0. * deg,
265 else if(stype ==
"TUBS")
269 if(std::fabs(phiDelta - twopi) < angularTolerance)
273 solid =
new G4Tubs(sname, solParam[0], solParam[1], solParam[2],
274 solParam[3], phiDelta);
276 else if(stype ==
"TRAP")
278 if(solParam.size() == 11)
280 solid =
new G4Trap(sname, solParam[0], solParam[1], solParam[2],
281 solParam[3], solParam[4], solParam[5], solParam[6],
282 solParam[7], solParam[8], solParam[9], solParam[10]);
284 else if(solParam.size() == 4)
286 solid =
new G4Trap(sname, solParam[0], solParam[1] / deg,
287 solParam[2] / deg, solParam[3]);
291 G4String ErrMessage1 =
"Solid type " + stype;
292 G4String ErrMessage2 =
" should have 11 or 4 parameters,\n";
295 G4String ErrMessage = ErrMessage1 + ErrMessage2 + ErrMessage3 +
" !";
296 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
301 else if(stype ==
"TRD")
304 solid =
new G4Trd(sname, solParam[0], solParam[1], solParam[2], solParam[3],
307 else if(stype ==
"PARA")
310 solid =
new G4Para(sname, solParam[0], solParam[1], solParam[2],
311 solParam[3], solParam[4], solParam[5]);
313 else if(stype ==
"CONE")
316 solid =
new G4Cons(sname, solParam[0], solParam[1], solParam[2],
317 solParam[3], solParam[4], 0., 360. * deg);
319 else if(stype ==
"CONS")
323 if(std::fabs(phiDelta - twopi) < angularTolerance)
327 solid =
new G4Cons(sname, solParam[0], solParam[1], solParam[2],
328 solParam[3], solParam[4], solParam[5], phiDelta);
330 else if(stype ==
"SPHERE")
334 if(std::fabs(phiDelta - twopi) < angularTolerance)
339 if(std::fabs(thetaDelta - pi) < angularTolerance)
343 solid =
new G4Sphere(sname, solParam[0], solParam[1], solParam[2], phiDelta,
344 solParam[4], thetaDelta);
346 else if(stype ==
"ORB")
349 solid =
new G4Orb(sname, solParam[0]);
351 else if(stype ==
"TORUS")
355 if(std::fabs(phiDelta - twopi) < angularTolerance)
359 solid =
new G4Torus(sname, solParam[0], solParam[1], solParam[2],
360 solParam[3], phiDelta);
362 else if(stype ==
"POLYCONE"
363 || stype ==
"GENERICPOLYCONE")
365 std::size_t nplanes = std::size_t(solParam[2]);
366 G4bool genericPoly =
false;
367 if(solParam.size() == 3 + nplanes * 3)
371 else if(solParam.size() == 3 + nplanes * 2)
377 G4String Err1 =
"Solid type " + stype +
" should have ";
382 G4String Err4 =
" (RZ corners) parameters,\n";
385 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
386 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
393 std::vector<G4double>* z_p =
new std::vector<G4double>;
394 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
395 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
396 for(std::size_t ii = 0; ii < nplanes; ++ii)
398 (*z_p).push_back(solParam[3 + 3 * ii]);
399 (*rmin_p).push_back(solParam[3 + 3 * ii + 1]);
400 (*rmax_p).push_back(solParam[3 + 3 * ii + 2]);
403 if(std::fabs(phiTotal - twopi) < angularTolerance)
407 solid =
new G4Polycone(sname, solParam[0], phiTotal,
409 &((*z_p)[0]), &((*rmin_p)[0]), &((*rmax_p)[0]));
413 std::vector<G4double>* R_c =
new std::vector<G4double>;
414 std::vector<G4double>* Z_c =
new std::vector<G4double>;
415 for(
size_t ii = 0; ii < nplanes; ii++)
417 (*R_c).push_back(solParam[3 + 2 * ii]);
418 (*Z_c).push_back(solParam[3 + 2 * ii + 1]);
421 if(std::fabs(phiTotal - twopi) < angularTolerance)
428 &((*R_c)[0]), &((*Z_c)[0]));
431 else if(stype ==
"POLYHEDRA")
433 std::size_t nplanes = std::size_t(solParam[3]);
434 G4bool genericPoly =
false;
435 if(solParam.size() == 4 + nplanes * 3)
439 else if(solParam.size() == 4 + nplanes * 2)
445 G4String Err1 =
"Solid type " + stype +
" should have ";
450 G4String Err4 =
" (RZ corners) parameters,\n";
453 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
454 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
461 std::vector<G4double>* z_p =
new std::vector<G4double>;
462 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
463 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
464 for(std::size_t ii = 0; ii < nplanes; ++ii)
466 (*z_p).push_back(solParam[4 + 3 * ii]);
467 (*rmin_p).push_back(solParam[4 + 3 * ii + 1]);
468 (*rmax_p).push_back(solParam[4 + 3 * ii + 2]);
471 if(std::fabs(phiTotal - twopi) < angularTolerance)
476 (
G4int)nplanes, &((*z_p)[0]), &((*rmin_p)[0]),
481 std::vector<G4double>* R_c =
new std::vector<G4double>;
482 std::vector<G4double>* Z_c =
new std::vector<G4double>;
483 for(std::size_t ii = 0; ii < nplanes; ++ii)
485 (*R_c).push_back(solParam[4 + 2 * ii]);
486 (*Z_c).push_back(solParam[4 + 2 * ii + 1]);
489 if(std::fabs(phiTotal - twopi) < angularTolerance)
494 (
G4int)nplanes, &((*R_c)[0]), &((*Z_c)[0]));
497 else if(stype ==
"ELLIPTICALTUBE")
502 else if(stype ==
"ELLIPSOID")
505 solid =
new G4Ellipsoid(sname, solParam[0], solParam[1], solParam[2],
506 solParam[3], solParam[4]);
508 else if(stype ==
"ELLIPTICALCONE")
514 else if(stype ==
"HYPE")
517 solid =
new G4Hype(sname, solParam[0], solParam[1], solParam[2],
518 solParam[3], solParam[4]);
520 else if(stype ==
"TET")
527 solid =
new G4Tet(sname, anchor, p2, p3, p4);
529 else if(stype ==
"TWISTEDBOX")
532 solid =
new G4TwistedBox(sname, solParam[0], solParam[1], solParam[2],
535 else if(stype ==
"TWISTEDTRAP")
539 new G4TwistedTrap(sname, solParam[0], solParam[1], solParam[2],
540 solParam[3], solParam[4], solParam[5], solParam[6],
541 solParam[7], solParam[8], solParam[9], solParam[10]);
543 else if(stype ==
"TWISTEDTRD")
546 solid =
new G4TwistedTrd(sname, solParam[0], solParam[1], solParam[2],
547 solParam[3], solParam[4], solParam[5]);
549 else if(stype ==
"SCALED")
552 if(tgrSol ==
nullptr)
554 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
562 else if(stype ==
"TWISTEDTUBS")
566 if(std::fabs(phiTotal - twopi) < angularTolerance)
570 solid =
new G4TwistedTubs(sname, solParam[0], solParam[1], solParam[2],
571 solParam[3], phiTotal);
573 else if(stype ==
"TESSELLATED")
581 for(
G4int ii = 0; ii < nFacets; ++ii)
584 if(
G4int(solParam.size()) < jj + nPoints * 3 + 2)
586 G4String Err1 =
"Too small number of parameters in tesselated solid, "
587 "it should be at least " +
590 G4String Err3 =
" number of parameters is " +
592 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
593 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
600 G4ThreeVector pt0(solParam[jj + 2], solParam[jj + 3], solParam[jj + 4]);
601 G4ThreeVector vt1(solParam[jj + 5], solParam[jj + 6], solParam[jj + 7]);
605 if(solParam[jj + 11] == 0)
609 else if(solParam[jj + 11] == 1)
615 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it "
616 "should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
619 G4String Err3 =
" vertex type is " +
621 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
622 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
628 else if(nPoints == 4)
630 G4ThreeVector pt0(solParam[jj + 2], solParam[jj + 3], solParam[jj + 4]);
631 G4ThreeVector vt1(solParam[jj + 5], solParam[jj + 6], solParam[jj + 7]);
637 if(solParam[jj + 14] == 0)
641 else if(solParam[jj + 14] == 1)
647 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it "
648 "should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
651 G4String Err3 =
" vertex type is " +
653 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
654 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
663 "Wrong number of points in tesselated solid, it should be 3 or 4";
666 G4String Err3 =
" number of points is " +
668 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
669 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
675 jj += nPoints * 3 + 2;
678 else if(stype ==
"EXTRUDED")
680 std::vector<G4TwoVector> polygonList;
681 std::vector<G4ExtrudedSolid::ZSection> zsectionList;
684 G4int nMax = nPolygons * 2 + 1;
685 for(; ii < nMax; ii += 2)
687 polygonList.push_back(
G4TwoVector(solParam[ii], solParam[ii + 1]));
690 nMax = nPolygons * 2 + nZSections * 4 + 2;
692 for(; ii < nMax; ii += 4)
694 G4TwoVector offset(solParam[ii + 1], solParam[ii + 2]);
695 zsectionList.push_back(
700 else if(stype.substr(0, 7) ==
"Boolean")
705 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
716 if(stype ==
"Boolean_UNION")
718 solid =
new G4UnionSolid(sname, sol1, sol2, relRotMat, relPlace);
720 else if(stype ==
"Boolean_SUBTRACTION")
724 else if(stype ==
"Boolean_INTERSECTION")
730 G4String ErrMessage =
"Unknown Boolean type " + stype;
731 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
736 else if(stype ==
"MULTIUNION")
739 if(tgrSol ==
nullptr)
741 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
751 for (
G4int i=0; i<nsol; ++i)
758 solid =
dynamic_cast<G4VSolid*
>(solidu);
763 "Solids of type " + stype +
" not implemented yet, sorry...";
764 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"NotImplemented",
772 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid()" <<
G4endl
773 <<
" Created solid " << sname <<
" of type "
781 G4cout <<
" Constructing new G4Solid: " << *solid <<
G4endl;