mirror of https://github.com/CGAL/cgal
Deprecate global modification functions.
This commit is contained in:
parent
67556fbef3
commit
6a171dcc77
|
|
@ -31,6 +31,7 @@
|
|||
#include <CGAL/Cell_const_iterators.h>
|
||||
#include <CGAL/Combinatorial_map_basic_operations.h>
|
||||
#include <CGAL/Combinatorial_map_storages.h>
|
||||
#include <CGAL/Combinatorial_map_operations.h>
|
||||
#include <CGAL/Unique_hash_map.h>
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
|
|
@ -3735,6 +3736,711 @@ namespace CGAL {
|
|||
this->automatic_attributes_management = newval;
|
||||
}
|
||||
|
||||
/** Test if an i-cell can be removed.
|
||||
* An i-cell can be removed if i==dimension or i==dimension-1,
|
||||
* or if there are at most two (i+1)-cell incident to it.
|
||||
* @param adart a dart of the i-cell.
|
||||
* @return true iff the i-cell can be removed.
|
||||
*/
|
||||
template < unsigned int i >
|
||||
bool is_removable(Dart_const_handle adart) const
|
||||
{ return CGAL::Is_removable_functor<Self, i>::run(*this, adart); }
|
||||
|
||||
/** Remove an i-cell, 0<=i<=dimension.
|
||||
* @param adart a dart of the i-cell to remove.
|
||||
* @param update_attributes a boolean to update the enabled attributes
|
||||
* @return the number of deleted darts.
|
||||
*/
|
||||
template < unsigned int i >
|
||||
size_t remove_cell(Dart_handle adart, bool update_attributes = true)
|
||||
{
|
||||
return CGAL::Remove_cell_functor<Self,i,Self::dimension-i>::
|
||||
run(*this,adart,update_attributes);
|
||||
}
|
||||
|
||||
/** Test if an i-cell can be contracted.
|
||||
* An i-cell can be contracted if i==1
|
||||
* or if there are at most two (i-1)-cell incident to it.
|
||||
* @param adart a dart of the i-cell.
|
||||
* @return true iff the i-cell can be contracted.
|
||||
*/
|
||||
template < unsigned int i >
|
||||
bool is_contractible(Dart_const_handle adart)
|
||||
{ return CGAL::Is_contractible_functor<Self, i>::run(*this,adart); }
|
||||
|
||||
/** Contract an i-cell, 1<=i<=dimension.
|
||||
* @param adart a dart of the i-cell to remove.
|
||||
* @return the number of deleted darts.
|
||||
*/
|
||||
template < unsigned int i >
|
||||
size_t contract_cell(Dart_handle adart, bool update_attributes = true)
|
||||
{
|
||||
return CGAL::Contract_cell_functor<Self,i>::
|
||||
run(*this,adart, update_attributes);
|
||||
}
|
||||
|
||||
/** Insert a vertex in a given edge.
|
||||
* @param adart a dart of the edge (!=NULL && !=null_dart_handle).
|
||||
* @param update_attributes a boolean to update the enabled attributes
|
||||
* @return a dart of the new vertex.
|
||||
*/
|
||||
Dart_handle insert_cell_0_in_cell_1( Dart_handle adart,
|
||||
typename Attribute_handle<0>::type
|
||||
ah=null_handle,
|
||||
bool update_attributes=true )
|
||||
{
|
||||
Dart_handle d1, d2;
|
||||
size_type mark=get_new_mark();
|
||||
|
||||
// 1) We store all the darts of the edge.
|
||||
std::deque<Dart_handle> vect;
|
||||
size_type m=get_new_mark();
|
||||
{
|
||||
for ( typename Dart_of_cell_basic_range<1>::iterator
|
||||
it=darts_of_cell_basic<1>(adart, m).begin();
|
||||
it != 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<Dart_handle>::iterator it = vect.begin();
|
||||
for (; it != vect.end(); ++it)
|
||||
{
|
||||
d1 = create_dart();
|
||||
|
||||
if (!is_free<1>(*it))
|
||||
{ basic_link_beta_1(d1, beta<1>(*it)); }
|
||||
|
||||
for ( unsigned int dim=2; dim<=dimension; ++dim )
|
||||
{
|
||||
if (!is_free(*it, dim) && is_marked(beta(*it, dim), mark))
|
||||
{
|
||||
basic_link_beta_for_involution(beta(*it, dim), d1, dim);
|
||||
basic_link_beta_for_involution(*it, beta(*it, dim, 1), dim);
|
||||
}
|
||||
}
|
||||
|
||||
basic_link_beta_1(*it, d1);
|
||||
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
// We copy all the attributes except for dim=0
|
||||
Helper::template Foreach_enabled_attributes_except
|
||||
<internal::Group_attribute_functor_of_dart<Self>, 0>::
|
||||
run(this,*it,d1);
|
||||
}
|
||||
if (ah != null_handle)
|
||||
{
|
||||
// We initialise the 0-atttrib to ah
|
||||
internal::Set_i_attribute_of_dart_functor<Self, 0>::
|
||||
run(this, d1, ah);
|
||||
}
|
||||
mark(*it, mark);
|
||||
}
|
||||
|
||||
for (it = vect.begin(); it != vect.end(); ++it)
|
||||
{
|
||||
unmark(*it, m);
|
||||
unmark(*it, mark);
|
||||
}
|
||||
|
||||
CGAL_assertion(is_whole_map_unmarked(m));
|
||||
CGAL_assertion(is_whole_map_unmarked(mark));
|
||||
|
||||
free_mark(m);
|
||||
free_mark(mark);
|
||||
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
internal::Degroup_attribute_functor_run<Self, 1>::
|
||||
run(this, adart, beta<1>(adart));
|
||||
}
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( is_valid() );
|
||||
#endif
|
||||
|
||||
return beta<1>(adart);
|
||||
}
|
||||
|
||||
/** Insert a vertex in the given 2-cell which is splitted in triangles,
|
||||
* once for each inital edge of the facet.
|
||||
* @param adart a dart of the facet to triangulate.
|
||||
* @param update_attributes a boolean to update the enabled attributes
|
||||
* (deprecated, now we use are_attributes_automatically_managed())
|
||||
* @return A dart incident to the new vertex.
|
||||
*/
|
||||
Dart_handle insert_cell_0_in_cell_2( Dart_handle adart,
|
||||
typename Attribute_handle<0>::type
|
||||
ah=null_handle,
|
||||
bool update_attributes=true )
|
||||
{
|
||||
CGAL_assertion(adart!=null_dart_handle);
|
||||
|
||||
Dart_handle first=adart, prev=null_handle,
|
||||
cur=null_handle, next=null_handle,
|
||||
n1=null_handle, n2=null_handle,
|
||||
nn1=null_handle, nn2=null_handle;
|
||||
|
||||
// If the facet is open, we search the dart 0-free
|
||||
while ( !this->template is_free<0>(first) && beta<0>(first)!=adart )
|
||||
first = this->template beta<0>(first);
|
||||
|
||||
// Mark used to mark darts already treated.
|
||||
size_type treated = get_new_mark();
|
||||
|
||||
// Stack of marked darts
|
||||
std::deque<Dart_handle> tounmark;
|
||||
|
||||
// Now we run through the facet
|
||||
cur = first;
|
||||
do
|
||||
{
|
||||
next = this->template beta<1>(cur);
|
||||
mark(cur, treated);
|
||||
tounmark.push_back(cur);
|
||||
|
||||
if (!this->template is_free<0>(cur))
|
||||
{
|
||||
n1=create_dart();
|
||||
link_beta_0(cur, n1);
|
||||
}
|
||||
else n1 = null_handle;
|
||||
|
||||
if (!this->template is_free<1>(cur))
|
||||
{
|
||||
n2 = create_dart();
|
||||
link_beta_1(cur, n2);
|
||||
}
|
||||
else n2 = null_handle;
|
||||
|
||||
if ( n1!=null_handle )
|
||||
{
|
||||
if ( n2!=null_handle )
|
||||
basic_link_beta_0(n1, n2);
|
||||
|
||||
if ( prev!=null_handle )
|
||||
this->template basic_link_beta_for_involution<2>(prev, n1);
|
||||
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
internal::Set_i_attribute_of_dart_functor<Self, 0>::
|
||||
run(this, n1, ah);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int dim=3; dim<=dimension; ++dim)
|
||||
{
|
||||
if ( !is_free(adart, dim) )
|
||||
{
|
||||
if ( !is_marked(beta(cur, dim), treated) )
|
||||
{
|
||||
if (n1!=null_handle)
|
||||
{
|
||||
nn1=create_dart();
|
||||
link_beta_1(beta(cur, dim), nn1);
|
||||
basic_link_beta_for_involution(n1, nn1, dim);
|
||||
}
|
||||
else nn1=null_handle;
|
||||
|
||||
if (n2!=null_handle)
|
||||
{
|
||||
nn2=create_dart();
|
||||
link_beta_0(beta(cur, dim), nn2);
|
||||
basic_link_beta_for_involution(n2, nn2, dim);
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
internal::Set_i_attribute_of_dart_functor<Self, 0>::
|
||||
run(this, nn2, ah);
|
||||
}
|
||||
}
|
||||
else nn2=null_handle;
|
||||
|
||||
if (nn1 != null_handle && nn2 != null_handle)
|
||||
basic_link_beta_1(nn1, nn2);
|
||||
|
||||
if (nn1 != null_handle && prev != null_handle)
|
||||
this->template basic_link_beta_for_involution<2>(nn1, beta(prev, dim));
|
||||
|
||||
mark(beta(cur, dim), treated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( n1!=null_handle )
|
||||
basic_link_beta_for_involution(n1,
|
||||
beta(cur, dim, 1), dim);
|
||||
if ( n2!=null_handle )
|
||||
basic_link_beta_for_involution(n2,
|
||||
beta(cur, dim, 0), dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prev = n2;
|
||||
cur = next;
|
||||
}
|
||||
while(cur!=first && cur!=null_dart_handle);
|
||||
|
||||
if (n2 != null_handle)
|
||||
{
|
||||
this->template basic_link_beta_for_involution<2>
|
||||
(this->template beta<0>(first), n2);
|
||||
for (unsigned int dim=3; dim<=dimension; ++dim)
|
||||
{
|
||||
if ( !is_free(adart, dim) )
|
||||
{
|
||||
this->template basic_link_beta_for_involution<2>(beta(first, 0, dim),
|
||||
beta(n2, dim));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we unmark all marked darts, and we degroup the new faces with the
|
||||
// initial one (if 2-attributes are non void).
|
||||
for ( typename std::deque<Dart_handle>::iterator
|
||||
itd=tounmark.begin(); itd!=tounmark.end(); ++itd )
|
||||
{
|
||||
unmark(*itd, treated);
|
||||
for (unsigned int dim=3; dim<=dimension; ++dim)
|
||||
{
|
||||
if ( !is_free(*itd, dim) )
|
||||
unmark(beta(*itd, dim), treated);
|
||||
}
|
||||
if ( *itd!=adart )
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
internal::Degroup_attribute_functor_run<Self, 2>::
|
||||
run(this, adart, *itd);
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_assertion(is_whole_map_unmarked(treated));
|
||||
free_mark(treated);
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( is_valid() );
|
||||
#endif
|
||||
|
||||
return n1;
|
||||
}
|
||||
|
||||
/** Insert a dangling edge in a 2-cell between given by a dart.
|
||||
* @param adart1 a first dart of the facet (!=NULL && !=null_dart_handle).
|
||||
* @param update_attributes a boolean to update the enabled attributes
|
||||
* @return a dart of the new edge, not incident to the vertex of adart1.
|
||||
*/
|
||||
Dart_handle insert_dangling_cell_1_in_cell_2( Dart_handle adart1,
|
||||
typename Attribute_handle<0>::type
|
||||
ah=null_handle,
|
||||
bool update_attributes=true )
|
||||
{
|
||||
size_type mark1 = get_new_mark();
|
||||
std::deque<Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
mark(it,mark1);
|
||||
}
|
||||
}
|
||||
|
||||
Dart_handle d1 = null_handle;
|
||||
Dart_handle d2 = null_handle;
|
||||
unsigned int s1 = 0;
|
||||
|
||||
size_type treated=get_new_mark();
|
||||
|
||||
CMap_dart_iterator_basic_of_involution<Self,1> it1(*this, adart1, treated);
|
||||
|
||||
for ( ; it1.cont(); ++it1)
|
||||
{
|
||||
d1 = create_dart();
|
||||
d2 = create_dart();
|
||||
|
||||
if ( is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !is_free(it1, s1) )
|
||||
{
|
||||
if ( s1==0 )
|
||||
link_beta_1(beta<0>(it1), d2);
|
||||
else
|
||||
link_beta_0(beta<1>(it1), d2);
|
||||
}
|
||||
|
||||
if (s1==0)
|
||||
{
|
||||
link_beta_0(it1, d1);
|
||||
link_beta_0(d1, d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
link_beta_1(it1, d1);
|
||||
link_beta_1(d1, d2);
|
||||
}
|
||||
|
||||
basic_link_beta_for_involution<2>(d1, d2);
|
||||
|
||||
for ( unsigned int dim=3; dim<=dimension; ++dim)
|
||||
{
|
||||
if ( !is_free(it1, dim) &&
|
||||
is_marked(beta(it1, dim), treated) )
|
||||
{
|
||||
basic_link_beta_for_involution
|
||||
(beta(it1, dim, CGAL_BETAINV(s1)), d1, dim);
|
||||
basic_link_beta_for_involution
|
||||
(beta(it1, dim, CGAL_BETAINV(s1), 2), d2, dim);
|
||||
}
|
||||
}
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
internal::Set_i_attribute_of_dart_functor<Self, 0>::run(this, d1, ah);
|
||||
}
|
||||
mark(it1, treated);
|
||||
}
|
||||
|
||||
negate_mark(treated);
|
||||
for ( it1.rewind(); it1.cont(); ++it1 )
|
||||
{ mark(it1, treated); }
|
||||
|
||||
CGAL_assertion( is_whole_map_marked(treated) );
|
||||
free_mark(treated);
|
||||
|
||||
for ( typename std::deque<Dart_handle>::iterator it=to_unmark.begin();
|
||||
it!=to_unmark.end(); ++it)
|
||||
{ unmark(*it, mark1); }
|
||||
|
||||
CGAL_assertion( is_whole_map_unmarked(mark1) );
|
||||
free_mark(mark1);
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( is_valid() );
|
||||
#endif
|
||||
|
||||
return this->template beta<0>(adart1);
|
||||
}
|
||||
|
||||
/** Test if an edge can be inserted onto a 2-cell between two given darts.
|
||||
* @param adart1 a first dart.
|
||||
* @param adart2 a second dart.
|
||||
* @return true iff an edge can be inserted between adart1 and adart2.
|
||||
*/
|
||||
bool is_insertable_cell_1_in_cell_2(Dart_const_handle adart1,
|
||||
Dart_const_handle adart2) const
|
||||
{
|
||||
if ( adart1==adart2 ) return false;
|
||||
for ( CMap_dart_const_iterator_of_orbit<Self,1> it(*this,adart1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
if ( it==adart2 ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Insert an edge in a 2-cell between two given darts.
|
||||
* @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.
|
||||
* @param update_attributes a boolean to update the enabled attributes
|
||||
* @return a dart of the new edge, and not incident to the
|
||||
* same vertex than adart1.
|
||||
*/
|
||||
Dart_handle insert_cell_1_in_cell_2(Dart_handle adart1,
|
||||
Dart_handle adart2,
|
||||
bool update_attributes=true)
|
||||
{
|
||||
if ( adart2==null_handle )
|
||||
return insert_dangling_cell_1_in_cell_2(adart1, null_handle,
|
||||
update_attributes);
|
||||
|
||||
CGAL_assertion(is_insertable_cell_1_in_cell_2(adart1, adart2));
|
||||
|
||||
size_type m1=get_new_mark();
|
||||
CMap_dart_iterator_basic_of_involution<Self,1> it1(*this, adart1, m1);
|
||||
|
||||
size_type m2=get_new_mark();
|
||||
CMap_dart_iterator_basic_of_involution<Self,1> it2(*this, adart2, m2);
|
||||
|
||||
size_type mark1=get_new_mark();
|
||||
std::deque<Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<Self,0> it(*this,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
mark(it, mark1);
|
||||
}
|
||||
}
|
||||
|
||||
Dart_handle d1=null_handle;
|
||||
Dart_handle d2=null_handle;
|
||||
unsigned int s1=0;
|
||||
|
||||
size_type treated=get_new_mark();
|
||||
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
CGAL_assertion ( it2.cont() );
|
||||
d1 = create_dart();
|
||||
d2 = create_dart();
|
||||
|
||||
if ( is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !is_free(it1, s1) )
|
||||
{
|
||||
if ( s1==0 ) link_beta_1(this->template beta<0>(it1), d2);
|
||||
else link_beta_0(this->template beta<1>(it1), d2);
|
||||
}
|
||||
|
||||
if ( !is_free(it2, s1) )
|
||||
{
|
||||
if ( s1==0 ) link_beta_1(this->template beta<0>(it2), d1);
|
||||
else link_beta_0(this->template beta<1>(it2), d1);
|
||||
}
|
||||
|
||||
if ( s1==0 )
|
||||
{
|
||||
link_beta_0(it1, d1);
|
||||
link_beta_0(it2, d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
link_beta_1(it1, d1);
|
||||
link_beta_1(it2, d2);
|
||||
}
|
||||
this->template basic_link_beta_for_involution<2>(d2, d1);
|
||||
|
||||
for ( unsigned int dim=3; dim<=dimension; ++dim)
|
||||
{
|
||||
if ( !is_free(it1, dim) &&
|
||||
is_marked(beta(it1, dim), treated) )
|
||||
{
|
||||
basic_link_beta_for_involution
|
||||
(beta(it1, dim, CGAL_BETAINV(s1)), d1, dim);
|
||||
basic_link_beta_for_involution
|
||||
(beta(it1, dim, CGAL_BETAINV(s1), 2), d2, dim);
|
||||
}
|
||||
}
|
||||
|
||||
mark(it1,treated);
|
||||
}
|
||||
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
internal::Degroup_attribute_functor_run<Self, 2>::run(this, d1, d2);
|
||||
}
|
||||
|
||||
negate_mark(m1);
|
||||
negate_mark(m2);
|
||||
it1.rewind(); it2.rewind();
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
mark(it1,m1);
|
||||
unmark(it1,treated);
|
||||
mark(it2,m2);
|
||||
}
|
||||
negate_mark(m1);
|
||||
negate_mark(m2);
|
||||
CGAL_assertion( is_whole_map_unmarked(m1) );
|
||||
CGAL_assertion( is_whole_map_unmarked(m2) );
|
||||
CGAL_assertion( is_whole_map_unmarked(treated) );
|
||||
free_mark(m1);
|
||||
free_mark(m2);
|
||||
free_mark(treated);
|
||||
|
||||
typename std::deque<Dart_handle>::iterator it = to_unmark.begin();
|
||||
for (; it != to_unmark.end(); ++it)
|
||||
{ unmark(*it, mark1); }
|
||||
CGAL_assertion( is_whole_map_unmarked(mark1) );
|
||||
free_mark(mark1);
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( is_valid() );
|
||||
#endif
|
||||
|
||||
return this->template beta<0>(adart1);
|
||||
}
|
||||
|
||||
/** Test if a 2-cell can be inserted onto a given 3-cell along
|
||||
* a path of edges.
|
||||
* @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.
|
||||
*/
|
||||
template <class InputIterator>
|
||||
bool is_insertable_cell_2_in_cell_3(InputIterator afirst,
|
||||
InputIterator alast) const
|
||||
{
|
||||
CGAL_assertion( dimension>= 3 );
|
||||
|
||||
// The path must have at least one dart.
|
||||
if (afirst==alast) return false;
|
||||
Dart_const_handle prec = null_handle;
|
||||
Dart_const_handle od = null_handle;
|
||||
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
// The path must contain only non empty darts.
|
||||
if (*it == null_handle || *it==null_dart_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 != null_handle)
|
||||
{
|
||||
od = other_extremity(prec);
|
||||
if ( od==null_handle ) return false;
|
||||
|
||||
// of and *it must belong to the same vertex of the same volume
|
||||
if ( !belong_to_same_cell<Self, 0, 2>(*this, od, *it) )
|
||||
return false;
|
||||
}
|
||||
prec = *it;
|
||||
}
|
||||
|
||||
// The path must be closed.
|
||||
od = other_extremity(prec);
|
||||
if ( od==null_handle ) return false;
|
||||
|
||||
if (!belong_to_same_cell<Self, 0, 2>(*this, od, *afirst))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Insert a 2-cell in a given 3-cell along a path of darts.
|
||||
* @param afirst iterator on the begining of the path.
|
||||
* @param alast iterator on the end of the path.
|
||||
* @param update_attributes a boolean to update the enabled attributes
|
||||
* @return a dart of the new 2-cell.
|
||||
*/
|
||||
template<class InputIterator>
|
||||
Dart_handle insert_cell_2_in_cell_3(InputIterator afirst, InputIterator alast,
|
||||
bool update_attributes=true)
|
||||
{
|
||||
CGAL_assertion(is_insertable_cell_2_in_cell_3(afirst,alast));
|
||||
|
||||
Dart_handle prec = null_handle, d = null_handle,
|
||||
dd = null_handle, first = null_handle;
|
||||
bool withBeta3 = false;
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); !withBeta3 && it!=alast; ++it)
|
||||
{
|
||||
if (!this->template is_free<2>(*it)) withBeta3 = true;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
d = create_dart();
|
||||
if ( withBeta3 )
|
||||
dd = create_dart();
|
||||
|
||||
if (prec != null_handle)
|
||||
{
|
||||
basic_link_beta_0(prec, d);
|
||||
if (withBeta3)
|
||||
basic_link_beta_1(this->template beta<3>(prec), dd);
|
||||
}
|
||||
else first = d;
|
||||
|
||||
if ( !this->template is_free<2>((*it)) )
|
||||
basic_link_beta_for_involution<2>(this->template beta<2>(*it), dd);
|
||||
|
||||
this->template link_beta_for_involution<2>(*it, d);
|
||||
if ( withBeta3 )
|
||||
this->template link_beta_for_involution<3>(d, dd);
|
||||
|
||||
prec = d;
|
||||
}
|
||||
}
|
||||
|
||||
basic_link_beta_0(prec, first);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
basic_link_beta_1(this->template beta<3>(prec),
|
||||
this->template beta<3>(first));
|
||||
}
|
||||
|
||||
// Make copies of the new facet for dimension >=4
|
||||
for ( unsigned int dim=4; dim<=dimension; ++dim )
|
||||
{
|
||||
if ( !is_free(first, dim) )
|
||||
{
|
||||
Dart_handle first2 = null_handle;
|
||||
prec = null_handle;
|
||||
for ( CMap_dart_iterator_basic_of_orbit<Self, 1> it(*this, first);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
d = create_dart();
|
||||
basic_link_beta_for_involution(this->template beta<2>(it), d, dim);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
dd = create_dart();
|
||||
basic_link_beta_for_involution(this->template beta<2,3>(it), dd, dim);
|
||||
this->template basic_link_beta_for_involution<3>(d, dd);
|
||||
}
|
||||
if ( prec!=null_handle )
|
||||
{
|
||||
link_beta_0(prec, d);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
basic_link_beta_1(this->template beta<3>(prec), dd);
|
||||
}
|
||||
}
|
||||
else first2 = prec;
|
||||
|
||||
// We consider dim2=2 out of the loop to use link_beta instead of
|
||||
// basic _link_beta (to modify non void attributes only once).
|
||||
if ( !this->template is_free<2>(it) && is_free(this->template beta<2>(it), dim) )
|
||||
this->template link_beta_for_involution<2>(beta(it,2,dim), d);
|
||||
if ( withBeta3 && !this->template is_free<2>(this->template beta<3>(it)) &&
|
||||
is_free(this->template beta<3,2>(it), dim) )
|
||||
this->template link_beta_for_involution<2>(beta(it,3,2,dim), dd);
|
||||
|
||||
for ( unsigned int dim2=3; dim2<=dimension; ++dim2 )
|
||||
{
|
||||
if ( dim2+1!=dim && dim2!=dim && dim2!=dim+1 )
|
||||
{
|
||||
if ( !is_free(it, dim2) && is_free(beta(it, dim2), dim) )
|
||||
basic_link_beta_for_involution(beta(it, dim2, dim),
|
||||
d, dim2);
|
||||
if ( withBeta3 && !is_free(this->template beta<3>(it), dim2) &&
|
||||
is_free(beta(it, 3, dim2), dim) )
|
||||
basic_link_beta_for_involution(beta(it, 3, dim2, dim), dd,
|
||||
dim2);
|
||||
}
|
||||
}
|
||||
prec = d;
|
||||
}
|
||||
basic_link_beta_0( prec, first2 );
|
||||
if ( withBeta3 )
|
||||
{
|
||||
basic_link_beta_1( this->template beta<3>(prec), this->template beta<3>(first2) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Degroup the attributes
|
||||
if ( withBeta3 )
|
||||
{ // Here we cannot use Degroup_attribute_functor_run as new darts do not
|
||||
// have their 3-attribute
|
||||
if (are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Degroup_attribute_functor_run<Self, 3>::
|
||||
run(this, first, this->template beta<3>(first));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( is_valid() );
|
||||
#endif
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Number of times each mark is reserved. 0 if the mark is free.
|
||||
mutable size_type mnb_times_reserved_marks[NB_MARKS];
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ namespace CGAL
|
|||
* Insertion operations on combinatorial map.
|
||||
*/
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
/** Insert a vertex in a given edge.
|
||||
* @param amap the used combinatorial map.
|
||||
* @param adart a dart of the edge (!=NULL && !=null_dart_handle).
|
||||
|
|
@ -36,84 +38,13 @@ namespace CGAL
|
|||
* @return a dart of the new vertex.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
CGAL_DEPRECATED typename CMap::Dart_handle
|
||||
insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
|
||||
typename CMap::template
|
||||
Attribute_handle<0>::type ah=CMap::null_handle,
|
||||
bool update_attributes=true )
|
||||
{
|
||||
typename CMap::Dart_handle d1, d2;
|
||||
typename CMap::size_type mark=amap.get_new_mark();
|
||||
|
||||
// 1) We store all the darts of the edge.
|
||||
std::deque<typename CMap::Dart_handle> vect;
|
||||
typename CMap::size_type m=amap.get_new_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<1>(*it))
|
||||
{ amap.basic_link_beta_1(d1, amap.template beta<1>(*it)); }
|
||||
|
||||
for ( unsigned int dim=2; dim<=CMap::dimension; ++dim )
|
||||
{
|
||||
if (!amap.is_free(*it, dim) && amap.is_marked(amap.beta(*it, dim), mark))
|
||||
{
|
||||
amap.basic_link_beta_for_involution(amap.beta(*it, dim), d1, dim);
|
||||
amap.basic_link_beta_for_involution(*it, amap.beta(*it, dim, 1), dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.basic_link_beta_1(*it, d1);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
for (it = vect.begin(); it != vect.end(); ++it)
|
||||
{
|
||||
amap.unmark(*it, m);
|
||||
amap.unmark(*it, mark);
|
||||
}
|
||||
|
||||
CGAL_assertion(amap.is_whole_map_unmarked(m));
|
||||
CGAL_assertion(amap.is_whole_map_unmarked(mark));
|
||||
|
||||
amap.free_mark(m);
|
||||
amap.free_mark(mark);
|
||||
|
||||
if (amap.are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Degroup_attribute_functor_run<CMap, 1>::
|
||||
run(&amap, adart, amap.template beta<1>(adart));
|
||||
}
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( amap.is_valid() );
|
||||
#endif
|
||||
|
||||
return amap.template beta<1>(adart);
|
||||
return amap.insert_cell_0_in_cell_1(adart, ah, update_attributes);
|
||||
}
|
||||
|
||||
/** Insert a vertex in the given 2-cell which is splitted in triangles,
|
||||
|
|
@ -125,161 +56,13 @@ insert_cell_0_in_cell_1( CMap& amap, typename CMap::Dart_handle adart,
|
|||
* @return A dart incident to the new vertex.
|
||||
*/
|
||||
template < class CMap >
|
||||
typename CMap::Dart_handle
|
||||
CGAL_DEPRECATED 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 )
|
||||
{
|
||||
CGAL_assertion(adart!=amap.null_dart_handle);
|
||||
|
||||
typename CMap::Dart_handle first=adart, prev=amap.null_handle,
|
||||
cur=amap.null_handle, next=amap.null_handle,
|
||||
n1=amap.null_handle, n2=amap.null_handle,
|
||||
nn1=amap.null_handle, nn2=amap.null_handle;
|
||||
|
||||
// If the facet is open, we search the dart 0-free
|
||||
while ( !amap.template is_free<0>(first) &&
|
||||
amap.template beta<0>(first)!=adart )
|
||||
first = amap.template beta<0>(first);
|
||||
|
||||
// Mark used to mark darts already treated.
|
||||
typename CMap::size_type treated = amap.get_new_mark();
|
||||
|
||||
// Stack of marked darts
|
||||
std::deque<typename CMap::Dart_handle> tounmark;
|
||||
|
||||
// Now we run through the facet
|
||||
cur = first;
|
||||
do
|
||||
{
|
||||
next = amap.template beta<1>(cur);
|
||||
amap.mark(cur, treated);
|
||||
tounmark.push_back(cur);
|
||||
|
||||
if (!amap.template is_free<0>(cur))
|
||||
{
|
||||
n1=amap.create_dart();
|
||||
amap.link_beta_0(cur, n1);
|
||||
}
|
||||
else n1 = amap.null_handle;
|
||||
|
||||
if (!amap.template is_free<1>(cur))
|
||||
{
|
||||
n2 = amap.create_dart();
|
||||
amap.link_beta_1(cur, n2);
|
||||
}
|
||||
else n2 = amap.null_handle;
|
||||
|
||||
if ( n1!=amap.null_handle )
|
||||
{
|
||||
if ( n2!=amap.null_handle )
|
||||
amap.basic_link_beta_0(n1, n2);
|
||||
|
||||
if ( prev!=amap.null_handle )
|
||||
amap.template basic_link_beta_for_involution<2>(prev, n1);
|
||||
|
||||
if (amap.are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
|
||||
run(&amap, n1, ah);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !amap.is_free(adart, dim) )
|
||||
{
|
||||
if ( !amap.is_marked(amap.beta(cur, dim), treated) )
|
||||
{
|
||||
if (n1!=amap.null_handle)
|
||||
{
|
||||
nn1=amap.create_dart();
|
||||
amap.link_beta_1(amap.beta(cur, dim), nn1);
|
||||
amap.basic_link_beta_for_involution(n1, nn1, dim);
|
||||
}
|
||||
else nn1=amap.null_handle;
|
||||
|
||||
if (n2!=amap.null_handle)
|
||||
{
|
||||
nn2=amap.create_dart();
|
||||
amap.link_beta_0(amap.beta(cur, dim), nn2);
|
||||
amap.basic_link_beta_for_involution(n2, nn2, dim);
|
||||
if (amap.are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
|
||||
run(&amap, nn2, ah);
|
||||
}
|
||||
}
|
||||
else nn2=amap.null_handle;
|
||||
|
||||
if (nn1 != amap.null_handle && nn2 != amap.null_handle)
|
||||
amap.basic_link_beta_1(nn1, nn2);
|
||||
|
||||
if (nn1 != amap.null_handle && prev != amap.null_handle)
|
||||
amap.template basic_link_beta_for_involution<2>
|
||||
(nn1, amap.beta(prev, dim));
|
||||
|
||||
amap.mark(amap.beta(cur, dim), treated);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( n1!=amap.null_handle )
|
||||
amap.basic_link_beta_for_involution(n1,
|
||||
amap.beta(cur, dim, 1), dim);
|
||||
if ( n2!=amap.null_handle )
|
||||
amap.basic_link_beta_for_involution(n2,
|
||||
amap.beta(cur, dim, 0), dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prev = n2;
|
||||
cur = next;
|
||||
}
|
||||
while(cur!=first && cur!=amap.null_dart_handle);
|
||||
|
||||
if (n2 != amap.null_handle)
|
||||
{
|
||||
amap.template basic_link_beta_for_involution<2>
|
||||
(amap.template beta<0>(first), n2);
|
||||
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !amap.is_free(adart, dim) )
|
||||
{
|
||||
amap.template basic_link_beta_for_involution<2>
|
||||
(amap.beta(first, 0, dim), amap.beta(n2, dim));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now we unmark all marked darts, and we degroup the new faces with the
|
||||
// initial one (if 2-attributes are non void).
|
||||
for ( typename std::deque<typename CMap::Dart_handle>::iterator
|
||||
itd=tounmark.begin(); itd!=tounmark.end(); ++itd )
|
||||
{
|
||||
amap.unmark(*itd, treated);
|
||||
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !amap.is_free(*itd, dim) )
|
||||
amap.unmark(amap.beta(*itd, dim), treated);
|
||||
}
|
||||
if ( *itd!=adart )
|
||||
if (amap.are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
|
||||
run(&amap, adart, *itd);
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_assertion(amap.is_whole_map_unmarked(treated));
|
||||
amap.free_mark(treated);
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( amap.is_valid() );
|
||||
#endif
|
||||
|
||||
return n1;
|
||||
return amap.insert_cell_0_in_cell_2(adart, ah, update_attributes);
|
||||
}
|
||||
/** Insert a dangling edge in a 2-cell between given by a dart.
|
||||
* @param amap the used combinatorial map.
|
||||
|
|
@ -289,100 +72,15 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
|
|||
* @return a dart of the new edge, not incident to the vertex of adart1.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
CGAL_DEPRECATED typename CMap::Dart_handle
|
||||
insert_dangling_cell_1_in_cell_2( CMap& amap,
|
||||
typename CMap::Dart_handle adart1,
|
||||
typename CMap::template
|
||||
Attribute_handle<0>::type ah=CMap::null_handle,
|
||||
bool update_attributes=true )
|
||||
{
|
||||
typename CMap::size_type mark1 = amap.get_new_mark();
|
||||
std::deque<typename CMap::Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<CMap,0> it(amap,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
amap.mark(it,mark1);
|
||||
}
|
||||
}
|
||||
|
||||
typename CMap::Dart_handle d1 = amap.null_handle;
|
||||
typename CMap::Dart_handle d2 = amap.null_handle;
|
||||
unsigned int s1 = 0;
|
||||
|
||||
typename CMap::size_type treated=amap.get_new_mark();
|
||||
|
||||
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1>
|
||||
it1(amap, adart1, treated);
|
||||
|
||||
for ( ; it1.cont(); ++it1)
|
||||
{
|
||||
d1 = amap.create_dart();
|
||||
d2 = amap.create_dart();
|
||||
|
||||
if ( amap.is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !amap.is_free(it1, s1) )
|
||||
{
|
||||
if ( s1==0 )
|
||||
amap.link_beta_1(amap.template beta<0>(it1), d2);
|
||||
else
|
||||
amap.link_beta_0(amap.template beta<1>(it1), d2);
|
||||
}
|
||||
|
||||
if (s1==0)
|
||||
{
|
||||
amap.link_beta_0(it1, d1);
|
||||
amap.link_beta_0(d1, d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
amap.link_beta_1(it1, d1);
|
||||
amap.link_beta_1(d1, d2);
|
||||
}
|
||||
|
||||
amap.template basic_link_beta_for_involution<2>(d1, d2);
|
||||
|
||||
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !amap.is_free(it1, dim) &&
|
||||
amap.is_marked(amap.beta(it1, dim), treated) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution
|
||||
(amap.beta(it1, dim, CGAL_BETAINV(s1)), d1, dim);
|
||||
amap.basic_link_beta_for_involution
|
||||
(amap.beta(it1, dim, CGAL_BETAINV(s1), 2), d2, dim);
|
||||
}
|
||||
}
|
||||
if (amap.are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Set_i_attribute_of_dart_functor<CMap, 0>::
|
||||
run(&amap, d1, ah);
|
||||
}
|
||||
amap.mark(it1, treated);
|
||||
}
|
||||
|
||||
amap.negate_mark(treated);
|
||||
for ( it1.rewind(); it1.cont(); ++it1 )
|
||||
{ amap.mark(it1, treated); }
|
||||
|
||||
CGAL_assertion( amap.is_whole_map_marked(treated) );
|
||||
amap.free_mark(treated);
|
||||
|
||||
for ( typename std::deque<typename CMap::Dart_handle>::iterator
|
||||
it=to_unmark.begin(); it!=to_unmark.end(); ++it)
|
||||
{ amap.unmark(*it, mark1); }
|
||||
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
|
||||
amap.free_mark(mark1);
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( amap.is_valid() );
|
||||
#endif
|
||||
|
||||
return amap.template beta<0>(adart1);
|
||||
return amap.insert_dangling_cell_1_in_cell_2(adart1,
|
||||
ah, update_attributes);
|
||||
}
|
||||
|
||||
/** Test if an edge can be inserted onto a 2-cell between two given darts.
|
||||
|
|
@ -392,17 +90,11 @@ insert_dangling_cell_1_in_cell_2( CMap& amap,
|
|||
* @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)
|
||||
CGAL_DEPRECATED 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 ) return false;
|
||||
for ( CGAL::CMap_dart_const_iterator_of_orbit<CMap,1> it(amap,adart1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
if ( it==adart2 ) return true;
|
||||
}
|
||||
return false;
|
||||
return amap.is_insertable_cell_1_in_cell_2(adart1, adart2);
|
||||
}
|
||||
|
||||
/** Insert an edge in a 2-cell between two given darts.
|
||||
|
|
@ -415,123 +107,14 @@ bool is_insertable_cell_1_in_cell_2(const CMap& amap,
|
|||
* same vertex than adart1.
|
||||
*/
|
||||
template<class CMap>
|
||||
typename CMap::Dart_handle
|
||||
CGAL_DEPRECATED 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 )
|
||||
return insert_dangling_cell_1_in_cell_2(amap,adart1);
|
||||
|
||||
CGAL_assertion(is_insertable_cell_1_in_cell_2<CMap>(amap, adart1, adart2));
|
||||
|
||||
typename CMap::size_type m1=amap.get_new_mark();
|
||||
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it1(amap, adart1, m1);
|
||||
|
||||
typename CMap::size_type m2=amap.get_new_mark();
|
||||
CGAL::CMap_dart_iterator_basic_of_involution<CMap,1> it2(amap, adart2, m2);
|
||||
|
||||
typename CMap::size_type mark1=amap.get_new_mark();
|
||||
std::deque<typename CMap::Dart_handle> to_unmark;
|
||||
{
|
||||
for ( CGAL::CMap_dart_iterator_basic_of_cell<CMap,0> it(amap,adart1,mark1);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_unmark.push_back(it);
|
||||
amap.mark(it, mark1);
|
||||
}
|
||||
}
|
||||
|
||||
typename CMap::Dart_handle d1=amap.null_handle;
|
||||
typename CMap::Dart_handle d2=amap.null_handle;
|
||||
unsigned int s1=0;
|
||||
|
||||
typename CMap::size_type treated=amap.get_new_mark();
|
||||
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
CGAL_assertion (it2.cont() );
|
||||
d1 = amap.create_dart();
|
||||
d2 = amap.create_dart();
|
||||
|
||||
if ( amap.is_marked(it1, mark1) ) s1 = 0;
|
||||
else s1 = 1;
|
||||
|
||||
if ( !amap.is_free(it1, s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.link_beta_1(amap.template beta<0>(it1), d2);
|
||||
else amap.link_beta_0(amap.template beta<1>(it1), d2);
|
||||
}
|
||||
|
||||
if ( !amap.is_free(it2, s1) )
|
||||
{
|
||||
if ( s1==0 ) amap.link_beta_1(amap.template beta<0>(it2), d1);
|
||||
else amap.link_beta_0(amap.template beta<1>(it2), d1);
|
||||
}
|
||||
|
||||
if ( s1==0 )
|
||||
{
|
||||
amap.link_beta_0(it1, d1);
|
||||
amap.link_beta_0(it2, d2);
|
||||
}
|
||||
else
|
||||
{
|
||||
amap.link_beta_1(it1, d1);
|
||||
amap.link_beta_1(it2, d2);
|
||||
}
|
||||
amap.template basic_link_beta_for_involution<2>(d2, d1);
|
||||
|
||||
for ( unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||
{
|
||||
if ( !amap.is_free(it1, dim) &&
|
||||
amap.is_marked(amap.beta(it1, dim), treated) )
|
||||
{
|
||||
amap.basic_link_beta_for_involution
|
||||
(amap.beta(it1, dim, CGAL_BETAINV(s1)), d1, dim);
|
||||
amap.basic_link_beta_for_involution
|
||||
(amap.beta(it1, dim, CGAL_BETAINV(s1), 2), d2, dim);
|
||||
}
|
||||
}
|
||||
|
||||
amap.mark(it1,treated);
|
||||
}
|
||||
|
||||
if (amap.are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::run(&amap, d1, d2);
|
||||
}
|
||||
|
||||
amap.negate_mark(m1);
|
||||
amap.negate_mark(m2);
|
||||
it1.rewind(); it2.rewind();
|
||||
for ( ; it1.cont(); ++it1, ++it2)
|
||||
{
|
||||
amap.mark(it1,m1);
|
||||
amap.unmark(it1,treated);
|
||||
amap.mark(it2,m2);
|
||||
}
|
||||
amap.negate_mark(m1);
|
||||
amap.negate_mark(m2);
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(m1) );
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(m2) );
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(treated) );
|
||||
amap.free_mark(m1);
|
||||
amap.free_mark(m2);
|
||||
amap.free_mark(treated);
|
||||
|
||||
typename std::deque<typename CMap::Dart_handle>::iterator it =
|
||||
to_unmark.begin();
|
||||
for (; it != to_unmark.end(); ++it)
|
||||
{ amap.unmark(*it, mark1); }
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark1) );
|
||||
amap.free_mark(mark1);
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( amap.is_valid() );
|
||||
#endif
|
||||
|
||||
return amap.template beta<0>(adart1);
|
||||
return amap.insert_cell_1_in_cell_2(adart1, adart2,
|
||||
update_attributes);
|
||||
}
|
||||
|
||||
/** Test if a 2-cell can be inserted onto a given 3-cell along
|
||||
|
|
@ -542,44 +125,10 @@ insert_cell_1_in_cell_2(CMap& amap,
|
|||
* @return true iff a 2-cell can be inserted along the path.
|
||||
*/
|
||||
template <class CMap, class InputIterator>
|
||||
bool is_insertable_cell_2_in_cell_3(const CMap& amap,
|
||||
InputIterator afirst,
|
||||
InputIterator alast)
|
||||
CGAL_DEPRECATED 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 || *it==amap.null_dart_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)
|
||||
{
|
||||
od = amap.other_extremity(prec);
|
||||
if ( od==amap.null_handle ) return false;
|
||||
|
||||
// of and *it must belong to the same vertex of the same volume
|
||||
if ( !CGAL::belong_to_same_cell<CMap, 0, 2>(amap, od, *it) )
|
||||
return false;
|
||||
}
|
||||
prec = *it;
|
||||
}
|
||||
|
||||
// The path must be closed.
|
||||
od = amap.other_extremity(prec);
|
||||
if ( od==amap.null_handle ) return false;
|
||||
|
||||
if (!CGAL::belong_to_same_cell<CMap, 0, 2>(amap, od, *afirst))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return amap.is_insertable_cell_2_in_cell_3(afirst, alast);
|
||||
}
|
||||
|
||||
/** Insert a 2-cell in a given 3-cell along a path of darts.
|
||||
|
|
@ -591,139 +140,15 @@ bool is_insertable_cell_2_in_cell_3(const CMap& amap,
|
|||
* @return a dart of the new 2-cell.
|
||||
*/
|
||||
template<class CMap, class InputIterator>
|
||||
typename CMap::Dart_handle
|
||||
CGAL_DEPRECATED typename CMap::Dart_handle
|
||||
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));
|
||||
|
||||
typename CMap::Dart_handle prec = amap.null_handle, d = amap.null_handle,
|
||||
dd = amap.null_handle, first = amap.null_handle;
|
||||
bool withBeta3 = false;
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); !withBeta3 && it!=alast; ++it)
|
||||
{
|
||||
if (!amap.template is_free<2>(*it)) withBeta3 = true;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (InputIterator it(afirst); it!=alast; ++it)
|
||||
{
|
||||
d = amap.create_dart();
|
||||
if ( withBeta3 )
|
||||
dd = amap.create_dart();
|
||||
|
||||
if (prec != amap.null_handle)
|
||||
{
|
||||
amap.basic_link_beta_0(prec, d);
|
||||
if (withBeta3)
|
||||
amap.basic_link_beta_1(amap.template beta<3>(prec), dd);
|
||||
}
|
||||
else first = d;
|
||||
|
||||
if ( !amap.template is_free<2>((*it)) )
|
||||
amap.template basic_link_beta_for_involution<2>
|
||||
(amap.template beta<2>(*it), dd);
|
||||
|
||||
amap.template link_beta_for_involution<2>(*it, d);
|
||||
if ( withBeta3 )
|
||||
amap.template link_beta_for_involution<3>(d, dd);
|
||||
|
||||
prec = d;
|
||||
}
|
||||
}
|
||||
|
||||
amap.basic_link_beta_0(prec, first);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
amap.basic_link_beta_1(amap.template beta<3>(prec),
|
||||
amap.template beta<3>(first));
|
||||
}
|
||||
|
||||
// Make copies of the new facet for dimension >=4
|
||||
for ( unsigned int dim=4; dim<=CMap::dimension; ++dim )
|
||||
{
|
||||
if ( !amap.is_free(first, dim) )
|
||||
{
|
||||
typename CMap::Dart_handle first2 = amap.null_handle;
|
||||
prec = amap.null_handle;
|
||||
for ( CMap_dart_iterator_basic_of_orbit<CMap, 1> it(amap, first);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
d = amap.create_dart();
|
||||
amap.basic_link_beta_for_involution(amap.template beta<2>(it), d, dim);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
dd = amap.create_dart();
|
||||
amap.basic_link_beta_for_involution
|
||||
(amap.template beta<2,3>(it), dd, dim);
|
||||
amap.template basic_link_beta_for_involution<3>(d, dd);
|
||||
}
|
||||
if ( prec!=amap.null_handle )
|
||||
{
|
||||
amap.link_beta_0(prec, d);
|
||||
if ( withBeta3 )
|
||||
{
|
||||
amap.basic_link_beta_1(amap.template beta<3>(prec), dd);
|
||||
}
|
||||
}
|
||||
else first2 = prec;
|
||||
|
||||
// We consider dim2=2 out of the loop to use link_beta instead of
|
||||
// basic _link_beta (to modify non void attributes only once).
|
||||
if ( !amap.template is_free<2>(it) &&
|
||||
amap.is_free(amap.template beta<2>(it), dim) )
|
||||
amap.template link_beta_for_involution<2>
|
||||
(amap.beta(it,2,dim), d);
|
||||
if ( withBeta3 &&
|
||||
!amap.template is_free<2>(amap.template beta<3>(it)) &&
|
||||
amap.is_free(amap.template beta<3,2>(it), dim) )
|
||||
amap.template link_beta_for_involution<2>(amap.beta(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.beta(it, dim2), dim) )
|
||||
amap.basic_link_beta_for_involution(amap.beta(it, dim2, dim),
|
||||
d, dim2);
|
||||
if ( withBeta3 && !amap.is_free(amap.template beta<3>(it), dim2) &&
|
||||
amap.is_free(amap.beta(it, 3, dim2), dim) )
|
||||
amap.basic_link_beta_for_involution
|
||||
(amap.beta(it, 3, dim2, dim), dd, dim2);
|
||||
}
|
||||
}
|
||||
prec = d;
|
||||
}
|
||||
amap.basic_link_beta_0( prec, first2 );
|
||||
if ( withBeta3 )
|
||||
{
|
||||
amap.basic_link_beta_1( amap.template beta<3>(prec),
|
||||
amap.template beta<3>(first2) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Degroup the attributes
|
||||
if ( withBeta3 )
|
||||
{ // Here we cannot use Degroup_attribute_functor_run as new darts do not
|
||||
// have their 3-attribute
|
||||
if (amap.are_attributes_automatically_managed() && update_attributes)
|
||||
{
|
||||
CGAL::internal::Degroup_attribute_functor_run<CMap, 3>::
|
||||
run(&amap, first, amap.template beta<3>(first));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CGAL_CMAP_TEST_VALID_INSERTIONS
|
||||
CGAL_assertion( amap.is_valid() );
|
||||
#endif
|
||||
|
||||
return first;
|
||||
return amap.insert_cell_2_in_cell_3(afirst, alast, update_attributes);
|
||||
}
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_COMBINATORIAL_MAP_INSERTIONS_H
|
||||
|
|
|
|||
|
|
@ -74,10 +74,13 @@ namespace CGAL
|
|||
* @param adart a dart of the i-cell.
|
||||
* @return true iff the i-cell can be removed.
|
||||
*/
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
template < class CMap, unsigned int i >
|
||||
bool is_removable(const CMap& amap, typename CMap::Dart_const_handle adart)
|
||||
CGAL_DEPRECATED bool is_removable(const CMap& amap,
|
||||
typename CMap::Dart_const_handle adart)
|
||||
{ return CGAL::Is_removable_functor<CMap, i>::run(amap,adart); }
|
||||
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
/** Remove an i-cell, 0<i<dimension, and merge eventually both incident
|
||||
* (i+1)-cells.
|
||||
* @param amap the used combinatorial map.
|
||||
|
|
@ -89,10 +92,11 @@ namespace CGAL
|
|||
template<class CMap, unsigned int i, unsigned int nmi>
|
||||
struct Remove_cell_functor
|
||||
{
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart, bool update_attributes)
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart,
|
||||
bool update_attributes)
|
||||
{
|
||||
CGAL_static_assertion ( 1<=i && i<CMap::dimension );
|
||||
CGAL_assertion( (is_removable<CMap,i>(amap, adart)) );
|
||||
CGAL_assertion( (amap.is_removable<i>(adart)) );
|
||||
|
||||
size_t res = 0;
|
||||
|
||||
|
|
@ -278,7 +282,8 @@ namespace CGAL
|
|||
template<class CMap,unsigned int i>
|
||||
struct Remove_cell_functor<CMap,i,0>
|
||||
{
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart, bool update_attributes)
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart,
|
||||
bool update_attributes)
|
||||
{
|
||||
typename CMap::size_type mark = amap.get_new_mark();
|
||||
std::deque<typename CMap::Dart_handle> to_erase;
|
||||
|
|
@ -348,7 +353,7 @@ namespace CGAL
|
|||
static size_t run(CMap& amap, typename CMap::Dart_handle adart,
|
||||
bool update_attributes)
|
||||
{
|
||||
CGAL_assertion( (is_removable<CMap,0>(amap,adart)) );
|
||||
CGAL_assertion( (amap.is_removable<0>(adart)) );
|
||||
|
||||
size_t res = 0;
|
||||
|
||||
|
|
@ -470,12 +475,15 @@ namespace CGAL
|
|||
* @param update_attributes a boolean to update the enabled attributes
|
||||
* @return the number of deleted darts.
|
||||
*/
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
template < class CMap, unsigned int i >
|
||||
size_t remove_cell(CMap& amap, typename CMap::Dart_handle adart, bool update_attributes = true)
|
||||
CGAL_DEPRECATED size_t remove_cell(CMap& amap, typename CMap::Dart_handle adart,
|
||||
bool update_attributes = true)
|
||||
{
|
||||
return
|
||||
CGAL::Remove_cell_functor<CMap,i,CMap::dimension-i>::run(amap,adart,update_attributes);
|
||||
return CGAL::Remove_cell_functor<CMap,i,CMap::dimension-i>::
|
||||
run(amap,adart,update_attributes);
|
||||
}
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
/** Test if an i-cell can be contracted.
|
||||
* An i-cell can be contracted if i==1
|
||||
|
|
@ -533,7 +541,8 @@ namespace CGAL
|
|||
template<class CMap, unsigned int i>
|
||||
struct Contract_cell_functor
|
||||
{
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart)
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart,
|
||||
bool update_attributes)
|
||||
{
|
||||
CGAL_static_assertion ( 2<=i && i<=CMap::dimension );
|
||||
CGAL_assertion( (is_contractible<CMap,i>(amap, adart)) );
|
||||
|
|
@ -560,7 +569,7 @@ namespace CGAL
|
|||
++res;
|
||||
}
|
||||
|
||||
if ( amap.are_attributes_automatically_managed() )
|
||||
if ( amap.are_attributes_automatically_managed() && update_attributes )
|
||||
{
|
||||
// We group the two (i+1)-cells incident if they exist.
|
||||
if ( dg1!=amap.null_handle )
|
||||
|
|
@ -643,7 +652,7 @@ namespace CGAL
|
|||
}
|
||||
}
|
||||
|
||||
if ( amap.are_attributes_automatically_managed() )
|
||||
if ( amap.are_attributes_automatically_managed() && update_attributes )
|
||||
{
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
|
|
@ -689,7 +698,8 @@ namespace CGAL
|
|||
template<class CMap>
|
||||
struct Contract_cell_functor<CMap,1>
|
||||
{
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart)
|
||||
static size_t run(CMap& amap, typename CMap::Dart_handle adart,
|
||||
bool update_attributes)
|
||||
{
|
||||
CGAL_assertion( (is_contractible<CMap,1>(amap,adart)) );
|
||||
|
||||
|
|
@ -713,7 +723,7 @@ namespace CGAL
|
|||
++res;
|
||||
}
|
||||
|
||||
if ( amap.are_attributes_automatically_managed() )
|
||||
if ( amap.are_attributes_automatically_managed() && update_attributes )
|
||||
{
|
||||
// We group the two vertices incident if they exist.
|
||||
if ( dg1!=amap.null_handle )
|
||||
|
|
@ -740,7 +750,7 @@ namespace CGAL
|
|||
{
|
||||
/*modified_darts2.push_back((*it)->template beta<0>());
|
||||
if ( (*it)->beta(0)!=(*it)->beta(1) )*/
|
||||
if ( amap.are_attributes_automatically_managed() )
|
||||
if ( amap.are_attributes_automatically_managed() && update_attributes )
|
||||
{
|
||||
modified_darts.push_back(amap.template beta<1>(*it));
|
||||
}
|
||||
|
|
@ -750,7 +760,7 @@ namespace CGAL
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( amap.are_attributes_automatically_managed() )
|
||||
if ( amap.are_attributes_automatically_managed() && update_attributes )
|
||||
{
|
||||
modified_darts2.push_back(amap.template beta<0>(*it));
|
||||
}
|
||||
|
|
@ -761,7 +771,7 @@ namespace CGAL
|
|||
{
|
||||
if ( !amap.template is_free<1>(*it) )
|
||||
{
|
||||
if ( amap.are_attributes_automatically_managed() )
|
||||
if ( amap.are_attributes_automatically_managed() && update_attributes )
|
||||
{
|
||||
modified_darts.push_back(amap.template beta<1>(*it));
|
||||
}
|
||||
|
|
@ -777,7 +787,7 @@ namespace CGAL
|
|||
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
|
||||
amap.free_mark(mark);
|
||||
|
||||
if ( amap.are_attributes_automatically_managed() )
|
||||
if ( amap.are_attributes_automatically_managed() && update_attributes )
|
||||
{
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
|
|
@ -799,9 +809,12 @@ namespace CGAL
|
|||
* @param adart a dart of the i-cell to remove.
|
||||
* @return the number of deleted darts.
|
||||
*/
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
template < class CMap, unsigned int i >
|
||||
size_t contract_cell(CMap& amap, typename CMap::Dart_handle adart)
|
||||
{ return CGAL::Contract_cell_functor<CMap,i>::run(amap,adart); }
|
||||
CGAL_DEPRECATED size_t contract_cell(CMap& amap, typename CMap::Dart_handle adart,
|
||||
bool update_attributes)
|
||||
{ return CGAL::Contract_cell_functor<CMap,i>::run(amap,adart, update_attributes); }
|
||||
#endif // CGAL_NO_DEPRECATED_CODE
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue