35 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
55 : G4USolid(name, new UPolyhedra(name,phiStart, phiTotal, numSide,
56 numZPlanes, zPlane, rInner, rOuter))
72 : G4USolid(name, new UPolyhedra(name, phiStart, phiTotal, numSide,
83 G4UPolyhedra::G4UPolyhedra( __void__&
a )
93 G4UPolyhedra::~G4UPolyhedra()
102 G4UPolyhedra::G4UPolyhedra(
const G4UPolyhedra &source )
112 G4UPolyhedra& G4UPolyhedra::operator=(
const G4UPolyhedra &source )
114 if (
this == &source)
return *
this;
116 G4USolid::operator=( source );
126 G4int G4UPolyhedra::GetNumSide()
const
128 return GetShape()->GetNumSide();
130 G4double G4UPolyhedra::GetStartPhi()
const
132 return GetShape()->GetStartPhi();
134 G4double G4UPolyhedra::GetEndPhi()
const
136 return GetShape()->GetEndPhi();
138 G4bool G4UPolyhedra::IsOpen()
const
140 return GetShape()->IsOpen();
142 G4bool G4UPolyhedra::IsGeneric()
const
144 return GetShape()->IsGeneric();
146 G4int G4UPolyhedra::GetNumRZCorner()
const
148 return GetShape()->GetNumRZCorner();
152 UPolyhedraSideRZ pside = GetShape()->GetCorner(index);
159 UPolyhedraHistorical* pars = GetShape()->GetOriginalParameters();
163 pdata->
numSide = pars->fNumSide;
164 for (
G4int i=0; i<pars->fNumZPlanes; ++i)
166 pdata->
Z_values[i] = pars->fZValues[i];
167 pdata->
Rmin[i] = pars->Rmin[i];
168 pdata->
Rmax[i] = pars->Rmax[i];
174 UPolyhedraHistorical* pdata = GetShape()->GetOriginalParameters();
177 pdata->fNumSide = pars->
numSide;
179 for (
G4int i=0; i<pdata->fNumZPlanes; ++i)
181 pdata->fZValues[i] = pars->
Z_values[i];
182 pdata->Rmin[i] = pars->
Rmin[i];
183 pdata->Rmax[i] = pars->
Rmax[i];
185 fRebuildPolyhedron =
true;
187 G4bool G4UPolyhedra::Reset()
189 return GetShape()->Reset();
210 G4VSolid* G4UPolyhedra::Clone()
const
212 return new G4UPolyhedra(*
this);
227 GetOriginalParameters()->Opening_angle,
228 GetOriginalParameters()->numSide,
229 GetOriginalParameters()->Num_z_planes,
230 GetOriginalParameters()->Z_values,
231 GetOriginalParameters()->Rmin,
232 GetOriginalParameters()->Rmax);
233 delete original_parameters;
264 typedef G4int int4[4];
271 std::vector<G4bool> chopped(GetNumRZCorner(),
false);
272 std::vector<G4int*> triQuads;
273 G4int remaining = GetNumRZCorner();
275 while (remaining >= 3)
280 G4int iStepper = iStarter;
283 if (A < 0) { A = iStepper; }
284 else if (
B < 0) {
B = iStepper; }
285 else if (
C < 0) {
C = iStepper; }
288 if (++iStepper >= GetNumRZCorner()) iStepper = 0;
290 while (chopped[iStepper]);
292 while (
C < 0 && iStepper != iStarter);
297 G4double BAr = GetCorner(A).r - GetCorner(
B).r;
298 G4double BAz = GetCorner(A).z - GetCorner(
B).z;
299 G4double BCr = GetCorner(
C).r - GetCorner(
B).r;
300 G4double BCz = GetCorner(
C).z - GetCorner(
B).z;
301 if (BAr * BCz - BAz * BCr < kCarTolerance)
307 triQuads.push_back(tq);
315 if (++iStarter >= GetNumRZCorner()) { iStarter = 0; }
317 while (chopped[iStarter]);
322 G4int numSide=GetNumSide();
323 nNodes = (numSide + 1) * GetNumRZCorner();
324 nFaces = numSide * GetNumRZCorner() + 2 * triQuads.size();
325 faces_vec =
new int4[nFaces];
327 G4int addition = GetNumRZCorner() * numSide;
328 G4int d = GetNumRZCorner() - 1;
329 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
331 for (
size_t i = 0; i < triQuads.size(); ++i)
344 a = triQuads[i][0] + addition;
345 b = triQuads[i][2] + addition;
346 c = triQuads[i][1] + addition;
349 G4int bc = std::abs(c - b);
350 G4int ca = std::abs(a - c);
351 faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
352 faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
353 faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
354 faces_vec[iface][3] = 0;
361 xyz =
new double3[nNodes];
362 const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
365 for (
G4int iSide = 0; iSide < numSide; ++iSide)
367 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
369 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
370 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
371 xyz[ixyz][2] = GetCorner(iCorner).z;
372 if (iCorner < GetNumRZCorner() - 1)
374 faces_vec[iface][0] = ixyz + 1;
375 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
376 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
377 faces_vec[iface][3] = ixyz + 2;
381 faces_vec[iface][0] = ixyz + 1;
382 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
383 faces_vec[iface][2] = ixyz + 2;
384 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
394 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
396 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
397 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
398 xyz[ixyz][2] = GetCorner(iCorner).z;
404 nNodes = GetNumSide() * GetNumRZCorner();
405 nFaces = GetNumSide() * GetNumRZCorner();;
406 xyz =
new double3[nNodes];
407 faces_vec =
new int4[nFaces];
411 G4int ixyz = 0, iface = 0;
412 for (
G4int iSide = 0; iSide < GetNumSide(); ++iSide)
414 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
416 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
417 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
418 xyz[ixyz][2] = GetCorner(iCorner).z;
419 if (iSide < GetNumSide() - 1)
421 if (iCorner < GetNumRZCorner() - 1)
423 faces_vec[iface][0] = ixyz + 1;
424 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
425 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
426 faces_vec[iface][3] = ixyz + 2;
430 faces_vec[iface][0] = ixyz + 1;
431 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
432 faces_vec[iface][2] = ixyz + 2;
433 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
438 if (iCorner < GetNumRZCorner() - 1)
440 faces_vec[iface][0] = ixyz + 1;
441 faces_vec[iface][1] = ixyz + GetNumRZCorner() - nFaces + 1;
442 faces_vec[iface][2] = ixyz + GetNumRZCorner() - nFaces + 2;
443 faces_vec[iface][3] = ixyz + 2;
447 faces_vec[iface][0] = ixyz + 1;
448 faces_vec[iface][1] = ixyz - nFaces + GetNumRZCorner() + 1;
449 faces_vec[iface][2] = ixyz - nFaces + 2;
450 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
460 G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
465 std::ostringstream message;
466 message <<
"Problem creating G4Polyhedron for: " << GetName();
467 G4Exception(
"G4Polyhedra::CreatePolyhedron()",
"GeomSolids1002",
479 #endif // G4GEOM_USE_USOLIDS
double B(double temperature)
double A(double temperature)
static const double twopi
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const