[sections] Enlarge section bounding Boxes WRT epsilon.

This allows the algorithms using sections to check spatial predicates
using raw operators < (e.g. in Box/Box disjoint). There is no need to
use less performant calls to math::smaller.

Replace math::smaller usage in section functions preceeding() and
exceeding() and therefore revert the change done recently.
This commit is contained in:
Adam Wulkiewicz
2015-08-21 19:41:01 +02:00
parent d248323369
commit b22a3c0530
2 changed files with 17 additions and 14 deletions

View File

@@ -18,7 +18,7 @@
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/algorithms/detail/recalculate.hpp>
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
#include <boost/geometry/util/math.hpp>
namespace boost { namespace geometry
{
@@ -40,8 +40,8 @@ static inline bool preceding(int dir, Point const& point,
{
typename geometry::robust_point_type<Point, RobustPolicy>::type robust_point;
geometry::recalculate(robust_point, point, robust_policy);
return (dir == 1 && math::smaller(get<Dimension>(robust_point), get<min_corner, Dimension>(robust_box)))
|| (dir == -1 && math::larger(get<Dimension>(robust_point), get<max_corner, Dimension>(robust_box)));
return (dir == 1 && get<Dimension>(robust_point) < get<min_corner, Dimension>(robust_box))
|| (dir == -1 && get<Dimension>(robust_point) > get<max_corner, Dimension>(robust_box));
}
template
@@ -57,8 +57,8 @@ static inline bool exceeding(int dir, Point const& point,
{
typename geometry::robust_point_type<Point, RobustPolicy>::type robust_point;
geometry::recalculate(robust_point, point, robust_policy);
return (dir == 1 && math::larger(get<Dimension>(robust_point), get<max_corner, Dimension>(robust_box)))
|| (dir == -1 && math::smaller(get<Dimension>(robust_point), get<min_corner, Dimension>(robust_box)));
return (dir == 1 && get<Dimension>(robust_point) > get<max_corner, Dimension>(robust_box))
|| (dir == -1 && get<Dimension>(robust_point) < get<min_corner, Dimension>(robust_box));
}

View File

@@ -52,6 +52,8 @@
#include <boost/geometry/views/reversible_view.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/algorithms/detail/expand_by_epsilon.hpp>
namespace boost { namespace geometry
{
@@ -599,19 +601,18 @@ inline void enlarge_sections(Sections& sections)
// Reason: turns might, rarely, be missed otherwise (case: "buffer_mp1")
// Drawback: not really, range is now completely inside the section. Section is a tiny bit too large,
// which might cause (a small number) of more comparisons
// TODO: make dimension-agnostic
// NOTE: above is old comment to the not used code expanding the Boxes by relaxed_epsilon(10)
// Enlarge sections by scaled epsilon, this should be consistent with math::equals().
// Points and Segments are equal-compared WRT machine epsilon, but Boxes aren't
// Enlarging Boxes ensures that they correspond to the bound objects,
// Segments in this case, since Sections are collections of Segments.
for (typename boost::range_iterator<Sections>::type it = boost::begin(sections);
it != boost::end(sections);
++it)
{
typedef typename boost::range_value<Sections>::type section_type;
typedef typename section_type::box_type box_type;
typedef typename geometry::coordinate_type<box_type>::type coordinate_type;
coordinate_type const reps = math::relaxed_epsilon(10.0);
geometry::set<0, 0>(it->bounding_box, geometry::get<0, 0>(it->bounding_box) - reps);
geometry::set<0, 1>(it->bounding_box, geometry::get<0, 1>(it->bounding_box) - reps);
geometry::set<1, 0>(it->bounding_box, geometry::get<1, 0>(it->bounding_box) + reps);
geometry::set<1, 1>(it->bounding_box, geometry::get<1, 1>(it->bounding_box) + reps);
detail::expand_by_epsilon(it->bounding_box);
}
}
@@ -802,6 +803,8 @@ inline void sectionalize(Geometry const& geometry,
Reverse,
DimensionVector
>::apply(geometry, robust_policy, sections, ring_id, max_count);
detail::sectionalize::enlarge_sections(sections);
}