From 8cf04d6e89fcd5e44405d2bc853cc505e5d5b804 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Mon, 30 Mar 2015 16:52:19 +0200 Subject: [PATCH] Fixed all compiler warnings. Fixed unsigned/signed int comparisons. Added missing returns statements. Removed unused local typedefs. --- .../CGAL/Rotational_sweep_visibility_2.h | 31 +++++---- .../CGAL/Simple_polygon_visibility_2.h | 24 ++++--- .../CGAL/Visibility_2/visibility_utils.h | 17 ++--- .../include/CGAL/test_model_methods.h | 29 +++------ .../Visibility_2/include/CGAL/test_utils.h | 63 +++++-------------- .../test_rotational_visibility.cpp | 4 -- .../Visibility_2/test_simple_visibility.cpp | 4 -- .../test/Visibility_2/test_star_shape.cpp | 6 +- 8 files changed, 67 insertions(+), 111 deletions(-) diff --git a/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h b/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h index 89d0d07c807..b8eb08d98d4 100644 --- a/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h +++ b/Visibility_2/include/CGAL/Rotational_sweep_visibility_2.h @@ -123,7 +123,10 @@ private: case LEFT_TURN: return 2; } + + return -1; } + bool operator() (const EH& e1, const EH& e2) const { if (e1 == e2) return false; @@ -232,13 +235,15 @@ private: return true; } } + + return false; } }; - - const Geometry_traits_2 *geom_traits; const Arrangement_2 *p_arr; + const Geometry_traits_2 *geom_traits; + mutable Point_2 q; //query point mutable Points polygon; //visibility polygon @@ -257,10 +262,12 @@ private: mutable VH cone_end1; //an end of visibility cone mutable VH cone_end2; //another end of visibility cone - mutable int cone_end1_idx; //index of cone_end1->point() in + mutable typename Points::size_type cone_end1_idx; + //index of cone_end1->point() in //visibility polygon - mutable int cone_end2_idx; //index of cone_end2->point() in + mutable typename Points::size_type cone_end2_idx; + //index of cone_end2->point() in //visibility polygon mutable bool is_vertex_query; @@ -317,7 +324,7 @@ public: visibility_region_impl(e->face(), q); //decide which inside of the visibility butterfly is needed. - int small_idx, big_idx; + typename Points::size_type small_idx, big_idx; if ( cone_end1_idx < cone_end2_idx ) { small_idx = cone_end1_idx; big_idx = cone_end2_idx; @@ -326,7 +333,7 @@ public: small_idx = cone_end2_idx; big_idx = cone_end1_idx; } - int next_idx = small_idx + 1; + typename Points::size_type next_idx = small_idx + 1; bool is_between; //indicate whether the shape between small_idx and big_idx is the visibility //region required. @@ -367,7 +374,7 @@ public: else { Points polygon_out(polygon.begin(), first+1); if (is_vertex_query) polygon_out.push_back(q); - for (int i = big_idx; i != polygon.size(); i++) { + for (typename Points::size_type i = big_idx; i != polygon.size(); i++) { polygon_out.push_back(polygon[i]); } Visibility_2::report_while_handling_needles @@ -566,17 +573,17 @@ private: else remove_ehs.push_back(e); } - int insert_cnt = insert_ehs.size(); - int remove_cnt = remove_ehs.size(); + typename EHs::size_type insert_cnt = insert_ehs.size(); + typename EHs::size_type remove_cnt = remove_ehs.size(); if (insert_cnt == 1 && remove_cnt == 1) { const EH& ctemp_eh = *active_edges.find(remove_ehs.front()); EH& temp_eh = const_cast(ctemp_eh); temp_eh = insert_ehs.front(); } else { - for (int j=0; j!=remove_cnt; j++) + for (typename EHs::size_type j=0; j!=remove_cnt; j++) active_edges.erase(remove_ehs[j]); - for (int j=0; j!=insert_cnt; j++) + for (typename EHs::size_type j=0; j!=insert_cnt; j++) active_edges.insert(insert_ehs[j]); } @@ -919,7 +926,7 @@ private: } template - void conditional_regularize(VARR& arr_out, CGAL::Tag_false) const { + void conditional_regularize(VARR&, CGAL::Tag_false) const { //do nothing } diff --git a/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h b/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h index db37298e9b0..a7de0cdcebb 100644 --- a/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h +++ b/Visibility_2/include/CGAL/Simple_polygon_visibility_2.h @@ -224,7 +224,7 @@ private: /*! No need to regularize output if flag is set to false*/ template - void conditional_regularize(VARR& out_arr, CGAL::Tag_false) const { + void conditional_regularize(VARR&, CGAL::Tag_false) const { //do nothing } @@ -308,10 +308,12 @@ private: circ->source()->incident_halfedges(); Halfedge_around_vertex_const_circulator incident_curr = incident_circ; + Ccb_halfedge_const_circulator incident_next; + do { if (incident_curr->face() == face) { - Ccb_halfedge_const_circulator incident_next = incident_curr; + incident_next = incident_curr; ++incident_next; if (Visibility_2::orientation_2(traits, @@ -323,10 +325,12 @@ private: incident_next->target()->point(), q) == LEFT_TURN) { - return incident_next; + break; } } } while (++incident_curr != incident_circ); + + return incident_next; } @@ -368,13 +372,15 @@ private: scana(i, w, q); break; case SCANB: - scanb(i, w, q); + scanb(i, w); break; case SCANC: - scanc(i, w, q); + scanc(i, w); break; case SCAND: - scand(i, w, q); + scand(i, w); + break; + case FINISH: break; } if ( upcase == LEFT ) { @@ -581,7 +587,7 @@ private: } /*! Find the first edge interecting the segment (v_0, s_t) */ - void scanb(int& i, Point_2& w, const Point_2& q) const { + void scanb(int& i, Point_2& w) const { if ( i == vertices.size() - 1 ) { upcase = FINISH; return; @@ -602,7 +608,7 @@ private: /*! Finds the exit from a general front hidden window by finding the first vertex to the right of the ray defined by the query_point and w*/ - void scanc(int& i, Point_2& w, const Point_2& q) const { + void scanc(int& i, Point_2& w) const { Point_2 u; int k = scan_edges( i, s.top(), w, u, false ); upcase = RIGHT; @@ -611,7 +617,7 @@ private: } /*! find the first edge intersecting the given window (s_t, w) */ - void scand(int& i, Point_2& w, const Point_2& q) const { + void scand(int& i, Point_2& w) const { Point_2 u; int k = scan_edges( i, s.top(), w, u, false ); upcase = LEFT; diff --git a/Visibility_2/include/CGAL/Visibility_2/visibility_utils.h b/Visibility_2/include/CGAL/Visibility_2/visibility_utils.h index 3107a89f5d9..46a2c2247e1 100644 --- a/Visibility_2/include/CGAL/Visibility_2/visibility_utils.h +++ b/Visibility_2/include/CGAL/Visibility_2/visibility_utils.h @@ -213,10 +213,11 @@ void report_while_handling_needles( typedef typename Visibility_2::Arrangement_2 Arrangement_2; typedef typename Arrangement_2::Point_2 Point_2; typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; typedef typename Geometry_traits_2::Segment_2 Segment_2; - typedef typename Geometry_traits_2::Direction_2 Direction_2; + + typedef typename Visibility_arrangement_2::Halfedge_handle Halfedge_handle; + typedef typename Visibility_arrangement_2::Vertex_handle Vertex_handle; + typename std::vector::size_type i = 0; @@ -232,16 +233,16 @@ void report_while_handling_needles( points.push_back(points[i]); - typename Visibility_arrangement_2::Halfedge_handle he_handle; + Halfedge_handle he_handle; //the handle of vertex where the next segment is inserted - typename Visibility_arrangement_2::Vertex_handle v_trg; + Vertex_handle v_trg; //the handle of vertex inserted first - typename Visibility_arrangement_2::Vertex_handle v_fst; + Vertex_handle v_fst; //the handle of vertex of the end of a needle - typename Visibility_arrangement_2::Vertex_handle v_needle_end; + Vertex_handle v_needle_end; v_trg = v_fst = arr_out.insert_in_face_interior(points[i], @@ -250,7 +251,7 @@ void report_while_handling_needles( //find a point that is right after a needle while (i+1 < points.size()) { if ( collinear(traits, points[i], points[i+1], q)) { - typename Visibility_arrangement_2::Vertex_handle v_needle_begin = v_trg; + Vertex_handle v_needle_begin = v_trg; std::vector forward_needle; //vertices of the needle that are not //between q and v_needle_begin; 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 361b794df12..32d6dbfda16 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 @@ -33,15 +33,11 @@ template void test_model_methods_for_arr( typename Visibility_2::Arrangement_2 &arr) { - typedef typename Visibility_2::Arrangement_2 - Arrangement_2; - typedef typename Visibility_2::Traits_2 Traits_2; - typedef typename Arrangement_2::Point_2 - Point_2; - typedef typename Arrangement_2::Geometry_traits_2::Segment_2 - Segment_2; + typedef typename Visibility_2::Arrangement_2 Arrangement_2; + typedef typename Arrangement_2::Point_2 Point_2; - typedef typename Visibility_arrangement_2::Face_handle VFH; + + typedef typename Visibility_arrangement_2::Face_handle VFH; Visibility_2 visibility; @@ -139,19 +135,10 @@ void test_model_methods_for_arr( template void test_model_methods() { - // Check concept obediance - typedef typename Visibility_2::Arrangement_2 - Arrangement_2; - typedef typename Arrangement_2::Point_2 Point_2; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Visibility_2::Regularization_category Regularization_category; - typedef typename Visibility_2::Supports_general_polygon_category - Supports_general_polygon_category; - typedef typename Visibility_2::Supports_simple_polygon_category - Supports_simple_polygon_category; - typedef typename Arrangement_2::Geometry_traits_2::Segment_2 - Segment_2; + typedef typename Visibility_2::Arrangement_2 Arrangement_2; + typedef typename Arrangement_2::Point_2 Point_2; + typedef typename Arrangement_2::Geometry_traits_2::Segment_2 Segment_2; + Point_2 p1(0, 0), p2(8, 0), p3(8, 8), p4(0, 8); std::vector seg_sq; diff --git a/Visibility_2/test/Visibility_2/include/CGAL/test_utils.h b/Visibility_2/test/Visibility_2/include/CGAL/test_utils.h index 8215d8b6c94..441cd0bda4e 100644 --- a/Visibility_2/test/Visibility_2/include/CGAL/test_utils.h +++ b/Visibility_2/test/Visibility_2/include/CGAL/test_utils.h @@ -49,9 +49,7 @@ template typename Arrangement_2::Halfedge_handle get_initial_halfedge(const Arrangement_2 &arr) { typedef typename Arrangement_2::Vertex Vertex; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator; - typedef typename Arrangement_2::Halfedge Halfedge; typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; // find the min vertex @@ -90,11 +88,6 @@ typename Arrangement_2::Halfedge_handle get_initial_halfedge(const Arrangement_2 */ template bool test_are_equal(const ARR1 &arr1, const ARR2 &arr2) { - - typedef typename ARR1::Geometry_traits_2 Geometry_traits_2; - typedef typename Geometry_traits_2::Segment_2 Segment_2; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename ARR1::Halfedge_handle HE1; typedef typename ARR2::Halfedge_handle HE2; @@ -160,7 +153,7 @@ bool test_are_equal(const ARR1 &arr1, const ARR2 &arr2) { template Number_type string2num(const std::string& s) { - int i; + typename std::string::size_type i; if (s.find("/") != std::string::npos) { i = s.find("/"); std::string p = s.substr(0, i); @@ -477,6 +470,8 @@ void test_interface() { // must have const arrangement_2(); const Arrangement_2& a = vis.arrangement_2(); + visibility.attach(a); + // must have const is_attached(); vis.is_attached(); @@ -495,7 +490,6 @@ void run_tests_with_changes_to_arr() { typedef typename Arrangement_2::Face_const_handle Face_const_handle; typedef typename Geometry_traits_2::Segment_2 Segment_2; typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::FT Number_type; bool all_passed = true; @@ -861,11 +855,6 @@ bool is_star_shape( const Arrangement_2& arr) { typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; - typedef typename Arrangement_2::Edge_iterator Edge_iterator; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::Segment_2 Segment_2; // this test is written for an arr that contains on star shaped polygon if (arr.number_of_faces()!=2){ @@ -1112,20 +1101,10 @@ void simple_benchmark(Visibility_2_fst &visibility_fst, const Query_choice &choice, std::ifstream &input) { - typedef typename Visibility_2_fst::Arrangement_2 - Arrangement_2; - typedef typename Arrangement_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; + typedef typename Visibility_2_fst::Arrangement_2 Arrangement_2; + typedef typename Arrangement_2::Face_const_iterator Face_const_iterator; typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Hole_const_iterator Hole_const_iterator; - typedef typename Arrangement_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Arrangement_2::Ccb_halfedge_const_circulator - Ccb_halfedge_const_circulator; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::Segment_2 Segment_2; assert(Visibility_2_fst::Regularization_category::value == Visibility_2_snd::Regularization_category::value); @@ -1211,18 +1190,17 @@ void pure_benchmark_one_unit( double& qtime, int& query_cnt) { - typedef typename Visibility_2::Arrangement_2 Arrangement_2; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Visibility_2::Arrangement_2 Visibility_arrangement_2; + typedef typename Visibility_2::Arrangement_2 Arrangement_2; + typedef typename Visibility_2::Arrangement_2 Visibility_arrangement_2; typedef typename Arrangement_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; + Halfedge_const_handle; + typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; typedef typename Arrangement_2::Ccb_halfedge_const_circulator Ccb_halfedge_const_circulator; - typedef typename Visibility_arrangement_2::Face_handle Face_handle; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::FT Number_type; + typedef typename Visibility_arrangement_2::Face_handle Face_handle; + typedef typename Geometry_traits_2::Point_2 Point_2; + typedef typename Geometry_traits_2::FT Number_type; typedef Timer Benchmark_timer; Benchmark_timer timer; @@ -1290,20 +1268,10 @@ void pure_benchmark( Visibility_2 &visibility, const Query_choice &choice, std::ifstream &input) { - typedef typename Visibility_2::Arrangement_2 - Arrangement_2; - typedef typename Arrangement_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; + typedef typename Visibility_2::Arrangement_2 Arrangement_2; + typedef typename Arrangement_2::Face_const_iterator Face_const_iterator; typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Hole_const_iterator Hole_const_iterator; - typedef typename Arrangement_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Arrangement_2::Ccb_halfedge_const_circulator - Ccb_halfedge_const_circulator; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::Segment_2 Segment_2; Arrangement_2 arr; create_arrangement_from_env_file(arr, input); @@ -1396,7 +1364,6 @@ void test_star_shape_one_face( typename Visibility_2::Arrangement_2 &arr, typedef typename Visibility_2::Arrangement_2 Visibility_arrangement_2; typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; typedef typename Arrangement_2::Ccb_halfedge_const_circulator @@ -1405,7 +1372,6 @@ void test_star_shape_one_face( typename Visibility_2::Arrangement_2 &arr, typedef typename Visibility_arrangement_2::Face_handle Face_handle; typedef typename Geometry_traits_2::Point_2 Point_2; typedef typename Geometry_traits_2::FT Number_type; - typedef Timer Benchmark_timer; visibility.attach(arr); @@ -1478,7 +1444,6 @@ void test_star_shape(Visibility_2 &visibility, Halfedge_const_handle; typedef typename Visibility_arrangement_2::Ccb_halfedge_const_circulator Ccb_halfedge_const_circulator; - typedef typename Geometry_traits_2::Point_2 Point_2; typedef typename Geometry_traits_2::Segment_2 Segment_2; Arrangement_2 arr; diff --git a/Visibility_2/test/Visibility_2/test_rotational_visibility.cpp b/Visibility_2/test/Visibility_2/test_rotational_visibility.cpp index e085ae2afad..513950210ee 100644 --- a/Visibility_2/test/Visibility_2/test_rotational_visibility.cpp +++ b/Visibility_2/test/Visibility_2/test_rotational_visibility.cpp @@ -38,8 +38,6 @@ int main() { { typedef CGAL::Cartesian Kernel; typedef CGAL::Arr_segment_traits_2 Traits_2; - typedef Traits_2::Point_2 Point_2; - typedef Traits_2::X_monotone_curve_2 Segment_2; typedef CGAL::Arrangement_2 Arrangement_2; { typedef CGAL::Rotational_sweep_visibility_2 @@ -58,8 +56,6 @@ int main() { }{ typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Arr_segment_traits_2 Traits_2; - typedef Traits_2::Point_2 Point_2; - typedef Traits_2::X_monotone_curve_2 Segment_2; typedef CGAL::Arrangement_2 Arrangement_2; { typedef CGAL::Rotational_sweep_visibility_2 diff --git a/Visibility_2/test/Visibility_2/test_simple_visibility.cpp b/Visibility_2/test/Visibility_2/test_simple_visibility.cpp index a32c683b116..c6b92124fdc 100644 --- a/Visibility_2/test/Visibility_2/test_simple_visibility.cpp +++ b/Visibility_2/test/Visibility_2/test_simple_visibility.cpp @@ -39,8 +39,6 @@ int main() { typedef CGAL::Gmpq Number_type; typedef CGAL::Cartesian Kernel; typedef CGAL::Arr_segment_traits_2 Traits_2; - 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; @@ -54,8 +52,6 @@ int main() { { typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Arr_segment_traits_2 Traits_2; - 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; diff --git a/Visibility_2/test/Visibility_2/test_star_shape.cpp b/Visibility_2/test/Visibility_2/test_star_shape.cpp index 8678724c2d3..e380d3e456d 100644 --- a/Visibility_2/test/Visibility_2/test_star_shape.cpp +++ b/Visibility_2/test/Visibility_2/test_star_shape.cpp @@ -37,11 +37,9 @@ int main(int argc, char* argv[]) { { - typedef CGAL::Gmpq Number_type; + typedef CGAL::Gmpq Number_type; typedef CGAL::Cartesian Kernel; - typedef CGAL::Arr_segment_traits_2 Traits_2; - typedef Traits_2::Point_2 Point_2; - typedef Traits_2::X_monotone_curve_2 Segment_2; + typedef CGAL::Arr_segment_traits_2 Traits_2; typedef CGAL::Arrangement_2 Arrangement_2; typedef CGAL::Simple_polygon_visibility_2 Simple_polygon_visibility_2;