diff --git a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp index bc1ff722b..c09fc86e4 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/multipoint_geometry.hpp @@ -10,6 +10,8 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIPOINT_GEOMETRY_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIPOINT_GEOMETRY_HPP +#include + #include #include @@ -18,6 +20,14 @@ #include #include +#if defined(BOOST_GEOMETRY_DISJOINT_USE_PARTITION) +#include +#include +#include +#include +#include +#endif + #include @@ -75,6 +85,71 @@ struct multipoint_geometry }; +#if defined(BOOST_GEOMETRY_DISJOINT_USE_PARTITION) +template +class multipoint_multipoint +{ +private: + struct point_expand + { + template + static inline void apply(Box& total, Point const& point) + { + geometry::expand(total, point); + } + }; + + struct overlaps_point + { + template + static inline bool apply(Box const& box, Point const& point) + { + return !dispatch::disjoint::apply(point, box); + } + }; + + struct two_point_visitor + { + std::size_t count; + + two_point_visitor() + : count(0) + {} + + template + inline void apply(Point1 const& item1, Point2 const& item2) + { + if ( count == 0 && geometry::equals(item1, item2) ) + { + ++count; + } + } + }; + +public: + static inline bool apply(MultiPoint1 const& multipoint1, + MultiPoint2 const& multipoint2) + { + BOOST_ASSERT( boost::size(multipoint1) <= boost::size(multipoint2) ); + + typedef typename boost::range_value::type point1_type; + + two_point_visitor visitor; + + geometry::partition + < + geometry::model::box + < + typename boost::range_value::type + >, + point_expand, + overlaps_point + >::apply(multipoint1, multipoint2, visitor); + + return visitor.count == 0; + } +}; +#else template struct multipoint_multipoint { @@ -108,6 +183,7 @@ struct multipoint_multipoint return true; } }; +#endif }} // namespace detail::disjoint