add random generator np for sampling

This commit is contained in:
Sébastien Loriot 2021-10-20 09:24:13 +02:00
parent ed3503d238
commit f55e482d0f
2 changed files with 24 additions and 2 deletions

View File

@ -128,6 +128,7 @@ CGAL_add_named_parameter(match_faces_t, match_faces, match_faces)
CGAL_add_named_parameter(face_epsilon_map_t, face_epsilon_map, face_epsilon_map) CGAL_add_named_parameter(face_epsilon_map_t, face_epsilon_map, face_epsilon_map)
CGAL_add_named_parameter(maximum_number_t, maximum_number, maximum_number) CGAL_add_named_parameter(maximum_number_t, maximum_number, maximum_number)
CGAL_add_named_parameter(use_one_sided_hausdorff_t, use_one_sided_hausdorff, use_one_sided_hausdorff) CGAL_add_named_parameter(use_one_sided_hausdorff_t, use_one_sided_hausdorff, use_one_sided_hausdorff)
CGAL_add_named_parameter(random_generator_f, random_generator, random_generator)
// List of named parameters that we use in the package 'Surface Mesh Simplification' // List of named parameters that we use in the package 'Surface Mesh Simplification'
CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost) CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost)

View File

@ -438,6 +438,7 @@ struct Triangle_structure_sampler_for_triangle_mesh
Vpm pmap; Vpm pmap;
double min_sq_edge_length; double min_sq_edge_length;
const Mesh& tm; const Mesh& tm;
CGAL::Random rnd;
Triangle_structure_sampler_for_triangle_mesh(const Mesh& m, Triangle_structure_sampler_for_triangle_mesh(const Mesh& m,
PointOutputIterator& out, PointOutputIterator& out,
@ -449,6 +450,8 @@ struct Triangle_structure_sampler_for_triangle_mesh
pmap = choose_parameter(get_parameter(np, internal_np::vertex_point), pmap = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_const_property_map(vertex_point, tm)); get_const_property_map(vertex_point, tm));
rnd = choose_parameter(get_parameter(np, internal_np::random_generator),
get_default_random());
min_sq_edge_length = (std::numeric_limits<double>::max)(); min_sq_edge_length = (std::numeric_limits<double>::max)();
} }
@ -549,7 +552,7 @@ struct Triangle_structure_sampler_for_triangle_mesh
Randomizer get_randomizer() Randomizer get_randomizer()
{ {
return Randomizer(tm, pmap); return Randomizer(tm, pmap, rnd);
} }
void internal_sample_triangles(double grid_spacing_, bool smpl_fcs, bool smpl_dgs) void internal_sample_triangles(double grid_spacing_, bool smpl_fcs, bool smpl_dgs)
@ -609,6 +612,7 @@ struct Triangle_structure_sampler_for_triangle_soup
double min_sq_edge_length; double min_sq_edge_length;
const PointRange& points; const PointRange& points;
const TriangleRange& triangles; const TriangleRange& triangles;
Random rnd;
Triangle_structure_sampler_for_triangle_soup(const PointRange& pts, Triangle_structure_sampler_for_triangle_soup(const PointRange& pts,
const TriangleRange& trs, const TriangleRange& trs,
@ -616,7 +620,12 @@ struct Triangle_structure_sampler_for_triangle_soup
const NamedParameters& np) const NamedParameters& np)
: Base(out, np), points(pts), triangles(trs) : Base(out, np), points(pts), triangles(trs)
{ {
using parameters::choose_parameter;
using parameters::get_parameter;
min_sq_edge_length = (std::numeric_limits<double>::max)(); min_sq_edge_length = (std::numeric_limits<double>::max)();
rnd = choose_parameter(get_parameter(np, internal_np::random_generator),
get_default_random());
} }
std::pair<TriangleIterator, TriangleIterator> get_range() std::pair<TriangleIterator, TriangleIterator> get_range()
@ -681,7 +690,7 @@ struct Triangle_structure_sampler_for_triangle_soup
Randomizer get_randomizer() Randomizer get_randomizer()
{ {
return Randomizer(triangles, points); return Randomizer(triangles, points, rnd);
} }
void internal_sample_triangles(double distance, bool, bool) void internal_sample_triangles(double distance, bool, bool)
@ -737,6 +746,12 @@ struct Triangle_structure_sampler_for_triangle_soup
* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.}
* \cgalParamNEnd * \cgalParamNEnd
* *
* \cgalParamNBegin{random_generator}
* \cgalParamDescription{An instance of `CGAL::Random` used for generating random numbers.}
* \cgalParamType{`CGAL::Random`}
* \cgalParamType{`CGAL::get_default_random()`}
* \cgalParamNEnd
*
* \cgalParamNBegin{use_random_uniform_sampling} * \cgalParamNBegin{use_random_uniform_sampling}
* \cgalParamDescription{If `true` is passed, points are generated in a random and uniform way * \cgalParamDescription{If `true` is passed, points are generated in a random and uniform way
* on the surface of `tm`, and/or on edges of `tm`.} * on the surface of `tm`, and/or on edges of `tm`.}
@ -896,6 +911,12 @@ sample_triangle_mesh(const TriangleMesh& tm,
* \cgalParamExtra{The geometric traits class must be compatible with the point range's point type.} * \cgalParamExtra{The geometric traits class must be compatible with the point range's point type.}
* \cgalParamNEnd * \cgalParamNEnd
* *
* \cgalParamNBegin{random_generator}
* \cgalParamDescription{An instance of `CGAL::Random` used for generating random numbers.}
* \cgalParamType{`CGAL::Random`}
* \cgalParamType{`CGAL::get_default_random()`}
* \cgalParamNEnd
*
* \cgalParamNBegin{use_random_uniform_sampling} * \cgalParamNBegin{use_random_uniform_sampling}
* \cgalParamDescription{If `true` is passed, points are generated in a random and uniform way * \cgalParamDescription{If `true` is passed, points are generated in a random and uniform way
* over the triangles of the soup.} * over the triangles of the soup.}