mirror of https://github.com/CGAL/cgal
progress with needle test cases
This commit is contained in:
parent
1888cfc93d
commit
538e5ca1ee
|
|
@ -95,12 +95,10 @@ public:
|
||||||
Output_Arrangement_2 &out_arr
|
Output_Arrangement_2 &out_arr
|
||||||
) {
|
) {
|
||||||
|
|
||||||
std::vector<Point_2> temp_vertices;
|
|
||||||
bool query_point_on_source = false;
|
|
||||||
|
|
||||||
if (q != he->source()->point()) {
|
if (q != he->source()->point()) {
|
||||||
if (q != he->target()->point()) {
|
if (q != he->target()->point()) {
|
||||||
vertices.push_back(q);
|
s.push(q);
|
||||||
|
// vertices.push_back(q);
|
||||||
vertices.push_back(he->target()->point());
|
vertices.push_back(he->target()->point());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -108,38 +106,45 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
query_point_on_source = true;
|
|
||||||
vertices.push_back(q);
|
vertices.push_back(q);
|
||||||
vertices.push_back(he->target()->point());
|
vertices.push_back(he->target()->point());
|
||||||
}
|
}
|
||||||
|
|
||||||
typename Input_Arrangement_2::Face_const_handle face = he->face();
|
typename Input_Arrangement_2::Face_const_handle face = he->face();
|
||||||
typename Input_Arrangement_2::Ccb_halfedge_const_circulator circ = face->outer_ccb();
|
typename Input_Arrangement_2::Ccb_halfedge_const_circulator circ = face->outer_ccb();
|
||||||
typename Input_Arrangement_2::Ccb_halfedge_const_circulator curr = circ;
|
typename Input_Arrangement_2::Ccb_halfedge_const_circulator curr;
|
||||||
typename Input_Arrangement_2::Halfedge_const_handle he_handle = curr;
|
typename Input_Arrangement_2::Halfedge_const_handle he_handle = circ;
|
||||||
|
|
||||||
while (he_handle != he) {
|
while (he_handle != he) {
|
||||||
|
he_handle = circ;
|
||||||
|
circ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
curr = circ;
|
||||||
|
curr++;
|
||||||
|
|
||||||
|
he_handle = curr;
|
||||||
|
vertices.push_back(Point_2(he_handle->source()->point()));
|
||||||
|
|
||||||
|
typename Input_Arrangement_2::Ccb_halfedge_const_circulator next;
|
||||||
|
next = curr;
|
||||||
|
next++;
|
||||||
|
|
||||||
|
while (curr != circ) {
|
||||||
he_handle = curr;
|
he_handle = curr;
|
||||||
|
Point_2 curr_vertex = he_handle->target()->point();
|
||||||
|
vertices.push_back(curr_vertex);
|
||||||
curr++;
|
curr++;
|
||||||
|
next = curr;
|
||||||
|
next++;
|
||||||
}
|
}
|
||||||
|
vertices.push_back(q);
|
||||||
do {
|
|
||||||
he_handle = curr;
|
|
||||||
Point_2 curr_vertex = he->target()->point();
|
|
||||||
temp_vertices.push_back(curr_vertex);
|
|
||||||
|
|
||||||
} while (++curr != circ);
|
|
||||||
|
|
||||||
if (!query_point_on_source) {
|
|
||||||
vertices.push_back(he->source()->point());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Vertices:" << std::endl;
|
std::cout << "Vertices:" << std::endl;
|
||||||
for (unsigned int i = 0 ; i < vertices.size() ; i++) {
|
for (unsigned int i = 0 ; i < vertices.size() ; i++) {
|
||||||
std::cout << vertices[i] << std::endl;
|
std::cout << vertices[i] << std::endl;
|
||||||
}
|
}
|
||||||
std::cout << " end" << std::endl;
|
|
||||||
// visibility_region_impl(q, out_arr);
|
visibility_region_impl(q, out_arr);
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
const Input_Arrangement_2 *p_arr;
|
const Input_Arrangement_2 *p_arr;
|
||||||
|
|
@ -161,7 +166,7 @@ protected:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void visibility_region_impl(Point_2 &q, Output_Arrangement_2 &out_arr) {
|
void visibility_region_impl(const Point_2 &q, Output_Arrangement_2 &out_arr) {
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Point_2 w;
|
Point_2 w;
|
||||||
|
|
@ -181,7 +186,7 @@ protected:
|
||||||
w = vertices[1];
|
w = vertices[1];
|
||||||
s.push(vertices[0]);
|
s.push(vertices[0]);
|
||||||
}
|
}
|
||||||
int counter = 0;
|
|
||||||
do {
|
do {
|
||||||
std::cout << "CASE: " << upcase << std::endl;
|
std::cout << "CASE: " << upcase << std::endl;
|
||||||
switch(upcase) {
|
switch(upcase) {
|
||||||
|
|
@ -222,6 +227,7 @@ protected:
|
||||||
if ((*vertex_new) != (s_t_prev) && (*vertex_new != s_t)) {
|
if ((*vertex_new) != (s_t_prev) && (*vertex_new != s_t)) {
|
||||||
std::cout << "switch to scanb" << std::endl;
|
std::cout << "switch to scanb" << std::endl;
|
||||||
upcase = SCANB;
|
upcase = SCANB;
|
||||||
|
std::cout << "pushing " << *vertex_new << std::endl;
|
||||||
s.push(*vertex_new);
|
s.push(*vertex_new);
|
||||||
}
|
}
|
||||||
else { // Do not alter stack if it doesn't intersect - push back s_t
|
else { // Do not alter stack if it doesn't intersect - push back s_t
|
||||||
|
|
@ -237,10 +243,9 @@ protected:
|
||||||
s.push(s_t);
|
s.push(s_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (counter == 8) {
|
if (i == 9) {
|
||||||
// exit(0);
|
// exit(0);
|
||||||
}
|
}
|
||||||
counter++;
|
|
||||||
} while(upcase != FINISH);
|
} while(upcase != FINISH);
|
||||||
|
|
||||||
std::cout << "RESULT: " << std::endl;
|
std::cout << "RESULT: " << std::endl;
|
||||||
|
|
@ -374,9 +379,11 @@ protected:
|
||||||
}
|
}
|
||||||
else if ((orientation(query_pt, s_j, vertices[i]) == CGAL::RIGHT_TURN)
|
else if ((orientation(query_pt, s_j, vertices[i]) == CGAL::RIGHT_TURN)
|
||||||
&& (orientation(query_pt, s_j_prev, vertices[i]) == CGAL::COLLINEAR)) {
|
&& (orientation(query_pt, s_j_prev, vertices[i]) == CGAL::COLLINEAR)) {
|
||||||
|
std::cout << "we're here in collinear" << std::endl;
|
||||||
found = true;
|
found = true;
|
||||||
upcase = LEFT;
|
upcase = LEFT;
|
||||||
|
std::cout << "right::pushing " << vertices[i] << std::endl;
|
||||||
|
std::cout << "right::pushing " << vertices[i+1] << std::endl;
|
||||||
s.push(vertices[i]);
|
s.push(vertices[i]);
|
||||||
s.push(vertices[i+1]);
|
s.push(vertices[i+1]);
|
||||||
w = vertices[i+1];
|
w = vertices[i+1];
|
||||||
|
|
@ -429,7 +436,11 @@ protected:
|
||||||
upcase = LEFT;
|
upcase = LEFT;
|
||||||
i = k+1;
|
i = k+1;
|
||||||
s.push(intersection_pt);
|
s.push(intersection_pt);
|
||||||
s.push(vertices[k+1]);
|
std::cout << "scana::pushing " << intersection_pt << std::endl;
|
||||||
|
if (intersection_pt != vertices[k+1]) {
|
||||||
|
std::cout << "scana::pushing " << vertices[k+1] << std::endl;
|
||||||
|
s.push(vertices[k+1]);
|
||||||
|
}
|
||||||
w = vertices[k+1];
|
w = vertices[k+1];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -450,14 +461,17 @@ protected:
|
||||||
Segment_2 s2(s_t, vertices[vertices.size()-1]);
|
Segment_2 s2(s_t, vertices[vertices.size()-1]);
|
||||||
CGAL::Object result = intersection(s1, s2);
|
CGAL::Object result = intersection(s1, s2);
|
||||||
if (const Point_2 *ipoint = CGAL::object_cast<Point_2>(&result)) {
|
if (const Point_2 *ipoint = CGAL::object_cast<Point_2>(&result)) {
|
||||||
intersection_pt = *ipoint;
|
if (*ipoint != s_t) {
|
||||||
found = true;
|
intersection_pt = *ipoint;
|
||||||
break;
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
if ((intersection_pt == vertices[k+1]) && (intersection_pt == vertices[vertices.size()-1])) {
|
if ((intersection_pt == vertices[k+1]) && (intersection_pt == vertices[vertices.size()-1])) {
|
||||||
|
std::cout << "scanb::done\n";
|
||||||
upcase = FINISH;
|
upcase = FINISH;
|
||||||
w = vertices[vertices.size()-1];
|
w = vertices[vertices.size()-1];
|
||||||
s.push(vertices[vertices.size()-1]);
|
s.push(vertices[vertices.size()-1]);
|
||||||
|
|
@ -468,6 +482,10 @@ protected:
|
||||||
w = intersection_pt;
|
w = intersection_pt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
upcase = LEFT;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scanc(int &i,Point_2 &w, const Point_2 &query_pt) {
|
void scanc(int &i,Point_2 &w, const Point_2 &query_pt) {
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,10 @@ bool simple_polygon_halfedge_test_case(std::ifstream &input, std::ifstream &corr
|
||||||
Segment_2 curr_seg(hit->source()->point(), hit->target()->point());
|
Segment_2 curr_seg(hit->source()->point(), hit->target()->point());
|
||||||
if (curr_seg.has_on(query_pt)) {
|
if (curr_seg.has_on(query_pt)) {
|
||||||
visibility.visibility_region(query_pt, hit, out_arr);
|
visibility.visibility_region(query_pt, hit, out_arr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::cout << "exited" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
// return CGAL::test_are_equal<Arrangement_2>(correct_out_arr, out_arr);
|
// return CGAL::test_are_equal<Arrangement_2>(correct_out_arr, out_arr);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,13 +88,17 @@ bool test_are_equal(const _Arrangement_2 &arr1, const _Arrangement_2 &arr2) {
|
||||||
}
|
}
|
||||||
eit_fst_mid = eit_fst;
|
eit_fst_mid = eit_fst;
|
||||||
eit_snd_mid = eit_snd;
|
eit_snd_mid = eit_snd;
|
||||||
|
|
||||||
// Now we know where to start the edge comparisons from
|
// Now we know where to start the edge comparisons from
|
||||||
for (eit_fst, eit_snd ; eit_fst != arr1.edges_end(),
|
for (eit_fst, eit_snd ; eit_fst != arr1.edges_end(),
|
||||||
eit_snd != arr2.edges_end() ; ++eit_fst, ++eit_snd) {
|
eit_snd != arr2.edges_end() ; ++eit_fst, ++eit_snd) {
|
||||||
|
|
||||||
Segment_2 seg_fst = eit_fst->curve();
|
Segment_2 seg_fst = eit_fst->curve();
|
||||||
Segment_2 seg_snd = eit_snd->curve();
|
Segment_2 seg_snd = eit_snd->curve();
|
||||||
if (seg_fst != seg_snd) {
|
std::cout << seg_fst << std::endl;
|
||||||
|
std::cout << seg_snd << std::endl;
|
||||||
|
if ((seg_fst.source() != seg_snd.source() || seg_fst.target() != seg_snd.target()) &&
|
||||||
|
(seg_fst.source() != seg_snd.target() || seg_fst.target() != seg_snd.source())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ int main() {
|
||||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||||
|
|
||||||
// First read arrangement
|
// First read arrangement
|
||||||
/* Arrangement_2 arr;
|
Arrangement_2 arr;
|
||||||
std::ifstream input("./data/simple_polygon_test_case_1.in");
|
std::ifstream input("./data/simple_polygon_test_case_1.in");
|
||||||
CGAL::create_arrangement_from_file<Arrangement_2>(arr, input);
|
CGAL::create_arrangement_from_file<Arrangement_2>(arr, input);
|
||||||
CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> visibility;
|
CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> visibility;
|
||||||
|
|
@ -39,11 +39,11 @@ int main() {
|
||||||
assert(false == (CGAL::test_is_attached<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> >(visibility)));
|
assert(false == (CGAL::test_is_attached<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> >(visibility)));
|
||||||
visibility.attach(arr);
|
visibility.attach(arr);
|
||||||
assert(true == (CGAL::test_are_equal<Arrangement_2>(arr, visibility.arr())));
|
assert(true == (CGAL::test_are_equal<Arrangement_2>(arr, visibility.arr())));
|
||||||
*/
|
|
||||||
// Run test cases from https://cgal.geometryfactory.com/CGAL/Members/wiki/Visibility/TestCases
|
// Run test cases from https://cgal.geometryfactory.com/CGAL/Members/wiki/Visibility/TestCases
|
||||||
/* assert(true == (CGAL::simple_polygon_test_case_1<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
assert(true == (CGAL::simple_polygon_test_case_1<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
||||||
assert(true == (CGAL::simple_polygon_test_case_2<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
assert(true == (CGAL::simple_polygon_test_case_2<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
||||||
assert(true == (CGAL::simple_polygon_test_case_3<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));*/
|
assert(true == (CGAL::simple_polygon_test_case_3<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
||||||
assert(true == (CGAL::simple_polygon_test_case_4<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
assert(true == (CGAL::simple_polygon_test_case_4<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -54,7 +54,7 @@ int main() {
|
||||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||||
|
|
||||||
// First read arrangement
|
// First read arrangement
|
||||||
/* Arrangement_2 arr;
|
Arrangement_2 arr;
|
||||||
std::ifstream input("./data/simple_polygon_test_case_1.in");
|
std::ifstream input("./data/simple_polygon_test_case_1.in");
|
||||||
CGAL::create_arrangement_from_file<Arrangement_2>(arr, input);
|
CGAL::create_arrangement_from_file<Arrangement_2>(arr, input);
|
||||||
CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> visibility;
|
CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> visibility;
|
||||||
|
|
@ -65,11 +65,11 @@ int main() {
|
||||||
assert(false == (CGAL::test_is_attached<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> >(visibility)));
|
assert(false == (CGAL::test_is_attached<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2> >(visibility)));
|
||||||
visibility.attach(arr);
|
visibility.attach(arr);
|
||||||
assert(true == (CGAL::test_are_equal<Arrangement_2>(arr, visibility.arr())));
|
assert(true == (CGAL::test_are_equal<Arrangement_2>(arr, visibility.arr())));
|
||||||
*/
|
|
||||||
// Run test cases from https://cgal.geometryfactory.com/CGAL/Members/wiki/Visibility/TestCases
|
// Run test cases from https://cgal.geometryfactory.com/CGAL/Members/wiki/Visibility/TestCases
|
||||||
/* assert(true == (CGAL::simple_polygon_test_case_1<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
assert(true == (CGAL::simple_polygon_test_case_1<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
||||||
assert(true == (CGAL::simple_polygon_test_case_2<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
assert(true == (CGAL::simple_polygon_test_case_2<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
||||||
assert(true == (CGAL::simple_polygon_test_case_3<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));*/
|
assert(true == (CGAL::simple_polygon_test_case_3<CGAL::Visibility_2::Simple_visibility_2<Arrangement_2>, Arrangement_2> ()));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue