From 2b13859fb6abb08fa22ed924e909cc0c4a292768 Mon Sep 17 00:00:00 2001 From: Baruch Zukerman Date: Wed, 25 Jan 2006 18:08:15 +0000 Subject: [PATCH] 1st revision: adaptor from Ccb_circulator to iterator of x-monotone curves --- .../Ccb_curve_iterator.h | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 Packages/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Ccb_curve_iterator.h diff --git a/Packages/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Ccb_curve_iterator.h b/Packages/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Ccb_curve_iterator.h new file mode 100755 index 00000000000..d5b23e0bff0 --- /dev/null +++ b/Packages/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Ccb_curve_iterator.h @@ -0,0 +1,100 @@ + +#ifndef CGAL_CCB_CURVE_ITERATOR_H +#define CGAL_CCB_CURVE_ITERATOR_H + +CGAL_BEGIN_NAMESPACE + + /*! \class + * A circulator adapter that iterates over all curves in a CCB. + */ + template + class Ccb_curve_iterator + { + public: + + typedef Arrangement_ Arrangement; + typedef typename Arrangement::Traits_2 Traits; + typedef Ccb_curve_iterator Self; + typedef typename Arrangement::Ccb_halfedge_const_circulator + Ccb_halfedge_const_circulator; + typedef typename Traits::X_monotone_curve_2 value_type; + typedef std::forward_iterator_tag iterator_category; + typedef const value_type& reference; + typedef const value_type* pointer; + typedef std::size_t difference_type; + + private: + + Ccb_halfedge_const_circulator _first; // The first halfedge. + Ccb_halfedge_const_circulator _circ; // The current circulator. + bool _done; // Indicates whether we completed + // a full traversal of the CCB. + + public: + + /*! Default constructor. */ + Ccb_curve_iterator () : + _done (true) + {} + + /*! + * Constructor from a circulator. + * \param circ A circulator for the first halfedge in the CCB. + * \param done (true) in order to create a past-the-end iterator. + */ + Ccb_curve_iterator (Ccb_halfedge_const_circulator circ, + bool done = false) : + _first (circ), + _circ (circ), + _done (done) + {} + + /*! Dereference operators. */ + reference operator* () const + { + return (_circ->curve()); + } + + pointer operator-> () const + { + return (&(_circ->curve())); + } + + /*! Equality operators.*/ + bool operator== (const Self& it) const + { + return (_done == it._done && _circ == it._circ); + } + + bool operator!= (const Self& it) const + { + return (_done != it._done || _circ != it._circ); + } + + /*! Increment operators. */ + Self& operator++ () + { + CGAL_assertion(!_done); + + --_circ; + + if (_circ == _first) + _done = true; + + + return (*this); + } + + Self operator++ (int ) + { + Self temp = *this; + ++(*this); + return (temp); + } + + }; + + +CGAL_END_NAMESPACE + +#endif