Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80678 - in trunk/boost/geometry: algorithms multi/algorithms
From: bruno.lalande_at_[hidden]
Date: 2012-09-23 17:04:21


Author: bruno.lalande
Date: 2012-09-23 17:04:20 EDT (Sun, 23 Sep 2012)
New Revision: 80678
URL: http://svn.boost.org/trac/boost/changeset/80678

Log:
Moved Strategy template parameter from class level to function level in dispatch::centroid.
Text files modified:
   trunk/boost/geometry/algorithms/centroid.hpp | 87 +++++++++++++--------------------------
   trunk/boost/geometry/multi/algorithms/centroid.hpp | 54 ++++--------------------
   2 files changed, 39 insertions(+), 102 deletions(-)

Modified: trunk/boost/geometry/algorithms/centroid.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/centroid.hpp (original)
+++ trunk/boost/geometry/algorithms/centroid.hpp 2012-09-23 17:04:20 EDT (Sun, 23 Sep 2012)
@@ -77,9 +77,9 @@
 namespace detail { namespace centroid
 {
 
-template<typename Point, typename PointCentroid, typename Strategy>
 struct centroid_point
 {
+ template<typename Point, typename PointCentroid, typename Strategy>
     static inline void apply(Point const& point, PointCentroid& centroid,
             Strategy const&)
     {
@@ -127,9 +127,9 @@
 };
 
 
-template<typename Box, typename Point, typename Strategy>
 struct centroid_box
 {
+ template<typename Box, typename Point, typename Strategy>
     static inline void apply(Box const& box, Point& centroid,
             Strategy const&)
     {
@@ -173,9 +173,10 @@
 /*!
     \brief Calculate the centroid of a ring.
 */
-template<typename Ring, closure_selector Closure, typename Strategy>
+template <closure_selector Closure>
 struct centroid_range_state
 {
+ template<typename Ring, typename Strategy>
     static inline void apply(Ring const& ring,
             Strategy const& strategy, typename Strategy::state_type& state)
     {
@@ -196,21 +197,17 @@
     }
 };
 
-template<typename Range, typename Point, closure_selector Closure, typename Strategy>
+template <closure_selector Closure>
 struct centroid_range
 {
+ template<typename Range, typename Point, typename Strategy>
     static inline void apply(Range const& range, Point& centroid,
             Strategy const& strategy)
     {
         if (range_ok(range, centroid))
         {
             typename Strategy::state_type state;
- centroid_range_state
- <
- Range,
- Closure,
- Strategy
- >::apply(range, strategy, state);
+ centroid_range_state<Closure>::apply(range, strategy, state);
             strategy.result(state, centroid);
         }
     }
@@ -222,20 +219,14 @@
     \note Because outer ring is clockwise, inners are counter clockwise,
     triangle approach is OK and works for polygons with rings.
 */
-template<typename Polygon, typename Strategy>
 struct centroid_polygon_state
 {
- typedef typename ring_type<Polygon>::type ring_type;
-
+ template<typename Polygon, typename Strategy>
     static inline void apply(Polygon const& poly,
             Strategy const& strategy, typename Strategy::state_type& state)
     {
- typedef centroid_range_state
- <
- ring_type,
- geometry::closure<ring_type>::value,
- Strategy
- > per_ring;
+ typedef typename ring_type<Polygon>::type ring_type;
+ typedef centroid_range_state<geometry::closure<ring_type>::value> per_ring;
 
         per_ring::apply(exterior_ring(poly), strategy, state);
 
@@ -248,20 +239,16 @@
     }
 };
 
-template<typename Polygon, typename Point, typename Strategy>
 struct centroid_polygon
 {
+ template<typename Polygon, typename Point, typename Strategy>
     static inline void apply(Polygon const& poly, Point& centroid,
             Strategy const& strategy)
     {
         if (range_ok(exterior_ring(poly), centroid))
         {
             typename Strategy::state_type state;
- centroid_polygon_state
- <
- Polygon,
- Strategy
- >::apply(poly, strategy, state);
+ centroid_polygon_state::apply(poly, strategy, state);
             strategy.result(state, centroid);
         }
     }
@@ -280,56 +267,41 @@
 <
     typename Tag,
     typename Geometry,
- typename Point,
- typename Strategy
+ typename Point
>
 struct centroid {};
 
 template
 <
     typename Geometry,
- typename Point,
- typename Strategy
+ typename Point
>
-struct centroid<point_tag, Geometry, Point, Strategy>
- : detail::centroid::centroid_point<Geometry, Point, Strategy>
+struct centroid<point_tag, Geometry, Point>
+ : detail::centroid::centroid_point
 {};
 
 template
 <
     typename Box,
- typename Point,
- typename Strategy
+ typename Point
>
-struct centroid<box_tag, Box, Point, Strategy>
- : detail::centroid::centroid_box<Box, Point, Strategy>
+struct centroid<box_tag, Box, Point>
+ : detail::centroid::centroid_box
 {};
 
-template <typename Ring, typename Point, typename Strategy>
-struct centroid<ring_tag, Ring, Point, Strategy>
- : detail::centroid::centroid_range
- <
- Ring,
- Point,
- geometry::closure<Ring>::value,
- Strategy
- >
+template <typename Ring, typename Point>
+struct centroid<ring_tag, Ring, Point>
+ : detail::centroid::centroid_range<geometry::closure<Ring>::value>
 {};
 
-template <typename Linestring, typename Point, typename Strategy>
-struct centroid<linestring_tag, Linestring, Point, Strategy>
- : detail::centroid::centroid_range
- <
- Linestring,
- Point,
- closed,
- Strategy
- >
+template <typename Linestring, typename Point>
+struct centroid<linestring_tag, Linestring, Point>
+ : detail::centroid::centroid_range<closed>
  {};
 
-template <typename Polygon, typename Point, typename Strategy>
-struct centroid<polygon_tag, Polygon, Point, Strategy>
- : detail::centroid::centroid_polygon<Polygon, Point, Strategy>
+template <typename Polygon, typename Point>
+struct centroid<polygon_tag, Polygon, Point>
+ : detail::centroid::centroid_polygon
  {};
 
 } // namespace dispatch
@@ -369,8 +341,7 @@
         <
             typename tag<Geometry>::type,
             Geometry,
- Point,
- Strategy
+ Point
>::apply(geometry, c, strategy);
 }
 

Modified: trunk/boost/geometry/multi/algorithms/centroid.hpp
==============================================================================
--- trunk/boost/geometry/multi/algorithms/centroid.hpp (original)
+++ trunk/boost/geometry/multi/algorithms/centroid.hpp 2012-09-23 17:04:20 EDT (Sun, 23 Sep 2012)
@@ -35,13 +35,9 @@
     \brief Building block of a multi-point, to be used as Policy in the
         more generec centroid_multi
 */
-template
-<
- typename Point,
- typename Strategy
->
 struct centroid_multi_point_state
 {
+ template <typename Point, typename Strategy>
     static inline void apply(Point const& point,
             Strategy const& strategy, typename Strategy::state_type& state)
     {
@@ -59,15 +55,10 @@
         detail::centroid::centroid_multi
 
 */
-template
-<
- typename Multi,
- typename Point,
- typename Strategy,
- typename Policy
->
+template <typename Policy>
 struct centroid_multi
 {
+ template <typename Multi, typename Point, typename Strategy>
     static inline void apply(Multi const& multi, Point& centroid,
             Strategy const& strategy)
     {
@@ -107,41 +98,24 @@
 template
 <
     typename MultiLinestring,
- typename Point,
- typename Strategy
+ typename Point
>
-struct centroid<multi_linestring_tag, MultiLinestring, Point, Strategy>
+struct centroid<multi_linestring_tag, MultiLinestring, Point>
     : detail::centroid::centroid_multi
         <
- MultiLinestring,
- Point,
- Strategy,
- detail::centroid::centroid_range_state
- <
- typename boost::range_value<MultiLinestring>::type,
- closed,
- Strategy
- >
+ detail::centroid::centroid_range_state<closed>
>
 {};
 
 template
 <
     typename MultiPolygon,
- typename Point,
- typename Strategy
+ typename Point
>
-struct centroid<multi_polygon_tag, MultiPolygon, Point, Strategy>
+struct centroid<multi_polygon_tag, MultiPolygon, Point>
     : detail::centroid::centroid_multi
         <
- MultiPolygon,
- Point,
- Strategy,
             detail::centroid::centroid_polygon_state
- <
- typename boost::range_value<MultiPolygon>::type,
- Strategy
- >
>
 {};
 
@@ -149,20 +123,12 @@
 template
 <
     typename MultiPoint,
- typename Point,
- typename Strategy
+ typename Point
>
-struct centroid<multi_point_tag, MultiPoint, Point, Strategy>
+struct centroid<multi_point_tag, MultiPoint, Point>
     : detail::centroid::centroid_multi
         <
- MultiPoint,
- Point,
- Strategy,
             detail::centroid::centroid_multi_point_state
- <
- typename boost::range_value<MultiPoint>::type,
- Strategy
- >
>
 {};
 


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