From 34e8ed18f043baa1b018c86bc03b65cde0c29748 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 15 Feb 2017 15:38:09 +0100 Subject: [PATCH] Fix the VC++ warnings reported in Issue #1904 --- Snap_rounding_2/include/CGAL/Snap_rounding_2.h | 2 +- Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h | 6 +++--- .../Surface_mesh_shortest_path/shortest_path_sequence.cpp | 7 ++++--- .../shortest_paths_OpenMesh.cpp | 6 ++++-- .../shortest_paths_multiple_sources.cpp | 4 ++-- .../Surface_mesh_shortest_path/shortest_paths_no_id.cpp | 6 ++++-- .../Surface_mesh_shortest_path/shortest_paths_with_id.cpp | 5 +++-- .../CGAL/Surface_mesh_shortest_path/function_objects.h | 2 +- .../Surface_mesh_shortest_path_test_2.cpp | 8 ++++---- .../Surface_mesh_shortest_path_test_3.cpp | 2 +- .../Surface_mesh_shortest_path_test_4.cpp | 4 ++-- .../Surface_mesh_shortest_path_traits_test.cpp | 2 +- 12 files changed, 30 insertions(+), 24 deletions(-) diff --git a/Snap_rounding_2/include/CGAL/Snap_rounding_2.h b/Snap_rounding_2/include/CGAL/Snap_rounding_2.h index c5dd4b3efea..259e0477929 100644 --- a/Snap_rounding_2/include/CGAL/Snap_rounding_2.h +++ b/Snap_rounding_2/include/CGAL/Snap_rounding_2.h @@ -617,7 +617,7 @@ find_intersected_hot_pixels(Segment_data & seg, } - number_of_intersections = hot_pixels_intersected_set.size(); + number_of_intersections = static_cast(hot_pixels_intersected_set.size()); } /*! */ diff --git a/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h b/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h index 91ca63a466c..a4f21774809 100644 --- a/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h +++ b/Snap_rounding_2/include/CGAL/Snap_rounding_kd_2.h @@ -416,7 +416,7 @@ public: // find the kd trees that have enough candidates (segments with a close // slope) int * kd_counter = new int[number_of_trees]; - int number_of_segments = seg_list.size(); + std::size_t number_of_segments = seg_list.size(); // auxilary directions Direction_list directions; @@ -529,8 +529,8 @@ public: // determine right kd-tree to work on, depending on the segment's slope Direction_2 d = get_direction(s); - int i = 0; - int n = kd_trees_list.size(); + std::size_t i = 0; + std::size_t n = kd_trees_list.size(); bool found = false; typename Kd_triple_list::const_iterator iter = kd_trees_list.begin(); diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp index 08f5889052c..7f5faba8d95 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp @@ -16,6 +16,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron_3; @@ -95,9 +96,9 @@ int main(int argc, char** argv) CGAL::set_halfedgeds_items_id(polyhedron); // pick up a random face - const size_t randSeed = argc > 2 ? std::atoi(argv[2]) : 7915421; + const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; CGAL::Random rand(randSeed); - const int target_face_index = rand.get_int(0, num_faces(polyhedron)); + const int target_face_index = rand.get_int(0, static_cast(num_faces(polyhedron))); face_iterator face_it = faces(polyhedron).first; std::advance(face_it,target_face_index); // ... and define a barycentric coordinates inside the face @@ -109,7 +110,7 @@ int main(int argc, char** argv) // pick a random target point inside a face face_it = faces(polyhedron).first; - std::advance(face_it, rand.get_int(0, num_faces(polyhedron))); + std::advance(face_it, rand.get_int(0, static_cast(num_faces(polyhedron)))); // collect the sequence of simplicies crossed by the shortest path Sequence_collector sequence_collector; diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp index 50827c1296a..4b93682207a 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp @@ -17,6 +17,8 @@ #include #include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef OpenMesh::PolyMesh_ArrayKernelT<> Mesh; @@ -37,9 +39,9 @@ int main(int argc, char** argv) OpenMesh::IO::read_mesh(polyhedron, (argc>1)?argv[1]:"data/elephant.off"); // pick up a random face - const size_t randSeed = argc > 2 ? std::atoi(argv[2]) : 7915421; + const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; CGAL::Random rand(randSeed); - const int target_face_index = rand.get_int(0, num_faces(polyhedron)); + const int target_face_index = rand.get_int(0, static_cast(num_faces(polyhedron))); face_iterator face_it = faces(polyhedron).first; std::advance(face_it,target_face_index); // ... and define a barycentric coordinates inside the face diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp index b0543f422de..4265cc005b2 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp @@ -38,7 +38,7 @@ int main(int argc, char** argv) CGAL::set_halfedgeds_items_id(polyhedron); // pick up some source points inside faces, - const size_t randSeed = argc > 2 ? std::atoi(argv[2]) : 7915421; + const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; CGAL::Random rand(randSeed); // by copying the faces in a vector to get a direct access to faces std::size_t nb_faces=num_faces(polyhedron); @@ -51,7 +51,7 @@ int main(int argc, char** argv) std::vector faceLocations(nb_source_points, Face_location(face_descriptor(), face_location)); for (std::size_t i = 0; i < nb_source_points; ++i) { - faceLocations[i].first=face_vector[rand.get_int(0, nb_faces)]; + faceLocations[i].first=face_vector[rand.get_int(0, static_cast(nb_faces))]; } // construct a shortest path query object and add a range of source points diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp index ae6dbadd78e..ad1619e9f1e 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp @@ -16,6 +16,8 @@ #include #include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron_3; typedef CGAL::Surface_mesh_shortest_path_traits Traits; @@ -45,9 +47,9 @@ int main(int argc, char** argv) input.close(); // pick up a random face - const size_t randSeed = argc > 2 ? std::atoi(argv[2]) : 7915421; + const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; CGAL::Random rand(randSeed); - const int target_face_index = rand.get_int(0, num_faces(polyhedron)); + const int target_face_index = rand.get_int(0, static_cast(num_faces(polyhedron))); face_iterator face_it = faces(polyhedron).first; std::advance(face_it,target_face_index); // ... and define a barycentric coordinates inside the face diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp index aad64662e5e..d471620b220 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp @@ -15,6 +15,7 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Polyhedron_3; @@ -36,9 +37,9 @@ int main(int argc, char** argv) CGAL::set_halfedgeds_items_id(polyhedron); // pick up a random face - const size_t randSeed = argc > 2 ? std::atoi(argv[2]) : 7915421; + const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; CGAL::Random rand(randSeed); - const int target_face_index = rand.get_int(0, num_faces(polyhedron)); + const int target_face_index = rand.get_int(0, static_cast(num_faces(polyhedron))); face_iterator face_it = faces(polyhedron).first; std::advance(face_it,target_face_index); // ... and define a barycentric coordinates inside the face diff --git a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h index de5caec5cbd..6c66102d29d 100644 --- a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h +++ b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/function_objects.h @@ -362,7 +362,7 @@ public: { } - result_type operator() (const Triangle_3& t3, std::size_t edgeIndex, const Segment_2& segment) const + result_type operator() (const Triangle_3& t3, int edgeIndex, const Segment_2& segment) const { Point_3 projectedLocation3d(m_construct_projected_point_3(m_construct_line_3(m_construct_vertex_3(t3, edgeIndex), m_construct_vertex_3(t3, edgeIndex + 1)), m_construct_vertex_3(t3, edgeIndex + 2))); FT scalePoint = m_parametric_distance_along_segment_3(m_construct_segment_3(m_construct_vertex_3(t3, edgeIndex), m_construct_vertex_3(t3, edgeIndex + 1)), projectedLocation3d); diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp index c749ee3c09c..8b5493eea39 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_2.cpp @@ -106,8 +106,8 @@ int main(int argc, char* argv[]) for (size_t i = 0; i < numTests; ++i) { - size_t startVertexIndex = rand.get_int(0, vertices.size()); - size_t endVertexIndex = rand.get_int(0, vertices.size()); + size_t startVertexIndex = rand.get_int(0, static_cast(vertices.size())); + size_t endVertexIndex = rand.get_int(0, static_cast(vertices.size())); vertex_descriptor startVertex = vertices[startVertexIndex]; vertex_descriptor endVertex = vertices[endVertexIndex]; @@ -192,8 +192,8 @@ int main(int argc, char* argv[]) for (size_t i = 0; i < numTests; ++i) { - size_t startFaceIndex = rand.get_int(0, faces.size()); - size_t endFaceIndex = rand.get_int(0, faces.size()); + size_t startFaceIndex = rand.get_int(0, static_cast(faces.size())); + size_t endFaceIndex = rand.get_int(0, static_cast(faces.size())); face_descriptor startFace = faces[startFaceIndex]; face_descriptor endFace = faces[endFaceIndex]; diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp index f39ce7636a8..eb81aa1df7d 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_3.cpp @@ -87,7 +87,7 @@ int main(int argc, char* argv[]) for (size_t i = 0; i < numTrials; ++i) { - size_t faceIndex = random.get_int(0, facesList.size()); + size_t faceIndex = random.get_int(0, static_cast(facesList.size())); face_descriptor face = facesList[faceIndex]; Triangle_3 faceTriangle = CGAL::internal::triangle_from_halfedge(halfedge(face, polyhedron), polyhedron, vertexPointMap); diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp index 7d187c65cee..87020292d7c 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_test_4.cpp @@ -93,7 +93,7 @@ int main(int argc, char* argv[]) for (size_t i = 0; i < numTrials; ++i) { - size_t faceIndex = random.get_int(0, facesList.size()); + size_t faceIndex = random.get_int(0, static_cast(facesList.size())); face_descriptor face = facesList[faceIndex]; Triangle_3 faceTriangle = CGAL::internal::triangle_from_halfedge(halfedge(face, polyhedron), polyhedron, vertexPointMap); @@ -124,7 +124,7 @@ int main(int argc, char* argv[]) { Point_3 currentPoint = get(vertexPointMap, *currVertexIt); - for (size_t i = 0; i < 3; ++i) + for (int i = 0; i < 3; ++i) { if (first) { diff --git a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp index 9d4cbb0cc2a..d3e575d5e68 100644 --- a/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp +++ b/Surface_mesh_shortest_path/test/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits_test.cpp @@ -237,7 +237,7 @@ void nonsimple_flattening_triangle_along_edge() Traits::Point_3(Kernel::FT(5), Kernel::FT(-9), Kernel::FT(7)), Traits::Point_3(Kernel::FT(0), Kernel::FT(4), Kernel::FT(5))); - for (size_t edgeIndex = 0; edgeIndex < 3; ++edgeIndex) + for (int edgeIndex = 0; edgeIndex < 3; ++edgeIndex) { const Kernel::FT baseDistance = CGAL::sqrt(compute_squared_distance_3(sourceTriangle.vertex(edgeIndex), sourceTriangle.vertex(edgeIndex + 1))); const Traits::Vector_2 direction(Kernel::FT(3.0) / Kernel::FT(5.0), Kernel::FT(4.0) / Kernel::FT(5.0));