From 9c8a469339b6ebd70b5924416ba7ad8969e7f3f3 Mon Sep 17 00:00:00 2001 From: Clement Jamin Date: Fri, 4 Apr 2014 16:06:33 +0200 Subject: [PATCH] Use transform_iterator instead of iterator_adaptor --- .../include/CGAL/Delaunay_triangulation.h | 13 ++-- Triangulation/include/CGAL/Triangulation.h | 59 ++++++++----------- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/Triangulation/include/CGAL/Delaunay_triangulation.h b/Triangulation/include/CGAL/Delaunay_triangulation.h index 31a95d39220..3f019752a9f 100644 --- a/Triangulation/include/CGAL/Delaunay_triangulation.h +++ b/Triangulation/include/CGAL/Delaunay_triangulation.h @@ -303,11 +303,14 @@ public: else { Substitute_point_in_vertex_iterator< - Full_cell::Vertex_handle_const_iterator> it(s->vertices_begin(), - dc_.infinite_vertex(), - &p_); - Orientation o = ori_(it, it + cur_dim_ + 1); - + typename Full_cell::Vertex_handle_const_iterator> + spivi(dc_.infinite_vertex(), &p_); + + Orientation o = ori_( + boost::make_transform_iterator(s->vertices_begin(), spivi), + boost::make_transform_iterator(s->vertices_begin() + cur_dim_ + 1, + spivi)); + if( POSITIVE == o ) ok = true; else if( o == NEGATIVE ) diff --git a/Triangulation/include/CGAL/Triangulation.h b/Triangulation/include/CGAL/Triangulation.h index 005c0eb08ff..777c2d6e989 100644 --- a/Triangulation/include/CGAL/Triangulation.h +++ b/Triangulation/include/CGAL/Triangulation.h @@ -29,9 +29,6 @@ #include #include -#include - - namespace CGAL { template < class TriangulationTraits, class TDS_ = Default > @@ -92,44 +89,35 @@ protected: // dereferenced. If the current // vertex_handle vh == vh_where_point_should_be_substituted, it returns // "subtitute_point", otherwise, it returns vh->point() - template - class Substitute_point_in_vertex_iterator - : public boost::iterator_adaptor< - Substitute_point_in_vertex_iterator // Derived - , Vertex_iterator // Base - , typename Vertex_iterator::value_type::value_type::Point // Value - , boost::use_default // CategoryOrTraversal - , typename Vertex_iterator::value_type::value_type::Point const & // Reference - > + template + class Substitute_point_in_vertex_iterator { - typedef typename Vertex_iterator::value_type Vertex_handle; - typedef typename Vertex_handle::value_type::Point Point; - public: - Substitute_point_in_vertex_iterator() - : Substitute_point_in_vertex_iterator::iterator_adaptor_(Vertex_iterator()) {} + typedef typename VertexHandleConstIter::value_type Vertex_handle; + typedef typename Vertex_handle::value_type Vertex; + typedef typename Vertex::Point Point; - explicit Substitute_point_in_vertex_iterator( - Vertex_iterator it, - const Vertex_handle &vh_where_point_should_be_substituted, - const Point *subtitute_point) - : Substitute_point_in_vertex_iterator::iterator_adaptor_(it) - , vh_where_point_should_be_substituted_(vh_where_point_should_be_substituted) + public: + typedef Point const& result_type; // For result_of + + Substitute_point_in_vertex_iterator( + Vertex_handle vh_where_point_should_be_substituted, + Point const *subtitute_point) + : vh_where_point_should_be_substituted_(vh_where_point_should_be_substituted) , subtitute_point_(subtitute_point) {} - private: - friend class boost::iterator_core_access; - - typename iterator_adaptor::reference dereference() const + result_type operator()(Vertex_handle vh) const { - if (*this->base() == vh_where_point_should_be_substituted_) + if (vh == vh_where_point_should_be_substituted_) return *subtitute_point_; else - return (*this->base())->point(); + return vh->point(); } + private: Vertex_handle vh_where_point_should_be_substituted_; - const Point *subtitute_point_; + Point const *subtitute_point_; + }; public: @@ -1011,10 +999,13 @@ Triangulation } Substitute_point_in_vertex_iterator< - Full_cell::Vertex_handle_const_iterator> it(s->vertices_begin(), - s->vertex(i), - &p); - orientations_[i] = orientation_pred(it, it + cur_dim + 1); + typename Full_cell::Vertex_handle_const_iterator> + spivi(s->vertex(i), &p); + + orientations_[i] = orientation_pred( + boost::make_transform_iterator(s->vertices_begin(), spivi), + boost::make_transform_iterator(s->vertices_begin() + cur_dim + 1, + spivi)); if( orientations_[i] != NEGATIVE ) {