36 #if defined(G4GEOM_USE_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 G4Polyhedron* G4UGenericPolycone::CreatePolyhedron()
const
127 const G4int numSide =
128 G4int(G4Polyhedron::GetNumberOfRotationSteps()
129 * (GetEndPhi() - GetStartPhi()) /
twopi) + 1;
134 typedef G4int int4[4];
141 std::vector<G4bool> chopped(GetNumRZCorner(),
false);
142 std::vector<G4int*> triQuads;
143 G4int remaining = GetNumRZCorner();
145 while (remaining >= 3)
150 G4int iStepper = iStarter;
153 if (A < 0) { A = iStepper; }
154 else if (
B < 0) {
B = iStepper; }
155 else if (
C < 0) {
C = iStepper; }
158 if (++iStepper >= GetNumRZCorner()) { iStepper = 0; }
160 while (chopped[iStepper]);
162 while (
C < 0 && iStepper != iStarter);
167 G4double BAr = GetCorner(A).r - GetCorner(
B).r;
168 G4double BAz = GetCorner(A).z - GetCorner(
B).z;
169 G4double BCr = GetCorner(
C).r - GetCorner(
B).r;
170 G4double BCz = GetCorner(
C).z - GetCorner(
B).z;
171 if (BAr * BCz - BAz * BCr < kCarTolerance)
177 triQuads.push_back(tq);
185 if (++iStarter >= GetNumRZCorner()) { iStarter = 0; }
187 while (chopped[iStarter]);
192 nNodes = (numSide + 1) * GetNumRZCorner();
193 nFaces = numSide * GetNumRZCorner() + 2 * triQuads.size();
194 faces_vec =
new int4[nFaces];
196 G4int addition = GetNumRZCorner() * numSide;
197 G4int d = GetNumRZCorner() - 1;
198 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
200 for (
size_t i = 0; i < triQuads.size(); ++i)
213 a = triQuads[i][0] + addition;
214 b = triQuads[i][2] + addition;
215 c = triQuads[i][1] + addition;
218 G4int bc = std::abs(c - b);
219 G4int ca = std::abs(a - c);
220 faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
221 faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
222 faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
223 faces_vec[iface][3] = 0;
230 xyz =
new double3[nNodes];
231 const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
234 for (
G4int iSide = 0; iSide < numSide; ++iSide)
236 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
238 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
239 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
240 xyz[ixyz][2] = GetCorner(iCorner).z;
243 if (iCorner < GetNumRZCorner() - 1)
245 faces_vec[iface][0] = ixyz + 1;
246 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
247 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
248 faces_vec[iface][3] = ixyz + 2;
252 faces_vec[iface][0] = ixyz + 1;
253 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
254 faces_vec[iface][2] = ixyz + 2;
255 faces_vec[iface][3] = ixyz - GetNumRZCorner() + 2;
258 else if (iSide == numSide - 1)
260 if (iCorner < GetNumRZCorner() - 1)
262 faces_vec[iface][0] = ixyz + 1;
263 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
264 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
265 faces_vec[iface][3] = -(ixyz + 2);
269 faces_vec[iface][0] = ixyz + 1;
270 faces_vec[iface][1] = ixyz + GetNumRZCorner() + 1;
271 faces_vec[iface][2] = ixyz + 2;
272 faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
277 if (iCorner < GetNumRZCorner() - 1)
279 faces_vec[iface][0] = ixyz + 1;
280 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
281 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
282 faces_vec[iface][3] = -(ixyz + 2);
286 faces_vec[iface][0] = ixyz + 1;
287 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
288 faces_vec[iface][2] = ixyz + 2;
289 faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
300 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
302 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
303 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
304 xyz[ixyz][2] = GetCorner(iCorner).z;
310 nNodes = numSide * GetNumRZCorner();
311 nFaces = numSide * GetNumRZCorner();;
312 xyz =
new double3[nNodes];
313 faces_vec =
new int4[nFaces];
314 const G4double dPhi = (GetEndPhi() - GetStartPhi()) / numSide;
316 G4int ixyz = 0, iface = 0;
317 for (
G4int iSide = 0; iSide < numSide; ++iSide)
319 for (
G4int iCorner = 0; iCorner < GetNumRZCorner(); ++iCorner)
321 xyz[ixyz][0] = GetCorner(iCorner).r * std::cos(phi);
322 xyz[ixyz][1] = GetCorner(iCorner).r * std::sin(phi);
323 xyz[ixyz][2] = GetCorner(iCorner).z;
325 if (iSide < numSide - 1)
327 if (iCorner < GetNumRZCorner() - 1)
329 faces_vec[iface][0] = ixyz + 1;
330 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
331 faces_vec[iface][2] = ixyz + GetNumRZCorner() + 2;
332 faces_vec[iface][3] = -(ixyz + 2);
336 faces_vec[iface][0] = ixyz + 1;
337 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() + 1);
338 faces_vec[iface][2] = ixyz + 2;
339 faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
344 if (iCorner < GetNumRZCorner() - 1)
346 faces_vec[iface][0] = ixyz + 1;
347 faces_vec[iface][1] = -(ixyz + GetNumRZCorner() - nFaces + 1);
348 faces_vec[iface][2] = ixyz + GetNumRZCorner() - nFaces + 2;
349 faces_vec[iface][3] = -(ixyz + 2);
353 faces_vec[iface][0] = ixyz + 1;
354 faces_vec[iface][1] = -(ixyz - nFaces + GetNumRZCorner() + 1);
355 faces_vec[iface][2] = ixyz - nFaces + 2;
356 faces_vec[iface][3] = -(ixyz - GetNumRZCorner() + 2);
366 G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
371 std::ostringstream message;
372 message <<
"Problem creating G4Polyhedron for: " << GetName();
373 G4Exception(
"G4GenericPolycone::CreatePolyhedron()",
"GeomSolids1002",
384 #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)