diff --git a/Generator/include/CGAL/point_generators_2.h b/Generator/include/CGAL/point_generators_2.h index 73effe1d163..3b56c39d45a 100644 --- a/Generator/include/CGAL/point_generators_2.h +++ b/Generator/include/CGAL/point_generators_2.h @@ -28,12 +28,14 @@ #ifndef CGAL_POINT_GENERATORS_2_H #define CGAL_POINT_GENERATORS_2_H 1 + #include -#include #include #include #include +#include + namespace CGAL { template < class P, class Creator = @@ -547,6 +549,7 @@ void Random_points_in_triangle_2::generate_point() { } namespace internal { + //Functor returning Triangle_2 from Triangulation_2 Faces template class Triangle_from_face_2 @@ -556,38 +559,75 @@ public: typedef Triangle result_type; Triangle_from_face_2() {} - Triangle operator()(typename T::Face_handle face)const { + Triangle operator()(typename T::Finite_faces_iterator face) const { return Triangle(face->vertex(0)->point(), face->vertex(1)->point(), face->vertex(2)->point()); } }; + +struct Is_not_in_domain +{ + typedef bool result_type; + + template + result_type operator()(const FH fh) const { + return (!fh->is_in_domain()); + } +}; + +template +class In_domain_finite_faces_iterator + : public Filter_iterator +{ + typedef CGAL::Filter_iterator Base; + typedef In_domain_finite_faces_iterator Self; + + typedef typename T::Face_handle Face_handle; + typedef typename T::Finite_faces_iterator Finite_faces_iterator; + +public: + In_domain_finite_faces_iterator() : Base() {} + In_domain_finite_faces_iterator(const Base &b) : Base(b) {} + Self & operator++() { Base::operator++(); return *this; } + Self & operator--() { Base::operator--(); return *this; } + Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } + Self operator--(int) { Self tmp(*this); --(*this); return tmp; } + operator Finite_faces_iterator() const { return Base::base(); } + operator Face_handle() const { return Face_handle(Base::base()); } +}; + }//end namespace internal + template ::Kernel::RT,P> -> -class Random_points_in_triangle_mesh_2 : public Generic_random_point_generator< - typename T::Face_handle , - internal::Triangle_from_face_2, - Random_points_in_triangle_2

, P> { + class Creator = Creator_uniform_2::Kernel::RT, P> > +class Random_points_in_triangle_mesh_2 + : public Generic_random_point_generator, + internal::Triangle_from_face_2, + Random_points_in_triangle_2, + P> +{ public: - typedef Generic_random_point_generator, internal::Triangle_from_face_2, Random_points_in_triangle_2, P> Base; typedef typename T::Face_handle Id; - typedef P result_type; + typedef P result_type; typedef Random_points_in_triangle_mesh_2 This; - - Random_points_in_triangle_mesh_2( const T& triangulation, Random& rnd = get_default_random()) - : Base( CGAL::make_prevent_deref_range(triangulation.finite_faces_begin(), - triangulation.finite_faces_end()), - internal::Triangle_from_face_2(), - typename Kernel_traits

::Kernel::Compute_area_2(), - rnd ) + Random_points_in_triangle_mesh_2(const T& triangulation, Random& rnd = get_default_random()) + : Base(CGAL::make_prevent_deref_range( + CGAL::filter_iterator(triangulation.finite_faces_end(), + internal::Is_not_in_domain(), + triangulation.finite_faces_begin()), + CGAL::filter_iterator(triangulation.finite_faces_end(), + internal::Is_not_in_domain())), + internal::Triangle_from_face_2(), + typename Kernel_traits

::Kernel::Compute_area_2(), + rnd) { } + This& operator++() { Base::generate_point(); return *this;