Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63707 - in sandbox/geometry/boost/geometry: extensions/contrib extensions/gis/geographic/strategies strategies/cartesian strategies/concepts strategies/spherical
From: barend.gehrels_at_[hidden]
Date: 2010-07-06 16:46:40


Author: barendgehrels
Date: 2010-07-06 16:46:37 EDT (Tue, 06 Jul 2010)
New Revision: 63707
URL: http://svn.boost.org/trac/boost/changeset/63707

Log:
ttmath exp/mnt reversal
removed first/second point type (as it is only necessary for concept checking)
Text files modified:
   sandbox/geometry/boost/geometry/extensions/contrib/ttmath_stub.hpp | 52 ++++++++++++------------
   sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp | 2
   sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp | 3 -
   sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp | 6 --
   sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp | 86 +++++++++++++++++++++++++++------------
   sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp | 5 --
   6 files changed, 86 insertions(+), 68 deletions(-)

Modified: sandbox/geometry/boost/geometry/extensions/contrib/ttmath_stub.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/contrib/ttmath_stub.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/contrib/ttmath_stub.hpp 2010-07-06 16:46:37 EDT (Tue, 06 Jul 2010)
@@ -7,70 +7,70 @@
 #include <ttmath/ttmath.h>
 namespace ttmath
 {
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> sqrt(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> sqrt(Big<Exponent, Mantissa> const& v)
     {
         return Sqrt(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> abs(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> abs(Big<Exponent, Mantissa> const& v)
     {
         return Abs(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> ceil(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> ceil(Big<Exponent, Mantissa> const& v)
     {
         return Ceil(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> floor(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> floor(Big<Exponent, Mantissa> const& v)
     {
         return Floor(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> asin(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> asin(Big<Exponent, Mantissa> const& v)
     {
         return ASin(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> sin(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> sin(Big<Exponent, Mantissa> const& v)
     {
         return Sin(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> cos(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> cos(Big<Exponent, Mantissa> const& v)
     {
         return Cos(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> tan(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> tan(Big<Exponent, Mantissa> const& v)
     {
         return Tan(v);
     }
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> atan(Big<Mantissa, Exponent> const& v)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> atan(Big<Exponent, Mantissa> const& v)
     {
         return ATan(v);
     }
 
 
- template <uint Mantissa, uint Exponent>
- inline Big<Mantissa, Exponent> atan2(Big<Mantissa, Exponent> const& y, Big<Mantissa, Exponent> const& x)
+ template <uint Exponent, uint Mantissa>
+ inline Big<Exponent, Mantissa> atan2(Big<Exponent, Mantissa> const& y, Big<Exponent, Mantissa> const& x)
     {
         // return ATan2(y, 2); does not (yet) exist in ttmath...
 
         // See http://en.wikipedia.org/wiki/Atan2
 
- Big<Mantissa, Exponent> const zero(0);
- Big<Mantissa, Exponent> const two(2);
+ Big<Exponent, Mantissa> const zero(0);
+ Big<Exponent, Mantissa> const two(2);
 
         if (y == zero)
         {
@@ -109,14 +109,14 @@
 
 namespace boost{ namespace math { namespace constants
 {
- // Workaround for boost::math::constants::pi:
+ // Workaround for boost::math::constants::pi:
     // 1) lexical cast -> stack overflow and
     // 2) because it is implemented as a function, generic implementation not possible
 
- template <ttmath::uint Mantissa, ttmath::uint Exponent>
- inline ttmath::Big<Mantissa, Exponent> ttmath_pi()
+ template <ttmath::uint Exponent, ttmath::uint Mantissa>
+ inline ttmath::Big<Exponent, Mantissa> ttmath_pi()
     {
- static ttmath::Big<Mantissa, Exponent> const the_pi("3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196");
+ static ttmath::Big<Exponent, Mantissa> const the_pi("3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196");
         return the_pi;
     }
 

Modified: sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp 2010-07-06 16:46:37 EDT (Tue, 06 Jul 2010)
@@ -48,8 +48,6 @@
 class andoyer
 {
     public :
- typedef P1 first_point_type;
- typedef P2 second_point_type;
         typedef double return_type;
 
         andoyer()

Modified: sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp 2010-07-06 16:46:37 EDT (Tue, 06 Jul 2010)
@@ -65,9 +65,6 @@
>::type
>::type return_type;
 
- typedef Point1 first_point_type;
- typedef Point2 second_point_type;
-
     inline vincenty()
     {}
 

Modified: sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp 2010-07-06 16:46:37 EDT (Tue, 06 Jul 2010)
@@ -86,9 +86,6 @@
                 CalculationType
>::type calculation_type;
 
- typedef Point1 first_point_type;
- typedef Point2 second_point_type;
-
     static inline calculation_type apply(Point1 const& p1, Point2 const& p2)
     {
         BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point1>) );
@@ -133,9 +130,6 @@
             typename services::return_type<comparable_type>::type
>::type calculation_type;
 
- typedef Point1 first_point_type;
- typedef Point2 second_point_type;
-
     static inline calculation_type apply(Point1 const& p1, Point2 const& p2)
     {
         calculation_type const t = comparable_type::apply(p1, p2);

Modified: sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/concepts/distance_concept.hpp 2010-07-06 16:46:37 EDT (Tue, 06 Jul 2010)
@@ -20,6 +20,40 @@
 namespace boost { namespace geometry { namespace concept
 {
 
+namespace detail
+{
+
+template <typename Strategy> struct first_point_type {};
+template <typename Strategy> struct second_point_type {};
+
+// Specializations for strategies having P1,P2,CalculationType
+template <template <typename, typename, typename> class Strategy, typename P1, typename P2, typename C>
+struct first_point_type<Strategy<P1, P2, C> >
+{
+ typedef P1 type;
+};
+
+template <template <typename, typename, typename> class Strategy, typename P1, typename P2, typename C>
+struct second_point_type<Strategy<P1, P2, C> >
+{
+ typedef P2 type;
+};
+
+
+// Specializations for strategies having P1,P2
+template <template <typename, typename> class Strategy, typename P1, typename P2>
+struct first_point_type<Strategy<P1, P2> >
+{
+ typedef P1 type;
+};
+
+template <template <typename, typename> class Strategy, typename P1, typename P2>
+struct second_point_type<Strategy<P1, P2> >
+{
+ typedef P2 type;
+};
+
+}
 
 /*!
     \brief Checks strategy for point-segment-distance
@@ -31,60 +65,60 @@
 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
     private :
 
- // 1) must define first_point_type
- typedef typename Strategy::first_point_type ptype1;
+ // Helper to get first_point_type
+ //typedef typename Strategy::first_point_type ptype1;
+ typedef typename detail::first_point_type<Strategy>::type ptype1;
         BOOST_CONCEPT_ASSERT
             (
                 (concept::ConstPoint<ptype1>)
             );
 
- // 2) must define second_point_type
- typedef typename Strategy::second_point_type ptype2;
+ // Helper to get second_point_type
+ typedef typename detail::second_point_type<Strategy>::type ptype2;
         BOOST_CONCEPT_ASSERT
             (
                 (concept::ConstPoint<ptype2>)
             );
 
- // 3) must define meta-function return_type
+ // 1) must define meta-function return_type
         typedef typename strategy::distance::services::return_type<Strategy>::type rtype;
 
- // 4) must implement apply with arguments
- struct apply_checker
- {
- static void check()
- {
- Strategy* str;
- ptype1 *p1;
- ptype2 *p2;
- rtype r = str->apply(*p1, *p2);
-
- boost::ignore_unused_variable_warning(str);
- boost::ignore_unused_variable_warning(r);
- }
- };
-
- // 5) must define meta-function "similar_type"
+ // 2) must define meta-function "similar_type"
         typedef typename strategy::distance::services::similar_type
             <
                 Strategy, ptype2, ptype1
>::type stype;
 
- // 6) must define meta-function "comparable_type"
+ // 3) must define meta-function "comparable_type"
         typedef typename strategy::distance::services::comparable_type
             <
                 Strategy
>::type ctype;
 
- // 6) must define meta-function "tag"
+ // 4) must define meta-function "tag"
         typedef typename strategy::distance::services::tag
             <
                 Strategy
>::type tag;
 
+ // 5) must implement apply with arguments
+ struct apply_checker
+ {
+ static void check()
+ {
+ Strategy* str;
+ ptype1 *p1;
+ ptype2 *p2;
+ rtype r = str->apply(*p1, *p2);
+
+ boost::ignore_unused_variable_warning(str);
+ boost::ignore_unused_variable_warning(r);
+ }
+ };
 
- // 7) must define (meta)struct "get_similar" with apply
- // 8) must define (meta)struct "get_comparable" with apply
- // 9) must define (meta)struct "result_from_distance" with apply
+ // 6) must define (meta)struct "get_similar" with apply
+ // 7) must define (meta)struct "get_comparable" with apply
+ // 8) must define (meta)struct "result_from_distance" with apply
         struct services_checker
         {
             static void check()

Modified: sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp 2010-07-06 16:46:37 EDT (Tue, 06 Jul 2010)
@@ -57,9 +57,6 @@
>::type
>::type calculation_type;
 
- typedef Point1 first_point_type;
- typedef Point2 second_point_type;
-
     inline haversine(calculation_type const& r = 1.0)
         : m_radius(r)
     {}
@@ -123,8 +120,6 @@
     typedef comparable::haversine<Point1, Point2, CalculationType> comparable_type;
 
 public :
- typedef Point1 first_point_type;
- typedef Point2 second_point_type;
 
     typedef typename services::return_type<comparable_type>::type calculation_type;
 


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