diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h b/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h index 3503720430d..87160240682 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h @@ -152,6 +152,10 @@ namespace CGAL { m_map.free_mark(marktemp); m_map.display_darts(std::cout); #endif + + m_map.display_darts(std::cout); + + assert(are_paths_valid()); } ~Combinatorial_map_tools() @@ -168,10 +172,12 @@ namespace CGAL { { if (!m_original_map.is_marked(path[i], m_mark_T)) { - res.push_back(get_first_dart_of_the_path(path[i])); - res.push_back(get_second_dart_of_the_path(path[i])); + res.push_back(get_first_dart_of_the_path(path[i]), false); + res.push_back(get_second_dart_of_the_path(path[i]), false); } } + res.update_is_closed(); + assert(res.is_closed()); assert(res.is_valid()); return res; } @@ -402,20 +408,20 @@ namespace CGAL { // <(p.first); + // p.first=m_map.template beta<0>(p.first); Dart_const_handle initdart=p.first; while (m_map.is_marked(p.first, toremove)) { - p.first=m_map.template beta<2, 0>(p.first); + p.first=m_map.template beta<2, 1>(p.first); //std::cout<(p.second); + // p.second=m_map.template beta<0>(p.second); initdart=p.second; while (m_map.is_marked(p.second, toremove)) { - p.second=m_map.template beta<2, 0>(p.second); + p.second=m_map.template beta<2, 1>(p.second); //std::cout<& p=itp->second; //std::cout<<"Pair: "<(p.first); - p.second=m_map.template beta<1,2>(p.second); + p.first=m_map.template beta<0, 2>(p.first); + p.second=m_map.template beta<0>(p.second); //std::cout<<" -> "<(p.get_map(), *it, amark); } p.get_map().free_mark(amark); + + p.update_is_closed(); // TODO we can avoid that because we know that we generated a closed path (to do so, we need a method that put p.is_closed to true) + assert(p.is_closed()); } } // namespace CGAL diff --git a/Combinatorial_map/include/CGAL/Path_on_surface.h b/Combinatorial_map/include/CGAL/Path_on_surface.h index a7b13761225..4981d4d3379 100644 --- a/Combinatorial_map/include/CGAL/Path_on_surface.h +++ b/Combinatorial_map/include/CGAL/Path_on_surface.h @@ -439,6 +439,10 @@ public: { if (is_empty()) return false; +#ifndef NDEBUG + bool is_even=length()%2; +#endif // NDEBUG + Self new_path(m_map); bool positive=false; std::size_t begin, end; @@ -471,6 +475,9 @@ public: { copy_rest_of_path(end+1, length(), new_path); } swap(new_path); + + assert(length()%2==is_even); // bracket flattening is supposed to preserve length parity + return true; } } @@ -495,25 +502,43 @@ public: bool res=false; std::size_t i; std::size_t lastturn=m_path.size()-(is_closed()?0:1); - Self new_path(m_map); - for (i=0; i(m_path[next_index(i)])) - { - i+=2; - res=true; - } - else - { - new_path.push_back(m_path[i]); // We copy this dart - ++i; - } + { res=true; } + } + + if (!res) + { return false; } + +#ifndef NDEBUG + bool is_even=length()%2; +#endif // NDEBUG + + --i; // Because we did a ++ before to leave the loop + // Here there is a spur at position i in the path + Self new_path(m_map); + + // Special case, the spur is between last dart of the path and the first dart + if (is_closed() && i==m_path.size()-1) + { + copy_rest_of_path(1, m_path.size()-1, new_path); // copy path between 1 and m_path.size()-2 + } + else + { // Otherwise copy darts before the spur + if (i>0) + { copy_rest_of_path(0, i, new_path); } // copy path between 0 and i-1 + + // and the darts after + if (i+2 LCC_3_cmap; typedef CGAL::Linear_cell_complex_for_generalized_map<2,3> LCC_3_gmap; #define NB_TESTS 25 // 0 ... 24 -int nbtests=0; +static int nbtests=0; enum Transformation // enum for the type of transformations { @@ -27,7 +27,7 @@ enum Transformation // enum for the type of transformations FULL_SIMPLIFICATION }; -unsigned int starting_seed; +static unsigned int starting_seed; /////////////////////////////////////////////////////////////////////////////// void transform_path(CGAL::Path_on_surface& path, Transformation t, @@ -164,7 +164,7 @@ bool unit_test_canonize(std::vector >& paths, std::cout<<"."< > transformed_paths; // Test 23 (3 g1 cycles) - for (int i=0; i<3; ++i) + for (unsigned int i=0; i<3; ++i) { paths.push_back(CGAL::Path_on_surface(lcc)); CGAL::generate_g1_double_torus(paths[i], i); @@ -559,11 +559,11 @@ bool test_double_torus_quad(bool draw, int testtorun) generate_random_closed_path(p, random.get_int(5, 20), random); // random path, length between 30 and 500 // p.close(); paths.push_back(p); - /* update_path_randomly(p, random); - paths.push_back(p); update_path_randomly(p, random); + paths.push_back(p); + /* update_path_randomly(p, random); paths.push_back(p); */ - for (int i=0; i