diff --git a/.gitattributes b/.gitattributes index c0ef5aa9cc1..0bb56aff483 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1387,6 +1387,7 @@ Combinatorial_map/include/CGAL/Cell_iterators.h -text Combinatorial_map/include/CGAL/Combinatorial_map.h -text Combinatorial_map/include/CGAL/Combinatorial_map_basic_operations.h -text Combinatorial_map/include/CGAL/Combinatorial_map_constructors.h -text +Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h -text Combinatorial_map/include/CGAL/Combinatorial_map_min_items.h -text Combinatorial_map/include/CGAL/Combinatorial_map_operations.h -text Combinatorial_map/include/CGAL/Dart.h -text @@ -1394,6 +1395,7 @@ Combinatorial_map/include/CGAL/Dart_const_iterators.h -text Combinatorial_map/include/CGAL/Dart_iterators.h -text Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h -text Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h -text +Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility_novariadic.h -text Combinatorial_map/package_info/Combinatorial_map/description.txt -text Combinatorial_map/package_info/Combinatorial_map/long_description.txt -text Combinatorial_map/package_info/Combinatorial_map/maintainer -text diff --git a/Combinatorial_map/include/CGAL/Cell_iterators.h b/Combinatorial_map/include/CGAL/Cell_iterators.h index 376268a52fe..bcf1b11ba0b 100644 --- a/Combinatorial_map/include/CGAL/Cell_iterators.h +++ b/Combinatorial_map/include/CGAL/Cell_iterators.h @@ -31,9 +31,10 @@ namespace CGAL { * All the cell iterators. Not commented in doxygen to avoid too much * classes in the documentation. * There are 3 classes: - * - CMap_cell_iterator - * - CMap_one_dart_per_incident_cell_iterator - * - CMap_one_dart_per_cell_iterator + * - CMap_cell_iterator: "tools" class used for the + * two following iterators. + * * - CMap_one_dart_per_incident_cell_iterator + * * - CMap_one_dart_per_cell_iterator */ //**************************************************************************** @@ -88,7 +89,8 @@ namespace CGAL { Ite(amap, adart, amap.get_new_mark()), mcell_mark_number(amap.get_new_mark()) { - CGAL_assertion( Ite::is_basic_iterator() ); + CGAL_static_assertion( (boost::is_same::value) ); CGAL_assertion(amap.is_whole_map_unmarked(mcell_mark_number)); mark_cell(amap, adart, mcell_mark_number); @@ -195,8 +197,9 @@ namespace CGAL { CMap_cell_iterator(Map& amap, Dart_handle adart): Ite(amap, adart), mmark_number(amap.get_new_mark()) - { - CGAL_assertion( Ite::is_basic_iterator() ); + { + CGAL_static_assertion( (boost::is_same::value) ); CGAL_assertion(amap.is_whole_map_unmarked(mmark_number)); mark_cell(amap, adart, mmark_number); } @@ -298,7 +301,8 @@ namespace CGAL { Base(amap), mmark_number(amap.get_new_mark()) { - CGAL_assertion( Base::is_basic_iterator() ); + CGAL_static_assertion( (boost::is_same::value) ); CGAL_assertion(amap.is_whole_map_unmarked(mmark_number)); mark_cell(amap, (*this), mmark_number); } @@ -379,6 +383,9 @@ namespace CGAL { typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Map Map; + typedef Tag_false Use_mark; + typedef Tag_false Basic_iterator; + /// Main constructor. CMap_one_dart_per_incident_cell_iterator(Map& amap, Dart_handle adart): Base(amap, adart) @@ -402,6 +409,9 @@ namespace CGAL { typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Map Map; + + typedef Tag_false Use_mark; + typedef Tag_false Basic_iterator; /// Main constructor. CMap_one_dart_per_cell_iterator(Map& amap): Base(amap) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index ee296f30910..47b04386c4c 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -694,7 +694,8 @@ namespace CGAL { template < class Ite > std::ostream& display_orbits(std::ostream & aos) const { - CGAL_assertion( Ite::is_basic_iterator() ); + CGAL_static_assertion( (boost::is_same::value) ); unsigned int nb = 0; int amark = get_new_mark(); for (typename Dart_range::const_iterator it1(darts().begin()), @@ -1197,12 +1198,12 @@ namespace CGAL { template void group_enabled_attribute( Dart_handle adart1, Dart_handle adart2) { + CGAL_static_assertion(i<=dimension); CGAL_static_assertion_msg( Helper::template Dimension_index::value>=0, "group_enabled_attribute but " "i-attributes are disabled"); CGAL_assertion(adart1 != NULL && adart2 != NULL); CGAL_assertion(adart1 != null_dart_handle && adart2 != null_dart_handle); - CGAL_assertion(i<=dimension); typename Attribute_handle::type a1=adart1->template attribute(); typename Attribute_handle::type a2=adart2->template attribute(); @@ -1249,12 +1250,12 @@ namespace CGAL { template void group_enabled_attribute_of_dart( Dart_handle dh1, Dart_handle dh2) { + CGAL_static_assertion(i<=dimension); CGAL_static_assertion_msg( Helper::template Dimension_index::value>=0, "group_enabled_attribute_of_dart but " "i-attributes are disabled"); CGAL_assertion( dh1!=NULL && dh2!=NULL ); CGAL_assertion( dh1!=null_dart_handle && dh2!=null_dart_handle ); - CGAL_assertion(i<=dimension); typename Attribute_handle::type a1=dh1->template attribute(); typename Attribute_handle::type a2=dh2->template attribute(); @@ -1296,6 +1297,7 @@ namespace CGAL { template bool degroup_enabled_attribute(Dart_handle adart1, Dart_handle adart2) { + CGAL_static_assertion(i<=dimension); CGAL_static_assertion_msg( Helper::template Dimension_index::value>=0, "degroup_enabled_attribute but " "i-attributes are disabled"); @@ -1368,12 +1370,12 @@ namespace CGAL { template bool degroup_enabled_attribute_of_dart( Dart_handle dh1, Dart_handle dh2) { + CGAL_static_assertion(i<=dimension); CGAL_static_assertion_msg( Helper::template Dimension_index::value>=0, "group_enabled_attribute_of_dart but " "i-attributes are disabled"); CGAL_assertion( dh1!=NULL && dh2!=NULL ); CGAL_assertion( dh1!=null_dart_handle && dh2!=null_dart_handle ); - CGAL_assertion(i<=dimension); typename Attribute_handle::type a1=dh1->template attribute(); typename Attribute_handle::type a2=dh2->template attribute(); @@ -1474,6 +1476,7 @@ namespace CGAL { void set_attribute_of_dart(Dart_handle adart, typename Attribute_handle::type ah) { + CGAL_static_assertion(i<=dimension); CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, "set_attribute_of_dart but " "i-attributes are disabled"); @@ -1494,6 +1497,7 @@ namespace CGAL { void set_attribute(Dart_handle adart, typename Attribute_handle::type ah) { + CGAL_static_assertion(i<=dimension); CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, "set_attribute but i-attributes are disabled"); CGAL_assertion( adart!=NULL && adart!=null_dart_handle && ah!=NULL ); @@ -1510,343 +1514,744 @@ namespace CGAL { } #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - //**************************************************************************** + //************************************************************************** + // Dart_of_orbit_basic_range + template + struct Dart_of_orbit_basic_range : public CMap_range + , + CMap_dart_const_iterator_basic_of_orbit > + { + typedef CMap_range + , + CMap_dart_const_iterator_basic_of_orbit > Base; + + Dart_of_orbit_basic_range(Self &amap, Dart_handle adart, int amark=-1): + Base(amap, adart, amark) + {} + }; + //************************************************************************** + // Dart_of_orbit_basic_const_range + template + struct Dart_of_orbit_basic_const_range : public CMap_const_range + > + { + typedef CMap_const_range + > Base; + + Dart_of_orbit_basic_const_range(const Self &amap, Dart_const_handle adart, + int amark=-1): + Base(amap, adart, amark) + {} + }; + //************************************************************************** // Dart_of_orbit_range template - struct Dart_of_orbit_range { - typedef CMap_dart_iterator_of_orbit iterator; - typedef CMap_dart_const_iterator_of_orbit const_iterator; - Dart_of_orbit_range(Self &amap, Dart_handle adart) : - mmap(amap), mdart(adart), msize(0) + struct Dart_of_orbit_range : public CMap_range + , + CMap_dart_const_iterator_of_orbit > + { + typedef CMap_range + , + CMap_dart_const_iterator_of_orbit > Base; + + Dart_of_orbit_range(Self &amap, Dart_handle adart) : Base(amap,adart) {} - iterator begin() { return iterator(mmap,mdart); } - iterator end() { return iterator(mmap,NULL); } - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( iterator it=begin(),itend=end(); it!=itend; ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - Self & mmap; - Dart_handle mdart; - size_type msize; }; - //**************************************************************************** + //************************************************************************** // Dart_of_orbit_const_range template - struct Dart_of_orbit_const_range { - typedef CMap_dart_const_iterator_of_orbit const_iterator; - Dart_of_orbit_const_range(const Self &amap, Dart_const_handle adart) : - mmap(amap), mdart(adart), msize(0) + struct Dart_of_orbit_const_range : public CMap_const_range + > + { + typedef CMap_const_range + > Base; + + Dart_of_orbit_const_range(const Self &amap, Dart_const_handle adart): + Base(amap,adart) {} - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( const_iterator it=begin(),itend=end(); it!=itend; ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - const Self & mmap; - Dart_const_handle mdart; - size_type msize; }; -#else - //**************************************************************************** - // Dart_of_orbit_range - template - struct Dart_of_orbit_range { - typedef CMap_dart_iterator_of_orbit - iterator; - typedef CMap_dart_const_iterator_of_orbit - const_iterator; - Dart_of_orbit_range(Self &amap, Dart_handle adart) : - mmap(amap), mdart(adart), msize(0) - {} - iterator begin() { return iterator(mmap,mdart); } - iterator end() { return iterator(mmap,NULL); } - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( iterator it=begin(),itend=end(); it!=itend; ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - Self & mmap; - Dart_handle mdart; - size_type msize; - }; - //**************************************************************************** - // Dart_of_orbit_const_range - template - struct Dart_of_orbit_const_range { - typedef CMap_dart_const_iterator_of_orbit - const_iterator; - Dart_of_orbit_const_range(const Self &amap, Dart_const_handle adart) : - mmap(amap), mdart(adart), msize(0) - {} - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( const_iterator it=begin(),itend=end(); it!=itend; ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - const Self & mmap; - Dart_const_handle mdart; - size_type msize; - }; -#endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - //**************************************************************************** - // Dart_of_cell_range - template - struct Dart_of_cell_range { - typedef CMap_dart_iterator_of_cell iterator; - typedef CMap_dart_const_iterator_of_cell const_iterator; - Dart_of_cell_range(Self &amap, Dart_handle adart) : - mmap(amap), mdart(adart), msize(0) - {} - iterator begin() { return iterator(mmap,mdart); } - iterator end() { return iterator(mmap,NULL); } - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - Self & mmap; - Dart_handle mdart; - size_type msize; - }; - //**************************************************************************** - // Dart_of_cell_const_range - template - struct Dart_of_cell_const_range { - typedef CMap_dart_const_iterator_of_cell const_iterator; - Dart_of_cell_const_range(const Self &amap, Dart_const_handle adart) : - mmap(amap), mdart(adart), msize(0) - {} - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( const_iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - const Self & mmap; - Dart_const_handle mdart; - size_type msize; - }; - //**************************************************************************** - -#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + //************************************************************************** /// @return a range on all the darts of the given orbit template Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_orbit_const_range darts_of_orbit(Dart_const_handle adart) const { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic(Dart_handle adart, + int amark=-1) + { return Dart_of_orbit_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range + darts_of_orbit_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range(*this,adart,amark); } + //************************************************************************** #else + //************************************************************************** + // Dart_of_orbit_basic_range + template + struct Dart_of_orbit_basic_range: public CMap_range + , + CMap_dart_const_iterator_basic_of_orbit > + { + typedef CMap_range + , + CMap_dart_const_iterator_basic_of_orbit > + Base; + + Dart_of_orbit_basic_range(Self &amap, Dart_handle adart, int amark=-1): + Base(amap, adart) + {} + }; + //************************************************************************** + // Dart_of_orbit_basic_const_range + template + struct Dart_of_orbit_basic_const_range: public CMap_const_range + > + { + typedef CMap_const_range > + Base; + + Dart_of_orbit_basic_const_range(const Self &amap, Dart_const_handle adart, + int amark=-1): + Base(amap, adart, amark) + {} + }; + //************************************************************************** + // Dart_of_orbit_range + template + struct Dart_of_orbit_range: public CMap_range + , + CMap_dart_const_iterator_of_orbit > + { + typedef CMap_range + , + CMap_dart_const_iterator_of_orbit > + Base; + + Dart_of_orbit_range(Self &amap, Dart_handle adart): + Base(amap, adart) + {} + }; + //************************************************************************** + // Dart_of_orbit_const_range + template + struct Dart_of_orbit_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > + Base; + + Dart_of_orbit_const_range(const Self &amap, Dart_const_handle adart): + Base(amap, adart) + {} + }; + //************************************************************************** /// @return a range on all the darts of the given orbit Dart_of_orbit_range<> darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range<>(*this,adart); } - Dart_of_orbit_const_range<> darts_of_orbit(Dart_const_handle adart) const - { return Dart_of_orbit_const_range<>(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } - template - Dart_of_orbit_const_range darts_of_orbit(Dart_const_handle - adart) const - { return Dart_of_orbit_const_range(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } - template - Dart_of_orbit_const_range darts_of_orbit(Dart_const_handle - adart) const - { return Dart_of_orbit_const_range(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } - template - Dart_of_orbit_range darts_of_orbit(Dart_const_handle adart) const - { return Dart_of_orbit_range(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } - template - Dart_of_orbit_const_range - darts_of_orbit(Dart_const_handle adart) const - { return Dart_of_orbit_const_range(*this,adart); } - + //-------------------------------------------------------------------------- template + unsigned int B5> Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } + //-------------------------------------------------------------------------- template - Dart_of_orbit_const_range - darts_of_orbit(Dart_const_handle adart) const - { return Dart_of_orbit_const_range(*this,adart); } - - template + unsigned int B5,unsigned int B6> Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } - template - Dart_of_orbit_const_range - darts_of_orbit(Dart_const_handle adart) const - { return Dart_of_orbit_const_range(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } + //-------------------------------------------------------------------------- template - Dart_of_orbit_const_range - darts_of_orbit(Dart_const_handle adart) const - { return Dart_of_orbit_const_range(*this,adart); } - - template + unsigned int B5,unsigned int B6,unsigned int B7,unsigned int B8> Dart_of_orbit_range darts_of_orbit (Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } + //-------------------------------------------------------------------------- template - Dart_of_orbit_const_range - darts_of_orbit(Dart_const_handle adart) const - { return Dart_of_orbit_const_range(*this,adart); } - - template + unsigned int B5,unsigned int B6,unsigned int B7,unsigned int B8, + unsigned int B9> Dart_of_orbit_range darts_of_orbit(Dart_handle adart) { return Dart_of_orbit_range(*this,adart); } + //-------------------------------------------------------------------------- + // Const versions. + Dart_of_orbit_const_range<> darts_of_orbit(Dart_const_handle adart) const + { return Dart_of_orbit_const_range<>(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_const_range darts_of_orbit(Dart_const_handle + adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_const_range darts_of_orbit(Dart_const_handle + adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_const_range darts_of_orbit + (Dart_const_handle adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_const_range + darts_of_orbit(Dart_const_handle adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- template + unsigned int B5> + Dart_of_orbit_const_range + darts_of_orbit(Dart_const_handle adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_const_range + darts_of_orbit(Dart_const_handle adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_const_range + darts_of_orbit(Dart_const_handle adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_const_range + darts_of_orbit(Dart_const_handle adart) const + { return Dart_of_orbit_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template Dart_of_orbit_const_range darts_of_orbit(Dart_const_handle adart) const { return Dart_of_orbit_const_range - (*this,adart); } + (*this,adart); } + //-------------------------------------------------------------------------- + // Basic versions + Dart_of_orbit_basic_range<> darts_of_orbit_basic(Dart_handle adart, + int amark=-1) + { return Dart_of_orbit_basic_range<>(*this,adart,amark); } + //-------------------------------------------------------------------------- + Dart_of_orbit_basic_const_range<> darts_of_orbit_basic + (Dart_const_handle adart,int amark=-1) const + { return Dart_of_orbit_basic_const_range<>(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic(Dart_handle adart, + int amark=-1) + { return Dart_of_orbit_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range darts_of_orbit_basic + (Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic(Dart_handle adart, + int amark=-1) + { return Dart_of_orbit_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range darts_of_orbit_basic + (Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic(Dart_handle adart, + int amark=-1) + { return Dart_of_orbit_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range darts_of_orbit_basic + (Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic + (Dart_handle adart, int amark=-1) + { return Dart_of_orbit_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range + darts_of_orbit_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic + (Dart_handle adart, int amark=-1) + { return Dart_of_orbit_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range + darts_of_orbit_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic + (Dart_handle adart, int amark=-1) + { return Dart_of_orbit_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range + darts_of_orbit_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit_basic + (Dart_handle adart, int amark=-1) + { return Dart_of_orbit_basic_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range + darts_of_orbit_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range darts_of_orbit + (Dart_handle adart, int amark=-1) + { return Dart_of_orbit_basic_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range + darts_of_orbit_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_range + darts_of_orbit_basic(Dart_handle adart, int amark=-1) + { return Dart_of_orbit_basic_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_orbit_basic_const_range + darts_of_orbit_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_orbit_basic_const_range + (*this,adart,amark); } + //************************************************************************** #endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - + //************************************************************************** + // Dart_of_cell_basic_range + template + struct Dart_of_cell_basic_range: public CMap_range + , + CMap_dart_const_iterator_basic_of_cell > + { + typedef CMap_range + , + CMap_dart_const_iterator_basic_of_cell > Base; + + Dart_of_cell_basic_range(Self &amap, Dart_handle adart, int amark=-1) : + Base(amap, adart, amark) + {} + }; + //************************************************************************** + // Dart_of_cell_basic_const_range + template + struct Dart_of_cell_basic_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > Base; + + Dart_of_cell_basic_const_range(const Self &amap, Dart_const_handle adart, + int amark=-1) : + Base(amap, adart, amark) + {} + }; + //************************************************************************** + // Dart_of_cell_range + template + struct Dart_of_cell_range: public CMap_range + , + CMap_dart_const_iterator_of_cell > + { + typedef CMap_range + , + CMap_dart_const_iterator_of_cell > Base; + + Dart_of_cell_range(Self &amap, Dart_handle adart) : + Base(amap, adart) + {} + }; + //************************************************************************** + // Dart_of_cell_const_range + template + struct Dart_of_cell_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > Base; + + Dart_of_cell_const_range(const Self &amap, Dart_const_handle adart) : + Base(amap, adart) + {} + }; + //-------------------------------------------------------------------------- /// @return a range on all the darts of the given i-cell template + Dart_of_cell_basic_range darts_of_cell_basic(Dart_handle adart, + int amark=-1) + { return Dart_of_cell_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_cell_basic_const_range darts_of_cell_basic + (Dart_const_handle adart, int amark=-1) const + { return Dart_of_cell_basic_const_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_cell_basic_range + darts_of_cell_basic(Dart_handle adart, int amark=-1) + { return darts_of_cell_basic(adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_cell_basic_const_range + darts_of_cell_basic(Dart_const_handle adart, int amark=-1) const + { return darts_of_cell_basic(adart,amark); } + //-------------------------------------------------------------------------- + template Dart_of_cell_range darts_of_cell(Dart_handle adart) { return Dart_of_cell_range(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_cell_const_range darts_of_cell(Dart_const_handle adart) const { return Dart_of_cell_const_range(*this,adart); } - + //-------------------------------------------------------------------------- template Dart_of_cell_range darts_of_cell(Dart_handle adart) { return darts_of_cell(adart); } - + //-------------------------------------------------------------------------- template Dart_of_cell_const_range darts_of_cell(Dart_const_handle adart) const - { return darts_of_cell(adart); } - + { return darts_of_cell(adart); } + //************************************************************************** + // Dart_of_involution_basic_range + template + struct Dart_of_involution_basic_range: public CMap_range + , + CMap_dart_const_iterator_basic_of_involution > + { + typedef CMap_range + , + CMap_dart_const_iterator_basic_of_involution > Base; + + Dart_of_involution_basic_range(Self &amap, Dart_handle adart, + int amark=-1): + Base(amap, adart, amark) + {} + }; + //************************************************************************** + // Dart_of_involution_basic_const_range + template + struct Dart_of_involution_basic_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > Base; + + Dart_of_involution_basic_const_range(const Self &amap, + Dart_const_handle adart, + int amark=-1) : + Base(amap, adart, amark) + {} + }; + //************************************************************************** + template + Dart_of_involution_basic_range + darts_of_involution_basic(Dart_handle adart, int amark=-1) + { return Dart_of_involution_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_basic_const_range + darts_of_involution_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_involution_basic_const_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_basic_range + darts_of_involution_basic(Dart_handle adart, int amark=-1) + { return Dart_of_involution_basic_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_basic_const_range + darts_of_involution_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_involution_basic_const_range + (*this,adart,amark); } + //************************************************************************** + // Dart_of_involution_inv_basic_range + template + struct Dart_of_involution_inv_basic_range: public CMap_range + , + CMap_dart_const_iterator_basic_of_involution_inv > + { + typedef CMap_range + , + CMap_dart_const_iterator_basic_of_involution_inv > Base; + + Dart_of_involution_inv_basic_range(Self &amap, Dart_handle adart, + int amark=-1): + Base(amap, adart, amark) + {} + }; + //************************************************************************** + // Dart_of_involution_inv_basic_const_range + template + struct Dart_of_involution_inv_basic_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > + Base; + + Dart_of_involution_inv_basic_const_range(const Self &amap, + Dart_const_handle adart, + int amark=-1) : + Base(amap, adart, amark) + {} + }; + //************************************************************************** + template + Dart_of_involution_inv_basic_range + darts_of_involution_inv_basic(Dart_handle adart, int amark=-1) + { return Dart_of_involution_inv_basic_range(*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_inv_basic_const_range + darts_of_involution_inv_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_involution_inv_basic_const_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_inv_basic_range + darts_of_involution_inv_basic(Dart_handle adart, int amark=-1) + { return Dart_of_involution_inv_basic_range + (*this,adart,amark); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_inv_basic_const_range + darts_of_involution_inv_basic(Dart_const_handle adart, int amark=-1) const + { return Dart_of_involution_inv_basic_const_range + (*this,adart,amark); } + //************************************************************************** + // Dart_of_involution_range + template + struct Dart_of_involution_range: public CMap_range + , + CMap_dart_const_iterator_of_involution > + { + typedef CMap_range + , + CMap_dart_const_iterator_of_involution > Base; + + Dart_of_involution_range(Self &amap, Dart_handle adart) : + Base(amap, adart) + {} + }; + //************************************************************************** + // Dart_of_involution_const_range + template + struct Dart_of_involution_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > Base; + + Dart_of_involution_const_range(const Self &amap, Dart_const_handle adart): + Base(amap, adart) + {} + }; + //************************************************************************** + template + Dart_of_involution_range + darts_of_involution(Dart_handle adart) + { return Dart_of_involution_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_const_range + darts_of_involution(Dart_const_handle adart) const + { return Dart_of_involution_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_range + darts_of_involution(Dart_handle adart) + { return Dart_of_involution_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_const_range + darts_of_involution(Dart_const_handle adart) const + { return Dart_of_involution_const_range(*this,adart); } + //************************************************************************** + // Dart_of_involution_inv_range + template + struct Dart_of_involution_inv_range: public CMap_range + , + CMap_dart_const_iterator_of_involution_inv > + { + typedef CMap_range + , + CMap_dart_const_iterator_of_involution_inv > Base; + + Dart_of_involution_inv_range(Self &amap, Dart_handle adart) : + Base(amap, adart) + {} + }; + //************************************************************************** + // Dart_of_involution_inv_const_range + template + struct Dart_of_involution_inv_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > Base; + + Dart_of_involution_inv_const_range(const Self &amap, + Dart_const_handle adart): + Base(amap, adart) + {} + }; + //************************************************************************** + template + Dart_of_involution_inv_range + darts_of_involution_inv(Dart_handle adart) + { return Dart_of_involution_inv_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_inv_const_range + darts_of_involution_inv(Dart_const_handle adart) const + { return Dart_of_involution_inv_const_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_inv_range + darts_of_involution_inv(Dart_handle adart) + { return Dart_of_involution_inv_range(*this,adart); } + //-------------------------------------------------------------------------- + template + Dart_of_involution_inv_const_range + darts_of_involution_inv(Dart_const_handle adart) const + { return Dart_of_involution_inv_const_range + (*this,adart); } + //************************************************************************** + // Dart_basic_range + struct Dart_basic_range { + typedef CMap_dart_iterator_basic_of_all iterator; + typedef CMap_dart_const_iterator_basic_of_all const_iterator; + Dart_basic_range(Self &amap) : mmap(amap) + {} + iterator begin() { return iterator(mmap); } + iterator end() { return iterator(mmap,NULL); } + const_iterator begin() const { return const_iterator(mmap); } + const_iterator end() const { return const_iterator(mmap,NULL); } + size_type size() + { return mmap.number_of_darts(); } + bool empty() const + { return mmap.is_empty(); } + private: + Self & mmap; + }; + //************************************************************************** + // Dart_basic_const_range + struct Dart_basic_const_range { + typedef CMap_dart_const_iterator_basic_of_all const_iterator; + Dart_basic_const_range(Self &amap) : mmap(amap) + {} + const_iterator begin() const { return const_iterator(mmap); } + const_iterator end() const { return const_iterator(mmap,NULL); } + size_type size() const + { return mmap.number_of_darts(); } + bool empty() const + { return mmap.is_empty(); } + private: + const Self & mmap; + }; + //************************************************************************** + Dart_basic_range darts_basic() + { return Dart_basic_range(*this); } + //-------------------------------------------------------------------------- + Dart_basic_const_range darts_basic() const + { return Dart_basic_const_range(*this); } //************************************************************************** // One_dart_per_incident_cell_range template - struct One_dart_per_incident_cell_range { - typedef CMap_one_dart_per_incident_cell_iterator iterator; - typedef CMap_one_dart_per_incident_cell_const_iterator - const_iterator; - One_dart_per_incident_cell_range(Self &amap, Dart_handle adart) : - mmap(amap), mdart(adart),msize(0) + struct One_dart_per_incident_cell_range: public CMap_range + , + CMap_one_dart_per_incident_cell_const_iterator > + { + typedef CMap_range + , + CMap_one_dart_per_incident_cell_const_iterator > Base; + + One_dart_per_incident_cell_range(Self &amap, Dart_handle adart): + Base(amap, adart) {} - iterator begin() { return iterator(mmap,mdart); } - iterator end() { return iterator(mmap,NULL); } - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - Self & mmap; - Dart_handle mdart; - size_type msize; }; //************************************************************************** // One_dart_per_incident_cell_const_range template - struct One_dart_per_incident_cell_const_range { - typedef CMap_one_dart_per_incident_cell_const_iterator - const_iterator; + struct One_dart_per_incident_cell_const_range: public CMap_const_range + > + { + typedef CMap_const_range + > + Base; + One_dart_per_incident_cell_const_range(const Self &amap, - Dart_const_handle adart) : - mmap(amap), mdart(adart), msize(0) + Dart_const_handle adart) : + Base(amap, adart) {} - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for ( const_iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; - } - bool empty() const - { return mdart==NULL; } - private: - const Self & mmap; - Dart_const_handle mdart; - size_type msize; }; //************************************************************************** // One_dart_per_cell_range @@ -1862,10 +2267,10 @@ namespace CGAL { const_iterator end() const { return const_iterator(mmap,NULL); } size_type size() { - if (msize==0) - for ( iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; + if (msize==0) + for ( const_iterator it=begin(); it!=end(); ++it) + ++msize; + return msize; } bool empty() const { return mmap.is_empty(); } @@ -1884,10 +2289,10 @@ namespace CGAL { const_iterator end() const { return const_iterator(mmap,NULL); } size_type size() { - if (msize==0) - for ( const_iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; + if (msize==0) + for ( const_iterator it=begin(); it!=end(); ++it) + ++msize; + return msize; } bool empty() const { return mmap.is_empty(); } @@ -1896,95 +2301,44 @@ namespace CGAL { size_type msize; }; //************************************************************************** - // Dart_of_involution_range - template - struct Dart_of_involution_range { - typedef CMap_dart_iterator_of_involution iterator; - typedef CMap_dart_const_iterator_of_involution const_iterator; - Dart_of_involution_range(Self &amap, Dart_handle adart) : - mmap(amap), mdart(adart), msize(0) - {} - iterator begin() { return iterator(mmap,mdart); } - iterator end() { return iterator(mmap,NULL); } - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for (iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; - } - bool empty() const - { return mmap.is_empty(); } - private: - Self & mmap; - Dart_handle mdart; - size_type msize; - }; - //************************************************************************** - // Dart_of_involution_const_range - template - struct Dart_of_involution_const_range { - typedef CMap_dart_const_iterator_of_involution const_iterator; - Dart_of_involution_const_range(const Self &amap, Dart_const_handle adart) : - mmap(amap), mdart(adart), msize(0) - {} - const_iterator begin() const { return const_iterator(mmap,mdart); } - const_iterator end() const { return const_iterator(mmap,NULL); } - size_type size() - { - if (msize==0) - for (const_iterator it=begin(); it!=end(); ++it) - ++msize; - return msize; - } - bool empty() const - { return mmap.is_empty(); } - private: - const Self & mmap; - Dart_const_handle mdart; - size_type msize; - }; - //************************************************************************** - /// @return a range on the i-cells incindent to the given j-cell. template One_dart_per_incident_cell_range one_dart_per_incident_cell(Dart_handle adart) { return One_dart_per_incident_cell_range(*this,adart); } - + //-------------------------------------------------------------------------- template One_dart_per_incident_cell_const_range one_dart_per_incident_cell(Dart_const_handle adart) const { return One_dart_per_incident_cell_const_range(*this,adart); } - + //-------------------------------------------------------------------------- template One_dart_per_incident_cell_range one_dart_per_incident_cell(Dart_handle adart) { return one_dart_per_incident_cell(adart); } - + //-------------------------------------------------------------------------- template One_dart_per_incident_cell_const_range one_dart_per_incident_cell(Dart_const_handle adart) const { return one_dart_per_incident_cell(adart); } - + //-------------------------------------------------------------------------- /// @return a range on all the i-cells template One_dart_per_cell_range one_dart_per_cell() { return One_dart_per_cell_range(*this); } - + //-------------------------------------------------------------------------- template One_dart_per_cell_const_range one_dart_per_cell() const { return One_dart_per_cell_const_range(*this); } - + //-------------------------------------------------------------------------- template One_dart_per_cell_range one_dart_per_cell() { return one_dart_per_cell(); } - + //-------------------------------------------------------------------------- template One_dart_per_cell_const_range one_dart_per_cell() const { return one_dart_per_cell(); } + //-------------------------------------------------------------------------- public: /// Void dart. A dart d is i-free if beta_i(d)=null_dart_handle. @@ -2036,7 +2390,6 @@ namespace CGAL { // = mnull_dart_container.emplace( std::bitset() ); // Does not work on windows => segfault // Thus we initialize null_dart_handle in the Combinatorial_map constructor - // Not thread safe ! template < unsigned int d_, class Items_=Combinatorial_map_min_items, @@ -2055,7 +2408,6 @@ namespace CGAL { typedef typename Base::Alloc Alloc; }; - } // namespace CGAL #endif // CGAL_COMBINATORIAL_MAP_H // diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_basic_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_basic_operations.h index 5a5e7f36d03..8ce7e2ba315 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_basic_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_basic_operations.h @@ -37,7 +37,8 @@ bool belong_to_same_orbit(const Map & amap, typename Map::Dart_const_handle adart1, typename Map::Dart_const_handle adart2) { - CGAL_assertion( (!Iterator::is_basic_iterator()) ); + CGAL_static_assertion( (boost::is_same::value) ); bool found = false; for (Iterator it(amap, adart1); !found && it.cont(); ++it) @@ -59,7 +60,8 @@ bool is_whole_orbit_marked(const Map & amap, typename Map::Dart_const_handle adart, int amark) { - CGAL_assertion( !Iterator::is_basic_iterator() ); + CGAL_static_assertion( (boost::is_same::value) ); bool res = true; for ( Iterator it(amap, adart); res && it.cont(); ++it ) @@ -99,7 +101,8 @@ typename Map::size_type mark_orbit(const Map & amap, typename Map::Dart_const_handle adart, unsigned int amark) { - CGAL_assertion( Iterator::is_basic_iterator() ); + CGAL_static_assertion( (boost::is_same::value) ); CGAL_assertion( (is_whole_orbit_unmarked > (amap, adart, amark)) ); @@ -143,7 +146,9 @@ typename Map::size_type unmark_orbit(const Map & amap, typename Map::Dart_const_handle adart1, typename Map::Dart_const_handle adart2) { - return belong_to_same_orbit > + return belong_to_same_orbit::const_iterator> (amap, adart1, adart2); } @@ -167,7 +172,9 @@ bool is_whole_cell_marked(const Map & amap, typename Map::Dart_const_handle adart, unsigned int amark) { - return is_whole_orbit_marked > + return is_whole_orbit_marked::const_iterator> (amap, adart, amark); } @@ -190,7 +197,9 @@ bool is_whole_cell_unmarked(const Map & amap, typename Map::Dart_const_handle adart, unsigned int amark) { - return is_whole_orbit_unmarked > + return is_whole_orbit_unmarked::iterator> (amap, adart, amark); } @@ -211,9 +220,11 @@ bool is_whole_cell_unmarked(const Map & amap, */ template < class Map, unsigned int i, unsigned int d > typename Map::size_type mark_cell(const Map & amap, - typename Map::Dart_const_handle adart, - int amark) -{ return mark_orbit > + typename Map::Dart_const_handle adart, + int amark) +{ return mark_orbit::const_iterator> (amap, adart, amark); } template < class Map, unsigned int i> @@ -231,9 +242,11 @@ typename Map::size_type mark_cell(const Map & amap, */ template < class Map, unsigned int i, unsigned int d > typename Map::size_type unmark_cell(const Map & amap, - typename Map::Dart_handle adart, - int amark) -{ return unmark_orbit > + typename Map::Dart_handle adart, + int amark) +{ return unmark_orbit::const_iterator> (amap, adart, amark);} template < class Map, unsigned int i > @@ -258,7 +271,8 @@ typename Map::size_type degree( const Map & amap, int mark = amap.get_new_mark(); int treated = amap.get_new_mark(); - CMap_dart_const_iterator_basic_of_cell it(amap, adart, mark); + typename Map::template + Dart_of_cell_basic_range::const_iterator it(amap, adart, mark); for ( ;it.cont(); ++it ) { if (!amap.is_marked(*it, treated)) @@ -304,7 +318,8 @@ typename Map::size_type codegree(const Map & amap, int mark = amap.get_new_mark(); int treated = amap.get_new_mark(); - CMap_dart_const_iterator_basic_of_cell it(amap, adart, mark); + typename Map::template + Dart_of_cell_basic_range::const_iterator it(amap, adart, mark); for ( ; it.cont(); ++it) { if (!amap.is_marked(*it, treated)) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h new file mode 100644 index 00000000000..a678fac34f5 --- /dev/null +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_iterators_base.h @@ -0,0 +1,550 @@ +// Copyright (c) 2010-2011 CNRS and LIRIS' Establishments (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Guillaume Damiand +// +#ifndef CGAL_COMBINATORIAL_MAP_ITERATORS_BASE_HH +#define CGAL_COMBINATORIAL_MAP_ITERATORS_BASE_HH 1 + +#include + +namespace CGAL { + + /** @file Combinatorial_map_iterators_base.h + * Basic classes that serve as tools for definition of iterators. + There are 3 classes: + * - CMap_dart_iterator is the basic generic class defining + * what is an interator on darts. + * - CMap_extend_iterator to extend the given iterator by adding + * the involution Bi. + * - CMap_non_basic_iterator to transform the basic iterator Ite + * into the corresponding non basic iterator. + */ + //**************************************************************************** + /// OperationState: type to keep the last operation used by the previous ++. + typedef char OperationState; + + /// Enum of all the possible operations used by the ++ operator. + enum + { + OP_NONE = -1, ///< Beginning of the iterator (there is not yet operator++). + OP_BETAI, ///< Previous op was the first beta. + OP_BETAI_INV, ///< Previous op was the inverse of the first beta. + OP_BETAJ, ///< Previous op was the second beta. + OP_BETAK, ///< Previous op was the third beta. + OP_BETA0I, ///< Previous op was beta0 o the first beta. + OP_BETAI1, ///< Previous op was the first beta o beta1. + OP_BETAIJ, ///< Previous op was the composition of two beta. + OP_BETAJI, ///< Previous op was the composition of two beta. + OP_BETA21, ///< Previous op was beta21. + OP_JUMP, ///< Previous op was a jump . + OP_POP, ///< Previous op pop a dart from a stack or a queue. + OP_END ///< Previous op go out of the iterator. + }; + //**************************************************************************** + /** Generic class of iterator onto darts. + * Class CMap_dart_iterator is a generic iterator. All the combinatorial + * map iterator classes inherit from this class (or one of its subclass). + */ + template < typename Map_,bool Const=false > + class CMap_dart_iterator: + public internal::CC_iterator + { + public: + typedef CMap_dart_iterator Self; + typedef internal::CC_iterator Base; + + typedef Base Dart_handle; + typedef typename boost::mpl::if_c< Const, const Map_, + Map_>::type Map; + + typedef std::input_iterator_tag iterator_category; + typedef typename Base::value_type value_type; + typedef typename Base::difference_type difference_type; + typedef typename Base::pointer pointer; + typedef typename Base::reference reference; + + /// true iff this iterator is basic + typedef Tag_true Basic_iterator; + + public: + /// Main constructor. + CMap_dart_iterator(Map& amap, Dart_handle adart): + Base(adart), + mmap(&amap), + mfirst_dart(adart), + mprev_op(OP_NONE) + {} + + /// == operator. + bool operator==(const Self& aiterator) const + { + return ( ((*this==NULL) && (aiterator==NULL)) || + (mfirst_dart == aiterator.mfirst_dart && + ((const Base&)*this==(const Base&)aiterator)) ); + } + + /// != operator. + bool operator!=(const Self& aiterator) const + { return !operator==(aiterator); } + + /// Accessor to the initial dart of the iterator. + Dart_handle get_first_dart() const { return mfirst_dart; } + + /// Accessor to the combinatorial map. + Map* get_combinatorial_map() const { return mmap; } + + /// Rewind of the iterator to its beginning. + void rewind() + { set_current_dart(mfirst_dart); mprev_op = OP_NONE; } + + /// Test if the iterator is at its end. + bool cont() const { return *this != NULL; } + + /// Get the previous operation used for the last ++. + OperationState prev_operation() const { return mprev_op; } + + protected: + /// Set the current dart to a given dart + void set_current_dart(Dart_handle adart) + { Base::operator=(adart); } + + private: + /// operator -- in private to invalidate the base operator. + Self& operator--() + { return *this; } + /// operator -- in private to invalidate the base operator. + void operator--(int) + {} + + protected: + /// test if adart->beta(ai) exists and is not marked for amark + bool is_unmarked(Dart_handle adart, unsigned int ai, unsigned amark) const + { return !adart->is_free(ai) && + !mmap->is_marked(adart->beta(ai), amark); } + + /// test if adart->beta(ai)->beta(aj) exists + bool exist_betaij(Dart_handle adart, unsigned int ai, unsigned int aj) const + { return !adart->is_free(ai) && !adart->beta(ai)->is_free(aj); } + + /// test if adart->beta(ai)->beta(aj) exists and is not marked for amark + bool is_unmarked2(Dart_handle adart, unsigned int ai, unsigned int aj, + unsigned amark) const + { return exist_betaij(adart,ai,aj) && + !mmap->is_marked(adart->beta(ai)->beta(aj), amark); } + + protected: + /// The map containing the darts to iterate on. + Map* mmap; + + /// The initial dart of the iterator. + Dart_handle mfirst_dart; + + /// The last operation used for the ++ operator. + OperationState mprev_op; + }; + //**************************************************************************** + /* Class CMap_extend_iterator which extend a given iterator by + * adding Bi and by using a stack and a mark. + * General case when Ite does not have already a stack. + */ + template + class CMap_extend_iterator: public Ite + { + public: + typedef CMap_extend_iterator Self; + typedef Ite Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + typedef Tag_true Use_mark; + + CGAL_static_assertion( (Bi<=Map::dimension && + boost::is_same::value) ); + + public: + /// Main constructor. + CMap_extend_iterator(Map& amap, Dart_handle adart, int amark): + Base(amap, adart), + mmark_number(amark), + minitial_dart(adart) + { + if ( adart!=NULL ) + { + this->mmap->mark(adart, mmark_number); + if (!(*this)->is_free(Bi)) + mto_treat.push((*this)->beta(Bi)); + } + } + + /// Rewind of the iterator to its beginning. + void rewind() + { + CGAL_assertion(mmark_number != -1); + Base::operator= ( Base(*this->mmap,minitial_dart) ); + mto_treat = std::queue(); + this->mmap->mark((*this), mmark_number); + if (!(*this)->is_free(Bi)) + mto_treat.push((*this)->beta(Bi)); + } + + /// Prefix ++ operator. + Self& operator++() + { + CGAL_assertion(mmark_number != -1); + CGAL_assertion(this->cont()); + + Base::operator++(); + + if ( !this->cont() ) + { + if ( !mto_treat.empty() ) + { + Dart_handle res=NULL; + do + { + res = mto_treat.front(); + mto_treat.pop(); + } + while (!mto_treat.empty() && + this->mmap->is_marked(res, mmark_number)); + + if (!this->mmap->is_marked(res, mmark_number)) + { + Base::operator= ( Base(*this->mmap,res) ); + this->mprev_op = OP_POP; + } + } + } + + if ( this->cont() ) + { + CGAL_assertion( !this->mmap->is_marked((*this), + mmark_number) ); + this->mmap->mark((*this), mmark_number); + + if (!(*this)->is_free(Bi) && + !this->mmap->is_marked((*this)->beta(Bi), + mmark_number)) + mto_treat.push((*this)->beta(Bi)); + } + + return *this; + } + + /// Postfix ++ operator. + Self operator++(int) + { Self res=*this; operator ++(); return res; } + + protected: + /// Queue of darts to process. + std::queue mto_treat; + + /// Index of the used mark. + int mmark_number; + + /// Initial dart + Dart_handle minitial_dart; + }; + //**************************************************************************** + /* Class CMap_extend_iterator which extend a given iterator by + * adding Bi and by using a stack and a mark. + * Specialization when Ite has already a stack. + */ + template + class CMap_extend_iterator: public Ite + { + public: + typedef CMap_extend_iterator Self; + typedef Ite Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + typedef Tag_true Use_mark; + + /// Main constructor. + CMap_extend_iterator(Map& amap, Dart_handle adart, int amark): + Base(amap, adart, amark) + { + if (adart!=NULL) + { + if (!adart->is_free(Bi) && + !this->mmap->is_marked(adart->beta(Bi), this->mmark_number)) + this->mto_treat.push(adart->beta(Bi)); + } + } + + /// Rewind of the iterator to its beginning. + void rewind() + { + CGAL_assertion(this->mmark_number != -1); + Base::rewind(); + if (!(*this)->is_free(Bi) && + !this->mmap->is_marked((*this)->beta(Bi), + this->mmark_number)) + this->mto_treat.push((*this)->beta(Bi)); + } + + /// Prefix ++ operator. + Self& operator++() + { + Base::operator++(); + + if ( this->cont() ) + { + if (!(*this)->is_free(Bi) && + !this->mmap->is_marked((*this)->beta(Bi), + this->mmark_number)) + this->mto_treat.push((*this)->beta(Bi)); + } + return *this; + } + + /// Postfix ++ operator. + Self operator++(int) + { Self res=*this; operator ++(); return res; } + }; + //**************************************************************************** + //* Class CMap_non_basic_iterator allows to transform a basic_iterator onto + //* a non basic one, depending if the basic iterator uses mark or not. + template + class CMap_non_basic_iterator; + //**************************************************************************** + template + class CMap_non_basic_iterator: + public Base_ + { + public: + typedef CMap_non_basic_iterator Self; + typedef Base_ Base; + + typedef typename Base::Map Map; + typedef typename Base::Dart_handle Dart_handle; + + /// True iff this iterator is basic + typedef Tag_false Basic_iterator; + + CGAL_static_assertion( (boost::is_same::value) ); + + /// Main constructor. + CMap_non_basic_iterator(Map& amap, Dart_handle adart1): + Base(amap, adart1, amap.get_new_mark()) + {} + + /// Destructor. + ~CMap_non_basic_iterator() + { + if (this->mmark_number != -1) + { + unmark_treated_darts(); + CGAL_assertion( this->mmap->is_whole_map_unmarked + (this->mmark_number) ); + this->mmap->free_mark(this->mmark_number); + } + } + + /// Copy constructor. + CMap_non_basic_iterator(const Self& aiterator): + Base(aiterator) + { this->mmark_number = -1; } + + /// Assignment operator. + Self& operator=(const Self& aiterator) + { + if (this != &aiterator) + { + Base::operator=(aiterator); + this->mmark_number = -1; + } + return *this; + } + + /// Rewind of the iterator to its beginning. + void rewind() + { + CGAL_assertion(this->mmark_number != -1); + unmark_treated_darts(); + Base::rewind(); + } + + using Base::operator++; + + /// Postfix ++ operator. + void operator++(int) + { operator ++(); } + + protected: + /// Unmark all the marked darts during the iterator. + void unmark_treated_darts() + { + CGAL_assertion(this->mmark_number != -1); + if (this->mmap->is_whole_map_unmarked(this->mmark_number)) return; + + this->mmap->negate_mark(this->mmark_number); + + if (this->mmap->is_whole_map_unmarked(this->mmark_number)) return; + + Base::rewind(); + while (this->mmap->number_of_unmarked_darts(this->mmark_number) > 0) + this->operator++(); + this->mmap->negate_mark(this->mmark_number); + CGAL_assertion(this->mmap->is_whole_map_unmarked(this->mmark_number)); + } + }; + //**************************************************************************** + template + class CMap_non_basic_iterator: + public Base_ + { + public: + typedef CMap_non_basic_iterator Self; + typedef Base_ Base; + + typedef typename Base::Map Map; + typedef typename Base::Dart_handle Dart_handle; + + /// True iff this iterator is basic + typedef Tag_false Basic_iterator; + + CGAL_static_assertion( (boost::is_same::value) ); + + /// Main constructor. + CMap_non_basic_iterator(Map& amap, Dart_handle adart): + Base(amap, adart,-1) + {} + }; + //**************************************************************************** + template + struct CMap_range + { + typedef It iterator; + typedef Const_it const_iterator; + CMap_range(Map_ &amap, typename Map_::Dart_handle adart) : + mmap(amap), mdart(adart), msize(0) + {} + iterator begin() { return iterator(mmap,mdart); } + iterator end() { return iterator(mmap,NULL); } + const_iterator begin() const { return const_iterator(mmap,mdart); } + const_iterator end() const { return const_iterator(mmap,NULL); } + typename Map_::size_type size() + { + if (msize==0) + for (const_iterator it=begin(); it!=end(); ++it) + ++msize; + return msize; + } + bool empty() const + { return mmap.is_empty(); } + private: + Map_ & mmap; + typename Map_::Dart_handle mdart; + typename Map_::size_type msize; + }; + //**************************************************************************** + template + struct CMap_range + { + typedef CMap_range Base_cmap_range; + typedef It iterator; + typedef Const_it const_iterator; + CMap_range(Map_ &amap, typename Map_::Dart_handle adart, int amark=-1): + mmap(amap), mdart(adart), msize(0), mmark(amark) + {} + iterator begin() { return iterator(mmap,mdart,mmark); } + iterator end() { return iterator(mmap,NULL,mmark); } + const_iterator begin() const { return const_iterator(mmap,mdart,mmark); } + const_iterator end() const { return const_iterator(mmap,NULL,mmark); } + typename Map_::size_type size() + { + if (msize==0) + for ( CMap_non_basic_iterator it(mmap,mdart); + it.cont(); ++it ) + ++msize; + return msize; + } + bool empty() const + { return mmap.is_empty(); } + private: + Map_ & mmap; + typename Map_::Dart_handle mdart; + typename Map_::size_type msize; + int mmark; + }; + //**************************************************************************** + template + struct CMap_const_range + { + typedef Const_it const_iterator; + CMap_const_range(const Map_ &amap, typename Map_::Dart_const_handle adart): + mmap(amap), mdart(adart), msize(0) + {} + const_iterator begin() const { return const_iterator(mmap,mdart); } + const_iterator end() const { return const_iterator(mmap,NULL); } + typename Map_::size_type size() + { + if (msize==0) + for (const_iterator it=begin(); it!=end(); ++it) + ++msize; + return msize; + } + bool empty() const + { return mmap.is_empty(); } + private: + const Map_ & mmap; + typename Map_::Dart_const_handle mdart; + typename Map_::size_type msize; + }; + //**************************************************************************** + template + struct CMap_const_range + { + typedef Const_it const_iterator; + CMap_const_range(const Map_ &amap, typename Map_::Dart_const_handle adart, + int amark=-1): + mmap(amap), mdart(adart), msize(0), mmark(amark) + {} + const_iterator begin() const { return const_iterator(mmap,mdart,mmark); } + const_iterator end() const { return const_iterator(mmap,NULL,mmark); } + typename Map_::size_type size() + { + if (msize==0) + for ( CMap_non_basic_iterator it(mmap,mdart); + it.cont(); ++it ) + ++msize; + return msize; + } + bool empty() const + { return mmap.is_empty(); } + private: + const Map_ & mmap; + typename Map_::Dart_const_handle mdart; + typename Map_::size_type msize; + int mmark; + }; + //**************************************************************************** +} // namespace CGAL +//****************************************************************************** +#endif // CGAL_COMBINATORIAL_MAP_ITERATORS_BASE_HH +//****************************************************************************** diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index 96aa9cbfe03..dc239767b39 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -156,7 +156,7 @@ namespace CGAL { bool is_removable(const Map& amap, typename Map::Dart_const_handle adart) { CGAL_assertion(adart != NULL); - CGAL_assertion(0<=i && i<=Map::dimension); + CGAL_static_assertion(0<=i && i<=Map::dimension); if ( i==Map::dimension ) return true; if ( i==Map::dimension-1 ) return true; @@ -183,7 +183,7 @@ namespace CGAL { { static size_t run(Map& amap, typename Map::Dart_handle adart) { - CGAL_assertion ( 1<=i && i(amap, adart)) ); size_t res = 0; @@ -504,7 +504,7 @@ namespace CGAL { InputIterator afirst, InputIterator alast) { - CGAL_assertion( Map::dimension>= 3 ); + CGAL_static_assertion( Map::dimension>= 3 ); // The path must have at least one dart. if (afirst==alast) return false; diff --git a/Combinatorial_map/include/CGAL/Dart_const_iterators.h b/Combinatorial_map/include/CGAL/Dart_const_iterators.h index dde0800692b..8c67353da80 100644 --- a/Combinatorial_map/include/CGAL/Dart_const_iterators.h +++ b/Combinatorial_map/include/CGAL/Dart_const_iterators.h @@ -25,15 +25,16 @@ namespace CGAL { /** @file Dart_const_iterators.h - * Definition of dart const iterators. There are 8 iterators: + * Definition of dart const iterators. There are 9 iterators: * - CMap_dart_const_iterator_basic_of_orbit * - CMap_dart_const_iterator_basic_of_cell + * - CMap_dart_const_iterator_basic_of_all + * - CMap_dart_const_iterator_basic_of_involution + * - CMap_dart_const_iterator_of_involution_inv * - CMap_dart_const_iterator_of_orbit * - CMap_dart_const_iterator_of_cell - * - CMap_dart_const_iterator_basic_of_involution * - CMap_dart_const_iterator_of_involution * - CMap_dart_const_iterator_basic_of_involution_inv - * - CMap_dart_const_iterator_of_involution_inv */ //**************************************************************************** #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES @@ -58,6 +59,13 @@ namespace CGAL { int amark): Base(amap,adart,amark) {} + /// Constructor from non const version. + CMap_dart_const_iterator_basic_of_orbit + (const CMap_dart_iterator_basic_of_orbit& it): + Base(*const_cast(it.get_combinatorial_map()), + it.get_first_dart(), + it.mmark_number) + {} }; //**************************************************************************** template @@ -109,6 +117,14 @@ namespace CGAL { int amark): Base(amap,adart,amark) {} + /// Constructor from non const version. + CMap_dart_const_iterator_basic_of_orbit + (const CMap_dart_iterator_basic_of_orbit& it): + Base(*const_cast(it.get_combinatorial_map()), + it.get_first_dart(), + it.mmark_number) + {} }; //**************************************************************************** template + class CMap_dart_const_iterator_basic_of_all: + public CMap_dart_iterator_basic_of_all + { + public: + typedef CMap_dart_iterator_basic_of_all Base; + typedef typename Map_::Dart_const_handle Dart_const_handle; + + /* Main constructor. */ + CMap_dart_const_iterator_basic_of_all(const Map_& amap, + Dart_const_handle adart): + Base(amap,adart) + {} + /* Main constructor. */ + CMap_dart_const_iterator_basic_of_all(const Map_& amap, + Dart_const_handle adart, + int /*amark*/): + Base(amap,adart) + {} + /// Constructor from non const version. + CMap_dart_const_iterator_basic_of_all + (const CMap_dart_iterator_basic_of_all& it): + Base(*const_cast(it.get_combinatorial_map()), + it.get_first_dart()) + {} + }; + //**************************************************************************** template class CMap_dart_const_iterator_basic_of_cell: public CMap_dart_iterator_basic_of_cell diff --git a/Combinatorial_map/include/CGAL/Dart_iterators.h b/Combinatorial_map/include/CGAL/Dart_iterators.h index e3907ff515c..5b42ab28d2f 100644 --- a/Combinatorial_map/include/CGAL/Dart_iterators.h +++ b/Combinatorial_map/include/CGAL/Dart_iterators.h @@ -20,151 +20,25 @@ #ifndef CGAL_DART_ITERATORS_HH #define CGAL_DART_ITERATORS_HH 1 -#include +#include namespace CGAL { /** @file Dart_iterators.h * Definition of dart iterators. There are 9 iterators: - * - CMap_dart_iterator_basic_of_orbit - * - CMap_dart_iterator_basic_of_cell - * - CMap_dart_iterator_basic_of_all - * - CMap_dart_iterator_of_orbit - * - CMap_dart_iterator_of_cell - * - CMap_dart_iterator_basic_of_involution - * - CMap_dart_iterator_of_involution - * - CMap_dart_iterator_basic_of_involution_inv - * - CMap_dart_iterator_of_involution_inv + * - CMap_dart_iterator_basic_of_orbit + * - CMap_dart_iterator_basic_of_cell + * - CMap_dart_iterator_basic_of_all + * - CMap_dart_iterator_basic_of_involution + * - CMap_dart_iterator_basic_of_involution_inv + * - CMap_dart_iterator_of_orbit + * - CMap_dart_iterator_of_cell + * - CMap_dart_iterator_of_involution + * - CMap_dart_iterator_of_involution_inv * but many specializations to optimize specific cases. * */ //**************************************************************************** - /// OperationState: type to keep the last operation used by the previous ++. - typedef char OperationState; - - /// Enum of all the possible operations used by the ++ operator. - enum - { - OP_NONE = -1, ///< Beginning of the iterator (there is not yet operator++). - OP_BETAI, ///< Previous op was the first beta. - OP_BETAI_INV, ///< Previous op was the inverse of the first beta. - OP_BETAJ, ///< Previous op was the second beta. - OP_BETAK, ///< Previous op was the third beta. - OP_BETA0I, ///< Previous op was beta0 o the first beta. - OP_BETAI1, ///< Previous op was the first beta o beta1. - OP_BETAIJ, ///< Previous op was the composition of two beta. - OP_BETAJI, ///< Previous op was the composition of two beta. - OP_BETA21, ///< Previous op was beta21. - OP_JUMP, ///< Previous op was a jump . - OP_POP, ///< Previous op pop a dart from a stack or a queue. - OP_END ///< Previous op go out of the iterator. - }; - //**************************************************************************** - //**************************************************************************** - /** Generic class of iterator onto darts. - * Class CMap_dart_iterator is a pure virtual generic iterator. This - * class defines what is an iterator. All the iterator classes inherit - * from this class. - */ - template < typename Map_,bool Const=false > - class CMap_dart_iterator: - public internal::CC_iterator - { - public: - typedef CMap_dart_iterator Self; - typedef internal::CC_iterator Base; - - typedef Base Dart_handle; - typedef typename boost::mpl::if_c< Const, const Map_, - Map_>::type Map; - - typedef std::input_iterator_tag iterator_category; - typedef typename Base::value_type value_type; - typedef typename Base::difference_type difference_type; - typedef typename Base::pointer pointer; - typedef typename Base::reference reference; - - public: - /// Main constructor. - CMap_dart_iterator(Map& amap, Dart_handle adart): - Base(adart), - mmap(&amap), - mfirst_dart(adart), - mprev_op(OP_NONE) - {} - - /// == operator. - bool operator==(const Self& aiterator) const - { - return ( ((*this==NULL) && (aiterator==NULL)) || - (mfirst_dart == aiterator.mfirst_dart && - ((const Base&)*this==(const Base&)aiterator)) ); - } - - /// != operator. - bool operator!=(const Self& aiterator) const - { return !operator==(aiterator); } - - /// Accessor to the initial dart of the iterator. - Dart_handle get_first_dart() const { return mfirst_dart; } - - /// Accessor to the combinatorial map. - Map* get_combinatorial_map() const { return mmap; } - - /// Rewind of the iterator to its beginning. - void rewind() - { set_current_dart(mfirst_dart); mprev_op = OP_NONE; } - - /// Test if the iterator is at its end. - bool cont() const { return *this != NULL; } - - /// Get the previous operation used for the last ++. - OperationState prev_operation() const { return mprev_op; } - - /// Return true iff this iterator is basic - static bool is_basic_iterator() - { return true; } - - protected: - /// Set the current dart to a given dart - void set_current_dart(Dart_handle adart) - { Base::operator=(adart); } - - private: - /// operator -- in private to invalidate the base operator. - Self& operator--() - { return *this; } - /// operator -- in private to invalidate the base operator. - void operator--(int) - {} - - protected: - /// test if adart->beta(ai) exists and is not marked for amark - bool is_unmarked(Dart_handle adart, unsigned int ai, unsigned amark) const - { return !adart->is_free(ai) && - !mmap->is_marked(adart->beta(ai), amark); } - - /// test if adart->beta(ai)->beta(aj) exists - bool exist_betaij(Dart_handle adart, unsigned int ai, unsigned int aj) const - { return !adart->is_free(ai) && !adart->beta(ai)->is_free(aj); } - - /// test if adart->beta(ai)->beta(aj) exists and is not marked for amark - bool is_unmarked2(Dart_handle adart, unsigned int ai, unsigned int aj, - unsigned amark) const - { return exist_betaij(adart,ai,aj) && - !mmap->is_marked(adart->beta(ai)->beta(aj), amark); } - - protected: - /// The map containing the darts to iterate on. - Map* mmap; - - /// The initial dart of the iterator. - Dart_handle mfirst_dart; - - /// The last operation used for the ++ operator. - OperationState mprev_op; - }; - //**************************************************************************** //**********************BASIC ITERATORS*************************************** //**************************************************************************** /* Class CMap_dart_iterator_basic_of_orbit: to iterate @@ -258,73 +132,6 @@ namespace CGAL { -1,-1,-1,-1,-1,-1,-1,-1,-1> { typedef CMap_dart_iterator_basic_of_orbit_generic type; - }; - - template - class CMap_dart_iterator_basic_of_orbit_generic: - public Get_CMap_dart_iterator_basic_of_orbit::type - { - public: - typedef typename Get_CMap_dart_iterator_basic_of_orbit::type Self; - typedef typename Get_CMap_dart_iterator_basic_of_orbit::type Base; - - typedef typename Base::Dart_handle Dart_handle; - typedef typename Base::Map Map; - - typedef Tag_true Use_mark; - - public: - /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, - int amark): - Base(amap, adart, amark) - { - CGAL_assertion( B1>=0 && B1<=Map::dimension ); - - if (adart!=NULL) - { - if (!adart->is_free(B1) && - !this->mmap->is_marked(adart->beta(B1), this->mmark_number)) - this->mto_treat.push(adart->beta(B1)); - } - } - - /// Rewind of the iterator to its beginning. - void rewind() - { - CGAL_assertion(this->mmark_number != -1); - Base::rewind(); - if (!(*this)->is_free(B1) && - !this->mmap->is_marked((*this)->beta(B1), this->mmark_number)) - this->mto_treat.push((*this)->beta(B1)); - } - - /// Prefix ++ operator. - Self& operator++() - { - CGAL_assertion(this->cont()); - - Base::operator++(); - - if (this->cont()) - { - if (!(*this)->is_free(B1) && - !this->mmap->is_marked((*this)->beta(B1), - this->mmark_number)) - this->mto_treat.push((*this)->beta(B1)); - } - return *this; - } - - /// Postfix ++ operator. - Self operator++(int) - { Self res=*this; operator ++(); return res; } }; #endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES //**************************************************************************** @@ -580,13 +387,13 @@ namespace CGAL { /// Main constructor. CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart): Base(amap, adart) - { CGAL_assertion( Bi>=2 && Bi<=Map::dimension ); } + { CGAL_static_assertion( Bi>=2 && Bi<=Map::dimension ); } /// Main constructor. CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, int /*amark*/): Base(amap, adart) - { CGAL_assertion( Bi>=2 && Bi<=Map::dimension ); } + { CGAL_static_assertion( Bi>=2 && Bi<=Map::dimension ); } /// Prefix ++ operator. Self& operator++() @@ -610,145 +417,19 @@ namespace CGAL { { Self res=*this; operator ++(); return res; } }; //**************************************************************************** - /* Class CMap_extend_iterator which extend a given iterator by - * adding Bi and by using a stack and a mark. - */ - template - class CMap_extend_iterator: public Ite - { - public: - typedef CMap_extend_iterator Self; - typedef Ite Base; - - typedef typename Base::Dart_handle Dart_handle; - typedef typename Base::Map Map; - - typedef Tag_true Use_mark; - - public: - /// Main constructor. - CMap_extend_iterator(Map& amap, Dart_handle adart, int amark): - Base(amap, adart), - mmark_number(amark), - minitial_dart(adart) - { - if ( adart!=NULL ) - { - this->mmap->mark(adart, mmark_number); - if (!(*this)->is_free(Bi)) - mto_treat.push((*this)->beta(Bi)); - } - } - - /// Rewind of the iterator to its beginning. - void rewind() - { - CGAL_assertion(mmark_number != -1); - Base::operator= ( Base(*this->mmap,minitial_dart) ); - mto_treat = std::queue(); - this->mmap->mark((*this), mmark_number); - if (!(*this)->is_free(Bi)) - mto_treat.push((*this)->beta(Bi)); - } - - /// Prefix ++ operator. - Self& operator++() - { - CGAL_assertion(mmark_number != -1); - CGAL_assertion(this->cont()); - - Base::operator++(); - - if ( !this->cont() ) - { - if ( !mto_treat.empty() ) - { - Dart_handle res=NULL; - do - { - res = mto_treat.front(); - mto_treat.pop(); - } - while (!mto_treat.empty() && - this->mmap->is_marked(res, mmark_number)); - - if (!this->mmap->is_marked(res, mmark_number)) - { - Base::operator= ( Base(*this->mmap,res) ); - this->mprev_op = OP_POP; - } - } - } - - if ( this->cont() ) - { - CGAL_assertion( !this->mmap->is_marked((*this), - mmark_number) ); - this->mmap->mark((*this), mmark_number); - - if (!(*this)->is_free(Bi) && - !this->mmap->is_marked((*this)->beta(Bi), - mmark_number)) - mto_treat.push((*this)->beta(Bi)); - } - - return *this; - } - - /// Postfix ++ operator. - Self operator++(int) - { Self res=*this; operator ++(); return res; } - - protected: - /// Queue of darts to process. - std::queue mto_treat; - - /// Index of the used mark. - int mmark_number; - - /// Initial dart - Dart_handle minitial_dart; - }; - //**************************************************************************** - /* Class CMap_dart_iterator_basic_of_orbit: to iterate - * on the darts of the orbit : Bi: to iterate + * on the darts of the orbit : Bi1 and delta>1. * Basic classes do not guaranty correct marks (i.e. do not unmark darts in * the destructor, possible problem with the rewind). If you are not sure, - * use CMap_dart_iterator_basic_of_orbit. + * use CMap_dart_iterator_basic_of_two_beta. */ - template - class CMap_dart_iterator_basic_of_orbit_generic: - public CMap_extend_iterator, Bj> - { - public: - typedef CMap_dart_iterator_basic_of_orbit_generic Self; - typedef CMap_extend_iterator, Bj> Base; - - typedef typename Base::Dart_handle Dart_handle; - typedef typename Base::Map Map; - - typedef Tag_true Use_mark; - - public: - /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, - int amark): - Base(amap, adart, amark) - { CGAL_assertion( Bi: to iterate onto the - * darts of the orbit (i.e. orbit facet in 3D). - * Specialized here since we do not need queue nor mark. - */ - template - class CMap_dart_iterator_basic_of_orbit_generic: + template + class CMap_dart_iterator_basic_of_two_beta : public CMap_dart_iterator { public: - typedef CMap_dart_iterator_basic_of_orbit_generic Self; + typedef CMap_dart_iterator_basic_of_two_beta Self; typedef CMap_dart_iterator Base; typedef typename Base::Dart_handle Dart_handle; @@ -756,52 +437,238 @@ namespace CGAL { typedef Tag_false Use_mark; + CGAL_static_assertion( Bi>1 && delta>1 && Bi+delta<=Map::dimension ); + public: /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart): + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart): Base(amap, adart), - mit(amap, adart), - mexist_beta3(false), - mprev_beta3(false), - mfirst_border(true) - { if (adart!=NULL) mexist_beta3=!adart->is_free(3); } + mcurdart(0) + {} /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, - int /*amark*/): + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart, + int /*amark*/): Base(amap, adart), - mit(amap, adart), - mexist_beta3(false), - mprev_beta3(false), - mfirst_border(true) - { if (adart!=NULL) mexist_beta3=!adart->is_free(3); } + mcurdart(0) + {} + + /// Rewind of the iterator to its beginning. + void rewind() + { + Base::rewind(); + mcurdart=0; + } /// Prefix ++ operator. Self& operator++() { CGAL_assertion(this->cont()); - if (mexist_beta3 && !mprev_beta3) - { - mprev_beta3 = true; - mfirst_border = ! mfirst_border; - this->set_current_dart((*this)->beta(3)); - this->mprev_op = OP_BETAJ; - } + + if (mcurdart==0) + { + if (!(*this)->is_free(Bi)) + { + this->set_current_dart((*this)->beta(Bi)); + this->mprev_op = OP_BETAI; + mcurdart=1; + } + else + { + if (!(*this)->is_free(Bi+delta)) + { + this->set_current_dart((*this)->beta(Bi+delta)); + this->mprev_op = OP_BETAJ; + mcurdart=3; + } + else + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + } + } + else if (mcurdart==1) + { + if (!(*this)->is_free(Bi+delta)) + { + this->set_current_dart((*this)->beta(Bi+delta)); + this->mprev_op = OP_BETAJ; + mcurdart=2; + } + else + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + } + else if (mcurdart==2) + { + CGAL_assertion(!(*this)->is_free(Bi)); + this->set_current_dart((*this)->beta(Bi)); + this->mprev_op = OP_BETAI; + mcurdart=1; + } + else + { + CGAL_assertion (mcurdart==3); + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + + return *this; + } + + /// Postfix ++ operator. + Self operator++(int) + { Self res=*this; operator ++(); return res; } + + private: + /// mcurdart: number of the current dart (0,1,2 or 3). + char mcurdart; + }; + //**************************************************************************** + /* Class CMap_dart_iterator_basic_of_two_beta: to iterate + * on the darts of the orbit : Bi + class CMap_dart_iterator_basic_of_two_beta : + public CMap_extend_iterator + , + 2> + { + public: + typedef CMap_dart_iterator_basic_of_two_beta Self; + typedef CMap_extend_iterator + , + 2> Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + typedef Tag_true Use_mark; + + CGAL_static_assertion( 2<=Map::dimension ); + + public: + /// Main constructor. + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart, + int amark): + Base(amap, adart, amark) + {} + }; + //**************************************************************************** + /* Class CMap_dart_iterator_basic_of_two_beta: to iterate + * on the darts of the orbit : Bi + class CMap_dart_iterator_basic_of_two_beta : + public CMap_extend_iterator + , + 2> + { + public: + typedef CMap_dart_iterator_basic_of_two_beta Self; + typedef CMap_extend_iterator + , + 2> + Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + typedef Tag_true Use_mark; + + CGAL_static_assertion( 2<=Map::dimension ); + + public: + /// Main constructor. + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart, + int amark): + Base(amap, adart, amark) + {} + }; + //**************************************************************************** + /* Class CMap_dart_iterator_basic_of_two_beta: to iterate + * on the darts of the orbit : Bi2. + * Basic classes do not guaranty correct marks (i.e. do not unmark darts in + * the destructor, possible problem with the rewind). If you are not sure, + * use CMap_dart_iterator_basic_of_two_beta. + */ + template + class CMap_dart_iterator_basic_of_two_beta : + public CMap_dart_iterator + { + public: + typedef CMap_dart_iterator_basic_of_two_beta Self; + typedef CMap_dart_iterator Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + typedef Tag_false Use_mark; + + CGAL_static_assertion( delta>1 && delta<=Map::dimension ); + + public: + /// Main constructor. + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart): + Base(amap, adart), + mit(amap, adart), + mexist_betaj(false), + mprev_betaj(false), + mfirst_border(true) + { if (adart!=NULL) mexist_betaj=!adart->is_free(delta); } + + /// Main constructor. + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart, + int /*amark*/): + Base(amap, adart), + mit(amap, adart), + mexist_betaj(false), + mprev_betaj(false), + mfirst_border(true) + { if (adart!=NULL) mexist_betaj=!adart->is_free(delta); } + + /// Prefix ++ operator. + Self& operator++() + { + CGAL_assertion(this->cont()); + if (mexist_betaj && !mprev_betaj) + { + mprev_betaj = true; + mfirst_border = ! mfirst_border; + this->set_current_dart((*this)->beta(delta)); + this->mprev_op = OP_BETAJ; + } else - { - mprev_beta3 = false; - ++mit; - this->mprev_op = mit.prev_operation(); - if ( !mit.cont() ) - this->set_current_dart(NULL); - else - { - if ( !mfirst_border ) - this->set_current_dart(mit->beta(3)); - else - this->set_current_dart(*mit); - } - } + { + mprev_betaj = false; + ++mit; + this->mprev_op = mit.prev_operation(); + if ( !mit.cont() ) + this->set_current_dart(NULL); + else + { + if ( !mfirst_border ) + this->set_current_dart(mit->beta(delta)); + else + this->set_current_dart(mit); + } + } return *this; } @@ -814,7 +681,7 @@ namespace CGAL { { Base::rewind(); mit.rewind(); - mprev_beta3 = false; + mprev_betaj = false; mfirst_border = true; } @@ -823,78 +690,83 @@ namespace CGAL { CMap_dart_iterator_basic_of_orbit_generic mit; /// Boolean: true iff there are two half facets. - bool mexist_beta3; + bool mexist_betaj; - /// Boolean: true iff the last ++ used beta3. - bool mprev_beta3; + /// Boolean: true iff the last ++ used betaj. + bool mprev_betaj; /// Boolean: true iff the current dart is on the first border. bool mfirst_border; }; //**************************************************************************** - /* Class CMap_dart_iterator_basic_of_orbit: to iterate onto the - * darts of the orbit (i.e. orbit facet in 3D). - * Specialized here since we do not need queue nor mark. + /* Class CMap_dart_iterator_basic_of_two_beta: to iterate + * on the darts of the orbit : Bi1. + * Basic classes do not guaranty correct marks (i.e. do not unmark darts in + * the destructor, possible problem with the rewind). If you are not sure, + * use CMap_dart_iterator_basic_of_two_beta. */ - template - class CMap_dart_iterator_basic_of_orbit_generic: + template + class CMap_dart_iterator_basic_of_two_beta : public CMap_dart_iterator { public: - typedef CMap_dart_iterator_basic_of_orbit_generic Self; + typedef CMap_dart_iterator_basic_of_two_beta Self; typedef CMap_dart_iterator Base; - + typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Map Map; typedef Tag_false Use_mark; + CGAL_static_assertion( delta>1 && delta+1<=Map::dimension ); + public: /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart): + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart): Base(amap, adart), mit(amap, adart), - mexist_beta3(false), - mprev_beta3(false), + mexist_betaj(false), + mprev_betaj(false), mfirst_border(true) - { if (adart!=NULL) mexist_beta3=!adart->is_free(3); } - + { if (adart!=NULL) mexist_betaj=!adart->is_free(1+delta); } + /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, - int /*amark*/): + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart, + int /*amark*/): Base(amap, adart), mit(amap, adart), - mexist_beta3(false), - mprev_beta3(false), + mexist_betaj(false), + mprev_betaj(false), mfirst_border(true) - { if (adart!=NULL) mexist_beta3=!adart->is_free(3); } + { if (adart!=NULL) mexist_betaj=!adart->is_free(1+delta); } /// Prefix ++ operator. Self& operator++() { CGAL_assertion(this->cont()); - if (mexist_beta3 && !mprev_beta3) - { - mprev_beta3 = true; - mfirst_border = ! mfirst_border; - this->set_current_dart((*this)->beta(3)); - this->mprev_op = OP_BETAJ; - } + if (mexist_betaj && !mprev_betaj) + { + mprev_betaj = true; + mfirst_border = ! mfirst_border; + this->set_current_dart((*this)->beta(1+delta)); + this->mprev_op = OP_BETAJ; + } else - { - mprev_beta3 = false; - ++mit; - this->mprev_op = mit.prev_operation(); - if ( !mit.cont() ) - this->set_current_dart(NULL); - else - { - if ( !mfirst_border ) - this->set_current_dart(mit->beta(3)); - else - this->set_current_dart(mit); - } - } + { + mprev_betaj = false; + ++mit; + this->mprev_op = mit.prev_operation(); + if ( !mit.cont() ) + this->set_current_dart(NULL); + else + { + if ( !mfirst_border ) + this->set_current_dart(mit->beta(1+delta)); + else + this->set_current_dart(mit); + } + } return *this; } @@ -907,33 +779,37 @@ namespace CGAL { { Base::rewind(); mit.rewind(); - mprev_beta3 = false; + mprev_betaj = false; mfirst_border = true; } private: /// Iterator on beta1 - CMap_dart_iterator_basic_of_orbit_generic mit; + CMap_dart_iterator_basic_of_orbit_generic mit; /// Boolean: true iff there are two half facets. - bool mexist_beta3; + bool mexist_betaj; - /// Boolean: true iff the last ++ used beta3. - bool mprev_beta3; + /// Boolean: true iff the last ++ used betaj. + bool mprev_betaj; /// Boolean: true iff the current dart is on the first border. bool mfirst_border; }; //**************************************************************************** - /* Class CMap_dart_iterator_basic_of_orbit: to iterate onto the - * darts of the orbit (i.e. orbit edge in 3D). + /* Class CMap_dart_iterator_basic_of_two_beta: to iterate + * on the darts of the orbit : Bi1 and delta==1. + * Basic classes do not guaranty correct marks (i.e. do not unmark darts in + * the destructor, possible problem with the rewind). If you are not sure, + * use CMap_dart_iterator_basic_of_two_beta. */ - template - class CMap_dart_iterator_basic_of_orbit_generic: + template + class CMap_dart_iterator_basic_of_two_beta : public CMap_dart_iterator { public: - typedef CMap_dart_iterator_basic_of_orbit_generic Self; + typedef CMap_dart_iterator_basic_of_two_beta Self; typedef CMap_dart_iterator Base; typedef typename Base::Dart_handle Dart_handle; @@ -941,124 +817,126 @@ namespace CGAL { typedef Tag_false Use_mark; + CGAL_static_assertion( Bi>1 && Bi+1<=Map::dimension ); + public: /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart): + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart): Base(amap, adart), mfirst_dir(true), - mnext_try_beta2(true) + mnext_try_betai(true) {} /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, - int /*amark*/): + CMap_dart_iterator_basic_of_two_beta(Map& amap, Dart_handle adart, + int /*amark*/): Base(amap, adart), mfirst_dir(true), - mnext_try_beta2(true) + mnext_try_betai(true) {} - + /// Rewind of the iterator to its beginning. void rewind() { Base::rewind(); mfirst_dir = true; - mnext_try_beta2 = true; + mnext_try_betai = true; } /// Prefix ++ operator. Self& operator++() { CGAL_assertion(this->cont()); - + if (mfirst_dir) - { - if (mnext_try_beta2) - { - if ((*this)->is_free(2)) - { - mfirst_dir = false; - if (this->mfirst_dart->is_free(3)) - { - this->mprev_op = OP_END; - this->set_current_dart(NULL); - } - else - { - this->set_current_dart(this->mfirst_dart->beta(3)); - this->mprev_op = OP_JUMP; - } - } - else - { - this->set_current_dart((*this)->beta(2)); - mnext_try_beta2 = false; - this->mprev_op = OP_BETAI; - } - } - else - { - if ((*this)->is_free(3)) - { - mfirst_dir = false; - if (this->mfirst_dart->is_free(3)) - { - this->mprev_op = OP_END; - this->set_current_dart(NULL); - } - else - { - this->set_current_dart(this->mfirst_dart->beta(3)); - mnext_try_beta2 = true; - this->mprev_op = OP_JUMP; - } - } - else - { - this->set_current_dart((*this)->beta(3)); - if ((*this)==this->mfirst_dart) - { - this->mprev_op = OP_END; - this->set_current_dart(NULL); - } - else - { - mnext_try_beta2 = true; - this->mprev_op = OP_BETAJ; - } - } - } - } + { + if (mnext_try_betai) + { + if ((*this)->is_free(Bi)) + { + mfirst_dir = false; + if (this->mfirst_dart->is_free(Bi+1)) + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + else + { + this->set_current_dart(this->mfirst_dart->beta(Bi+1)); + this->mprev_op = OP_JUMP; + } + } + else + { + this->set_current_dart((*this)->beta(Bi)); + mnext_try_betai = false; + this->mprev_op = OP_BETAI; + } + } + else + { + if ((*this)->is_free(Bi+1)) + { + mfirst_dir = false; + if (this->mfirst_dart->is_free(Bi+1)) + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + else + { + this->set_current_dart(this->mfirst_dart->beta(Bi+1)); + mnext_try_betai = true; + this->mprev_op = OP_JUMP; + } + } + else + { + this->set_current_dart((*this)->beta(Bi+1)); + if ((*this)==this->mfirst_dart) + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + else + { + mnext_try_betai = true; + this->mprev_op = OP_BETAJ; + } + } + } + } else - { - if (mnext_try_beta2) - { - if ((*this)->is_free(2)) - { - this->mprev_op = OP_END; - this->set_current_dart(NULL); - } - else - { - this->set_current_dart((*this)->beta(2)); - mnext_try_beta2 = false; - this->mprev_op = OP_BETAI; - } - } - else - { - if ((*this)->is_free(3)) - { - this->mprev_op = OP_END; - this->set_current_dart(NULL); - } - else - { - this->set_current_dart((*this)->beta(3)); - mnext_try_beta2 = true; - this->mprev_op = OP_BETAJ; - } - } - } + { + if (mnext_try_betai) + { + if ((*this)->is_free(Bi)) + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + else + { + this->set_current_dart((*this)->beta(Bi)); + mnext_try_betai = false; + this->mprev_op = OP_BETAI; + } + } + else + { + if ((*this)->is_free(Bi+1)) + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + else + { + this->set_current_dart((*this)->beta(Bi+1)); + mnext_try_betai = true; + this->mprev_op = OP_BETAJ; + } + } + } return *this; } @@ -1067,103 +945,111 @@ namespace CGAL { { Self res=*this; operator ++(); return res; } private: - /// Boolean: true iff we turn in the first direction (i.e. using beta2). + /// Boolean: true iff we turn in the first direction (i.e. using betai). bool mfirst_dir; - /// Boolean: true iff the next ++ must use beta2. - bool mnext_try_beta2; + /// Boolean: true iff the next ++ must use betai. + bool mnext_try_betai; }; //**************************************************************************** - /* Class CMap_dart_iterator_basic_of_orbit: to iterate onto - * the darts of the orbit , Bi, , which are specific cases. + /* Class CMap_dart_iterator_basic_of_orbit: to iterate + * on the darts of the orbit : Bi - class CMap_dart_iterator_basic_of_orbit_generic: - public CMap_dart_iterator_basic_of_orbit_generic + template + class CMap_dart_iterator_basic_of_orbit_generic: + public CMap_dart_iterator_basic_of_two_beta { public: - typedef CMap_dart_iterator_basic_of_orbit_generic Self; - typedef CMap_dart_iterator_basic_of_orbit_generic Base; + typedef CMap_dart_iterator_basic_of_orbit_generic Self; + typedef CMap_dart_iterator_basic_of_two_beta Base; typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Map Map; - typedef Tag_true Use_mark; + typedef typename Base::Use_mark Use_mark; + + public: + /// Main constructor. + CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart) : + Base(amap, adart) + {} + + /// Main constructor. + CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, + int amark): + Base(amap, adart, amark) + {} + }; + //**************************************************************************** + /* Generic nD version. + */ +#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + template + class CMap_dart_iterator_basic_of_orbit_generic: + public CMap_extend_iterator, + Bk> + { + public: + typedef CMap_dart_iterator_basic_of_orbit_generic + Self; + typedef CMap_extend_iterator, + Bk> Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; public: /// Main constructor. CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, - int amark): + int amark): Base(amap, adart, amark) - { - CGAL_assertion( Biis_free(Bk) && - !this->mmap->is_marked(adart->beta(Bk), this->mmark_number)) - this->mto_treat.push(adart->beta(Bk)); - } - } - - /// Rewind of the iterator to its beginning. - void rewind() - { - CGAL_assertion(this->mmark_number != -1); - Base::rewind(); - if (!(*this)->is_free(Bk) && - !this->mmap->is_marked((*this)->beta(Bk), - this->mmark_number)) - this->mto_treat.push((*this)->beta(Bk)); - } - - /// Prefix ++ operator. - Self& operator++() - { - Base::operator++(); - - if ( this->cont() ) - { - if (!(*this)->is_free(Bk) && - !this->mmap->is_marked((*this)->beta(Bk), - this->mmark_number)) - this->mto_treat.push((*this)->beta(Bk)); - } - return *this; - } - - /// Postfix ++ operator. - Self operator++(int) - { Self res=*this; operator ++(); return res; } + {} }; - //**************************************************************************** - template - class CMap_dart_iterator_basic_of_orbit_generic: - public CMap_extend_iterator, Bk> +#else //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + template + class CMap_dart_iterator_basic_of_orbit_generic: + public CMap_extend_iterator + ::type, B3> { public: - typedef CMap_dart_iterator_basic_of_orbit_generic Self; - typedef CMap_extend_iterator, Bk> Base; + typedef typename Get_CMap_dart_iterator_basic_of_orbit + ::type Self; + + typedef CMap_extend_iterator + ::type, B3> Base; typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Map Map; - typedef Tag_true Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; public: /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, - int amark): + CMap_dart_iterator_basic_of_orbit_generic(Map& amap, Dart_handle adart, + int amark): Base(amap, adart, amark) - { CGAL_assertion( Bi<3 && 3 when + // 1 class CMap_dart_iterator_basic_of_orbit: public CMap_dart_iterator_basic_of_orbit_generic @@ -1211,6 +1097,65 @@ namespace CGAL { }; #endif // CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES //**************************************************************************** + /* Class CMap_dart_iterator_basic_of_all: to iterate onto all the + * darts of the map. + */ + template + class CMap_dart_iterator_basic_of_all: public CMap_dart_iterator + { + public: + typedef CMap_dart_iterator_basic_of_all Self; + typedef CMap_dart_iterator Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + typedef Tag_false Use_mark; + + public: + /// Main constructor. + CMap_dart_iterator_basic_of_all(Map& amap): + Base(amap, amap.darts().begin()) + {} + /// Main constructor. + CMap_dart_iterator_basic_of_all(Map& amap, int /*amark*/): + Base(amap, amap.darts().begin()) + {} + + /// Constructor with a dart in parameter (for end iterator). + CMap_dart_iterator_basic_of_all(Map& amap, Dart_handle adart): + Base(amap, adart) + {} + /// Constructor with a dart in parameter (for end iterator). + CMap_dart_iterator_basic_of_all(Map& amap, Dart_handle adart, + int /*amark*/): + Base(amap, adart) + {} + + /// Prefix ++ operator. + Self& operator++() + { + CGAL_assertion(this->cont()); + + Base::operator++(); + if ( (*this) != this->mmap->darts().end()) + { this->mprev_op = OP_POP; } + else + { + this->set_current_dart(NULL); + this->mprev_op = OP_END; + } + return *this; + } + + /// Postfix ++ operator. + Self operator++(int) + { Self res=*this; operator ++(); return res; } + }; + //**************************************************************************** + //***************************CELL*ITERATORS*********************************** + //**************************************************************************** + //**************************************************************************** // i-Cell iterator in combinatorial map of dimension d, i>1 // i<=Map::dimension+1 (for i==Map::dimension+1, iterate on the connected // component) @@ -1226,6 +1171,8 @@ namespace CGAL { typedef Tag_true Use_mark; + CGAL_static_assertion( i>1 && i<=Map::dimension+1 ); + public: /// Main constructor. CMap_dart_iterator_basic_of_cell(Map& amap, @@ -1234,7 +1181,6 @@ namespace CGAL { Base(amap, adart), mmark_number(amark) { - CGAL_assertion( i>=2 && i<=Map::dimension+1 ); if (adart!=NULL) this->mmap->mark(adart, mmark_number); } @@ -1254,31 +1200,143 @@ namespace CGAL { CGAL_assertion(mmark_number != -1); CGAL_assertion(this->cont()); Dart_handle nd = NULL; + + for ( unsigned int k=0; kis_unmarked((*this), k, mmark_number) ) + { + if (nd == NULL) + { + nd = (*this)->beta(k); + CGAL_assertion(nd!=Map::null_dart_handle); + this->mmap->mark(nd, mmark_number); + this->mprev_op = OP_BETAI; + } + else + { + mto_treat.push((*this)->beta(k)); + this->mmap->mark((*this)->beta(k), mmark_number); + } + } + } + for ( unsigned int k=i+1; k<=d; ++k ) + { + if ( this->is_unmarked((*this), k, mmark_number) ) + { + if (nd == NULL) + { + nd = (*this)->beta(k); + CGAL_assertion(nd!=Map::null_dart_handle); + this->mmap->mark(nd, mmark_number); + this->mprev_op = OP_BETAI; + } + else + { + mto_treat.push((*this)->beta(k)); + this->mmap->mark((*this)->beta(k), mmark_number); + } + } + } - for ( unsigned int k=0; k<=d; ++k ) - { - if ( k!=i && this->is_unmarked((*this), k, mmark_number) ) - { - if (nd == NULL) - { - nd = (*this)->beta(k); - CGAL_assertion(nd!=Map::null_dart_handle); - this->mmap->mark(nd, mmark_number); - this->mprev_op = OP_BETAI; - } - else - { - mto_treat.push((*this)->beta(k)); - this->mmap->mark((*this)->beta(k), mmark_number); - } - } - } + if (nd == NULL) + { + if (!mto_treat.empty()) + { + nd = mto_treat.front(); + mto_treat.pop(); + this->mprev_op = OP_POP; + } + else + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + } + + this->set_current_dart(nd); + return *this; + } + + /// Postfix ++ operator. + Self operator++(int) + { Self res=*this; operator ++(); return res; } + + protected: + /// Queue of darts to process. + std::queue mto_treat; + + /// Index of the used mark. + int mmark_number; + }; + //**************************************************************************** + // i-Cell iterator in combinatorial map of dimension d, i==1. + template + class CMap_dart_iterator_basic_of_cell: + public CMap_dart_iterator + { + public: + typedef CMap_dart_iterator_basic_of_cell Self; + typedef CMap_dart_iterator Base; + + typedef typename Base::Dart_handle Dart_handle; + typedef typename Base::Map Map; + + typedef Tag_true Use_mark; + + public: + /// Main constructor. + CMap_dart_iterator_basic_of_cell(Map& amap, + Dart_handle adart, + int amark): + Base(amap, adart), + mmark_number(amark) + { + if (adart!=NULL) + this->mmap->mark(adart, mmark_number); + } + + /// Rewind of the iterator to its beginning. + void rewind() + { + CGAL_assertion(mmark_number != -1); + Base::rewind(); + mto_treat = std::queue(); + this->mmap->mark((*this), mmark_number); + } + + /// Prefix ++ operator. + Self& operator++() + { + CGAL_assertion(mmark_number != -1); + CGAL_assertion(this->cont()); + + Dart_handle nd = NULL; + + for ( unsigned int k=2; k<=d; ++k ) + { + if ( this->is_unmarked((*this), k, mmark_number) ) + { + if (nd == NULL) + { + nd = (*this)->beta(k); + CGAL_assertion(nd!=Map::null_dart_handle); + this->mmap->mark(nd, mmark_number); + this->mprev_op = OP_BETAI; + } + else + { + mto_treat.push((*this)->beta(k)); + this->mmap->mark((*this)->beta(k), mmark_number); + } + } + } if (nd == NULL) { if (!mto_treat.empty()) { nd = mto_treat.front(); + CGAL_assertion(nd!=Map::null_dart_handle); mto_treat.pop(); this->mprev_op = OP_POP; } @@ -1319,148 +1377,6 @@ namespace CGAL { typedef Tag_true Use_mark; - public: - /// Main constructor. - CMap_dart_iterator_basic_of_cell(Map& amap, - Dart_handle adart, - int amark): - Base(amap, adart), - mmark_number(amark) - { - if (adart!=NULL) this->mmap->mark(adart, mmark_number); - } - - /// Rewind of the iterator to its beginning. - void rewind() - { - CGAL_assertion(mmark_number != -1); - Base::rewind(); - mto_treat = std::queue(); - this->mmap->mark((*this), mmark_number); - } - - /// Prefix ++ operator. - Self& operator++() - { - CGAL_assertion(mmark_number != -1); - CGAL_assertion(this->cont()); - - Dart_handle nd = NULL; - - for ( unsigned int k=2; k<=d; ++k ) - { - if ( this->is_unmarked2((*this), 0, k, mmark_number) ) - { - if (nd == NULL) - { - nd = (*this)->beta(0)->beta(k); - CGAL_assertion(nd!=Map::null_dart_handle); - this->mmap->mark(nd, mmark_number); - this->mprev_op = OP_BETA0I; - } - else - { - mto_treat.push((*this)->beta(0)->beta(k)); - this->mmap->mark((*this)->beta(0)->beta(k), mmark_number); - } - - } - if ( this->is_unmarked2((*this), k, 1, mmark_number) ) - { - if (nd == NULL) - { - nd = (*this)->beta(k)->beta(1); - CGAL_assertion(nd!=Map::null_dart_handle); - this->mmap->mark(nd, mmark_number); - this->mprev_op = OP_BETAI1; - } - else - { - mto_treat.push((*this)->beta(k)->beta(1)); - this->mmap->mark((*this)->beta(k)->beta(1), mmark_number); - } - } - for ( unsigned int l=k+1; l<=d; ++l ) - { - if ( this->is_unmarked2((*this), k, l, mmark_number) ) - { - if (nd == NULL) - { - nd = (*this)->beta(k)->beta(l); - CGAL_assertion(nd!=Map::null_dart_handle); - this->mmap->mark(nd, mmark_number); - this->mprev_op = OP_BETAIJ; - } - else - { - mto_treat.push((*this)->beta(k)->beta(l)); - this->mmap->mark((*this)->beta(k)->beta(l), mmark_number); - } - } - if ( this->is_unmarked2((*this), l, k, mmark_number) ) - { - if (nd == NULL) - { - nd = (*this)->beta(l)->beta(k); - CGAL_assertion(nd!=Map::null_dart_handle); - this->mmap->mark(nd, mmark_number); - this->mprev_op = OP_BETAJI; - } - else - { - mto_treat.push((*this)->beta(l)->beta(k)); - this->mmap->mark((*this)->beta(l)->beta(k), mmark_number); - } - } - } - } - - if (nd == NULL) - { - if (!mto_treat.empty()) - { - nd = mto_treat.front(); - CGAL_assertion(nd!=Map::null_dart_handle); - mto_treat.pop(); - this->mprev_op = OP_POP; - } - else - { - this->mprev_op = OP_END; - this->set_current_dart(NULL); - } - } - - this->set_current_dart(nd); - return *this; - } - - /// Postfix ++ operator. - Self operator++(int) - { Self res=*this; operator ++(); return res; } - - protected: - /// Queue of darts to process. - std::queue mto_treat; - - /// Index of the used mark. - int mmark_number; - }; - //**************************************************************************** - // 1-Cell iterator in combinatorial map of dimension d - template - class CMap_dart_iterator_basic_of_cell: - public CMap_dart_iterator - { - public: - typedef CMap_dart_iterator_basic_of_cell Self; - typedef CMap_dart_iterator Base; - - typedef typename Base::Dart_handle Dart_handle; - typedef typename Base::Map Map; - - typedef Tag_true Use_mark; - public: /// Main constructor. CMap_dart_iterator_basic_of_cell(Map& amap, @@ -1488,37 +1404,87 @@ namespace CGAL { Dart_handle nd = NULL; for ( unsigned int k=2; k<=d; ++k ) - { - if ( this->is_unmarked((*this), k, mmark_number) ) - { - if (nd == NULL) - { - nd = (*this)->beta(k); - CGAL_assertion(nd!=Map::null_dart_handle); - this->mmap->mark(nd, mmark_number); - this->mprev_op = OP_BETAI; - } - else - { - mto_treat.push((*this)->beta(k)); - this->mmap->mark((*this)->beta(k), mmark_number); - } - } - } + { + if ( this->is_unmarked2((*this), 0, k, mmark_number) ) + { + if (nd == NULL) + { + nd = (*this)->beta(0)->beta(k); + CGAL_assertion(nd!=Map::null_dart_handle); + this->mmap->mark(nd, mmark_number); + this->mprev_op = OP_BETA0I; + } + else + { + mto_treat.push((*this)->beta(0)->beta(k)); + this->mmap->mark((*this)->beta(0)->beta(k), mmark_number); + } + } + if ( this->is_unmarked2((*this), k, 1, mmark_number) ) + { + if (nd == NULL) + { + nd = (*this)->beta(k)->beta(1); + CGAL_assertion(nd!=Map::null_dart_handle); + this->mmap->mark(nd, mmark_number); + this->mprev_op = OP_BETAI1; + } + else + { + mto_treat.push((*this)->beta(k)->beta(1)); + this->mmap->mark((*this)->beta(k)->beta(1), mmark_number); + } + } + for ( unsigned int l=k+1; l<=d; ++l ) + { + if ( this->is_unmarked2((*this), k, l, mmark_number) ) + { + if (nd == NULL) + { + nd = (*this)->beta(k)->beta(l); + CGAL_assertion(nd!=Map::null_dart_handle); + this->mmap->mark(nd, mmark_number); + this->mprev_op = OP_BETAIJ; + } + else + { + mto_treat.push((*this)->beta(k)->beta(l)); + this->mmap->mark((*this)->beta(k)->beta(l), mmark_number); + } + } + if ( this->is_unmarked2((*this), l, k, mmark_number) ) + { + if (nd == NULL) + { + nd = (*this)->beta(l)->beta(k); + CGAL_assertion(nd!=Map::null_dart_handle); + this->mmap->mark(nd, mmark_number); + this->mprev_op = OP_BETAJI; + } + else + { + mto_treat.push((*this)->beta(l)->beta(k)); + this->mmap->mark((*this)->beta(l)->beta(k), mmark_number); + } + } + } + } if (nd == NULL) - { - if (!mto_treat.empty()) - { - nd = mto_treat.front(); - mto_treat.pop(); - this->mprev_op = OP_POP; - } - else - { - this->mprev_op = OP_END; - } - } + { + if (!mto_treat.empty()) + { + nd = mto_treat.front(); + CGAL_assertion(nd!=Map::null_dart_handle); + mto_treat.pop(); + this->mprev_op = OP_POP; + } + else + { + this->mprev_op = OP_END; + this->set_current_dart(NULL); + } + } this->set_current_dart(nd); return *this; @@ -1792,227 +1758,9 @@ namespace CGAL { /// Boolean: true iff we turn in the first direction (i.e. using beta02). bool mfirst_dir; }; - //**************************************************************************** - /* Class CMap_dart_iterator_basic_of_all: to iterate onto all the - * darts of the map. - */ - template - class CMap_dart_iterator_basic_of_all: public CMap_dart_iterator - { - public: - typedef CMap_dart_iterator_basic_of_all Self; - typedef CMap_dart_iterator Base; - - typedef typename Base::Dart_handle Dart_handle; - typedef typename Base::Map Map; - - typedef Tag_false Use_mark; - - public: - /// Main constructor. - CMap_dart_iterator_basic_of_all(Map& amap): - Base(amap, amap.darts().begin()) - {} - - /// Main constructor. - CMap_dart_iterator_basic_of_all(Map& amap, int /*amark*/): - Base(amap, amap.darts().begin()) - {} - - /// Prefix ++ operator. - Self& operator++() - { - CGAL_assertion(this->cont()); - - Base::operator++(); - if ( (*this) != this->mmap->darts().end()) - { this->mprev_op = OP_POP; } - else - { - this->set_current_dart(NULL); - this->mprev_op = OP_END; - } - return *this; - } - - /// Postfix ++ operator. - Self operator++(int) - { Self res=*this; operator ++(); return res; } - }; - //************************************************************************** - /* Generic nD version. Here we are sure that all the bases classes use mark - * and queue. - */ - #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - template - class CMap_dart_iterator_basic_of_orbit_generic: - public CMap_dart_iterator_basic_of_orbit_generic - { - public: - typedef CMap_dart_iterator_basic_of_orbit_generic Self; - typedef CMap_dart_iterator_basic_of_orbit_generic Base; - - typedef typename Base::Dart_handle Dart_handle; - typedef typename Base::Map Map; - - typedef Tag_true Use_mark; - - public: - /// Main constructor. - CMap_dart_iterator_basic_of_orbit_generic(Map& amap, - Dart_handle adart, - int amark): - Base(amap, adart, amark) - { - CGAL_assertion( Bi>=0 && Bi<=Map::dimension ); - - if (adart!=NULL) - { - if (!adart->is_free(Bi) && - !this->mmap->is_marked(adart->beta(Bi), this->mmark_number)) - this->mto_treat.push(adart->beta(Bi)); - } - } - - /// Rewind of the iterator to its beginning. - void rewind() - { - CGAL_assertion(this->mmark_number != -1); - Base::rewind(); - if (!(*this)->is_free(Bi) && - !this->mmap->is_marked((*this)->beta(Bi), - this->mmark_number)) - this->mto_treat.push((*this)->beta(Bi)); - } - - /// Prefix ++ operator. - Self& operator++() - { - CGAL_assertion(this->cont()); - - Base::operator++(); - - if (this->cont()) - { - if (!(*this)->is_free(Bi) && - !this->mmap->is_marked((*this)->beta(Bi), - this->mmark_number)) - this->mto_treat.push((*this)->beta(Bi)); - } - return *this; - } - - /// Postfix ++ operator. - Self operator++(int) - { Self res=*this; operator ++(); return res; } - }; -#endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES //**************************************************************************** //*************************ITERATORS*NON*BASIC********************************* //**************************************************************************** - //* Class CMap_non_basic_iterator allows to transform a basic_iterator onto - //* a non basic one, depending if the basic iterator uses mark or not. - template - class CMap_non_basic_iterator; - //**************************************************************************** - template - class CMap_non_basic_iterator: - public Basic_iterator - { - public: - typedef CMap_non_basic_iterator Self; - - typedef typename Basic_iterator::Map Map; - typedef typename Basic_iterator::Dart_handle Dart_handle; - - /// Main constructor. - CMap_non_basic_iterator(Map& amap, Dart_handle adart1): - Basic_iterator(amap, adart1, amap.get_new_mark()) - { CGAL_assertion( Basic_iterator::is_basic_iterator() ); } - - /// Destructor. - ~CMap_non_basic_iterator() - { - if (this->mmark_number != -1) - { - unmark_treated_darts(); - CGAL_assertion( this->mmap->is_whole_map_unmarked - (this->mmark_number) ); - this->mmap->free_mark(this->mmark_number); - } - } - - /// Copy constructor. - CMap_non_basic_iterator(const Self& aiterator): - Basic_iterator(aiterator) - { this->mmark_number = -1; } - - /// Assignment operator. - Self& operator=(const Self& aiterator) - { - if (this != &aiterator) - { - Basic_iterator::operator=(aiterator); - this->mmark_number = -1; - } - return *this; - } - - /// Rewind of the iterator to its beginning. - void rewind() - { - CGAL_assertion(this->mmark_number != -1); - unmark_treated_darts(); - Basic_iterator::rewind(); - } - - using Basic_iterator::operator++; - - /// Postfix ++ operator. - void operator++(int) - { operator ++(); } - - /// Return true iff this iterator is basic - static bool is_basic_iterator() - { return false; } - - protected: - /// Unmark all the marked darts during the iterator. - void unmark_treated_darts() - { - CGAL_assertion(this->mmark_number != -1); - if (this->mmap->is_whole_map_unmarked(this->mmark_number)) return; - - this->mmap->negate_mark(this->mmark_number); - - if (this->mmap->is_whole_map_unmarked(this->mmark_number)) return; - - Basic_iterator::rewind(); - while (this->mmap->number_of_unmarked_darts(this->mmark_number) > 0) - this->operator++(); - this->mmap->negate_mark(this->mmark_number); - CGAL_assertion(this->mmap->is_whole_map_unmarked(this->mmark_number)); - } - }; - //**************************************************************************** - template - class CMap_non_basic_iterator: - public Basic_iterator - { - public: - typedef CMap_non_basic_iterator Self; - typedef typename Basic_iterator::Map Map; - typedef typename Basic_iterator::Dart_handle Dart_handle; - - /// Main constructor. - CMap_non_basic_iterator(Map& amap, Dart_handle adart): - Basic_iterator(amap, adart,-1) - {} - /// Return true iff this iterator is basic - static bool is_basic_iterator() - { return false; } - }; //**************************************************************************** #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES template @@ -2141,6 +1889,9 @@ namespace CGAL { typedef Tag_true Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2149,8 +1900,8 @@ namespace CGAL { Base(amap, adart), mmark_number(amark) { - CGAL_assertion( d>=3 && d<=Map::dimension ); - CGAL_assertion( i>=3 && i<=Map::dimension ); + CGAL_static_assertion( d>=3 && d<=Map::dimension ); + CGAL_static_assertion( i>=3 && i<=Map::dimension ); if (adart!=NULL) this->mmap->mark(adart, mmark_number); } @@ -2258,6 +2009,9 @@ namespace CGAL { typedef Tag_true Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, @@ -2266,7 +2020,7 @@ namespace CGAL { Base(amap, adart), mmark_number(amark) { - CGAL_assertion( i>=3 && i<=Map::dimension ); + CGAL_static_assertion( i>=3 && i<=Map::dimension ); if (adart!=NULL) this->mmap->mark(adart, mmark_number); } @@ -2371,6 +2125,9 @@ namespace CGAL { typedef Tag_true Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2462,6 +2219,9 @@ namespace CGAL { typedef Tag_true Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, @@ -2486,6 +2246,9 @@ namespace CGAL { typedef Tag_true Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2577,6 +2340,9 @@ namespace CGAL { typedef Tag_true Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, @@ -2601,6 +2367,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2630,6 +2399,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, @@ -2659,6 +2431,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2688,6 +2463,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, @@ -2717,6 +2495,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2746,6 +2527,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, @@ -2775,6 +2559,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2804,6 +2591,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, @@ -2833,6 +2623,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution(Map& amap, @@ -2862,6 +2655,9 @@ namespace CGAL { typedef Tag_false Use_mark; + /// True iff this iterator is basic + typedef Tag_true Basic_iterator; + public: /// Main constructor. CMap_dart_iterator_basic_of_involution_inv(Map& amap, diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h index 5a0b1ef34e0..80b19d9e7b2 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h @@ -51,7 +51,7 @@ namespace CGAL { typename Map::Dart_const_handle adart1, typename Map::Dart_const_handle adart2) { - CGAL_assertion(2<=i && i<=Map::dimension); + CGAL_static_assertion(2<=i && i<=Map::dimension); CGAL_assertion(adart1!=NULL && adart2!=NULL); if ( !adart1->is_free(i) || !adart2->is_free(i) || adart1==adart2 ) @@ -144,7 +144,7 @@ namespace CGAL { static void run(Map& amap,typename Map::Dart_handle adart1, typename Map::Dart_handle adart2) { - CGAL_assertion(2<=i && i<=Map::dimension); + CGAL_static_assertion(2<=i && i<=Map::dimension); CGAL_assertion( (is_sewable_functor::run(amap,adart1,adart2)) ); CMap_dart_iterator_of_involution I1(amap, adart1); @@ -205,7 +205,7 @@ namespace CGAL { static void run(Map& amap,typename Map::Dart_handle adart1, typename Map::Dart_handle adart2) { - CGAL_assertion(2<=i && i<=Map::dimension); + CGAL_static_assertion(2<=i && i<=Map::dimension); CGAL_assertion( (is_sewable_functor::run(amap,adart1,adart2)) ); CMap_dart_iterator_of_involution I1(amap, adart1); @@ -312,7 +312,7 @@ namespace CGAL { static void run(Map& amap,typename Map::Dart_handle adart) { CGAL_assertion( adart!=NULL && !adart->is_free(i) ); - CGAL_assertion(2<=i && i<=Map::dimension); + CGAL_static_assertion(2<=i && i<=Map::dimension); CMap_dart_iterator_of_involution it(amap, adart); while ( it.cont() ) @@ -372,7 +372,7 @@ namespace CGAL { struct unsew_functor{ static void run(Map& amap,typename Map::Dart_handle adart) { - CGAL_assertion(2<=i && i<=Map::dimension); + CGAL_static_assertion(2<=i && i<=Map::dimension); CGAL_assertion( adart!=NULL && !adart->is_free(i) ); std::stack > todegroup; @@ -478,7 +478,7 @@ namespace CGAL { typename Map::Dart_handle adart2) { CGAL_assertion(adart1 != NULL && adart2 != NULL && adart1!=adart2); - CGAL_assertion( i>=2 && i<=Map::dimension ); + CGAL_static_assertion( i>=2 && i<=Map::dimension ); adart1->basic_link_beta(adart2, i); adart2->basic_link_beta(adart1, i); } @@ -514,7 +514,7 @@ namespace CGAL { static void run(Map&,typename Map::Dart_handle adart) { CGAL_assertion(adart != NULL && !adart->is_free(i)); - CGAL_assertion(2<=i && i<=Map::dimension); + CGAL_static_assertion(2<=i && i<=Map::dimension); adart->beta(i)->unlink_beta(i); adart->unlink_beta(i); } @@ -889,7 +889,7 @@ namespace CGAL { typename CMap::Dart_handle adart2) { CGAL_assertion(adart1 != NULL && adart2 != NULL && adart1!=adart2 ); - CGAL_assertion( 2<=i && i<=CMap::dimension ); + CGAL_static_assertion( 2<=i && i<=CMap::dimension ); adart1->basic_link_beta(adart2, i); adart2->basic_link_beta(adart1, i); CMap::Helper::template Foreach_enabled_attributes diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h index fee79ded604..30c90f9b84d 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_utility.h @@ -23,1439 +23,299 @@ #include #include #include -#include - -#ifdef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES -#include -#include -#endif - namespace CGAL { - // struct Disabled {}; // If we want to use CGAL::Disabled for disabled attributes - // typedef CGAL::Void Disabled; - // typedef void Disabled; // If we wand to use void, does not compile on windows - namespace internal { - // There is a problem on windows to handle tuple containing void. To solve this, we - // transform such a tuple in tuple containing Disabled. - template - struct Convert_void - { typedef T type; }; - - template<> - struct Convert_void - { typedef CGAL::Void type; }; - - #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - template - struct Convert_tuple_with_void; + // There is a problem on windows to handle tuple containing void. + // To solve this, we transform such a tuple in tuple containing Disabled. + template + struct Convert_void + { typedef T type; }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type... > type; - }; - - template - struct My_length; - template - struct My_length > - { - static const int value = My_length >::value + 1; - }; - - template<> - struct My_length > - { - static const int value = 0; - }; - - -#else //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES - template - struct Convert_tuple_with_void; - - template <> - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple<> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type > type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type, - typename Convert_void::type> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type> type; - }; - template - struct Convert_tuple_with_void > - { - typedef CGAL::cpp0x::tuple::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type, - typename Convert_void::type> type; - }; - template - struct My_length; - - template <> - struct My_length > - { - static const int value = 0; - }; - template - struct My_length > - { - static const int value = 1; - }; - template - struct My_length > - { - static const int value = 2; - }; - template - struct My_length > - { - static const int value = 3; - }; - template - struct My_length > - { - static const int value = 4; - }; - template - struct My_length > - { - static const int value = 5; - }; - template - struct My_length > - { - static const int value = 6; - }; - template - struct My_length > - { - static const int value = 7; - }; - template - struct My_length > - { - static const int value = 8; - }; - template - struct My_length > - { - static const int value = 9; - }; -#endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + template<> + struct Convert_void + { typedef CGAL::Void type; }; #ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES -//count the number of time a given type is present in a tuple -template -struct Number_of_type_in_tuple; - -template -struct Number_of_type_in_tuple >{ - static const int value=Number_of_type_in_tuple >::value+1; -}; + // Convert a tuple in a same tuple where each void type was replaced into + // CGAL::Void. + template + struct Convert_tuple_with_void; + template + struct Convert_tuple_with_void > + { + typedef CGAL::cpp0x::tuple::type... > type; + }; -template -struct Number_of_type_in_tuple >{ - static const int value=Number_of_type_in_tuple >::value; -}; + // Length of a variadic template + template + struct My_length; + template + struct My_length > + { + static const int value = My_length >::value + 1; + }; + template<> + struct My_length > + { + static const int value = 0; + }; -template -struct Number_of_type_in_tuple >{ - static const int value=0; -}; -#endif //CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES + //count the number of time a given type is present in a tuple + template + struct Number_of_type_in_tuple; + template + struct Number_of_type_in_tuple >{ + static const int value=Number_of_type_in_tuple + >::value+1; + }; + template + struct Number_of_type_in_tuple >{ + static const int value=Number_of_type_in_tuple + >::value; + }; + template + struct Number_of_type_in_tuple >{ + static const int value=0; + }; -//count the number of different types from Type is present in a tuple -#ifndef CGAL_CFG_NO_CPP0X_VARIADIC_TEMPLATES -template -struct Number_of_different_type_in_tuple; - -template -struct Number_of_different_type_in_tuple > -{ - static const int value=Number_of_different_type_in_tuple >::value+1; -}; + //count the number of different types from Type is present in a tuple + template + struct Number_of_different_type_in_tuple; + template + struct Number_of_different_type_in_tuple > + { + static const int value=Number_of_different_type_in_tuple + >::value+1; + }; + template + struct Number_of_different_type_in_tuple > + { + static const int value=Number_of_different_type_in_tuple + >::value; + }; + template + struct Number_of_different_type_in_tuple > + { + static const int value=0; + }; -template -struct Number_of_different_type_in_tuple > -{ - static const int value=Number_of_different_type_in_tuple >::value; -}; + //count the number of time a given type have been found + //within a tuple, until reaching position the k'th type of the tuple. + //dim is the total size of the tuple + template ::value-1> + struct Nb_type_in_tuple_up_to_k; + + template + struct Nb_type_in_tuple_up_to_k,dim> + { + static const int pos= Nb_type_in_tuple_up_to_k + ,dim>::pos - 1; + + static const int value = + ( pos==k ) ? ( boost::is_same::value ? 0:-dim-1 ) + : ( ( pos::value ? 1:0 ) + + Nb_type_in_tuple_up_to_k + ,dim >::value) + :0 + ); + }; + + template + struct Nb_type_in_tuple_up_to_k,dim > + { + static const int pos=dim; + static const int value=(pos==k? + (boost::is_same::value?0:-dim-1) : + 0); + }; -template -struct Number_of_different_type_in_tuple > -{ - static const int value=0; -}; + //count the number of time a type different from Type have been found + //within a tuple, until reaching position the k'th type of the tuple. + //dim is the total size of the tuple + template ::value-1> + struct Nb_type_different_in_tuple_up_to_k; + + template + struct Nb_type_different_in_tuple_up_to_k,dim> + { + static const int pos = Nb_type_different_in_tuple_up_to_k + ,dim >::pos - 1; + + static const int value = + ( pos==k ) ? ( boost::is_same::value ? -dim-1 : 0 ) + : ( ( pos::value ? 0:1 ) + + Nb_type_different_in_tuple_up_to_k + ,dim >::value) + :0 + ); + }; + + template + struct Nb_type_different_in_tuple_up_to_k,dim > + { + static const int pos=dim; + static const int value=(pos==k? + (boost::is_same::value?-dim-1:0) : + 0); + }; + + //Convert a tuple of T... to a tuple of Functor::type... + template