diff --git a/include/boost/geometry/algorithms/disjoint.hpp b/include/boost/geometry/algorithms/disjoint.hpp index d48adf93b..5804105c0 100644 --- a/include/boost/geometry/algorithms/disjoint.hpp +++ b/include/boost/geometry/algorithms/disjoint.hpp @@ -40,9 +40,8 @@ namespace boost { namespace geometry namespace detail { namespace disjoint { - template -struct general +struct disjoint_linear { static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2) { @@ -62,6 +61,46 @@ struct general return false; } + return true; + } +}; + +template +struct disjoint_segment +{ + static inline bool apply(Segment1 const& segment1, Segment2 const& segment2) + { + typedef typename point_type::type point_type; + + segment_intersection_points is + = strategy::intersection::relate_cartesian_segments + < + policies::relate::segments_intersection_points + < + Segment1, + Segment2, + segment_intersection_points + > + >::apply(segment1, segment2); + + return is.count == 0; + } +}; + + + +template +struct general_areal +{ + static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2) + { + if (! disjoint_linear::apply(geometry1, geometry2)) + { + return false; + } + + typedef typename geometry::point_type::type point_type; + // If there is no intersection of segments, they might located // inside each other point_type p1; @@ -100,7 +139,7 @@ template std::size_t DimensionCount > struct disjoint - : detail::disjoint::general + : detail::disjoint::general_areal {}; @@ -121,6 +160,16 @@ struct disjoint : detail::disjoint::point_box {}; +template +struct disjoint + : detail::disjoint::disjoint_linear +{}; + +template +struct disjoint + : detail::disjoint::disjoint_segment +{}; + template < @@ -150,13 +199,13 @@ struct disjoint_reversed /*! - \brief Calculate if two geometries are disjoint - \ingroup disjoint - \tparam Geometry1 first geometry type - \tparam Geometry2 second geometry type - \param geometry1 first geometry - \param geometry2 second geometry - \return true if disjoint, else false +\brief \brief_check2{are disjoint} +\ingroup disjoint +\tparam Geometry1 \tparam_geometry +\tparam Geometry2 \tparam_geometry +\param geometry1 \param_geometry +\param geometry2 \param_geometry +\return \return_check2{are disjoint} */ template inline bool disjoint(Geometry1 const& geometry1,