From 6b129f3ad094a28e7e7a42988ba851a8b937ff9b Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 20 May 2014 17:39:56 +0200 Subject: [PATCH] unify API --- .../Constrained_Delaunay_triangulation_2.h | 24 ++++++++-- .../CGAL/Constrained_triangulation_2.h | 47 +++++++++---------- .../CGAL/Constrained_triangulation_plus_2.h | 21 +++++---- .../doc/Triangulation_2/Triangulation_2.txt | 3 +- .../Constrained_Delaunay_triangulation_2.h | 2 + 5 files changed, 55 insertions(+), 42 deletions(-) diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h index 32ddd89be59..b1e4a5d0376 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_Delaunay_triangulation_2.h @@ -111,7 +111,7 @@ Constrained_Delaunay_triangulation_2& cdt1); A templated constructor which introduces and builds a constrained triangulation with constrained edges in the range `[first,last)`. -\tparam InputIterator must be an input iterator with the value type `Constraint`. +\tparam InputIterator must be an input iterator with the value type `std::pair`. */ template Constrained_Delaunay_triangulation_2( InputIterator first, @@ -186,7 +186,7 @@ Once endpoints have been inserted, the segments are inserted in the order of the using the vertex handles of its endpoints \return the number of inserted points. -\tparam ConstraintIterator must be an input iterator with `Constraint` or `Segment_2` as value type. +\tparam ConstraintIterator must be an input iterator with `std::pair` or `Segment_2` as value type. */ template std::size_t insert_constraints(ConstraintIterator first, ConstraintIterator beyond); @@ -194,7 +194,7 @@ std::size_t insert_constraints(ConstraintIterator first, ConstraintIterator beyo /*! Same as above except that each constraints is given as a pair of indices of the points in the range [points_first, points_beyond). The indices must go from 0 to `std::distance(points_first, points_beyond)` -\tparam PointIterator is an input iterator with `Point_2` as value type. +\tparam PointIterator is an input iterator with `Point` as value type. \tparam IndicesIterator is an input iterator with `std::pair` where `Int` is an integral type implicitly convertible to `std::size_t` */ template @@ -204,7 +204,7 @@ std::size_t insert_constraints(PointIterator points_first, PointIterator points_ /*! Inserts the line segment between the points `c.first` and `c.second` as a constrained edge in the triangulation. */ -void push_back(const Constraint& c); + void push_back(const std::pair& c); /*! Inserts the line segment whose endpoints are the vertices `va` and @@ -212,6 +212,22 @@ Inserts the line segment whose endpoints are the vertices `va` and */ void insert_constraint(Vertex_handle va, Vertex_handle vb); +/*! +Inserts a polyline defined by the points in the range `[first,last)`. + +\tparam PointIterator must be an `InputIterator` with the value type `Point`. +*/ +template < class PointIterator> +void insert_constraint(PointIterator first, PointIterator last); + + +/*! +Inserts the polygon. +*/ +template +void insert_constraint(const Polygon_2& polygon); + + /*! Removes vertex v. \pre Vertex `v` is not incident to a constrained edge. diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h index 6a3700ddef9..8b7bfd7b75b 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_2.h @@ -33,8 +33,8 @@ A constrained triangulation is a triangulation of a set of points which has to include among its edges a given set of polylines joining the points. The given polylines are -called constraints and the corresponding -edges in the triangulation are called constrained edges. +called *constraints* and the corresponding +edges in the triangulation are called *constrained edges* or *sub-constraints*. The endpoints of constrained edges are of course vertices of the triangulation. However the triangulation may include @@ -57,23 +57,22 @@ is a proper intersection point of two constraints. A single constraint intersecting other constraints will then appear as the union of several constrained edges of the triangulation. -The two versions dealing with intersecting constraints, slightly differ -in the way intersecting constraints are dealt with. +There are two ways to deal with intersecting constraints.
    -
  • One of them is -designed to be robust when predicates are evaluated exactly but +
  • The first one is robust when predicates are evaluated exactly but constructions (i. e. intersection computations) are approximate. -
  • The other one is designed to be used -with an exact arithmetic (meaning exact -evaluation of predicates and exact computation of intersections.) -This last version finds its full efficiency when used in conjunction -with a constraint hierarchy data structure -as provided in the class -`Polylne_constrained_triangulation_2`. See -Section \ref Section_2D_Triangulations_Constrained_Plus. +
  • The second one should be used with exact arithmetic (meaning exact +evaluation of predicates and exact computation of intersections.)
+In order to retrieve the constrained edges of a constraint, or +the constraints overlapping with a constrained edge, we provide +the class `Constrained_triangulation_plus_2`. This class maintains +a constraint hierarchy data structure. See +Section \ref Section_2D_Triangulations_Constrained_Plus for details. +This class should also be used when doing exact intersection computations +as it avoids the cascading of intersection computations. \image html constraints.png \image latex constraints.png @@ -277,22 +276,18 @@ are removed and new ones are created. void insert_constraint(const Vertex_handle & va, const Vertex_handle & vb); /*! -Inserts the polyline defined by the iterator range `[begin,end)`. -\tparam InputIterator must be an input iterator with value type `Point`. +Inserts a polyline defined by the points in the range `[first,last)`. + +\tparam PointIterator must be an `InputIterator` with the value type `Point`. */ -template -void insert_constraint(InputIterator begin, InputIterator end); +template < class PointIterator> +void insert_constraint(PointIterator first, PointIterator last); + /*! -Inserts the polyline defined by the iterator range `range`. -\tparam IteratorRange must be an iterator range with value type `Point`. -*/ -template -void insert_constraint(IteratorRange range); - -/*! -Inserts the polygon. +Inserts the polygon. */ +template void insert_constraint(const Polygon_2& polygon); diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h index bdd889da0bf..357241eddba 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h @@ -5,9 +5,9 @@ namespace CGAL { \ingroup PkgTriangulation2TriangulationClasses The class `Constrained_triangulation_plus_2` -implements a constrained triangulation where the constraints are polylines. -It maintains an additional data structure, called the constraint hierarchy, -that keeps track of the input constraints and of their refinement +implements a constrained triangulation that +maintains an additional data structure, called the constraint hierarchy, +which keeps track of the input constraints and of their refinement in the triangulation. The class `Constrained_triangulation_plus_2` @@ -225,17 +225,18 @@ void insert_constraint(Vertex_handle va, Vertex_handle vb); Inserts a polyline defined by the points in the range `[first,last)`. Returns the constraint id. -\tparam InputIterator must be an input iterator with the value type `Point`. +\tparam PointIterator must be an `InputIterator` with the value type `Point`. */ -template < class InputIterator> -Constraint_id insert_constraint(InputIterator first, InputIterator last); +template < class PointIterator> +Constraint_id insert_constraint(PointIterator first, PointIterator last); /*! -Inserts the polyline defined by the iterator range `range`. -\tparam IteratorRange must be an iterator range with value type `Point`. +Inserts the polygon. Returns the constraint id. + */ -template -void insert_constraint(IteratorRange range); +template < class Polygon_2> +Constraint_id insert_constraint(const Polygon_2& polygon); + /*! Removes the constraint `cid`, without removing the points from the triangulation. diff --git a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt index f1db5949d83..ab74dba7cb0 100644 --- a/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt +++ b/Triangulation_2/doc/Triangulation_2/Triangulation_2.txt @@ -820,8 +820,7 @@ There are two ways to deal with intersecting constraints.
  • The first one is robust when predicates are evaluated exactly but constructions (i. e. intersection computations) are approximate. -
  • The second one is designed to be used -with exact arithmetic (meaning exact +
  • The second one should be used with exact arithmetic (meaning exact evaluation of predicates and exact computation of intersections.)
diff --git a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h index 065034da756..0cf000265ea 100644 --- a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h @@ -426,6 +426,8 @@ public: segment_indices.end() ); } + + template std::pair get_conflicts_and_boundary(const Point &p,