From 38147c2fc7b342f3e003a6382143192e29925614 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 4 Mar 2014 16:55:18 +0100 Subject: [PATCH] relate() for_each_disjoint_linestring_if utility now works for all geometries, renamed to for_each_disjoint_geometry_if --- .../detail/relate/linear_linear.hpp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp b/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp index 5a5b508e7..d0f4d81af 100644 --- a/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp @@ -31,13 +31,20 @@ namespace detail { namespace relate { // For 1-point linestrings or with all equal points turns won't be generated! // Check for those degenerated cases may be connected with this one! +// TODO: +// Move this to separate file, maybe name it differently e.g. for_each_turnless_geometry_if + template ::type> -struct for_each_disjoint_linestring_if {}; + typename Tag = typename geometry::tag::type, + bool IsMulti = boost::is_base_of::value +> +struct for_each_disjoint_geometry_if + : public not_implemented +{}; -template -struct for_each_disjoint_linestring_if +template +struct for_each_disjoint_geometry_if { template static inline bool apply(TurnIt first, TurnIt last, @@ -51,8 +58,8 @@ struct for_each_disjoint_linestring_if } }; -template -struct for_each_disjoint_linestring_if +template +struct for_each_disjoint_geometry_if { template static inline bool apply(TurnIt first, TurnIt last, @@ -61,7 +68,11 @@ struct for_each_disjoint_linestring_if { BOOST_ASSERT(first != last); - std::size_t count = boost::size(geometry); + const std::size_t count = boost::size(geometry); + boost::ignore_unused_variable_warning(count); + + // O(I) + // gather info about turns generated for contained geometries std::vector detected_intersections(count, false); for ( TurnIt it = first ; it != last ; ++it ) { @@ -74,6 +85,8 @@ struct for_each_disjoint_linestring_if bool found = false; + // O(N) + // check predicate for each contained geometry without generated turn for ( std::vector::iterator it = detected_intersections.begin() ; it != detected_intersections.end() ; ++it ) { @@ -286,13 +299,13 @@ struct linear_linear boundary_checker boundary_checker1(geometry1); disjoint_linestring_pred<0, Result, boundary_checker > pred1(result, boundary_checker1); - for_each_disjoint_linestring_if<0, Geometry1>::apply(turns.begin(), turns.end(), geometry1, pred1); + for_each_disjoint_geometry_if<0, Geometry1>::apply(turns.begin(), turns.end(), geometry1, pred1); if ( result.interrupt ) return; boundary_checker boundary_checker2(geometry2); disjoint_linestring_pred<1, Result, boundary_checker > pred2(result, boundary_checker2); - for_each_disjoint_linestring_if<1, Geometry2>::apply(turns.begin(), turns.end(), geometry2, pred2); + for_each_disjoint_geometry_if<1, Geometry2>::apply(turns.begin(), turns.end(), geometry2, pred2); if ( result.interrupt ) return;