From 2fbd64a8e563416a0dfed3b6f0ab80b912be5443 Mon Sep 17 00:00:00 2001 From: kanhuang Date: Thu, 8 Aug 2013 00:28:54 -0400 Subject: [PATCH] consistency of Naive --- .../include/CGAL/Naive_visibility_2.h | 29 +++++++++++-------- .../CGAL/Simple_polygon_visibility_2.h | 2 +- .../include/CGAL/test_model_methods.h | 2 +- .../Visibility_2/test_naive_visibility.cpp | 20 +++++++------ 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Visibility_2/include/CGAL/Naive_visibility_2.h b/Visibility_2/include/CGAL/Naive_visibility_2.h index c2ed814293b..411b6bd77c6 100644 --- a/Visibility_2/include/CGAL/Naive_visibility_2.h +++ b/Visibility_2/include/CGAL/Naive_visibility_2.h @@ -30,7 +30,6 @@ #include #include #include -#include namespace CGAL { @@ -45,6 +44,7 @@ void print(std::vector ps){ template class Naive_visibility_2 { +public: typedef Arrangement_2 Input_arrangement_2; typedef Arrangement_2 Output_arrangement_2; typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; @@ -71,16 +71,14 @@ class Naive_visibility_2 { enum Intersection_type { UNBOUNDED, CORNER, INNER }; -public: - //members - Arrangement_2 arr; + //functions - Naive_visibility_2(const Arrangement_2 &arr):arr(arr), attach_tag(true) {} + Naive_visibility_2(const Input_arrangement_2 &arr):arr_env(arr), attach_tag(true) {} Naive_visibility_2(): attach_tag(false) {} - Face_const_handle visibility_region(const Point_2 &q, Halfedge_const_handle &e, Arrangement_2 &out_arr) { - Arrangement_2 arrc = arr ; //copy of arr; + Face_const_handle visibility_region(const Point_2 &q, Halfedge_const_handle e, Output_arrangement_2 &out_arr) { + Arrangement_2 arrc = arr_env ; //copy of arr; Halfedge_handle ec; //copy of edge; for (Halfedge_handle eh = arrc.edges_begin(); eh != arrc.edges_end(); eh++) { if (eh->source()->point() == e-> source()->point() && eh->target()->point() == e->target()->point()) { @@ -232,7 +230,7 @@ public: } - Face_const_handle visibility_region(const Point_2 &q, Face_const_handle fh, Arrangement_2 &out_arr) { + Face_const_handle visibility_region(const Point_2 &q, Face_const_handle fh, Output_arrangement_2 &out_arr) { std::vector polygon; visibility_region_impl(q, fh, polygon); build_arr(polygon, out_arr); @@ -247,18 +245,25 @@ public: return attach_tag; } - void attach(Arrangement_2 arr) { - this->arr = arr; - this->attach_tag = true; + void attach(const Input_arrangement_2 &arr) { + arr_env = arr; + attach_tag = true; } void detach() { attach_tag = false; } + const Input_arrangement_2& arr() { + return arr_env; + } + private: + //members + Input_arrangement_2 arr_env; bool attach_tag; - // return the intersection of a ray and a segment. if the intersection is a segment, return the end closer to the source of ray. + //----------------------------- + //functions // if there is no intersection, return the source of ray. /*! obtain the vertices of visibility into polygon. these vertices can be used to build output arrangement by build_arr(). diff --git a/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h b/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h index c37545d1ab8..60cd4015713 100644 --- a/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h +++ b/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h @@ -83,7 +83,7 @@ public: vertices.clear(); } - Input_arrangement_2 arr() { + const Input_arrangement_2& arr() { return *p_arr; } diff --git a/Visibility_2/test/Visibility_2/include/CGAL/test_model_methods.h b/Visibility_2/test/Visibility_2/include/CGAL/test_model_methods.h index 5557e6bec8f..d90d26f1345 100644 --- a/Visibility_2/test/Visibility_2/include/CGAL/test_model_methods.h +++ b/Visibility_2/test/Visibility_2/include/CGAL/test_model_methods.h @@ -137,4 +137,4 @@ void test_model_methods() { } } // end CGAL namespace -#endif \ No newline at end of file +#endif diff --git a/Visibility_2/test/Visibility_2/test_naive_visibility.cpp b/Visibility_2/test/Visibility_2/test_naive_visibility.cpp index d8504764b6d..b369786f7c3 100644 --- a/Visibility_2/test/Visibility_2/test_naive_visibility.cpp +++ b/Visibility_2/test/Visibility_2/test_naive_visibility.cpp @@ -27,8 +27,7 @@ #include #include #include -#include -#include +#include #include #include @@ -41,11 +40,12 @@ int main() { typedef Traits_2::Point_2 Point_2; typedef Traits_2::X_monotone_curve_2 Segment_2; typedef CGAL::Arrangement_2 Arrangement_2; - typedef CGAL::Simple_polygon_visibility_2 - Simple_polygon_visibility_2; + typedef CGAL::Naive_visibility_2 + Naive_visibility_2; - CGAL::test_model_methods(); - CGAL::run_tests(1); + CGAL::test_model_methods(); + std::cout << "Running test suite with " << GREEN << "Cartesian" << RESET << " Kernel..." << std::endl; + CGAL::run_tests(1); } { typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; @@ -53,10 +53,12 @@ int main() { typedef Traits_2::Point_2 Point_2; typedef Traits_2::X_monotone_curve_2 Segment_2; typedef CGAL::Arrangement_2 Arrangement_2; - typedef CGAL::Simple_polygon_visibility_2 - Simple_polygon_visibility_2; + typedef CGAL::Naive_visibility_2 + Naive_visibility_2; - CGAL::test_model_methods(); + CGAL::test_model_methods(); + std::cout << "Running test suite with " << GREEN << "EPECK" << RESET << " Kernel..." << std::endl; + CGAL::run_tests(1); } return 0; }