Update generalized maps.

This commit is contained in:
Guillaume Damiand 2016-03-07 14:00:06 +01:00
parent 96e3ded2a5
commit 84518582f4
7 changed files with 546 additions and 511 deletions

View File

@ -45,7 +45,7 @@ namespace CGAL {
* n is the dimension of the space (2 for 2D, 3 for 3D...) * n is the dimension of the space (2 for 2D, 3 for 3D...)
* Refs the ref class * Refs the ref class
*/ */
template <int d, typename Refs> template <unsigned int d, typename Refs>
struct GMap_dart struct GMap_dart
{ {
template < unsigned int, class, class, class, class > template < unsigned int, class, class, class, class >

View File

@ -560,6 +560,7 @@ namespace CGAL {
typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Dart_handle Dart_handle;
typedef typename Base::Map Map; typedef typename Base::Map Map;
typedef typename Map::size_type size_type;
typedef Tag_false Use_mark; ///< True iff this iterator uses mark typedef Tag_false Use_mark; ///< True iff this iterator uses mark
typedef Tag_true Basic_iterator; ///< True iff this iterator is basic typedef Tag_true Basic_iterator; ///< True iff this iterator is basic
@ -599,6 +600,8 @@ namespace CGAL {
typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Dart_handle Dart_handle;
typedef typename Base::Map Map; typedef typename Base::Map Map;
typedef typename Map::size_type size_type;
typedef Tag_true Basic_iterator; ///< True iff this iterator is basic typedef Tag_true Basic_iterator; ///< True iff this iterator is basic
CGAL_static_assertion( Bi<Bj && Bj<Bk && Bk<=Map::dimension ); CGAL_static_assertion( Bi<Bj && Bj<Bk && Bk<=Map::dimension );
@ -629,6 +632,8 @@ namespace CGAL {
typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Dart_handle Dart_handle;
typedef typename Base::Map Map; typedef typename Base::Map Map;
typedef typename Map::size_type size_type;
typedef Tag_true Basic_iterator; ///< True iff this iterator is basic typedef Tag_true Basic_iterator; ///< True iff this iterator is basic
public: public:
@ -650,6 +655,8 @@ namespace CGAL {
typedef typename Map::Dart_handle Dart_handle; typedef typename Map::Dart_handle Dart_handle;
typedef typename Base::Use_mark Use_mark; ///< True iff this iterator uses mark typedef typename Base::Use_mark Use_mark; ///< True iff this iterator uses mark
typedef typename Map::size_type size_type;
typedef Tag_true Basic_iterator; ///< True iff this iterator is basic typedef Tag_true Basic_iterator; ///< True iff this iterator is basic
/// Main constructor. /// Main constructor.
@ -730,6 +737,7 @@ namespace CGAL {
typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Dart_handle Dart_handle;
typedef typename Base::Map Map; typedef typename Base::Map Map;
typedef typename Map::size_type size_type;
typedef Tag_true Use_mark; ///< True iff this iterator uses mark typedef Tag_true Use_mark; ///< True iff this iterator uses mark
typedef Tag_true Basic_iterator; ///< True iff this iterator is basic typedef Tag_true Basic_iterator; ///< True iff this iterator is basic

View File

@ -2921,6 +2921,10 @@ namespace CGAL {
/// Number of marked darts for each used marks. /// Number of marked darts for each used marks.
mutable size_type mnb_marked_darts[NB_MARKS]; mutable size_type mnb_marked_darts[NB_MARKS];
/// Automatic management of the attributes:
/// true means attributes are always maintained updated during operations.
bool automatic_attributes_management;
/// Tuple of unary and binary functors (for all non void attributes). /// Tuple of unary and binary functors (for all non void attributes).
typename Helper::Split_functors m_onsplit_functors; typename Helper::Split_functors m_onsplit_functors;
typename Helper::Merge_functors m_onmerge_functors; typename Helper::Merge_functors m_onmerge_functors;

View File

@ -35,14 +35,15 @@ template<class CMap>
typename CMap::Dart_handle typename CMap::Dart_handle
insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart, insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::template typename CMap::template
Attribute_handle<0>::type ah=CMap::null_handle ) Attribute_handle<0>::type ah=CMap::null_handle,
bool update_attributes=true )
{ {
typename CMap::Dart_handle d1, d2; typename CMap::Dart_handle d1, d2;
int mark=amap.get_new_mark(); typename CMap::size_type mark=amap.get_new_mark();
// 1) We store all the darts of the edge. // 1) We store all the darts of the edge.
std::deque<typename CMap::Dart_handle> vect; std::deque<typename CMap::Dart_handle> vect;
int m=amap.get_new_mark(); typename CMap::size_type m=amap.get_new_mark();
{ {
for ( typename CMap::template Dart_of_cell_basic_range<1>::iterator for ( typename CMap::template Dart_of_cell_basic_range<1>::iterator
it=amap.template darts_of_cell_basic<1>(adart, m).begin(); it=amap.template darts_of_cell_basic<1>(adart, m).begin();
@ -71,15 +72,21 @@ insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
} }
} }
if (amap.are_attributes_automatically_managed() && update_attributes)
{
// We copy all the attributes except for dim=0 // We copy all the attributes except for dim=0
CMap::Helper::template Foreach_enabled_attributes_except CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 0>:: <CGAL::internal::Group_attribute_functor_of_dart<CMap>, 0>::
run(&amap,*it,d1); run(&amap,*it,d1);
}
if (ah != CMap::null_handle)
{
// We initialise the 0-atttrib to ah // We initialise the 0-atttrib to ah
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>:: CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d1, ah); run(&amap, d1, ah);
amap.mark(*it, mark); amap.mark(*it, mark);
} }
}
for (it = vect.begin(); it != vect.end(); ++it) for (it = vect.begin(); it != vect.end(); ++it)
{ {
@ -93,11 +100,14 @@ insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
amap.free_mark(m); amap.free_mark(m);
amap.free_mark(mark); amap.free_mark(mark);
if (amap.are_attributes_automatically_managed() && update_attributes)
{
if ( !amap.template is_free<1>(amap.template alpha<0>(adart)) ) if ( !amap.template is_free<1>(amap.template alpha<0>(adart)) )
{ {
CGAL::internal::Degroup_attribute_functor_run<CMap, 1>:: CGAL::internal::Degroup_attribute_functor_run<CMap, 1>::
run(&amap, adart, amap.template alpha<0,1>(adart)); run(&amap, adart, amap.template alpha<0,1>(adart));
} }
}
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS #ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
CGAL_assertion( amap.is_valid() ); CGAL_assertion( amap.is_valid() );
@ -116,15 +126,16 @@ template < class CMap >
typename CMap::Dart_handle typename CMap::Dart_handle
insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart, insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::template typename CMap::template
Attribute_handle<0>::type ah=CMap::null_handle ) Attribute_handle<0>::type ah=CMap::null_handle,
bool update_attributes=true )
{ {
CGAL_assertion(adart!=amap.null_handle); CGAL_assertion(adart!=amap.null_handle);
typename CMap::Dart_handle d1=amap.null_handle, d2=amap.null_handle; typename CMap::Dart_handle d1=amap.null_handle, d2=amap.null_handle;
// Mark used to mark darts already treated. // Mark used to mark darts already treated.
int treated = amap.get_new_mark(); typename CMap::size_type treated = amap.get_new_mark();
int m = amap.get_new_mark(); typename CMap::size_type m = amap.get_new_mark();
// Stack of darts of the face // Stack of darts of the face
std::deque<typename CMap::Dart_handle> vect; std::deque<typename CMap::Dart_handle> vect;
@ -169,6 +180,8 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
} }
} }
if (amap.are_attributes_automatically_managed() && update_attributes)
{
// We copy all the attributes except for dim=1 // We copy all the attributes except for dim=1
CMap::Helper::template Foreach_enabled_attributes_except CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 1>:: <CGAL::internal::Group_attribute_functor_of_dart<CMap>, 1>::
@ -177,6 +190,7 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>:: CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d2, ah); run(&amap, d2, ah);
} }
}
for (it = vect.begin(); it != vect.end(); ++it) for (it = vect.begin(); it != vect.end(); ++it)
{ {
@ -189,11 +203,14 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
amap.free_mark(m); amap.free_mark(m);
amap.free_mark(treated); amap.free_mark(treated);
if (amap.are_attributes_automatically_managed() && update_attributes)
{
for (it = todegroup.begin(); it != todegroup.end(); ++it) for (it = todegroup.begin(); it != todegroup.end(); ++it)
{ {
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>:: CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
run(&amap, adart, *it); run(&amap, adart, *it);
} }
}
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS #ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
CGAL_assertion( amap.is_valid() ); CGAL_assertion( amap.is_valid() );
@ -233,23 +250,24 @@ template<class CMap>
typename CMap::Dart_handle typename CMap::Dart_handle
insert_cell_1_in_cell_2(CMap& amap, insert_cell_1_in_cell_2(CMap& amap,
typename CMap::Dart_handle adart1, typename CMap::Dart_handle adart1,
typename CMap::Dart_handle adart2) typename CMap::Dart_handle adart2,
bool update_attributes=true)
{ {
if ( adart2!=amap.null_handle) if ( adart2!=amap.null_handle)
{ {
CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2)); CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2));
} }
int m1=amap.get_new_mark(); typename CMap::size_type m1=amap.get_new_mark();
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it1(amap, adart1, m1); CGAL::CMap_dart_iterator_basic_of_involution<CMap,0,1> it1(amap, adart1, m1);
int m2=amap.get_new_mark(); typename CMap::size_type m2=amap.get_new_mark();
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it2(amap, adart2, m2); CGAL::CMap_dart_iterator_basic_of_involution<CMap,0,1> it2(amap, adart2, m2);
typename CMap::Dart_handle d1=amap.null_handle; typename CMap::Dart_handle d1=amap.null_handle;
typename CMap::Dart_handle d2=amap.null_handle; typename CMap::Dart_handle d2=amap.null_handle;
int treated=amap.get_new_mark(); typename CMap::size_type treated=amap.get_new_mark();
for ( ; it1.cont(); ++it1) for ( ; it1.cont(); ++it1)
{ {
@ -284,9 +302,12 @@ insert_cell_1_in_cell_2(CMap& amap,
} }
} }
if (amap.are_attributes_automatically_managed() && update_attributes)
{
if ( !amap.template is_free<2>(d1) && d2!=amap.null_handle ) if ( !amap.template is_free<2>(d1) && d2!=amap.null_handle )
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>:: CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
run(&amap, d1, amap.template alpha<2>(d1)); run(&amap, d1, amap.template alpha<2>(d1));
}
amap.negate_mark(m1); amap.negate_mark(m1);
it1.rewind(); it1.rewind();
@ -379,7 +400,8 @@ bool is_insertable_cell_2_in_cell_3(const CMap& amap,
*/ */
template<class CMap, class InputIterator> template<class CMap, class InputIterator>
typename CMap::Dart_handle typename CMap::Dart_handle
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast) insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast,
bool update_attributes=true)
{ {
CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast)); CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast));
@ -387,7 +409,7 @@ insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
dd = amap.null_handle, first = amap.null_handle; dd = amap.null_handle, first = amap.null_handle;
bool withAlpha3 = false; bool withAlpha3 = false;
int treated = amap.get_new_mark(); typename CMap::size_type treated = amap.get_new_mark();
{ {
for (InputIterator it(afirst); !withAlpha3 && it!=alast; ++it) for (InputIterator it(afirst); !withAlpha3 && it!=alast; ++it)

View File

@ -63,6 +63,7 @@ namespace CGAL {
typedef typename Base::Dart_handle Dart_handle; typedef typename Base::Dart_handle Dart_handle;
typedef typename Base::Map Map; typedef typename Base::Map Map;
typedef typename Base::size_type size_type;
typedef Tag_true Use_mark; typedef Tag_true Use_mark;

View File

@ -32,19 +32,19 @@ namespace CGAL
*/ */
/** Test if an i-cell can be removed. /** Test if an i-cell can be removed.
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1, * An i-cell can be removed if i==GMap::dimension or i==GMap::dimension-1,
* or if there are at most two (i+1)-cell incident to it. * or if there are at most two (i+1)-cell incident to it.
* @param adart a dart of the i-cell. * @param adart a dart of the i-cell.
* @return true iff the i-cell can be removed. * @return true iff the i-cell can be removed.
*/ */
template <class CMap, unsigned int i, unsigned int nmi=CMap::dimension-i> template <class GMap, unsigned int i, unsigned int nmi=GMap::dimension-i>
struct Is_removable_functor struct Is_removable_functor
{ {
static bool run(const CMap& amap, typename CMap::Dart_const_handle adart) static bool run(const GMap& amap, typename GMap::Dart_const_handle adart)
{ {
// TODO? Optimisation for dim-2, and to not test all the darts of the cell? // TODO? Optimisation for dim-2, and to not test all the darts of the cell?
bool res = true; bool res = true;
for ( CGAL::GMap_dart_const_iterator_of_cell<CMap,i> it(amap, adart); for ( CGAL::GMap_dart_const_iterator_of_cell<GMap,i> it(amap, adart);
res && it.cont(); ++it ) res && it.cont(); ++it )
{ {
if (amap.template alpha<i+2,i+1>(it)!=amap.template alpha<i+1,i+2>(it)) if (amap.template alpha<i+2,i+1>(it)!=amap.template alpha<i+1,i+2>(it))
@ -53,29 +53,29 @@ namespace CGAL
return res; return res;
} }
}; };
// Specialization for i=CMap::dimension // Specialization for i=GMap::dimension
template <class CMap, unsigned int i> template <class GMap, unsigned int i>
struct Is_removable_functor<CMap, i, 0> struct Is_removable_functor<GMap, i, 0>
{ {
static bool run(const CMap&, typename CMap::Dart_const_handle) static bool run(const GMap&, typename GMap::Dart_const_handle)
{ return true; } { return true; }
}; };
// Specialization for i=CMap::dimension-1 // Specialization for i=GMap::dimension-1
template <class CMap, unsigned int i> template <class GMap, unsigned int i>
struct Is_removable_functor<CMap, i, 1> struct Is_removable_functor<GMap, i, 1>
{ {
static bool run(const CMap&, typename CMap::Dart_const_handle) static bool run(const GMap&, typename GMap::Dart_const_handle)
{ return true; } { return true; }
}; };
/** Test if an i-cell can be removed. /** Test if an i-cell can be removed.
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1, * An i-cell can be removed if i==GMap::dimension or i==GMap::dimension-1,
* or if there are at most two (i+1)-cell incident to it. * or if there are at most two (i+1)-cell incident to it.
* @param adart a dart of the i-cell. * @param adart a dart of the i-cell.
* @return true iff the i-cell can be removed. * @return true iff the i-cell can be removed.
*/ */
template < class CMap, unsigned int i > template < class GMap, unsigned int i >
bool is_removable(const CMap& amap, typename CMap::Dart_const_handle adart) bool is_removable(const GMap& amap, typename GMap::Dart_const_handle adart)
{ return CGAL::Is_removable_functor<CMap, i>::run(amap,adart); } { return CGAL::Is_removable_functor<GMap, i>::run(amap,adart); }
/** Remove an i-cell, 0<=i<dimension, and merge eventually both incident /** Remove an i-cell, 0<=i<dimension, and merge eventually both incident
* (i+1)-cells. * (i+1)-cells.
@ -83,26 +83,26 @@ namespace CGAL
* @param adart a dart of the i-cell to remove. * @param adart a dart of the i-cell to remove.
* @return the number of deleted darts. * @return the number of deleted darts.
*/ */
template<class CMap, unsigned int i, unsigned int nmi> template<class GMap, unsigned int i, unsigned int nmi>
struct Remove_cell_functor struct Remove_cell_functor
{ {
static size_t run(CMap& amap, typename CMap::Dart_handle adart) static size_t run(GMap& amap, typename GMap::Dart_handle adart)
{ {
CGAL_static_assertion ( i<CMap::dimension ); CGAL_static_assertion ( i<GMap::dimension );
CGAL_assertion( (is_removable<CMap,i>(amap, adart)) ); CGAL_assertion( (is_removable<GMap,i>(amap, adart)) );
size_t res = 0; size_t res = 0;
typename CMap::Dart_handle d1, d2; typename GMap::Dart_handle d1, d2;
typename CMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle; typename GMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle;
typename CMap::size_type mark = amap.get_new_mark(); typename GMap::size_type mark = amap.get_new_mark();
typename CMap::size_type mark_modified_darts = amap.get_new_mark(); typename GMap::size_type mark_modified_darts = amap.get_new_mark();
std::deque<typename CMap::Dart_handle> to_erase; std::deque<typename GMap::Dart_handle> to_erase;
// First we store and mark all the darts of the i-cell to remove. // First we store and mark all the darts of the i-cell to remove.
for ( CGAL::GMap_dart_iterator_basic_of_cell<CMap,i> it(amap,adart,mark); for ( CGAL::GMap_dart_iterator_basic_of_cell<GMap,i> it(amap,adart,mark);
it.cont(); ++it ) it.cont(); ++it )
{ {
to_erase.push_back(it); to_erase.push_back(it);
@ -116,16 +116,16 @@ namespace CGAL
{ {
// We group the two (i+1)-cells incident if they exist. // We group the two (i+1)-cells incident if they exist.
if ( dg1!=amap.null_handle ) if ( dg1!=amap.null_handle )
CGAL::internal::Group_attribute_functor_run<CMap, i+1>:: CGAL::internal::Group_attribute_functor_run<GMap, i+1>::
run(&amap, dg1, dg2); run(&amap, dg1, dg2);
} }
// During the operation, we store in modified_darts the darts modified // During the operation, we store in modified_darts the darts modified
// to test after the loop the non void attributes that are split. // to test after the loop the non void attributes that are split.
std::deque<typename CMap::Dart_handle> modified_darts; std::deque<typename GMap::Dart_handle> modified_darts;
// For each dart of the i-cell, we modify i-links of neighbors. // For each dart of the i-cell, we modify i-links of neighbors.
typename std::deque<typename CMap::Dart_handle>::iterator it = typename std::deque<typename GMap::Dart_handle>::iterator it =
to_erase.begin(); to_erase.begin();
for ( ; it!=to_erase.end(); ++it ) for ( ; it!=to_erase.end(); ++it )
{ {
@ -159,8 +159,8 @@ namespace CGAL
{ {
// We test the split of all the incident cells for all the non // We test the split of all the incident cells for all the non
// void attributes. // void attributes.
CMap::Helper::template Foreach_enabled_attributes_except GMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Test_split_attribute_functor<CMap,i>, i>:: <CGAL::internal::Test_split_attribute_functor<GMap,i>, i>::
run(&amap, modified_darts, mark_modified_darts); run(&amap, modified_darts, mark_modified_darts);
} }
@ -197,19 +197,19 @@ namespace CGAL
* @param adart a dart of the volume to remove. * @param adart a dart of the volume to remove.
* @return the number of deleted darts. * @return the number of deleted darts.
*/ */
template<class Gmap,unsigned int i> template<class GMap,unsigned int i>
struct Remove_cell_functor<Gmap,i,0> struct Remove_cell_functor<GMap,i,0>
{ {
static size_t run(Gmap& amap, typename Gmap::Dart_handle adart) static size_t run(GMap& amap, typename GMap::Dart_handle adart)
{ {
typename CMap::size_type mark = amap.get_new_mark(); typename GMap::size_type mark = amap.get_new_mark();
std::deque<typename Gmap::Dart_handle> to_erase; std::deque<typename GMap::Dart_handle> to_erase;
size_t res = 0; size_t res = 0;
std::deque<typename Gmap::Dart_handle> modified_darts; std::deque<typename GMap::Dart_handle> modified_darts;
// We mark all the darts of the d-cell. // We mark all the darts of the d-cell.
for ( CGAL::GMap_dart_iterator_basic_of_cell<Gmap,Gmap::dimension> for ( CGAL::GMap_dart_iterator_basic_of_cell<GMap,GMap::dimension>
it(amap,adart,mark); it.cont(); ++it ) it(amap,adart,mark); it.cont(); ++it )
{ {
to_erase.push_back(it); to_erase.push_back(it);
@ -218,18 +218,18 @@ namespace CGAL
} }
// We unlink all the darts of the volume for alpha-d. // We unlink all the darts of the volume for alpha-d.
typename std::deque<typename Gmap::Dart_handle>::iterator typename std::deque<typename GMap::Dart_handle>::iterator
it = to_erase.begin(); it = to_erase.begin();
for ( it = to_erase.begin(); it != to_erase.end(); ++it ) for ( it = to_erase.begin(); it != to_erase.end(); ++it )
{ {
if ( !amap.template is_free<Gmap::dimension>(*it) && if ( !amap.template is_free<GMap::dimension>(*it) &&
!amap.is_marked(amap.template alpha<Gmap::dimension>(*it), mark) ) !amap.is_marked(amap.template alpha<GMap::dimension>(*it), mark) )
{ {
if (amap.are_attributes_automatically_managed()) if (amap.are_attributes_automatically_managed())
{ {
modified_darts.push_back(amap.template beta<CMap::dimension>(*it)); modified_darts.push_back(amap.template alpha<GMap::dimension>(*it));
} }
amap.template unlink_alpha<Gmap::dimension>(*it); amap.template unlink_alpha<GMap::dimension>(*it);
} }
} }
@ -237,9 +237,9 @@ namespace CGAL
{ {
// We test the split of all the incident cells for all the non // We test the split of all the incident cells for all the non
// void attributes. // void attributes.
Gmap::Helper::template Foreach_enabled_attributes_except GMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Test_split_attribute_functor<Gmap,i>, <CGAL::internal::Test_split_attribute_functor<GMap,i>,
Gmap::dimension>::run(&amap, modified_darts); GMap::dimension>::run(&amap, modified_darts);
} }
// We remove all the darts of the d-cell. // We remove all the darts of the d-cell.
@ -262,11 +262,11 @@ namespace CGAL
* @param adart a dart of the i-cell to remove. * @param adart a dart of the i-cell to remove.
* @return the number of deleted darts. * @return the number of deleted darts.
*/ */
template< class Gmap, unsigned int i > template< class GMap, unsigned int i >
size_t remove_cell(Gmap& amap, typename Gmap::Dart_handle adart) size_t remove_cell(GMap& amap, typename GMap::Dart_handle adart)
{ {
return return
CGAL::Remove_cell_functor<Gmap,i,Gmap::dimension-i>::run(amap,adart); CGAL::Remove_cell_functor<GMap,i,GMap::dimension-i>::run(amap,adart);
} }
/** Test if an i-cell can be contracted. /** Test if an i-cell can be contracted.
@ -275,14 +275,14 @@ namespace CGAL
* @param adart a dart of the i-cell. * @param adart a dart of the i-cell.
* @return true iff the i-cell can be contracted. * @return true iff the i-cell can be contracted.
*/ */
template <class Gmap, unsigned int i> template <class GMap, unsigned int i>
struct Is_contractible_functor struct Is_contractible_functor
{ {
static bool run(const Gmap& amap, typename Gmap::Dart_const_handle adart) static bool run(const GMap& amap, typename GMap::Dart_const_handle adart)
{ {
// TODO ? Optimisation possible to not test all the darts of the cell ? // TODO ? Optimisation possible to not test all the darts of the cell ?
bool res = true; bool res = true;
for ( CGAL::GMap_dart_const_iterator_of_cell<Gmap,i> it(amap, adart); for ( CGAL::GMap_dart_const_iterator_of_cell<GMap,i> it(amap, adart);
res && it.cont(); ++it ) res && it.cont(); ++it )
{ {
if (amap.template alpha<i-2,i-1>(it)!=amap.template alpha<i-1,i-2>(it)) if (amap.template alpha<i-2,i-1>(it)!=amap.template alpha<i-1,i-2>(it))
@ -292,17 +292,17 @@ namespace CGAL
} }
}; };
// Specialization for i=0 // Specialization for i=0
template <class Gmap> template <class GMap>
struct Is_contractible_functor<Gmap, 0> struct Is_contractible_functor<GMap, 0>
{ {
static bool run(const Gmap&, typename Gmap::Dart_const_handle) static bool run(const GMap&, typename GMap::Dart_const_handle)
{ return false; } { return false; }
}; };
// Specialization for i=1 // Specialization for i=1
template <class Gmap> template <class GMap>
struct Is_contractible_functor<Gmap, 1> struct Is_contractible_functor<GMap, 1>
{ {
static bool run(const Gmap&, typename Gmap::Dart_const_handle) static bool run(const GMap&, typename GMap::Dart_const_handle)
{ return true; } { return true; }
}; };
/** Test if an i-cell can be contracted. /** Test if an i-cell can be contracted.
@ -311,9 +311,9 @@ namespace CGAL
* @param adart a dart of the i-cell. * @param adart a dart of the i-cell.
* @return true iff the i-cell can be contracted. * @return true iff the i-cell can be contracted.
*/ */
template < class Gmap, unsigned int i > template < class GMap, unsigned int i >
bool is_contractible(const Gmap& amap, typename Gmap::Dart_const_handle adart) bool is_contractible(const GMap& amap, typename GMap::Dart_const_handle adart)
{ return CGAL::Is_contractible_functor<Gmap, i>::run(amap,adart); } { return CGAL::Is_contractible_functor<GMap, i>::run(amap,adart); }
/** Contract an i-cell, 1<=i<=dimension, and merge eventually both incident /** Contract an i-cell, 1<=i<=dimension, and merge eventually both incident
* (i-1)-cells. * (i-1)-cells.
@ -321,25 +321,25 @@ namespace CGAL
* @param adart a dart of the i-cell to contract. * @param adart a dart of the i-cell to contract.
* @return the number of deleted darts. * @return the number of deleted darts.
*/ */
template<class Gmap, unsigned int i> template<class GMap, unsigned int i>
struct Contract_cell_functor struct Contract_cell_functor
{ {
static size_t run(Gmap& amap, typename Gmap::Dart_handle adart) static size_t run(GMap& amap, typename GMap::Dart_handle adart)
{ {
CGAL_static_assertion ( 1<=i && i<=Gmap::dimension ); CGAL_static_assertion ( 1<=i && i<=GMap::dimension );
CGAL_assertion( (is_contractible<Gmap,i>(amap, adart)) ); CGAL_assertion( (is_contractible<GMap,i>(amap, adart)) );
size_t res = 0; size_t res = 0;
typename Gmap::Dart_handle d1, d2; typename GMap::Dart_handle d1, d2;
typename Gmap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle; typename GMap::Dart_handle dg1=amap.null_handle, dg2=amap.null_handle;
typename CMap::size_type mark = amap.get_new_mark(); typename GMap::size_type mark = amap.get_new_mark();
typename CMap::size_type mark_modified_darts = amap.get_new_mark(); typename GMap::size_type mark_modified_darts = amap.get_new_mark();
// First we store and mark all the darts of the i-cell to contract. // First we store and mark all the darts of the i-cell to contract.
std::deque<typename Gmap::Dart_handle> to_erase; std::deque<typename GMap::Dart_handle> to_erase;
for ( CGAL::GMap_dart_iterator_basic_of_cell<Gmap,i> it(amap,adart,mark); for ( CGAL::GMap_dart_iterator_basic_of_cell<GMap,i> it(amap,adart,mark);
it.cont(); ++it ) it.cont(); ++it )
{ {
to_erase.push_back(it); to_erase.push_back(it);
@ -353,16 +353,16 @@ namespace CGAL
{ {
// We group the two (i-1)-cells incident if they exist. // We group the two (i-1)-cells incident if they exist.
if ( dg1!=amap.null_handle ) if ( dg1!=amap.null_handle )
CGAL::internal::Group_attribute_functor_run<Gmap,i-1>:: CGAL::internal::Group_attribute_functor_run<GMap,i-1>::
run(&amap, dg1, dg2); run(&amap, dg1, dg2);
} }
// During the operation, we store in modified_darts the darts modified // During the operation, we store in modified_darts the darts modified
// to test after the loop the non void attributes that are split. // to test after the loop the non void attributes that are split.
std::deque<typename Gmap::Dart_handle> modified_darts; std::deque<typename GMap::Dart_handle> modified_darts;
// For each dart of the i-cell, we modify i-links of neighbors. // For each dart of the i-cell, we modify i-links of neighbors.
typename std::deque<typename Gmap::Dart_handle>::iterator it = typename std::deque<typename GMap::Dart_handle>::iterator it =
to_erase.begin(); to_erase.begin();
for ( ; it!=to_erase.end(); ++it ) for ( ; it!=to_erase.end(); ++it )
{ {
@ -393,8 +393,8 @@ namespace CGAL
{ {
// We test the split of all the incident cells for all the non // We test the split of all the incident cells for all the non
// void attributes. // void attributes.
Gmap::Helper::template Foreach_enabled_attributes_except GMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Test_split_attribute_functor<Gmap,i>, i>:: <CGAL::internal::Test_split_attribute_functor<GMap,i>, i>::
run(&amap, modified_darts, mark_modified_darts); run(&amap, modified_darts, mark_modified_darts);
} }
@ -430,9 +430,9 @@ namespace CGAL
* @param adart a dart of the i-cell to remove. * @param adart a dart of the i-cell to remove.
* @return the number of deleted darts. * @return the number of deleted darts.
*/ */
template < class Gmap, unsigned int i > template < class GMap, unsigned int i >
size_t contract_cell(Gmap& amap, typename Gmap::Dart_handle adart) size_t contract_cell(GMap& amap, typename GMap::Dart_handle adart)
{ return CGAL::Contract_cell_functor<Gmap,i>::run(amap,adart); } { return CGAL::Contract_cell_functor<GMap,i>::run(amap,adart); }
} // namespace CGAL } // namespace CGAL

View File

@ -55,14 +55,14 @@ struct GMap_is_sewable_functor
typename CMap::Dart_const_handle, typename CMap::Dart_const_handle,
typename CMap::Hash_function> bijection; typename CMap::Hash_function> bijection;
int m1 = amap->get_new_mark(); typename CMap::size_type m1 = amap->get_new_mark();
int m2 = amap->get_new_mark(); typename CMap::size_type m2 = amap->get_new_mark();
CGAL::GMap_dart_const_iterator_basic_of_involution<CMap,i> CGAL::GMap_dart_const_iterator_basic_of_involution<CMap,i>
I1(*amap, adart1, m1); I1(*amap, adart1, m1);
CGAL::GMap_dart_const_iterator_basic_of_involution<CMap,i> CGAL::GMap_dart_const_iterator_basic_of_involution<CMap,i>
I2(*amap, adart2, m2); I2(*amap, adart2, m2);
bool res = true; bool res = true;
int mbijection = amap->get_new_mark(); typename CMap::size_type mbijection = amap->get_new_mark();
while ( res && I1.cont() && I2.cont() ) while ( res && I1.cont() && I2.cont() )
{ {
@ -73,7 +73,7 @@ struct GMap_is_sewable_functor
CGAL_assertion( amap->template is_free<i>(I2) ); CGAL_assertion( amap->template is_free<i>(I2) );
// We can remove this constraint which is not required for // We can remove this constraint which is not required for
// combinatorial map definition, but which is quite "normal" // generalized map definition, but which is quite "normal"
// Indeed in this case we try to i-sew an i-cell with itself (case // Indeed in this case we try to i-sew an i-cell with itself (case
// of folded cells). // of folded cells).
if ( I1==adart2 || I2==adart1 ) res=false; if ( I1==adart2 || I2==adart1 ) res=false;