trying to resolv bug

This commit is contained in:
Francisc Bungiu 2013-09-04 12:30:33 +03:00
parent 6c0a16623b
commit eb1854307d
1 changed files with 21 additions and 8 deletions

View File

@ -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<Geometry_traits_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;