diff --git a/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h b/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h index 381a8a29087..3503720430d 100644 --- a/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h +++ b/Combinatorial_map/include/CGAL/Combinatorial_map_functionalities.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace CGAL { @@ -129,6 +130,27 @@ namespace CGAL { std::cout<<"Paths are all valid ? "<<(are_paths_valid()?"YES":"NO") <(dh2))<(dh2); + } + while(dh2!=it); + } + } + m_map.free_mark(marktemp); + m_map.display_darts(std::cout); #endif } 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 3dccd77f60b..647e70040f0 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 @@ -348,6 +348,53 @@ void generate_g2_torus(Path& p, std::size_t i) } } +template +void generate_g1_v0_double_torus(Path& p) +{ // 1st generator + p.clear(); + p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[16])); + extend_straight_negative(p, 2); +} + +template +void generate_g1_v1_double_torus(Path& p) +{ // 1st generator + p.clear(); + p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[4])); + extend_straight_negative(p, 2); +} + +template +void generate_g1_v2_double_torus(Path& p) +{ // 1st generator + p.clear(); + p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[2])); + extend_straight_negative(p, 2); + p.reverse(); +} + +template +void generate_g2_v1_double_torus(Path& p) +{ // 2nd generator + p.clear(); + p.push_back(p.get_map().darts().iterator_to(p.get_map().darts()[10])); + extend_straight_negative(p, 2); + extend_uturn_negative(p, 1); +} + +template +void generate_g1_double_torus(Path& p, std::size_t i) +{ + assert(i<3); + switch(i) + { + case 0: generate_g1_v0_double_torus(p); break; + case 1: generate_g1_v1_double_torus(p); break; + case 2: generate_g1_v2_double_torus(p); break; + default: assert(false); + } +} + } // 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 45b5e74cd73..6b6a54b3dce 100644 --- a/Combinatorial_map/include/CGAL/Path_on_surface.h +++ b/Combinatorial_map/include/CGAL/Path_on_surface.h @@ -571,6 +571,14 @@ public: else { CGAL::extend_straight_positive(new_path, 1); } } + + if (begin==middle && next_index(middle)==end) + { // TODO: check if we need to do also something for !case_seven ? + // if (case_seven) + { CGAL::extend_uturn_positive(new_path, 1); } + /* else + { assert(false); } // We think (?) that this case is not possible */ + } } void push_l_shape_cycle_2() @@ -583,10 +591,30 @@ public: CGAL::extend_straight_positive_until(*this, d1); } + bool push_l_shape_2darts() + { + Dart_const_handle d1=NULL; + + if (next_negative_turn(0)==1) + d1=m_map.template beta<2,1>(get_ith_dart(0)); + else if (next_negative_turn(1)==1) + d1=m_map.template beta<2,1>(get_ith_dart(1)); + else return false; + + clear(); + push_back(d1); + CGAL::extend_uturn_positive(*this, 1); + //push_back(m_map.template beta<1>(d1)); + return true; + } + bool right_push_one_step() { if (is_empty()) { return false; } + if (length()==2) + { return push_l_shape_2darts(); } + std::size_t begin, middle, end; std::size_t lastturn=m_path.size()-(is_closed()?0:1); std::size_t next_turn; @@ -626,7 +654,8 @@ public: else { if (next_turn==1) - { // Here middle is a real middle; we already know begin (or we know + { + // Here middle is a real middle; we already know begin (or we know // that there is no -2 before if !prev2), we only need to compute // end. if (!prev2) { begin=middle; } // There is no -2 before this -1 @@ -676,7 +705,11 @@ public: { bool res=false; while(right_push_one_step()) - { res=true; } + { res=true; + + std::cout<<"RP "; display(); display_pos_and_neg_turns(); + std::cout< compute_positive_turns() const @@ -824,8 +871,8 @@ public: std::cout< LCC_3_cmap; typedef CGAL::Linear_cell_complex_for_generalized_map<2,3> LCC_3_gmap; -#define NB_TESTS 23 // 0 ... 22 +#define NB_TESTS 24 // 0 ... 23 int nbtests=0; enum Transformation // enum for the type of transformations @@ -402,8 +402,8 @@ bool test_some_random_paths_on_cube(bool draw, int testtorun) { res=false; } generate_random_bracket(path, 5, 12, 8, random); // Test 20 - if (!unit_test(path, FULL_SIMPLIFICATION, 0, "(2^4 1 2^12 1 2^8 ...)", - "2", draw, testtorun)) + if (!unit_test(path, PUSH, 0, "(2^4 1 2^12 1 2^8 ...)", + "2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 2 2 2 2 0 2 2 2 2 1 2 1", draw, testtorun)) { res=false; } return true; @@ -455,7 +455,7 @@ bool test_torus_quad(bool draw, int testtorun) { res=false; } // Test 23 (3 g2 cycles) TODO BUG IN TEST 23 !!! - /* paths.clear(); transformed_paths.clear(); + paths.clear(); transformed_paths.clear(); for (int i=0; i<3; ++i) { paths.push_back(CGAL::Path_on_surface(lcc)); @@ -468,11 +468,40 @@ bool test_torus_quad(bool draw, int testtorun) "canonize paths on torus gen2", draw, testtorun)) { res=false; } - */ return res; } +/////////////////////////////////////////////////////////////////////////////// +bool test_double_torus_quad(bool draw, int testtorun) +{ + bool res=true; + LCC_3_cmap lcc; + if (!CGAL::load_off(lcc, "./data/double-torus.off")) + { + std::cout<<"PROBLEM reading file ./data/double-torus.off"< cmt(lcc); + + std::vector > paths; + std::vector > transformed_paths; + + // Test 21 (3 g1 cycles) + for (int i=0; i<3; ++i) + { + paths.push_back(CGAL::Path_on_surface(lcc)); + CGAL::generate_g1_double_torus(paths[i], i); + transformed_paths.push_back + (cmt.transform_original_path_into_quad_surface(paths[i])); + } + + if (!unit_test_canonize(paths, transformed_paths, + "canonize paths on double torus gen1", + draw, testtorun)) + { res=false; } +} /////////////////////////////////////////////////////////////////////////////// bool test_elephant(bool draw, int testtorun) // TODO LATER { @@ -600,11 +629,17 @@ int main(int argc, char** argv) return EXIT_FAILURE; } - if (!test_torus_quad(draw, testN)) + if (!test_double_torus_quad(draw, testN)) + { + std::cout<<"TEST DOUBLE TORUS FAILED."<