diff --git a/Combinatorial_map/include/CGAL/Creation_of_test_cases_for_paths.h b/Combinatorial_map/include/CGAL/Creation_of_test_cases_for_paths.h index 753b3b9abcb..c80ba4582b5 100644 --- a/Combinatorial_map/include/CGAL/Creation_of_test_cases_for_paths.h +++ b/Combinatorial_map/include/CGAL/Creation_of_test_cases_for_paths.h @@ -101,11 +101,30 @@ template void generate_positive_bracket_special1(Path& p) { generate_bracket_special1(p, false); } - template void generate_negative_bracket_special1(Path& p) { generate_bracket_special1(p, true); } +template +void generate_bracket_special2(Path& p, bool reverse) +{ // Case (1, 2^r) + p.clear(); + p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[0])); + extend_uturn_positive(p, 1); + extend_straight_positive(p, 10); + + if (reverse) + { p.reverse(); } +} + +template +void generate_positive_bracket_special2(Path& p) +{ generate_bracket_special2(p, false); } + +template +void generate_negative_bracket_special2(Path& p) +{ generate_bracket_special2(p, true); } + } // namespace CGAL #endif // CGAL_CREATION_OF_TEST_CASES_FOR_PATHS_H // diff --git a/Combinatorial_map/include/CGAL/Path_on_surface.h b/Combinatorial_map/include/CGAL/Path_on_surface.h index 15a7a2a2a3b..9310d54578a 100644 --- a/Combinatorial_map/include/CGAL/Path_on_surface.h +++ b/Combinatorial_map/include/CGAL/Path_on_surface.h @@ -62,6 +62,12 @@ public: void clear() { m_path.clear(); } + std::size_t next_index(std::size_t i) const + { return (i==m_path.size()-1?0:i+1); } + + std::size_t prev_index(std::size_t i) const + { return (i==0?m_path.size()-1:i-1); } + Dart_const_handle get_ith_dart(std::size_t i) const { assert(i<=m_path.size()); @@ -214,22 +220,16 @@ public: assert((positive && next_turn(begin)==1) || (!positive && next_negative_turn(begin)==1)); std::size_t end=begin+1; - if (end==m_path.size()-1) + if (!is_closed() && end==m_path.size()-1) { return begin; } // begin is the before last dart while ((positive && next_turn(end)==2) || (!positive && next_negative_turn(end)==2)) - { - ++end; - if (is_closed() && end==m_path.size()) { end=0; } - } + { end=next_index(end); } if ((positive && next_turn(end)==1) || (!positive && next_negative_turn(end)==1)) // We are on the end of a bracket - { - ++end; - if (is_closed() && end==m_path.size()) { end=0; } - } + { end=next_index(end); } else { end=begin; } @@ -239,8 +239,14 @@ public: void transform_positive_bracket(std::size_t begin, std::size_t end, std::vector& new_path) { - Dart_const_handle d1=m_map.template beta<0>(get_ith_dart(begin)); - Dart_const_handle d2=m_map.template beta<2,0>(get_ith_dart(end)); + // There is a special case for (1 2^r). In this case, we need to ignore + // the two darts begin and end + Dart_const_handle d1=(next_index(begin)!=end? + m_map.template beta<0>(get_ith_dart(begin)): + m_map.template beta<1,2,0>(get_ith_dart(end))); + Dart_const_handle d2=(next_index(begin)!=end? + m_map.template beta<2,0>(get_ith_dart(end)): + m_map.template beta<0,0>(get_ith_dart(begin))); do { new_path.push_back(m_map.template beta<2>(d1)); @@ -252,8 +258,14 @@ public: void transform_negative_bracket(std::size_t begin, std::size_t end, std::vector& new_path) { - Dart_const_handle d1=m_map.template beta<2,1>(get_ith_dart(begin)); - Dart_const_handle d2=m_map.template beta<1>(get_ith_dart(end)); + // There is a special case for (-1 -2^r). In this case, we need to ignore + // the two darts begin and end + Dart_const_handle d1=(next_index(begin)!=end? + m_map.template beta<2,1>(get_ith_dart(begin)): + m_map.template beta<2,0,2,1>(get_ith_dart(end))); + Dart_const_handle d2=(next_index(begin)!=end? + m_map.template beta<1>(get_ith_dart(end)): + m_map.template beta<2,1,1>(get_ith_dart(begin))); do { new_path.push_back(d1); @@ -300,7 +312,9 @@ public: <<(positive?"+":"-")<& path, delete curp; curp=NULL; } - // if (nbtest==1) - // display(lcc, v); + if (draw /* && nbtest==1*/) + display(path.get_map(), v); } while(curp!=NULL); @@ -58,9 +58,10 @@ void simplify_path(CGAL::Path_on_surface& path, curp=NULL; } - path.swap(*prevp); if (draw) { display(path.get_map(), v); } + + path.swap(*prevp); } void test_file(int argc, char** argv) @@ -162,72 +163,92 @@ void test_some_random_paths_on_cube() void test_all_cases_spurs_and_bracket() { - LCC_3_cmap lcc1; - if (!CGAL::load_off(lcc1, "./data/cube-mesh-5-5.off")) + LCC_3_cmap lcc; + if (!CGAL::load_off(lcc, "./data/cube-mesh-5-5.off")) { std::cout<<"PROBLEM reading file ./data/cube-mesh-5-5.off"< "; path1.display_positive_turns(); std::cout< "; path.display_positive_turns(); std::cout< "; path1.display_negative_turns(); std::cout< "; path.display_negative_turns(); std::cout< "; path1.display_positive_turns(); std::cout< "; path.display_positive_turns(); std::cout< "; path1.display_positive_turns(); std::cout< "; path.display_positive_turns(); std::cout< "; path1.display_negative_turns(); std::cout< "; path.display_negative_turns(); std::cout< path2(lcc2); + lcc.clear(); + if (!CGAL::load_off(lcc, "./data/spiral-squared.off")) + { + std::cout<<"PROBLEM reading file ./data/spiral-squared.off"< +"; path2.display_positive_turns(); - std::cout<<" -"; path2.display_negative_turns(); std::cout< +"; path.display_positive_turns(); + std::cout<<" -"; path.display_negative_turns(); std::cout< +"; path2.display_positive_turns(); - std::cout<<" -"; path2.display_negative_turns(); std::cout< +"; path.display_positive_turns(); + std::cout<<" -"; path.display_negative_turns(); std::cout< +"; path.display_positive_turns(); + std::cout<<" -"; path.display_negative_turns(); std::cout< +"; path.display_positive_turns(); + std::cout<<" -"; path.display_negative_turns(); std::cout<is_empty()) + { return; } + CGAL::Random random(i); CGAL::Color color=get_random_color(random);