213   if( sol == 0 ) { 
return 0; }
 
  218     G4cout << 
" G4tgbVolume::FindOrConstructG4Solid():" << 
G4endl 
  219            << 
"   SOLID = " << sol << 
G4endl 
  220            << 
"   " << sol->GetName() << 
" of type " << sol->GetType()
 
  228   if( solid ) { 
return solid; }
 
  235     G4cout << 
" G4tgbVolume::FindOrConstructG4Solid() - " 
  236            << sol->GetSolidParams().size() << 
G4endl;
 
  240   std::vector<G4double> solParam;
 
  244   if( sol->GetSolidParams().size() == 1)
 
  246     solParam = * sol->GetSolidParams()[ 0 ];
 
  256     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],
 
  265   else if( stype == 
"TUBS" )
 
  269     if( std::fabs(phiDelta - 
twopi) < angularTolerance ) { phiDelta = 
twopi; }
 
  270     solid = 
new G4Tubs( sname, solParam[0], solParam[1], solParam[2],
 
  271                         solParam[3], phiDelta );
 
  273   else if( stype == 
"TRAP" )
 
  275     if( solParam.size() == 11 )
 
  277       solid = 
new G4Trap( sname, solParam[0], solParam[1], solParam[2],
 
  278                           solParam[3], solParam[4], solParam[5], solParam[6],
 
  279                           solParam[7], solParam[8], solParam[9], solParam[10] );
 
  281     else if( solParam.size() == 4 )
 
  283       solid = 
new G4Trap( sname, solParam[0], solParam[1]/
deg,
 
  284                           solParam[2]/
deg, solParam[3]);
 
  288       G4String ErrMessage1 = 
"Solid type " + stype;
 
  289       G4String ErrMessage2 = 
" should have 11 or 4 parameters,\n";
 
  290       G4String ErrMessage3 = 
"and it has " 
  292       G4String ErrMessage = ErrMessage1 + ErrMessage2 + ErrMessage3 + 
" !";
 
  293       G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  299   else if( stype == 
"TRD" )
 
  302     solid = 
new G4Trd( sname, solParam[0], solParam[1], solParam[2],
 
  303                        solParam[3], solParam[4] );
 
  305   else if( stype == 
"PARA" )
 
  308     solid = 
new G4Para( sname, solParam[0], solParam[1], solParam[2],
 
  309                         solParam[3], solParam[4], solParam[5] );
 
  311   else if( stype == 
"CONE" )
 
  314     solid = 
new G4Cons( sname, solParam[0], solParam[1], solParam[2],
 
  315                         solParam[3], solParam[4], 0., 360.*
deg);
 
  317   else if( stype == 
"CONS" )
 
  321     if( std::fabs(phiDelta - 
twopi) < angularTolerance ) { phiDelta = 
twopi; }
 
  322     solid = 
new G4Cons( sname, solParam[0], solParam[1], solParam[2],
 
  323                         solParam[3], solParam[4], solParam[5], phiDelta);
 
  325   else if( stype == 
"SPHERE" )
 
  329     if( std::fabs(phiDelta - 
twopi) < angularTolerance ) { phiDelta = 
twopi; }
 
  331     if( std::fabs(thetaDelta - 
pi) < angularTolerance ) { thetaDelta = 
pi; }
 
  332     solid = 
new G4Sphere( sname, solParam[0], solParam[1], solParam[2],
 
  333                           phiDelta, solParam[4], thetaDelta);
 
  335   else if( stype == 
"ORB" )
 
  338     solid = 
new G4Orb( sname, solParam[0] );
 
  340   else if( stype == 
"TORUS" )
 
  344     if( std::fabs(phiDelta - 
twopi) < angularTolerance ) { phiDelta = 
twopi; }
 
  345     solid = 
new G4Torus( sname, solParam[0], solParam[1], solParam[2],
 
  346                          solParam[3], phiDelta );
 
  348   else if( stype == 
"POLYCONE" )
 
  350     size_t nplanes = size_t(solParam[2]);
 
  351     G4bool genericPoly = 
false;
 
  352     if( solParam.size() == 3+nplanes*3 )
 
  356     else if( solParam.size() == 3+nplanes*2 )
 
  362       G4String Err1 = 
"Solid type " + stype + 
" should have ";
 
  364                     + 
" (Z,Rmin,Rmax)\n";
 
  366       G4String Err4 = 
" (RZ corners) parameters,\n";
 
  369       G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 + 
" !";
 
  370       G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  377       std::vector<G4double>* z_p = 
new std::vector<G4double>;
 
  378       std::vector<G4double>* rmin_p = 
new std::vector<G4double>;
 
  379       std::vector<G4double>* rmax_p = 
new std::vector<G4double>;
 
  380       for( 
size_t ii = 0; ii < nplanes; ii++ )
 
  382         (*z_p).push_back( solParam[3+3*ii] );
 
  383         (*rmin_p).push_back( solParam[3+3*ii+1] );
 
  384         (*rmax_p).push_back(  solParam[3+3*ii+2] );
 
  387       if( std::fabs(phiTotal - 
twopi) < angularTolerance ) { phiTotal = 
twopi; }
 
  388       solid = 
new G4Polycone( sname, solParam[0], phiTotal, 
 
  390                               &((*z_p)[0]), &((*rmin_p)[0]), &((*rmax_p)[0]));
 
  394       std::vector<G4double>* R_c = 
new std::vector<G4double>;
 
  395       std::vector<G4double>* Z_c = 
new std::vector<G4double>;
 
  396       for( 
size_t ii = 0; ii < nplanes; ii++ )
 
  398         (*R_c).push_back( solParam[3+2*ii] );
 
  399         (*Z_c).push_back( solParam[3+2*ii+1] );
 
  402       if( std::fabs(phiTotal - 
twopi) < angularTolerance ) { phiTotal = 
twopi; }
 
  404                               solParam[0], phiTotal, 
 
  406                               &((*R_c)[0]), &((*Z_c)[0]));
 
  410   else if( stype == 
"POLYHEDRA" )
 
  412     size_t nplanes = size_t(solParam[3]);
 
  413     G4bool genericPoly = 
false;
 
  414     if( solParam.size() == 4+nplanes*3 )
 
  418     else if( solParam.size() == 4+nplanes*2 )
 
  424       G4String Err1 = 
"Solid type " + stype + 
" should have ";
 
  426                     + 
" (Z,Rmin,Rmax)\n";
 
  428       G4String Err4 = 
" (RZ corners) parameters,\n";
 
  431       G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 + 
" !";
 
  432       G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  439       std::vector<G4double>* z_p = 
new std::vector<G4double>;
 
  440       std::vector<G4double>* rmin_p = 
new std::vector<G4double>;
 
  441       std::vector<G4double>* rmax_p = 
new std::vector<G4double>;
 
  442       for( 
size_t ii = 0; ii < nplanes; ii++ )
 
  444         (*z_p).push_back( solParam[4+3*ii] );
 
  445         (*rmin_p).push_back( solParam[4+3*ii+1] );
 
  446         (*rmax_p).push_back(  solParam[4+3*ii+2] );
 
  449       if( std::fabs(phiTotal - 
twopi) < angularTolerance ) { phiTotal = 
twopi; }
 
  450       solid = 
new G4Polyhedra( sname, solParam[0], phiTotal,
 
  451                                G4int(solParam[2]), nplanes,
 
  452                                &((*z_p)[0]), &((*rmin_p)[0]), &((*rmax_p)[0]));
 
  456       std::vector<G4double>* R_c = 
new std::vector<G4double>;
 
  457       std::vector<G4double>* Z_c = 
new std::vector<G4double>;
 
  458       for( 
size_t ii = 0; ii < nplanes; ii++ )
 
  460         (*R_c).push_back( solParam[4+2*ii] );
 
  461         (*Z_c).push_back( solParam[4+2*ii+1] );
 
  464       if( std::fabs(phiTotal - 
twopi) < angularTolerance ) { phiTotal = 
twopi; }
 
  465       solid = 
new G4Polyhedra( sname, solParam[0], phiTotal,
 
  466                                G4int(solParam[2]), nplanes,
 
  467                                &((*R_c)[0]), &((*Z_c)[0]));
 
  470   else if( stype == 
"ELLIPTICALTUBE" )
 
  473     solid = 
new G4EllipticalTube( sname, solParam[0], solParam[1], solParam[2]);
 
  475   else if( stype == 
"ELLIPSOID" )
 
  478     solid = 
new G4Ellipsoid( sname, solParam[0], solParam[1], solParam[2],
 
  479                              solParam[3], solParam[4] );
 
  481   else if( stype == 
"ELLIPTICALCONE" )
 
  485                                   solParam[2], solParam[3] );
 
  487   else if( stype == 
"HYPE" )
 
  490     solid = 
new G4Hype( sname, solParam[0], solParam[1], solParam[2],
 
  491                         solParam[3], solParam[4] );
 
  493   else if( stype == 
"TET" )
 
  500     solid = 
new G4Tet( sname, anchor, p2, p3, p4 );
 
  502   else if( stype == 
"TWISTEDBOX" )
 
  505     solid = 
new G4TwistedBox( sname, solParam[0], solParam[1],
 
  506                               solParam[2], solParam[3]);
 
  508   else if( stype == 
"TWISTEDTRAP" )
 
  511     solid = 
new G4TwistedTrap( sname, solParam[0], solParam[1], solParam[2],
 
  512                         solParam[3], solParam[4], solParam[5], solParam[6],
 
  513                         solParam[7], solParam[8], solParam[9], solParam[10] );
 
  515   else if( stype == 
"TWISTEDTRD" )
 
  518     solid = 
new G4TwistedTrd( sname, solParam[0], solParam[1], solParam[2],
 
  519                               solParam[3], solParam[4], solParam[5]);
 
  521   else if( stype == 
"TWISTEDTUBS" )
 
  525     if( std::fabs(phiTotal - 
twopi) < angularTolerance ) { phiTotal = 
twopi; }
 
  526     solid = 
new G4TwistedTubs( sname, solParam[0], solParam[1], solParam[2],
 
  527                                solParam[3], phiTotal);
 
  529   else if( stype == 
"TESSELLATED" )
 
  537     for( 
G4int ii = 0; ii < nFacets; ii++){
 
  539       if( 
G4int(solParam.size()) < jj + nPoints*3 + 2 ) {
 
  543     G4String ErrMessage = Err1 + Err2 + Err3 + 
" !";
 
  544     G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  551     G4ThreeVector pt0(solParam[jj+2],solParam[jj+3],solParam[jj+4]);
 
  552     G4ThreeVector vt1(solParam[jj+5],solParam[jj+6],solParam[jj+7]);
 
  553     G4ThreeVector vt2(solParam[jj+8],solParam[jj+9],solParam[jj+10]);
 
  555     if( solParam[jj+11] == 0 ) 
 
  559     else if( solParam[jj+11] == 1 )  
 
  565       G4String Err1 = 
"Wrong number of vertex type in tesselated solid, it should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
 
  568       G4String ErrMessage = Err1 + Err2 + Err3 + 
" !";
 
  569       G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  575       else if( nPoints == 4 ) 
 
  577     G4ThreeVector pt0(solParam[jj+2],solParam[jj+3],solParam[jj+4]);
 
  578     G4ThreeVector vt1(solParam[jj+5],solParam[jj+6],solParam[jj+7]);
 
  579     G4ThreeVector vt2(solParam[jj+8],solParam[jj+9],solParam[jj+10]);
 
  580     G4ThreeVector vt3(solParam[jj+11],solParam[jj+12],solParam[jj+13]);
 
  582     if( solParam[jj+14] == 0 ) 
 
  586     else if( solParam[jj+14] == 1 )
 
  592       G4String Err1 = 
"Wrong number of vertex type in tesselated solid, it should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
 
  595       G4String ErrMessage = Err1 + Err2 + Err3 + 
" !";
 
  596       G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  604     G4String Err1 = 
"Wrong number of points in tesselated solid, it should be 3 or 4";
 
  607     G4String ErrMessage = Err1 + Err2 + Err3 + 
" !";
 
  608     G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  618   else if( stype == 
"EXTRUDED" ) 
 
  620     std::vector<G4TwoVector> polygonList;
 
  621     std::vector<G4ExtrudedSolid::ZSection> zsectionList;
 
  624     G4int nMax = nPolygons*2+1;
 
  625     for( ;ii < nMax; ii+=2 )
 
  627       polygonList.push_back( 
G4TwoVector(solParam[ii],solParam[ii+1]) );
 
  630     nMax = nPolygons*2 + nZSections*4 + 2; 
 
  632     for( ; ii < nMax; ii+=4 )
 
  640   else if( stype.substr(0,7) == 
"Boolean" )
 
  645       G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  655     if( stype == 
"Boolean_UNION" )
 
  657       solid = 
new G4UnionSolid( sname, sol1, sol2, relRotMat, relPlace );
 
  659     else if( stype == 
"Boolean_SUBTRACTION" )
 
  663     else if( stype == 
"Boolean_INTERSECTION" )
 
  669       G4String ErrMessage = 
"Unknown Boolean type " + stype;
 
  670       G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
 
  677     G4String ErrMessage = 
"Solids of type " + stype
 
  678                         + 
" not implemented yet, sorry...";
 
  679     G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()", 
"NotImplemented",
 
  687     G4cout << 
" G4tgbVolume::FindOrConstructG4Solid()" << 
G4endl 
  688            << 
"   Created solid " << sname
 
  696       G4cout << 
" Constructing new G4Solid: "  
G4VSolid * FindG4Solid(const G4String &name)
 
G4VSolid * FindOrConstructG4Solid(const G4tgrSolid *vol)
 
const G4tgrSolid * GetSolid(G4int ii) const 
 
static G4tgbRotationMatrixMgr * GetInstance()
 
void CheckNoSolidParams(const G4String &solidType, const unsigned int NoParamExpected, const unsigned int NoParam)
 
static G4String ConvertToString(G4bool boolVal)
 
virtual G4GeometryType GetEntityType() const =0
 
static constexpr double twopi
 
G4ThreeVector GetRelativePlace() const 
 
G4GLOB_DLL std::ostream G4cout
 
static G4int GetVerboseLevel()
 
G4bool AddFacet(G4VFacet *aFacet)
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
CLHEP::Hep2Vector G4TwoVector
 
G4RotationMatrix * FindOrBuildG4RotMatrix(const G4String &name)
 
static constexpr double pi
 
static constexpr double deg
 
static G4tgbVolumeMgr * GetInstance()
 
G4double GetAngularTolerance() const 
 
static G4GeometryTolerance * GetInstance()