diff --git a/Documentation/doc/Documentation/General.txt b/Documentation/doc/Documentation/General.txt index f8707467413..18fe443daef 100644 --- a/Documentation/doc/Documentation/General.txt +++ b/Documentation/doc/Documentation/General.txt @@ -106,6 +106,18 @@ See http://www.boost.org/libs/property_map/doc/ReadablePropertyMap.html */ class ReadablePropertyMap {}; +/*! +See http://www.boost.org/libs/range/doc/html/range/concepts/single_pass_range.html +/// \cgalConcept +*/ +class SinglePassRange {}; + +/*! +See http://www.boost.org/libs/range/doc/html/range/concepts/forward_range.html +/// \cgalConcept +*/ +class ForwardRange {}; + /*! This indicates that the definition of a type nested in a class is not documented. */ diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp index 2e8991c32a9..8024278bc9a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp @@ -28,11 +28,11 @@ int main() { patch_1.reserve(polyline.size() -2); // there will be exactly n-2 triangles in the patch CGAL::Polygon_mesh_processing::triangulate_hole_polyline( - polyline.begin(), polyline.end(), back_inserter(patch_1)); + polyline, back_inserter(patch_1)); CGAL::Polygon_mesh_processing::triangulate_hole_polyline( - polyline.begin(), polyline.end(), back_inserter(patch_2)); + polyline, back_inserter(patch_2)); CGAL::Polygon_mesh_processing::triangulate_hole_polyline( - polyline.begin(), polyline.end(), back_inserter(patch_3)); + polyline, back_inserter(patch_3)); for(std::size_t i = 0; i < patch_1.size(); ++i) { std::cout << "Triangle " << i << ": " << patch_1[i].get<0>() << " " @@ -54,7 +54,7 @@ int main() { polyline_collinear.push_back(Point_3(4.,0.,0.)); std::vector patch_will_be_empty; CGAL::Polygon_mesh_processing::triangulate_hole_polyline( - polyline_collinear.begin(), polyline_collinear.end(), + polyline_collinear, back_inserter(patch_will_be_empty)); CGAL_assertion(patch_will_be_empty.empty()); } diff --git a/Polygon_mesh_processing/include/CGAL/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/internal/Hole_filling/Triangulate_hole_polyline.h index c56ff99eee6..9ce015fb45b 100644 --- a/Polygon_mesh_processing/include/CGAL/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/internal/Hole_filling/Triangulate_hole_polyline.h @@ -1153,20 +1153,26 @@ public: * Internal entry point for both polyline and Polyhedron_3 triangulation functions ***********************************************************************************/ template < - typename Point_3, + typename PointRange, typename Tracer, typename WeightCalculator > typename WeightCalculator::Weight -triangulate_hole_polyline(std::vector& P, - std::vector& Q, +triangulate_hole_polyline(const PointRange& points, + const PointRange& third_points, Tracer& tracer, const WeightCalculator& WC, bool use_delaunay_triangulation) { - typedef typename CGAL::Kernel_traits::Kernel Kernel; - typedef CGAL::internal::Triangulate_hole_polyline_DT Fill_DT; - typedef CGAL::internal::Triangulate_hole_polyline Fill; + typedef typename PointRange::iterator InIterator; + typedef typename std::iterator_traits::value_type Point_3; + typedef typename CGAL::Kernel_traits::Kernel K; + + typedef CGAL::internal::Triangulate_hole_polyline_DT Fill_DT; + typedef CGAL::internal::Triangulate_hole_polyline Fill; + + std::vector P(boost::begin(points), boost::end(points)); + std::vector Q(boost::begin(third_points), boost::end(third_points)); if(P.front() != P.back()){ P.push_back(P.front()); diff --git a/Polygon_mesh_processing/include/CGAL/triangulate_hole.h b/Polygon_mesh_processing/include/CGAL/triangulate_hole.h index 95f9d0be8d9..a8ad7db0f72 100644 --- a/Polygon_mesh_processing/include/CGAL/triangulate_hole.h +++ b/Polygon_mesh_processing/include/CGAL/triangulate_hole.h @@ -247,34 +247,33 @@ namespace Polygon_mesh_processing { /*! \ingroup PkgPolygonMeshProcessing - Creates triangles to fill the hole defined by points in the range (@a pbegin, @a pend). Triangles are put into @a out - using the indices of the input points in the range (@a pbegin, @a pend). - Note that no degenerate triangle is allowed during filling. If no possible patch is found, then no triangle is put into @a out. + Creates triangles to fill the hole defined by points in the range (@a points). Triangles are put into @a out + using the indices of the input points in the range (@a points). + Note that no degenerate triangles are allowed during filling. If no possible patch is found, then no triangle is put into @a out. - The optional range (@a qbegin, @a qend) indicate for each pair of consecutive points in the range (@a pbegin, @a pend), + The optional range (@a third_points) indicates for each pair of consecutive points in the range (@a points), the third point of the facet this segment is incident to. - Note that the range (@a pbegin, @a pend) and (@a qbegin, @a qend) may or may not contain duplicated first point at the end of sequence. + Note that the ranges (@a points) and (@a third_points) may or may not contain duplicated first point at the end of sequence. @tparam OutputIteratorValueType value type of OutputIterator having a constructor `OutputIteratorValueType(int p0, int p1, int p2)` available. - It is default to value_type_traits::type, and can be omitted when the default is fine - @tparam InputIterator iterator over input points + It defaults to `value_type_traits::type`, and can be omitted when the default is fine. + + @tparam PointRange range of points, model of `SinglePassRange` @tparam OutputIterator iterator over patch triangles - @param pbegin first iterator of the range of points - @param pend past-the-end iterator of the range of points - @param qbegin first iterator of the range of third points, can be omitted - @param qend past-the-end iterator of the range of third points, can be omitted + @param points the range of input points + @param third_points the range of third points, can be omitted @param out iterator over output patch triangles - @param use_delaunay_triangulation if `true`, use the Delaunay triangulation facet search space + @param use_delaunay_triangulation if `true`, use the Delaunay triangulation facet search space, defaults to true if omitted. \todo handle islands */ template OutputIterator - triangulate_hole_polyline(InputIterator pbegin, InputIterator pend, - InputIterator qbegin, InputIterator qend, + triangulate_hole_polyline(const PointRange& points, + const PointRange& third_points, OutputIterator out, bool use_delaunay_triangulation = true) { @@ -284,32 +283,32 @@ namespace Polygon_mesh_processing { #else use_delaunay_triangulation; #endif - typedef typename std::iterator_traits::value_type Point_3; + typedef typename PointRange::iterator InIterator; + typedef typename std::iterator_traits::value_type Point_3; + typedef CGAL::internal::Weight_min_max_dihedral_and_area Weight; typedef CGAL::internal::Weight_calculator WC; typedef std::vector > Holes; typedef std::back_insert_iterator Holes_out; - std::vector P(pbegin, pend); - std::vector Q(qbegin, qend); - Holes holes;//just to check there is no holes + Holes holes;//just to check there is no holes left CGAL::internal::Tracer_polyline_incomplete tracer(out, Holes_out(holes)); - triangulate_hole_polyline(P, Q, tracer, WC(), use_dt3); + triangulate_hole_polyline(points, third_points, tracer, WC(), use_dt3); CGAL_assertion(holes.empty()); return tracer.out; } // overload for OutputIteratorValueType - template OutputIterator - triangulate_hole_polyline(InputIterator pbegin, InputIterator pend, - InputIterator qbegin, InputIterator qend, - OutputIterator out, - bool use_delaunay_triangulation = true) + triangulate_hole_polyline(const PointRange& points, + const PointRange& third_points, + OutputIterator out, + bool use_delaunay_triangulation = true) { bool use_dt3 = #ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 @@ -318,15 +317,15 @@ namespace Polygon_mesh_processing { use_delaunay_triangulation; #endif return triangulate_hole_polyline::type> - (pbegin, pend, qbegin, qend, out, use_dt3); + (points, third_points, out, use_dt3); } // overload no (qbegin, qend) template OutputIterator - triangulate_hole_polyline(InputIterator pbegin, InputIterator pend, + triangulate_hole_polyline(const PointRange& points, OutputIterator out, bool use_delaunay_triangulation = true) { @@ -336,18 +335,16 @@ namespace Polygon_mesh_processing { #else use_delaunay_triangulation; #endif - typedef typename std::iterator_traits::value_type Point; - typedef std::vector Polyline_3; - Polyline_3 Q; + return triangulate_hole_polyline - (pbegin, pend, Q.begin(), Q.end(), out, use_dt3); + (points, PointRange(), out, use_dt3); } // overload for OutputIteratorValueType - template OutputIterator - triangulate_hole_polyline(InputIterator pbegin, InputIterator pend, + triangulate_hole_polyline(const PointRange& points, OutputIterator out, bool use_delaunay_triangulation = true) { @@ -358,7 +355,7 @@ namespace Polygon_mesh_processing { use_delaunay_triangulation; #endif return triangulate_hole_polyline::type> - (pbegin, pend, out, use_dt3); + (points, out, use_dt3); } } //end namespace Polygon_mesh_processing diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp index 150ef07efdd..f2cb852562b 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp @@ -139,8 +139,8 @@ void test_1(const char* file_name, bool use_DT) { read_polyline_one_line(file_name, points); std::vector > tris; - CGAL::Polygon_mesh_processing::triangulate_hole_polyline(points.begin(), - --points.end(), std::back_inserter(tris), use_DT); + CGAL::Polygon_mesh_processing::triangulate_hole_polyline( + points, std::back_inserter(tris), use_DT); check_triangles(points, tris); check_constructed_polyhedron(file_name, &tris, &points); @@ -156,8 +156,8 @@ void test_2(const char* file_name, bool use_DT) { read_polyline_with_extra_points(file_name, points, extras); std::vector > tris; - CGAL::Polygon_mesh_processing::triangulate_hole_polyline(points.begin(), - points.end(), extras.begin(), extras.end(), std::back_inserter(tris), use_DT); + CGAL::Polygon_mesh_processing::triangulate_hole_polyline( + points, extras, std::back_inserter(tris), use_DT); check_triangles(points, tris); check_constructed_polyhedron(file_name, &tris, &points); @@ -173,7 +173,7 @@ void test_should_be_no_output(const char* file_name, bool use_DT) { std::vector > tris; CGAL::Polygon_mesh_processing::triangulate_hole_polyline( - points.begin(), points.end(), std::back_inserter(tris), use_DT); + points, std::back_inserter(tris), use_DT); if(!tris.empty()) { std::cerr << " Error: patch should be empty" << std::endl; diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_polyline_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_polyline_plugin.cpp index 7f5d1c49811..15eee8e5d13 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_polyline_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_polyline_plugin.cpp @@ -125,8 +125,7 @@ public slots: CGAL::Timer timer; timer.start(); std::vector > patch; - CGAL::Polygon_mesh_processing::triangulate_hole_polyline(it->begin(), - --it->end(), std::back_inserter(patch), use_DT); + CGAL::Polygon_mesh_processing::triangulate_hole_polyline(*it, std::back_inserter(patch), use_DT); print_message(QString("Triangulated in %1 sec.").arg(timer.time())); if(patch.empty()) {