diff --git a/Generator/doc/Generator/CGAL/point_generators_2.h b/Generator/doc/Generator/CGAL/point_generators_2.h index 2621f121466..1d15714f149 100644 --- a/Generator/doc/Generator/CGAL/point_generators_2.h +++ b/Generator/doc/Generator/CGAL/point_generators_2.h @@ -371,6 +371,8 @@ typedef const Point_2& reference; \sa`CGAL::Random_points_on_triangle_mesh_3` \sa`CGAL::Random_points_on_tetrahedral_mesh_boundary` \sa`CGAL::Random_points_in_tetrahedral_mesh_3` + \sa `CGAL::Random_points_in_triangles_3` + \sa `CGAL::Random_points_in_triangles_2` \sa `std::random_shuffle` */ @@ -418,6 +420,75 @@ default_random); }; /* end Random_points_in_triangle_mesh_2 */ + /*! + + The class `Random_points_in_triangles_2` is an input iterator creating points uniformly distributed inside a range of `Triangle_2`. The range must remain valid. + + + \cgalModels `InputIterator` + \cgalModels `PointGenerator` + + \sa `CGAL::cpp11::copy_n()` + \sa `CGAL::Counting_iterator` + \sa `CGAL::Points_on_segment_2` + \sa `CGAL::Random_points_in_disc_2` + \sa `CGAL::Random_points_on_segment_2` + \sa `CGAL::Random_points_on_square_2` + \sa `CGAL::Random_points_in_cube_3` + \sa `CGAL::Random_points_in_triangle_3` + \sa `CGAL::Random_points_in_tetrahedron_3` + \sa `CGAL::Random_points_on_triangle_mesh_3` + \sa `CGAL::Random_points_on_tetrahedral_mesh_boundary` + \sa `CGAL::Random_points_in_tetrahedral_mesh_3` + \sa `CGAL::Random_points_in_triangles_3` + \sa `std::random_shuffle` + + */ + template< typename Point_2 > + class Random_points_in_triangles_2 { + public: + + /// \name Types + /// @{ + + /*! + + */ + typedef std::input_iterator_tag iterator_category; + + /*! + + */ + typedef Point_2 value_type; + + /*! + + */ + typedef std::ptrdiff_t difference_type; + + /*! + + */ + typedef const Point_2* pointer; + + /*! + + */ + typedef const Point_2& reference; + +/*! +Creates an input iterator `g` generating points of type `Point_2` uniformly +distributed between the triangles of the range. Each triangle has a probability to be chosen to hold the point depending on its area. + +*/ +template +Random_points_in_triangles_2(TriangleRange triangles, Random& rnd = +default_random); + +/// @} + +}; /* end Random_points_in_triangles_2 */ + /*! The class `Random_points_on_circle_2` is an input iterator creating points uniformly diff --git a/Generator/doc/Generator/CGAL/point_generators_3.h b/Generator/doc/Generator/CGAL/point_generators_3.h index 0d3c94e1dc1..82ec7b21099 100644 --- a/Generator/doc/Generator/CGAL/point_generators_3.h +++ b/Generator/doc/Generator/CGAL/point_generators_3.h @@ -331,31 +331,34 @@ get_default_random()); } /* end namespace CGAL */ - namespace CGAL { /*! -The class `Random_points_on_triangles_3` is an input iterator creating points uniformly -distributed inside the triangles of a range. +The class `Random_points_in_triangles_3` is an input iterator creating points uniformly distributed inside a range of `Triangle_3`. The range must remain valid. + \cgalModels `InputIterator` \cgalModels `PointGenerator` \sa `CGAL::cpp11::copy_n()` \sa `CGAL::Counting_iterator` +\sa `CGAL::Points_on_segment_2` \sa `CGAL::Random_points_in_disc_2` +\sa `CGAL::Random_points_on_segment_2` +\sa `CGAL::Random_points_on_square_2` \sa `CGAL::Random_points_in_cube_3` -\sa `CGAL::Random_points_in_triangle_3` -\sa `CGAL::Random_points_on_sphere_3` -\sa `CGAL::Random_points_in_triangle_mesh_2` +\sa `CGAL::Random_points_in_triangle_3` +\sa `CGAL::Random_points_in_tetrahedron_3` +\sa `CGAL::Random_points_on_triangle_mesh_3` \sa `CGAL::Random_points_on_tetrahedral_mesh_boundary` \sa `CGAL::Random_points_in_tetrahedral_mesh_3` +\sa `CGAL::Random_points_in_triangles_2` \sa `std::random_shuffle` */ -template < class Point_3> -class Random_points_on_triangles_3 { +template< typename Point_3> +class Random_points_in_triangles_3 { public: /// \name Types @@ -386,20 +389,18 @@ typedef const Point_3* pointer; */ typedef const Point_3& reference; - - /*! Creates an input iterator `g` generating points of type `Point_3` uniformly -distributed in the triangles of `TriangleRange`. Each triangle has a probability to be chosen to hold the point depending on its area. -TriangleRange must stay valid during the whole operation. +distributed between the triangles of the range. Each triangle has a probability to be chosen to hold the point depending on its area. + */ - typedef -Random_points_on_triangles_3(TriangleRange& triangles, Random& rnd = default_random); +template +Random_points_in_triangles_3(TriangleRange triangulation, Random& rnd = +default_random); /// @} -}; /* end Random_points_on_triangles_3 */ - +}; /* end Random_points_in_triangles_3 */ } /* end namespace CGAL */ namespace CGAL { @@ -421,6 +422,8 @@ distributed inside the faces of a triangle mesh model of `FaceListGraph`. \sa `CGAL::Random_points_in_triangle_mesh_2` \sa `CGAL::Random_points_on_tetrahedral_mesh_boundary` \sa `CGAL::Random_points_in_tetrahedral_mesh_3` +\sa `CGAL::Random_points_in_triangles_2` +\sa `CGAL::Random_points_in_triangles_3` \sa `std::random_shuffle` */ @@ -493,6 +496,8 @@ C3T3 is a model of `Mesh_complex_3_in_triangulation_3` \sa `CGAL::Random_points_on_triangle_mesh_3` \sa `CGAL::Random_points_in_triangle_mesh_2` \sa `CGAL::Random_points_in_tetrahedral_mesh_3` +\sa `CGAL::Random_points_in_triangles_2` +\sa `CGAL::Random_points_in_triangles_3` \sa `std::random_shuffle` */ @@ -564,6 +569,8 @@ C3T3 is a model of `Mesh_complex_3_in_triangulation_3` \sa `CGAL::Random_points_on_triangle_mesh_3` \sa `CGAL::Random_points_in_triangle_mesh_2` \sa `CGAL::Random_points_on_tetrahedral_mesh_boundary` +\sa `CGAL::Random_points_in_triangles_2` +\sa `CGAL::Random_points_in_triangles_3` \sa `std::random_shuffle` */ diff --git a/Generator/doc/Generator/Generator.txt b/Generator/doc/Generator/Generator.txt index 9ca3c805b5e..e9f9f43436e 100644 --- a/Generator/doc/Generator/Generator.txt +++ b/Generator/doc/Generator/Generator.txt @@ -32,6 +32,7 @@ on a circle (`Random_points_on_circle_2`), on a segment (`Random_points_on_segment`), in a square (`Random_points_on_square_2`), in a triangle (`Random_points_in_triangle_2`), +in a range of triangles (`Random_points_in_triangles_2`), and in a triangle mesh (`Random_points_in_triangle_mesh_2`). For generating grid points we provide three functions, `points_on_segment_2()`, @@ -40,6 +41,7 @@ an input iterator `Points_on_segment_2`. For 3D points, input iterators are provided for random points uniformly distributed in a sphere (`Random_points_in_sphere_3`), in a triangle (`Random_points_in_triangle_3`), +in a range of triangles (`Random_points_in_triangles_3`), in a tetrahedron (`Random_points_in_tetrahedron_3`), in a cube (`Random_points_in_cube_3`), on the boundary of a sphere (`Random_points_on_sphere_3`), in a triangle mesh (`Random_points_on_triangle_mesh_3`), in a tetrahedron mesh (`Random_points_in_tetrahedral_mesh_3`), and on the boundary diff --git a/Generator/doc/Generator/examples.txt b/Generator/doc/Generator/examples.txt index c59a420287f..aeb30eb04e0 100644 --- a/Generator/doc/Generator/examples.txt +++ b/Generator/doc/Generator/examples.txt @@ -19,4 +19,7 @@ \example Generator/random_points_on_triangle_mesh_3.cpp \example Generator/random_points_on_tetrahedral_mesh_3.cpp \example Generator/random_points_in_tetrahedral_mesh_3.cpp +\example Generator/random_points_in_triangles_2.cpp +\example Generator/random_points_in_triangles_3.cpp + */ diff --git a/Generator/examples/Generator/random_points_on_triangles_3.cpp b/Generator/examples/Generator/random_points_in_triangles_3.cpp similarity index 94% rename from Generator/examples/Generator/random_points_on_triangles_3.cpp rename to Generator/examples/Generator/random_points_in_triangles_3.cpp index 49a3b3318d5..c23d7c39f34 100644 --- a/Generator/examples/Generator/random_points_on_triangles_3.cpp +++ b/Generator/examples/Generator/random_points_in_triangles_3.cpp @@ -20,7 +20,7 @@ int main() } // Create the generator, input is the vector of Triangle_3 - Random_points_on_triangles_3 g(triangles); + Random_points_in_triangles_3 g(triangles); // Get 100 random points in cdt CGAL::cpp11::copy_n(g, 1000, std::back_inserter(points)); diff --git a/Generator/include/CGAL/point_generators_3.h b/Generator/include/CGAL/point_generators_3.h index fd05031ba74..2eb6e1e6887 100644 --- a/Generator/include/CGAL/point_generators_3.h +++ b/Generator/include/CGAL/point_generators_3.h @@ -471,7 +471,7 @@ public: template -class Random_points_on_triangles_3 : public Generic_random_point_generator< +class Random_points_in_triangles_3 : public Generic_random_point_generator< const typename Kernel_traits::Kernel::Triangle_3*, internal::Deref::Kernel::Triangle_3*>, Random_points_in_triangle_3 ,Point_3> { @@ -483,10 +483,10 @@ public: Random_points_in_triangle_3 ,Point_3> Base; typedef const Triangle_3* Id; typedef Point_3 result_type; - typedef Random_points_on_triangles_3 This; + typedef Random_points_in_triangles_3 This; template - Random_points_on_triangles_3( const TriangleRange& triangles, Random& rnd = default_random) + Random_points_in_triangles_3( const TriangleRange& triangles, Random& rnd = default_random) : Base(make_range( boost::make_transform_iterator(triangles.begin(), internal::Address_of()), boost::make_transform_iterator(triangles.end(), internal::Address_of()) ), internal::Deref(), diff --git a/Generator/test/Generator/generic_random_test.cpp b/Generator/test/Generator/generic_random_test.cpp index df92f9fdf75..7c3f3cf1d4b 100644 --- a/Generator/test/Generator/generic_random_test.cpp +++ b/Generator/test/Generator/generic_random_test.cpp @@ -78,7 +78,7 @@ int test_triangles_3() triangles.push_back(K::Triangle_3(Point(0.5,0.5,0), Point(0.5,0.5,0.5), Point(0.5,0.,0.5))); // Create the generator, input is the vector of Triangle_3 - Random_points_on_triangles_3 g(triangles); + Random_points_in_triangles_3 g(triangles); // Get 100 random points in triangle range CGAL::cpp11::copy_n(g, 100, std::back_inserter(points)); diff --git a/Installation/changes.html b/Installation/changes.html index 22b8267135c..eb1f847bca0 100644 --- a/Installation/changes.html +++ b/Installation/changes.html @@ -159,8 +159,10 @@ and src/ directories).
  • There is now convenience classes to uniformly generate random points on a FaceListGraph and a Triangulation_2, - and there is also classes to do so in and on a Mesh_complex_3_in_triangulation_3, respectively CGAL::Random_points_on_triangle_mesh_3(), CGAL::Random_points_in_triangle_mesh_2(), - CGAL::Random_points_in_tetrahedral_mesh_3(), and CGAL::Random_points_on_tetrahedral_mesh_boundary(). + and there is also classes to do so in and on a Mesh_complex_3_in_triangulation_3, along with classes for a range of + Triangle_3 and a range of Triangle_2: respectively CGAL::Random_points_on_triangle_mesh_3(), CGAL::Random_points_in_triangle_mesh_2(), + CGAL::Random_points_in_tetrahedral_mesh_3(), CGAL::Random_points_on_tetrahedral_mesh_boundary(), + CGAL::Random_points_in_triangles_3 and Random_points_in_triangles_2.