From bcb6638535a77ccf7532f9266798e02301116152 Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 3 Apr 1999 05:22:57 +0000 Subject: [PATCH] Found a bug in dividing and adding unique verticle segments which could cause the triangulator to end up in an infinite loop. Basically the code was correct, but the verticle line test was a bit to selective. --- Main/construct.cxx | 9 ++++++++- Triangulate/triangle.cxx | 9 +++++++-- Triangulate/trisegs.cxx | 18 ++++++++++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Main/construct.cxx b/Main/construct.cxx index 12099f928..85227747b 100644 --- a/Main/construct.cxx +++ b/Main/construct.cxx @@ -206,7 +206,8 @@ main(int argc, char **argv) { // lon = -112.012175; lat = 41.195944; // KOGD // lon = -90.757128; lat = 46.790212; // WI32 // lon = -122.220717; lat = 37.721291; // KOAK - lon = -111.721477; lat = 40.215641; // KPVU + // lon = -111.721477; lat = 40.215641; // KPVU + lon = -122.309313; lat = 47.448982; // KSEA double min_x = lon - 1; double min_y = lat - 1; @@ -214,6 +215,7 @@ main(int argc, char **argv) { FGBucket b_max( lon + 1, lat + 1 ); FGBucket b_omit(550314L); + // FGBucket b(942698L); // FGBucket b(-146.248360, 61.133950); // construct_tile( work_base, output_base, b ); // exit(0); @@ -243,6 +245,11 @@ main(int argc, char **argv) { // $Log$ +// Revision 1.17 1999/04/03 05:22:57 curt +// Found a bug in dividing and adding unique verticle segments which could +// cause the triangulator to end up in an infinite loop. Basically the code +// was correct, but the verticle line test was a bit to selective. +// // Revision 1.16 1999/04/01 13:52:12 curt // Version 0.6.0 // Shape name tweak. diff --git a/Triangulate/triangle.cxx b/Triangulate/triangle.cxx index 6265237b0..6ce08c492 100644 --- a/Triangulate/triangle.cxx +++ b/Triangulate/triangle.cxx @@ -328,7 +328,7 @@ int FGTriangle::run_triangulate() { vorout.normlist = (REAL *) NULL; // Needed only if -v switch used. // TEMPORARY - // write_out_data(&in); + write_out_data(&in); // Triangulate the points. Switches are chosen to read and write // a PSLG (p), preserve the convex hull (c), number everything @@ -343,7 +343,7 @@ int FGTriangle::run_triangulate() { triangulate(tri_options.c_str(), &in, &out, &vorout); // TEMPORARY - write_out_data(&out); + // write_out_data(&out); // now copy the results back into the corresponding FGTriangle // structures @@ -398,6 +398,11 @@ int FGTriangle::run_triangulate() { // $Log$ +// Revision 1.15 1999/04/03 05:22:58 curt +// Found a bug in dividing and adding unique verticle segments which could +// cause the triangulator to end up in an infinite loop. Basically the code +// was correct, but the verticle line test was a bit to selective. +// // Revision 1.14 1999/03/31 23:47:09 curt // Debugging output tweaks. // diff --git a/Triangulate/trisegs.cxx b/Triangulate/trisegs.cxx index 1c1c386bf..d05c6ccf1 100644 --- a/Triangulate/trisegs.cxx +++ b/Triangulate/trisegs.cxx @@ -87,7 +87,7 @@ void FGTriSegments::unique_divide_and_add( const point_list& nodes, // temp = true; // } - if ( fabs(p0.x() - p1.x()) > FG_EPSILON ) { + if ( fabs(p0.x() - p1.x()) > 3 * FG_EPSILON ) { // use y = mx + b // sort these in a sensable order @@ -131,6 +131,8 @@ void FGTriSegments::unique_divide_and_add( const point_list& nodes, } else { // use x = constant + // cout << "FOUND VERTICLE SEGMENT" << endl; + // sort these in a sensable order if ( p0.y() > p1.y() ) { Point3D tmp = p0; @@ -138,15 +140,22 @@ void FGTriSegments::unique_divide_and_add( const point_list& nodes, p1 = tmp; } + // cout << " p0 = " << p0 << " p1 = " << p1 << endl; + current = nodes.begin(); last = nodes.end(); counter = 0; for ( ; current != last; ++current ) { // cout << counter << endl; - if ( (current->y() > p0.y()) && (current->y() < p1.y()) ) { + if ( (current->y() > (p0.y() + FG_EPSILON)) + && (current->y() < (p1.y() - FG_EPSILON)) ) { x_err = fabs(current->x() - p0.x()); + // cout << " found a potential point, x err = " + // << x_err << endl; if ( x_err < 10*FG_EPSILON ) { cout << "FOUND EXTRA SEGMENT NODE (X)" << endl; + cout << p0 << " < " << *current << " < " + << p1 << endl; found_extra = true; extra_index = counter; break; @@ -170,6 +179,11 @@ void FGTriSegments::unique_divide_and_add( const point_list& nodes, // $Log$ +// Revision 1.6 1999/04/03 05:22:59 curt +// Found a bug in dividing and adding unique verticle segments which could +// cause the triangulator to end up in an infinite loop. Basically the code +// was correct, but the verticle line test was a bit to selective. +// // Revision 1.5 1999/03/29 13:11:13 curt // Shuffled stl type names a bit. // Began adding support for tri-fanning (or maybe other arrangments too.) -- 2.39.5