36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
46 G4UGenericPolycone::G4UGenericPolycone(
const G4String&
name,
52 : G4USolid(name, new UGenericPolycone(name, phiStart, phiTotal, numRZ, r, z))
62 G4UGenericPolycone::G4UGenericPolycone(__void__&
a)
72 G4UGenericPolycone::~G4UGenericPolycone()
81 G4UGenericPolycone::G4UGenericPolycone(
const G4UGenericPolycone &source)
92 G4UGenericPolycone::operator=(
const G4UGenericPolycone &source)
94 if (
this == &source)
return *
this;
96 G4USolid::operator=( source );
101 G4double G4UGenericPolycone::GetStartPhi()
const
103 return GetShape()->GetStartPhi();
105 G4double G4UGenericPolycone::GetEndPhi()
const
107 return GetShape()->GetEndPhi();
109 G4bool G4UGenericPolycone::IsOpen()
const
111 return GetShape()->IsOpen();
113 G4int G4UGenericPolycone::GetNumRZCorner()
const
115 return GetShape()->GetNumRZCorner();
119 UPolyconeSideRZ pside = GetShape()->GetCorner(index);
125 G4Polyhedron* G4UGenericPolycone::CreatePolyhedron()
const
151 const G4int numSide =
152 G4int(G4Polyhedron::GetNumberOfRotationSteps()
153 * (GetEndPhi() - GetStartPhi()) /
twopi) + 1;
158 typedef G4int int4[4];
165 std::vector<G4bool> chopped(GetNumRZCorner(),
false);
166 std::vector<G4int*> triQuads;
167 G4int remaining = GetNumRZCorner();
169 while (remaining >= 3)
174 G4int iStepper = iStarter;
177 if (A < 0) { A = iStepper; }
178 else if (
B < 0) {
B = iStepper; }
179 else if (
C < 0) {
C = iStepper; }
182 if (++iStepper >= GetNumRZCorner()) { iStepper = 0; }
184 while (chopped[iStepper]);
186 while (
C < 0 && iStepper != iStarter);
191 G4double BAr = GetCorner(A).r - GetCorner(
B).r;
192 G4double BAz = GetCorner(A).z - GetCorner(
B).z;
193 G4double BCr = GetCorner(
C).r - GetCorner(
B).r;
194 G4double BCz = GetCorner(
C).z - GetCorner(
B).z;
195 if (BAr * BCz - BAz * BCr < kCarTolerance)
201 triQuads.push_back(tq);
209 if (++iStarter >= GetNumRZCorner()) { iStarter = 0; }
211 while (chopped[iStarter]);
216 nNodes = (numSide + 1) * GetNumRZCorner();
217 nFaces = numSide * GetNumRZCorner() + 2 * triQuads.size();
218 faces_vec =
new int4[nFaces];
220 G4int addition = GetNumRZCorner() * numSide;
221 G4int d = GetNumRZCorner() - 1;
222 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
224 for (
size_t i = 0; i < triQuads.size(); ++i)
237 a = triQuads[i][0] + addition;
238 b = triQuads[i][2] + addition;
239 c = triQuads[i][1] + addition;
242 G4int bc = std::abs(c - b);
243 G4int ca = std::abs(a - c);
244 faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
245 faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
246 faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
247 faces_vec[iface][3] = 0;
254 xyz =
new double3[nNodes];
255 const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
258 for (
G4int iSide = 0; iSide < numSide; ++iSide)
260 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
262 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
263 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
264 xyz[ixyz][2] = GetCorner(iCorner).z;
267 if (iCorner < GetNumRZCorner() - 1)
269 faces_vec[iface][0] = ixyz + 1;
270 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
271 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
272 faces_vec[iface][3] = ixyz + 2;
276 faces_vec[iface][0] = ixyz + 1;
277 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
278 faces_vec[iface][2] = ixyz + 2;
279 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
282 else if (iSide == numSide - 1)
284 if (iCorner < GetNumRZCorner() - 1)
286 faces_vec[iface][0] = ixyz + 1;
287 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
288 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
289 faces_vec[iface][3] = -(ixyz + 2);
293 faces_vec[iface][0] = ixyz + 1;
294 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
295 faces_vec[iface][2] = ixyz + 2;
296 faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
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);
324 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
326 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
327 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
328 xyz[ixyz][2] = GetCorner(iCorner).z;
334 nNodes = numSide * GetNumRZCorner();
335 nFaces = numSide * GetNumRZCorner();;
336 xyz =
new double3[nNodes];
337 faces_vec =
new int4[nFaces];
338 const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
340 G4int ixyz = 0, iface = 0;
341 for (
G4int iSide = 0; iSide < numSide; ++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;
349 if (iSide < numSide - 1)
351 if (iCorner < GetNumRZCorner() - 1)
353 faces_vec[iface][0] = ixyz + 1;
354 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
355 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
356 faces_vec[iface][3] = -(ixyz + 2);
360 faces_vec[iface][0] = ixyz + 1;
361 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
362 faces_vec[iface][2] = ixyz + 2;
363 faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
368 if (iCorner < GetNumRZCorner() - 1)
370 faces_vec[iface][0] = ixyz + 1;
371 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() - nFaces + 1);
372 faces_vec[iface][2] = ixyz + GetNumRZCorner() - nFaces + 2;
373 faces_vec[iface][3] = -(ixyz + 2);
377 faces_vec[iface][0] = ixyz + 1;
378 faces_vec[iface][1] = -(ixyz - nFaces + GetNumRZCorner() + 1);
379 faces_vec[iface][2] = ixyz - nFaces + 2;
380 faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
390 G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
395 std::ostringstream message;
396 message <<
"Problem creating G4Polyhedron for: " << GetName();
397 G4Exception(
"G4GenericPolycone::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)