110 : theTgrVolume(0), theG4AssemblyVolume(0)
142 G4bool bFirstCopy =
false;
182 std::pair<G4mmapspl::iterator, G4mmapspl::iterator> children
184 G4mmapspl::iterator cite;
185 for( cite = children.first; cite != children.second; cite++ )
213 if( sol == 0 ) {
return 0; }
218 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid():" <<
G4endl
219 <<
" SOLID = " << sol <<
G4endl
228 if( solid ) {
return solid; }
235 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid() - "
240 std::vector<G4double> solParam;
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: "
706 const unsigned int NoParamExpected,
707 const unsigned int NoParam )
709 if( NoParamExpected != NoParam )
711 G4String Err1 =
"Solid type " + solidType +
" should have ";
716 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
717 G4Exception(
"G4tgbVolume::CheckNoSolidParams()",
"InvalidSetup",
740 G4String ErrMessage =
"Material not found "
742 +
" for volume " +
GetName() +
".";
743 G4Exception(
"G4tgbVolume::ConstructG4LogVol()",
"InvalidSetup",
749 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
756 const_cast<G4Material*>(mate),
GetName() );
761 G4cout <<
" Constructing new G4LogicalVolume: "
773 G4cout <<
" Constructing new G4VisAttributes: "
804 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
828 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - World: "
833 const_cast<G4LogicalVolume*>(currentLV),
839 G4cout <<
" Constructing new : G4PVPlacement "
852 <<
" inside " << parentLV->
GetName() <<
" copy No: " << copyNo
864 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - Placement type = "
870 if( place->
GetType() ==
"PlaceSimple" )
882 if (1-std::abs(check)>tol)
884 G4cerr <<
" Matrix : " << rmName <<
" " << rotmat->
colX()
886 <<
" product x X y * z = " << check <<
" x X y "
888 G4String ErrMessage =
"Rotation is not ortogonal " + rmName +
" !";
893 else if (1+check<=tol)
898 const_cast<G4LogicalVolume*>(currentLV),
899 const_cast<G4LogicalVolume*>(parentLV),
900 false, copyNo,
false )).
first;
907 G4cout <<
"Construction new G4VPhysicalVolume"
908 <<
" through G4ReflectionFactory " <<
GetName()
909 <<
" in volume " << parentLV->
GetName()
910 <<
" copyNo " << copyNo
912 <<
" ROT " << rotmat->
colX()
913 <<
" " << rotmat->
colY()
927 else if( place->
GetType() ==
"PlaceParam" )
935 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
968 G4String ErrMessage =
"Parameterisation has wrong type, TYPE: "
970 G4Exception(
"G4tgbVolume::ConstructG4PhysVol",
"WrongArgument",
977 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
978 <<
" New G4PVParameterised: " <<
GetName() <<
" vol "
980 <<
" axis " << param->
GetAxis() <<
" nCopies "
985 const_cast<G4LogicalVolume*>(currentLV),
986 const_cast<G4LogicalVolume*>(parentLV),
992 G4cout <<
" Constructing new G4PVParameterised: "
1000 else if( place->
GetType() ==
"PlaceReplica" )
1008 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1009 <<
" replica" <<
" " << currentLV->
GetName()
1010 <<
" in " << parentLV->
GetName()
1016 const_cast<G4LogicalVolume*>(currentLV),
1017 const_cast<G4LogicalVolume*>(parentLV),
1023 G4cout <<
" Constructing new G4PVReplica: "
1025 <<
" in " << parentLV->
GetName()
1040 const_cast<G4Material*>(mate),
1045 G4cout <<
" Constructed new G4LogicalVolume for division: "
1046 << divLV->
GetName() <<
" mate " << mate->GetName() <<
G4endl;
1055 const_cast<G4LogicalVolume*>(parentLV),
1061 G4cout <<
" Constructing new G4PVDivision by number of divisions: "
1063 <<
" axis " << placeDiv->
GetAxis()
1064 <<
" Ndiv " << placeDiv->
GetNDiv()
1071 const_cast<G4LogicalVolume*>(parentLV),
1077 G4cout <<
" Constructing new G4PVDivision by width: "
1079 <<
" axis " << placeDiv->
GetAxis()
1080 <<
" width " << placeDiv->
GetWidth()
1087 const_cast<G4LogicalVolume*>(parentLV),
1094 G4cout <<
" Constructing new G4PVDivision by width"
1095 <<
" and number of divisions: "
1097 <<
" axis " << placeDiv->
GetAxis()
1098 <<
" Ndiv " << placeDiv->
GetNDiv()
1099 <<
" width " << placeDiv->
GetWidth()
1117 G4cout <<
" Constructing new G4AssemblyVolume: "
1118 <<
" number of assembly components "
1145 G4cout <<
" G4AssemblyVolume->AddPlacedVolume " << ii
1147 <<
" translation " << transl
1148 <<
" rotmat " << rotmat->
colX()
1149 <<
" " << rotmat->
colY()
1171 G4String ErrMessage =
"Volume type not supported: "
1173 G4Exception(
"G4tgbVolume::ConstructG4PhysVol()",
"NotImplemented",
1257 origParam.
Rmin[ii] = origParam.
Rmin[ii]*redf;
1258 origParam.
Rmax[ii] = origParam.
Rmax[ii]*redf;
1266 else if ( parentSolid->
GetEntityType() ==
"G4GenericPolycone" )
1272 for(
G4int ii = 0; ii < numRZ; ii++ )
1280 delete [] r;
delete []
z;
1289 origParam.
Rmin[ii] = origParam.
Rmin[ii]*redf;
1290 origParam.
Rmax[ii] = origParam.
Rmax[ii]*redf;
1300 G4String ErrMessage =
"Solid type not supported. VOLUME= " +
GetName()
1302 +
"Only supported types are: G4Box, G4Tubs, G4Cons,"
1303 +
" G4Trd, G4Para, G4Polycone, G4Polyhedra.";
1304 G4Exception(
"G4tgbVolume::BuildSolidForDivision()",
"NotImplemented",
1312 G4cout <<
" Constructing new G4Solid for division: "
G4ThreeVector GetRelativePlace() const
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)
const G4String & GetType() const
G4double GetInnerRadiusMinusZ() const
const G4String & GetComponentName(G4int ii) const
CLHEP::Hep3Vector G4ThreeVector
void ConstructG4Volumes(const G4tgrPlace *place, const G4LogicalVolume *parentLV)
static G4int GetVerboseLevel()
G4LogicalVolume * GetLogicalVolume() const
static G4tgbMaterialMgr * GetInstance()
virtual G4VisExtent GetExtent() const
const G4String & GetParamType() const
G4double GetTanAlpha() const
G4double GetWidth() const
G4double GetStartPhi() const
G4double GetEndPhi() const
const G4String & GetType() const
CLHEP::Hep2Vector G4TwoVector
virtual const G4String & GetRelativeRotMatName() const
const G4String & GetMaterialName() const
G4Material * FindOrBuildG4Material(const G4String &name, G4bool bMustExist=1)
const G4double * GetColour() const
G4tgrSolid * GetSolid() const
G4double GetXHalfLength() const
G4double GetAngularTolerance() const
G4DivType GetDivType() const
unsigned int GetCopyNo() const
G4ThreeVector GetSymAxis() const
G4double GetOuterRadiusMinusZ() const
G4PolyhedraHistorical * GetOriginalParameters() const
G4double GetDeltaPhiAngle() const
G4double GetOuterRadiusPlusZ() const
G4LogicalVolume * ConstructG4LogVol(const G4VSolid *solid)
G4double GetZHalfLength() const
G4double GetYHalfLength2() const
G4double GetZHalfLength() const
static G4tgbVolumeMgr * GetInstance()
G4double GetXHalfLength1() const
G4VSolid * BuildSolidForDivision(G4VSolid *parentSolid, EAxis axis)
G4bool AddFacet(G4VFacet *aFacet)
const G4String & GetName() const
const G4String & GetName() const
G4ThreeVector GetComponentPos(G4int ii) const
const G4String & GetName() const
G4tgrVolume * theTgrVolume
G4bool GetVisibility() const
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
void RegisterMe(const G4tgbVolume *vol)
G4RotationMatrix * FindOrBuildG4RotMatrix(const G4String &name)
G4VSolid * FindG4Solid(const G4String &name)
G4double GetStartPhi() const
static constexpr double deg
G4double GetInnerRadius() const
void CheckNoSolidParams(const G4String &solidType, const unsigned int NoParamExpected, const unsigned int NoParam)
static constexpr double twopi
G4double GetEndPhi() const
G4AssemblyVolume * theG4AssemblyVolume
G4VSolid * FindOrConstructG4Solid(const G4tgrSolid *vol)
G4tgrPlaceDivRep * GetPlaceDivision()
G4double GetInnerRadiusPlusZ() const
G4double GetZHalfLength() const
G4double GetStartPhiAngle() const
G4double GetXHalfLength() const
void SetVisAttributes(const G4VisAttributes *pVA)
G4double GetYHalfLength1() const
G4GLOB_DLL std::ostream G4cerr
G4PolyconeSideRZ GetCorner(G4int index) const
G4bool GetCheckOverlaps() const
const G4String & GetRotMatName() const
G4LogicalVolume * FindG4LogVol(const G4String &theName, const G4bool bExists=0)
Hep3Vector cross(const Hep3Vector &) const
G4double GetEndPhi() const
const G4tgrSolid * GetSolid(G4int ii) const
G4VPhysicalVolume * ConstructG4PhysVol(const G4tgrPlace *place, const G4LogicalVolume *currentLV, const G4LogicalVolume *parentLV)
G4tgrVolume * GetVolume() const
static G4String ConvertToString(G4bool boolVal)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void SetVisibility(G4bool=true)
const std::vector< std::vector< G4double > * > GetSolidParams() const
virtual G4ThreeVector GetPlacement() const
const G4String & GetName() const
G4double GetOffset() const
G4double GetStartPhi() const
G4double GetXHalfLength2() const
G4double GetDeltaPhiAngle() const
G4double GetStartPhiAngle() const
std::pair< G4mmapspl::iterator, G4mmapspl::iterator > GetChildren(const G4String &name)
static G4tgbRotationMatrixMgr * GetInstance()
G4double GetOuterRadius() const
G4GLOB_DLL std::ostream G4cout
G4VSolid * GetSolid() const
void SetColour(const G4Colour &)
const G4String & GetType() const
static G4GeometryTolerance * GetInstance()
G4PolyconeHistorical * GetOriginalParameters() const
G4double GetZHalfLength() const
static constexpr double pi
G4tgbVolume * FindVolume(const G4String &volname)
static G4tgrVolumeMgr * GetInstance()
virtual G4GeometryType GetEntityType() const =0
G4double GetZHalfLength() const
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
const G4String & GetComponentRM(G4int ii) const
const G4String & GetName() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
void RegisterChildParentLVs(const G4LogicalVolume *logvol, const G4LogicalVolume *parentLV)
G4int GetNumRZCorner() const
G4double GetYHalfLength() const
const G4String & GetName() const
static G4ReflectionFactory * Instance()
G4int GetNoComponents() const