From faadf52a540c51ef0c893c31997826e9c8a0a46f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 9 Jun 2017 12:08:04 +0200 Subject: [PATCH] make the random generator seeding integer a named parameter --- .../internal/parameters_interface.h | 2 ++ .../random_perturbation.h | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h index 8feab1527d8..c9c5c27313c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h @@ -44,8 +44,10 @@ CGAL_add_named_parameter(number_of_points_per_edge_t, number_of_points_per_edge, CGAL_add_named_parameter(number_of_points_on_edges_t, number_of_points_on_edges, number_of_points_on_edges) CGAL_add_named_parameter(nb_points_per_area_unit_t, nb_points_per_area_unit, number_of_points_per_area_unit) CGAL_add_named_parameter(nb_points_per_distance_unit_t, nb_points_per_distance_unit, number_of_points_per_distance_unit) + //to be documented CGAL_add_named_parameter(face_normal_t, face_normal, face_normal_map) +CGAL_add_named_parameter(random_seed_t, random_seed, random_seed) //internal CGAL_add_named_parameter(weight_calculator_t, weight_calculator, weight_calculator) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h index 79724b84d94..ecd0efb7553 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/random_perturbation.h @@ -46,12 +46,12 @@ namespace Polygon_mesh_processing { namespace internal { - template + template void random_perturbation_impl(PM& tmesh, const double& max_size, VCMap vcmap, VPMap vpmap, - const int seed, + RNG& rng, const GT& gt) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -65,8 +65,6 @@ namespace internal { Tree tree(faces(tmesh).first, faces(tmesh).second, tmesh); tree.accelerate_distance_queries(); - CGAL::Random rng(seed); - typename GT::Construct_translated_point_3 translate = gt.construct_translated_point_3_object(); typename GT::Construct_vector_3 vec @@ -112,6 +110,8 @@ namespace internal { * constrained-or-not status of each vertex of `tmesh`. A constrained vertex * cannot be modified at all during remeshing * \cgalParamEnd +* \cgalParambegin{random_seed} an non-negative integer value to seed the random + number generator, and make the perturbation deterministic * \cgalNamedParamsEnd * */ @@ -149,12 +149,14 @@ void random_perturbation(TriangleMesh& tmesh VCMap vcmap = choose_param(get_param(np, internal_np::vertex_is_constrained), internal::No_constraint_pmap()); + unsigned int seed = choose_param(get_param(np, internal_np::random_seed), -1); + internal::random_perturbation_impl(tmesh, - perturbation_max_size, - vcmap, - vpmap, - 0/*seed*/, - gt); + perturbation_max_size, + vcmap, + vpmap, + ((seed == -1) ? CGAL::Random() : CGAL::Random(seed)), + gt); #ifdef CGAL_PMP_RANDOM_PERTURBATION_VERBOSE t.stop();