diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map.h b/Combinatorial_map/include/CGAL/Combinatorial_map.h index 967638fec29..ecaa92b0c0f 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map.h @@ -1693,6 +1693,7 @@ namespace CGAL { int m=get_new_mark(); std::deque dartv; std::deque modified_darts; + std::deque modified_darts2; for ( CMap_dart_iterator_basic_of_cell it(*this, adart, m); it.cont(); ++it) @@ -1707,12 +1708,12 @@ namespace CGAL { if ( is_marked(it, m) ) { modified_darts.push_back(it); - modified_darts.push_back(it->template beta<0>()); + modified_darts2.push_back(it->template beta<0>()); unlink_beta_0(it); } else { - modified_darts.push_back(it); + modified_darts2.push_back(it); modified_darts.push_back(it->template beta<1>()); unlink_beta_1(it); } @@ -1725,12 +1726,11 @@ namespace CGAL { CGAL_assertion( is_whole_map_unmarked(m) ); free_mark(m); - // TODO pass the mark m to know which dart is modified by b0 of b1 // We test the split of all the incident cells for all the non // void attributes. Helper::template Foreach_enabled_attributes_except , 1>:: - run(this, &modified_darts); + run(this, modified_darts, modified_darts2); } /** Unsew by beta1 the given dart plus all the required darts @@ -1748,6 +1748,7 @@ namespace CGAL { int m = get_new_mark(); std::deque dartv; std::deque modified_darts; + std::deque modified_darts2; for ( CMap_dart_iterator_basic_of_cell it(*this,adart,m); it.cont(); ++it) @@ -1761,14 +1762,14 @@ namespace CGAL { { if ( is_marked(it, m) ) { - modified_darts.push_back(it); + modified_darts2.push_back(it); modified_darts.push_back(it->template beta<1>()); unlink_beta_1(it); } else { modified_darts.push_back(it); - modified_darts.push_back(it->template beta<0>()); + modified_darts2.push_back(it->template beta<0>()); unlink_beta_0(it); } } @@ -1784,7 +1785,7 @@ namespace CGAL { // void attributes. Helper::template Foreach_enabled_attributes_except , 1>:: - run(this, &modified_darts); + run(this, modified_darts, modified_darts2); } /** Unsew by betai the given dart plus all the required darts @@ -1816,7 +1817,7 @@ namespace CGAL { // void attributes. Helper::template Foreach_enabled_attributes_except , i>:: - run(this, &modified_darts); + run(this, modified_darts); } /** Unsew by betai the given dart plus all the required darts diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h index 2fb52811ac2..67e14648dfd 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_insertions.h @@ -48,7 +48,7 @@ insert_cell_0_in_cell_1(CMap& amap, typename CMap::Dart_handle adart) } } - amap.template link_beta_1(*it, d1); + amap.link_beta_1(*it, d1); // TODO remove this group, and use link_beta instead ? //amap.group_all_dart_attributes_except(*it, d1, 1); diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index d61669525ed..05632564998 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -104,13 +104,14 @@ namespace CGAL { // the operation. typename std::deque::iterator it = to_erase.begin(); + //TODO remove ? or be sure that this is required for (; it != to_erase.end(); ++it) amap.update_dart_of_all_attributes(*it, mark); 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) + for ( it=to_erase.begin(); it!=to_erase.end(); ++it ) { d1=(*it)->template beta(); while ( d1!=CMap::null_dart_handle && amap.is_marked(d1, mark) ) @@ -141,6 +142,7 @@ namespace CGAL { amap.mark(d2, mark_modified_darts); modified_darts.push_back(d1); modified_darts.push_back(d2); + // TODO push only one out of two dart ? /*if ( i==1 ) { d2->basic_link_beta(d1, 0); @@ -150,9 +152,9 @@ namespace CGAL { } else { - if ( !d1->is_free(i) ) + if ( !d1->template is_free() ) { - d1->unlink_beta(i); + d1->template unlink_beta(); CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) ); amap.mark(d1, mark_modified_darts); modified_darts.push_back(d1); @@ -161,9 +163,9 @@ namespace CGAL { } else if ( d2!=CMap::null_dart_handle ) { - if ( !d2->is_free(iinv) ) + if ( !d2->template is_free() ) { - d2->unlink_beta(iinv); + d2->template unlink_beta(); CGAL_assertion( !amap.is_marked(d2, mark_modified_darts) ); amap.mark(d2, mark_modified_darts); modified_darts.push_back(d2); @@ -171,12 +173,13 @@ namespace CGAL { } } } - if ( (*it)->is_free(i+1) && !(*it)->is_free(i) ) + if ( (*it)->template is_free() && + !(*it)->template is_free() ) { - d1 = (*it)->beta(i); - if ( !d1->is_free(iinv) ) + d1 = (*it)->template beta(); + if ( !d1->template is_free() ) { - d1->unlink_beta(iinv); + d1->template unlink_beta(); CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) ); amap.mark(d1, mark_modified_darts); modified_darts.push_back(d1); @@ -188,7 +191,7 @@ namespace CGAL { // void attributes. CMap::Helper::template Foreach_enabled_attributes_except , i>:: - run(&amap, &modified_darts, mark_modified_darts); + run(&amap, modified_darts, mark_modified_darts); // We remove all the darts of the i-cell. for ( it=to_erase.begin(); it!=to_erase.end(); ++it ) @@ -233,18 +236,6 @@ namespace CGAL { std::deque modified_darts; -/* int mark_for_incident_cells[CMap::Helper::nb_attribs]; - std::deque > - incident_cells[CMap::Helper::nb_attribs]; - - // Marks used to mark all the incident cells. - for (int j=0; j it(amap,adart,mark); it.cont(); ++it) @@ -257,29 +248,13 @@ namespace CGAL { typename std::deque::iterator it = to_erase.begin(); - // 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(CMap::dimension) ) - { - CMap::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(CMap::dimension) && - !amap.is_marked((*it)->beta(CMap::dimension), mark) ) + if ( !(*it)->template is_free() && + !amap.is_marked((*it)->template beta(), mark) ) { - modified_darts.push_back((*it)->beta(CMap::dimension)); - //(*it)->beta(CMap::dimension)->unlink_beta(CMap::dimension); + modified_darts.push_back((*it)->template beta()); amap.template unlink_beta_for_involution(*it); } } @@ -287,11 +262,8 @@ namespace CGAL { // 4) We test the split of all the incident cells for all the non // void attributes. CMap::Helper::template Foreach_enabled_attributes_except - , - CMap::dimension>:: - run(&amap, &modified_darts, -1); //, modified_darts2); - //&mark_for_incident_cells[0], - //&incident_cells[0]); + , + CMap::dimension>::run(&amap, modified_darts); // 5) We remove all the darts of the d-cell. for ( it = to_erase.begin(); it != to_erase.end(); ++it ) @@ -300,14 +272,6 @@ namespace CGAL { CGAL_assertion( amap.is_whole_map_unmarked(mark) ); amap.free_mark(mark); - // We free the marks. -/* for (int j=0; j to_erase; std::deque modified_darts; - -/* int mark_for_incident_cells[CMap::Helper::nb_attribs]; - std::deque > - incident_cells[CMap::Helper::nb_attribs]; - - // Marks used to mark all the incident cells. - for (int j=0; j modified_darts2; // 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); - if ( !it->is_free(0) && dg1==NULL ) - { dg1=it; dg2=it->beta(0); } + if ( !it->template is_free<0>() && dg1==NULL ) + { dg1=it; dg2=it->template beta<0>(); } amap.mark(it, mark); ++res; } @@ -366,39 +319,6 @@ namespace CGAL { // 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) ) - { - if ( dg1==NULL ) { dg1=(*it)->beta(0); dg2=(*it)->beta(1); } - CMap::Helper::template Foreach_enabled_attributes - >:: - run(&amap, *it, mark, &mark_for_incident_cells[0], - &incident_cells[0]); - } - else - { - CMap::Helper::template Foreach_enabled_attributes - >:: - run(&amap, *it, mark, &mark_for_incident_cells[0], - &incident_cells[0]); - } - } - else - { - if ( !(*it)->is_free(1) ) - { - CMap::Helper::template Foreach_enabled_attributes - >:: - run(&amap, (*it)->beta(1), mark, &mark_for_incident_cells[0], - &incident_cells[0]); - } - } - } -*/ - for (; it != to_erase.end(); ++it) amap.update_dart_of_all_attributes(*it, mark); @@ -410,18 +330,21 @@ namespace CGAL { // 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) ) + if ( !(*it)->template is_free<0>() ) { - if ( !(*it)->is_free(1) && (*it)->beta(0)!=(*it) ) + if ( !(*it)->template is_free<1>() && + (*it)->template beta<0>()!=(*it) ) { - amap.template basic_link_beta<1>((*it)->beta(0), (*it)->beta(1)); - modified_darts.push_back((*it)->beta(0)); - modified_darts.push_back((*it)->beta(1)); + amap.basic_link_beta_1((*it)->template beta<0>(), + (*it)->template beta<1>()); + modified_darts.push_back((*it)->template beta<0>()); + modified_darts2.push_back((*it)->template beta<1>()); + // TODO push only one out of two dart ? } else { - (*it)->beta(0)->unlink_beta(1); - modified_darts.push_back((*it)->beta(0)); + (*it)->template beta<0>()->template unlink_beta<1>(); + modified_darts.push_back((*it)->template beta<0>()); } for ( unsigned int j=2; j<=CMap::dimension; ++j ) @@ -430,17 +353,18 @@ namespace CGAL { { // TODO push these darts in modified_darts ? // not sure this is required - amap.basic_link_beta((*it)->beta(0), (*it)->beta(j), j); + amap.basic_link_beta((*it)->template beta<0>(), + (*it)->beta(j), j); //((*it)->beta(0))->basic_link_beta((*it)->beta(j),j); } } } else { - if ( !(*it)->is_free(1) ) + if ( !(*it)->template is_free<1>() ) { - (*it)->beta(1)->unlink_beta(0); - modified_darts.push_back((*it)->beta(1)); + (*it)->template beta<1>()->template unlink_beta<0>(); + modified_darts2.push_back((*it)->template beta<1>()); } for ( unsigned int j=2; j<=CMap::dimension; ++j ) @@ -459,11 +383,8 @@ namespace CGAL { // void attributes. CMap::Helper::template Foreach_enabled_attributes_except , 1>:: - // >:: run(&amap, - &modified_darts, -1); //mark_modified_darts); - //&mark_for_incident_cells[0], - //&incident_cells[0]); + modified_darts, modified_darts2); // We remove all the darts of the i-cell. for ( it=to_erase.begin(); it!=to_erase.end(); ++it ) @@ -472,15 +393,6 @@ namespace CGAL { CGAL_assertion( amap.is_whole_map_unmarked(mark) ); amap.free_mark(mark); - // We free the marks. - /* for (int j=0; jis_free(i-1) && dg1==NULL ) - { dg1=it; dg2=it->beta(i-1); } + if ( !it->template is_free() && dg1==NULL ) + { dg1=it; dg2=it->template beta(); } amap.mark(it, mark); ++res; } @@ -577,20 +489,21 @@ namespace CGAL { // 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(i); + d1 = (*it)->template beta(); while ( d1!=CMap::null_dart_handle && amap.is_marked(d1, mark) ) { - d1 = d1->beta(imuinv)->beta(i); - if (d1 == (*it)->beta(i)) d1 = CMap::null_dart_handle; + d1 = d1->template beta()->template beta(); + if (d1 == (*it)->template beta()) d1 = CMap::null_dart_handle; } if ( !amap.is_marked(d1, mark_modified_darts) ) { - d2 = (*it)->beta(i-1)->beta(i); + d2 = (*it)->template beta()->template beta(); while ( d2!=CMap::null_dart_handle && amap.is_marked(d2, mark) ) { - d2 = d2->beta(i-1)->beta(i); - if ( d2==(*it)->beta(i-1)->beta(i) ) d2=CMap::null_dart_handle; + d2 = d2->template beta()->template beta(); + if ( d2==(*it)->template beta()->template beta() ) + d2=CMap::null_dart_handle; } if ( !amap.is_marked(d2, mark_modified_darts) ) @@ -599,15 +512,16 @@ namespace CGAL { { if (d2 != CMap::null_dart_handle && d1!=d2 ) { - amap.template basic_link_beta(d1, d2); + amap.template basic_link_beta_for_involution(d1, d2); amap.mark(d1, mark_modified_darts); amap.mark(d2, mark_modified_darts); modified_darts.push_back(d1); modified_darts.push_back(d2); + // TODO push only one out of two dart ? } else { - if ( !d1->is_free(i) ) + if ( !d1->template is_free() ) { d1->unlink_beta(i); CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) ); @@ -645,7 +559,7 @@ namespace CGAL { // void attributes. CMap::Helper::template Foreach_enabled_attributes_except , i>:: - run(&amap, &modified_darts, mark_modified_darts); + run(&amap, modified_darts, mark_modified_darts); // We remove all the darts of the i-cell. for ( it=to_erase.begin(); it!=to_erase.end(); ++it ) @@ -697,6 +611,7 @@ namespace CGAL { std::deque to_erase; std::deque modified_darts; + std::deque modified_darts2; // First we store and mark all the darts of the 1-cell to contract. for ( CMap_dart_iterator_basic_of_cell it(amap,adart,mark); @@ -731,15 +646,16 @@ namespace CGAL { { /* modified_darts.push_back((*it)->beta(0)); if ( (*it)->beta(0)!=(*it)->beta(1) )*/ - modified_darts.push_back((*it)->beta(1)); - amap.template basic_link_beta<1>((*it)->beta(0), (*it)->beta(1)); + modified_darts2.push_back((*it)->template beta<1>()); + amap.basic_link_beta_1((*it)->template beta<0>(), + (*it)->template beta<1>()); } } else { // TODO todegroup.push(Dart_pair((*it)->beta(0), *it)); - modified_darts.push_back((*it)->beta(0)); - (*it)->beta(0)->unlink_beta(1); + modified_darts.push_back((*it)->template beta<0>()); + (*it)->template beta<0>()->template unlink_beta<1>(); } } else @@ -747,8 +663,8 @@ namespace CGAL { if ( !(*it)->is_free(1) ) { // TODO todegroup.push(Dart_pair((*it)->beta(1), *it)); - modified_darts.push_back((*it)->beta(1)); - (*it)->beta(1)->unlink_beta(0); + modified_darts2.push_back((*it)->template beta<1>()); + (*it)->template beta<1>()->template unlink_beta<0>(); } } } @@ -757,11 +673,7 @@ namespace CGAL { // void attributes. CMap::Helper::template Foreach_enabled_attributes_except , 1>:: - // >:: - run(&amap, - &modified_darts, -1); //mark_modified_darts); - //&mark_for_incident_cells[0], - //&incident_cells[0]); + run(&amap, modified_darts, modified_darts2); // 6) We remove all the darts of the cell. for (it = to_erase.begin(); it != to_erase.end(); ++it) diff --git a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h index 4095411f046..ee1646e9bad 100644 --- a/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h +++ b/Combinatorial_map/include/CGAL/internal/Combinatorial_map_functors.h @@ -428,6 +428,16 @@ namespace CGAL typename CMap::Dart_handle) {} }; + // Specialization for i=1 and j=0. Do nothing as edges attributes are not + // modify when we modify beta_0. + template + struct Group_attribute_functor_of_dart_run + { + static void run(CMap*, + typename CMap::Dart_handle, + typename CMap::Dart_handle) + {} + }; // ************************************************************************** /// Functor used for link_beta to update the attributes of /// adart2 on the attributes of this dart, except for j-attributes. @@ -660,6 +670,16 @@ namespace CGAL typename CMap::Dart_handle) {} }; + // Specialization for i=1 and j=0. Do nothing as edges attributes are not + // modify when we modify beta_0. + template + struct Group_attribute_functor_run + { + static void run(CMap*, + typename CMap::Dart_handle, + typename CMap::Dart_handle) + {} + }; // ************************************************************************** /// Functor used for sew to update the attributes of /// adart2 on the attributes of this dart, except for j-attributes. @@ -804,85 +824,78 @@ namespace CGAL {} }; // ************************************************************************** - /// Functor used by Test_split_attribute_functor_run to process one dart. - template - struct Test_split_attribute_functor_one_dart + // Function used by Test_split_attribute_functor_run to process one dart. + // Test the split of the i-cell containing the given dart adart. + // When we process a dart, we search in the Unique_hash_map if its + // i-attribute was already found. If yes, it means that we already + // found an i-cell with this attribute, thus this attribute is split. + // We mark (with mark) all the darts of the i-cell containing adart to + // process them exactly once. + template + void test_split_attribute_functor_one_dart + ( CMap* amap, typename CMap::Dart_handle adart, + Unique_hash_map::type, + unsigned int> & found_attributes, int mark ) { + CGAL_assertion( amap!=NULL ); + CGAL_assertion( adart!=NULL ); + CGAL_static_assertion_msg(CMap::Helper::template + Dimension_index::value>=0, + "Test_split_attribute_functor_one_dart but " + "i-attributes are disabled"); + typedef typename CMap::Dart_handle Dart_handle; + typedef typename CMap::Helper::template Attribute_handle::type + Attribute_handle_i; - // Test the split of the i-cell containing the given dart adart. - // When we process a dart, we search in the Unique_hash_map if its - // i-attribute was already found. If yes, it means that we already - // found an i-cell with this attribute, thus this attribute is split. - // We mark (with mark) all the darts of the i-cell containing adart to - // process them exactly once. - template - static void run( CMap* amap, - Dart_handle adart, - Unique_hash_map::type, int> & found_attributes, - int mark ) - { - CGAL_assertion( amap!=NULL ); - CGAL_assertion( adart!=NULL ); - CGAL_static_assertion_msg(CMap::Helper::template - Dimension_index::value>=0, - "Test_split_attribute_functor_one_dart but " - "i-attributes are disabled"); + // If the current dart has no attribute, or if it is aldready marked, + // nothing to do. + if ( adart->template attribute()==NULL || + amap->is_marked(adart, mark) ) + return; - typedef typename CMap::Helper::template Attribute_handle::type - Attribute_handle_i; + Attribute_handle_i a1 = adart->template attribute(); + if ( found_attributes.is_defined(a1) ) + { // Here the attribute was already present in the hash_map + Attribute_handle_i a2 = amap->template create_attribute(*a1); + a2->set_dart(adart); - // If the current dart has no attribute, or if it is aldready marked, - // nothing to do. - if ( adart->template attribute()==NULL || - amap->is_marked(adart, mark) ) - return; - - Attribute_handle_i a1 = adart->template attribute(); - if ( found_attributes.is_defined(a1) ) - { // Here the attribute was already present in the hash_map - Attribute_handle_i a2 = amap->template create_attribute(*a1); - a2->set_dart(adart); - - for ( CMap_dart_iterator_basic_of_cell - itj(*amap, adart, mark); itj.cont(); ++itj ) - { - amap->template set_attribute_of_dart(itj, a2); - amap->mark(itj, mark); - } - Call_split_functor::run(a1, a2); - } - else + for ( CMap_dart_iterator_basic_of_cell + itj(*amap, adart, mark); itj.cont(); ++itj ) { - // Here the attribute was not in the hash_map. - found_attributes[a1]=1; - a1->set_dart(adart); + amap->template set_attribute_of_dart(itj, a2); + amap->mark(itj, mark); + } + Call_split_functor::run(a1, a2); + } + else + { + // Here the attribute was not in the hash_map. + found_attributes[a1]=1; + a1->set_dart(adart); - for ( CMap_dart_iterator_basic_of_cell - itj(*amap, adart, mark); itj.cont(); ++itj ) - { - CGAL_assertion( itj->template attribute()==a1 ); - amap->mark(itj, mark); - } + for ( CMap_dart_iterator_basic_of_cell + itj(*amap, adart, mark); itj.cont(); ++itj ) + { + CGAL_assertion( itj->template attribute()==a1 ); + amap->mark(itj, mark); } } - }; + } // ************************************************************************** /// Functor used for unsew to test if i-attributes are split after an /// operation, except for j-attributes. /// (j is the dimension of the beta modified for darts in modified_darts, - /// if j==0 modified_darts_2 are the darts modified for beta_1). + /// if j==0 modified_darts2 are the darts modified for beta_1). template::type> struct Test_split_attribute_functor_run { + // modified_darts is the set of modified darts for beta_j static void run( CMap* amap, - std::deque - *modified_darts, - std::deque - */*modified_darts2*/, + const std::deque + &modified_darts, int mark_modified_darts=-1) { CGAL_static_assertion( 1<=i && i<=CMap::dimension ); @@ -899,23 +912,86 @@ namespace CGAL Unique_hash_map found_attributes; int mark = amap->get_new_mark(); // to mark incident cells. - typename std::deque::iterator - it=modified_darts->begin(); - for ( ; it!=modified_darts->end(); ++it ) + typename std::deque::const_iterator + it=modified_darts.begin(); + for ( ; it!=modified_darts.end(); ++it ) { - Test_split_attribute_functor_one_dart:: - run(amap, *it, found_attributes, mark); + test_split_attribute_functor_one_dart + (amap, *it, found_attributes, mark); } // Now we unmark all the marked darts. amap->negate_mark(mark); - for ( it=modified_darts->begin(); it!=modified_darts->end(); ++it ) + for ( it=modified_darts.begin(); it!=modified_darts.end(); ++it ) { if ( mark_modified_darts!=-1 ) amap->unmark(*it, mark_modified_darts); if ( !amap->is_marked(*it, mark) ) - mark_cell(*amap, *it, mark); + mark_cell(*amap, *it, mark); + } + + CGAL_assertion( amap->is_whole_map_marked(mark) ); + amap->free_mark(mark); + } + static void run( CMap* amap, + const std::deque + &modified_darts, + const std::deque + &modified_darts2, + int mark_modified_darts=-1) + { + // Normalement on utilise la version avec modified_darts2 + // que dans le cas j=0 + CGAL_assertion(false); + // TODO remove cette function run + + CGAL_static_assertion( 1<=i && i<=CMap::dimension ); + CGAL_assertion( i!=j ); + CGAL_assertion( amap!=NULL ); + CGAL_static_assertion_msg(CMap::Helper::template + Dimension_index::value>=0, + "Test_split_attribute_functor_run but " + "i-attributes are disabled"); + + typedef typename CMap::Helper::template Attribute_handle::type + Attribute_handle_i; + + Unique_hash_map found_attributes; + + int mark = amap->get_new_mark(); // to mark incident cells. + typename std::deque::const_iterator + it=modified_darts.begin(); + for ( ; it!=modified_darts.end(); ++it ) + { + test_split_attribute_functor_one_dart + (amap, *it, found_attributes, mark); + } + typename std::deque::const_iterator + it2=modified_darts2.begin(); + for ( ; it2!=modified_darts2.end(); ++it2 ) + { + test_split_attribute_functor_one_dart + (amap, *it2, found_attributes, mark); + } + + // Now we unmark all the marked darts. + amap->negate_mark(mark); + for ( it=modified_darts.begin(); it!=modified_darts.end(); ++it ) + { + if ( mark_modified_darts!=-1 ) + amap->unmark(*it, mark_modified_darts); + + if ( !amap->is_marked(*it, mark) ) + mark_cell(*amap, *it, mark); + } + for ( it2=modified_darts2.begin(); it2!=modified_darts2.end(); ++it2 ) + { + if ( mark_modified_darts!=-1 ) + amap->unmark(*it2, mark_modified_darts); + + if ( !amap->is_marked(*it2, mark) ) + mark_cell(*amap, *it2, mark); } CGAL_assertion( amap->is_whole_map_marked(mark) ); @@ -927,10 +1003,8 @@ namespace CGAL struct Test_split_attribute_functor_run { static void run( CMap* amap, - std::deque - *modified_darts, - std::deque - */*modified_darts2*/, + const std::deque + &modified_darts, int mark_modified_darts=-1) { CGAL_assertion( j!=0 && j!=1 ); @@ -947,32 +1021,113 @@ namespace CGAL typename CMap::Dart_handle od=NULL; int mark = amap->get_new_mark(); // to mark incident cells. - typename std::deque::iterator - it=modified_darts->begin(); - for ( ; it!=modified_darts->end(); ++it ) + typename std::deque::const_iterator + it=modified_darts.begin(); + for ( ; it!=modified_darts.end(); ++it ) { - Test_split_attribute_functor_one_dart:: - run<0>(amap, *it, found_attributes, mark); + test_split_attribute_functor_one_dart + (amap, *it, found_attributes, mark); od=(*it)->other_extremity(); if ( od!=NULL ) - Test_split_attribute_functor_one_dart:: - run<0>(amap, od, found_attributes, mark); + test_split_attribute_functor_one_dart + (amap, od, found_attributes, mark); } // Now we unmark all the marked darts. amap->negate_mark(mark); - for ( it=modified_darts->begin(); it!=modified_darts->end(); ++it ) + for ( it=modified_darts.begin(); it!=modified_darts.end(); ++it ) { if ( mark_modified_darts!=-1 ) amap->unmark(*it, mark_modified_darts); if ( !amap->is_marked(*it, mark) ) - mark_cell<0>(*amap, *it, mark); + mark_cell(*amap, *it, mark); od=(*it)->other_extremity(); if ( od!=NULL && !amap->is_marked(od, mark) ) - mark_cell<0>(*amap, od, mark); + mark_cell(*amap, od, mark); + } + + CGAL_assertion( amap->is_whole_map_marked(mark) ); + amap->free_mark(mark); + } + static void run( CMap* amap, + const std::deque + &modified_darts, + const std::deque + &modified_darts2, + int mark_modified_darts=-1) + { + // Normalement on utilise la version avec modified_darts2 + // que dans le cas j=0 + CGAL_assertion(false); + // TODO remove cette function run + + CGAL_assertion( j!=0 && j!=1 ); + CGAL_assertion( amap!=NULL ); + CGAL_static_assertion_msg(CMap::Helper::template + Dimension_index<0>::value>=0, + "Test_split_attribute_functor_run<0> but " + "0-attributes are disabled"); + + typedef typename CMap::Helper::template Attribute_handle<0>::type + Attribute_handle_0; + + Unique_hash_map found_attributes; + typename CMap::Dart_handle od=NULL; + + int mark = amap->get_new_mark(); // to mark incident cells. + typename std::deque::const_iterator + it=modified_darts.begin(); + for ( ; it!=modified_darts.end(); ++it ) + { + test_split_attribute_functor_one_dart + (amap, *it, found_attributes, mark); + + od=(*it)->other_extremity(); + if ( od!=NULL ) + test_split_attribute_functor_one_dart + (amap, od, found_attributes, mark); + } + typename std::deque::const_iterator + it2=modified_darts2.begin(); + for ( ; it2!=modified_darts2.end(); ++it2 ) + { + test_split_attribute_functor_one_dart + (amap, *it2, found_attributes, mark); + + od=(*it2)->other_extremity(); + if ( od!=NULL ) + test_split_attribute_functor_one_dart + (amap, od, found_attributes, mark); + } + + // Now we unmark all the marked darts. + amap->negate_mark(mark); + for ( it=modified_darts.begin(); it!=modified_darts.end(); ++it ) + { + if ( mark_modified_darts!=-1 ) + amap->unmark(*it, mark_modified_darts); + + if ( !amap->is_marked(*it, mark) ) + mark_cell(*amap, *it, mark); + + od=(*it)->other_extremity(); + if ( od!=NULL && !amap->is_marked(od, mark) ) + mark_cell(*amap, od, mark); + } + for ( it2=modified_darts2.begin(); it2!=modified_darts2.end(); ++it2 ) + { + if ( mark_modified_darts!=-1 ) + amap->unmark(*it2, mark_modified_darts); + + if ( !amap->is_marked(*it2, mark) ) + mark_cell(*amap, *it2, mark); + + od=(*it2)->other_extremity(); + if ( od!=NULL && !amap->is_marked(od, mark) ) + mark_cell(*amap, od, mark); } CGAL_assertion( amap->is_whole_map_marked(mark) ); @@ -983,18 +1138,115 @@ namespace CGAL template struct Test_split_attribute_functor_run { + static void run( CMap* amap, + const std::deque + &modified_darts, + const std::deque + &modified_darts2, + int mark_modified_darts=-1) + { + CGAL_assertion( amap!=NULL ); + CGAL_static_assertion_msg(CMap::Helper::template + Dimension_index<0>::value>=0, + "Test_split_attribute_functor_run<0> but " + "0-attributes are disabled"); + + typedef typename CMap::Helper::template Attribute_handle<0>::type + Attribute_handle_0; + + Unique_hash_map found_attributes; + typename CMap::Dart_handle od=NULL; + + int mark = amap->get_new_mark(); // to mark incident cells. + typename std::deque::const_iterator + it=modified_darts.begin(); + for ( ; it!=modified_darts.end(); ++it ) + { + test_split_attribute_functor_one_dart + (amap, *it, found_attributes, mark); + } + typename std::deque::const_iterator + it2=modified_darts2.begin(); + for ( ; it2!=modified_darts2.end(); ++it2 ) + { + od=(*it2)->other_extremity(); + if ( od!=NULL ) + test_split_attribute_functor_one_dart + (amap, od, found_attributes, mark); + } + + // Now we unmark all the marked darts. + amap->negate_mark(mark); + for ( it=modified_darts.begin(); it!=modified_darts.end(); ++it ) + { + if ( mark_modified_darts!=-1 ) + amap->unmark(*it, mark_modified_darts); + + if ( !amap->is_marked(*it, mark) ) + mark_cell(*amap, *it, mark); + } + for ( it2=modified_darts2.begin(); it2!=modified_darts2.end(); ++it2 ) + { + if ( mark_modified_darts!=-1 ) + amap->unmark(*it2, mark_modified_darts); + + od=(*it2)->other_extremity(); + if ( od!=NULL && !amap->is_marked(od, mark) ) + mark_cell(*amap, od, mark); + } + + CGAL_assertion( amap->is_whole_map_marked(mark) ); + amap->free_mark(mark); + } }; - // Specialization for i=1 and j=0. + // Specialization for i=0 and j=1. + // Equivalent to i=0 and j=0. template - struct Test_split_attribute_functor_run + struct Test_split_attribute_functor_run { - // No sense as we use always <0,0> ? + static void run( CMap*, const std::deque&, + int=-1) + { CGAL_assertion(false); } + static void run( CMap*, const std::deque&, + const std::deque&, int=-1) + { CGAL_assertion(false); } }; // Specialization for void attributes. template struct Test_split_attribute_functor_run { + static void run( CMap*, const std::deque&, + int=-1) + {} + static void run( CMap*, const std::deque&, + const std::deque&, int=-1) + {} }; + // Specialization for i=j. + template + struct Test_split_attribute_functor_run + { + static void run( CMap*, const std::deque&, + int=-1) + {} + static void run( CMap*, const std::deque&, + const std::deque&, int=-1) + {} + }; + // Specialization for i=1 and j=0 (edge attributes are not modified + // when we modify beta_0). + template + struct Test_split_attribute_functor_run + { + static void run( CMap*, const std::deque&, + int=-1) + {} + static void run( CMap*, const std::deque&, + const std::deque&, int=-1) + {} + }; + // ************************************************************************** + /// Functor used for unsew to test if i-attributes are split after an /// operation, except for j-attributes. /// We define run to allows to use this functor with @@ -1002,116 +1254,33 @@ namespace CGAL template struct Test_split_attribute_functor { - typedef typename CMap::Dart_handle Dart_handle; - - // Test the split of the i-cell containing dart adart. - template - static void test_one_dart( CMap* amap, - Dart_handle adart, - Unique_hash_map::type, int> & - found_attributes, int mark ) - { - typedef typename CMap::Helper::template Attribute_handle::type - Attribute_handle_i; - - if ( adart->template attribute()!=NULL && - !amap->is_marked(adart, mark) ) - { - Attribute_handle_i a1 = adart->template attribute(); - if ( found_attributes.is_defined(a1) ) - { // Here the attribute was already present in the hash_map - Attribute_handle_i a2 = amap->template create_attribute(*a1); - - for ( CMap_dart_iterator_basic_of_cell - itj(*amap, adart, mark); itj.cont(); ++itj ) - { - amap->template set_attribute_of_dart(itj, a2); - amap->mark(itj, mark); - } - a2->set_dart(adart); - Call_split_functor::run(a1, a2); - } - else - { - // Here the attribute was not in the hash_map. - found_attributes[a1]=1; - a1->set_dart(adart); - - for ( CMap_dart_iterator_basic_of_cell - itj(*amap, adart, mark); itj.cont(); ++itj ) - { - CGAL_assertion( itj->template attribute()==a1 ); - amap->mark(itj, mark); - } - } - } - } - // Test the split of i-attributes, for all modified darts given in // modified_darts, and marked with mark_modified_darts. // For each split attribute, create a new i-attribute, associate // it with the new i-cell and call onsplit functors. template static void run( CMap* amap, - std::deque - *modified_darts, + const std::deque + &modified_darts, int mark_modified_darts=-1) { - CGAL_assertion( i!=j ); - CGAL_assertion( amap!=NULL ); - - typedef typename CMap::Helper::template Attribute_handle::type - Attribute_handle_i; - - Unique_hash_map found_attributes; - - int mark = amap->get_new_mark(); // to mark incident cells. - for ( typename std::deque::iterator - it=modified_darts->begin(); it!=modified_darts->end(); ++it ) - { - test_one_dart(amap, *it, found_attributes, mark); - - if ( /*j!=1 &&*/ i==0 ) // TODO Here we test too many cases, but more works to do - { - typename CMap::Dart_handle od = (*it)->other_extremity(); - if ( od!=NULL ) - test_one_dart(amap, od, found_attributes, mark); - } - } - - // Now we unmark all the marked darts. - amap->negate_mark(mark); - for ( typename std::deque::iterator - it=modified_darts->begin(); it!=modified_darts->end(); ++it ) - { - if ( mark_modified_darts!=-1 ) - amap->unmark(*it, mark_modified_darts); - - if ( !amap->is_marked(*it, mark) ) - for ( CMap_dart_iterator_basic_of_cell - itj(*amap, *it, mark); itj.cont(); ++itj ) - { - amap->mark(itj, mark); - } - - if ( /*j!=1 &&*/ i==0 ) - { - Dart_handle od = (*it)->other_extremity(); - if ( od!=NULL && !amap->is_marked(od, mark) ) - for ( CMap_dart_iterator_basic_of_cell - itj(*amap, od, mark); itj.cont(); ++itj ) - { - amap->mark(itj, mark); - } - } - } - - CGAL_assertion( amap->is_whole_map_marked(mark) ); - amap->free_mark(mark); + Test_split_attribute_functor_run::run(amap, modified_darts, + mark_modified_darts); + } + template + static void run( CMap* amap, + const std::deque + &modified_darts, + const std::deque + &modified_darts2, + int mark_modified_darts=-1) + { + Test_split_attribute_functor_run::run(amap, modified_darts, + modified_darts2, + mark_modified_darts); } }; - + // ************************************************************************** } // namespace internal } // namespace CGAL