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

@ -22,523 +22,545 @@
namespace CGAL namespace CGAL
{ {
/** @file Generalized_map_insertions.h /** @file Generalized_map_insertions.h
* Insertion operations on generalized map. * Insertion operations on generalized map.
*/ */
/** Insert a vertex in a given edge. /** Insert a vertex in a given edge.
* @param amap the used generalized map. * @param amap the used generalized map.
* @param adart a dart of the edge (!=NULL). * @param adart a dart of the edge (!=NULL).
* @return a dart of the new vertex. * @return a dart of the new vertex.
*/ */
template<class CMap> 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;
int mark=amap.get_new_mark();
// 1) We store all the darts of the edge.
std::deque<typename CMap::Dart_handle> vect;
int m=amap.get_new_mark();
{ {
for ( typename CMap::template Dart_of_cell_basic_range<1>::iterator typename CMap::Dart_handle d1, d2;
it=amap.template darts_of_cell_basic<1>(adart, m).begin(); typename CMap::size_type mark=amap.get_new_mark();
it != amap.template darts_of_cell_basic<1>(adart, m).end(); ++it )
vect.push_back(it);
}
// 2) For each dart of the cell, we modify link of neighbors. // 1) We store all the darts of the edge.
typename std::deque<typename CMap::Dart_handle>::iterator it = vect.begin(); std::deque<typename CMap::Dart_handle> vect;
for (; it != vect.end(); ++it) typename CMap::size_type m=amap.get_new_mark();
{
d1 = amap.create_dart();
if (!amap.template is_free<0>(*it) &&
amap.is_marked(amap.template alpha<0>(*it), mark))
amap.template basic_link_alpha<1>(d1, amap.template alpha<0,0>(*it));
amap.template basic_link_alpha<0>(*it, d1);
amap.mark(*it, mark);
for ( unsigned int dim=2; dim<=CMap::dimension; ++dim )
{ {
if (!amap.is_free(*it, dim) && amap.is_marked(amap.alpha(*it, dim), mark)) 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).end(); ++it )
vect.push_back(it);
}
// 2) For each dart of the cell, we modify link of neighbors.
typename std::deque<typename CMap::Dart_handle>::iterator it = vect.begin();
for (; it != vect.end(); ++it)
{
d1 = amap.create_dart();
if (!amap.template is_free<0>(*it) &&
amap.is_marked(amap.template alpha<0>(*it), mark))
amap.template basic_link_alpha<1>(d1, amap.template alpha<0,0>(*it));
amap.template basic_link_alpha<0>(*it, d1);
amap.mark(*it, mark);
for ( unsigned int dim=2; dim<=CMap::dimension; ++dim )
{ {
amap.basic_link_alpha(amap.beta(*it, dim, 0), d1, dim); if (!amap.is_free(*it, dim) && amap.is_marked(amap.alpha(*it, dim), mark))
{
amap.basic_link_alpha(amap.beta(*it, dim, 0), d1, dim);
}
}
if (amap.are_attributes_automatically_managed() && update_attributes)
{
// We copy all the attributes except for dim=0
CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 0>::
run(&amap,*it,d1);
}
if (ah != CMap::null_handle)
{
// We initialise the 0-atttrib to ah
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d1, ah);
amap.mark(*it, mark);
} }
} }
// We copy all the attributes except for dim=0 for (it = vect.begin(); it != vect.end(); ++it)
CMap::Helper::template Foreach_enabled_attributes_except {
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 0>:: amap.unmark(*it, m);
run(&amap,*it,d1); amap.unmark(*it, mark);
// We initialise the 0-atttrib to ah }
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d1, ah);
amap.mark(*it, mark);
}
for (it = vect.begin(); it != vect.end(); ++it) CGAL_assertion(amap.is_whole_map_unmarked(m));
{ CGAL_assertion(amap.is_whole_map_unmarked(mark));
amap.unmark(*it, m);
amap.unmark(*it, mark);
}
CGAL_assertion(amap.is_whole_map_unmarked(m)); amap.free_mark(m);
CGAL_assertion(amap.is_whole_map_unmarked(mark)); amap.free_mark(mark);
amap.free_mark(m); if (amap.are_attributes_automatically_managed() && update_attributes)
amap.free_mark(mark); {
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() );
#endif #endif
return amap.template alpha<0>(adart); return amap.template alpha<0>(adart);
}
/** Insert a vertex in the given 2-cell which is splitted in triangles,
* once for each inital edge of the facet.
* @param amap the used generalized map.
* @param adart a dart of the facet to triangulate.
* @return A dart incident to the new vertex.
*/
template < class CMap >
typename CMap::Dart_handle
insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::template
Attribute_handle<0>::type ah=CMap::null_handle )
{
CGAL_assertion(adart!=amap.null_handle);
typename CMap::Dart_handle d1=amap.null_handle, d2=amap.null_handle;
// Mark used to mark darts already treated.
int treated = amap.get_new_mark();
int m = amap.get_new_mark();
// Stack of darts of the face
std::deque<typename CMap::Dart_handle> vect;
{
for ( typename CMap::template Dart_of_cell_basic_range<2>::iterator
it=amap.template darts_of_cell_basic<2>(adart,m).begin();
it != amap.template darts_of_cell_basic<2>(adart,m).end(); ++it )
vect.push_back(it);
} }
// Stack of darts to degroup (one dart per edge of the face) /** Insert a vertex in the given 2-cell which is splitted in triangles,
std::deque<typename CMap::Dart_handle> todegroup; * once for each inital edge of the facet.
* @param amap the used generalized map.
* @param adart a dart of the facet to triangulate.
* @return A dart incident to the new vertex.
*/
template < class CMap >
typename CMap::Dart_handle
insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
typename CMap::template
Attribute_handle<0>::type ah=CMap::null_handle,
bool update_attributes=true )
{ {
for ( typename CMap::template Dart_of_cell_basic_range<2,2>::iterator CGAL_assertion(adart!=amap.null_handle);
it=amap.template darts_of_cell_basic<2,2>(adart).begin();
it != amap.template darts_of_cell_basic<2,2>(adart).end(); ++it )
if ( it!=adart && it!=amap.template alpha<0>(adart) )
todegroup.push_back(it);
}
// 2) For each dart of the cell, we modify link of neighbors. typename CMap::Dart_handle d1=amap.null_handle, d2=amap.null_handle;
typename std::deque<typename CMap::Dart_handle>::iterator it = vect.begin();
for (; it != vect.end(); ++it)
{
d1 = amap.create_dart();
d2 = amap.create_dart();
amap.template basic_link_alpha<0>(d1, d2);
amap.mark(*it, treated);
amap.template basic_link_alpha<1>(*it, d1); // Mark used to mark darts already treated.
typename CMap::size_type treated = amap.get_new_mark();
typename CMap::size_type m = amap.get_new_mark();
if (!amap.template is_free<0>(*it) && // Stack of darts of the face
amap.is_marked(amap.template alpha<0>(*it), treated)) std::deque<typename CMap::Dart_handle> vect;
amap.template basic_link_alpha<1>(d2, amap.template alpha<0,1,0>(*it));
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim )
{ {
if (!amap.is_free(*it, dim) && amap.is_marked(amap.alpha(*it, dim), treated)) for ( typename CMap::template Dart_of_cell_basic_range<2>::iterator
it=amap.template darts_of_cell_basic<2>(adart,m).begin();
it != amap.template darts_of_cell_basic<2>(adart,m).end(); ++it )
vect.push_back(it);
}
// Stack of darts to degroup (one dart per edge of the face)
std::deque<typename CMap::Dart_handle> todegroup;
{
for ( typename CMap::template Dart_of_cell_basic_range<2,2>::iterator
it=amap.template darts_of_cell_basic<2,2>(adart).begin();
it != amap.template darts_of_cell_basic<2,2>(adart).end(); ++it )
if ( it!=adart && it!=amap.template alpha<0>(adart) )
todegroup.push_back(it);
}
// 2) For each dart of the cell, we modify link of neighbors.
typename std::deque<typename CMap::Dart_handle>::iterator it = vect.begin();
for (; it != vect.end(); ++it)
{
d1 = amap.create_dart();
d2 = amap.create_dart();
amap.template basic_link_alpha<0>(d1, d2);
amap.mark(*it, treated);
amap.template basic_link_alpha<1>(*it, d1);
if (!amap.template is_free<0>(*it) &&
amap.is_marked(amap.template alpha<0>(*it), treated))
amap.template basic_link_alpha<1>(d2, amap.template alpha<0,1,0>(*it));
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim )
{ {
amap.basic_link_alpha(amap.beta(*it, dim, 1), d1, dim); if (!amap.is_free(*it, dim) && amap.is_marked(amap.alpha(*it, dim), treated))
amap.basic_link_alpha(amap.beta(*it, dim, 1, 0), d2, dim); {
amap.basic_link_alpha(amap.beta(*it, dim, 1), d1, dim);
amap.basic_link_alpha(amap.beta(*it, dim, 1, 0), d2, dim);
}
}
if (amap.are_attributes_automatically_managed() && update_attributes)
{
// We copy all the attributes except for dim=1
CMap::Helper::template Foreach_enabled_attributes_except
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 1>::
run(&amap,*it,d1);
// We initialise the 0-atttrib to ah
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d2, ah);
} }
} }
// We copy all the attributes except for dim=1 for (it = vect.begin(); it != vect.end(); ++it)
CMap::Helper::template Foreach_enabled_attributes_except {
<CGAL::internal::Group_attribute_functor_of_dart<CMap>, 1>:: amap.unmark(*it, m);
run(&amap,*it,d1); amap.unmark(*it, treated);
// We initialise the 0-atttrib to ah }
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
run(&amap, d2, ah);
}
for (it = vect.begin(); it != vect.end(); ++it) CGAL_assertion(amap.is_whole_map_unmarked(m));
{ CGAL_assertion(amap.is_whole_map_unmarked(treated));
amap.unmark(*it, m); amap.free_mark(m);
amap.unmark(*it, treated); amap.free_mark(treated);
}
CGAL_assertion(amap.is_whole_map_unmarked(m)); if (amap.are_attributes_automatically_managed() && update_attributes)
CGAL_assertion(amap.is_whole_map_unmarked(treated)); {
amap.free_mark(m); for (it = todegroup.begin(); it != todegroup.end(); ++it)
amap.free_mark(treated); {
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
for (it = todegroup.begin(); it != todegroup.end(); ++it) run(&amap, adart, *it);
{ }
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>:: }
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() );
#endif #endif
return amap.template alpha<1,0>(adart); return amap.template alpha<1,0>(adart);
}
/** Test if an edge can be inserted onto a 2-cell between two given darts.
* @param amap the used generalized map.
* @param adart1 a first dart.
* @param adart2 a second dart.
* @return true iff an edge can be inserted between adart1 and adart2.
*/
template < class CMap >
bool is_insertable_cell_1_in_cell_2(const CMap& amap,
typename CMap::Dart_const_handle adart1,
typename CMap::Dart_const_handle adart2)
{
if ( adart1==adart2 || adart1==amap.template alpha<0>(adart2) ) return false;
for ( CGAL::CMap_dart_const_iterator_of_orbit<CMap,0,1> it(amap,adart1);
it.cont(); ++it )
{
if ( it==adart2 ) return true;
}
return false;
}
/** Insert an edge in a 2-cell between two given darts.
* @param amap the used generalized map.
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
* @param adart2 a second dart of the facet. If NULL insert a dangling edge.
* @return a dart of the new edge, and not incident to the
* same vertex than adart1.
*/
template<class CMap>
typename CMap::Dart_handle
insert_cell_1_in_cell_2(CMap& amap,
typename CMap::Dart_handle adart1,
typename CMap::Dart_handle adart2)
{
if ( adart2!=amap.null_handle)
{
CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2));
} }
int m1=amap.get_new_mark(); /** Test if an edge can be inserted onto a 2-cell between two given darts.
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it1(amap, adart1, m1); * @param amap the used generalized map.
* @param adart1 a first dart.
int m2=amap.get_new_mark(); * @param adart2 a second dart.
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it2(amap, adart2, m2); * @return true iff an edge can be inserted between adart1 and adart2.
*/
typename CMap::Dart_handle d1=amap.null_handle; template < class CMap >
typename CMap::Dart_handle d2=amap.null_handle; bool is_insertable_cell_1_in_cell_2(const CMap& amap,
typename CMap::Dart_const_handle adart1,
int treated=amap.get_new_mark(); typename CMap::Dart_const_handle adart2)
for ( ; it1.cont(); ++it1)
{ {
CGAL_assertion (it2.cont() ); if ( adart1==adart2 || adart1==amap.template alpha<0>(adart2) ) return false;
d1 = amap.create_dart(); for ( CGAL::CMap_dart_const_iterator_of_orbit<CMap,0,1> it(amap,adart1);
d2 = amap.create_dart(); it.cont(); ++it )
amap.template basic_link_alpha<0>(d1, d2);
amap.mark(it1,treated);
if ( !amap.template is_free<1>(it1) &&
amap.is_marked(amap.template alpha<1>(it1), treated) )
{ {
amap.template basic_link_alpha<2>(amap.template alpha<1,1>(it1), d1); if ( it==adart2 ) return true;
amap.template basic_link_alpha<2>(amap.template alpha<2,0>(d1), d2); }
return false;
}
/** Insert an edge in a 2-cell between two given darts.
* @param amap the used generalized map.
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
* @param adart2 a second dart of the facet. If NULL insert a dangling edge.
* @return a dart of the new edge, and not incident to the
* same vertex than adart1.
*/
template<class CMap>
typename CMap::Dart_handle
insert_cell_1_in_cell_2(CMap& amap,
typename CMap::Dart_handle adart1,
typename CMap::Dart_handle adart2,
bool update_attributes=true)
{
if ( adart2!=amap.null_handle)
{
CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2));
} }
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim) typename CMap::size_type m1=amap.get_new_mark();
CGAL::CMap_dart_iterator_basic_of_involution<CMap,0,1> it1(amap, adart1, m1);
typename CMap::size_type m2=amap.get_new_mark();
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 d2=amap.null_handle;
typename CMap::size_type treated=amap.get_new_mark();
for ( ; it1.cont(); ++it1)
{ {
if ( !amap.is_free(it1, dim) && CGAL_assertion (it2.cont() );
amap.is_marked(amap.alpha(it1, dim), treated) ) d1 = amap.create_dart();
d2 = amap.create_dart();
amap.template basic_link_alpha<0>(d1, d2);
amap.mark(it1,treated);
if ( !amap.template is_free<1>(it1) &&
amap.is_marked(amap.template alpha<1>(it1), treated) )
{ {
amap.basic_link_alpha(amap.alpha(it1, dim, 1), d1, dim); amap.template basic_link_alpha<2>(amap.template alpha<1,1>(it1), d1);
amap.basic_link_alpha(amap.alpha(d1, dim, 0), d2, dim); amap.template basic_link_alpha<2>(amap.template alpha<2,0>(d1), d2);
}
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
{
if ( !amap.is_free(it1, dim) &&
amap.is_marked(amap.alpha(it1, dim), treated) )
{
amap.basic_link_alpha(amap.alpha(it1, dim, 1), d1, dim);
amap.basic_link_alpha(amap.alpha(d1, dim, 0), d2, dim);
}
}
amap.template link_alpha<1>(it1, d1);
if ( adart2!=amap.null_handle )
{
amap.template link_alpha<1>(it2, d2);
++it2;
} }
} }
amap.template link_alpha<1>(it1, d1); if (amap.are_attributes_automatically_managed() && update_attributes)
{
if ( !amap.template is_free<2>(d1) && d2!=amap.null_handle )
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
run(&amap, d1, amap.template alpha<2>(d1));
}
amap.negate_mark(m1);
it1.rewind();
if ( adart2!=amap.null_handle )
{ it2.rewind(); amap.negate_mark(m2); }
for ( ; it1.cont(); ++it1, ++it2)
{
amap.mark(it1,m1);
amap.unmark(it1,treated);
if ( adart2!=amap.null_handle ) amap.mark(it2,m2);
}
amap.negate_mark(m1);
CGAL_assertion( amap.is_whole_map_unmarked(m1) );
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
amap.free_mark(m1);
amap.free_mark(treated);
if ( adart2!=amap.null_handle ) if ( adart2!=amap.null_handle )
{ {
amap.template link_alpha<1>(it2, d2); amap.negate_mark(m2);
++it2; CGAL_assertion( amap.is_whole_map_unmarked(m2) );
} }
} amap.free_mark(m2);
if ( !amap.template is_free<2>(d1) && d2!=amap.null_handle )
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
run(&amap, d1, amap.template alpha<2>(d1));
amap.negate_mark(m1);
it1.rewind();
if ( adart2!=amap.null_handle )
{ it2.rewind(); amap.negate_mark(m2); }
for ( ; it1.cont(); ++it1, ++it2)
{
amap.mark(it1,m1);
amap.unmark(it1,treated);
if ( adart2!=amap.null_handle ) amap.mark(it2,m2);
}
amap.negate_mark(m1);
CGAL_assertion( amap.is_whole_map_unmarked(m1) );
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
amap.free_mark(m1);
amap.free_mark(treated);
if ( adart2!=amap.null_handle )
{
amap.negate_mark(m2);
CGAL_assertion( amap.is_whole_map_unmarked(m2) );
}
amap.free_mark(m2);
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS #ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
CGAL_assertion( amap.is_valid() ); CGAL_assertion( amap.is_valid() );
#endif #endif
return amap.template alpha<1>(adart1); return amap.template alpha<1>(adart1);
}
/** Test if a 2-cell can be inserted onto a given 3-cell along
* a path of edges.
* @param amap the used generalized map.
* @param afirst iterator on the begining of the path.
* @param alast iterator on the end of the path.
* @return true iff a 2-cell can be inserted along the path.
* the path is a sequence of dartd, one per edge
* where the face will be inserted.
*/
template <class CMap, class InputIterator>
bool is_insertable_cell_2_in_cell_3(const CMap& amap,
InputIterator afirst,
InputIterator alast)
{
CGAL_assertion( CMap::dimension>= 3 );
// The path must have at least one dart.
if (afirst==alast) return false;
typename CMap::Dart_const_handle prec = amap.null_handle;
typename CMap::Dart_const_handle od = amap.null_handle;
for (InputIterator it(afirst); it!=alast; ++it)
{
// The path must contain only non empty darts.
if (*it == amap.null_handle) return false;
// Two consecutive darts of the path must belong to two edges
// incident to the same vertex of the same volume.
if (prec != amap.null_handle)
{
if ( amap.template is_free<0>(prec) ) return false;
// alpha0(prec) and *it must belong to the same vertex of the same volume
if ( !CGAL::belong_to_same_cell<CMap, 0, 2>
(amap, amap.template alpha<0>(prec), *it) )
return false;
}
prec = *it;
} }
// The path must be closed. /** Test if a 2-cell can be inserted onto a given 3-cell along
if ( amap.template is_free<0>(prec) ) return false; * a path of edges.
if (!CGAL::belong_to_same_cell<CMap, 0, 2> * @param amap the used generalized map.
(amap, amap.template alpha<0>(prec), *afirst)) * @param afirst iterator on the begining of the path.
return false; * @param alast iterator on the end of the path.
* @return true iff a 2-cell can be inserted along the path.
return true; * the path is a sequence of dartd, one per edge
} * where the face will be inserted.
*/
/** Insert a 2-cell in a given 3-cell along a path of darts. template <class CMap, class InputIterator>
* @param amap the used generalized map. bool is_insertable_cell_2_in_cell_3(const CMap& amap,
* @param afirst iterator on the begining of the path. InputIterator afirst,
* @param alast iterator on the end of the path. InputIterator alast)
* the path is a sequence of dartd, one per edge
* where the face will be inserted.
* @return a dart of the new 2-cell.
*/
template<class CMap, class InputIterator>
typename CMap::Dart_handle
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast)
{
CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast));
typename CMap::Dart_handle prec = amap.null_handle, d = amap.null_handle,
dd = amap.null_handle, first = amap.null_handle;
bool withAlpha3 = false;
int treated = amap.get_new_mark();
{ {
for (InputIterator it(afirst); !withAlpha3 && it!=alast; ++it) CGAL_assertion( CMap::dimension>= 3 );
{
if (!amap.template is_free<2>(*it)) withAlpha3 = true; // The path must have at least one dart.
} if (afirst==alast) return false;
} typename CMap::Dart_const_handle prec = amap.null_handle;
typename CMap::Dart_const_handle od = amap.null_handle;
{
for (InputIterator it(afirst); it!=alast; ++it) for (InputIterator it(afirst); it!=alast; ++it)
{ {
d = amap.create_dart(); // The path must contain only non empty darts.
amap.template basic_link_alpha<0>(d, amap.create_dart()); if (*it == amap.null_handle) return false;
if ( withAlpha3 ) // Two consecutive darts of the path must belong to two edges
// incident to the same vertex of the same volume.
if (prec != amap.null_handle)
{ {
dd = amap.create_dart(); if ( amap.template is_free<0>(prec) ) return false;
amap.template basic_link_alpha<0>(dd, amap.create_dart());
// alpha0(prec) and *it must belong to the same vertex of the same volume
if ( !CGAL::belong_to_same_cell<CMap, 0, 2>
(amap, amap.template alpha<0>(prec), *it) )
return false;
} }
prec = *it;
if ( prec!=amap.null_handle )
{
amap.template basic_link_alpha<1>(prec, d);
if (withAlpha3)
amap.template basic_link_alpha<1>(amap.template alpha<3>(prec), dd);
}
else first = amap.template alpha<0>(d);
if ( !amap.template is_free<2>(*it) )
{
amap.template link_alpha<2>(amap.template alpha<2>(*it), dd);
}
amap.template link_alpha<2>(*it, d);
if (withAlpha3) amap.template basic_link_alpha<3>(d, dd);
prec = amap.template alpha<0>(d);
} }
// The path must be closed.
if ( amap.template is_free<0>(prec) ) return false;
if (!CGAL::belong_to_same_cell<CMap, 0, 2>
(amap, amap.template alpha<0>(prec), *afirst))
return false;
return true;
} }
amap.template basic_link_alpha<1>(prec, first); /** Insert a 2-cell in a given 3-cell along a path of darts.
if ( withAlpha3 ) * @param amap the used generalized map.
* @param afirst iterator on the begining of the path.
* @param alast iterator on the end of the path.
* the path is a sequence of dartd, one per edge
* where the face will be inserted.
* @return a dart of the new 2-cell.
*/
template<class CMap, class InputIterator>
typename CMap::Dart_handle
insert_cell_2_in_cell_3(CMap& amap, InputIterator afirst, InputIterator alast,
bool update_attributes=true)
{ {
amap.template basic_link_alpha<1>(amap.template alpha<3>(prec), CGAL_assertion(is_insertable_cell_2_in_cell_3(amap,afirst,alast));
amap.template alpha<3>(first));
} typename CMap::Dart_handle prec = amap.null_handle, d = amap.null_handle,
dd = amap.null_handle, first = amap.null_handle;
bool withAlpha3 = false;
typename CMap::size_type treated = amap.get_new_mark();
// Make copies of the new facet for dimension >=4
/* for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
{
if ( !amap.is_free(*it, dim) )
{ {
ddd = amap.create_dart(); for (InputIterator it(afirst); !withAlpha3 && it!=alast; ++it)
amap.template basic_link_alpha<0>(ddd, amap.create_dart()); {
amap.basic_link_alpha(d, ddd, dim); if (!amap.template is_free<2>(*it)) withAlpha3 = true;
amap.basic_link_alpha(amap.template alpha<0>(d), }
amap.template alpha<0>(ddd), dim); }
if ( withAlpha3 ) {
{ for (InputIterator it(afirst); it!=alast; ++it)
dddd = amap.create_dart(); {
amap.template basic_link_alpha<0>(dddd, amap.create_dart()); d = amap.create_dart();
amap.template basic_link_alpha<0>(d, amap.create_dart());
amap.basic_link_alpha(dd, dddd, dim); if ( withAlpha3 )
amap.basic_link_alpha(amap.template alpha<0>(dd), {
amap.template alpha<0>(dddd), dim); dd = amap.create_dart();
} amap.template basic_link_alpha<0>(dd, amap.create_dart());
}
if ( prec!=amap.null_handle )
{
amap.template basic_link_alpha<1>(prec, d);
if (withAlpha3)
amap.template basic_link_alpha<1>(amap.template alpha<3>(prec), dd);
}
else first = amap.template alpha<0>(d);
if ( !amap.template is_free<2>(*it) )
{
amap.template link_alpha<2>(amap.template alpha<2>(*it), dd);
}
amap.template link_alpha<2>(*it, d);
if (withAlpha3) amap.template basic_link_alpha<3>(d, dd);
prec = amap.template alpha<0>(d);
}
}
amap.template basic_link_alpha<1>(prec, first);
if ( withAlpha3 )
{
amap.template basic_link_alpha<1>(amap.template alpha<3>(prec),
amap.template alpha<3>(first));
}
// Make copies of the new facet for dimension >=4
/* for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
{
if ( !amap.is_free(*it, dim) )
{
ddd = amap.create_dart();
amap.template basic_link_alpha<0>(ddd, amap.create_dart());
amap.basic_link_alpha(d, ddd, dim);
amap.basic_link_alpha(amap.template alpha<0>(d),
amap.template alpha<0>(ddd), dim);
if ( withAlpha3 )
{
dddd = amap.create_dart();
amap.template basic_link_alpha<0>(dddd, amap.create_dart());
amap.basic_link_alpha(dd, dddd, dim);
amap.basic_link_alpha(amap.template alpha<0>(dd),
amap.template alpha<0>(dddd), dim);
}
} }
}*/ }*/
// Make copies of the new facet for dimension >=4 // Make copies of the new facet for dimension >=4
for ( unsigned int dim=4; dim<=CMap::dimension; ++dim ) for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
{
if ( !amap.is_free(first, dim) )
{ {
typename CMap::Dart_handle first2 = amap.null_handle; if ( !amap.is_free(first, dim) )
prec = amap.null_handle;
for ( CMap_dart_iterator_basic_of_orbit<CMap,0,1> it(amap, first);
it.cont(); ++it )
{ {
d = amap.create_dart(); typename CMap::Dart_handle first2 = amap.null_handle;
amap.basic_link_alpha(amap.template alpha<2>(it), d, dim); prec = amap.null_handle;
if ( withAlpha3 ) for ( CMap_dart_iterator_basic_of_orbit<CMap,0,1> it(amap, first);
it.cont(); ++it )
{ {
dd = amap.create_dart(); d = amap.create_dart();
amap.basic_link_alpha_for_involution amap.basic_link_alpha(amap.template alpha<2>(it), d, dim);
(amap.template alpha<2,3>(it), dd, dim);
amap.template basic_link_alpha_for_involution<3>(d, dd);
}
if ( prec!=amap.null_handle )
{
amap.link_alpha_0(prec, d);
if ( withAlpha3 ) if ( withAlpha3 )
{ {
amap.basic_link_alpha_1(amap.template alpha<3>(prec), dd); dd = amap.create_dart();
amap.basic_link_alpha_for_involution
(amap.template alpha<2,3>(it), dd, dim);
amap.template basic_link_alpha_for_involution<3>(d, dd);
} }
} if ( prec!=amap.null_handle )
else first2 = prec;
// We consider dim2=2 out of the loop to use link_alpha instead of
// basic _link_alpha (to modify non void attributes only once).
if ( !amap.template is_free<2>(it) &&
amap.is_free(amap.template alpha<2>(it), dim) )
amap.template link_alpha_for_involution<2>
(amap.alpha(it,2,dim), d);
if ( withAlpha3 &&
!amap.template is_free<2>(amap.template alpha<3>(it)) &&
amap.is_free(amap.template alpha<3,2>(it), dim) )
amap.template link_alpha_for_involution<2>(amap.alpha(it,3,2,dim), dd);
for ( unsigned int dim2=3; dim2<=CMap::dimension; ++dim2 )
{
if ( dim2+1!=dim && dim2!=dim && dim2!=dim+1 )
{ {
if ( !amap.is_free(it, dim2) && amap.is_free(amap.alpha(it, dim2), dim) ) amap.link_alpha_0(prec, d);
amap.basic_link_alpha_for_involution(amap.alpha(it, dim2, dim), if ( withAlpha3 )
d, dim2); {
if ( withAlpha3 && !amap.is_free(amap.template alpha<3>(it), dim2) && amap.basic_link_alpha_1(amap.template alpha<3>(prec), dd);
amap.is_free(amap.alpha(it, 3, dim2), dim) ) }
amap.basic_link_alpha_for_involution
(amap.alpha(it, 3, dim2, dim), dd, dim2);
} }
else first2 = prec;
// We consider dim2=2 out of the loop to use link_alpha instead of
// basic _link_alpha (to modify non void attributes only once).
if ( !amap.template is_free<2>(it) &&
amap.is_free(amap.template alpha<2>(it), dim) )
amap.template link_alpha_for_involution<2>
(amap.alpha(it,2,dim), d);
if ( withAlpha3 &&
!amap.template is_free<2>(amap.template alpha<3>(it)) &&
amap.is_free(amap.template alpha<3,2>(it), dim) )
amap.template link_alpha_for_involution<2>(amap.alpha(it,3,2,dim), dd);
for ( unsigned int dim2=3; dim2<=CMap::dimension; ++dim2 )
{
if ( dim2+1!=dim && dim2!=dim && dim2!=dim+1 )
{
if ( !amap.is_free(it, dim2) && amap.is_free(amap.alpha(it, dim2), dim) )
amap.basic_link_alpha_for_involution(amap.alpha(it, dim2, dim),
d, dim2);
if ( withAlpha3 && !amap.is_free(amap.template alpha<3>(it), dim2) &&
amap.is_free(amap.alpha(it, 3, dim2), dim) )
amap.basic_link_alpha_for_involution
(amap.alpha(it, 3, dim2, dim), dd, dim2);
}
}
prec = d;
}
amap.basic_link_alpha_0( prec, first2 );
if ( withAlpha3 )
{
amap.basic_link_alpha_1( amap.template alpha<3>(prec),
amap.template alpha<3>(first2) );
} }
prec = d;
}
amap.basic_link_alpha_0( prec, first2 );
if ( withAlpha3 )
{
amap.basic_link_alpha_1( amap.template alpha<3>(prec),
amap.template alpha<3>(first2) );
} }
} }
}
// Degroup the attributes // Degroup the attributes
if ( withAlpha3 ) if ( withAlpha3 )
{ // Here we cannot use Degroup_attribute_functor_run as new darts do not { // Here we cannot use Degroup_attribute_functor_run as new darts do not
// have their 3-attribute // have their 3-attribute
CGAL::internal::Degroup_attribute_functor_run<CMap, 3>:: CGAL::internal::Degroup_attribute_functor_run<CMap, 3>::
run(&amap, first, amap.template alpha<3>(first)); run(&amap, first, amap.template alpha<3>(first));
} }
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS #ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
CGAL_assertion( amap.is_valid() ); CGAL_assertion( amap.is_valid() );
#endif #endif
return first; return first;
} }
} // namespace CGAL } // namespace CGAL

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;