diff --git a/uniquepoints.c b/uniquepoints.c index a57072ff..a1ac88bf 100644 --- a/uniquepoints.c +++ b/uniquepoints.c @@ -90,14 +90,20 @@ static int uniquify(int n, double *list, double tolerance) double val = list[pos++];/* Keep first value */ for (i=1; i tolerance){ + if (val + tolerance < list [i]){ val = list[i]; list[pos++] = val; } } /* Keep last value (one way or the other...) */ - list[pos-1] = list[n-1]; +#if 0 + if (val + tolerance < list[n-1]){ + list[pos-1] = list[n-1]; + } +#else + list[pos-1] = list[n-1]; +#endif return pos; } @@ -139,12 +145,12 @@ static int assignPointNumbers(int begin, } /* Find next k such that zlist[k] < z[i] < zlist[k+1] */ - while ((k < end) && (z[i] - zlist[k] > tolerance)){ + while ((k < end) && (zlist[k] + tolerance < z[i])){ k++; } /* assert (k < len && z[i] - zlist[k] <= tolerance) */ - if ((k == end) || ( z[i] - zlist[k] > tolerance)){ + if ((k == end) || ( zlist[k] + tolerance < z[i])){ fprintf(stderr, "Cannot associate zcorn values with given list\n"); fprintf(stderr, "of z-coordinates to given tolerance\n"); return 0;