From 39484599bcceebfa228aae3d39a932c849ff3dd0 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 14 Dec 2013 19:34:54 +0100 Subject: [PATCH] [geometry] recently added detail::XXX::YYY_dispatch structs moved/renamed to detail_dispatch::XXX::YYY --- .../algorithms/detail/sub_geometry.hpp | 46 ++++++++----------- .../detail/within/point_in_geometry.hpp | 26 +++++++---- .../detail/within/within_no_turns.hpp | 42 +++++++++-------- .../detail/within/point_in_geometry.hpp | 12 ++--- 4 files changed, 66 insertions(+), 60 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/sub_geometry.hpp b/include/boost/geometry/algorithms/detail/sub_geometry.hpp index f0c1c3603..c3db75694 100644 --- a/include/boost/geometry/algorithms/detail/sub_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/sub_geometry.hpp @@ -36,15 +36,19 @@ struct index_type } }; +}} // namespace detail::sub_geometry + +namespace detail_dispatch { namespace sub_geometry { + // TODO: later remove IsMulti and move to multi directory template ::type, bool IsMulti = boost::is_base_of::value> -struct get_dispatch : not_implemented +struct get : not_implemented {}; template -struct get_dispatch +struct get { typedef Geometry & result_type; @@ -56,7 +60,7 @@ struct get_dispatch }; template -struct get_dispatch +struct get { typedef typename geometry::ring_type::type & result_type; @@ -75,50 +79,40 @@ struct get_dispatch }; template -struct get_dispatch +struct get { typedef typename boost::range_value::type sub_type; - typedef typename get_dispatch::result_type result_type; + typedef detail_dispatch::sub_geometry::get get_type; + typedef typename get_type::result_type result_type; template static inline result_type apply(Geometry & geometry, Id const& id) { BOOST_ASSERT(0 <= id.multi_index); - return get_dispatch::apply(*(boost::begin(geometry) + id.multi_index), id); + return get_type::apply(*(boost::begin(geometry) + id.multi_index), id); } }; +}} // namespace detail_dispatch::sub_geometry + +namespace detail { namespace sub_geometry { + template struct result_type { - typedef typename get_dispatch::result_type type; + typedef typename detail_dispatch::sub_geometry::get::result_type type; }; -//template -//struct result_type -//{ -// typedef typename get_dispatch::result_type type; -//}; - // This function also works for geometry::segment_identifier template inline -typename get_dispatch::result_type -get(Geometry & g, Id const& id) +typename detail_dispatch::sub_geometry::get::result_type +get(Geometry & geometry, Id const& id) { - return get_dispatch::apply(g, id); + return detail_dispatch::sub_geometry::get::apply(geometry, id); }; -//template inline -//typename get_dispatch::result_type -//get(Geometry const& g, Id const& id) -//{ -// return get_dispatch::apply(g, id); -//}; - -} // namespace sub_geometry - -} // namespace detail +}} // namespace detail::sub_geometry #endif }} // namespace boost::geometry diff --git a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp index fc1b386a2..57d9e9e88 100644 --- a/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/within/point_in_geometry.hpp @@ -51,6 +51,10 @@ int point_in_range(Point const& point, Range const& range, Strategy const& strat return strategy.result(state); } +}} // namespace detail::within + +namespace detail_dispatch { namespace within { + // checks the relation between a point P and geometry G // returns 1 if P is in the interior of G // returns 0 if P is on the boundry of G @@ -58,11 +62,11 @@ int point_in_range(Point const& point, Range const& range, Strategy const& strat template ::type> -struct point_in_geometry_dispatch : not_implemented +struct point_in_geometry : not_implemented {}; template -struct point_in_geometry_dispatch +struct point_in_geometry { template static inline int apply(Point const& point, Box const& box, Strategy const& strategy) @@ -73,7 +77,7 @@ struct point_in_geometry_dispatch }; template -struct point_in_geometry_dispatch +struct point_in_geometry { template static inline int apply(Point const& point, Linestring const& linestring, Strategy const& strategy) @@ -103,7 +107,7 @@ struct point_in_geometry_dispatch }; template -struct point_in_geometry_dispatch +struct point_in_geometry { template static inline int apply(Point const& point, Ring const& ring, Strategy const& strategy) @@ -127,19 +131,19 @@ struct point_in_geometry_dispatch rev_view_type rev_view(ring); cl_view_type view(rev_view); - return point_in_range(point, view, strategy); + return detail::within::point_in_range(point, view, strategy); } }; //// Polygon: in exterior ring, and if so, not within interior ring(s) template -struct point_in_geometry_dispatch +struct point_in_geometry { template static inline int apply(Point const& point, Polygon const& polygon, Strategy const& strategy) { - int const code = point_in_geometry_dispatch + int const code = point_in_geometry < typename ring_type::type >::apply(point, exterior_ring(polygon), strategy); @@ -152,7 +156,7 @@ struct point_in_geometry_dispatch it != boost::end(rings); ++it) { - int const interior_code = point_in_geometry_dispatch + int const interior_code = point_in_geometry < typename ring_type::type >::apply(point, *it, strategy); @@ -170,6 +174,10 @@ struct point_in_geometry_dispatch } }; +}} // namespace detail_dispatch::within + +namespace detail { namespace within { + // 1 - in the interior // 0 - in the boundry // -1 - in the exterior @@ -178,7 +186,7 @@ int point_in_geometry(Point const& point, Geometry const& geometry, Strategy con { BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategyPolygonal) ); - return point_in_geometry_dispatch::apply(point, geometry, strategy); + return detail_dispatch::within::point_in_geometry::apply(point, geometry, strategy); } template inline diff --git a/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp b/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp index d3bcbe063..7863f70ae 100644 --- a/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp +++ b/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp @@ -23,7 +23,7 @@ namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace within { +namespace detail_dispatch { namespace within { // returns true if G1 is within G2 // this function should be called only if there are no intersection points @@ -34,7 +34,7 @@ template ::type, typename Tag2 = typename geometry::tag::type> -struct within_no_turns_dispatch +struct within_no_turns { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) @@ -44,12 +44,12 @@ struct within_no_turns_dispatch if ( !geometry::point_on_border(p, geometry1) ) return false; - return point_in_geometry(p, geometry2, strategy) >= 0; + return detail::within::point_in_geometry(p, geometry2, strategy) >= 0; } }; template -struct within_no_turns_dispatch +struct within_no_turns { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) @@ -60,7 +60,7 @@ struct within_no_turns_dispatch if ( !geometry::point_on_border(p, geometry1) ) return false; // check if one of ring points is outside the polygon - if ( point_in_geometry(p, geometry2, strategy) < 0 ) + if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 ) return false; // Now check if holes of G2 aren't inside G1 typedef typename boost::range_const_iterator @@ -74,7 +74,7 @@ struct within_no_turns_dispatch point2_type p; if ( !geometry::point_on_border(p, *it) ) return false; - if ( point_in_geometry(p, geometry1, strategy) > 0 ) + if ( detail::within::point_in_geometry(p, geometry1, strategy) > 0 ) return false; } return true; @@ -82,7 +82,7 @@ struct within_no_turns_dispatch }; template -struct within_no_turns_dispatch +struct within_no_turns { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) @@ -93,7 +93,7 @@ struct within_no_turns_dispatch if ( !geometry::point_on_border(p, geometry1) ) return false; // check if one of ring points is outside the polygon - if ( point_in_geometry(p, geometry2, strategy) < 0 ) + if ( detail::within::point_in_geometry(p, geometry2, strategy) < 0 ) return false; // Now check if holes of G2 aren't inside G1 typedef typename boost::range_const_iterator @@ -108,7 +108,7 @@ struct within_no_turns_dispatch if ( !geometry::point_on_border(p2, *it) ) return false; // if the hole of G2 is inside G1 - if ( point_in_geometry(p2, geometry1, strategy) > 0 ) + if ( detail::within::point_in_geometry(p2, geometry1, strategy) > 0 ) { // if it's also inside one of the G1 holes, it's ok bool ok = false; @@ -120,7 +120,7 @@ struct within_no_turns_dispatch it1 != boost::end(geometry::interior_rings(geometry1)) ; ++it1 ) { - if ( point_in_geometry(p2, *it1, strategy) < 0 ) + if ( detail::within::point_in_geometry(p2, *it1, strategy) < 0 ) { ok = true; break; @@ -142,17 +142,17 @@ template ::type, bool IsMulti1 = boost::is_base_of::value, bool IsMulti2 = boost::is_base_of::value> -struct within_no_turns_multi_dispatch +struct within_no_turns_multi { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) { - return within_no_turns_dispatch::apply(geometry1, geometry2, strategy); + return within_no_turns::apply(geometry1, geometry2, strategy); } }; template -struct within_no_turns_multi_dispatch +struct within_no_turns_multi { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) @@ -162,7 +162,7 @@ struct within_no_turns_multi_dispatch::type iterator; for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) { - if ( !within_no_turns_dispatch::apply(*it, geometry2, strategy) ) + if ( !within_no_turns::apply(*it, geometry2, strategy) ) return false; } return true; @@ -170,7 +170,7 @@ struct within_no_turns_multi_dispatch -struct within_no_turns_multi_dispatch +struct within_no_turns_multi { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) @@ -180,7 +180,7 @@ struct within_no_turns_multi_dispatch::type iterator; for ( iterator it = boost::begin(geometry2) ; it != boost::end(geometry2) ; ++it ) { - if ( within_no_turns_dispatch::apply(geometry1, *it, strategy) ) + if ( within_no_turns::apply(geometry1, *it, strategy) ) return true; } return false; @@ -188,7 +188,7 @@ struct within_no_turns_multi_dispatch -struct within_no_turns_multi_dispatch +struct within_no_turns_multi { template static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) @@ -198,17 +198,21 @@ struct within_no_turns_multi_dispatch::type iterator; for ( iterator it = boost::begin(geometry1) ; it != boost::end(geometry1) ; ++it ) { - if ( !within_no_turns_multi_dispatch::apply(*it, geometry2, strategy) ) + if ( !within_no_turns_multi::apply(*it, geometry2, strategy) ) return false; } return true; } }; +}} // namespace detail_dispatch::within + +namespace detail { namespace within { + template inline bool within_no_turns(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy) { - return within_no_turns_multi_dispatch::apply(geometry1, geometry2, strategy); + return detail_dispatch::within::within_no_turns_multi::apply(geometry1, geometry2, strategy); } }} // namespace detail::within diff --git a/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp b/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp index 5a635ba35..ed7efec8e 100644 --- a/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp +++ b/include/boost/geometry/multi/algorithms/detail/within/point_in_geometry.hpp @@ -23,10 +23,10 @@ namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace within { +namespace detail_dispatch { namespace within { template -struct point_in_geometry_dispatch +struct point_in_geometry { template static inline int apply(Point const& point, Geometry const& geometry, Strategy const& strategy) @@ -38,7 +38,7 @@ struct point_in_geometry_dispatch typedef typename boost::range_const_iterator::type iterator; for ( iterator it = boost::begin(geometry) ; it != boost::end(geometry) ; ++it ) { - int pip = detail::within::point_in_geometry_dispatch::apply(point, *it, strategy); + int pip = point_in_geometry::apply(point, *it, strategy); if ( 1 == pip ) // inside polygon return 1; @@ -56,7 +56,7 @@ struct point_in_geometry_dispatch }; template -struct point_in_geometry_dispatch +struct point_in_geometry { template static inline int apply(Point const& point, Geometry const& geometry, Strategy const& strategy) @@ -69,7 +69,7 @@ struct point_in_geometry_dispatch iterator it = boost::begin(geometry); for ( ; it != boost::end(geometry) ; ++it ) { - pip = detail::within::point_in_geometry_dispatch::apply(point, *it, strategy); + pip = point_in_geometry::apply(point, *it, strategy); if ( 0 <= pip ) { @@ -104,7 +104,7 @@ struct point_in_geometry_dispatch } }; -}} // namespace detail::within +}} // namespace detail_dispatch::within #endif // DOXYGEN_NO_DETAIL }} // namespace boost::geometry