From cceb42748150ed4d9c8b03f3ae1bf1453f591412 Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Tue, 4 Sep 2018 16:11:35 +0200 Subject: [PATCH] Bugfix in removal operation. --- .../CGAL/Combinatorial_map_operations.h | 72 +++++++++---------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h index bf44a965fa8..becece3f9e2 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_operations.h @@ -149,64 +149,57 @@ namespace CGAL to_erase.begin(); for ( ; it!=to_erase.end(); ++it ) { - d1=amap.template beta(*it); - while ( d1!=amap.null_dart_handle && amap.is_marked(d1, mark) ) + if (i!=1 || amap.template beta<1>(*it)!=*it) // for 1-removal of a dart loop, nothing to do { - d1=amap.template beta(d1); - if ( d1==amap. template beta(*it) ) d1=amap.null_dart_handle; - } + d1=amap.template beta(*it); + while (d1!=amap.null_dart_handle && amap.is_marked(d1, mark)) + { + d1=amap.template beta(d1); + if (d1==amap. template beta(*it)) + { d1=amap.null_dart_handle; } + } - if ( !amap.is_marked(d1, mark_modified_darts) ) - { d2=amap.template beta(*it); while ( d2!=amap.null_dart_handle && amap.is_marked(d2, mark) ) { d2=amap.template beta(d2); if ( d2==amap.template beta(*it) ) - d2=amap.null_dart_handle; + { d2=amap.null_dart_handle; } } - if ( !amap.is_marked(d2, mark_modified_darts) ) + if ( d1!=amap.null_dart_handle ) { - if ( d1!=amap.null_dart_handle ) + if ( d2!=amap.null_dart_handle && d1!=d2 ) { - if ( d2!=amap.null_dart_handle && d1!=d2 ) + amap.template basic_link_beta(d1, d2); + amap.mark(d1, mark_modified_darts); + amap.mark(d2, mark_modified_darts); + first_modified_darts.push_back(d1); + modified_darts.push_back(d2); + } + else + { + if (d1==d2) { - //d1->basic_link_beta(d2, i); - amap.template basic_link_beta(d1, d2); + amap.template basic_link_beta(d1, d1); amap.mark(d1, mark_modified_darts); - amap.mark(d2, mark_modified_darts); first_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); - modified_darts.push_back(d2); - }*/ - // modified_darts2.push_back(d1); } - else + else if ( !amap.template is_free(d1) ) { - if ( !amap.template is_free(d1) ) - { - amap.template unlink_beta(d1); - CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) ); - amap.mark(d1, mark_modified_darts); - first_modified_darts.push_back(d1); - } + amap.template unlink_beta(d1); + amap.mark(d1, mark_modified_darts); + first_modified_darts.push_back(d1); } } - else if ( d2!=amap.null_dart_handle ) + } + else if ( d2!=amap.null_dart_handle ) + { + if ( !amap.template is_free(d2) ) { - if ( !amap.template is_free(d2) ) - { - amap.template unlink_beta(d2); - CGAL_assertion( !amap.is_marked(d2, mark_modified_darts) ); - amap.mark(d2, mark_modified_darts); - modified_darts.push_back(d2); - } + amap.template unlink_beta(d2); + amap.mark(d2, mark_modified_darts); + modified_darts.push_back(d2); } } } @@ -217,7 +210,6 @@ namespace CGAL if ( !amap.template is_free(d1) ) { amap.template unlink_beta(d1); - CGAL_assertion( !amap.is_marked(d1, mark_modified_darts) ); amap.mark(d1, mark_modified_darts); modified_darts.push_back(d1); }