diff options
Diffstat (limited to 'boost/geometry/algorithms/disjoint.hpp')
-rw-r--r-- | boost/geometry/algorithms/disjoint.hpp | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/boost/geometry/algorithms/disjoint.hpp b/boost/geometry/algorithms/disjoint.hpp index f36b8dbdd0..f986cc24af 100644 --- a/boost/geometry/algorithms/disjoint.hpp +++ b/boost/geometry/algorithms/disjoint.hpp @@ -27,6 +27,7 @@ #include <boost/geometry/core/reverse_dispatch.hpp> #include <boost/geometry/algorithms/detail/disjoint.hpp> +#include <boost/geometry/algorithms/detail/for_each_range.hpp> #include <boost/geometry/algorithms/detail/point_on_border.hpp> #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp> #include <boost/geometry/algorithms/within.hpp> @@ -44,15 +45,57 @@ namespace boost { namespace geometry namespace detail { namespace disjoint { +template<typename Geometry> +struct check_each_ring_for_within +{ + bool has_within; + Geometry const& m_geometry; + + inline check_each_ring_for_within(Geometry const& g) + : has_within(false) + , m_geometry(g) + {} + + template <typename Range> + inline void apply(Range const& range) + { + typename geometry::point_type<Range>::type p; + geometry::point_on_border(p, range); + if (geometry::within(p, m_geometry)) + { + has_within = true; + } + } +}; + +template <typename FirstGeometry, typename SecondGeometry> +inline bool rings_containing(FirstGeometry const& geometry1, + SecondGeometry const& geometry2) +{ + check_each_ring_for_within<FirstGeometry> checker(geometry1); + geometry::detail::for_each_range(geometry2, checker); + return checker.has_within; +} + + struct assign_disjoint_policy { // We want to include all points: static bool const include_no_turn = true; static bool const include_degenerate = true; + static bool const include_opposite = true; // We don't assign extra info: - template <typename Point1, typename Point2, typename Info> - static inline void apply(Info& , Point1 const& , Point2 const& ) + template + < + typename Info, + typename Point1, + typename Point2, + typename IntersectionInfo, + typename DirInfo + > + static inline void apply(Info& , Point1 const& , Point2 const&, + IntersectionInfo const&, DirInfo const&) {} }; @@ -107,8 +150,6 @@ struct disjoint_segment } }; - - template <typename Geometry1, typename Geometry2> struct general_areal { @@ -119,20 +160,10 @@ struct general_areal return false; } - typedef typename geometry::point_type<Geometry1>::type point_type; - // If there is no intersection of segments, they might located // inside each other - point_type p1; - geometry::point_on_border(p1, geometry1); - if (geometry::within(p1, geometry2)) - { - return false; - } - - typename geometry::point_type<Geometry1>::type p2; - geometry::point_on_border(p2, geometry2); - if (geometry::within(p2, geometry1)) + if (rings_containing(geometry1, geometry2) + || rings_containing(geometry2, geometry1)) { return false; } |