35 #if defined(G4GEOM_USE_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 );
139 G4VSolid* G4UPolyhedra::Clone()
const
141 return new G4UPolyhedra(*
this);
156 GetOriginalParameters()->Opening_angle,
157 GetOriginalParameters()->numSide,
158 GetOriginalParameters()->Num_z_planes,
159 GetOriginalParameters()->Z_values,
160 GetOriginalParameters()->Rmin,
161 GetOriginalParameters()->Rmax);
162 delete original_parameters;
193 typedef G4int int4[4];
200 std::vector<G4bool> chopped(GetNumRZCorner(),
false);
201 std::vector<G4int*> triQuads;
202 G4int remaining = GetNumRZCorner();
204 while (remaining >= 3)
209 G4int iStepper = iStarter;
212 if (A < 0) { A = iStepper; }
213 else if (
B < 0) {
B = iStepper; }
214 else if (
C < 0) {
C = iStepper; }
217 if (++iStepper >= GetNumRZCorner()) iStepper = 0;
219 while (chopped[iStepper]);
221 while (
C < 0 && iStepper != iStarter);
226 G4double BAr = GetCorner(A).r - GetCorner(
B).r;
227 G4double BAz = GetCorner(A).z - GetCorner(
B).z;
228 G4double BCr = GetCorner(
C).r - GetCorner(
B).r;
229 G4double BCz = GetCorner(
C).z - GetCorner(
B).z;
230 if (BAr * BCz - BAz * BCr < kCarTolerance)
236 triQuads.push_back(tq);
244 if (++iStarter >= GetNumRZCorner()) { iStarter = 0; }
246 while (chopped[iStarter]);
251 G4int numSide=GetNumSide();
252 nNodes = (numSide + 1) * GetNumRZCorner();
253 nFaces = numSide * GetNumRZCorner() + 2 * triQuads.size();
254 faces_vec =
new int4[nFaces];
256 G4int addition = GetNumRZCorner() * numSide;
257 G4int d = GetNumRZCorner() - 1;
258 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
260 for (
size_t i = 0; i < triQuads.size(); ++i)
273 a = triQuads[i][0] + addition;
274 b = triQuads[i][2] + addition;
275 c = triQuads[i][1] + addition;
278 G4int bc = std::abs(c - b);
279 G4int ca = std::abs(a - c);
280 faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
281 faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
282 faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
283 faces_vec[iface][3] = 0;
290 xyz =
new double3[nNodes];
291 const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
294 for (
G4int iSide = 0; iSide < numSide; ++iSide)
296 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
298 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
299 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
300 xyz[ixyz][2] = GetCorner(iCorner).z;
301 if (iCorner < GetNumRZCorner() - 1)
303 faces_vec[iface][0] = ixyz + 1;
304 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
305 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
306 faces_vec[iface][3] = ixyz + 2;
310 faces_vec[iface][0] = ixyz + 1;
311 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
312 faces_vec[iface][2] = ixyz + 2;
313 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
323 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
325 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
326 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
327 xyz[ixyz][2] = GetCorner(iCorner).z;
333 nNodes = GetNumSide() * GetNumRZCorner();
334 nFaces = GetNumSide() * GetNumRZCorner();;
335 xyz =
new double3[nNodes];
336 faces_vec =
new int4[nFaces];
340 G4int ixyz = 0, iface = 0;
341 for (
G4int iSide = 0; iSide < GetNumSide(); ++iSide)
343 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
345 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
346 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
347 xyz[ixyz][2] = GetCorner(iCorner).z;
348 if (iSide < GetNumSide() - 1)
350 if (iCorner < GetNumRZCorner() - 1)
352 faces_vec[iface][0] = ixyz + 1;
353 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
354 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
355 faces_vec[iface][3] = ixyz + 2;
359 faces_vec[iface][0] = ixyz + 1;
360 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
361 faces_vec[iface][2] = ixyz + 2;
362 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
367 if (iCorner < GetNumRZCorner() - 1)
369 faces_vec[iface][0] = ixyz + 1;
370 faces_vec[iface][1] = ixyz + GetNumRZCorner() - nFaces + 1;
371 faces_vec[iface][2] = ixyz + GetNumRZCorner() - nFaces + 2;
372 faces_vec[iface][3] = ixyz + 2;
376 faces_vec[iface][0] = ixyz + 1;
377 faces_vec[iface][1] = ixyz - nFaces + GetNumRZCorner() + 1;
378 faces_vec[iface][2] = ixyz - nFaces + 2;
379 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
389 G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
394 std::ostringstream message;
395 message <<
"Problem creating G4Polyhedron for: " << GetName();
396 G4Exception(
"G4Polyhedra::CreatePolyhedron()",
"GeomSolids1002",
408 #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