31 : aMin(0.), aMax(0.), bMin(0.), bMax(0.),
46 const double z[],
int n)
47 : aMin(0.), aMax(0.), bMin(0.), bMax(0.),
53 double*
a =
new double[n * 2];
54 double* b =
new double[n * 2];
62 for (i = 0; i <
n; i++, rOut++, zOut++, rIn--, zIn--)
83 const double b[],
int n)
89 const double* anext =
a, *bnext = b;
95 newVertex->
a = *anext;
96 newVertex->
b = *bnext;
104 prev->
next = newVertex;
109 while (++anext, ++bnext < b + n);
142 double* anext =
a, *bnext = b;
194 *prev = 0, *next = 0;
200 if (std::fabs(curr->
a - next->a) < tolerance &&
201 std::fabs(curr->
b - next->b) < tolerance)
221 if (prev) prev->next = curr;
253 double tolerance2 = tolerance *
tolerance;
264 double da = next->
a - curr->
a,
265 db = next->b - curr->
b;
281 if (test == curr)
break;
286 double dat = test->
a - curr->
a,
287 dbt = test->
b - curr->
b;
289 if (std::fabs(dat * db - dbt * da) > tolerance2)
break;
314 if ((curr != next) && (next != test))
delete next;
349 if (prev == 0)
return;
352 if (curr == 0)
return;
375 if (save == 0)
break;
398 double bcurr = curr->
b;
408 if (curr1->
next == 0)
434 double tolerance2 = tolerance *
tolerance;
445 double da1 = next1->
a - curr1->
a,
446 db1 = next1->b - curr1->
b;
456 double da2 = next2->
a - curr2->
a,
457 db2 = next2->
b - curr2->
b;
458 double a12 = curr2->
a - curr1->
a,
459 b12 = curr2->
b - curr1->
b;
464 double deter = da1 * db2 - db1 * da2;
465 if (std::fabs(deter) > tolerance2)
468 s1 = (a12 * db2 - b12 * da2) / deter;
470 if (s1 >= zero && s1 < one)
472 s2 = -(da1 * b12 - db1 * a12) / deter;
473 if (s2 >= zero && s2 < one)
return true;
491 double a2,
double b2,
494 int nNeg = 0, nPos = 0;
496 double a12 = a2 -
a1, b12 = b2 -
b1;
497 double len12 = std::sqrt(a12 * a12 + b12 * b12);
504 double av = curr->
a -
a1,
507 double Cross = av * b12 - bv * a12;
509 if (Cross < -tolerance)
511 if (nPos)
return true;
514 else if (Cross > tolerance)
516 if (nNeg)
return true;
547 answer += curr->
a * next->b - curr->
b * next->a;
564 std::cerr << curr->
a <<
" " << curr->
b << std::endl;
587 else if (curr->
a >
aMax)
592 else if (curr->
b >
bMax)
UReduciblePolygon(const double a[], const double b[], int n)
virtual ~UReduciblePolygon()
bool RemoveRedundantVertices(double tolerance)
void ScaleB(double scale)
void Create(const double a[], const double b[], int n)
static const G4double tolerance
void CopyVertices(double a[], double b[]) const
bool RemoveDuplicateVertices(double tolerance)
bool BisectedBy(double a1, double b1, double a2, double b2, double tolerance)
void ScaleA(double scale)
bool CrossesItself(double tolerance)
void Exception(const char *originOfException, const char *exceptionCode, UExceptionSeverity severity, int level, const char *description)