From d8539d5412503acaa037005048543680b15031b6 Mon Sep 17 00:00:00 2001 From: Ralf Gerlich Date: Thu, 3 Jan 2008 15:56:10 +0100 Subject: [PATCH] calc_point_inside(): - Fixed one-off bug. - Take care of the border-case where the line exactly overlaps a node. --- src/Lib/Geometry/poly_support.cxx | 40 ++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/Lib/Geometry/poly_support.cxx b/src/Lib/Geometry/poly_support.cxx index 93c572ef..a12d92c8 100644 --- a/src/Lib/Geometry/poly_support.cxx +++ b/src/Lib/Geometry/poly_support.cxx @@ -36,6 +36,7 @@ #include #include +#include #define REAL double extern "C" { @@ -51,6 +52,8 @@ extern "C" { SG_USING_STD(cout); SG_USING_STD(endl); SG_USING_STD(sort); +SG_USING_STD(copy); +SG_USING_STD(ostream_iterator); // Given a line segment specified by two endpoints p1 and p2, return // the slope of the line. @@ -821,7 +824,7 @@ static void intersect_yline_with_contour( double yline, TGContourNode *node, TGP point_list::size_type count = pts.size(); - cout << "intersect_yline_with_contour() yline=" << yline << endl; + // cout << "intersect_yline_with_contour() yline=" << yline << endl; for ( int i = 0; i < count; ++i ) { const Point3D &p0 = pts[ i ]; @@ -834,24 +837,35 @@ static void intersect_yline_with_contour( double yline, TGContourNode *node, TGP if (ymax(cout, " ")); + cout << endl; + if ( xcuts.size() < 2 || (xcuts.size() % 2) != 0 ) { throw sg_exception("Geometric inconsistency in calc_point_inside()"); } @@ -925,6 +941,8 @@ static void calc_point_inside( TGContourNode *node, TGPolygon &p ) { double x = (xcuts[ longest ] + xcuts[ longest + 1 ])/2.0; + // cout << "calc_point_inside() found point inside x=" << x << " y=" << yline << endl; + p.set_point_inside( contour_num, Point3D(x, yline, -9999.0) ); }