diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index 084e53bbcae..709ebbeaec0 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -225,7 +225,7 @@ namespace CGAL { const int iinv = CGAL_BETAINV(i); - int mark_for_incident_cells[Map::Helper::nb_attribs]; +/* int mark_for_incident_cells[Map::Helper::nb_attribs]; std::deque > incident_cells[Map::Helper::nb_attribs]; @@ -234,7 +234,7 @@ namespace CGAL { { 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; @@ -252,7 +252,7 @@ namespace CGAL { // the operation. typename std::deque::iterator it = to_erase.begin(); - for (; it != to_erase.end(); ++it) + /* for (; it != to_erase.end(); ++it) { d1 = (*it)->beta(iinv); while ( d1!=Map::null_dart_handle && amap.is_marked(d1, mark) ) @@ -318,11 +318,14 @@ namespace CGAL { // Required to process cells non consider in the cases above. amap.update_dart_of_all_attributes(*it, mark); - } + }*/ // We group the two (i+1)-cells incident if they exist. - if ( dg1!=NULL ) - amap.template group_attribute(dg1, dg2); + // TODO GROUP BEFORE TO MODIFY +/* if ( dg1!=NULL ) + amap.template group_attribute(dg1, dg2);*/ + + std::deque modified_darts; // For each dart of the i-cell, we modify i-links of neighbors. for ( it=to_erase.begin(); it != to_erase.end(); ++it) @@ -349,10 +352,15 @@ namespace CGAL { { d1->basic_link_beta(d2, i); if ( i==1 ) d2->basic_link_beta(d1, 0); + modified_darts.push_back(d1); } else { - if ( !d1->is_free(i) ) d1->unlink_beta(i); + if ( !d1->is_free(i) ) + { + d1->unlink_beta(i); + modified_darts.push_back(d1); + } } } else if (d2 != Map::null_dart_handle) @@ -360,6 +368,7 @@ namespace CGAL { if ( !d2->is_free(iinv) ) { d2->unlink_beta(iinv); + modified_darts.push_back(d2); } } if ((*it)->is_free(i+1) && !(*it)->is_free(i)) @@ -368,6 +377,7 @@ namespace CGAL { if ( !d1->is_free(iinv) ) { d1->unlink_beta(iinv); + modified_darts.push_back(d1); } } } @@ -375,9 +385,10 @@ namespace CGAL { // 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]); + >:: + run(&amap, &modified_darts); + //&mark_for_incident_cells[0], + //&incident_cells[0]); // We remove all the darts of the i-cell. for ( it=to_erase.begin(); it!=to_erase.end(); ++it ) @@ -387,13 +398,13 @@ namespace CGAL { amap.free_mark(mark); // We free the marks. - for (int j=0; j #include #include +#include namespace CGAL { namespace internal { @@ -620,6 +621,96 @@ namespace CGAL { } }; + template + struct Test2_split_with_deque + { + template + static void run( Map* amap, + std::deque + *modified_darts ) + { + if ( i==j ) return; + + CGAL_assertion( amap!=NULL ); + + int nbofjcell = 0; + typename Map::Helper::template Attribute_handle::type + a1 = NULL; + typename Map::Helper::template Attribute_handle::type + a2=NULL; + + std::set::type> found_attributes; + + int mark = amap->get_new_mark(); + + for ( typename std::deque:: + iterator it=modified_darts->begin(); + it!=modified_darts->end(); ++it ) + { + if ( (*it)->template attribute()!=NULL && + !amap->is_marked(*it, mark) ) + { + a1 = (*it)->template attribute(); + if ( found_attributes.insert(a1).second ) + { // Here the attribute was not in the set as we are able + // to insert it. + a2 = amap->template create_attribute(*a1); + // std::cout<<"A2 "<<&*a2<<" "<<&**itj<<": "; + + for ( CMap_dart_iterator_basic_of_cell + itj(*amap, *it, mark); + itj.cont(); ++itj ) + { + // std::cout<<&*itj<<", "; + amap->template set_attribute_of_dart(itj, a2); + amap->mark(itj, mark); + } + + Apply_cell_functor + ::type, + typename Map::Helper::template Attribute_type::type:: + On_split>::run(*a1, *a2); + } + else + { // Here the attribute was already present in the set + a1->set_dart(*it); + // std::cout<<"A1 "<<&*a1<<" "<<&**itj<<": "; + + for ( CMap_dart_iterator_basic_of_cell + itj(*amap, *it, mark); + itj.cont(); ++itj ) + { + // std::cout<<&*itj<<", "; + CGAL_assertion( itj->template attribute()==a1 ); + amap->mark(itj, mark); + } + } + // std::cout<negate_mark(mark); + + for ( typename std::deque:: + iterator it=modified_darts->begin(); + it!=modified_darts->end(); ++it ) + { + if ( !amap->is_marked(*it, mark) ) + for ( CMap_dart_iterator_basic_of_cell + itj(*amap, *it, mark); + itj.cont(); ++itj ) + { + amap->mark(itj, mark); + } + } + + CGAL_assertion( amap->is_whole_map_marked(mark) ); + amap->free_mark(mark); + } + }; + } // namespace internal } // namespace CGAL