From 619bc7f1f740abbfe99caa768d7e966e62f7de80 Mon Sep 17 00:00:00 2001 From: Peter Sadrozinski Date: Wed, 7 Nov 2012 21:55:58 -0500 Subject: [PATCH] a better fix for the boundary box fix --- src/Lib/Geometry/point3d.hxx | 33 ++++++++++++++++++++++++++------- src/Lib/Geometry/tg_nodes.cxx | 4 ++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/Lib/Geometry/point3d.hxx b/src/Lib/Geometry/point3d.hxx index e1a912e4..2b680cb2 100644 --- a/src/Lib/Geometry/point3d.hxx +++ b/src/Lib/Geometry/point3d.hxx @@ -144,6 +144,8 @@ public: bool IsWithin( Point3D min, Point3D max ) const; bool IsWithin( double xmin, double xmax, double ymin, double ymax ) const; + bool IsAlmostWithin( Point3D min, Point3D max ) const; + bool IsAlmostWithin( double xmin, double xmax, double ymin, double ymax ) const; #ifdef _MSC_VER double round(double d) @@ -431,13 +433,6 @@ inline bool Point3D::HasElevation() const inline bool Point3D::IsWithin( Point3D min, Point3D max ) const { - // make sure we take epsilon into account - min.n[PX] -= fgPoint3_Epsilon; - min.n[PY] -= fgPoint3_Epsilon; - - max.n[PX] += fgPoint3_Epsilon; - max.n[PY] += fgPoint3_Epsilon; - return ( (min.n[PX] <= n[PX]) && (min.n[PY] <= n[PY]) && (max.n[PX] >= n[PX]) && (max.n[PY] >= n[PY]) ); } @@ -455,6 +450,30 @@ inline bool Point3D::IsWithin( double xmin, double xmax, double ymin, double yma (xmax >= n[PX]) && (ymax >= n[PY]) ); } +inline bool Point3D::IsAlmostWithin( Point3D min, Point3D max ) const +{ + // make sure we take epsilon into account + min.n[PX] -= fgPoint3_Epsilon; + min.n[PY] -= fgPoint3_Epsilon; + + max.n[PX] += fgPoint3_Epsilon; + max.n[PY] += fgPoint3_Epsilon; + + return ( IsWithin(min, max) ); +} + +inline bool Point3D::IsAlmostWithin( double xmin, double xmax, double ymin, double ymax ) const +{ + // make sure we take epsilon into account + xmin -= fgPoint3_Epsilon; + ymin -= fgPoint3_Epsilon; + + xmax += fgPoint3_Epsilon; + ymax += fgPoint3_Epsilon; + + return ( IsWithin( xmin, xmax, ymin,ymax ) ); +} + // FRIENDS inline Point3D operator - (const Point3D& a) diff --git a/src/Lib/Geometry/tg_nodes.cxx b/src/Lib/Geometry/tg_nodes.cxx index 6fcbdb94..ad1f4371 100644 --- a/src/Lib/Geometry/tg_nodes.cxx +++ b/src/Lib/Geometry/tg_nodes.cxx @@ -239,11 +239,11 @@ point_list TGNodes::get_geod_inside( Point3D min, Point3D max ) const { for ( ; current != last; ++current ) { Point3D pt = (*current).GetPosition(); - if ( pt.IsWithin( min, max ) ) { + if ( pt.IsAlmostWithin( min, max ) ) { points.push_back( pt ); } else { if ( (pt < max) && (pt > min) ) { - SG_LOG(SG_GENERAL, SG_ALERT, "pt " << pt << " failes IsWithin, but sholdn't have: min " << min << " max " << max ); + SG_LOG(SG_GENERAL, SG_ALERT, "pt " << pt << " fails IsAlmostWithin, but sholdn't have: min " << min << " max " << max ); } } }