41 : aMin(0.), aMax(0.), bMin(0.), bMax(0.)
54 : aMin(0.), aMax(0.), bMin(0.), bMax(0.)
67 for(
G4int i=0; i < n; ++i, ++rOut, ++zOut, --rIn, --zIn )
85void G4ReduciblePolygon::Create(
const G4double a[],
90 G4Exception(
"G4ReduciblePolygon::Create()",
"GeomSolids0002",
94 const G4double *anext = a, *bnext = b;
95 ABVertex* prev =
nullptr;
98 auto newVertex =
new ABVertex;
99 newVertex->a = *anext;
100 newVertex->b = *bnext;
101 newVertex->next =
nullptr;
104 vertexHead = newVertex;
108 prev->next = newVertex;
112 }
while( ++anext, ++bnext < b+n );
123 : aMin(0.), aMax(0.), bMin(0.), bMax(0.)
133 ABVertex* curr = vertexHead;
134 while( curr !=
nullptr )
136 ABVertex* toDelete = curr;
151 ABVertex *curr = vertexHead;
152 while( curr !=
nullptr )
166 ABVertex* curr = vertexHead;
167 while( curr !=
nullptr )
180 ABVertex* curr = vertexHead;
181 while( curr !=
nullptr )
195 ABVertex *curr = vertexHead,
196 *prev =
nullptr, *next =
nullptr;
197 while( curr !=
nullptr )
200 if (next ==
nullptr) { next = vertexHead; }
202 if (std::fabs(curr->a-next->a) < tolerance &&
203 std::fabs(curr->b-next->b) < tolerance )
208 if (numVertices <= 3)
217 ABVertex* toDelete = curr;
257 if (numVertices <= 2) {
return false; }
259 G4double tolerance2 = tolerance*tolerance;
264 ABVertex *curr = vertexHead, *next =
nullptr;
265 while( curr !=
nullptr )
268 if (next ==
nullptr) { next = vertexHead; }
271 db = next->b - curr->b;
281 ABVertex* test = next->next;
282 if (test ==
nullptr) { test = vertexHead; }
287 if (test==curr) {
break; }
293 dbt = test->b - curr->b;
295 if (std::fabs(dat*db-dbt*da)>tolerance2) {
break; }
300 if (numVertices <= 3)
309 if (curr->next !=
nullptr)
311 if (next->next !=
nullptr)
317 curr->next =
nullptr;
325 if ((curr != next) && (next != test)) {
delete next; }
356 ABVertex* prev = vertexHead;
357 if (prev==
nullptr) {
return; }
359 ABVertex* curr = prev->next;
360 if (curr==
nullptr) {
return; }
365 vertexHead->next =
nullptr;
372 ABVertex *save = curr->next;
383 if (save ==
nullptr) {
break; }
406 ABVertex* curr = vertexHead;
408 ABVertex* prev = curr;
409 while( curr !=
nullptr)
414 ABVertex* curr1 = curr;
415 while( curr1 !=
nullptr )
417 if(curr1->next ==
nullptr) { curr1->next = vertexHead;
break; }
421 prev->next =
nullptr;
436 G4double tolerance2 = tolerance*tolerance;
443 ABVertex *curr1 = vertexHead, *next1 =
nullptr;
444 while (curr1->next !=
nullptr)
448 db1 = next1->b-curr1->b;
453 ABVertex* curr2 = next1->next;
454 while( curr2 !=
nullptr )
456 ABVertex* next2 = curr2->next;
457 if (next2==
nullptr) { next2 = vertexHead; }
459 db2 = next2->b-curr2->b;
461 b12 = curr2->b-curr1->b;
467 if (std::fabs(deter) > tolerance2)
470 s1 = (a12*db2-b12*da2)/deter;
472 if (s1 >= zero && s1 < one)
474 s2 = -(da1*b12-db1*a12)/deter;
475 if (s2 >= zero && s2 < one) {
return true; }
493 G4int nNeg = 0, nPos = 0;
496 G4double len12 = std::sqrt( a12*a12 + b12*b12 );
497 a12 /= len12; b12 /= len12;
499 ABVertex* curr = vertexHead;
507 if (cross < -tolerance)
509 if (nPos != 0) {
return true; }
512 else if (cross > tolerance)
514 if (nNeg != 0) {
return true; }
518 }
while( curr !=
nullptr );
535 ABVertex *curr = vertexHead, *next =
nullptr;
539 if (next==
nullptr) { next = vertexHead; }
541 answer += curr->a*next->b - curr->b*next->a;
543 }
while( curr !=
nullptr );
552 ABVertex* curr = vertexHead;
557 }
while( curr !=
nullptr );
565void G4ReduciblePolygon::CalculateMaxMin()
568 aMin = aMax = curr->a;
569 bMin = bMax = curr->b;
571 while( curr !=
nullptr )
577 else if (curr->a > aMax)
586 else if (curr->b > bMax)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cerr
G4ReduciblePolygon(const G4double a[], const G4double b[], G4int n)
G4bool BisectedBy(G4double a1, G4double b1, G4double a2, G4double b2, G4double tolerance)
void ScaleB(G4double scale)
void CopyVertices(G4double a[], G4double b[]) const
G4bool RemoveDuplicateVertices(G4double tolerance)
G4bool RemoveRedundantVertices(G4double tolerance)
G4bool CrossesItself(G4double tolerance)
void ScaleA(G4double scale)