Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75975 - in trunk: boost/geometry/algorithms libs/geometry/doc/src/docutils/tools/support_status
From: bruno.lalande_at_[hidden]
Date: 2011-12-15 18:26:29


Author: bruno.lalande
Date: 2011-12-15 18:26:22 EST (Thu, 15 Dec 2011)
New Revision: 75975
URL: http://svn.boost.org/trac/boost/changeset/75975

Log:
Made dispatch::distance able to reverse itself. This is no longer driven by the caller.
Text files modified:
   trunk/boost/geometry/algorithms/distance.hpp | 102 +++++++++++++++++++++------------------
   trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp | 3
   2 files changed, 56 insertions(+), 49 deletions(-)

Modified: trunk/boost/geometry/algorithms/distance.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/distance.hpp (original)
+++ trunk/boost/geometry/algorithms/distance.hpp 2011-12-15 18:26:22 EST (Thu, 15 Dec 2011)
@@ -250,7 +250,8 @@
     typename Geometry1, typename Geometry2,
     typename StrategyTag, typename Strategy,
     typename Tag1 = typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
- typename Tag2 = typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type
+ typename Tag2 = typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
+ bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
>
 struct distance: not_implemented<for_geometry<Tag1>,
                                  and_geometry<Tag2> >
@@ -262,19 +263,53 @@
     <
         P1, P2,
         strategy_tag_distance_point_point, Strategy,
- point_tag, point_tag
+ point_tag, point_tag,
+ false
>
     : detail::distance::point_to_point<P1, P2, Strategy>
 {};
 
 
+// If reversal is needed, perform it
+template
+<
+ typename Geometry1, typename Geometry2,
+ typename StrategyTag, typename Strategy,
+ typename Tag1,
+ typename Tag2
+>
+struct distance
+<
+ Geometry1, Geometry2,
+ StrategyTag, Strategy,
+ Tag1, Tag2,
+ true
+>: distance<Geometry2, Geometry1, StrategyTag, Strategy, Tag2, Tag1, false>
+{
+ static inline typename return_type<Strategy>::type apply(
+ Geometry1 const& g1,
+ Geometry2 const& g2,
+ Strategy const& strategy)
+ {
+ return distance
+ <
+ Geometry2, Geometry1,
+ StrategyTag, Strategy,
+ Tag2, Tag1,
+ false
+ >::apply(g2, g1, strategy);
+ }
+};
+
+
 // Point-line version 1, where point-point strategy is specified
 template <typename Point, typename Linestring, typename Strategy>
 struct distance
 <
     Point, Linestring,
     strategy_tag_distance_point_point, Strategy,
- point_tag, linestring_tag
+ point_tag, linestring_tag,
+ false
>
 {
 
@@ -303,7 +338,8 @@
 <
     Point, Linestring,
     strategy_tag_distance_point_segment, Strategy,
- point_tag, linestring_tag
+ point_tag, linestring_tag,
+ false
>
 {
     static inline typename return_type<Strategy>::type apply(Point const& point,
@@ -324,7 +360,8 @@
 <
     Point, Ring,
     strategy_tag_distance_point_point, Strategy,
- point_tag, ring_tag
+ point_tag, ring_tag,
+ false
>
 {
     typedef typename return_type<Strategy>::type return_type;
@@ -359,7 +396,8 @@
 <
     Point, Polygon,
     strategy_tag_distance_point_point, Strategy,
- point_tag, polygon_tag
+ point_tag, polygon_tag,
+ false
>
 {
     typedef typename return_type<Strategy>::type return_type;
@@ -395,7 +433,8 @@
 <
     Point, Segment,
     strategy_tag_distance_point_point, Strategy,
- point_tag, segment_tag
+ point_tag, segment_tag,
+ false
> : detail::distance::point_to_segment<Point, Segment, Strategy>
 {};
 
@@ -404,8 +443,9 @@
 struct distance
 <
     Point, Segment,
+ strategy_tag_distance_point_segment, Strategy,
     point_tag, segment_tag,
- strategy_tag_distance_point_segment, Strategy
+ false
>
 {
     static inline typename return_type<Strategy>::type apply(Point const& point,
@@ -421,27 +461,6 @@
 
 
 
-// Strictly spoken this might be in namespace <impl> again
-template
-<
- typename G1, typename G2,
- typename StrategyTag, typename Strategy,
- typename GeometryTag1 = typename tag_cast<typename tag<G1>::type, multi_tag>::type,
- typename GeometryTag2 = typename tag_cast<typename tag<G2>::type, multi_tag>::type
->
-struct distance_reversed
-{
- static inline typename return_type<Strategy>::type apply(G1 const& g1,
- G2 const& g2, Strategy const& strategy)
- {
- return distance
- <
- G2, G1,
- StrategyTag, Strategy
- >::apply(g2, g1, strategy);
- }
-};
-
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH
 
@@ -489,24 +508,13 @@
     concept::check<Geometry1 const>();
     concept::check<Geometry2 const>();
 
- return boost::mpl::if_
- <
- typename geometry::reverse_dispatch<Geometry1, Geometry2>::type,
- dispatch::distance_reversed
- <
- Geometry1,
- Geometry2,
- typename strategy::distance::services::tag<Strategy>::type,
- Strategy
- >,
- dispatch::distance
- <
- Geometry1,
- Geometry2,
- typename strategy::distance::services::tag<Strategy>::type,
- Strategy
- >
- >::type::apply(geometry1, geometry2, strategy);
+ return dispatch::distance
+ <
+ Geometry1,
+ Geometry2,
+ typename strategy::distance::services::tag<Strategy>::type,
+ Strategy
+ >::apply(geometry1, geometry2, strategy);
 }
 
 

Modified: trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp
==============================================================================
--- trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp (original)
+++ trunk/libs/geometry/doc/src/docutils/tools/support_status/support_status.cpp 2011-12-15 18:26:22 EST (Thu, 15 Dec 2011)
@@ -55,8 +55,7 @@
     template <typename T2>
     void operator()(T2)
     {
- if (boost::is_base_of<boost::geometry::not_implemented_base, check_distance<T1, T2> >::type::value
- && boost::is_base_of<boost::geometry::not_implemented_base, check_distance<T2, T1> >::type::value)
+ if (boost::is_base_of<boost::geometry::not_implemented_base, check_distance<T1, T2> >::type::value)
         {
             std::cout << "-\t";
         }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk