mirror of https://github.com/CGAL/cgal
Split for removal, special cases.
This commit is contained in:
parent
e7049ef7e6
commit
18aa10a293
|
|
@ -220,7 +220,7 @@ namespace CGAL {
|
|||
CGAL_assertion( (is_removable<Map,i>(amap, adart)) );
|
||||
|
||||
typename Map::Dart_handle d1, d2;
|
||||
int mark = amap.get_new_mark();
|
||||
int mark = amap.get_new_mark();
|
||||
std::deque<typename Map::Dart_handle> to_erase;
|
||||
|
||||
const int iinv = CGAL_BETAINV(i);
|
||||
|
|
@ -229,12 +229,14 @@ namespace CGAL {
|
|||
std::deque<std::deque<typename Map::Dart_handle> >
|
||||
incident_cells[Map::Helper::nb_attribs];
|
||||
|
||||
// Marks used to mark all the incident cells.
|
||||
for (int j=0; j<Map::Helper::nb_attribs; ++j)
|
||||
{
|
||||
mark_for_incident_cells [j] = amap.get_new_mark();
|
||||
CGAL_assertion( mark_for_incident_cells [j]!=-1 );
|
||||
}
|
||||
|
||||
// First we store and mark all the darts of the i-cell to remove.
|
||||
size_t res = 0;
|
||||
for ( CMap_dart_iterator_basic_of_cell<Map,i> it(amap,adart,mark);
|
||||
it.cont(); ++it )
|
||||
|
|
@ -246,6 +248,8 @@ namespace CGAL {
|
|||
|
||||
typename Map::Dart_handle dg1=NULL, dg2=NULL;
|
||||
|
||||
// Second we store all the incident cells that can be split by
|
||||
// the operation.
|
||||
typename std::deque<typename Map::Dart_handle>::iterator it =
|
||||
to_erase.begin();
|
||||
for (; it != to_erase.end(); ++it)
|
||||
|
|
@ -264,8 +268,6 @@ namespace CGAL {
|
|||
if ( d2==(*it)->beta(i+1)->beta(i) ) d2=Map::null_dart_handle;
|
||||
}
|
||||
|
||||
// TODO ? We can optimize by using map.basic_link_beta but we
|
||||
// need to mark the second dart to not process another time...
|
||||
if (d1 != Map::null_dart_handle)
|
||||
{
|
||||
if (d2 != Map::null_dart_handle)
|
||||
|
|
@ -309,11 +311,11 @@ namespace CGAL {
|
|||
amap.update_dart_of_all_attributes(*it, mark);
|
||||
}
|
||||
|
||||
// 2) We group the two (i+1)-cells if they exist.
|
||||
// We group the two (i+1)-cells incident if they exist.
|
||||
if ( dg1!=NULL )
|
||||
amap.template group_attribute<i+1>(dg1, dg2);
|
||||
|
||||
// 4) For each dart of the cell, we modify i-link of neighbors.
|
||||
// For each dart of the i-cell, we modify i-links of neighbors.
|
||||
for ( it=to_erase.begin(); it != to_erase.end(); ++it)
|
||||
{
|
||||
d1 = (*it)->beta_inv(i);
|
||||
|
|
@ -361,18 +363,21 @@ namespace CGAL {
|
|||
}
|
||||
}
|
||||
|
||||
// 6) We remove all the darts of the cell.
|
||||
// We remove all the darts of the i-cell.
|
||||
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
|
||||
{ amap.erase_dart(*it); }
|
||||
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
|
||||
amap.free_mark(mark);
|
||||
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
Map::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test_split_with_deque<Map,i> >::
|
||||
run(&amap, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
|
||||
// We free the marks.
|
||||
for (int j=0; j<Map::Helper::nb_attribs; ++j)
|
||||
{
|
||||
CGAL_assertion( amap.is_whole_map_marked
|
||||
|
|
@ -380,7 +385,7 @@ namespace CGAL {
|
|||
amap.free_mark( mark_for_incident_cells [j] );
|
||||
}
|
||||
|
||||
// CGAL_postcondition(amap.is_valid());
|
||||
CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -398,14 +403,25 @@ namespace CGAL {
|
|||
{
|
||||
CGAL_assertion( adart!=NULL );
|
||||
|
||||
std::vector<typename Map::Dart_handle> to_erase;
|
||||
std::deque<typename Map::Dart_handle> to_erase;
|
||||
int mark = amap.get_new_mark();
|
||||
size_t res = 0;
|
||||
|
||||
// Stack of couple of dart for which we must call degroup_all_attributes
|
||||
typedef std::pair<typename Map::Dart_handle, typename Map::Dart_handle>
|
||||
Dart_pair;
|
||||
std::stack<Dart_pair> todegroup;
|
||||
std::deque<Dart_pair> todegroup;
|
||||
|
||||
int mark_for_incident_cells[Map::Helper::nb_attribs];
|
||||
std::deque<std::deque<typename Map::Dart_handle> >
|
||||
incident_cells[Map::Helper::nb_attribs];
|
||||
|
||||
// Marks used to mark all the incident cells.
|
||||
for (int j=0; j<Map::Helper::nb_attribs; ++j)
|
||||
{
|
||||
mark_for_incident_cells [j] = amap.get_new_mark();
|
||||
CGAL_assertion( mark_for_incident_cells [j]!=-1 );
|
||||
}
|
||||
|
||||
// 1) We mark all the darts of the d-cell.
|
||||
{
|
||||
|
|
@ -418,38 +434,55 @@ namespace CGAL {
|
|||
}
|
||||
}
|
||||
|
||||
// 2) We update the cells incident to the remove volume.
|
||||
typename std::vector<typename Map::Dart_handle>::iterator
|
||||
typename std::deque<typename Map::Dart_handle>::iterator
|
||||
it = to_erase.begin();
|
||||
for (; it != to_erase.end(); ++it)
|
||||
{ amap.update_dart_of_all_attributes(*it, mark); }
|
||||
|
||||
// 2) We store all the incident cells that can be split by the operation,
|
||||
// and we update the dart of the cells incident to the remove volume.
|
||||
for ( ; it != to_erase.end(); ++it )
|
||||
{
|
||||
if ( !(*it)->is_free(Map::dimension) )
|
||||
{
|
||||
Map::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<Map,i> >::
|
||||
run(&amap, *it, mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
}
|
||||
amap.update_dart_of_all_attributes(*it, mark);
|
||||
}
|
||||
|
||||
// 3) We unlink all the darts of the volume for beta-d.
|
||||
for ( it = to_erase.begin(); it != to_erase.end(); ++it )
|
||||
{
|
||||
if ( !(*it)->is_free(Map::dimension) )
|
||||
{
|
||||
todegroup.push(Dart_pair(*it, (*it)->beta(Map::dimension)));
|
||||
amap.unlink_beta_for_involution(*it,Map::dimension);
|
||||
}
|
||||
}
|
||||
|
||||
// 4) We degroup all the pairs
|
||||
while ( !todegroup.empty() )
|
||||
{
|
||||
Dart_pair & p=todegroup.top();
|
||||
amap.degroup_all_attributes(p.first,p.second);
|
||||
todegroup.pop();
|
||||
}
|
||||
|
||||
// 5) last, we remove all the darts of the d-cell.
|
||||
// 4) We remove all the darts of the d-cell.
|
||||
for ( it = to_erase.begin(); it != to_erase.end(); ++it )
|
||||
{ amap.erase_dart(*it); }
|
||||
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
|
||||
amap.free_mark(mark);
|
||||
|
||||
//CGAL_postcondition(amap.is_valid());
|
||||
// 5) We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
Map::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test_split_with_deque<Map,i> >::
|
||||
run(&amap, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
|
||||
// We free the marks.
|
||||
for (int j=0; j<Map::Helper::nb_attribs; ++j)
|
||||
{
|
||||
CGAL_assertion( amap.is_whole_map_marked
|
||||
(mark_for_incident_cells [j]) );
|
||||
amap.free_mark( mark_for_incident_cells [j] );
|
||||
}
|
||||
|
||||
CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -469,39 +502,87 @@ namespace CGAL {
|
|||
|
||||
size_t res = 0;
|
||||
|
||||
// Stack of couple of dart for which we must call degroup_all_attributes
|
||||
typedef std::pair<typename Map::Dart_handle, typename Map::Dart_handle>
|
||||
Dart_pair;
|
||||
std::stack<Dart_pair> todegroup;
|
||||
|
||||
// 1) We group the two edges if they exist.
|
||||
if (!adart->is_free(0))
|
||||
amap.template group_attribute<1>(adart, adart->beta(0));
|
||||
|
||||
typename Map::Dart_handle d1, d2;
|
||||
int mark = amap.get_new_mark();
|
||||
std::vector<typename Map::Dart_handle> to_erase;
|
||||
int mark = amap.get_new_mark();
|
||||
std::deque<typename Map::Dart_handle> to_erase;
|
||||
|
||||
// 2) We mark all the darts of the vertex.
|
||||
int mark_for_incident_cells[Map::Helper::nb_attribs];
|
||||
std::deque<std::deque<typename Map::Dart_handle> >
|
||||
incident_cells[Map::Helper::nb_attribs];
|
||||
|
||||
// Marks used to mark all the incident cells.
|
||||
for (int j=0; j<Map::Helper::nb_attribs; ++j)
|
||||
{
|
||||
for ( CMap_dart_iterator_basic_of_cell<Map,0> it(amap,adart,mark);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_erase.push_back(it);
|
||||
amap.mark(it,mark);
|
||||
++res;
|
||||
}
|
||||
mark_for_incident_cells [j] = amap.get_new_mark();
|
||||
CGAL_assertion( mark_for_incident_cells [j]!=-1 );
|
||||
}
|
||||
|
||||
// 3) We modify the darts of the cells incident to the vertex
|
||||
// when they are marked to remove.
|
||||
typename std::vector<typename Map::Dart_handle>::iterator
|
||||
it = to_erase.begin();
|
||||
for (; it != to_erase.end(); ++it)
|
||||
{ amap.update_dart_of_all_attributes(*it, mark); }
|
||||
// First we store and mark all the darts of the 0-cell to remove.
|
||||
for ( CMap_dart_iterator_basic_of_cell<Map,0> it(amap,adart,mark);
|
||||
it.cont(); ++it )
|
||||
{
|
||||
to_erase.push_back(it);
|
||||
amap.mark(it, mark);
|
||||
++res;
|
||||
}
|
||||
|
||||
// 4) For each dart of the cell, we modify link of neighbors.
|
||||
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
|
||||
typename Map::Dart_handle dg1=NULL, dg2=NULL;
|
||||
|
||||
// Second we store all the incident cells that can be split by
|
||||
// the operation.
|
||||
typename std::deque<typename Map::Dart_handle>::iterator it =
|
||||
to_erase.begin();
|
||||
for (; it != to_erase.end(); ++it)
|
||||
{
|
||||
if ( !(*it)->is_free(0) )
|
||||
{
|
||||
if ( !(*it)->is_free(1) && (*it)->beta(0)!=(*it) )
|
||||
amap.template basic_link_beta<1>((*it)->beta(0), (*it)->beta(1));
|
||||
else
|
||||
{
|
||||
Map::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<Map,0> >::
|
||||
run(&amap, *it, mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
// todegroup.push(Dart_pair((*it)->beta(0), *it));
|
||||
// (*it)->beta(0)->unlink_beta(1);
|
||||
}
|
||||
|
||||
/* for ( unsigned int j=2; j<=Map::dimension; ++j )
|
||||
{
|
||||
if ( !(*it)->is_free(j) )
|
||||
amap.basic_link_beta((*it)->beta(0), (*it)->beta(j), j);
|
||||
//((*it)->beta(0))->basic_link_beta((*it)->beta(j),j);
|
||||
} */
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !(*it)->is_free(1) )
|
||||
{
|
||||
Map::Helper::template Foreach_enabled_attributes
|
||||
<internal::Store_incident_cells<Map,0> >::
|
||||
run(&amap, (*it)->beta(1), mark, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
//todegroup.push(Dart_pair((*it)->beta(1), *it));
|
||||
//(*it)->beta(1)->unlink_beta(0);
|
||||
}
|
||||
|
||||
/* for ( unsigned int j=2; j<=Map::dimension; ++j )
|
||||
{
|
||||
if ( !(*it)->is_free(j) )
|
||||
amap.unlink_beta(*it, j);
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
// We group the two edges incident if they exist.
|
||||
if ( dg1!=NULL )
|
||||
amap.template group_attribute<1>(dg1, dg2);
|
||||
//if (!adart->is_free(0))
|
||||
// amap.template group_attribute<1>(adart, adart->beta(0));
|
||||
|
||||
// For each dart of the vertex, we modify 0 and 1-links of neighbors.
|
||||
for ( it=to_erase.begin(); it != to_erase.end(); ++it)
|
||||
{
|
||||
if ( !(*it)->is_free(0) )
|
||||
{
|
||||
|
|
@ -509,7 +590,6 @@ namespace CGAL {
|
|||
amap.template basic_link_beta<1>((*it)->beta(0), (*it)->beta(1));
|
||||
else
|
||||
{
|
||||
todegroup.push(Dart_pair((*it)->beta(0), *it));
|
||||
(*it)->beta(0)->unlink_beta(1);
|
||||
}
|
||||
|
||||
|
|
@ -524,7 +604,6 @@ namespace CGAL {
|
|||
{
|
||||
if ( !(*it)->is_free(1) )
|
||||
{
|
||||
todegroup.push(Dart_pair((*it)->beta(1), *it));
|
||||
(*it)->beta(1)->unlink_beta(0);
|
||||
}
|
||||
|
||||
|
|
@ -536,22 +615,29 @@ namespace CGAL {
|
|||
}
|
||||
}
|
||||
|
||||
// 5) We degroup all the pairs
|
||||
while ( !todegroup.empty() )
|
||||
{
|
||||
Dart_pair & p=todegroup.top();
|
||||
amap.degroup_all_attributes(p.first,p.second);
|
||||
todegroup.pop();
|
||||
}
|
||||
|
||||
// 6) We remove all the darts of the cell.
|
||||
for (it = to_erase.begin(); it != to_erase.end(); ++it)
|
||||
// We remove all the darts of the i-cell.
|
||||
for ( it=to_erase.begin(); it!=to_erase.end(); ++it )
|
||||
{ amap.erase_dart(*it); }
|
||||
|
||||
CGAL_assertion( amap.is_whole_map_unmarked(mark) );
|
||||
amap.free_mark(mark);
|
||||
|
||||
// CGAL_postcondition( amap.is_valid() );
|
||||
// We test the split of all the incident cells for all the non
|
||||
// void attributes.
|
||||
Map::Helper::template Foreach_enabled_attributes
|
||||
<internal::Test_split_with_deque<Map,0> >::
|
||||
run(&amap, &mark_for_incident_cells[0],
|
||||
&incident_cells[0]);
|
||||
|
||||
// We free the marks.
|
||||
for (int j=0; j<Map::Helper::nb_attribs; ++j)
|
||||
{
|
||||
CGAL_assertion( amap.is_whole_map_marked
|
||||
(mark_for_incident_cells [j]) );
|
||||
amap.free_mark( mark_for_incident_cells [j] );
|
||||
}
|
||||
|
||||
CGAL_expensive_postcondition( amap.is_valid() );
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue