Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51748 - in sandbox/ggl/boost/ggl/geometry: algorithms core core/concepts geometries projections/impl util
From: barend.gehrels_at_[hidden]
Date: 2009-03-13 11:04:56


Author: barendgehrels
Date: 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
New Revision: 51748
URL: http://svn.boost.org/trac/boost/changeset/51748

Log:
Added Reversible to distance
Added is_linear to num_points
Fixed a few typo's in comments

Added:
   sandbox/ggl/boost/ggl/geometry/core/is_linear.hpp (contents, props changed)
Removed:
   sandbox/ggl/boost/ggl/geometry/projections/impl/proj_util.hpp
Text files modified:
   sandbox/ggl/boost/ggl/geometry/algorithms/distance.hpp | 57 +++++++++++++++------------------------
   sandbox/ggl/boost/ggl/geometry/algorithms/envelope.hpp | 2
   sandbox/ggl/boost/ggl/geometry/algorithms/make.hpp | 2
   sandbox/ggl/boost/ggl/geometry/algorithms/num_points.hpp | 23 ++++++++-------
   sandbox/ggl/boost/ggl/geometry/core/concepts/ring_concept.hpp | 4 +-
   sandbox/ggl/boost/ggl/geometry/core/topological_dimension.hpp | 2
   sandbox/ggl/boost/ggl/geometry/geometries/point.hpp | 2
   sandbox/ggl/boost/ggl/geometry/util/loop.hpp | 2
   8 files changed, 41 insertions(+), 53 deletions(-)

Modified: sandbox/ggl/boost/ggl/geometry/algorithms/distance.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/algorithms/distance.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/algorithms/distance.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -12,6 +12,8 @@
 #include <boost/range/functions.hpp>
 #include <boost/range/metafunctions.hpp>
 
+#include <boost/static_assert.hpp>
+
 #include <geometry/core/cs.hpp>
 
 #include <geometry/geometries/segment.hpp>
@@ -154,13 +156,25 @@
         namespace dispatch
         {
 
- template <typename TAG1, typename TAG2, typename G1, typename G2>
+ template <typename TAG1, typename TAG2, typename G1, typename G2, bool Reversible>
                 struct distance
                 {
+ BOOST_STATIC_ASSERT(Reversible);
+
+ template <typename S>
+ static inline typename S::return_type calculate(const G1& g1, const G2& g2, const S& strategy)
+ {
+ return distance<TAG2, TAG1, G2, G1, false>::calculate(g2, g1, strategy);
+ }
+
+ static inline typename distance_result<G1, G2>::type calculate(const G1& g1, const G2& g2)
+ {
+ return distance<TAG2, TAG1, G2, G1, false>::calculate(g2, g1);
+ }
                 };
 
                 template <typename P1, typename P2>
- struct distance<point_tag, point_tag, P1, P2>
+ struct distance<point_tag, point_tag, P1, P2, false>
                 {
                         template <typename S>
                         static inline typename S::return_type calculate(const P1& p1, const P2& p2, const S& strategy)
@@ -179,8 +193,8 @@
                         }
                 };
 
- template <typename P, typename L>
- struct distance<point_tag, linestring_tag, P, L>
+ template <typename P, typename L, bool Reversible>
+ struct distance<point_tag, linestring_tag, P, L, Reversible>
                 {
                         template<typename S>
                         static inline typename S::return_type calculate(const P& point, const L& linestring, const S& strategy)
@@ -193,22 +207,8 @@
                         }
                 };
 
- template <typename L, typename P>
- struct distance<linestring_tag, point_tag, L, P>
- {
- template<typename S>
- static inline typename S::return_type calculate(const L& linestring, const P& point, const S& strategy)
- {
- return impl::distance::point_to_linestring(point, linestring, strategy);
- }
- static inline typename distance_result<P, L>::type calculate(const L& linestring, const P& point)
- {
- return impl::distance::point_to_linestring(point, linestring);
- }
- };
-
- template <typename P, typename SEG>
- struct distance<point_tag, segment_tag, P, SEG>
+ template <typename P, typename SEG, bool Reversible>
+ struct distance<point_tag, segment_tag, P, SEG, Reversible>
                 {
                         template<typename STR>
                         static inline typename STR::return_type calculate(const P& point, const SEG& segment, const STR& strategy)
@@ -221,19 +221,6 @@
                         }
                 };
 
- template <typename SEG, typename P>
- struct distance<segment_tag, point_tag, SEG, P>
- {
- template<typename STR>
- static inline typename STR::return_type calculate(const SEG& segment, const P& point, const STR& strategy)
- {
- return impl::distance::point_to_segment(point, segment, strategy);
- }
- static inline typename distance_result<P, SEG>::type calculate(const SEG& segment, const P& point)
- {
- return impl::distance::point_to_segment(point, segment);
- }
- };
 
 
         } // namespace dispatch
@@ -255,7 +242,7 @@
                 distance(const G1& geometry1, const G2& geometry2)
         {
                 return dispatch::distance<typename tag<G1>::type,
- typename tag<G2>::type, G1, G2>::calculate(geometry1, geometry2);
+ typename tag<G2>::type, G1, G2, true>::calculate(geometry1, geometry2);
         }
 
         /*!
@@ -279,7 +266,7 @@
         inline typename S::return_type distance(const G1& geometry1, const G2& geometry2, const S& strategy)
         {
                 return dispatch::distance<typename tag<G1>::type,
- typename tag<G2>::type, G1, G2>::calculate(geometry1, geometry2, strategy);
+ typename tag<G2>::type, G1, G2, true>::calculate(geometry1, geometry2, strategy);
         }
 
 

Modified: sandbox/ggl/boost/ggl/geometry/algorithms/envelope.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/algorithms/envelope.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/algorithms/envelope.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -42,7 +42,7 @@
         returned as a Geometry. The polygon is defined by the corner points of the bounding
         box [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].
 
-\note Implemented in the Geometry library: The minimum bounding box, always as a box, having min <= max
+\note Implemented in the Generic Geometry Library: The minimum bounding box, always as a box, having min <= max
 
 The envelope algorithm calculates the bounding box, or envelope, of a geometry. There are two versions:
 - envelope, taking a reference to a box as second parameter

Modified: sandbox/ggl/boost/ggl/geometry/algorithms/make.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/algorithms/make.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/algorithms/make.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -18,7 +18,7 @@
         /*!
                 \brief Make a geometry
                 \ingroup access
- \details The Geometry Library uses concepts for all its geometries. Therefore it does not rely
+ \details the Generic Geometry Library uses concepts for all its geometries. Therefore it does not rely
                 on constructors. The "make" functions are object generators creating geometries. There are overloads
                 with two, three, four or six values, which are implemented depending on the geometry specified.
                 \tparam G the geometry type

Modified: sandbox/ggl/boost/ggl/geometry/algorithms/num_points.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/algorithms/num_points.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/algorithms/num_points.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -13,6 +13,8 @@
 
 #include <boost/type_traits/remove_const.hpp>
 
+#include <geometry/core/is_linear.hpp>
+
 
 namespace geometry
 {
@@ -64,29 +66,27 @@
         #ifndef DOXYGEN_NO_DISPATCH
         namespace dispatch
         {
- template <typename TAG, typename G>
+ template <typename TAG, bool LINEAR, typename G>
                 struct num_points {};
 
- template <typename G>
- struct num_points<point_tag, G> : impl::other_number_of_points<G, 1> {};
+ template <typename TAG, typename G>
+ struct num_points<TAG, true, G> : impl::range_number_of_points<G> {};
 
- template <typename G>
- struct num_points<box_tag, G> : impl::other_number_of_points<G, 4> {};
 
                 template <typename G>
- struct num_points<segment_tag, G> : impl::other_number_of_points<G, 2> {};
+ struct num_points<point_tag, false, G> : impl::other_number_of_points<G, 1> {};
 
                 template <typename G>
- struct num_points<nsphere_tag, G> : impl::other_number_of_points<G, 1> {};
+ struct num_points<box_tag, false, G> : impl::other_number_of_points<G, 4> {};
 
                 template <typename G>
- struct num_points<linestring_tag, G> : impl::range_number_of_points<G> {};
+ struct num_points<segment_tag, false, G> : impl::other_number_of_points<G, 2> {};
 
                 template <typename G>
- struct num_points<ring_tag, G> : impl::range_number_of_points<G> {};
+ struct num_points<nsphere_tag, false, G> : impl::other_number_of_points<G, 1> {};
 
                 template <typename G>
- struct num_points<polygon_tag, G> : impl::polygon_number_of_points<G> {};
+ struct num_points<polygon_tag, false, G> : impl::polygon_number_of_points<G> {};
 
         } // namespace dispatch
         #endif
@@ -107,7 +107,8 @@
         inline size_t num_points(G& geometry)
         {
                 typedef typename boost::remove_const<G>::type NCG;
- return dispatch::num_points<typename tag<G>::type, NCG>::get(geometry);
+ return dispatch::num_points<typename tag<G>::type, is_linear<NCG>::value,
+ NCG>::get(geometry);
         }
 
 }

Modified: sandbox/ggl/boost/ggl/geometry/core/concepts/ring_concept.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/core/concepts/ring_concept.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/core/concepts/ring_concept.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -31,7 +31,7 @@
 
 
         /*!
- \brief Checks linestring concept, using Boost Concept Check Library and metafunctions
+ \brief Checks (linear) Ring concept, using Boost Concept Check Library and metafunctions
                 \ingroup concepts
         */
         template <typename R>
@@ -57,7 +57,7 @@
 
 
         /*!
- \brief Checks Ring concept (const version)
+ \brief Checks (linear) ring concept (const version)
                 \ingroup concepts
                 \details The ConstLinearRing concept check the same as the Ring concept,
                 but does not check write access.

Added: sandbox/ggl/boost/ggl/geometry/core/is_linear.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/boost/ggl/geometry/core/is_linear.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -0,0 +1,57 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef _GEOMETRY_IS_LINEAR_HPP
+#define _GEOMETRY_IS_LINEAR_HPP
+
+
+#include <boost/type_traits.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <geometry/core/tag.hpp>
+#include <geometry/core/tags.hpp>
+
+
+namespace geometry
+{
+
+
+ #ifndef DOXYGEN_NO_DISPATCH
+ namespace core_dispatch
+ {
+ template <typename TAG, typename G>
+ struct is_linear : boost::false_type {};
+
+
+ template <typename G> struct is_linear<linestring_tag, G> : boost::true_type {};
+ template <typename G> struct is_linear<ring_tag, G> : boost::true_type {};
+
+
+ } // namespace core_dispatch
+ #endif
+
+
+
+
+ /*!
+ \brief Meta-function defining "true" for linear types (linestring,ring), "false" for non-linear typse
+ \details Can be used for tag dispatching mechanism
+ \ingroup core
+ */
+ template <typename G>
+ struct is_linear
+ : core_dispatch::is_linear
+ < typename tag<G>::type , typename boost::remove_const<G>::type >
+ { };
+
+
+}
+
+
+#endif

Modified: sandbox/ggl/boost/ggl/geometry/core/topological_dimension.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/core/topological_dimension.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/core/topological_dimension.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -47,7 +47,7 @@
 
 
         /*!
- \brief Meta-function returning gives the topological dimension of a geometry
+ \brief Meta-function returning the topological dimension of a geometry
                 \details The topological dimension defines a point as 0-dimensional, a linestring as 1-dimensional,
                         and a ring or polygon as 2-dimensional.
                 \see http://www.math.okstate.edu/mathdept/dynamics/lecnotes/node36.html

Modified: sandbox/ggl/boost/ggl/geometry/geometries/point.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/geometries/point.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/geometries/point.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -25,7 +25,7 @@
 
 
         /*!
- \brief Basic point class, having coordinates dfined in a neutral way
+ \brief Basic point class, having coordinates defined in a neutral way
                 \ingroup Geometry
                 \tparam T numeric type, for example double, float, int
                 \tparam D number of coordinates, for example 2

Deleted: sandbox/ggl/boost/ggl/geometry/projections/impl/proj_util.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/projections/impl/proj_util.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
+++ (empty file)
@@ -1 +0,0 @@
-// obsolete

Modified: sandbox/ggl/boost/ggl/geometry/util/loop.hpp
==============================================================================
--- sandbox/ggl/boost/ggl/geometry/util/loop.hpp (original)
+++ sandbox/ggl/boost/ggl/geometry/util/loop.hpp 2009-03-13 11:04:53 EDT (Fri, 13 Mar 2009)
@@ -47,7 +47,7 @@
                         - <em>if it is a class functor</em>: bool operator()(const segment&, state&) const
                 - \a S
                         - no specific requirements here, requirments given by F
- \note Some algorithms from the Geometry Library, for example within, centroid,
+ \note Some algorithms from the Generic Geometry Library, for example within, centroid,
                 use this method.
                 \par Examples:
                 First example, using a class functor


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