From c6fe1586c1d91c39eef3d21a86c0aa423ae73436 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 2 Jan 2023 16:33:45 +0000 Subject: [PATCH] Convex_hull_2: Use of 2D Delaunay --- .../doc/Convex_hull_2/Convex_hull_2.txt | 6 ++++- Convex_hull_2/doc/Convex_hull_2/examples.txt | 1 + .../examples/Convex_hull_2/ch_delaunay_2.cpp | 27 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Convex_hull_2/examples/Convex_hull_2/ch_delaunay_2.cpp diff --git a/Convex_hull_2/doc/Convex_hull_2/Convex_hull_2.txt b/Convex_hull_2/doc/Convex_hull_2/Convex_hull_2.txt index 16b2a60610d..bca9d0f275f 100644 --- a/Convex_hull_2/doc/Convex_hull_2/Convex_hull_2.txt +++ b/Convex_hull_2/doc/Convex_hull_2/Convex_hull_2.txt @@ -143,6 +143,10 @@ check whether a given sequence of 2D points forms a (counter)clockwise strongly convex polygon. These are used in postcondition testing of the two-dimensional convex hull functions. +In case you want to keep collinear points you can use the 2D Delaunay triangulation as +in the following example. This sequence is then not strongly convex. + +\cgalExample{Convex_hull_2/ch_delaunay_2.cpp} + */ } /* namespace CGAL */ - diff --git a/Convex_hull_2/doc/Convex_hull_2/examples.txt b/Convex_hull_2/doc/Convex_hull_2/examples.txt index 8439df4a923..63515ecab88 100644 --- a/Convex_hull_2/doc/Convex_hull_2/examples.txt +++ b/Convex_hull_2/doc/Convex_hull_2/examples.txt @@ -6,4 +6,5 @@ \example Convex_hull_2/ch_timing.cpp \example Convex_hull_2/iostream_convex_hull_2.cpp \example Convex_hull_2/vector_convex_hull_2.cpp +\example Convex_hull_2/ch_delaunay_2.cpp */ diff --git a/Convex_hull_2/examples/Convex_hull_2/ch_delaunay_2.cpp b/Convex_hull_2/examples/Convex_hull_2/ch_delaunay_2.cpp new file mode 100644 index 00000000000..0b80ee4c3de --- /dev/null +++ b/Convex_hull_2/examples/Convex_hull_2/ch_delaunay_2.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_2 Point_2; +typedef CGAL::Delaunay_triangulation_2 Delaunay_triangulation_2; + + +int main() +{ + std::vector input = { Point_2(0, 0), Point_2(1,1), Point_2(2,0), Point_2(2,2), Point_2(1,2), Point_2(0,2) }; + + Delaunay_triangulation_2 dt(input.begin(), input.end()); + + std::list result; + Delaunay_triangulation_2::Vertex_circulator vc = dt.incident_vertices(dt.infinite_vertex()), done(vc); + do{ + std ::cout << vc->point() << std::endl; + // push_front in order to obtain the counterclockwise sequence + result.push_front(vc->point()); + ++vc; + }while(vc != done); + + return 0; +}