From d3f1a4c7030d989270a6a7219f3887a471350c9c Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Fri, 23 Mar 2018 16:10:55 +0100 Subject: [PATCH] Seems ok for bracket flatering and spurs removal. --- .../include/CGAL/Path_on_surface.h | 63 +++++++++++-------- .../Linear_cell_complex/compute_example.cpp | 47 ++++++++------ .../CGAL/Linear_cell_complex_constructors.h | 2 +- 3 files changed, 67 insertions(+), 45 deletions(-) diff --git a/Combinatorial_map/include/CGAL/Path_on_surface.h b/Combinatorial_map/include/CGAL/Path_on_surface.h index 9310d54578a..680a6b16346 100644 --- a/Combinatorial_map/include/CGAL/Path_on_surface.h +++ b/Combinatorial_map/include/CGAL/Path_on_surface.h @@ -63,10 +63,10 @@ public: { m_path.clear(); } std::size_t next_index(std::size_t i) const - { return (i==m_path.size()-1?0:i+1); } + { return (is_closed() && 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); } + { return (is_closed() && i==0?m_path.size()-1:i-1); } Dart_const_handle get_ith_dart(std::size_t i) const { @@ -284,24 +284,32 @@ public: { transform_negative_bracket(begin, end, new_path); } } + // copy all darts starting from begin and going to the dart before end + // from this path to new_path. + void copy_rest_of_path(std::size_t begin, std::size_t end, + std::vector& new_path) + { + assert(end<=length()); + assert(begin<=end); + while(begin!=end) + { + new_path.push_back(get_ith_dart(begin)); + ++begin; + } + } + bool bracket_flattening_one_step() { if (is_empty()) return false; - bool res=false; std::vector new_path; std::size_t i; bool positive=false; - for (i=0; i& path, if (draw) { v.push_back(&path); - display(path.get_map(), v); + // display(path.get_map(), v); } CGAL::Path_on_surface* prevp=&path; @@ -31,33 +31,42 @@ void simplify_path(CGAL::Path_on_surface& path, do { curp=new CGAL::Path_on_surface(*prevp); + /* std::cout<<"+ "; curp->display_negative_turns(); + std::cout<<"- "; curp->display_positive_turns(); + std::cout<<" -> "<bracket_flattening_one_step()) { if (draw) { v.push_back(curp); } prevp=curp; + + /* std::cout<<"+ "; curp->display_negative_turns(); + std::cout<<"- "; curp->display_positive_turns(); + std::cout<remove_spurs()) + { + if (draw) { v.push_back(curp); } + prevp=curp; + + /* std::cout<<"+ "; curp->display_negative_turns(); + std::cout<<"- "; curp->display_positive_turns(); + std::cout<(*prevp); - if (curp->remove_spurs()) - { - if (draw) { v.push_back(curp); } - prevp=curp; - } - else - { - delete curp; - curp=NULL; - } - if (draw) { display(path.get_map(), v); } @@ -245,7 +254,7 @@ void test_all_cases_spurs_and_bracket() generate_negative_bracket_special2(path); std::cout<<"Negative special case 1 (-1 -2^10): "< +"; path.display_positive_turns(); std::cout<<" -"; path.display_negative_turns(); std::cout< #include #include +#include #include #include