|
Boost-Commit : |
From: lucanus.j.simonson_at_[hidden]
Date: 2008-05-13 01:55:07
Author: ljsimons
Date: 2008-05-13 01:55:06 EDT (Tue, 13 May 2008)
New Revision: 45317
URL: http://svn.boost.org/trac/boost/changeset/45317
Log:
fixed std compliance of lazy iterators
Text files modified:
sandbox/gtl/gtl/gtl.h | 7 +++++--
sandbox/gtl/gtl/iterator_compact_to_points.h | 8 +++++++-
sandbox/gtl/gtl/iterator_points_to_compact.h | 12 +++++++++---
sandbox/gtl/gtl/polygon_concept.h | 10 ++++------
sandbox/gtl/gtl/polygon_with_holes_concept.h | 38 ++++++++++++++++++--------------------
5 files changed, 43 insertions(+), 32 deletions(-)
Modified: sandbox/gtl/gtl/gtl.h
==============================================================================
--- sandbox/gtl/gtl/gtl.h (original)
+++ sandbox/gtl/gtl/gtl.h 2008-05-13 01:55:06 EDT (Tue, 13 May 2008)
@@ -13,6 +13,7 @@
#include <iostream>
#include <algorithm>
#include <limits>
+#include <iterator>
//isotropy types
#include "isotropy.h"
@@ -60,8 +61,10 @@
#include "boolean_op.h"
template <typename geometry_type_1, typename geometry_type_2>
-bool contains(const geometry_type_1& geometry_object, const geometry_type_2& contained_geometry_object) {
- typename geometry_traits<geometry_type_1>::geometry_concept().contains(geometry_object, contained_geometry_object);
+bool contains(const geometry_type_1& geometry_object, const geometry_type_2& contained_geometry_object,
+ bool consider_touch = true) {
+ typename geometry_traits<geometry_type_1>::geometry_concept().contains(geometry_object, contained_geometry_object,
+ consider_touch, typename geometry_traits<geometry_type_2>::geometry_concept());
}
template <typename geometry_type_1, typename geometry_type_2>
Modified: sandbox/gtl/gtl/iterator_compact_to_points.h
==============================================================================
--- sandbox/gtl/gtl/iterator_compact_to_points.h (original)
+++ sandbox/gtl/gtl/iterator_compact_to_points.h 2008-05-13 01:55:06 EDT (Tue, 13 May 2008)
@@ -14,6 +14,12 @@
typename point_traits<point_type>::coordinate_type firstX_;
orientation_2d orient_;
public:
+ typedef std::forward_iterator_tag iterator_category;
+ typedef point_type value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef const point_type* pointer; //immutable
+ typedef const point_type& reference; //immutable
+
inline iterator_compact_to_points() {}
inline iterator_compact_to_points(iterator_type iter, iterator_type iter_end) :
iter_(iter), iter_end_(iter_end), orient_(HORIZONTAL) {
@@ -51,5 +57,5 @@
inline bool operator!=(const iterator_compact_to_points& that) const {
return (iter_ != that.iter_);
}
- inline const point_type& operator*() const { return pt_; }
+ inline reference operator*() const { return pt_; }
};
Modified: sandbox/gtl/gtl/iterator_points_to_compact.h
==============================================================================
--- sandbox/gtl/gtl/iterator_points_to_compact.h (original)
+++ sandbox/gtl/gtl/iterator_points_to_compact.h 2008-05-13 01:55:06 EDT (Tue, 13 May 2008)
@@ -5,13 +5,19 @@
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
*/
-
-template <class iT, typename coordinate_type>
+template <class iT, typename point_type>
class iterator_points_to_compact {
private:
iT iter_;
orientation_2d orient_;
public:
+ typedef typename point_traits<point_type>::coordinate_type coordinate_type;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef coordinate_type value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef const coordinate_type* pointer; //immutable
+ typedef const coordinate_type& reference; //immutable
+
inline iterator_points_to_compact() {}
inline iterator_points_to_compact(iT iter) : iter_(iter), orient_(HORIZONTAL) {}
inline iterator_points_to_compact(const iterator_points_to_compact& that) :
@@ -33,5 +39,5 @@
inline bool operator!=(const iterator_points_to_compact& that) const {
return (iter_ != that.iter_);
}
- inline coordinate_type operator*() { return (*iter_).get(orient_); }
+ inline reference operator*() const { return point_concept::get(*iter_, orient_); }
};
Modified: sandbox/gtl/gtl/polygon_concept.h
==============================================================================
--- sandbox/gtl/gtl/polygon_concept.h (original)
+++ sandbox/gtl/gtl/polygon_concept.h 2008-05-13 01:55:06 EDT (Tue, 13 May 2008)
@@ -23,10 +23,8 @@
template<typename polygon_type, typename point_iterator_type>
static void set_points(polygon_type& polygon, point_iterator_type begin_point, point_iterator_type end_point) {
- return set(iterator_points_to_compact<point_iterator_type,
- typename polygon_traits<polygon_type>::coordinate_type>(begin_point),
- iterator_points_to_compact<point_iterator_type,
- typename polygon_traits<polygon_type>::coordinate_type>(end_point));
+ return set(iterator_points_to_compact<point_iterator_type, typename point_iterator_type::value_type>(begin_point),
+ iterator_points_to_compact<point_iterator_type, typename point_iterator_type::value_type>(end_point));
}
template <typename polygon_type>
@@ -203,8 +201,8 @@
/// check if point is inside polygon
template <typename polygon_type, typename point_type>
- static bool contains_point(const polygon_type& polygon, const point_type& point,
- bool consider_touch = true) {
+ static bool contains(const polygon_type& polygon, const point_type& point,
+ bool consider_touch, point_concept pc) {
typedef typename polygon_traits<polygon_type>::coordinate_type coordinate_type;
typedef typename polygon_traits<polygon_type>::iterator_type iterator_type;
typedef iterator_compact_to_points<iterator_type, point_data<coordinate_type> > iterator;
Modified: sandbox/gtl/gtl/polygon_with_holes_concept.h
==============================================================================
--- sandbox/gtl/gtl/polygon_with_holes_concept.h (original)
+++ sandbox/gtl/gtl/polygon_with_holes_concept.h 2008-05-13 01:55:06 EDT (Tue, 13 May 2008)
@@ -24,10 +24,8 @@
template<typename polygon_with_holes_type, typename point_iterator_type>
static void set_points(polygon_with_holes_type& polygon, point_iterator_type begin_point, point_iterator_type end_point) {
- return set(iterator_points_to_compact<point_iterator_type,
- typename polygon_traits<polygon_with_holes_type>::coordinate_type>(begin_point),
- iterator_points_to_compact<point_iterator_type,
- typename polygon_traits<polygon_with_holes_type>::coordinate_type>(end_point));
+ return set(iterator_points_to_compact<point_iterator_type, typename point_iterator_type::value_type>(begin_point),
+ iterator_points_to_compact<point_iterator_type, typename point_iterator_type::value_type>(end_point));
}
template<typename polygon_with_holes_type, typename hole_iterator_type>
@@ -130,16 +128,16 @@
/// check if point is inside polygon
template <typename polygon_with_holes_type, typename point_type>
- static bool contains_point(const polygon_with_holes_type& polygon, const point_type& point,
- bool consider_touch = true) {
+ static bool contains(const polygon_with_holes_type& polygon, const point_type& point,
+ bool consider_touch, point_concept pc) {
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) {
- if(polygon_concept::contains_point(*b, point, !consider_touch)) {
+ if(polygon_concept::contains(*b, point, !consider_touch, pc)) {
return false;
}
}
- return polygon_concept::contains_point(polygon, point, consider_touch);
+ return polygon_concept::contains(polygon, point, consider_touch, pc);
}
/// get the perimeter of the polygon
@@ -228,29 +226,29 @@
//std::cout << pwh << std::endl;
std::cout << "PolygonWithHoles test pattern 1 1 1 1 1 1 0 0 0 0 0 0\n";
std::cout << "PolygonWithHoles test pattern ";
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(1, 11))
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(1, 11), true, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(10, 10))
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(10, 10), true, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(10, 90))
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(10, 90), true, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(90, 90))
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(90, 90), true, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(90, 10))
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(90, 10), true, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(90, 80))
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(90, 80), true, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(12, 12))
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(12, 12), true, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(10, 10), false)
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(10, 10), false, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(10, 90), false)
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(10, 90), false, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(90, 90), false)
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(90, 90), false, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(90, 10), false)
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(90, 10), false, point_concept())
<< " " ;
- std::cout << polygon_with_holes_concept::contains_point(pwh, point_data<T>(90, 80), false)
+ std::cout << polygon_with_holes_concept::contains(pwh, point_data<T>(90, 80), false, point_concept())
<< "\n";
polygon_with_holes_concept::move(pwh, 5, 5);
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