From eb1854307d1434c725241d51a7d764f8ca6ff44f Mon Sep 17 00:00:00 2001 From: Francisc Bungiu Date: Wed, 4 Sep 2013 12:30:33 +0300 Subject: [PATCH] trying to resolv bug --- .../CGAL/Simple_polygon_visibility_2.h | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h b/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h index f6575726c6d..fbb0802230c 100644 --- a/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h +++ b/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h @@ -67,6 +67,7 @@ public: p_arr(&arr) { geom_traits = p_arr->geometry_traits(); query_pt_is_vertex = false; + query_pt_is_on_halfedge = false; } bool is_attached() { @@ -77,6 +78,7 @@ public: p_arr = &arr; geom_traits = p_arr->geometry_traits(); query_pt_is_vertex = false; + query_pt_is_on_halfedge = false; } void detach() { @@ -84,6 +86,7 @@ public: geom_traits = NULL; vertices.clear(); query_pt_is_vertex = false; + query_pt_is_on_halfedge = false; } const Input_arrangement_2& arr() { @@ -393,6 +396,7 @@ private: } void left(int& i, Point_2& w, const Point_2& query_pt) { + std::cout << "L w = " << w << std::endl; if (i == vertices.size() - 1) { upcase = FINISH; } @@ -402,25 +406,32 @@ private: w, vertices[i+1]); if (orient == CGAL::LEFT_TURN || orient == CGAL::COLLINEAR) { - upcase = LEFT; + std::cout << "L push " << vertices[i+1] << std::endl; + std::cout << "L w updated to " << vertices[i+1] << std::endl; s.push(vertices[i+1]); w = vertices[i+1]; i++; } else { - Point_2 s_t = s.top(); + std::cout << "L s_Top = " << s_t << std::endl; s.pop(); Point_2 s_t_prev = s.top(); + std::cout << "L s_t_prev = " << s_t_prev << std::endl; + std::cout << "L v[i] = " << vertices[i] << std::endl; + std::cout << "L v[i+1] = " << vertices[i+1] << std::endl; + if (CGAL::Visibility_2::Orientation_2(geom_traits, s_t_prev, vertices[i], vertices[i+1]) == CGAL::RIGHT_TURN) { + std::cout << "L scana\n"; upcase = SCANA; w = vertices[i]; } else { + std::cout << "L right\n"; upcase = RIGHT; w = vertices[i+1]; i++; @@ -434,7 +445,7 @@ private: // Scan s_t, s_t-1, ..., s_1, s_0 for the first edge (s_j, s_j-1) such that // (z, s_j, v_i) is a right turn and (z, s_j-1, v_i) is a left turn, or bool found = false; - + std::cout << "R w = " << w << std::endl; while(!found && upcase == RIGHT) { assert(!s.empty()); Point_2 s_j = s.top(); @@ -530,14 +541,14 @@ private: void scana(int& i, Point_2& w, const Point_2& query_pt) { // Scan v_i, v_i+1, ..., v_n for the first edge to intersect (z, s_t) int k = i; - + std::cout << "scana w = " << w << std::endl; while (k+1 < vertices.size()) { CGAL::Orientation qwv_orient = CGAL::Visibility_2::Orientation_2(geom_traits, query_pt, w, vertices[k+1]); if (qwv_orient == CGAL::LEFT_TURN) { - + std::cout << "scana left turn\n"; Ray_2 s2(query_pt, s.top()); Segment_2 s1(vertices[k], vertices[k+1]); @@ -553,8 +564,9 @@ private: } } else if (qwv_orient == CGAL::COLLINEAR) { - + std::cout << "scana coll\n"; if (!query_pt_is_vertex && !query_pt_is_on_halfedge) { + std::cout << "scana pushing " << vertices[k+1] << std::endl; s.push(vertices[k+1]); w = vertices[k+1]; i = k+1; @@ -564,7 +576,7 @@ private: if ((query_pt_is_vertex || query_pt_is_on_halfedge) && CGAL::Visibility_2::Collinear_are_ordered_along_line_2 (geom_traits, query_pt, w, vertices[k+1])) { - + std::cout << "scana here\n"; s.push(vertices[k+1]); w = vertices[k+1]; i = k+1; @@ -574,6 +586,7 @@ private: } k++; } + std::cout << "scana found w = " << w << " i = " << i << std::endl; } void scanc(int& i, Point_2& w, const Point_2& query_pt) { @@ -582,7 +595,7 @@ private: Point_2 s_t = s.top(); int k = i; Point_2 intersection_pt; - while (k < vertices.size()-1) { + while (k < vertices.size()) { CGAL::Orientation qwv_orient = CGAL::Visibility_2::Orientation_2(geom_traits, query_pt, w, vertices[k]); if (qwv_orient == CGAL::RIGHT_TURN || qwv_orient == CGAL::COLLINEAR) { break;