Boost logo

Boost-Commit :

From: lucanus.j.simonson_at_[hidden]
Date: 2008-07-18 19:51:14


Author: ljsimons
Date: 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
New Revision: 47583
URL: http://svn.boost.org/trac/boost/changeset/47583

Log:
completed implementation of generic operator syntax on containers of geometry objects
Text files modified:
   sandbox/gtl/gtl/geometry_concept.hpp | 54 ++++
   sandbox/gtl/gtl/gtl.hpp | 190 +++++++++++---
   sandbox/gtl/gtl/interval_concept.hpp | 28 +-
   sandbox/gtl/gtl/isotropy.hpp | 26 +-
   sandbox/gtl/gtl/iterator_geometry_to_set.hpp | 2
   sandbox/gtl/gtl/point_concept.hpp | 28 +-
   sandbox/gtl/gtl/polygon_45_concept.hpp | 8
   sandbox/gtl/gtl/polygon_45_with_holes_concept.hpp | 12
   sandbox/gtl/gtl/polygon_90_concept.hpp | 14
   sandbox/gtl/gtl/polygon_90_with_holes_concept.hpp | 4
   sandbox/gtl/gtl/polygon_formation.hpp | 85 +++++++
   sandbox/gtl/gtl/polygon_set_data.hpp | 148 ++++-------
   sandbox/gtl/gtl/polygon_set_traits.hpp | 25 -
   sandbox/gtl/gtl/polygon_set_view.hpp | 483 ++++++++++++++++++++++-----------------
   sandbox/gtl/gtl/polygon_set_wrapper.hpp | 61 +++++
   sandbox/gtl/gtl/post_geometry_traits_definitions.hpp | 8
   sandbox/gtl/gtl/rectangle_concept.hpp | 44 +-
   sandbox/gtl/gtl/rectangle_formation.hpp | 22 +
   sandbox/gtl/gtl/scan_arbitrary.hpp | 8
   19 files changed, 783 insertions(+), 467 deletions(-)

Modified: sandbox/gtl/gtl/geometry_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/geometry_concept.hpp (original)
+++ sandbox/gtl/gtl/geometry_concept.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -9,9 +9,7 @@
 #define GTL_GEOMETRY_CONCEPT_HPP
 namespace gtl {
 template <typename T>
-struct geometry_concept {
- typedef typename T::geometry_type type;
-};
+struct geometry_concept { }; //has to be empty by default
 
 template <>
 struct geometry_concept<int> {
@@ -23,5 +21,55 @@
   typedef coordinate_concept type;
 };
 
+template <typename T>
+struct geometry_concept<interval_data<T> > {
+ typedef interval_concept type;
+};
+
+template <typename T>
+struct geometry_concept<point_data<T> > {
+ typedef point_concept type;
+};
+
+template <typename T>
+struct geometry_concept<rectangle_data<T> > {
+ typedef rectangle_concept type;
+};
+
+template <typename T>
+struct geometry_concept<point_3d_data<T> > {
+ typedef point_3d_concept type;
+};
+
+template <typename T>
+struct geometry_concept<polygon_data<T> > {
+ typedef polygon_concept type;
+};
+
+template <typename T>
+struct geometry_concept<polygon_with_holes_data<T> > {
+ typedef polygon_with_holes_concept type;
+};
+
+template <typename T>
+struct geometry_concept<polygon_45_data<T> > {
+ typedef polygon_45_concept type;
+};
+
+template <typename T>
+struct geometry_concept<polygon_45_with_holes_data<T> > {
+ typedef polygon_45_with_holes_concept type;
+};
+
+template <typename T>
+struct geometry_concept<polygon_90_data<T> > {
+ typedef polygon_90_concept type;
+};
+
+template <typename T>
+struct geometry_concept<polygon_90_with_holes_data<T> > {
+ typedef polygon_90_with_holes_concept type;
+};
+
 }
 #endif

Modified: sandbox/gtl/gtl/gtl.hpp
==============================================================================
--- sandbox/gtl/gtl/gtl.hpp (original)
+++ sandbox/gtl/gtl/gtl.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -80,15 +80,15 @@
 //polygon set concepts
 #include "polygon_set_view.hpp"
 //polygon set data types
+#include "polygon_set_wrapper.hpp"
 #include "polygon_set_data.hpp"
 
-#include "polygon_set_wrapper.hpp"
 
 //defintions
 #include "post_geometry_traits_definitions.hpp"
 
 //general scanline
-#include "scan_arbitrary.hpp"
+//#include "scan_arbitrary.hpp"
 
 namespace gtl {
 
@@ -180,21 +180,21 @@
 
 //accepts: interval
 template <typename geometry_type>
-typename coordinate_type<geometry_type>::type
+typename coordinate_difference<geometry_type>::type
 delta(const geometry_type& geometry_object) {
   return geometry_concept<geometry_type>::type::delta(geometry_object);
 }
 
 //accepts: rectangle prism
 template <typename geometry_type>
-typename coordinate_type<geometry_type>::type
+typename coordinate_difference<geometry_type>::type
 delta(const geometry_type& geometry_object, orientation_2d orient) {
   return geometry_concept<geometry_type>::type::delta(geometry_object, orient);
 }
 
 //accepts: prism
 template <typename geometry_type>
-typename coordinate_type<geometry_type>::type
+typename coordinate_difference<geometry_type>::type
 delta(const geometry_type& geometry_object, orientation_3d orient) {
   return geometry_concept<geometry_type>::type::delta(geometry_object, orient);
 }
@@ -208,14 +208,14 @@
 
 //accepts: rectangle
 template <typename geometry_type>
-typename coordinate_type<geometry_type>::type
+typename coordinate_distance<geometry_type>::type
 half_perimeter(const geometry_type& geometry_object) {
   return geometry_concept<geometry_type>::type::half_perimeter(geometry_object);
 }
 
-//accepts: rectangle
+//accepts: rectangle, polygon
 template <typename geometry_type>
-typename distance_type<geometry_type>::type
+typename coordinate_distance<geometry_type>::type
 perimeter(const geometry_type& geometry_object) {
   return geometry_concept<geometry_type>::type::perimeter(geometry_object);
 }
@@ -364,8 +364,8 @@
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
-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());
+typename coordinate_distance<geometry_type_1>::type euclidean_distance(geometry_type_1& lvalue, const geometry_type_2& rvalue) {
+ return geometry_concept<geometry_type_1>::type::euclidean_distance(lvalue, rvalue, typename geometry_concept<geometry_type_2>::type());
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
@@ -459,94 +459,192 @@
 //boolean operator functions
 
 template <typename geometry_type_1, typename geometry_type_2>
-polygon_set_view<typename geometry_type_1::operator_arg_type,
- typename geometry_type_2::operator_arg_type,
+polygon_set_view<typename polygon_set_traits<geometry_type_1>::operator_arg_type,
+ typename polygon_set_traits<geometry_type_2>::operator_arg_type,
                  boolean_op::BinaryOr,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>
 operator|(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
   return polygon_set_view<geometry_type_1, geometry_type_2,
     boolean_op::BinaryOr,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>(lvalue, rvalue,
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>(lvalue, rvalue,
                                                     polygon_set_traits<geometry_type_1>::orient(lvalue),
                                                     boolean_op::BinaryOr());
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
-polygon_set_view<typename geometry_type_1::operator_arg_type,
- typename geometry_type_2::operator_arg_type,
+polygon_set_view<typename polygon_set_traits<geometry_type_1>::operator_arg_type,
+ typename polygon_set_traits<geometry_type_2>::operator_arg_type,
                  boolean_op::BinaryOr,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>
 operator+(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
   return polygon_set_view<geometry_type_1, geometry_type_2,
     boolean_op::BinaryOr,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>(lvalue, rvalue,
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>(lvalue, rvalue,
                                                     polygon_set_traits<geometry_type_1>::orient(lvalue),
                                                     boolean_op::BinaryOr());
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
-polygon_set_view<typename geometry_type_1::operator_arg_type,
- typename geometry_type_2::operator_arg_type,
+polygon_set_view<typename polygon_set_traits<geometry_type_1>::operator_arg_type,
+ typename polygon_set_traits<geometry_type_2>::operator_arg_type,
                  boolean_op::BinaryAnd,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>
 operator*(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
   return polygon_set_view<geometry_type_1, geometry_type_2,
     boolean_op::BinaryAnd,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>(lvalue, rvalue,
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>(lvalue, rvalue,
                                                     polygon_set_traits<geometry_type_1>::orient(lvalue),
                                                     boolean_op::BinaryAnd());
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
-polygon_set_view<typename geometry_type_1::operator_arg_type,
- typename geometry_type_2::operator_arg_type,
+polygon_set_view<typename polygon_set_traits<geometry_type_1>::operator_arg_type,
+ typename polygon_set_traits<geometry_type_2>::operator_arg_type,
                  boolean_op::BinaryAnd,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>
 operator&(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
   return polygon_set_view<geometry_type_1, geometry_type_2,
     boolean_op::BinaryAnd,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>(lvalue, rvalue,
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>(lvalue, rvalue,
                                                      polygon_set_traits<geometry_type_1>::orient(lvalue),
                                                      boolean_op::BinaryAnd());
 }
 
 template <typename geometry_type_1, typename geometry_type_2>
-polygon_set_view<typename geometry_type_1::operator_arg_type,
- typename geometry_type_2::operator_arg_type,
+polygon_set_view<typename polygon_set_traits<geometry_type_1>::operator_arg_type,
+ typename polygon_set_traits<geometry_type_2>::operator_arg_type,
                  boolean_op::BinaryXor,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>
 operator^(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
   return polygon_set_view<geometry_type_1, geometry_type_2,
     boolean_op::BinaryXor,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>(lvalue, rvalue,
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>(lvalue, rvalue,
                                                     polygon_set_traits<geometry_type_1>::orient(lvalue),
                                                     boolean_op::BinaryXor());
 }
  
 template <typename geometry_type_1, typename geometry_type_2>
-polygon_set_view<typename geometry_type_1::operator_arg_type,
- typename geometry_type_2::operator_arg_type,
+polygon_set_view<typename polygon_set_traits<geometry_type_1>::operator_arg_type,
+ typename polygon_set_traits<geometry_type_2>::operator_arg_type,
                  boolean_op::BinaryNot,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>
 operator-(const geometry_type_1& lvalue, const geometry_type_2& rvalue) {
   return polygon_set_view<geometry_type_1, geometry_type_2,
     boolean_op::BinaryNot,
- typename geometry_type_1::operator_storage_tag,
- typename geometry_type_2::operator_storage_tag>(lvalue, rvalue,
+ typename polygon_set_traits<geometry_type_1>::operator_storage_tag,
+ typename polygon_set_traits<geometry_type_2>::operator_storage_tag>(lvalue, rvalue,
                                                     polygon_set_traits<geometry_type_1>::orient(lvalue),
                                                     boolean_op::BinaryNot());
 }
 
+ template <typename T>
+ struct polygon_set_traits<std::vector<rectangle_data<T> > > {
+ typedef T coordinate_type;
+ typedef typename polygon_set_const_wrapper<std::vector<rectangle_data<T> > >::iterator_type iterator_type;
+ typedef typename std::vector<rectangle_data<T> > operator_arg_type;
+ typedef operator_requires_copy operator_storage_tag;
+
+ static inline iterator_type begin(const std::vector<rectangle_data<T> >& polygon_set) {
+ return wrap_const(polygon_set).begin();
+ }
+
+ static inline iterator_type end(const std::vector<rectangle_data<T> >& polygon_set) {
+ return wrap_const(polygon_set).end();
+ }
+
+ template <typename input_iterator_type>
+ static inline void set(std::vector<rectangle_data<T> >& polygon_set,
+ input_iterator_type input_begin, input_iterator_type input_end,
+ orientation_2d orient) {
+ wrap(polygon_set).set(input_begin, input_end, orient);
+ }
+
+ static inline orientation_2d orient(const std::vector<rectangle_data<T> >& polygon_set) { return HORIZONTAL; }
+
+ static inline bool dirty(const std::vector<rectangle_data<T> >& polygon_set) { return true; }
+
+ static inline bool sorted(const std::vector<rectangle_data<T> >& polygon_set) { return false; }
+
+ };
+
+ template <typename T>
+ struct polygon_set_traits<std::vector<polygon_90_data<T> > > {
+ typedef T coordinate_type;
+ typedef typename polygon_set_const_wrapper<std::vector<polygon_90_data<T> > >::iterator_type iterator_type;
+ typedef typename std::vector<polygon_90_data<T> > operator_arg_type;
+ typedef operator_requires_copy operator_storage_tag;
+
+ static inline iterator_type begin(const std::vector<polygon_90_data<T> >& polygon_set) {
+ return wrap_const(polygon_set).begin();
+ }
+
+ static inline iterator_type end(const std::vector<polygon_90_data<T> >& polygon_set) {
+ return wrap_const(polygon_set).end();
+ }
+
+ template <typename input_iterator_type>
+ static inline void set(std::vector<polygon_90_data<T> >& polygon_set,
+ input_iterator_type input_begin, input_iterator_type input_end,
+ orientation_2d orient) {
+ wrap(polygon_set).set(input_begin, input_end, orient);
+ }
+
+ static inline orientation_2d orient(const std::vector<polygon_90_data<T> >& polygon_set) { return HORIZONTAL; }
+
+ static inline bool dirty(const std::vector<polygon_90_data<T> >& polygon_set) { return true; }
+
+ static inline bool sorted(const std::vector<polygon_90_data<T> >& polygon_set) { return false; }
+
+ };
+
+// template <typename T>
+// struct polygon_set_traits<std::vector<polygon_90_with_holes_data<T> > > {
+// typedef T coordinate_type;
+// typedef typename polygon_set_const_wrapper<std::vector<polygon_90_with_holes_data<T> > >::iterator_type iterator_type;
+// typedef typename std::vector<polygon_90_with_holes_data<T> > operator_arg_type;
+// typedef operator_requires_copy operator_storage_tag;
+
+// static inline iterator_type begin(const std::vector<polygon_90_with_holes_data<T> >& polygon_set) {
+// return wrap_const(polygon_set).begin();
+// }
+
+// static inline iterator_type end(const std::vector<polygon_90_with_holes_data<T> >& polygon_set) {
+// return wrap_const(polygon_set).end();
+// }
+
+// template <typename input_iterator_type>
+// static inline void set(std::vector<polygon_90_with_holes_data<T> >& polygon_set,
+// input_iterator_type input_begin, input_iterator_type input_end,
+// orientation_2d orient) {
+// wrap(polygon_set).set(input_begin, input_end, orient);
+// }
+
+// static inline orientation_2d orient(const std::vector<polygon_90_with_holes_data<T> >& polygon_set) { return HORIZONTAL; }
+
+// static inline bool dirty(const std::vector<polygon_90_with_holes_data<T> >& polygon_set) { return true; }
+
+// static inline bool sorted(const std::vector<polygon_90_with_holes_data<T> >& polygon_set) { return false; }
+
+// };
+
+ template <typename T>
+ struct polygon_set_traits<std::vector<polygon_90_with_holes_data<T> > > : public
+ polygon_set_traits<polygon_set_wrapper<std::vector<polygon_90_with_holes_data<T> > > > {};
+ // template <typename T>
+ // struct polygon_set_traits<const std::vector<polygon_90_with_holes_data<T> > > : public
+// polygon_set_traits<polygon_set_const_wrapper<const std::vector<polygon_90_with_holes_data<T> > > > {};
+
+
 }
 #endif

Modified: sandbox/gtl/gtl/interval_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/interval_concept.hpp (original)
+++ sandbox/gtl/gtl/interval_concept.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -27,14 +27,14 @@
   };
 
   template <typename T>
- struct difference_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ struct coordinate_difference {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_difference type;
   };
 
   template <typename T>
- struct distance_type {
+ struct coordinate_distance {
     //1D distance is difference
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_difference type;
   };
 
 
@@ -137,9 +137,9 @@
   
   /// get the magnitude of the interval
   template <typename interval_type>
- static inline typename difference_type<interval_type>::type
+ static inline typename coordinate_difference<interval_type>::type
   delta(const interval_type& interval) {
- typedef typename difference_type<interval_type>::type diffT;
+ typedef typename coordinate_difference<interval_type>::type diffT;
     return (diffT)high(interval) - (diffT)low(interval); }
     
   /// flip this about coordinate
@@ -168,8 +168,8 @@
   /// move interval by delta
   template <typename interval_type>
   static interval_type& move(interval_type& interval,
- typename difference_type<interval_type>::type displacement) {
- typedef typename difference_type<interval_type>::type Unit;
+ typename coordinate_difference<interval_type>::type displacement) {
+ typedef typename coordinate_difference<interval_type>::type Unit;
     Unit len = delta(interval);
     low(interval, (Unit)low(interval) + displacement);
     high(interval, (Unit)low(interval) + len);
@@ -250,10 +250,10 @@
   
   /// distance from a coordinate to an interval
   template <typename interval_type>
- static inline typename distance_type<interval_type>::type
- distance(const interval_type& interval,
+ static inline typename coordinate_distance<interval_type>::type
+ euclidean_distance(const interval_type& interval,
            typename interval_traits<interval_type>::coordinate_type position, coordinate_concept tag) {
- typedef typename distance_type<interval_type>::type Unit;
+ typedef typename coordinate_distance<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) ];
   }
@@ -261,10 +261,10 @@
 
   /// distance between two intervals
   template <typename interval_type, typename interval_type_2>
- static inline typename distance_type<interval_type>::type
- distance(const interval_type& interval,
+ static inline typename coordinate_distance<interval_type>::type
+ euclidean_distance(const interval_type& interval,
            const interval_type_2& b, interval_concept tag) {
- typedef typename distance_type<interval_type>::type Unit;
+ typedef typename coordinate_distance<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) ];
   }

Modified: sandbox/gtl/gtl/isotropy.hpp
==============================================================================
--- sandbox/gtl/gtl/isotropy.hpp (original)
+++ sandbox/gtl/gtl/isotropy.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -14,24 +14,24 @@
 struct coordinate_traits {
   typedef T coordinate_type;
   typedef T area_type;
- typedef T difference_type;
- typedef T distance_type;
+ typedef T coordinate_difference;
+ typedef T coordinate_distance;
 };
 
 template <>
 struct coordinate_traits<int> {
   typedef int coordinate_type;
   typedef long long area_type;
- typedef long long difference_type;
- typedef double distance_type;
+ typedef long long coordinate_difference;
+ typedef double coordinate_distance;
 };
 
 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;
+ typedef long long coordinate_difference;
+ typedef double coordinate_distance;
 };
 
 struct coordinate_concept {
@@ -44,18 +44,18 @@
     typedef typename coordinate_traits<T>::area_type type;
   };
   template <typename T>
- struct difference_type {
- typedef typename coordinate_traits<T>::difference_type type;
+ struct coordinate_difference {
+ typedef typename coordinate_traits<T>::coordinate_difference type;
   };
   template <typename T>
- struct distance_type {
- typedef typename coordinate_traits<T>::distance_type type;
+ struct coordinate_distance {
+ typedef typename coordinate_traits<T>::coordinate_distance 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;
+ static typename coordinate_difference<coordinate_type_1>::type
+ euclidean_distance(const coordinate_type_1& lvalue, const coordinate_type_2& rvalue) {
+ typedef typename coordinate_difference<coordinate_type_1>::type Unit;
     return (lvalue < rvalue) ? (Unit)rvalue - (Unit)lvalue : (Unit)lvalue - (Unit)rvalue;
   }
 };

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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -312,6 +312,8 @@
   }
 };
 
+
+
 }
 #endif
 

Modified: sandbox/gtl/gtl/point_concept.hpp
==============================================================================
--- sandbox/gtl/gtl/point_concept.hpp (original)
+++ sandbox/gtl/gtl/point_concept.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -27,13 +27,13 @@
   };
 
   template <typename T>
- struct difference_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ struct coordinate_difference {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_difference type;
   };
 
   template <typename T>
- struct distance_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
+ struct coordinate_distance {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_distance type;
   };
 
 
@@ -101,30 +101,30 @@
   }
 
   template <typename point_type_1, typename point_type_2>
- static typename difference_type<point_type_1>::type
+ static typename coordinate_difference<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);
+ return euclidean_distance(point1, point2, HORIZONTAL) + euclidean_distance(point1, point2, VERTICAL);
   }
 
   template <typename point_type_1, typename point_type_2>
- static typename difference_type<point_type_1>::type
- distance(const point_type_1& point1, const point_type_2& point2, orientation_2d orient) {
+ static typename coordinate_difference<point_type_1>::type
+ euclidean_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)));
+ static typename coordinate_distance<point_type_1>::type
+ euclidean_distance(const point_type_1& point1, const point_type_2& point2) {
+ return sqrt((typename coordinate_distance<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
+ static typename coordinate_difference<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);
+ typename coordinate_difference<point_type_1>::type dx = euclidean_distance(point1, point2, HORIZONTAL);
+ typename coordinate_difference<point_type_1>::type dy = euclidean_distance(point1, point2, VERTICAL);
     dx *= dx;
     dy *= dy;
     return dx + dy;

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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -115,12 +115,12 @@
 
   /// get the perimeter of the polygon
   template <typename polygon_type>
- static typename distance_type<polygon_type>::type
+ static typename coordinate_distance<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;
- typename distance_type<polygon_type>::type return_value = 0;
+ typename coordinate_distance<polygon_type>::type return_value = 0;
     point_type previous_point, first_point;
     iterator itr = begin(polygon);
     iterator itr_end = end(polygon);
@@ -129,10 +129,10 @@
     ++itr;
     for( ; itr != itr_end; ++itr) {
       point_type current_point = *itr;
- return_value += point_concept::distance(current_point, previous_point);
+ return_value += point_concept::euclidean_distance(current_point, previous_point);
       previous_point = current_point;
     }
- return_value += point_concept::distance(previous_point, first_point);
+ return_value += point_concept::euclidean_distance(previous_point, first_point);
     return return_value;
   }
 

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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -29,13 +29,13 @@
   };
 
   template <typename T>
- struct difference_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ struct coordinate_difference {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_difference type;
   };
 
   template <typename T>
- struct distance_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
+ struct coordinate_distance {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_distance type;
   };
 
   template <typename polygon_with_holes_type_1, typename polygon_with_holes_type_2>
@@ -74,9 +74,9 @@
 
   /// get the perimeter of the polygon
   template <typename polygon_with_holes_type>
- static typename distance_type<polygon_with_holes_type>::type
+ static typename coordinate_distance<polygon_with_holes_type>::type
   perimeter(const polygon_with_holes_type& polygon) {
- typename distance_type<polygon_with_holes_type>::type retval = polygon_45_concept::perimeter(polygon);
+ typename coordinate_distance<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) {

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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -10,6 +10,8 @@
 namespace gtl {
 struct polygon_90_concept {
 
+ inline polygon_90_concept() {}
+
   template <typename T>
   struct coordinate_type {
     typedef typename polygon_traits<T>::coordinate_type type;
@@ -26,13 +28,13 @@
   };
 
   template <typename T>
- struct difference_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ struct coordinate_difference {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_difference type;
   };
 
   template <typename T>
- struct distance_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
+ struct coordinate_distance {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_distance type;
   };
 
   template<typename polygon_type, typename compact_iterator_type>
@@ -207,11 +209,11 @@
 
   /// get the perimeter of the polygon
   template <typename polygon_type>
- static typename difference_type<polygon_type>::type
+ static typename coordinate_difference<polygon_type>::type
   perimeter(const polygon_type& polygon) {
     typedef typename polygon_traits<polygon_type>::iterator_type iterator;
     typedef typename std::iterator_traits<iterator>::value_type point_type;
- typename difference_type<polygon_type>::type return_value = 0;
+ typename coordinate_difference<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_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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -79,9 +79,9 @@
 
   /// get the perimeter of the polygon
   template <typename polygon_with_holes_type>
- static typename difference_type<polygon_with_holes_type>::type
+ static typename coordinate_difference<polygon_with_holes_type>::type
   perimeter(const polygon_with_holes_type& polygon) {
- typename difference_type<polygon_with_holes_type>::type retval = polygon_90_concept::perimeter(polygon);
+ typename coordinate_difference<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) {

Modified: sandbox/gtl/gtl/polygon_formation.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_formation.hpp (original)
+++ sandbox/gtl/gtl/polygon_formation.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -1696,6 +1696,91 @@
 
 }; //polygon_formation namespace
 
+ //public API to access polygon formation algorithm
+ template <typename output_container, typename iterator_type, typename concept_type>
+ unsigned int get_polygons(output_container& container, iterator_type begin, iterator_type end,
+ orientation_2d orient, bool fracture_holes, concept_type tag) {
+ typedef typename output_container::value_type polygon_type;
+ typedef typename iterator_type::value_type::first_type coordinate_type;
+ polygon_type poly;
+ 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 = begin;
+ itr != 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);
+ }
+ }
+ return countPolygons;
+ }
+
+
 }
 #endif
 

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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -8,6 +8,7 @@
 #ifndef GTL_POLYGON_SET_DATA_HPP
 #define GTL_POLYGON_SET_DATA_HPP
 namespace gtl {
+
   template <typename T>
   class polygon_set_data {
   public:
@@ -71,6 +72,20 @@
       return *this;
     }
 
+ template <typename geometry_object>
+ inline polygon_set_data& operator=(const geometry_object& geometry) {
+ data_.clear();
+ insert(geometry);
+ return *this;
+ }
+
+ template <typename geometry_object>
+ inline polygon_set_data& operator=(const polygon_set_const_wrapper<geometry_object>& geometry) {
+ data_.clear();
+ insert(geometry.begin(), geometry.end());
+ return *this;
+ }
+
     /// insert iterator range
     template <typename iT>
     inline void insert(iT input_begin, iT input_end) {
@@ -166,6 +181,13 @@
       unsorted_ = false;
     }
 
+ template <typename input_iterator_type>
+ void set(input_iterator_type input_begin, input_iterator_type input_end, orientation_2d orient) {
+ data_.clear();
+ data_.insert(data_.end(), input_begin, input_end);
+ orient_ = orient;
+ }
+
     void set(const value_type& value, orientation_2d orient) {
       data_ = value;
       orient_ = orient;
@@ -180,25 +202,8 @@
     //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
- }
+ get_rectangles(output, data_.begin(), data_.end(), orient_, tag);
     }
     template <typename output_container>
     void get_dispatch(output_container& output, polygon_90_concept tag) {
@@ -210,85 +215,42 @@
     }
     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);
- }
- }
+ get_polygons(container, data_.begin(), data_.end(), orient_, fracture_holes, tag);
+ }
+ };
 
- }
- 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 T>
+ struct polygon_set_traits<polygon_set_data<T> > {
+ typedef typename polygon_set_data<T>::coordinate_type coordinate_type;
+ typedef typename polygon_set_data<T>::iterator_type iterator_type;
+ typedef typename polygon_set_data<T>::operator_arg_type operator_arg_type;
+ typedef typename polygon_set_data<T>::operator_storage_tag operator_storage_tag;
+
+ static inline iterator_type begin(const polygon_set_data<T>& polygon_set) {
+ return polygon_set.begin();
+ }
+
+ static inline iterator_type end(const polygon_set_data<T>& polygon_set) {
+ return polygon_set.end();
     }
+
+ template <typename input_iterator_type>
+ static inline void set(polygon_set_data<T>& polygon_set,
+ input_iterator_type input_begin, input_iterator_type input_end,
+ orientation_2d orient) {
+ polygon_set.set(input_begin, input_end, orient);
+ }
+
+ static inline orientation_2d orient(const polygon_set_data<T>& polygon_set) { return polygon_set.orient(); }
+
+ static inline bool dirty(const polygon_set_data<T>& polygon_set) { return polygon_set.dirty(); }
+
+ static inline bool sorted(const polygon_set_data<T>& polygon_set) { return polygon_set.sorted(); }
+
   };
+
+
   
   template <typename coordinate_type, typename property_type>
   class property_merge {

Modified: sandbox/gtl/gtl/polygon_set_traits.hpp
==============================================================================
--- sandbox/gtl/gtl/polygon_set_traits.hpp (original)
+++ sandbox/gtl/gtl/polygon_set_traits.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -10,31 +10,8 @@
 namespace gtl {
 
 template <typename T>
-struct polygon_set_traits {
- typedef typename T::coordinate_type coordinate_type;
- typedef typename T::iterator_type iterator_type;
- typedef typename T::operator_arg_type operator_arg_type;
+struct polygon_set_traits {};
 
- static inline iterator_type begin(const T& polygon_set) {
- return polygon_set.begin();
- }
-
- static inline iterator_type end(const T& polygon_set) {
- return polygon_set.end();
- }
-
- static inline void set(T& polygon_set, const std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >& value,
- orientation_2d orient) {
- polygon_set.set(value, orient);
- }
-
- static inline orientation_2d orient(const T& polygon_set) { return polygon_set.orient(); }
-
- static inline bool dirty(const T& polygon_set) { return polygon_set.dirty(); }
-
- static inline bool sorted(const T& polygon_set) { return polygon_set.sorted(); }
-
-};
 
 }
 #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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -11,242 +11,301 @@
   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);
 
-template <typename value_type, typename arg_type>
-inline void insert_into_view_arg(value_type& dest, const arg_type& arg, orientation_2d orient) {
- typedef typename polygon_set_traits<arg_type>::iterator_type literator;
- literator itr1, itr2;
- itr1 = polygon_set_traits<arg_type>::begin(arg);
- itr2 = polygon_set_traits<arg_type>::end(arg);
- if(polygon_set_traits<arg_type>::orient(arg) == orient) {
- for( ; itr1 != itr2; ++itr1) {
- dest.push_back(*itr1);
- }
- if(!polygon_set_traits<arg_type>::sorted(arg)) std::sort(dest.begin(), dest.end());
- } else {
- iterator_vertex_orient_conversion<literator> citr2(itr2);
- for(iterator_vertex_orient_conversion<literator> citr1(itr1); citr1 != citr2; ++citr1) {
- dest.push_back(*citr1);
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ class polygon_set_view;
+
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ struct polygon_set_traits<polygon_set_view<ltype, rtype, op_type, ltag, rtag> > {
+ typedef typename polygon_set_view<ltype, rtype, op_type, ltag, rtag>::coordinate_type coordinate_type;
+ typedef typename polygon_set_view<ltype, rtype, op_type, ltag, rtag>::iterator_type iterator_type;
+ typedef typename polygon_set_view<ltype, rtype, op_type, ltag, rtag>::operator_arg_type operator_arg_type;
+ typedef typename polygon_set_view<ltype, rtype, op_type, ltag, rtag>::operator_storage_tag operator_storage_tag;
+
+ static inline iterator_type begin(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set);
+ static inline iterator_type end(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set);
+
+ template <typename input_iterator_type>
+ static inline void set(polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set,
+ input_iterator_type input_begin, input_iterator_type input_end,
+ orientation_2d orient);
+
+ static inline orientation_2d orient(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set);
+
+ static inline bool dirty(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set);
+
+ static inline bool sorted(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set);
+ };
+
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ class polygon_set_view {
+ 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::const_iterator iterator_type;
+ typedef polygon_set_view operator_arg_type;
+ typedef operator_provides_storage operator_storage_tag;
+ private:
+ const ltype& lvalue_;
+ const rtype& rvalue_;
+ op_type op_;
+ orientation_2d orient_;
+ mutable value_type output_;
+ public:
+ polygon_set_view(const ltype& lvalue,
+ const rtype& rvalue,
+ orientation_2d orient,
+ op_type op) :
+ lvalue_(lvalue), rvalue_(rvalue), orient_(orient), op_(op) {}
+
+ /// get iterator to begin vertex data
+ const value_type& value() const {
+ if(output_.empty()) {
+ value_type linput_;
+ value_type rinput_;
+ insert_into_view_arg(linput_, lvalue_, orient_);
+ insert_into_view_arg(rinput_, rvalue_, orient_);
+ boolean_op::applyBooleanBinaryOp(output_, linput_, rinput_, boolean_op::BinaryCount<op_type>());
+ }
+ return output_;
     }
- std::sort(dest.begin(), dest.end());
- }
-}
 
+ iterator_type begin() const { return value().begin(); }
+ iterator_type end() const { return value().begin(); }
 
-template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
-class polygon_set_view {
-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::const_iterator iterator_type;
- typedef polygon_set_view operator_arg_type;
- typedef operator_provides_storage operator_storage_tag;
-private:
- const ltype& lvalue_;
- const rtype& rvalue_;
- op_type op_;
- orientation_2d orient_;
- mutable value_type output_;
-public:
- polygon_set_view(const ltype& lvalue,
- const rtype& rvalue,
- orientation_2d orient,
- op_type op) :
- lvalue_(lvalue), rvalue_(rvalue), orient_(orient), op_(op) {}
-
- /// get iterator to begin vertex data
- const value_type& value() const {
- if(output_.empty()) {
- value_type linput_;
- value_type rinput_;
- insert_into_view_arg(linput_, lvalue_, orient_);
- insert_into_view_arg(rinput_, rvalue_, orient_);
- boolean_op::applyBooleanBinaryOp(output_, linput_, rinput_, boolean_op::BinaryCount<op_type>());
+ 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
+
+ //insert is not inteded to be called because a view is read only
+ void insert(const value_type& value,
+ orientation_2d orient) const {
+ //throw a helpful exception
     }
- return output_;
- }
+ void sort() const {} //is always sorted
+ };
 
- iterator_type begin() const { return value().begin(); }
- iterator_type end() const { return value().begin(); }
+ template <typename ltype, typename rtype, typename op_type>
+ class polygon_set_view<ltype, rtype, op_type, operator_provides_storage, operator_provides_storage> {
+ 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::const_iterator iterator_type;
+ typedef polygon_set_view operator_arg_type;
+ typedef operator_provides_storage operator_storage_tag;
+ private:
+ const ltype& lvalue_;
+ const rtype& rvalue_;
+ op_type op_;
+ orientation_2d orient_;
+ mutable value_type output_;
+ public:
+ polygon_set_view(const ltype& lvalue,
+ const rtype& rvalue,
+ orientation_2d orient,
+ op_type op) :
+ lvalue_(lvalue), rvalue_(rvalue), op_(op), orient_(orient) {}
+
+ /// get iterator to begin vertex data
+ const value_type& value() const {
+ if(output_.empty()) {
+ value_type linput_;
+ value_type rinput_;
+ if(orient_ != lvalue_.orient()) {
+ insert_into_view_arg(linput_, lvalue_, orient_);
+ if(orient_ != rvalue_.orient()) {
+ insert_into_view_arg(rinput_, rvalue_, orient_);
+ boolean_op::applyBooleanBinaryOp(output_, linput_, rinput_, boolean_op::BinaryCount<op_type>());
+ } else {
+ boolean_op::applyBooleanBinaryOp(output_, linput_, rvalue_.value(), boolean_op::BinaryCount<op_type>());
+ }
+ } else {
+ if(!lvalue_.sorted()) lvalue_.sort();
+ if(orient_ != rvalue_.orient()) {
+ insert_into_view_arg(rinput_, rvalue_, orient_);
+ boolean_op::applyBooleanBinaryOp(output_, lvalue_.value(), rinput_, boolean_op::BinaryCount<op_type>());
+ } else {
+ if(!rvalue_.sorted()) rvalue_.sort();
+ boolean_op::applyBooleanBinaryOp(output_, lvalue_.value(), rvalue_.value(), boolean_op::BinaryCount<op_type>());
+ }
+ }
+ }
+ return output_;
+ }
 
- 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
-
- //insert is not inteded to be called because a view is read only
- void insert(const value_type& value,
- orientation_2d orient) const {
- //throw a helpful exception
- }
- void sort() const {} //is always sorted
-};
+ 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
+
+ //insert is not inteded to be called because a view is read only
+ void insert(const value_type& value,
+ orientation_2d orient) const {
+ //throw a helpful exception
+ }
+ void sort() const {} //is always sorted
+ };
 
-template <typename ltype, typename rtype, typename op_type>
-class polygon_set_view<ltype, rtype, op_type, operator_provides_storage, operator_provides_storage> {
-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::const_iterator iterator_type;
- typedef polygon_set_view operator_arg_type;
- typedef operator_provides_storage operator_storage_tag;
-private:
- const ltype& lvalue_;
- const rtype& rvalue_;
- op_type op_;
- orientation_2d orient_;
- mutable value_type output_;
-public:
- polygon_set_view(const ltype& lvalue,
- const rtype& rvalue,
- orientation_2d orient,
- op_type op) :
- lvalue_(lvalue), rvalue_(rvalue), op_(op), orient_(orient) {}
-
- /// get iterator to begin vertex data
- const value_type& value() const {
- if(output_.empty()) {
- value_type linput_;
- value_type rinput_;
- if(orient_ != lvalue_.orient()) {
- insert_into_view_arg(linput_, lvalue_, orient_);
- if(orient_ != rvalue_.orient()) {
- insert_into_view_arg(rinput_, rvalue_, orient_);
+ template <typename ltype, typename rtype, typename op_type, typename rtag>
+ class polygon_set_view<ltype, rtype, op_type, operator_provides_storage, rtag> {
+ 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::const_iterator iterator_type;
+ typedef polygon_set_view operator_arg_type;
+ typedef operator_provides_storage operator_storage_tag;
+ private:
+ const ltype& lvalue_;
+ const rtype& rvalue_;
+ op_type op_;
+ orientation_2d orient_;
+ mutable value_type output_;
+ public:
+ polygon_set_view(const ltype& lvalue,
+ const rtype& rvalue,
+ orientation_2d orient,
+ op_type op) :
+ lvalue_(lvalue), rvalue_(rvalue), op_(op) , orient_(orient) {}
+
+ /// get iterator to begin vertex data
+ const value_type& value() const {
+ if(output_.empty()) {
+ value_type linput_;
+ value_type rinput_;
+ insert_into_view_arg(rinput_, rvalue_, orient_);
+ if(orient_ != lvalue_.orient()) {
+ insert_into_view_arg(linput_, lvalue_, orient_);
           boolean_op::applyBooleanBinaryOp(output_, linput_, rinput_, boolean_op::BinaryCount<op_type>());
         } else {
- boolean_op::applyBooleanBinaryOp(output_, linput_, rvalue_.value(), boolean_op::BinaryCount<op_type>());
- }
- } else {
- if(!lvalue_.sorted()) lvalue_.sort();
- if(orient_ != rvalue_.orient()) {
- insert_into_view_arg(rinput_, rvalue_, orient_);
+ if(!lvalue_.sorted()) lvalue_.sort();
           boolean_op::applyBooleanBinaryOp(output_, lvalue_.value(), rinput_, boolean_op::BinaryCount<op_type>());
- } else {
- if(!rvalue_.sorted()) rvalue_.sort();
- boolean_op::applyBooleanBinaryOp(output_, lvalue_.value(), rvalue_.value(), boolean_op::BinaryCount<op_type>());
         }
       }
+ return output_;
     }
- 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
-
- //insert is not inteded to be called because a view is read only
- void insert(const value_type& value,
- orientation_2d orient) const {
- //throw a helpful exception
- }
- void sort() const {} //is always sorted
-};
+ 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
+
+ //insert is not inteded to be called because a view is read only
+ void insert(const value_type& value,
+ orientation_2d orient) const {
+ //throw a helpful exception
+ }
+ void sort() const {} //is always sorted
+ };
 
-template <typename ltype, typename rtype, typename op_type, typename rtag>
-class polygon_set_view<ltype, rtype, op_type, operator_provides_storage, rtag> {
-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::const_iterator iterator_type;
- typedef polygon_set_view operator_arg_type;
- typedef operator_provides_storage operator_storage_tag;
-private:
- const ltype& lvalue_;
- const rtype& rvalue_;
- op_type op_;
- orientation_2d orient_;
- mutable value_type output_;
-public:
- polygon_set_view(const ltype& lvalue,
- const rtype& rvalue,
- orientation_2d orient,
- op_type op) :
- lvalue_(lvalue), rvalue_(rvalue), op_(op) , orient_(orient) {}
-
- /// get iterator to begin vertex data
- const value_type& value() const {
- if(output_.empty()) {
- value_type linput_;
- value_type rinput_;
- insert_into_view_arg(rinput_, rvalue_, orient_);
- if(orient_ != lvalue_.orient()) {
+ template <typename ltype, typename rtype, typename op_type, typename ltag>
+ class polygon_set_view<ltype, rtype, op_type, ltag, operator_provides_storage> {
+ 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::const_iterator iterator_type;
+ typedef polygon_set_view operator_arg_type;
+ private:
+ const ltype& lvalue_;
+ const rtype& rvalue_;
+ op_type op_;
+ orientation_2d orient_;
+ mutable value_type output_;
+ mutable value_type linput_;
+ public:
+ polygon_set_view(const ltype& lvalue,
+ const rtype& rvalue,
+ orientation_2d orient,
+ op_type op) :
+ lvalue_(lvalue), rvalue_(rvalue), op_(op), orient_(orient) {}
+
+ /// get iterator to begin vertex data
+ const value_type& value() const {
+ if(output_.empty()) {
+ value_type linput_;
+ value_type rinput_;
         insert_into_view_arg(linput_, lvalue_, orient_);
- boolean_op::applyBooleanBinaryOp(output_, linput_, rinput_, boolean_op::BinaryCount<op_type>());
- } else {
- if(!lvalue_.sorted()) lvalue_.sort();
- boolean_op::applyBooleanBinaryOp(output_, lvalue_.value(), rinput_, boolean_op::BinaryCount<op_type>());
+ if(orient_ != lvalue_.orient()) {
+ insert_into_view_arg(rinput_, rvalue_, orient_);
+ boolean_op::applyBooleanBinaryOp(output_, linput_, rinput_, boolean_op::BinaryCount<op_type>());
+ } else {
+ if(!rvalue_.sorted()) rvalue_.sort();
+ boolean_op::applyBooleanBinaryOp(output_, linput_, rvalue_.value(), boolean_op::BinaryCount<op_type>());
+ }
       }
+ return output_;
     }
- 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
-
- //insert is not inteded to be called because a view is read only
- void insert(const value_type& value,
- orientation_2d orient) const {
- //throw a helpful exception
- }
- void sort() const {} //is always sorted
-};
+ 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
+
+ template <typename input_iterator_type>
+ void set(input_iterator_type input_begin, input_iterator_type input_end,
+ orientation_2d orient) const {
+ //TODO
+ }
+ void sort() const {} //is always sorted
+ };
 
-template <typename ltype, typename rtype, typename op_type, typename ltag>
-class polygon_set_view<ltype, rtype, op_type, ltag, operator_provides_storage> {
-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::const_iterator iterator_type;
- typedef polygon_set_view operator_arg_type;
-private:
- const ltype& lvalue_;
- const rtype& rvalue_;
- op_type op_;
- orientation_2d orient_;
- mutable value_type output_;
- mutable value_type linput_;
-public:
- polygon_set_view(const ltype& lvalue,
- const rtype& rvalue,
- orientation_2d orient,
- op_type op) :
- lvalue_(lvalue), rvalue_(rvalue), op_(op), orient_(orient) {}
-
- /// get iterator to begin vertex data
- const value_type& value() const {
- if(output_.empty()) {
- value_type linput_;
- value_type rinput_;
- insert_into_view_arg(linput_, lvalue_, orient_);
- if(orient_ != lvalue_.orient()) {
- insert_into_view_arg(rinput_, rvalue_, orient_);
- boolean_op::applyBooleanBinaryOp(output_, linput_, rinput_, boolean_op::BinaryCount<op_type>());
- } else {
- if(!rvalue_.sorted()) rvalue_.sort();
- boolean_op::applyBooleanBinaryOp(output_, linput_, rvalue_.value(), boolean_op::BinaryCount<op_type>());
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ typename polygon_set_view<ltype, rtype, op_type, ltag, rtag>::iterator_type
+ polygon_set_traits<polygon_set_view<ltype, rtype, op_type, ltag, rtag> >::
+ begin(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set) {
+ return polygon_set.begin();
+ }
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ typename polygon_set_view<ltype, rtype, op_type, ltag, rtag>::iterator_type
+ polygon_set_traits<polygon_set_view<ltype, rtype, op_type, ltag, rtag> >::
+ end(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set) {
+ return polygon_set.end();
+ }
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ template <typename input_iterator_type>
+ void polygon_set_traits<polygon_set_view<ltype, rtype, op_type, ltag, rtag> >::
+ set(polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set,
+ input_iterator_type input_begin, input_iterator_type input_end,
+ orientation_2d orient) {
+ polygon_set.set(input_begin, input_end, orient);
+ }
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ orientation_2d polygon_set_traits<polygon_set_view<ltype, rtype, op_type, ltag, rtag> >::
+ orient(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set) {
+ return polygon_set.orient(); }
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ bool polygon_set_traits<polygon_set_view<ltype, rtype, op_type, ltag, rtag> >::
+ dirty(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set) {
+ return polygon_set.dirty(); }
+ template <typename ltype, typename rtype, typename op_type, typename ltag, typename rtag>
+ bool polygon_set_traits<polygon_set_view<ltype, rtype, op_type, ltag, rtag> >::
+ sorted(const polygon_set_view<ltype, rtype, op_type, ltag, rtag>& polygon_set) {
+ return polygon_set.sorted(); }
+
+ template <typename value_type, typename arg_type>
+ inline void insert_into_view_arg(value_type& dest, const arg_type& arg, orientation_2d orient) {
+ typedef typename polygon_set_traits<arg_type>::iterator_type literator;
+ literator itr1, itr2;
+ itr1 = polygon_set_traits<arg_type>::begin(arg);
+ itr2 = polygon_set_traits<arg_type>::end(arg);
+ if(polygon_set_traits<arg_type>::orient(arg) == orient) {
+ for( ; itr1 != itr2; ++itr1) {
+ dest.push_back(*itr1);
+ }
+ if(!polygon_set_traits<arg_type>::sorted(arg)) std::sort(dest.begin(), dest.end());
+ } else {
+ iterator_vertex_orient_conversion<literator> citr2(itr2);
+ for(iterator_vertex_orient_conversion<literator> citr1(itr1); citr1 != citr2; ++citr1) {
+ dest.push_back(*citr1);
       }
+ std::sort(dest.begin(), dest.end());
     }
- 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
-
- //insert is not inteded to be called because a view is read only
- void insert(const value_type& value,
- orientation_2d orient) const {
- //throw a helpful exception
- }
- void sort() const {} //is always sorted
-};
-
+
 }
 #endif
 

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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -67,6 +67,7 @@
 
   inline void set(const std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >& value,
            orientation_2d orient) {
+ //TODO
   }
 
   inline orientation_2d orient() const { return HORIZONTAL; }
@@ -82,6 +83,66 @@
   return polygon_set_wrapper<T>(t);
 }
 
+ template <typename T>
+ struct polygon_set_traits<polygon_set_wrapper<T> > {
+ typedef typename polygon_set_wrapper<T>::coordinate_type coordinate_type;
+ typedef typename polygon_set_wrapper<T>::iterator_type iterator_type;
+ typedef T operator_arg_type;
+ typedef typename polygon_set_wrapper<T>::operator_storage_tag operator_storage_tag;
+
+ static inline iterator_type begin(const T& polygon_set) {
+ return wrap_const(polygon_set).begin();
+ }
+
+ static inline iterator_type end(const T& polygon_set) {
+ return wrap_const(polygon_set).end();
+ }
+
+ static inline void set(T& polygon_set,
+ const std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >& value,
+ orientation_2d orient) {
+ wrap(polygon_set).set(value, orient);
+ }
+
+ static inline orientation_2d orient(const T& polygon_set) { return HORIZONTAL; }
+
+ static inline bool dirty(const T& polygon_set) { return true; }
+
+ static inline bool sorted(const T& polygon_set) { return false; }
+
+ };
+
+ template <typename T>
+ struct polygon_set_traits<polygon_set_const_wrapper<T> > {
+ typedef typename polygon_set_const_wrapper<T>::coordinate_type coordinate_type;
+ typedef typename polygon_set_const_wrapper<T>::iterator_type iterator_type;
+ typedef T operator_arg_type;
+ typedef typename polygon_set_const_wrapper<T>::operator_storage_tag operator_storage_tag;
+
+ static inline iterator_type begin(const polygon_set_const_wrapper<T>& polygon_set) {
+ return polygon_set.begin();
+ }
+
+ static inline iterator_type end(const polygon_set_const_wrapper<T>& polygon_set) {
+ return polygon_set.end();
+ }
+
+ static inline void set(polygon_set_const_wrapper<T>& polygon_set,
+ const std::vector<std::pair<coordinate_type, std::pair<coordinate_type, int> > >& value,
+ orientation_2d orient) {
+ polygon_set.set(value, orient);
+ }
+
+ static inline orientation_2d orient(const polygon_set_const_wrapper<T>& polygon_set) { return polygon_set.orient(); }
+
+ static inline bool dirty(const polygon_set_const_wrapper<T>& polygon_set) { return polygon_set.dirty(); }
+
+ static inline bool sorted(const polygon_set_const_wrapper<T>& polygon_set) { return polygon_set.sorted(); }
+
+ };
+
+
+
 }
 #endif
 

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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -34,15 +34,15 @@
 };
 
 template <typename geometry_type>
-struct distance_type {
+struct coordinate_distance {
   typedef typename geometry_concept<geometry_type>::type::template
- distance_type<geometry_type>::type type;
+ coordinate_distance<geometry_type>::type type;
 };
 
 template <typename geometry_type>
-struct difference_type {
+struct coordinate_difference {
   typedef typename geometry_concept<geometry_type>::type::template
- difference_type<geometry_type>::type type;
+ coordinate_difference<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-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -34,13 +34,13 @@
   };
 
   template <typename T>
- struct difference_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::difference_type type;
+ struct coordinate_difference {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_difference type;
   };
 
   template <typename T>
- struct distance_type {
- typedef typename coordinate_traits<typename coordinate_type<T>::type>::distance_type type;
+ struct coordinate_distance {
+ typedef typename coordinate_traits<typename coordinate_type<T>::type>::coordinate_distance type;
   };
 
   template <typename T>
@@ -204,7 +204,7 @@
   /// move rectangle by delta in orient
   template <typename rectangle_type>
   static rectangle_type& move(rectangle_type& rectangle, orientation_2d orient,
- typename difference_type<rectangle_type>::type delta) {
+ typename coordinate_difference<rectangle_type>::type delta) {
     typename rectangle_traits<rectangle_type>::interval_type ivl = get(rectangle, orient);
     interval_concept::move(ivl, delta);
     set(rectangle, orient, ivl);
@@ -351,14 +351,14 @@
 
   /// get the half perimeter of the rectangle
   template <typename rectangle_type>
- static typename difference_type<rectangle_type>::type
+ static typename coordinate_difference<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 difference_type<rectangle_type>::type
+ static typename coordinate_difference<rectangle_type>::type
   perimeter(const rectangle_type& rectangle) {
     return 2 * half_perimeter(rectangle);
   }
@@ -574,39 +574,39 @@
   }
 
   template <typename rectangle_type, typename point_type>
- static typename difference_type<rectangle_type>::type
- distance(rectangle_type& lvalue, const point_type& rvalue,
+ static typename coordinate_difference<rectangle_type>::type
+ euclidean_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());
+ return interval_concept::euclidean_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,
+ static typename coordinate_difference<rectangle_type>::type
+ euclidean_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());
+ return interval_concept::euclidean_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
+ static typename coordinate_difference<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);
+ typename coordinate_difference<rectangle_type>::type xdist, ydist;
+ xdist = euclidean_distance(lvalue, rvalue, HORIZONTAL, tag);
+ ydist = euclidean_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)));
+ static typename coordinate_distance<rectangle_type>::type
+ euclidean_distance(rectangle_type& lvalue, const point_type& rvalue, tag_type tag) {
+ return sqrt((typename coordinate_distance<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
+ static typename coordinate_difference<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);
+ return euclidean_distance(lvalue, rvalue, HORIZONTAL, tag) + euclidean_distance(lvalue, rvalue, VERTICAL, tag);
   }
 
   template <typename rectangle_type_1, typename rectangle_type_2>

Modified: sandbox/gtl/gtl/rectangle_formation.hpp
==============================================================================
--- sandbox/gtl/gtl/rectangle_formation.hpp (original)
+++ sandbox/gtl/gtl/rectangle_formation.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -229,6 +229,28 @@
 
 }; //namespace rectangle_formation
   
+ template <typename output_container, typename iterator_type, typename rectangle_concept>
+ void get_rectangles(output_container& output, iterator_type begin, iterator_type end,
+ orientation_2d orient, rectangle_concept tag) {
+ typedef typename output_container::value_type rectangle_type;
+ typedef typename rectangle_concept::template coordinate_type<rectangle_type>::type Unit;
+ rectangle_data<Unit> model;
+ Unit prevPos = std::numeric_limits<Unit>::max();
+ rectangle_formation::ScanLineToRects<rectangle_type> scanlineToRects(orient, model);
+ for(iterator_type itr = begin;
+ itr != 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
+ }
+ }
 }
 #endif
 

Modified: sandbox/gtl/gtl/scan_arbitrary.hpp
==============================================================================
--- sandbox/gtl/gtl/scan_arbitrary.hpp (original)
+++ sandbox/gtl/gtl/scan_arbitrary.hpp 2008-07-18 19:51:12 EDT (Fri, 18 Jul 2008)
@@ -210,11 +210,11 @@
         multiplier *= -1;
       half_edge he;
       he.first = next_point;
- he.second[property] = multiplier * (point_concept::distance(next_point, current_point, HORIZONTAL) == 0 ? -1: 1);
+ he.second[property] = multiplier * (point_concept::euclidean_distance(next_point, current_point, HORIZONTAL) == 0 ? -1: 1);
       current_vertex.second.push_back(he);
       he.second.clear();
       he.first = previous_point;
- he.second[property] = -1 * multiplier * (point_concept::distance(previous_point, current_point, HORIZONTAL) == 0 ? -1: 1);
+ he.second[property] = -1 * multiplier * (point_concept::euclidean_distance(previous_point, current_point, HORIZONTAL) == 0 ? -1: 1);
       current_vertex.second.push_back(he);
       sort_vertex_half_edges(current_vertex);
     }
@@ -237,8 +237,8 @@
       const internal_point* pts[2] = {edge.first, edge.second};
       if(*(pts[0]) > *(pts[1]))
         std::swap(pts[0], pts[1]);
- internal_coordinate dx = point_concept::distance(*(pts[0]), *(pts[1]), HORIZONTAL);
- internal_coordinate dy = point_concept::distance(*(pts[0]), *(pts[1]), VERTICAL);
+ internal_coordinate dx = point_concept::euclidean_distance(*(pts[0]), *(pts[1]), HORIZONTAL);
+ internal_coordinate dy = point_concept::euclidean_distance(*(pts[0]), *(pts[1]), VERTICAL);
       internal_coordinate dx_intercept = coordinate - point_concept::get(*(pts[0]), HORIZONTAL);
       return point_concept::get(*(pts[0]), VERTICAL) + compute_intercept(dy, dx_intercept, dx);
     }


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