From 9ee11501ac94f12e1b4e7f02e9fa88309499a501 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 30 Nov 2016 10:01:59 +0100 Subject: [PATCH] Changes after the review by Sebastien --- .../dual/halfspace_intersection_3.h | 10 ++--- ...fspace_intersection_with_constructions_3.h | 8 ++-- .../Convex_hull_3/CGAL/Convex_hull_traits_3.h | 6 +-- .../doc/Convex_hull_3/CGAL/convex_hull_3.h | 8 ++-- .../CGAL/convex_hull_3_to_face_graph.h | 24 ++++++++++++ .../CGAL/convex_hull_3_to_polyhedron_3.h | 2 + .../Convex_hull_3/CGAL/convexity_check_3.h | 6 +-- .../doc/Convex_hull_3/Convex_hull_3.txt | 6 +-- .../examples/Convex_hull_3/dynamic_hull_3.cpp | 4 +- .../Convex_hull_3/lloyd_algorithm.cpp | 2 +- .../include/CGAL/Convex_hull_traits_3.h | 3 +- Convex_hull_3/include/CGAL/convex_hull_3.h | 2 +- .../CGAL/convex_hull_3_to_face_graph.h | 37 +++++++++++++++++++ .../CGAL/convex_hull_3_to_polyhedron_3.h | 8 ++-- .../quickhull_degenerate_test_3.cpp | 2 +- .../test/Convex_hull_3/quickhull_test_3.cpp | 2 +- .../include/CGAL/link_to_face_graph.h | 2 + 17 files changed, 99 insertions(+), 33 deletions(-) create mode 100644 Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_face_graph.h create mode 100644 Convex_hull_3/include/CGAL/convex_hull_3_to_face_graph.h diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h index 3bf14e101d6..ec4b2058d4d 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h @@ -4,28 +4,28 @@ namespace CGAL { \ingroup PkgConvexHull3Functions \brief computes robustly the intersection of the halfspaces defined by the planes contained in the range [`begin`, `end`) without constructing the dual points. The result is stored in the polyhedron `P`. -If `origin` is given then it must be a point strictly inside the polyhedron. If an interior point is not given then it is computed using a linear program and thus is slower. +If `origin` is given then it must be a point strictly inside the polygon mesh. If an interior point is not given then it is computed using a linear program and thus is slower. This version does not construct the dual points explicitely but uses a special traits class for the function `CGAL::convex_hull_3()` to handle predicates on dual points without constructing them. \attention Halfspaces are considered as lower halfspaces that is to say if the plane's equation is \f$ a\, x +b\, y +c\, z + d = 0 \f$ then the corresponding halfspace is defined by \f$ a\, x +b\, y +c\, z + d \le 0 \f$ . \attention -\pre The point type of `origin` and the point type of the vertices of `Polyhedron` must come from the same \cgal %Kernel.\pre if provided, `origin` is inside the intersection of halfspaces defined by the range `[begin, end)`. +\pre The point type of `origin` and the point type of the vertices of `PolygonMesh` must come from the same \cgal %Kernel.\pre if provided, `origin` is inside the intersection of halfspaces defined by the range `[begin, end)`. \pre The computed intersection must be a bounded convex polyhedron. \tparam PlaneIterator must be an input iterator where the value type is a model of the concept `Kernel::Plane_3` and this plane type must come from the same kernel as the point type. -\tparam Polyhedron must be a model of `MutableFaceGraph`. +\tparam PolygonMesh must be a model of `MutableFaceGraph`. \sa `halfspace_intersection_with_constructions_3()` */ -template +template void halfspace_intersection_3 (PlaneIterator begin, PlaneIterator end, - Polyhedron &P, + PolygonMesh &P, boost::optional::value_type>::Kernel::Point_3> > origin = boost::none); } /* namespace CGAL */ diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h index 3e01cd8eda5..636fa8163fe 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h @@ -15,17 +15,17 @@ This version constructs explicitly the dual points using the convex hull algorit \tparam PlaneIterator must be an input iterator where the value type is a model of the concept `Kernel::Plane_3` and this plane type must come from the same kernel as the point type. -\tparam Polyhedron must be a model of `MutableFaceGraph`. +\tparam PolygonMesh must be a model of `MutableFaceGraph`. \tparam Traits must be a model of the concept `ConvexHullTraits_3`. \sa `halfspace_intersection_3()` */ -template +template void halfspace_intersection_with_constructions_3(PlaneIterator pbegin, PlaneIterator pend, - Polyhedron &P, - boost::optional origin = boost::none, + PolygonMesh &P, + boost::optional::value_type>::Kernel::Point_3> > origin = boost::none, const Traits & ch_traits = Default_traits); } /* namespace CGAL */ diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h index ac9759b2319..46ab157269d 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/Convex_hull_traits_3.h @@ -8,12 +8,12 @@ The class `Convex_hull_traits_3` serves as a traits class for the function function when `R` is a kernel with exact predicates but inexact constructions (note that the type `Plane_3` is a triple of `Point_3` and not `R::Plane_3`). -\tparam MFG must be a model of MutableFaceGraph +\tparam MFG must be a model of the concept `MutableFaceGraph` \cgalModels `ConvexHullTraits_3` \cgalModels `IsStronglyConvexTraits_3` */ - template< typename R, typename MFG = Polyhedron_3 > + template< typename R, typename PolygonMesh = Polyhedron_3 > class Convex_hull_traits_3 { public: @@ -43,7 +43,7 @@ typedef unspecified_type Plane_3; /*! */ -typedef MFG Polyhedron_3; +typedef PolygonMesh Polygon_mesh; /*! diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h index 57266cf61ae..f10e2e5101f 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3.h @@ -14,7 +14,7 @@ that is `P` will contain only triangular facets. [`first`, `last`) not all of which are collinear. \tparam InputIterator must be an input iterator with a value type equivalent to `Traits::Point_3`. -\tparam Polyhedron_3 must be a model of `MutableFaceGraph`. +\tparam PolygonMesh must be a model of `MutableFaceGraph`. \tparam Traits must be a model of the concept `ConvexHullTraits_3`. For the purposes of checking the postcondition that the convex hull is valid, `Traits` must also be a model of the concept @@ -35,8 +35,8 @@ Barnard et al. \cgalCite{bdh-qach-96}. */ -template -void convex_hull_3(InputIterator first, InputIterator last, Polyhedron_3& P, const Traits& ch_traits = Default_traits); +template +void convex_hull_3(InputIterator first, InputIterator last, PolygonMesh& P, const Traits& ch_traits = Default_traits); /*! \ingroup PkgConvexHull3Functions @@ -54,7 +54,7 @@ in case the result is a polyhedron. \tparam Traits must be model of the concept `ConvexHullTraits_3`. For the purposes of checking the postcondition that the convex hull is valid, `Traits` must also be a model of the concept -`IsStronglyConvexTraits_3`. Furthermore, `Traits` must define a type `Polyhedron_3` that is a model of +`IsStronglyConvexTraits_3`. Furthermore, `Traits` must define a type `PolygonMesh` that is a model of `MutableFaceGraph`. If the kernel `R` of the points determined by the value type of `InputIterator` diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_face_graph.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_face_graph.h new file mode 100644 index 00000000000..73cfad6c0bf --- /dev/null +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_face_graph.h @@ -0,0 +1,24 @@ +namespace CGAL { + +/*! +\ingroup PkgConvexHull3Functions + +fills a polyhedron with the convex hull of a set of 3D points contained in a 3D triangulation of \cgal. + +The polyhedron `P` is cleared and the convex hull of the set of 3D points is stored in `P`. + +\attention This function does not compute the plane equations of the faces of `P`. + +\pre `T.dimension()`==3. + +\tparam Triangulation must be a \cgal 3D triangulation +\tparam PolygonMesh must be a model of the concept `MutableFaceGraph` + +\sa `convex_hull_3()` +\sa `link_to_face_graph()` + +*/ +template +void convex_hull_3_to_face_graph(const Triangulation& T,PolygonMesh& P); + +} /* namespace CGAL */ diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_polyhedron_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_polyhedron_3.h index 83333d27002..f0c72e374b6 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_polyhedron_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/convex_hull_3_to_polyhedron_3.h @@ -7,6 +7,8 @@ fills a polyhedron with the convex hull of a set of 3D points contained in a 3D The polyhedron `P` is cleared and the convex hull of the set of 3D points is stored in `P`. +\deprecated since \cgal 4.10. Use `convex_hull_to_face_graph() instead. + \attention This function does not compute the plane equations of the faces of `P`. \attention This function works only for `CGAL::Polyhedron_3`, and users who want diff --git a/Convex_hull_3/doc/Convex_hull_3/CGAL/convexity_check_3.h b/Convex_hull_3/doc/Convex_hull_3/CGAL/convexity_check_3.h index b1c7623f618..53a7c0f461e 100644 --- a/Convex_hull_3/doc/Convex_hull_3/CGAL/convexity_check_3.h +++ b/Convex_hull_3/doc/Convex_hull_3/CGAL/convexity_check_3.h @@ -9,7 +9,7 @@ to be strongly convex if it consists of only extreme points (i.e., vertices of the convex hull). -\tparam Polyhedron must be a model of the concept`FaceListGraph`. +\tparam PolygonMesh must be a model of the concept`FaceListGraph`. \tparam Traits must be a model of the concept `IsStronglyConvexTraits_3`. @@ -22,8 +22,8 @@ determine convexity and requires \f$ O(e + f)\f$ time for a polyhedron with */ -template -bool is_strongly_convex_3(Polyhedron& P, +template +bool is_strongly_convex_3(PolygonMesh& P, const Traits& traits = Default_traits); } /* namespace CGAL */ diff --git a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt index 58d0682977b..31a4188e36c 100644 --- a/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt +++ b/Convex_hull_3/doc/Convex_hull_3/Convex_hull_3.txt @@ -128,16 +128,16 @@ not all of them are vertices of the hull. The following example shows how to compute a convex hull with a triangulation. The vertices incident to the infinite vertex are on the convex hull. -The function `link_to_face_graph()` can be used to obtain a polyhedral surface +The function `convex_hull_3_to_face_graph()` can be used to obtain a polyhedral surface that is model of the concept `MutableFaceGraph`, e.g. `Polyhedron_3` and `Surface_mesh`. \cgalExample{Convex_hull_3/dynamic_hull_3.cpp} \section Convex_hull_3Performance Performance -In the following, we compare the running times of the three approaches to compute 3D convex hulls. +In the following, we compare the running times of the two approaches to compute 3D convex hulls. For the static version (using `convex_hull_3()`) and the dynamic version -(using `Delaunay_triangulation_3` and `link_to_face_graph()`), the kernel +(using `Delaunay_triangulation_3` and `convex_hull_3_to_face_graph()`), the kernel used was `Exact_predicates_inexact_constructions_kernel`. To compute the convex hull of a million of random points in a unit ball the static approach needed 1.63s, while diff --git a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp index 2e9657f3039..f3175f3e0bc 100644 --- a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include @@ -40,7 +40,7 @@ int main() //copy the convex hull of points into a polyhedron and use it //to get the number of points on the convex hull Surface_mesh chull; - CGAL::link_to_face_graph(T, T.infinite_vertex(), chull); + CGAL::convex_hull_3_to_face_graph(T, chull); std::cout << "After removal of 25 points, there are " << num_vertices(chull) << " points on the convex hull." << std::endl; diff --git a/Convex_hull_3/examples/Convex_hull_3/lloyd_algorithm.cpp b/Convex_hull_3/examples/Convex_hull_3/lloyd_algorithm.cpp index 3b0b9db3ac6..7789d5ea21f 100644 --- a/Convex_hull_3/examples/Convex_hull_3/lloyd_algorithm.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/lloyd_algorithm.cpp @@ -14,7 +14,7 @@ typedef K::Plane_3 Plane; typedef K::Vector_3 Vector; typedef CGAL::Convex_hull_traits_3 Traits; -typedef Traits::Polyhedron_3 Polyhedron; +typedef Traits::Polygon_mesh Polyhedron; typedef CGAL::Delaunay_triangulation_3 DT; typedef DT::Vertex_handle Vertex_handle; diff --git a/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h b/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h index a63155697c3..42e7aa73837 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_traits_3.h @@ -199,7 +199,8 @@ class Convex_hull_traits_3 : typedef Point_triple Plane_3; typedef typename R::Vector_3 Vector_3; - typedef typename Default::Get >::type Polyhedron_3; + typedef typename Default::Get >::type Polygon_mesh; + // typedef Polyhedron_3; typedef typename R::Construct_segment_3 Construct_segment_3; typedef typename R::Construct_ray_3 Construct_ray_3; diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index 9fbe2173a46..43786585a11 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -82,7 +82,7 @@ struct Default_polyhedron_for_Chull_3{ template struct Default_polyhedron_for_Chull_3 >{ - typedef typename Convex_hull_traits_3::Polyhedron_3 type; + typedef typename Convex_hull_traits_3::Polygon_mesh type; }; //utility class to select the right version of internal predicate Is_on_positive_side_of_plane_3 diff --git a/Convex_hull_3/include/CGAL/convex_hull_3_to_face_graph.h b/Convex_hull_3/include/CGAL/convex_hull_3_to_face_graph.h new file mode 100644 index 00000000000..67c3e1f4d61 --- /dev/null +++ b/Convex_hull_3/include/CGAL/convex_hull_3_to_face_graph.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : Sebastien Loriot +// + +#ifndef CGAL_CONVEX_HULL_3_TO_FACE_GRAPH_3_H +#define CGAL_CONVEX_HULL_3_TO_FACE_GRAPH_3_H + +#include + +namespace CGAL { + + +template +void convex_hull_3_to_face_graph(const Triangulation_3& T,PolygonMesh& P){ + link_to_face_graph(T,T.infinite_vertex(), P); +} + +} //namespace CGAL + +#endif //CGAL_CONVEX_HULL_3_TO_FACE_GRAPH_3_H diff --git a/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h b/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h index 11aaf0c8b28..f805abf84f4 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3_to_polyhedron_3.h @@ -19,12 +19,12 @@ // Author(s) : Sebastien Loriot // -#include -#include - #ifndef CGAL_CONVEX_HULL_3_TO_POLYHEDRON_3_H #define CGAL_CONVEX_HULL_3_TO_POLYHEDRON_3_H +#include +#include + namespace CGAL { template @@ -82,7 +82,7 @@ public: }; template -void convex_hull_3_to_polyhedron_3(const Triangulation_3& T,Polyhedron_3& P){ +CGAL_DEPRECATED void convex_hull_3_to_polyhedron_3(const Triangulation_3& T,Polyhedron_3& P){ P.clear(); Convex_hull_modifier_from_triangulation_3 modifier(T); P.delegate(modifier); diff --git a/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp b/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp index 9c96fc1a724..792ec440761 100644 --- a/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp +++ b/Convex_hull_3/test/Convex_hull_3/quickhull_degenerate_test_3.cpp @@ -13,7 +13,7 @@ typedef CGAL::Exact_rational Exact_rational; typedef CGAL::Cartesian< Exact_rational > R; typedef CGAL::Convex_hull_traits_3 Traits; -typedef Traits::Polyhedron_3 Polyhedron_3; +typedef Traits::Polygon_mesh Polyhedron_3; typedef R::Point_2 Point_2; typedef R::Point_3 Point_3; diff --git a/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp b/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp index b981080e97b..c5c4f22a255 100644 --- a/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp +++ b/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp @@ -11,7 +11,7 @@ typedef CGAL::Exact_rational NT; typedef CGAL::Cartesian K; typedef CGAL::Convex_hull_traits_3 Traits; -typedef Traits::Polyhedron_3 Polyhedron_3; +typedef Traits::Polygon_mesh Polyhedron_3; typedef K::Point_3 Point_3; typedef K::Segment_3 Segment_3; diff --git a/Triangulation_3/include/CGAL/link_to_face_graph.h b/Triangulation_3/include/CGAL/link_to_face_graph.h index 1d0be84f719..3fc63c460c3 100644 --- a/Triangulation_3/include/CGAL/link_to_face_graph.h +++ b/Triangulation_3/include/CGAL/link_to_face_graph.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace CGAL { @@ -42,6 +43,7 @@ link_to_face_graph(const Triangulation_3& t, typedef typename Triangulation_3::Vertex_handle Vertex_handle; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + clear(fg); vertex_descriptor inf; vertex_descriptor nullvertex = boost::graph_traits::null_vertex(); fg.clear();