35 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
42 using namespace CLHEP;
55 : Base_t(name, phiStart, phiTotal, numZPlanes, zPlane, rInner, rOuter)
58 SetOriginalParameters();
71 for (
G4int i=0; i<numZPlanes; ++i)
77 for (
G4int i=numZPlanes-1; i>=0; --i)
83 std::vector<G4int> iout;
92 G4UPolycone::G4UPolycone(
const G4String& name,
98 : Base_t(name, phiStart, phiTotal, numRZ, r, z)
101 SetOriginalParameters();
102 wrStart = phiStart;
while (wrStart < 0) wrStart +=
twopi;
110 for (
G4int i=0; i<numRZ; ++i)
114 std::vector<G4int> iout;
124 G4UPolycone::G4UPolycone( __void__&
a )
134 G4UPolycone::~G4UPolycone()
143 G4UPolycone::G4UPolycone(
const G4UPolycone &source )
146 fGenericPcon = source.fGenericPcon;
147 fOriginalParameters = source.fOriginalParameters;
148 wrStart = source.wrStart;
149 wrDelta = source.wrDelta;
150 rzcorners = source.rzcorners;
158 G4UPolycone &G4UPolycone::operator=(
const G4UPolycone &source )
160 if (
this == &source)
return *
this;
162 Base_t::operator=( source );
163 fGenericPcon = source.fGenericPcon;
164 fOriginalParameters = source.fOriginalParameters;
165 wrStart = source.wrStart;
166 wrDelta = source.wrDelta;
167 rzcorners = source.rzcorners;
177 G4double G4UPolycone::GetStartPhi()
const
181 G4double G4UPolycone::GetDeltaPhi()
const
185 G4double G4UPolycone::GetEndPhi()
const
187 return (wrStart + wrDelta);
189 G4double G4UPolycone::GetSinStartPhi()
const
191 if (!IsOpen())
return 0;
193 return std::sin(phi);
195 G4double G4UPolycone::GetCosStartPhi()
const
197 if (!IsOpen())
return 1;
199 return std::cos(phi);
201 G4double G4UPolycone::GetSinEndPhi()
const
203 if (!IsOpen())
return 0;
205 return std::sin(phi);
207 G4double G4UPolycone::GetCosEndPhi()
const
209 if (!IsOpen())
return 1;
211 return std::cos(phi);
213 G4bool G4UPolycone::IsOpen()
const
215 return (wrDelta <
twopi);
217 G4int G4UPolycone::GetNumRZCorner()
const
219 return rzcorners.size();
232 void G4UPolycone::SetOriginalParameters()
234 vecgeom::PolyconeHistorical* original_parameters = Base_t::GetOriginalParameters();
236 fOriginalParameters.Start_angle = original_parameters->fHStart_angle;
237 fOriginalParameters.Opening_angle = original_parameters->fHOpening_angle;
238 fOriginalParameters.Num_z_planes = original_parameters->fHNum_z_planes;
240 delete [] fOriginalParameters.Z_values;
241 delete [] fOriginalParameters.Rmin;
242 delete [] fOriginalParameters.Rmax;
244 G4int numPlanes = fOriginalParameters.Num_z_planes;
245 fOriginalParameters.Z_values =
new G4double[numPlanes];
246 fOriginalParameters.Rmin =
new G4double[numPlanes];
247 fOriginalParameters.Rmax =
new G4double[numPlanes];
248 for (
G4int i=0; i<numPlanes; ++i)
250 fOriginalParameters.Z_values[i] = original_parameters->fHZ_values[i];
251 fOriginalParameters.Rmin[i] = original_parameters->fHRmin[i];
252 fOriginalParameters.Rmax[i] = original_parameters->fHRmax[i];
257 fOriginalParameters = *pars;
258 fRebuildPolyhedron =
true;
267 message <<
"Solid " << GetName() <<
" built using generic construct."
268 <<
G4endl <<
"Not applicable to the generic construct !";
269 G4Exception(
"G4UPolycone::Reset()",
"GeomSolids1001",
277 wrStart = fOriginalParameters.Start_angle;
282 wrDelta = fOriginalParameters.Opening_angle;
289 for (
G4int i=0; i<fOriginalParameters.Num_z_planes; ++i)
291 G4double z = fOriginalParameters.Z_values[i];
292 G4double r = fOriginalParameters.Rmax[i];
295 for (
G4int i=fOriginalParameters.Num_z_planes-1; i>=0; --i)
297 G4double z = fOriginalParameters.Z_values[i];
298 G4double r = fOriginalParameters.Rmin[i];
301 std::vector<G4int> iout;
324 G4VSolid* G4UPolycone::Clone()
const
326 return new G4UPolycone(*
this);
336 static G4bool checkBBox =
true;
337 static G4bool checkPhi =
true;
342 for (
G4int i=0; i<GetNumRZCorner(); ++i)
345 if (corner.
r < rmin) rmin = corner.
r;
346 if (corner.
r > rmax) rmax = corner.
r;
347 if (corner.
z < zmin) zmin = corner.
z;
348 if (corner.
z > zmax) zmax = corner.
z;
355 GetSinStartPhi(),GetCosStartPhi(),
356 GetSinEndPhi(),GetCosEndPhi(),
358 pMin.
set(vmin.
x(),vmin.
y(),zmin);
359 pMax.
set(vmax.
x(),vmax.
y(),zmax);
363 pMin.
set(-rmax,-rmax, zmin);
364 pMax.
set( rmax, rmax, zmax);
369 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
372 message <<
"Bad bounding box (min >= max) for solid: "
374 <<
"\npMin = " << pMin
375 <<
"\npMax = " << pMax;
376 G4Exception(
"G4UPolycone::BoundingLimits()",
"GeomMgt0001",
395 message <<
"Inconsistency in bounding boxes for solid: "
397 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
398 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
399 G4Exception(
"G4UPolycone::BoundingLimits()",
"GeomMgt0001",
409 if (GetStartPhi() != Base_t::GetStartPhi() ||
410 GetEndPhi() != Base_t::GetEndPhi() ||
411 IsOpen() != (Base_t::GetDeltaPhi() <
twopi))
414 message <<
"Inconsistency in Phi angles or # of sides for solid: "
416 <<
"\nPhi start : wrapper = " << GetStartPhi()
417 <<
" solid = " << Base_t::GetStartPhi()
418 <<
"\nPhi end : wrapper = " << GetEndPhi()
419 <<
" solid = " << Base_t::GetEndPhi()
420 <<
"\nPhi is open: wrapper = " << (IsOpen() ?
"true" :
"false")
422 << ((Base_t::GetDeltaPhi() <
twopi) ?
"true" :
"false");
423 G4Exception(
"G4UPolycone::BoundingLimits()",
"GeomMgt0001",
434 G4bool G4UPolycone::CalculateExtent(
const EAxis pAxis,
444 BoundingLimits(bmin,bmax);
447 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
449 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
451 return exist = (pMin < pMax) ?
true :
false;
460 std::vector<G4int> iout;
465 for (
G4int i=0; i<GetNumRZCorner(); ++i)
472 if (area < 0.)
std::reverse(contourRZ.begin(),contourRZ.end());
478 message <<
"Triangulation of RZ contour has failed for solid: "
480 <<
"\nExtent has been calculated using boundary box";
483 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
487 const G4int NSTEPS = 24;
493 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
496 G4double sinHalf = std::sin(0.5*ang);
497 G4double cosHalf = std::cos(0.5*ang);
498 G4double sinStep = 2.*sinHalf*cosHalf;
499 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
501 G4double sinStart = GetSinStartPhi();
502 G4double cosStart = GetCosStartPhi();
507 std::vector<const G4ThreeVectorList *> polygons;
508 polygons.resize(ksteps+2);
510 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(6);
511 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
518 G4int ntria = triangles.size()/3;
519 for (
G4int i=0; i<ntria; ++i)
522 for (
G4int k=0; k<3; ++k)
524 G4int e0 = i3+k, e1 = (k<2) ? e0+1 : i3;
527 r0[k2+0] = triangles[e0].x(); z0[k2+0] = triangles[e0].y();
528 r0[k2+1] = triangles[e1].x(); z0[k2+1] = triangles[e1].y();
532 if (z0[k2+1] - z0[k2+0] <= 0)
continue;
538 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
539 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
540 for (
G4int j=0; j<6; ++j) pols[0][j].set(r0[j]*cosStart,r0[j]*sinStart,z0[j]);
541 for (
G4int k=1; k<ksteps+1; ++k)
543 for (
G4int j=0; j<6; ++j) pols[k][j].set(r1[j]*cosCur,r1[j]*sinCur,z0[j]);
545 sinCur = sinCur*cosStep + cosCur*sinStep;
546 cosCur = cosCur*cosStep - sinTmp*sinStep;
548 for (
G4int j=0; j<6; ++j) pols[ksteps+1][j].set(r0[j]*cosEnd,r0[j]*sinEnd,z0[j]);
553 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
554 if (emin < pMin) pMin = emin;
555 if (emax > pMax) pMax =
emax;
556 if (eminlim > pMin && emaxlim < pMax)
return true;
558 return (pMin < pMax);
569 fOriginalParameters.Opening_angle,
570 fOriginalParameters.Num_z_planes,
571 fOriginalParameters.Z_values,
572 fOriginalParameters.Rmin,
573 fOriginalParameters.Rmax );
577 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
G4double GetMaxExtent(const EAxis pAxis) const
std::vector< ExP01TrackerHit * > a
static const G4double kInfinity
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
CLHEP::Hep2Vector G4TwoVector
void message(RunManager *runmanager)
static const G4double emax
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
G4double GetMinExtent(const EAxis pAxis) const
static constexpr double deg
ntupleExperimental Reset()
static constexpr double twopi
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout