diff --git a/Arrangement_2/include/CGAL/Arr_dcel_base.h b/Arrangement_2/include/CGAL/Arr_dcel_base.h index e7f0d65a353..24a0145ec6c 100644 --- a/Arrangement_2/include/CGAL/Arr_dcel_base.h +++ b/Arrangement_2/include/CGAL/Arr_dcel_base.h @@ -33,6 +33,8 @@ #include #include #include +#include +#include CGAL_BEGIN_NAMESPACE @@ -60,6 +62,7 @@ inline bool _is_lsb_set (const void* p) return ((val & mask) != 0); } + /*! \class * Base vertex class. */ @@ -297,6 +300,7 @@ public: Isolated_vertex_const_iterator; protected: +public: void *p_he; // An incident halfedge along the face boundary. // The LSB of the pointer indicates whether @@ -637,19 +641,11 @@ public: return; } - // Define the hole iterators: - typedef I_HalfedgeDS_iterator< - typename F::Hole_iterator, - Halfedge*, - typename F::Hole_iterator::difference_type, - typename F::Hole_iterator::iterator_category> Hole_iterator; - - typedef I_HalfedgeDS_const_iterator< - typename F::Hole_const_iterator, - typename F::Hole_iterator, - const Halfedge*, - typename F::Hole_const_iterator::difference_type, - typename F::Hole_const_iterator::iterator_category> Hole_const_iterator; + typedef Cast_function_object HolePtr2HalfedgePtrCast ; + + typedef Iterator_project Hole_iterator ; + typedef Iterator_project Hole_const_iterator ; + /*! Get the number of holes inside the face. */ size_t number_of_holes() const diff --git a/Arrangement_2/include/CGAL/Arrangement_2.h b/Arrangement_2/include/CGAL/Arrangement_2.h index 63492f9d6ef..e2d2d7a2c0d 100644 --- a/Arrangement_2/include/CGAL/Arrangement_2.h +++ b/Arrangement_2/include/CGAL/Arrangement_2.h @@ -41,6 +41,10 @@ #include #include +#include +#include +#include + CGAL_BEGIN_NAMESPACE /*! \class @@ -353,28 +357,50 @@ public: Halfedge_const_iterator, Bidirectional_circulator_tag> Ccb_halfedge_const_circulator; - typedef I_HalfedgeDS_iterator - Hole_iterator; +private: + + struct HalfedgePtrToCirculator + { + typedef DHalfedge* argument_type ; + typedef Ccb_halfedge_circulator result_type ; + + result_type operator() ( argument_type const& s ) const + { + return Ccb_halfedge_circulator( Halfedge_iterator(s) ) ; + } + } ; + + struct HalfedgeConstPtrToConstCirculator + { + typedef DHalfedge const* argument_type ; + typedef Ccb_halfedge_const_circulator result_type ; + + result_type operator() ( argument_type const& s ) const + { + return Ccb_halfedge_const_circulator( Halfedge_const_iterator(s) ) ; + } + } ; + + typedef Cast_function_object DVertexToVertexCast ; + + typedef Iterator_project Isolated_vertex_iterator_base ; + typedef Iterator_project Isolated_vertex_const_iterator_base ; + +public : + + typedef Iterator_transform Hole_iterator ; + typedef Iterator_transform Hole_const_iterator ; + - typedef I_HalfedgeDS_const_iterator - Hole_const_iterator; /*! \class * Isolated vertices iterator - defined as a class to make it assignable * to the vertex iterator type. */ - class Isolated_vertex_iterator : - public I_HalfedgeDS_iterator + + class Isolated_vertex_iterator : public Isolated_vertex_iterator_base { - typedef I_HalfedgeDS_iterator Base; + typedef Isolated_vertex_iterator_base Base ; public: @@ -397,16 +423,9 @@ public: } }; - class Isolated_vertex_const_iterator : - public I_HalfedgeDS_const_iterator + class Isolated_vertex_const_iterator : public Isolated_vertex_const_iterator_base { - typedef I_HalfedgeDS_const_iterator Base; + typedef Isolated_vertex_const_iterator_base Base ; public: @@ -532,16 +551,21 @@ protected: } }; - /*! \class - * An iterator for traversing all arrangement edges (including the - * fictitious ones). - */ - class _All_edge_iterator : - public I_HalfedgeDS_iterator + + + typedef Cast_function_object DHalfedgeToHalfedgeCast ; + + typedef Iterator_project _All_edge_iterator_base; + typedef Iterator_project _All_edge_const_iterator_base; + + + //! \class + //! An iterator for traversing all arrangement edges (including the fictitious ones). + //! + + class _All_edge_iterator : public _All_edge_iterator_base { - typedef I_HalfedgeDS_iterator Base; + typedef _All_edge_iterator_base Base; public: @@ -565,14 +589,9 @@ protected: } }; - class _All_edge_const_iterator : - public I_HalfedgeDS_const_iterator + class _All_edge_const_iterator : public _All_edge_const_iterator_base { - typedef I_HalfedgeDS_const_iterator Base; + typedef _All_edge_const_iterator_base Base; public: @@ -586,6 +605,11 @@ protected: _All_edge_const_iterator (DEdge_const_iter iter) : Base (iter) {} + + _All_edge_const_iterator ( _All_edge_iterator const& iter) : + Base (iter) + {} + // Casting to a halfedge iterator. operator Halfedge_const_iterator () const @@ -595,6 +619,7 @@ protected: } }; + public: // Definition of handles (equivalent to iterators): diff --git a/Arrangement_2/include/CGAL/Arrangement_2/Arrangement_2_iterators.h b/Arrangement_2/include/CGAL/Arrangement_2/Arrangement_2_iterators.h index 851b60a32b6..b0cb1eceea2 100644 --- a/Arrangement_2/include/CGAL/Arrangement_2/Arrangement_2_iterators.h +++ b/Arrangement_2/include/CGAL/Arrangement_2/Arrangement_2_iterators.h @@ -85,7 +85,7 @@ public: pointer ptr () const { - return (reinterpret_cast (*iter)); + return (static_cast (*iter)); } reference operator* () const @@ -199,7 +199,7 @@ public: pointer ptr () const { - return (reinterpret_cast (*iter)); + return (static_cast (*iter)); } reference operator* () const @@ -283,11 +283,13 @@ public: /*! Constructors. */ I_Filtered_iterator() - {} + { + } I_Filtered_iterator (Iterator it) : - nt (it) - {} + nt (it), iend(it) + { + } I_Filtered_iterator (Iterator it, Iterator end) : nt (it), @@ -325,7 +327,7 @@ public: pointer ptr() const { - return (pointer)(&(*nt)); + return static_cast(&(*nt)); } /*! Equality operators. */ @@ -385,6 +387,7 @@ public: --(*this); return tmp; } + }; /*! @@ -429,11 +432,13 @@ public: /*! Constructors. */ I_Filtered_const_iterator() - {} + { + } I_Filtered_const_iterator (Iterator it) : - nt (it) - {} + nt (it), iend(it) + { + } I_Filtered_const_iterator (Iterator it, Iterator end) : nt (it), @@ -457,7 +462,8 @@ public: nt (it.current_iterator()), iend (it.past_the_end()), filt (it.filter()) - {} + { + } /*! Access operations. */ Iterator current_iterator() const @@ -477,7 +483,7 @@ public: pointer ptr() const { - return (pointer)(&(*nt)); + return static_cast(&(*nt)); } /*! Equality operators. */ @@ -537,6 +543,7 @@ public: --(*this); return tmp; } + }; CGAL_END_NAMESPACE