Boost logo

Boost-Commit :

From: lucanus.j.simonson_at_[hidden]
Date: 2008-07-16 20:24:02


Author: ljsimons
Date: 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
New Revision: 47498
URL: http://svn.boost.org/trac/boost/changeset/47498

Log:
lots of updates
Text files modified:
   sandbox/gtl/gtl/boolean_op.hpp | 2
   sandbox/gtl/gtl/geometry_concept.hpp | 71 -----
   sandbox/gtl/gtl/gtl.hpp | 24 +
   sandbox/gtl/gtl/interval_concept.hpp | 78 ++++--
   sandbox/gtl/gtl/interval_data.hpp | 2
   sandbox/gtl/gtl/isotropy.hpp | 51 ++++
   sandbox/gtl/gtl/iterator_geometry_to_set.hpp | 2
   sandbox/gtl/gtl/iterator_vertex_orient_conversion.hpp | 2
   sandbox/gtl/gtl/point_3d_concept.hpp | 5
   sandbox/gtl/gtl/point_3d_data.hpp | 2
   sandbox/gtl/gtl/point_concept.hpp | 48 +++
   sandbox/gtl/gtl/point_data.hpp | 8
   sandbox/gtl/gtl/polygon_45_concept.hpp | 85 ++++---
   sandbox/gtl/gtl/polygon_45_data.hpp | 2
   sandbox/gtl/gtl/polygon_45_with_holes_concept.hpp | 56 ++++
   sandbox/gtl/gtl/polygon_45_with_holes_data.hpp | 3
   sandbox/gtl/gtl/polygon_90_concept.hpp | 45 ++-
   sandbox/gtl/gtl/polygon_90_data.hpp | 2
   sandbox/gtl/gtl/polygon_90_with_holes_concept.hpp | 10
   sandbox/gtl/gtl/polygon_90_with_holes_data.hpp | 3
   sandbox/gtl/gtl/polygon_data.hpp | 4
   sandbox/gtl/gtl/polygon_formation.hpp | 5
   sandbox/gtl/gtl/polygon_set_data.hpp | 426 ++++++++++++++++++++++++++++-----------
   sandbox/gtl/gtl/polygon_set_view.hpp | 20 +
   sandbox/gtl/gtl/polygon_set_wrapper.hpp | 16
   sandbox/gtl/gtl/polygon_with_holes_concept.hpp | 6
   sandbox/gtl/gtl/polygon_with_holes_data.hpp | 4
   sandbox/gtl/gtl/post_geometry_traits_definitions.hpp | 24 +
   sandbox/gtl/gtl/rectangle_concept.hpp | 200 +++++++++---------
   sandbox/gtl/gtl/rectangle_data.hpp | 4
   30 files changed, 791 insertions(+), 419 deletions(-)

Modified: sandbox/gtl/gtl/boolean_op.hpp
==============================================================================
--- sandbox/gtl/gtl/boolean_op.hpp (original)
+++ sandbox/gtl/gtl/boolean_op.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -525,7 +525,7 @@
     typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::const_iterator itr1 = input1.begin();
     typename std::vector<std::pair<Unit, std::pair<Unit, int> > >::const_iterator itr2 = input2.begin();
     std::vector<std::pair<interval_data<Unit>, int> > container;
- output.reserve(max(input1.size(), input2.size()));
+ output.reserve(std::max(input1.size(), input2.size()));
 
     //consider eliminating dependecy on limits with bool flag for initial state
     Unit UnitMax = std::numeric_limits<Unit>::max();

Modified: sandbox/gtl/gtl/geometry_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/geometry_concept.hpp (original)
+++ sandbox/gtl/gtl/geometry_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -10,71 +10,18 @@
 namespace gtl {
 template <typename T>
 struct geometry_concept {
- typedef no_type type;
+ typedef typename T::geometry_type type;
 };
 
-#define GTL_REGISTER_GEOMETRY_TRAITS(coordinate_type) \
-template <>\
-struct geometry_concept<point_data<coordinate_type> > {\
- typedef point_concept type;\
-};\
-template <>\
-struct geometry_concept<rectangle_data<coordinate_type> > {\
- typedef rectangle_concept type;\
-};\
-template <>\
-struct geometry_concept<interval_data<coordinate_type> > {\
- typedef interval_concept type;\
-};\
-template <>\
-struct geometry_concept<point_3d_data<coordinate_type> > {\
- typedef point_3d_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_90_data<coordinate_type> > {\
- typedef polygon_90_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_90_with_holes_data<coordinate_type> > {\
- typedef polygon_90_with_holes_concept type;\
-};\
-template<>\
-struct geometry_concept<polygon_formation::PolyLinePolygonData<true, coordinate_type> > {\
- typedef polygon_90_with_holes_concept type;\
-};\
-template<>\
-struct geometry_concept<polygon_formation::PolyLinePolygonData<false, coordinate_type> > {\
- typedef polygon_90_with_holes_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_formation::PolyLineHoleData<true, coordinate_type> > {\
- typedef polygon_90_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_formation::PolyLineHoleData<false, coordinate_type> > {\
- typedef polygon_90_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_45_data<coordinate_type> > {\
- typedef polygon_45_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_45_with_holes_data<coordinate_type> > {\
- typedef polygon_45_with_holes_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_data<coordinate_type> > {\
- typedef polygon_concept type;\
-};\
-template <>\
-struct geometry_concept<polygon_with_holes_data<coordinate_type> > {\
- typedef polygon_with_holes_concept type;\
-};\
-
-//end of GTL_REGISTER_GEOMETRY_TRAITS macro
+template <>
+struct geometry_concept<int> {
+ typedef coordinate_concept type;
+};
 
-GTL_REGISTER_GEOMETRY_TRAITS(int)
-GTL_REGISTER_GEOMETRY_TRAITS(long long)
+template <>
+struct geometry_concept<long long> {
+ typedef coordinate_concept type;
+};
 
 }
 #endif

Modified: sandbox/gtl/gtl/gtl.hpp
==============================================================================
--- sandbox/gtl/gtl/gtl.hpp (original)
+++ sandbox/gtl/gtl/gtl.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,6 +8,7 @@
 #ifndef GTL_GTL_HPP
 #define GTL_GTL_HPP
 //external
+#include <math.h>
 #include <vector>
 #include <deque>
 #include <map>
@@ -67,23 +68,28 @@
 #include "boolean_op.hpp"
 #include "polygon_formation.hpp"
 #include "rectangle_formation.hpp"
+#include "property_merge.hpp"
 #include "iterator_vertex_orient_conversion.hpp"
 #include "iterator_geometry_to_set.hpp"
 
-//polygon set data types
-#include "polygon_set_data.hpp"
+//geometry traits
+#include "geometry_concept.hpp"
+
 //polygon set trait types
 #include "polygon_set_traits.hpp"
 //polygon set concepts
 #include "polygon_set_view.hpp"
-//geometry traits
-#include "geometry_concept.hpp"
+//polygon set data types
+#include "polygon_set_data.hpp"
 
 #include "polygon_set_wrapper.hpp"
 
 //defintions
 #include "post_geometry_traits_definitions.hpp"
 
+//general scanline
+#include "scan_arbitrary.hpp"
+
 namespace gtl {
 
 //immutable unary functions
@@ -195,7 +201,7 @@
 
 //accepts: rectangle, polygon
 template <typename geometry_type>
-typename coordinate_type<geometry_type>::type
+typename area_type<geometry_type>::type
 area(const geometry_type& geometry_object) {
   return geometry_concept<geometry_type>::type::area(geometry_object);
 }
@@ -209,7 +215,7 @@
 
 //accepts: rectangle
 template <typename geometry_type>
-typename coordinate_type<geometry_type>::type
+typename distance_type<geometry_type>::type
 perimeter(const geometry_type& geometry_object) {
   return geometry_concept<geometry_type>::type::perimeter(geometry_object);
 }
@@ -295,8 +301,8 @@
 template <typename geometry_type_1, typename geometry_type_2>
 bool contains(const geometry_type_1& geometry_object, const geometry_type_2& contained_geometry_object,
               bool consider_touch = true) {
- return typename geometry_concept<geometry_type_1>::type().contains(geometry_object, contained_geometry_object,
- consider_touch, typename geometry_concept<geometry_type_2>::type());
+ return geometry_concept<geometry_type_1>::type::contains(geometry_object, contained_geometry_object,
+ consider_touch, typename geometry_concept<geometry_type_2>::type());
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
@@ -358,7 +364,7 @@
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
-typename coordinate_type<geometry_type_1>::type distance(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+typename distance_type<geometry_type_1>::type distance(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
   return geometry_concept<geometry_type_1>::type::distance(lvalue, rvalue, typename geometry_concept<geometry_type_2>::type());
 }
 

Modified: sandbox/gtl/gtl/interval_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/interval_concept.hpp (original)
+++ sandbox/gtl/gtl/interval_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -11,13 +11,33 @@
 struct interval_concept {
   interval_concept() {}
 
- template <typename interval_type>
- struct registration {
- typedef typename interval_traits<interval_type>::coordinate_type coordinate_type;
- typedef typename interval_traits<interval_type>::coordinate_type component_type;
- typedef typename interval_traits<interval_type>::coordinate_type center_type;
+ template <typename T>
+ struct coordinate_type {
+ typedef typename interval_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct component_type {
+ typedef typename interval_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct center_type {
+ typedef typename interval_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct difference_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
   };
 
+ template <typename T>
+ struct distance_type {
+ //1D distance is difference
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ };
+
+
   template <direction_1d_enum dir, typename T>
   static inline typename interval_traits<T>::coordinate_type
   get(const T& interval) {
@@ -73,7 +93,7 @@
   template <typename interval_type>
   static bool contains(const interval_type& interval,
                        typename interval_traits<interval_type>::coordinate_type value,
- bool consider_touch, no_type tag) {
+ bool consider_touch, coordinate_concept tag) {
     if(consider_touch) {
       return value <= get<HIGH>(interval) && value >= get<LOW>(interval);
     } else {
@@ -84,8 +104,8 @@
   template <typename interval_type, typename interval_type_2>
   static bool contains(const interval_type& interval,
                        const interval_type_2& value, bool consider_touch, interval_concept tag) {
- return contains(interval, get(value, LOW), consider_touch, no_type()) &&
- contains(interval, get(value, HIGH), consider_touch, no_type());
+ return contains(interval, get(value, LOW), consider_touch, coordinate_concept()) &&
+ contains(interval, get(value, HIGH), consider_touch, coordinate_concept());
   }
 
     /// get the low coordinate
@@ -117,8 +137,10 @@
   
   /// get the magnitude of the interval
   template <typename interval_type>
- static inline typename interval_traits<interval_type>::coordinate_type
- delta(const interval_type& interval) { return high(interval) - low(interval); }
+ static inline typename difference_type<interval_type>::type
+ delta(const interval_type& interval) {
+ typedef typename difference_type<interval_type>::type diffT;
+ return (diffT)high(interval) - (diffT)low(interval); }
     
   /// flip this about coordinate
   template <typename interval_type>
@@ -146,18 +168,18 @@
   /// move interval by delta
   template <typename interval_type>
   static interval_type& move(interval_type& interval,
- typename interval_traits<interval_type>::coordinate_type delta) {
- typedef typename interval_traits<interval_type>::coordinate_type Unit;
- Unit len = high(interval) - low(interval);
- low(interval, low(interval) + delta);
- high(interval, low(interval) + len);
+ typename difference_type<interval_type>::type displacement) {
+ typedef typename difference_type<interval_type>::type Unit;
+ Unit len = delta(interval);
+ low(interval, (Unit)low(interval) + displacement);
+ high(interval, (Unit)low(interval) + len);
     return interval;
   }
   
   /// convolve this with b
   template <typename interval_type>
   static interval_type& convolve(interval_type& interval,
- typename interval_traits<interval_type>::coordinate_type b, no_type tag) {
+ typename interval_traits<interval_type>::coordinate_type b, coordinate_concept tag) {
     typedef typename interval_traits<interval_type>::coordinate_type Unit;
     Unit newLow = low(interval) + b;
     Unit newHigh = high(interval) + b;
@@ -169,7 +191,7 @@
   /// deconvolve this with b
   template <typename interval_type>
   static interval_type& deconvolve(interval_type& interval,
- typename interval_traits<interval_type>::coordinate_type b, no_type tag) {
+ typename interval_traits<interval_type>::coordinate_type b, coordinate_concept tag) {
     typedef typename interval_traits<interval_type>::coordinate_type Unit;
     Unit newLow = low(interval) - b;
     Unit newHigh = high(interval) - b;
@@ -228,22 +250,22 @@
   
   /// distance from a coordinate to an interval
   template <typename interval_type>
- static inline typename interval_traits<interval_type>::coordinate_type
+ static inline typename distance_type<interval_type>::type
   distance(const interval_type& interval,
- typename interval_traits<interval_type>::coordinate_type position, no_type tag) {
- typedef typename interval_traits<interval_type>::coordinate_type Unit;
- Unit dist[3] = {0, low(interval) - position, position - high(interval)};
+ typename interval_traits<interval_type>::coordinate_type position, coordinate_concept tag) {
+ typedef typename distance_type<interval_type>::type Unit;
+ Unit dist[3] = {0, (Unit)low(interval) - (Unit)position, (Unit)position - (Unit)high(interval)};
     return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
   }
 
 
   /// distance between two intervals
   template <typename interval_type, typename interval_type_2>
- static inline typename interval_traits<interval_type>::coordinate_type
+ static inline typename distance_type<interval_type>::type
   distance(const interval_type& interval,
            const interval_type_2& b, interval_concept tag) {
- typedef typename interval_traits<interval_type>::coordinate_type Unit;
- Unit dist[3] = {0, low(interval) - high(b), low(b) - high(interval)};
+ typedef typename distance_type<interval_type>::type Unit;
+ Unit dist[3] = {0, (Unit)low(interval) - (Unit)high(b), (Unit)low(b) - (Unit)high(interval)};
     return dist[ (dist[1] > 0) + ((dist[2] > 0) << 1) ];
   }
 
@@ -260,10 +282,10 @@
   template <typename interval_type, typename interval_type_2>
   static bool boundaries_intersect(const interval_type& interval, const interval_type_2& b,
                                    bool consider_touch, interval_concept tag) {
- return (contains(interval, low(b), consider_touch, no_type()) ||
- contains(interval, high(b), consider_touch, no_type())) &&
- (contains(b, low(interval), consider_touch, no_type()) ||
- contains(b, high(interval), consider_touch, no_type()));
+ return (contains(interval, low(b), consider_touch, coordinate_concept()) ||
+ contains(interval, high(b), consider_touch, coordinate_concept())) &&
+ (contains(b, low(interval), consider_touch, coordinate_concept()) ||
+ contains(b, high(interval), consider_touch, coordinate_concept()));
   }
 
   /// check if they are end to end

Modified: sandbox/gtl/gtl/interval_data.hpp
==============================================================================
--- sandbox/gtl/gtl/interval_data.hpp (original)
+++ sandbox/gtl/gtl/interval_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,11 @@
 #ifndef GTL_INTERVAL_DATA_HPP
 #define GTL_INTERVAL_DATA_HPP
 namespace gtl {
+struct interval_concept;
 template <typename T>
 class interval_data {
 public:
+ typedef interval_concept geometry_type;
   typedef T coordinate_type;
   inline interval_data(){}
   inline interval_data(coordinate_type low, coordinate_type high) {

Modified: sandbox/gtl/gtl/isotropy.hpp
==============================================================================
--- sandbox/gtl/gtl/isotropy.hpp (original)
+++ sandbox/gtl/gtl/isotropy.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -9,7 +9,56 @@
 #ifndef GTL_ISOTROPY_HPP
 #define GTL_ISOTROPY_HPP
 namespace gtl {
-struct no_type {};
+
+template <typename T>
+struct coordinate_traits {
+ typedef T coordinate_type;
+ typedef T area_type;
+ typedef T difference_type;
+ typedef T distance_type;
+};
+
+template <>
+struct coordinate_traits<int> {
+ typedef int coordinate_type;
+ typedef long long area_type;
+ typedef long long difference_type;
+ typedef double distance_type;
+};
+
+template <>
+struct coordinate_traits<long long> {
+ typedef long long coordinate_type;
+ typedef long long area_type;
+ typedef long long difference_type;
+ typedef double distance_type;
+};
+
+struct coordinate_concept {
+ template <typename T>
+ struct coordinate_type {
+ typedef typename coordinate_traits<T>::coordinate_type type;
+ };
+ template <typename T>
+ struct area_type {
+ typedef typename coordinate_traits<T>::area_type type;
+ };
+ template <typename T>
+ struct difference_type {
+ typedef typename coordinate_traits<T>::difference_type type;
+ };
+ template <typename T>
+ struct distance_type {
+ typedef typename coordinate_traits<T>::distance_type type;
+ };
+
+ template <typename coordinate_type_1, typename coordinate_type_2>
+ static typename difference_type<coordinate_type_1>::type
+ distance(const coordinate_type_1& lvalue, const coordinate_type_2& rvalue) {
+ typedef typename difference_type<coordinate_type_1>::type Unit;
+ return (lvalue < rvalue) ? (Unit)rvalue - (Unit)lvalue : (Unit)lvalue - (Unit)rvalue;
+ }
+};
 
 enum direction_1d_enum { LOW = 0, HIGH = 1,
                          LEFT = 0, RIGHT = 1,

Modified: sandbox/gtl/gtl/iterator_geometry_to_set.hpp
==============================================================================
--- sandbox/gtl/gtl/iterator_geometry_to_set.hpp (original)
+++ sandbox/gtl/gtl/iterator_geometry_to_set.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -13,6 +13,7 @@
 
 template <typename concept_type, typename iterator_type>
 class iterator_geometry_range_to_set {
+public:
   typedef typename std::iterator_traits<iterator_type>::value_type geometry_type;
   typedef iterator_geometry_to_set<concept_type, geometry_type> internal_iterator_type;
   typedef typename internal_iterator_type::value_type value_type;
@@ -26,6 +27,7 @@
   mutable bool dereferenced_;
   orientation_2d orient_;
 public:
+ iterator_geometry_range_to_set() {}
   iterator_geometry_range_to_set(iterator_type itr,
                            orientation_2d orient = HORIZONTAL) :
     itr_(itr), dereferenced_(false), orient_(orient) {}

Modified: sandbox/gtl/gtl/iterator_vertex_orient_conversion.hpp
==============================================================================
--- sandbox/gtl/gtl/iterator_vertex_orient_conversion.hpp (original)
+++ sandbox/gtl/gtl/iterator_vertex_orient_conversion.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -12,7 +12,7 @@
 class iterator_vertex_orient_conversion {
 private:
   iterator_type iter_;
- typename std::iterator_traits<iterator_type>::value_type vertex_;
+ mutable typename std::iterator_traits<iterator_type>::value_type vertex_;
 public:
   typedef std::forward_iterator_tag iterator_category;
   typedef typename std::iterator_traits<iterator_type>::value_type value_type;

Modified: sandbox/gtl/gtl/point_3d_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/point_3d_concept.hpp (original)
+++ sandbox/gtl/gtl/point_3d_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -11,11 +11,6 @@
 struct point_3d_concept : point_concept {
   point_3d_concept() {}
 
- template <typename point_3d_type>
- struct registration {
- typedef typename point_3d_traits<point_3d_type>::coordinate_type component_type;
- };
-
   template <orientation_3d_enum orient, typename T>
   static inline typename point_3d_traits<T>::coordinate_type get(const T& point) {
     return point_3d_traits<T>::get(point, orient); }

Modified: sandbox/gtl/gtl/point_3d_data.hpp
==============================================================================
--- sandbox/gtl/gtl/point_3d_data.hpp (original)
+++ sandbox/gtl/gtl/point_3d_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,11 @@
 #ifndef GTL_POINT_3D_DATA_HPP
 #define GTL_POINT_3D_DATA_HPP
 namespace gtl {
+struct point_3d_concept;
 template <typename T>
 class point_3d_data {
 public:
+ typedef point_3d_concept geometry_type;
   typedef T coordinate_type;
   inline point_3d_data(){}
   inline point_3d_data(coordinate_type x, coordinate_type y) {

Modified: sandbox/gtl/gtl/point_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/point_concept.hpp (original)
+++ sandbox/gtl/gtl/point_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -11,13 +11,33 @@
 struct point_concept {
   point_concept() {}
 
- template <typename point_type>
- struct registration {
- typedef typename point_traits<point_type>::coordinate_type component_type;
- typedef typename point_traits<point_type>::coordinate_type coordinate_type;
+ template <typename T>
+ struct coordinate_type {
+ typedef typename point_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct component_type {
+ typedef typename point_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct area_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::area_type type;
+ };
+
+ template <typename T>
+ struct difference_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
   };
 
   template <typename T>
+ struct distance_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
+ };
+
+
+ template <typename T>
   static inline typename point_traits<T>::coordinate_type get(const T& point, orientation_2d orient) {
     return point_traits<T>::get(point, orient);
   }
@@ -81,19 +101,35 @@
   }
 
   template <typename point_type_1, typename point_type_2>
- static typename point_traits<point_type_1>::coordinate_type
+ static typename difference_type<point_type_1>::type
   manhattan_distance(const point_type_1& point1, const point_type_2& point2) {
     return distance(point1, point2, HORIZONTAL) + distance(point1, point2, VERTICAL);
   }
 
   template <typename point_type_1, typename point_type_2>
- static typename point_traits<point_type_1>::coordinate_type
+ static typename difference_type<point_type_1>::type
   distance(const point_type_1& point1, const point_type_2& point2, orientation_2d orient) {
     typename point_traits<point_type_1>::coordinate_type return_value =
       get(point1, orient) - get(point2, orient);
     return return_value < 0 ? -return_value : return_value;
   }
 
+ template <typename point_type_1, typename point_type_2>
+ static typename distance_type<point_type_1>::type
+ distance(const point_type_1& point1, const point_type_2& point2) {
+ return sqrt((typename distance_type<point_type_1>::type)(distance_squared(point1, point2)));
+ }
+
+ template <typename point_type_1, typename point_type_2>
+ static typename difference_type<point_type_1>::type
+ distance_squared(const point_type_1& point1, const point_type_2& point2) {
+ typename difference_type<point_type_1>::type dx = distance(point1, point2, HORIZONTAL);
+ typename difference_type<point_type_1>::type dy = distance(point1, point2, VERTICAL);
+ dx *= dx;
+ dy *= dy;
+ return dx + dy;
+ }
+
 };
 
 }

Modified: sandbox/gtl/gtl/point_data.hpp
==============================================================================
--- sandbox/gtl/gtl/point_data.hpp (original)
+++ sandbox/gtl/gtl/point_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,13 @@
 #ifndef GTLPOINT_DATA_HPP
 #define GTLPOINT_DATA_HPP
 namespace gtl {
+
+struct point_concept;
+
 template <typename T>
 class point_data {
 public:
+ typedef point_concept geometry_type;
   typedef T coordinate_type;
   inline point_data(){}
   inline point_data(coordinate_type x, coordinate_type y) {
@@ -28,6 +32,10 @@
   inline bool operator!=(const point_data& that) const {
     return !((*this) == that);
   }
+ inline bool operator<(const point_data& that) const {
+ return coords_[0] < that.coords_[0] ||
+ (coords_[0] == that.coords_[0] && coords_[1] < that.coords_[1]);
+ }
   inline coordinate_type get(orientation_2d orient) const {
     return coords_[orient.to_int()];
   }

Modified: sandbox/gtl/gtl/polygon_45_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -9,44 +9,49 @@
 #define GTL_POLYGON_45_CONCEPT_HPP
 namespace gtl {
 
-template <typename iterator_type>
-typename point_traits<typename std::iterator_traits<iterator_type>::value_type>::coordinate_type
-polygon_point_sequence_area(iterator_type begin_range, iterator_type end_range) {
- typedef typename std::iterator_traits<iterator_type>::value_type point_type;
- typedef typename point_traits<point_type>::coordinate_type Unit;
- if(begin_range == end_range) return Unit(0);
- point_type first = *begin_range;
- ++begin_range;
- if(begin_range == end_range) return Unit(0); //throw bad polygon?
- point_type previous = *begin_range;
- ++begin_range;
- // Initialize trapezoid base line
- Unit y_base = point_concept::y(first);
- // Initialize area accumulator
-
- Unit area(0);
- while (begin_range != end_range) {
- Unit x1 = point_concept::x(previous);
- Unit x2 = point_concept::x(*begin_range);
- if(x1 != x2) {
- // do trapezoid area accumulation
- area += (x2 - x1) * ((point_concept::y(*begin_range) - y_base) +
- (point_concept::y(previous) - y_base)) / 2;
- }
- previous = *begin_range;
- // go to next point
- ++begin_range;
- }
- Unit x1 = point_concept::x(previous);
- Unit x2 = point_concept::x(first);
- area += (x2 - x1) * ((point_concept::y(first) - y_base) +
- (point_concept::y(previous) - y_base)) / 2;
- return area;
-}
 
 struct polygon_45_concept : polygon_90_concept {
   inline polygon_45_concept() {}
 
+ template <typename iterator_type>
+ typename coordinate_traits<
+ typename point_traits<
+ typename std::iterator_traits<iterator_type>::value_type>::coordinate_type>::area_type
+ static point_sequence_area(iterator_type begin_range, iterator_type end_range) {
+ typedef typename std::iterator_traits<iterator_type>::value_type point_type;
+ typedef typename point_traits<point_type>::coordinate_type Unit;
+ typedef typename coordinate_traits<Unit>::area_type area_type;
+ if(begin_range == end_range) return area_type(0);
+ point_type first = *begin_range;
+ point_type previous = first;
+ ++begin_range;
+ // Initialize trapezoid base line
+ area_type y_base = (area_type)point_concept::y(first);
+ // Initialize area accumulator
+
+ area_type area(0);
+ while (begin_range != end_range) {
+ area_type x1 = (area_type)point_concept::x(previous);
+ area_type x2 = (area_type)point_concept::x(*begin_range);
+ if(x1 != x2) {
+ // do trapezoid area accumulation
+ area += (x2 - x1) * (((area_type)point_concept::y(*begin_range) - y_base) +
+ ((area_type)point_concept::y(previous) - y_base)) / 2;
+ }
+ previous = *begin_range;
+ // go to next point
+ ++begin_range;
+ }
+ //wrap around to evaluate the edge between first and last if not closed
+ if(first != previous) {
+ area_type x1 = (area_type)point_concept::x(previous);
+ area_type x2 = (area_type)point_concept::x(first);
+ area += (x2 - x1) * (((area_type)point_concept::y(first) - y_base) +
+ ((area_type)point_concept::y(previous) - y_base)) / 2;
+ }
+ return area;
+ }
+
   template <typename polygon_type_1, typename polygon_type_2>
   static polygon_type_1& assign(polygon_type_1& lvalue, const polygon_type_2& rvalue) {
     set(lvalue, begin(rvalue), end(rvalue));
@@ -60,7 +65,7 @@
     if(wd != unknown_winding) {
       return wd == clockwise_winding ? CLOCKWISE: COUNTERCLOCKWISE;
     }
- return polygon_point_sequence_area(begin(polygon), end(polygon)) < 0 ? COUNTERCLOCKWISE : CLOCKWISE;
+ return point_sequence_area(begin(polygon), end(polygon)) < 0 ? COUNTERCLOCKWISE : CLOCKWISE;
   }
 
   template <typename polygon_type>
@@ -93,29 +98,29 @@
   }
 
   template <typename polygon_type>
- static typename registration<polygon_type>::center_type
+ static typename center_type<polygon_type>::type
   center(const polygon_type& polygon) {
     return rectangle_concept::center(bounding_box(polygon));
   }
 
   template <typename polygon_type>
- static typename polygon_traits<polygon_type>::coordinate_type
+ static typename coordinate_traits<typename polygon_traits<polygon_type>::coordinate_type>::area_type
   area(const polygon_type& polygon) {
     //rewrite for non-manhattan
     typename polygon_traits<polygon_type>::coordinate_type result =
- polygon_point_sequence_area(begin(polygon), end(polygon));
+ point_sequence_area(begin(polygon), end(polygon));
     if(result < 0) result *= -1;
     return result;
   }
 
   /// get the perimeter of the polygon
   template <typename polygon_type>
- static typename polygon_traits<polygon_type>::coordinate_type
+ static typename distance_type<polygon_type>::type
   perimeter(const polygon_type& polygon) {
     typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
     typedef typename polygon_traits<polygon_type>::iterator_type iterator;
     typedef typename std::iterator_traits<iterator>::value_type point_type;
- coordinate_type return_value = 0;
+ typename distance_type<polygon_type>::type return_value = 0;
     point_type previous_point, first_point;
     iterator itr = begin(polygon);
     iterator itr_end = end(polygon);

Modified: sandbox/gtl/gtl/polygon_45_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,11 @@
 #ifndef GTL_POLYGON_45_DATA_HPP
 #define GTL_POLYGON_45_DATA_HPP
 namespace gtl {
+struct polygon_45_concept;
 template <typename T>
 class polygon_45_data {
 public:
+ typedef polygon_45_concept geometry_type;
   typedef T coordinate_type;
   typedef typename std::vector<point_data<coordinate_type> >::const_iterator iterator_type;
   typedef iterator_points_to_compact<iterator_type, point_data<coordinate_type> > compact_iterator_type;

Modified: sandbox/gtl/gtl/polygon_45_with_holes_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_with_holes_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_with_holes_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -9,10 +9,35 @@
 #define GTL_POLYGON_45_WITH_HOLES_CONCEPT_HPP
 namespace gtl {
 
-struct polygon_45_with_holes_concept : virtual polygon_45_concept, polygon_90_with_holes_concept {
+struct polygon_45_with_holes_concept : virtual polygon_45_concept, virtual polygon_90_with_holes_concept {
 public:
   inline polygon_45_with_holes_concept() {}
 
+ template <typename T>
+ struct coordinate_type {
+ typedef typename polygon_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct center_type {
+ typedef point_data<typename coordinate_type<T>::type> type;
+ };
+
+ template <typename T>
+ struct area_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::area_type type;
+ };
+
+ template <typename T>
+ struct difference_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ };
+
+ template <typename T>
+ struct distance_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
+ };
+
   template <typename polygon_with_holes_type_1, typename polygon_with_holes_type_2>
   static polygon_with_holes_type_1& assign(polygon_with_holes_type_1& lvalue, const polygon_with_holes_type_2& rvalue) {
     polygon_45_concept::assign(lvalue, rvalue);
@@ -21,14 +46,16 @@
   }
 
   template <typename polygon_with_holes_type>
- static typename polygon_with_holes_traits<polygon_with_holes_type>::coordinate_type
+ static typename area_type<polygon_with_holes_type>::type
   area(const polygon_with_holes_type& polygon) {
- typename polygon_traits<polygon_with_holes_type>::coordinate_type retval = polygon_45_concept::area(polygon);
+ typedef typename polygon_traits<polygon_with_holes_type>::coordinate_type coordinate_type;
+ typename coordinate_traits<coordinate_type>::area_type retval = polygon_45_concept::area(polygon);
     typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type b, e;
     e = end_holes(polygon);
     for(b = begin_holes(polygon); b != e; ++b) {
       retval -= polygon_45_concept::area(*b);
     }
+ return retval;
   }
 
   /// check if point is inside polygon
@@ -47,14 +74,15 @@
 
   /// get the perimeter of the polygon
   template <typename polygon_with_holes_type>
- static typename polygon_traits<polygon_with_holes_type>::coordinate_type
+ static typename distance_type<polygon_with_holes_type>::type
   perimeter(const polygon_with_holes_type& polygon) {
- typename polygon_traits<polygon_with_holes_type>::coordinate_type retval = polygon_45_concept::perimeter(polygon);
+ typename distance_type<polygon_with_holes_type>::type retval = polygon_45_concept::perimeter(polygon);
     typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type b, e;
     e = end_holes(polygon);
     for(b = begin_holes(polygon); b != e; ++b) {
       retval -= polygon_45_concept::perimeter(*b);
     }
+ return retval;
   }
 
   template <typename polygon_with_holes_type, typename coordinate_type_1, typename coordinate_type_2>
@@ -85,6 +113,24 @@
     }
     return polygon;
   }
+
+ template <typename polygon_type>
+ static direction_1d winding(const polygon_type& polygon) {
+ return polygon_45_concept::winding(polygon);
+ }
+
+ template <typename polygon_type>
+ static typename center_type<polygon_type>::type
+ center(const polygon_type& polygon) {
+ return polygon_45_concept::center(polygon);
+ }
+
+ template <typename polygon_type>
+ static rectangle_data<typename polygon_traits<polygon_type>::coordinate_type>
+ bounding_box(const polygon_type& polygon) {
+ return polygon_45_concept::bounding_box(polygon);
+ }
+
 };
 
 }

Modified: sandbox/gtl/gtl/polygon_45_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_45_with_holes_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_45_with_holes_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,10 +8,11 @@
 #ifndef GTL_POLYGON_45_WITH_HOLES_DATA_HPP
 #define GTL_POLYGON_45_WITH_HOLES_DATA_HPP
 namespace gtl {
-
+struct polygon_45_with_holes_concept;
 template <typename T>
 class polygon_45_with_holes_data {
 public:
+ typedef polygon_45_with_holes_concept geometry_type;
   typedef T coordinate_type;
   typedef typename polygon_45_data<T>::iterator_type iterator_type;
   typedef typename polygon_45_data<T>::compact_iterator_type compact_iterator_type;

Modified: sandbox/gtl/gtl/polygon_90_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -9,14 +9,31 @@
 #define GTL_POLYGON_90_CONCEPT_HPP
 namespace gtl {
 struct polygon_90_concept {
- inline polygon_90_concept() {}
 
- template <typename polygon_type>
- struct registration {
- typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
- typedef point_data<coordinate_type> center_type;
+ template <typename T>
+ struct coordinate_type {
+ typedef typename polygon_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct center_type {
+ typedef point_data<typename coordinate_type<T>::type> type;
+ };
+
+ template <typename T>
+ struct area_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::area_type type;
   };
 
+ template <typename T>
+ struct difference_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ };
+
+ template <typename T>
+ struct distance_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
+ };
 
   template<typename polygon_type, typename compact_iterator_type>
   static void set_compact(polygon_type& polygon, compact_iterator_type input_begin, compact_iterator_type input_end) {
@@ -154,18 +171,19 @@
   }
 
   template <typename polygon_type>
- static typename registration<polygon_type>::center_type
+ static typename center_type<polygon_type>::type
   center(const polygon_type& polygon) {
     return rectangle_concept::center(bounding_box(polygon));
   }
 
   template <typename polygon_type>
- static typename polygon_traits<polygon_type>::coordinate_type
+ static typename area_type<polygon_type>::type
   area(const polygon_type& polygon) {
     //for (long i = 2; i < _size; i += 2) res += ((double)_vertex[i-1])*((double)(_vertex[i-2] - _vertex[i]));
     typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
+ typedef typename coordinate_traits<coordinate_type>::area_type area_type;
     typedef typename polygon_traits<polygon_type>::compact_iterator_type iterator;
- coordinate_type retval = 0;
+ area_type retval = 0;
     iterator itr = begin_compact(polygon);
     iterator end_itr = end_compact(polygon);
     coordinate_type firstx = *itr;
@@ -179,22 +197,21 @@
       ++itr;
       if(itr == end_itr) break;
       coordinate_type y = *itr;
- retval += (prevy * (prevx - x));
+ retval += ((area_type)prevy * ((area_type)prevx - (area_type)x));
       prevy = y;
       prevx = x;
     }
- retval += (prevy * (prevx - firstx));
+ retval += ((area_type)prevy * ((area_type)prevx - (area_type)firstx));
     return retval >= 0 ? retval : -retval;
   }
 
   /// get the perimeter of the polygon
   template <typename polygon_type>
- static typename polygon_traits<polygon_type>::coordinate_type
+ static typename difference_type<polygon_type>::type
   perimeter(const polygon_type& polygon) {
- typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
     typedef typename polygon_traits<polygon_type>::iterator_type iterator;
     typedef typename std::iterator_traits<iterator>::value_type point_type;
- coordinate_type return_value = 0;
+ typename difference_type<polygon_type>::type return_value = 0;
     point_type previous_point, first_point;
     iterator itr = begin(polygon);
     iterator itr_end = end(polygon);
@@ -237,7 +254,7 @@
         interval_data<coordinate_type> ivl =
           interval_concept::construct<interval_data<coordinate_type> >(point_concept::get<VERTICAL>(current_pt),
                                                                        point_concept::get<VERTICAL>(prev_pt));
- if(interval_concept::contains(ivl, point_concept::get<VERTICAL>(point), true, no_type())) {
+ if(interval_concept::contains(ivl, point_concept::get<VERTICAL>(point), true, coordinate_concept())) {
           if(point_concept::get<HORIZONTAL>(current_pt) ==
              point_concept::get<HORIZONTAL>(point)) return consider_touch;
           ++increment;

Modified: sandbox/gtl/gtl/polygon_90_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,11 @@
 #ifndef GTL_POLYGON_90_DATA_HPP
 #define GTL_POLYGON_90_DATA_HPP
 namespace gtl {
+struct polygon_90_concept;
 template <typename T>
 class polygon_90_data {
 public:
+ typedef polygon_90_concept geometry_type;
   typedef T coordinate_type;
   typedef typename std::vector<coordinate_type>::const_iterator compact_iterator_type;
   typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;

Modified: sandbox/gtl/gtl/polygon_90_with_holes_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_with_holes_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_with_holes_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -52,14 +52,15 @@
   }
 
   template <typename polygon_with_holes_type>
- static typename polygon_with_holes_traits<polygon_with_holes_type>::coordinate_type
+ static typename area_type<polygon_with_holes_type>::type
   area(const polygon_with_holes_type& polygon) {
- typename polygon_traits<polygon_with_holes_type>::coordinate_type retval = polygon_90_concept::area(polygon);
+ typename area_type<polygon_with_holes_type>::type retval = polygon_90_concept::area(polygon);
     typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type b, e;
     e = end_holes(polygon);
     for(b = begin_holes(polygon); b != e; ++b) {
       retval -= polygon_90_concept::area(*b);
     }
+ return retval;
   }
 
   /// check if point is inside polygon
@@ -78,14 +79,15 @@
 
   /// get the perimeter of the polygon
   template <typename polygon_with_holes_type>
- static typename polygon_traits<polygon_with_holes_type>::coordinate_type
+ static typename difference_type<polygon_with_holes_type>::type
   perimeter(const polygon_with_holes_type& polygon) {
- typename polygon_traits<polygon_with_holes_type>::coordinate_type retval = polygon_90_concept::perimeter(polygon);
+ typename difference_type<polygon_with_holes_type>::type retval = polygon_90_concept::perimeter(polygon);
     typename polygon_with_holes_traits<polygon_with_holes_type>::iterator_holes_type b, e;
     e = end_holes(polygon);
     for(b = begin_holes(polygon); b != e; ++b) {
       retval -= polygon_90_concept::perimeter(*b);
     }
+ return retval;
   }
 
   // //awaiting re-implementation of iterator_edges and edge concept

Modified: sandbox/gtl/gtl/polygon_90_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_90_with_holes_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_90_with_holes_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,10 +8,11 @@
 #ifndef GTL_POLYGON_90_WITH_HOLES_DATA_HPP
 #define GTL_POLYGON_90_WITH_HOLES_DATA_HPP
 namespace gtl {
-
+struct polygon_90_with_holes_concept;
 template <typename T>
 class polygon_90_with_holes_data {
 public:
+ typedef polygon_90_with_holes_concept geometry_type;
   typedef T coordinate_type;
   typedef typename polygon_90_data<T>::iterator_type iterator_type;
   typedef typename polygon_90_data<T>::compact_iterator_type compact_iterator_type;

Modified: sandbox/gtl/gtl/polygon_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,11 @@
 #ifndef GTL_POLYGON_DATA_HPP
 #define GTL_POLYGON_DATA_HPP
 namespace gtl {
+struct polygon_concept;
 template <typename T>
 class polygon_data : public polygon_45_data<T> {
- //inherits everything
+public:
+ typedef polygon_concept geometry_type;
 };
 }
 #endif

Modified: sandbox/gtl/gtl/polygon_formation.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_formation.hpp (original)
+++ sandbox/gtl/gtl/polygon_formation.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -556,12 +556,14 @@
   template <typename Unit>
   void destroyActiveTail(ActiveTail<Unit>* aTail);
      
+ struct polygon_90_concept;
 
   template<bool orientT, typename Unit>
   class PolyLineHoleData {
   private:
     ActiveTail<Unit>* p_;
   public:
+ typedef polygon_90_concept geometry_type;
     typedef Unit coordinate_type;
     typedef typename ActiveTail<Unit>::iterator compact_iterator_type;
     typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;
@@ -584,11 +586,14 @@
    
   };
 
+ struct polygon_90_with_holes_concept;
+
   template<bool orientT, typename Unit>
   class PolyLinePolygonData {
   private:
     ActiveTail<Unit>* p_;
   public:
+ typedef polygon_90_with_holes_concept geometry_type;
     typedef Unit coordinate_type;
     typedef typename ActiveTail<Unit>::iterator compact_iterator_type;
     typedef iterator_compact_to_points<compact_iterator_type, point_data<coordinate_type> > iterator_type;

Modified: sandbox/gtl/gtl/polygon_set_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_set_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_set_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,132 +8,316 @@
 #ifndef GTL_POLYGON_SET_DATA_HPP
 #define GTL_POLYGON_SET_DATA_HPP
 namespace gtl {
-struct operator_provides_storage {};
-struct operator_requires_copy {};
+ template <typename T>
+ class polygon_set_data {
+ public:
+ typedef T coordinate_type;
+ typedef std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > > value_type;
+ typedef typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::const_iterator iterator_type;
+ typedef polygon_set_data operator_arg_type;
+ typedef operator_provides_storage operator_storage_tag;
+
+ /// default constructor
+ inline polygon_set_data() : orient_(HORIZONTAL), dirty_(false), unsorted_(false) {}
+
+ /// constructor
+ inline polygon_set_data(orientation_2d orient) : orient_(orient), dirty_(false), unsorted_(false) {}
+
+ /// constructor from an iterator pair over vertex data
+ template <typename iT>
+ inline polygon_set_data(orientation_2d orient, iT input_begin, iT input_end) {
+ dirty_ = true;
+ unsorted_ = true;
+ for( ; input_begin != input_end; ++input_begin) { insert(*input_begin); }
+ }
 
-template <typename T>
-class polygon_set_data {
-public:
- typedef T coordinate_type;
- typedef std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > > value_type;
- typedef typename std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >::const_iterator iterator_type;
- typedef polygon_set_data operator_arg_type;
- typedef operator_provides_storage operator_storage_tag;
-
- /// default constructor
- inline polygon_set_data() : orient_(HORIZONTAL), dirty_(false), unsorted_(false) {}
-
- /// constructor
- inline polygon_set_data(orientation_2d orient) : orient_(orient), dirty_(false), unsorted_(false) {}
-
- /// constructor from an iterator pair over vertex data
- template <class iT>
- inline polygon_set_data(orientation_2d orient, iT input_begin, iT input_end) {
- dirty_ = true;
- unsorted_ = true;
- for( ; input_begin != input_end; ++input_begin) { data_.push_back(*input_begin); }
- }
-
- /// copy constructor
- inline polygon_set_data(const polygon_set_data& that) :
- orient_(that.orient_), data_(that.data_), dirty_(that.dirty), unsorted_(that.unsorted_) {}
-
- /// copy with orientation change constructor
- inline polygon_set_data(orientation_2d orient, const polygon_set_data& that) :
- orient_(orient), dirty_(false), unsorted_(false) {
- if(that.orient() == orient) { (*this) = that; }
- else if(!that.data_.empty()) {
- dirty_ = unsorted_ = true;
- iterator_vertex_orient_conversion<iterator_type> itr1(that.data_.begin()), iter2(that.data_.end());
- data_.resize(that.data_.size());
- for( ; itr1 != iter2; ++itr1) {
- data_.push_back(*itr1);
- }
- }
- }
-
- /// destructor
- inline ~polygon_set_data() {}
-
- /// assignement operator
- inline polygon_set_data& operator=(const polygon_set_data& that) {
- if(this == &that) return *this;
- orient_ = that.orient_;
- data_ = that.data_;
- dirty_ = that.dirty_;
- unsorted_ = that.unsorted_;
- return *this;
- }
-
- /// equivalence operator
- inline bool operator==(const polygon_set_data& p) const {
- if(orient_ == p.orient()) {
- clean();
- p.clean();
- return data_ == p.data_;
- } else {
- return false;
- }
- }
-
- /// inequivalence operator
- inline bool operator!=(const polygon_set_data& p) const {
- return !((*this) == p);
- }
-
- /// get iterator to begin vertex data
- inline iterator_type begin() const {
- return data_.begin();
- }
-
- /// get iterator to end vertex data
- inline iterator_type end() const {
- return data_.end();
- }
-
- const value_type& value() const {
- return data_;
- }
-
- /// clear the contents of the polygon_set_data
- inline void clear() { data_.clear(); dirty_ = unsorted_ = false; }
-
- /// find out if Polygon set is empty
- inline bool empty() const { return data_.empty(); }
-
- /// find out if Polygon set is sorted
- inline bool sorted() const { return !unsorted_; }
-
- /// find out if Polygon set is clean
- inline bool dirty() const { return dirty_; }
-
- /// get the scanline orientation of the polygon set
- inline orientation_2d orient() const { return orient_; }
-
- void clean() const {
- if(unsorted_) sort();
- if(dirty_) {
- applyBooleanOr(data_);
+ /// copy constructor
+ inline polygon_set_data(const polygon_set_data& that) :
+ orient_(that.orient_), data_(that.data_), dirty_(that.dirty_), unsorted_(that.unsorted_) {}
+
+ /// copy with orientation change constructor
+ inline polygon_set_data(orientation_2d orient, const polygon_set_data& that) :
+ orient_(orient), dirty_(false), unsorted_(false) {
+ if(that.orient() == orient) { (*this) = that; }
+ else if(!that.data_.empty()) {
+ dirty_ = unsorted_ = true;
+ iterator_vertex_orient_conversion<iterator_type> itr1(that.data_.begin()), iter2(that.data_.end());
+ data_.resize(that.data_.size());
+ for( ; itr1 != iter2; ++itr1) {
+ data_.push_back(*itr1);
+ }
+ }
+ }
+
+ /// destructor
+ inline ~polygon_set_data() {}
+
+ /// assignement operator
+ inline polygon_set_data& operator=(const polygon_set_data& that) {
+ if(this == &that) return *this;
+ orient_ = that.orient_;
+ data_ = that.data_;
+ dirty_ = that.dirty_;
+ unsorted_ = that.unsorted_;
+ return *this;
+ }
+
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ inline polygon_set_data& operator=(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& that) {
+ orient_ = that.orient();
+ data_ = that.value();
       dirty_ = false;
+ unsorted_ = false;
+ return *this;
+ }
+
+ /// insert iterator range
+ template <typename iT>
+ inline void insert(iT input_begin, iT input_end) {
+ for( ; input_begin != input_end; ++input_begin) {
+ insert(*input_begin);
+ }
+ }
+
+ template <typename geometry_type>
+ inline void insert(const geometry_type& geometry_object) {
+ iterator_geometry_to_set<typename geometry_concept<geometry_type>::type, geometry_type>
+ begin_input(geometry_object, LOW, orient_), end_input(geometry_object, HIGH, orient_);
+ insert(begin_input, end_input);
+ }
+
+ inline void insert(const std::pair<coordinate_type, std::pair<coordinate_type, int> >& vertex) {
+ data_.push_back(vertex);
+ dirty_ = true;
+ unsorted_ = true;
+ }
+
+ inline void insert(coordinate_type major_coordinate, const std::pair<interval_data<coordinate_type>, int>& edge) {
+ std::pair<coordinate_type, std::pair<coordinate_type, int> > vertex;
+ vertex.first = major_coordinate;
+ vertex.second.first = edge.first.get(LOW);
+ vertex.second.second = edge.second;
+ insert(vertex);
+ vertex.second.first = edge.first.get(HIGH);
+ vertex.second.second *= -1;
+ insert(vertex);
+ }
+
+ template <typename output_container>
+ inline void get(output_container& output) {
+ get_dispatch(output, typename geometry_concept<typename output_container::value_type>::type());
+ }
+
+ /// equivalence operator
+ inline bool operator==(const polygon_set_data& p) const {
+ if(orient_ == p.orient()) {
+ clean();
+ p.clean();
+ return data_ == p.data_;
+ } else {
+ return false;
+ }
+ }
+
+ /// inequivalence operator
+ inline bool operator!=(const polygon_set_data& p) const {
+ return !((*this) == p);
+ }
+
+ /// get iterator to begin vertex data
+ inline iterator_type begin() const {
+ return data_.begin();
+ }
+
+ /// get iterator to end vertex data
+ inline iterator_type end() const {
+ return data_.end();
     }
- }
 
- void sort() const{
- std::sort(data_.begin(), data_.end());
- unsorted_ = false;
- }
-
- void set(const value_type& value, orientation_2d orient) {
- data_ = value;
- orient_ = orient;
- }
-private:
- orientation_2d orient_;
- mutable value_type data_;
- mutable bool dirty_;
- mutable bool unsorted_;
+ const value_type& value() const {
+ return data_;
+ }
+
+ /// clear the contents of the polygon_set_data
+ inline void clear() { data_.clear(); dirty_ = unsorted_ = false; }
+
+ /// find out if Polygon set is empty
+ inline bool empty() const { return data_.empty(); }
+
+ /// find out if Polygon set is sorted
+ inline bool sorted() const { return !unsorted_; }
 
-};
+ /// find out if Polygon set is clean
+ inline bool dirty() const { return dirty_; }
+
+ /// get the scanline orientation of the polygon set
+ inline orientation_2d orient() const { return orient_; }
+
+ void clean() const {
+ if(unsorted_) sort();
+ if(dirty_) {
+ boolean_op::applyBooleanOr(data_);
+ dirty_ = false;
+ }
+ }
+
+ void sort() const{
+ std::sort(data_.begin(), data_.end());
+ unsorted_ = false;
+ }
+
+ void set(const value_type& value, orientation_2d orient) {
+ data_ = value;
+ orient_ = orient;
+ }
+ private:
+ orientation_2d orient_;
+ mutable value_type data_;
+ mutable bool dirty_;
+ mutable bool unsorted_;
+
+ private:
+ //functions
+ template <typename output_container>
+ void get_dispatch(output_container& output, rectangle_concept tag) {
+ typedef typename output_container::value_type rectangle_type;
+ typedef typename rectangle_concept::coordinate_type<rectangle_type>::type Unit;
+ clean();
+ rectangle_data<Unit> model;
+ Unit prevPos = std::numeric_limits<Unit>::max();
+ rectangle_formation::ScanLineToRects<rectangle_type> scanlineToRects(orient_, model);
+ for(iterator_type itr = data_.begin();
+ itr != data_.end(); ++ itr) {
+ Unit pos = (*itr).first;
+ if(pos != prevPos) {
+ scanlineToRects.nextMajorCoordinate(pos);
+ prevPos = pos;
+ }
+ Unit lowy = (*itr).second.first;
+ ++itr;
+ Unit highy = (*itr).second.first;
+ scanlineToRects.processEdge(output, interval_data<Unit>(lowy, highy));
+ if(abs((*itr).second.second) > 1) --itr; //next edge begins from this vertex
+ }
+ }
+ template <typename output_container>
+ void get_dispatch(output_container& output, polygon_90_concept tag) {
+ get_fracture(output, true, tag);
+ }
+ template <typename output_container>
+ void get_dispatch(output_container& output, polygon_90_with_holes_concept tag) {
+ get_fracture(output, false, tag);
+ }
+ template <typename output_container, typename concept_type>
+ void get_fracture(output_container& container, bool fracture_holes, concept_type tag) {
+ typedef typename output_container::value_type polygon_type;
+ polygon_type poly;
+ clean();
+ unsigned int countPolygons = 0;
+ polygon_formation::ScanLineToPolygonItrs<true, coordinate_type> scanlineToPolygonItrsV(fracture_holes);
+ polygon_formation::ScanLineToPolygonItrs<false, coordinate_type> scanlineToPolygonItrsH(fracture_holes);
+ std::vector<interval_data<coordinate_type> > leftEdges;
+ std::vector<interval_data<coordinate_type> > rightEdges;
+ coordinate_type prevPos = std::numeric_limits<coordinate_type>::max();
+ coordinate_type prevY = std::numeric_limits<coordinate_type>::max();
+ int count = 0;
+ for(iterator_type itr = data_.begin();
+ itr != data_.end(); ++ itr) {
+ coordinate_type pos = (*itr).first;
+ if(pos != prevPos) {
+ if(orient_ == VERTICAL) {
+ typename polygon_formation::ScanLineToPolygonItrs<true, coordinate_type>::iterator itrPoly, itrPolyEnd;
+ scanlineToPolygonItrsV.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+ for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+ ++countPolygons;
+ concept_type::assign(poly, *itrPoly);
+ container.insert(container.end(), poly);
+ }
+ } else {
+ typename polygon_formation::ScanLineToPolygonItrs<false, coordinate_type>::iterator itrPoly, itrPolyEnd;
+ scanlineToPolygonItrsH.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+ for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+ ++countPolygons;
+ concept_type::assign(poly, *itrPoly);
+ container.insert(container.end(), poly);
+ }
+ }
+ leftEdges.clear();
+ rightEdges.clear();
+ prevPos = pos;
+ prevY = (*itr).second.first;
+ count = (*itr).second.second;
+ continue;
+ }
+ coordinate_type y = (*itr).second.first;
+ if(count != 0 && y != prevY) {
+ std::pair<interval_data<coordinate_type>, int> element(interval_data<coordinate_type>(prevY, y), count);
+ if(element.second == 1) {
+ if(leftEdges.size() && leftEdges.back().high() == element.first.low()) {
+ interval_concept::encompass(leftEdges.back(), element.first, interval_concept());
+ } else {
+ leftEdges.push_back(element.first);
+ }
+ } else {
+ if(rightEdges.size() && rightEdges.back().high() == element.first.low()) {
+ interval_concept::encompass(rightEdges.back(), element.first, interval_concept());
+ } else {
+ rightEdges.push_back(element.first);
+ }
+ }
+
+ }
+ prevY = y;
+ count += (*itr).second.second;
+ }
+ if(orient_ == VERTICAL) {
+ typename polygon_formation::ScanLineToPolygonItrs<true, coordinate_type>::iterator itrPoly, itrPolyEnd;
+ scanlineToPolygonItrsV.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+ for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+ ++countPolygons;
+ concept_type::assign(poly, *itrPoly);
+ container.insert(container.end(), poly);
+ }
+ } else {
+ typename polygon_formation::ScanLineToPolygonItrs<false, coordinate_type>::iterator itrPoly, itrPolyEnd;
+ scanlineToPolygonItrsH.processEdges(itrPoly, itrPolyEnd, prevPos, leftEdges, rightEdges);
+ for( ; itrPoly != itrPolyEnd; ++ itrPoly) {
+ ++countPolygons;
+ concept_type::assign(poly, *itrPoly);
+ container.insert(container.end(), poly);
+ }
+ }
+ }
+ };
+
+ template <typename coordinate_type, typename property_type>
+ class property_merge {
+ private:
+ std::vector<std::pair<property_merge_point<coordinate_type>, std::pair<property_type, int> > > pmd_;
+ public:
+ inline property_merge() {}
+ inline property_merge(const property_merge& that) : pmd_(that.pmd_) {}
+ inline property_merge& operator=(const property_merge& that) { pmd_ = that.pmd_; }
+ inline void insert(const polygon_set_data<coordinate_type>& ps, const property_type& property) {
+ merge_scanline<coordinate_type, property_type, polygon_set_data<coordinate_type> >::
+ populate_property_merge_data(pmd_, ps.begin(), ps.end(), property, ps.orient());
+ }
+ template <class GeoObjT>
+ inline void insert(const GeoObjT& geoObj, const property_type& property) {
+ polygon_set_data<coordinate_type> ps;
+ ps.insert(geoObj);
+ insert(ps, property);
+ }
+ //merge properties of input geometries and store the resulting geometries of regions
+ //with unique sets of merged properties to polygons sets in a map keyed by sets of properties
+ // T = std::map<std::set<property_type>, polygon_set_data<coordiante_type> > or
+ // T = std::map<std::vector<property_type>, polygon_set_data<coordiante_type> >
+ template <typename ResultType>
+ inline void merge(ResultType& result) {
+ merge_scanline<coordinate_type, property_type, polygon_set_data<coordinate_type>, typename ResultType::key_type> ms;
+ ms.perform_merge(result, pmd_);
+ }
+ };
 
 }
 #endif

Modified: sandbox/gtl/gtl/polygon_set_view.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_set_view.hpp (original)
+++ sandbox/gtl/gtl/polygon_set_view.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,6 +8,9 @@
 #ifndef GTL_POLYGON_SET_VIEW_HPP
 #define GTL_POLYGON_SET_VIEW_HPP
 namespace gtl {
+ struct operator_provides_storage {};
+ struct operator_requires_copy {};
+
 
 template <typename value_type, typename arg_type>
 inline void insert_into_view_arg(value_type& dest, const arg_type& arg, orientation_2d orient) {
@@ -35,7 +38,7 @@
 public:
   typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
   typedef std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > > value_type;
- typedef typename value_type::iterator iterator_type;
+ typedef typename value_type::const_iterator iterator_type;
   typedef polygon_set_view operator_arg_type;
   typedef operator_provides_storage operator_storage_tag;
 private:
@@ -63,6 +66,9 @@
     return output_;
   }
 
+ iterator_type begin() const { return value().begin(); }
+ iterator_type end() const { return value().begin(); }
+
   orientation_2d orient() const { return orient_; }
   bool dirty() const { return false; } //result of a boolean is clean
   bool sorted() const { return true; } //result of a boolean is sorted
@@ -80,7 +86,7 @@
 public:
   typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
   typedef std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > > value_type;
- typedef typename value_type::iterator iterator_type;
+ typedef typename value_type::const_iterator iterator_type;
   typedef polygon_set_view operator_arg_type;
   typedef operator_provides_storage operator_storage_tag;
 private:
@@ -123,6 +129,8 @@
     return output_;
   }
 
+ iterator_type begin() const { return value().begin(); }
+ iterator_type end() const { return value().begin(); }
   orientation_2d orient() const { return orient_; }
   bool dirty() const { return false; } //result of a boolean is clean
   bool sorted() const { return true; } //result of a boolean is sorted
@@ -140,7 +148,7 @@
 public:
   typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
   typedef std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > > value_type;
- typedef typename value_type::iterator iterator_type;
+ typedef typename value_type::const_iterator iterator_type;
   typedef polygon_set_view operator_arg_type;
   typedef operator_provides_storage operator_storage_tag;
 private:
@@ -173,6 +181,8 @@
     return output_;
   }
 
+ iterator_type begin() const { return value().begin(); }
+ iterator_type end() const { return value().begin(); }
   orientation_2d orient() const { return orient_; }
   bool dirty() const { return false; } //result of a boolean is clean
   bool sorted() const { return true; } //result of a boolean is sorted
@@ -190,7 +200,7 @@
 public:
   typedef typename polygon_set_traits<ltype>::coordinate_type coordinate_type;
   typedef std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > > value_type;
- typedef typename value_type::iterator iterator_type;
+ typedef typename value_type::const_iterator iterator_type;
   typedef polygon_set_view operator_arg_type;
 private:
   const ltype& lvalue_;
@@ -223,6 +233,8 @@
     return output_;
   }
 
+ iterator_type begin() const { return value().begin(); }
+ iterator_type end() const { return value().begin(); }
   orientation_2d orient() const { return orient_; }
   bool dirty() const { return false; } //result of a boolean is clean
   bool sorted() const { return true; } //result of a boolean is sorted

Modified: sandbox/gtl/gtl/polygon_set_wrapper.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_set_wrapper.hpp (original)
+++ sandbox/gtl/gtl/polygon_set_wrapper.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -15,7 +15,7 @@
 public:
   typedef typename T::value_type geometry_type;
   typedef typename geometry_concept<geometry_type>::type concept_type;
- typedef typename concept_type::template registration<geometry_type>::coordinate_type coordinate_type;
+ typedef typename concept_type::template coordinate_type<geometry_type>::type coordinate_type;
   typedef iterator_geometry_range_to_set<concept_type, typename T::const_iterator> iterator_type;
   typedef polygon_set_const_wrapper operator_arg_type;
   typedef operator_requires_copy operator_storage_tag;
@@ -26,15 +26,15 @@
     return iterator_type(t_.begin());
   }
 
- inline iterator_type end(const T& polygon_set) const {
+ inline iterator_type end() const {
     return iterator_type(t_.end());
   }
 
   inline orientation_2d orient() const { return HORIZONTAL; }
 
- inline bool dirty(const T& polygon_set) const { return true; }
+ inline bool dirty() const { return true; }
 
- inline bool sorted(const T& polygon_set) const { return false; }
+ inline bool sorted() const { return false; }
 
 };
 
@@ -50,7 +50,7 @@
 public:
   typedef typename T::value_type geometry_type;
   typedef typename geometry_concept<geometry_type>::type concept_type;
- typedef typename concept_type::template registration<geometry_type>::coordinate_type coordinate_type;
+ typedef typename concept_type::template coordinate_type<geometry_type>::type coordinate_type;
   typedef iterator_geometry_range_to_set<concept_type, typename T::const_iterator> iterator_type;
   typedef polygon_set_wrapper operator_arg_type;
   typedef operator_requires_copy operator_storage_tag;
@@ -61,7 +61,7 @@
     return iterator_type(t_.begin());
   }
 
- inline iterator_type end(const T& polygon_set) const {
+ inline iterator_type end() const {
     return iterator_type(t_.end());
   }
 
@@ -71,9 +71,9 @@
 
   inline orientation_2d orient() const { return HORIZONTAL; }
 
- inline bool dirty(const T& polygon_set) const { return true; }
+ inline bool dirty() const { return true; }
 
- inline bool sorted(const T& polygon_set) const { return false; }
+ inline bool sorted() const { return false; }
 
 };
 

Modified: sandbox/gtl/gtl/polygon_with_holes_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_with_holes_concept.hpp (original)
+++ sandbox/gtl/gtl/polygon_with_holes_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -14,6 +14,12 @@
 public:
   inline polygon_with_holes_concept() {}
   //inherits its behaviors
+
+ //needed to disambiguate between multiple base class implementations of same function
+ template <typename polygon_with_holes_type_1, typename polygon_with_holes_type_2>
+ static polygon_with_holes_type_1& assign(polygon_with_holes_type_1& lvalue, const polygon_with_holes_type_2& rvalue) {
+ return polygon_45_with_holes_concept::assign(lvalue, rvalue);
+ }
 };
 
 }

Modified: sandbox/gtl/gtl/polygon_with_holes_data.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_with_holes_data.hpp (original)
+++ sandbox/gtl/gtl/polygon_with_holes_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,11 @@
 #ifndef GTL_POLYGON_WITH_HOLES_DATA_HPP
 #define GTL_POLYGON_WITH_HOLES_DATA_HPP
 namespace gtl {
-
+struct polygon_with_holes_concept;
 template <typename T>
 class polygon_with_holes_data : public polygon_45_with_holes_data<T> {
+public:
+ typedef polygon_with_holes_concept geometry_type;
   //inherits everything
 };
 

Modified: sandbox/gtl/gtl/post_geometry_traits_definitions.hpp
==============================================================================
--- sandbox/gtl/gtl/post_geometry_traits_definitions.hpp (original)
+++ sandbox/gtl/gtl/post_geometry_traits_definitions.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -12,19 +12,37 @@
 template <typename geometry_type>
 struct component_type {
   typedef typename geometry_concept<geometry_type>::type::template
- registration<geometry_type>::component_type type;
+ component_type<geometry_type>::type type;
 };
 
 template <typename geometry_type>
 struct coordinate_type {
   typedef typename geometry_concept<geometry_type>::type::template
- registration<geometry_type>::coordinate_type type;
+ coordinate_type<geometry_type>::type type;
 };
 
 template <typename geometry_type>
 struct center_type {
   typedef typename geometry_concept<geometry_type>::type::template
- registration<geometry_type>::center_type type;
+ center_type<geometry_type>::type type;
+};
+
+template <typename geometry_type>
+struct area_type {
+ typedef typename geometry_concept<geometry_type>::type::template
+ area_type<geometry_type>::type type;
+};
+
+template <typename geometry_type>
+struct distance_type {
+ typedef typename geometry_concept<geometry_type>::type::template
+ distance_type<geometry_type>::type type;
+};
+
+template <typename geometry_type>
+struct difference_type {
+ typedef typename geometry_concept<geometry_type>::type::template
+ difference_type<geometry_type>::type type;
 };
 
 }

Modified: sandbox/gtl/gtl/rectangle_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/rectangle_concept.hpp (original)
+++ sandbox/gtl/gtl/rectangle_concept.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -12,19 +12,37 @@
 struct rectangle_concept {
   rectangle_concept() {}
 
- template <typename rectangle_type>
- struct registration {
- typedef typename rectangle_traits<rectangle_type>::coordinate_type coordinate_type;
- typedef interval_data<coordinate_type> component_type;
- typedef point_data<coordinate_type> center_type;
+ template <typename T>
+ struct coordinate_type {
+ typedef typename rectangle_traits<T>::coordinate_type type;
+ };
+
+ template <typename T>
+ struct component_type {
+ typedef typename rectangle_traits<T>::interval_type type;
+ };
+
+ template <typename T>
+ struct center_type {
+ //should we make point_type a trait?
+ typedef point_data<typename coordinate_type<T>::type > type;
+ };
+
+ template <typename T>
+ struct area_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::area_type type;
+ };
+
+ template <typename T>
+ struct difference_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ };
+
+ template <typename T>
+ struct distance_type {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
   };
 
- template <orientation_2d_enum orient, typename T>
- static inline typename rectangle_traits<T>::interval_type
- get(const T& rectangle) {
- return rectangle_traits<T>::get(rectangle, orient);
- }
-
   template <typename T>
   static inline typename rectangle_traits<T>::interval_type
   get(const T& rectangle, orientation_2d orient) {
@@ -68,10 +86,10 @@
                             const T3& interval_vertical) {
     return rectangle_traits<T>::construct(interval_horizontal, interval_vertical); }
 
- template <typename T, typename coordinate_type>
- static inline T construct(coordinate_type xl, coordinate_type yl, coordinate_type xh, coordinate_type yh) {
- return rectangle_traits<T>::construct(interval_data<coordinate_type>(xl, xh),
- interval_data<coordinate_type>(yl, yh));
+ template <typename T, typename coord_type>
+ static inline T construct(coord_type xl, coord_type yl, coord_type xh, coord_type yh) {
+ return rectangle_traits<T>::construct(interval_data<coord_type>(xl, xh),
+ interval_data<coord_type>(yl, yh));
   }
 
   template <typename T, typename T2>
@@ -102,23 +120,9 @@
     return interval_concept::get(rectangle_traits<rectangle_type>::get(rectangle, orient), dir);
   }
 
- template <direction_1d_enum dir, typename rectangle_type>
- static inline typename rectangle_traits<rectangle_type>::coordinate_type
- get(const rectangle_type& rectangle, orientation_2d orient) {
- return get(rectangle, orient, dir);
- }
-
   template <typename rectangle_type>
   static inline void set(rectangle_type& rectangle, orientation_2d orient, direction_1d dir,
                          typename rectangle_traits<rectangle_type>::coordinate_type value) {
- typename rectangle_traits<rectangle_type>::interval_type ivl = orient(rectangle);
- interval_concept::set(ivl, dir, value);
- set(rectangle, orient, ivl);
- }
-
- template <direction_1d_enum dir, typename rectangle_type>
- static inline void set(rectangle_type& rectangle, orientation_2d orient,
- typename rectangle_traits<rectangle_type>::coordinate_type value) {
     typename rectangle_traits<rectangle_type>::interval_type ivl = get(rectangle, orient);
     interval_concept::set(ivl, dir, value);
     set(rectangle, orient, ivl);
@@ -127,58 +131,60 @@
   template <typename rectangle_type>
   static typename rectangle_traits<rectangle_type>::coordinate_type
   xl(const rectangle_type& rectangle) {
- return get<LOW>(rectangle, HORIZONTAL);
+ return get(rectangle, HORIZONTAL, LOW);
   }
 
   template <typename rectangle_type>
   static void xl(rectangle_type& rectangle, typename rectangle_traits<rectangle_type>::coordinate_type value) {
- return set<LOW>(rectangle, HORIZONTAL, value);
+ return set(rectangle, HORIZONTAL, LOW, value);
   }
 
   template <typename rectangle_type>
   static typename rectangle_traits<rectangle_type>::coordinate_type
   xh(const rectangle_type& rectangle) {
- return get<HIGH>(rectangle, HORIZONTAL);
+ return get(rectangle, HORIZONTAL, HIGH);
   }
 
   template <typename rectangle_type>
   static void xh(rectangle_type& rectangle, typename rectangle_traits<rectangle_type>::coordinate_type value) {
- return set<HIGH>(rectangle, HORIZONTAL, value);
+ return set(rectangle, HORIZONTAL, HIGH, value);
   }
 
   template <typename rectangle_type>
   static typename rectangle_traits<rectangle_type>::coordinate_type
   yl(const rectangle_type& rectangle) {
- return get<LOW>(rectangle, VERTICAL);
+ return get(rectangle, VERTICAL, LOW);
   }
 
   template <typename rectangle_type>
   static void yl(rectangle_type& rectangle, typename rectangle_traits<rectangle_type>::coordinate_type value) {
- return set<LOW>(rectangle, VERTICAL, value);
+ return set(rectangle, VERTICAL, LOW, value);
   }
 
   template <typename rectangle_type>
   static typename rectangle_traits<rectangle_type>::coordinate_type
   yh(const rectangle_type& rectangle) {
- return get<HIGH>(rectangle, VERTICAL);
+ return get(rectangle, VERTICAL, HIGH);
   }
 
   template <typename rectangle_type>
   static void yh(rectangle_type& rectangle, typename rectangle_traits<rectangle_type>::coordinate_type value) {
- return set<HIGH>(rectangle, VERTICAL, value);
+ return set(rectangle, VERTICAL, HIGH, value);
   }
 
   template <typename rectangle_type, typename rectangle_type2>
   static bool contains(const rectangle_type& rectangle, const rectangle_type2 rectangle_contained,
                                 bool consider_touch, rectangle_concept tag) {
- return interval_concept::contains(get<HORIZONTAL>(rectangle), get<HORIZONTAL>(rectangle_contained), consider_touch, interval_concept()) &&
- interval_concept::contains(get<VERTICAL>(rectangle), get<VERTICAL>(rectangle_contained), consider_touch, interval_concept());
+ return interval_concept::contains(horizontal(rectangle), horizontal(rectangle_contained), consider_touch, interval_concept()) &&
+ interval_concept::contains(vertical(rectangle), vertical(rectangle_contained), consider_touch, interval_concept());
   }
   template <typename rectangle_type, typename point_type>
   static bool contains(const rectangle_type& rectangle, const point_type point_contained,
                                 bool consider_touch, point_concept tag) {
- return interval_concept::contains(get<HORIZONTAL>(rectangle), point_concept::get<HORIZONTAL>(point_contained), consider_touch, no_type()) &&
- interval_concept::contains(get<VERTICAL>(rectangle), point_concept::get<VERTICAL>(point_contained), consider_touch, no_type());
+ return interval_concept::contains(horizontal(rectangle), point_concept::x(point_contained),
+ consider_touch, coordinate_concept()) &&
+ interval_concept::contains(vertical(rectangle), point_concept::y(point_contained),
+ consider_touch, coordinate_concept());
   }
 
   /// set all four coordinates based upon two points
@@ -198,7 +204,7 @@
   /// move rectangle by delta in orient
   template <typename rectangle_type>
   static rectangle_type& move(rectangle_type& rectangle, orientation_2d orient,
- typename rectangle_traits<rectangle_type>::coordinate_type delta) {
+ typename difference_type<rectangle_type>::type delta) {
     typename rectangle_traits<rectangle_type>::interval_type ivl = get(rectangle, orient);
     interval_concept::move(ivl, delta);
     set(rectangle, orient, ivl);
@@ -294,12 +300,12 @@
     horizontal(rectangle,
                interval_concept::convolve(ivl,
                                           point_concept::x(convolution_point),
- no_type()));
+ coordinate_concept()));
     ivl = vertical(rectangle);
     vertical(rectangle,
              interval_concept::convolve(ivl,
                                         point_concept::y(convolution_point),
- no_type()));
+ coordinate_concept()));
     return rectangle;
   }
 
@@ -312,12 +318,12 @@
     horizontal(rectangle,
                interval_concept::deconvolve(ivl,
                                             point_concept::x(convolution_point),
- no_type()));
+ coordinate_concept()));
     ivl = vertical(rectangle);
     vertical(rectangle,
              interval_concept::deconvolve(ivl,
                                           point_concept::y(convolution_point),
- no_type()));
+ coordinate_concept()));
     return rectangle;
   }
 
@@ -330,9 +336,10 @@
 
   /// get the area of the rectangle
   template <typename rectangle_type>
- static typename rectangle_traits<rectangle_type>::coordinate_type
+ static typename area_type<rectangle_type>::type
   area(const rectangle_type& rectangle) {
- return delta(rectangle, HORIZONTAL) * delta(rectangle, VERTICAL);
+ typedef typename area_type<rectangle_type>::type area_type;
+ return (area_type)delta(rectangle, HORIZONTAL) * (area_type)delta(rectangle, VERTICAL);
   }
 
   /// returns the orientation of the longest side
@@ -344,14 +351,14 @@
 
   /// get the half perimeter of the rectangle
   template <typename rectangle_type>
- static typename rectangle_traits<rectangle_type>::coordinate_type
+ static typename difference_type<rectangle_type>::type
   half_perimeter(const rectangle_type& rectangle) {
     return delta(rectangle, HORIZONTAL) + delta(rectangle, VERTICAL);
   }
    
   /// get the perimeter of the rectangle
   template <typename rectangle_type>
- static typename rectangle_traits<rectangle_type>::coordinate_type
+ static typename difference_type<rectangle_type>::type
   perimeter(const rectangle_type& rectangle) {
     return 2 * half_perimeter(rectangle);
   }
@@ -523,20 +530,20 @@
 
   /// returns the center of the rectangle
   template <typename rectangle_type>
- static inline typename registration<rectangle_type>::center_type
+ static inline typename center_type<rectangle_type>::type
   center(const rectangle_type& rectangle) {
- return typename registration<rectangle_type>::center_type(interval_concept::center(horizontal(rectangle)),
- interval_concept::center(vertical(rectangle)));
+ return typename center_type<rectangle_type>::type(interval_concept::center(horizontal(rectangle)),
+ interval_concept::center(vertical(rectangle)));
   }
 
   template <typename rectangle_type>
- static typename registration<rectangle_type>::center_type
+ static typename center_type<rectangle_type>::type
   get_corner(const rectangle_type& rectangle, direction_2d direction_facing, direction_1d direction_turning) {
     typedef typename rectangle_traits<rectangle_type>::coordinate_type Unit;
     Unit u1 = get(rectangle, direction_facing);
     Unit u2 = get(rectangle, direction_facing.turn(direction_turning));
     if(orientation_2d(direction_facing).to_int()) std::swap(u1, u2);
- return point_concept::construct<typename registration<rectangle_type>::center_type>(u1, u2);
+ return point_concept::construct<typename center_type<rectangle_type>::type>(u1, u2);
   }
 
   template <typename rectangle_type>
@@ -566,54 +573,41 @@
     return false;
   }
 
- //TODO: Add distance_type<geometry_type>::type and difference_type<geometry_type>::type
-
-// /// Returns the euclidian distance between the edge of the
-// /// rectangle and the point. Returns 0 if point is inside the
-// /// rectangle
-// template <class T2>
-// double
-// euclidianDistance(const PointImpl<T2> & p) const;
-
-// /// Returns the square of the euclidian distance between the edge of the
-// /// rectangle and the point. Returns 0 if point is inside the
-// /// rectangle
-// template <class T2>
-// UnsignedLongUnit
-// squareEuclidianDistance(const PointImpl<T2> & p) const;
-
-// /// Returns the manhattan distance (deltax + deltay) between the
-// /// edge of the rectangle and the point. Returns 0 if point is
-// /// inside the rectangle
-// template <class T2>
-// double
-// manhattanDistance(const PointImpl<T2> & p) const;
-
-// /// Returns the distance between this rectangle and a unit or a point
-// /// returns 0 if point or coordinate lies within
-// /// the range of the rectangle
-// Unit distance(Unit u, Orientation2D o) const;
-// template <class T2>
-// Unit distance(const PointImpl<T2> & p, Orientation2D o) const;
-
-// /// Returns the distance between two rectangles along the given orientation
-// template <class T2>
-// Unit distance(const RectangleImpl<T2> & r2, Orientation2D o) const;
-
-// /// Returns closest euclidian distance between the edges of the two rectangles.
-// /// Returns 0 if they overlap or touch
-// template <class T2>
-// double euclidianDistance(const RectangleImpl<T2> & r2) const;
-
-// /// Returns the square of the closest euclidian distance between the edges of the two rectangles.
-// /// Returns 0 if they overlap or touch
-// template <class T2>
-// UnsignedLongUnit squareEuclidianDistance(const RectangleImpl<T2> & r2) const;
-
-// /// Returns manhattan distance (deltax + deltay) between the two rectangles
-// /// Returns 0 if they overlap or touch
-// template <class T2>
-// Unit manhattanDistance(const RectangleImpl<T2> & r2) const;
+ template <typename rectangle_type, typename point_type>
+ static typename difference_type<rectangle_type>::type
+ distance(rectangle_type& lvalue, const point_type& rvalue,
+ orientation_2d orient, point_concept tag) {
+ return interval_concept::distance(get(lvalue, orient), point_concept::get(rvalue, orient), coordinate_concept());
+ }
+
+ template <typename rectangle_type, typename point_type>
+ static typename difference_type<rectangle_type>::type
+ distance(rectangle_type& lvalue, const point_type& rvalue,
+ orientation_2d orient, rectangle_concept tag) {
+ return interval_concept::distance(get(lvalue, orient), get(rvalue, orient), interval_concept());
+ }
+
+ template <typename rectangle_type, typename point_type, typename tag_type>
+ static typename difference_type<rectangle_type>::type
+ square_euclidian_distance(rectangle_type& lvalue, const point_type& rvalue, tag_type tag) {
+ typename difference_type<rectangle_type>::type xdist, ydist;
+ xdist = distance(lvalue, rvalue, HORIZONTAL, tag);
+ ydist = distance(lvalue, rvalue, VERTICAL, tag);
+ return (xdist * xdist) + (ydist * ydist);
+ }
+
+ template <typename rectangle_type, typename point_type, typename tag_type>
+ static typename distance_type<rectangle_type>::type
+ distance(rectangle_type& lvalue, const point_type& rvalue, tag_type tag) {
+ return sqrt((typename distance_type<rectangle_type>::type)(square_euclidian_distance(lvalue, rvalue, tag)));
+ }
+
+ template <typename rectangle_type, typename point_type, typename tag_type>
+ static typename difference_type<rectangle_type>::type
+ manhattan_distance(rectangle_type& lvalue, const point_type& rvalue,
+ tag_type tag) {
+ return distance(lvalue, rvalue, HORIZONTAL, tag) + distance(lvalue, rvalue, VERTICAL, tag);
+ }
 
   template <typename rectangle_type_1, typename rectangle_type_2>
   class less : public std::binary_function<const rectangle_type_1&, const rectangle_type_2&, bool> {

Modified: sandbox/gtl/gtl/rectangle_data.hpp
==============================================================================
--- sandbox/gtl/gtl/rectangle_data.hpp (original)
+++ sandbox/gtl/gtl/rectangle_data.hpp 2008-07-16 20:23:59 EDT (Wed, 16 Jul 2008)
@@ -8,9 +8,13 @@
 #ifndef GTL_RECTANGLE_DATA_HPP
 #define GTL_RECTANGLE_DATA_HPP
 namespace gtl {
+
+struct rectangle_concept;
+
 template <typename T>
 class rectangle_data {
 public:
+ typedef rectangle_concept geometry_type;
   typedef T coordinate_type;
   inline rectangle_data() {}
   template <typename interval_type_1, typename interval_type_2>


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