diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index 5b213ab0dd3..5f19046b29c 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -220,7 +220,7 @@ namespace CGAL { CGAL_assertion( (is_removable(amap, adart)) ); typename Map::Dart_handle d1, d2; - int mark = amap.get_new_mark(); + int mark = amap.get_new_mark(); std::deque to_erase; const int iinv = CGAL_BETAINV(i); @@ -229,12 +229,14 @@ namespace CGAL { std::deque > incident_cells[Map::Helper::nb_attribs]; + // Marks used to mark all the incident cells. for (int j=0; j 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::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(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 >:: run(&amap, &mark_for_incident_cells[0], &incident_cells[0]); + // We free the marks. for (int j=0; j to_erase; + std::deque 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 Dart_pair; - std::stack todegroup; + std::deque todegroup; + + int mark_for_incident_cells[Map::Helper::nb_attribs]; + std::deque > + incident_cells[Map::Helper::nb_attribs]; + + // Marks used to mark all the incident cells. + for (int j=0; j::iterator + typename std::deque::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 + >:: + 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 + >:: + run(&amap, &mark_for_incident_cells[0], + &incident_cells[0]); + + // We free the marks. + for (int j=0; j - Dart_pair; - std::stack 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 to_erase; + int mark = amap.get_new_mark(); + std::deque to_erase; - // 2) We mark all the darts of the vertex. + int mark_for_incident_cells[Map::Helper::nb_attribs]; + std::deque > + incident_cells[Map::Helper::nb_attribs]; + + // Marks used to mark all the incident cells. + for (int j=0; j 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::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 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::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 + >:: + 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 + >:: + 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 + >:: + run(&amap, &mark_for_incident_cells[0], + &incident_cells[0]); + + // We free the marks. + for (int j=0; j