From e83dc8775dc3747c823f4fc700a1d7c7b24f5984 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 23 Jul 2021 15:12:45 +0200 Subject: [PATCH] fixes after review --- .../self_intersections.h | 21 ++++++++++++------- .../self_intersection_surface_mesh_test.cpp | 4 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h index f15a921b8c9..802aeb583ec 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/self_intersections.h @@ -16,6 +16,7 @@ #ifndef CGAL_POLYGON_MESH_PROCESSING_SELF_INTERSECTIONS #define CGAL_POLYGON_MESH_PROCESSING_SELF_INTERSECTIONS + #include #include @@ -67,8 +68,8 @@ struct Throw_at_count_reached_functor { Output_iterator out; Throw_at_count_reached_functor(std::atomic& counter, - const unsigned int& max, - Output_iterator out) + const unsigned int& max, + Output_iterator out) : counter(counter), max(max), out(out) {} @@ -255,6 +256,10 @@ self_intersections_impl(const FaceRange& face_range, const bool do_limit = !(is_default_parameter(get_parameter(np, internal_np::maximum_number))); const unsigned int maximum_number = choose_parameter(get_parameter(np, internal_np::maximum_number), 0); + if(do_limit && maximum_number == 0) + { + return out; + } unsigned int counter = 0; const unsigned int seed = choose_parameter(get_parameter(np, internal_np::random_seed), 0); CGAL_USE(seed); // used in the random shuffle of the range, which is only done to balance tasks in parallel @@ -442,11 +447,11 @@ self_intersections_impl(const FaceRange& face_range, * \cgalParamNEnd * * \cgalParamNBegin{maximum_number} - * \cgalParamDescription{the maximum number of self intersections that will be computed and returned by the function.} + * \cgalParamDescription{the maximum number of self intersections that will be detected and returned by the function.} * \cgalParamType{unsigned int} - * \cgalParamDefault{the number of self intersections in `face_range`.} + * \cgalParamDefault{No limit.} * \cgalParamExtra{In parallel mode, the number of returned self-intersections is at least `maximum_number` - * (and not exactly that number) as for performance reason no strong synchronization is put on threads.} + * (and not exactly that number) as no strong synchronization is put on threads for performance reasons.} * \cgalParamNEnd * \cgalNamedParamsEnd * @@ -521,11 +526,11 @@ self_intersections(const FaceRange& face_range, * \cgalParamNEnd * * \cgalParamNBegin{maximum_number} - * \cgalParamDescription{the maximum number of self intersections that will be computed and returned by the function.} + * \cgalParamDescription{the maximum number of self intersections that will be detected and returned by the function.} * \cgalParamType{unsigned int} - * \cgalParamDefault{the number of self intersections in `tmesh`.} + * \cgalParamDefault{No limit.} * \cgalParamExtra{In parallel mode, the number of returned self-intersections is at least `maximum_number` - * (and not exactly that number) as for performance reason no strong synchronization is put on threads.} + * (and not exactly that number) as no strong synchronization is put on threads for performance reasons.} * \cgalParamNEnd * \cgalNamedParamsEnd * diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp index df60c8730c5..3c72304618b 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -87,10 +88,9 @@ int test_limited_self_intersections(const char* filename) typedef CGAL::Surface_mesh Mesh; typedef typename boost::graph_traits::face_descriptor face_descriptor; - std::ifstream input(filename); Mesh m; - if ( !input || !(input >> m) ) { + if ( !CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(filename, m) ) { std::cerr << "Error: cannot read file: " << filename << std::endl; return 1; }