Testwise STL_Extension + Mesh_2
|
|
@ -2735,6 +2735,29 @@ Mesh_2/benchmark/data/square.poly -text svneol=unset#application/octet-stream
|
||||||
Mesh_2/demo/Mesh_2/data/clusters.poly -text svneol=unset#application/octet-stream
|
Mesh_2/demo/Mesh_2/data/clusters.poly -text svneol=unset#application/octet-stream
|
||||||
Mesh_2/demo/Mesh_2/data/fish.poly -text svneol=unset#application/octet-stream
|
Mesh_2/demo/Mesh_2/data/fish.poly -text svneol=unset#application/octet-stream
|
||||||
Mesh_2/demo/Mesh_2/data/trivial.poly -text svneol=unset#application/octet-stream
|
Mesh_2/demo/Mesh_2/data/trivial.poly -text svneol=unset#application/octet-stream
|
||||||
|
Mesh_2/doc/Mesh_2/CGAL/Delaunay_mesh_criteria_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/CGAL/Delaunay_mesh_face_base_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/CGAL/Delaunay_mesh_size_criteria_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/CGAL/Delaunay_mesher_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/CGAL/Mesh_2/Face_badness.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/CGAL/Triangulation_conformer_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/Classified.txt -text
|
||||||
|
Mesh_2/doc/Mesh_2/Concepts/ConformingDelaunayTriangulationTraits_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/Concepts/DelaunayMeshFaceBase_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/Concepts/DelaunayMeshTraits_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/Concepts/MeshingCriteria_2.h -text
|
||||||
|
Mesh_2/doc/Mesh_2/Mesh_2.txt -text
|
||||||
|
Mesh_2/doc/Mesh_2/PackageDescription.txt -text
|
||||||
|
Mesh_2/doc/Mesh_2/fig/delaunaymesh-small.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/delaunaymesh-teaser.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/domain-mesh.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/domain-seeds-mesh.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/domain-seeds.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/domain.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/example-conform-Delaunay.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/example-conform-Gabriel.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/example-conform.png -text svneol=unset#image/png
|
||||||
|
Mesh_2/doc/Mesh_2/fig/part_of_a_cluster.gif -text svneol=unset#image/gif
|
||||||
Mesh_2/doc_tex/Mesh_2/delaunaymesh-small.png -text svneol=unset#image/png
|
Mesh_2/doc_tex/Mesh_2/delaunaymesh-small.png -text svneol=unset#image/png
|
||||||
Mesh_2/doc_tex/Mesh_2/delaunaymesh-teaser.png -text svneol=unset#image/png
|
Mesh_2/doc_tex/Mesh_2/delaunaymesh-teaser.png -text svneol=unset#image/png
|
||||||
Mesh_2/doc_tex/Mesh_2/domain-mesh.png -text svneol=unset#image/png
|
Mesh_2/doc_tex/Mesh_2/domain-mesh.png -text svneol=unset#image/png
|
||||||
|
|
@ -3672,6 +3695,29 @@ Robustness/demo/Robustness/help/index.html svneol=native#text/html
|
||||||
STL_Extension/benchmark/copy_n_benchmark/CMakeLists.txt -text
|
STL_Extension/benchmark/copy_n_benchmark/CMakeLists.txt -text
|
||||||
STL_Extension/benchmark/copy_n_benchmark/copy_n_benchmark.cpp -text
|
STL_Extension/benchmark/copy_n_benchmark/copy_n_benchmark.cpp -text
|
||||||
STL_Extension/benchmark/copy_n_benchmark/copy_n_use_case_benchmark.cpp -text
|
STL_Extension/benchmark/copy_n_benchmark/copy_n_use_case_benchmark.cpp -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Compact_container.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Complexity_tags.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Default.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Fourtuple.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/In_place_list.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Location_policy.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Multiset.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Object.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Sixtuple.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Threetuple.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Twotuple.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/Uncertain.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/algorithm.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/array.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/function_objects.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/iterator.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/tags.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/tuple.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/CGAL/utility.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/Concepts/Projection_object.h -text
|
||||||
|
STL_Extension/doc/STL_Extension/PackageDescription.txt -text
|
||||||
|
STL_Extension/doc/STL_Extension/STL_Extension.txt -text
|
||||||
|
STL_Extension/doc/STL_Extension/fig/plusplus.png -text svneol=unset#image/png
|
||||||
STL_Extension/doc_tex/STL_Extension/plusplus.png -text
|
STL_Extension/doc_tex/STL_Extension/plusplus.png -text
|
||||||
STL_Extension/include/CGAL/internal/boost/array_binary_tree.hpp -text
|
STL_Extension/include/CGAL/internal/boost/array_binary_tree.hpp -text
|
||||||
STL_Extension/include/CGAL/internal/boost/mutable_heap.hpp -text
|
STL_Extension/include/CGAL/internal/boost/mutable_heap.hpp -text
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Delaunay_mesh_criteria_2` is a model for the `MeshingCriteria_2` concept.
|
||||||
|
The shape criterion on triangles is given by a bound \f$ B\f$ such that for good
|
||||||
|
triangles \f$ \frac{r}{l} \le B\f$ where \f$ l\f$ is the shortest edge length
|
||||||
|
and \f$ r\f$ is the circumradius of the triangle. By default, \f$ B=\sqrt{2}\f$,
|
||||||
|
which is the best bound one can use with the guarantee that the refinement
|
||||||
|
algorithm will terminate. The upper bound \f$ B\f$ is related to a lower bound
|
||||||
|
\f$ \alpha_{min}\f$ on the minimum angle in the triangle:
|
||||||
|
\f[
|
||||||
|
\sin{ \alpha_{min} } = \frac{1}{2 B}
|
||||||
|
\f]
|
||||||
|
so \f$ B=\sqrt{2}\f$ corresponds to \f$ \alpha_{min} \ge 20.7\f$ degrees.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::MeshingCriteria_2
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename CDT >
|
||||||
|
class Delaunay_mesh_criteria_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Default constructor. \f$ B=\sqrt{2}\f$.
|
||||||
|
*/
|
||||||
|
Delaunay_mesh_criteria_2();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Construct
|
||||||
|
a traits class with bound \f$ B=\sqrt{\frac{1}{4 b}}\f$.
|
||||||
|
*/
|
||||||
|
Delaunay_mesh_criteria_2(double b = 0.125);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Delaunay_mesh_criteria_2 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Delaunay_mesh_face_base_2` is a model for the concept
|
||||||
|
`DelaunayMeshFaceBase_2`.
|
||||||
|
|
||||||
|
This class can be used directly or it can serve as a base to derive other
|
||||||
|
classes with some additional attributes (a color for example) tuned to a
|
||||||
|
specific application.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
<UL>
|
||||||
|
<LI>The first parameter `Traits` is the geometric traits class. It must
|
||||||
|
be the same as the one used for the Delaunay mesh.
|
||||||
|
<LI>The second parameter `Fb` is the base class from which `Delaunay_mesh_face_base_2`
|
||||||
|
derives. It must be a model of the `TriangulationFaceBase_2` concept.
|
||||||
|
</UL>
|
||||||
|
|
||||||
|
\models ::DelaunayMeshFaceBase_2
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Traits, typename Fb >
|
||||||
|
class Delaunay_mesh_face_base_2 : Fb {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Delaunay_mesh_face_base_2 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Delaunay_mesh_size_criteria_2` is a model for the `MeshingCriteria_2` concept.
|
||||||
|
The shape criterion on triangles is given by a bound \f$ B\f$ such that for good
|
||||||
|
triangles \f$ \frac{r}{l} \le B\f$ where \f$ l\f$ is the shortest edge length
|
||||||
|
and \f$ r\f$ is the circumradius of the triangle. By default, \f$ B=\sqrt{2}\f$,
|
||||||
|
which is the best bound one can use with the guarantee that the refinement
|
||||||
|
algorithm will terminate. The upper bound \f$ B\f$ is related to a lower bound
|
||||||
|
\f$ \alpha_{min}\f$ on the minimum angle in the triangle:
|
||||||
|
\f[
|
||||||
|
\sin{ \alpha_{min} } = \frac{1}{2 B}
|
||||||
|
\f]
|
||||||
|
so \f$ B=\sqrt{2}\f$ corresponds to \f$ \alpha_{min} \ge 20.7\f$ degrees.
|
||||||
|
|
||||||
|
This traits class defines also a size criteria: all segments of all
|
||||||
|
triangles must be shorter than a bound \f$ S\f$.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::MeshingCriteria_2
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename CDT >
|
||||||
|
class Delaunay_mesh_size_criteria_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Default
|
||||||
|
constructor. \f$ B=\sqrt{2}\f$. No bound on size
|
||||||
|
*/
|
||||||
|
Delaunay_mesh_size_criteria_2();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Construct a traits class with bound \f$ B=\sqrt{\frac{1}{4
|
||||||
|
b}}\f$. If \f$ S \neq0\f$, the size bound is \f$ S\f$. If \f$ S = 0\f$, there is
|
||||||
|
no bound on size.
|
||||||
|
*/
|
||||||
|
Delaunay_mesh_size_criteria_2(double b = 0.125, double S =
|
||||||
|
0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Delaunay_mesh_size_criteria_2 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,307 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
|
||||||
|
This class implements a 2D mesh generator.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The template parameter `CDT` should be a model of the
|
||||||
|
concept `ConstrainedDelaunayTriangulation_2`, and type `CDT::Face`
|
||||||
|
should be a model of the concept `MeshFaceBase_2`.
|
||||||
|
|
||||||
|
The geometric traits class of the instance of `CDT` has to be
|
||||||
|
a model of the concept `DelaunayMeshTraits_2`.
|
||||||
|
|
||||||
|
The template parameter `Criteria` should be a model of the concept
|
||||||
|
`MeshingCriteria_2`. This traits class defines the shape and size
|
||||||
|
criteria for the triangles of the mesh. `Criteria::Face_handle` has to
|
||||||
|
be the same as `CDT::Face_handle`.
|
||||||
|
|
||||||
|
Using this class
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The constructor of the class `Delaunay_mesher_2` takes a reference to a `CDT`
|
||||||
|
as an argument. A call to the refinement method `refine_mesh()` will
|
||||||
|
refine the constrained Delaunay triangulation into a mesh satisfying the
|
||||||
|
size and shape criteria specified in the traits class. Note that if, during
|
||||||
|
the life time of the `Delaunay_mesher_2` object, the triangulation is externally
|
||||||
|
modified, any further call to its member methods may crash. Consider
|
||||||
|
constructing a new `Delaunay_mesher_2` object if the triangulation has been
|
||||||
|
modified.
|
||||||
|
|
||||||
|
Meshing domain
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The domain to be mesh is defined by the constrained edges and a set of seed
|
||||||
|
points. The constrained edges divides the plane into several connected
|
||||||
|
components. The mesh domain is either the union of the bounded connected
|
||||||
|
components including at least one seed, or the union of the bounded
|
||||||
|
connected components that do no contain any seed. Note that the unbounded
|
||||||
|
component of the plane is never meshed.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename CDT, typename Criteria >
|
||||||
|
class Delaunay_mesher_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
the geometric traits class.
|
||||||
|
*/
|
||||||
|
typedef CDT::Geom_traits Geom_traits;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
const iterator over defined seeds. Its
|
||||||
|
value type is `Geom_traits::Point_2`.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Seeds_iterator;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Create a new mesher, working on `t`, with meshing criteria
|
||||||
|
`criteria`.
|
||||||
|
*/
|
||||||
|
Delaunay_mesher_2(CDT& t, Criteria criteria = Criteria());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Seeds functions
|
||||||
|
/// The following functions are used to define seeds.
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets seeds to the empty set. All
|
||||||
|
finite connected components of the constrained triangulation will be
|
||||||
|
refined.
|
||||||
|
*/
|
||||||
|
void clear_seeds ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets seeds to the sequence [`begin`,
|
||||||
|
`end`]. If `mark=true`, the mesh domain
|
||||||
|
is the union of the bounded connected
|
||||||
|
components including at least one seed. If
|
||||||
|
`mark=false`, the domain is the union of
|
||||||
|
the bounded components including no seed. Note
|
||||||
|
that the unbounded component of the plane is
|
||||||
|
never meshed.
|
||||||
|
\require The `value_type` of `begin` and `end` is `Geom_traits::Point_2`.
|
||||||
|
*/
|
||||||
|
template<class InputIterator>
|
||||||
|
void set_seeds(InputIterator begin, InputIterator end,
|
||||||
|
const bool mark=false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Start of the seeds sequence.
|
||||||
|
*/
|
||||||
|
Seeds_const_iterator seeds_begin () const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Past the end of the seeds sequence.
|
||||||
|
*/
|
||||||
|
Seeds_const_iterator seeds_end () const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\name Meshing methods
|
||||||
|
The function `set_criteria` scans all faces to recalculate the list of
|
||||||
|
<I>bad faces</I>, that are faces not conforming to the meshing criteria.
|
||||||
|
This function actually has an optional argument that permits to prevent
|
||||||
|
this recalculation. The filling of the list of bad faces can then be done
|
||||||
|
by a call to `set_bad_faces`.
|
||||||
|
*/
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Refines the constrained Delaunay triangulation into a mesh
|
||||||
|
satisfying the criteria defined by the traits.
|
||||||
|
|
||||||
|
*/
|
||||||
|
void refine_mesh();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns a const reference to the criteria traits object.
|
||||||
|
*/
|
||||||
|
const Criteria& get_criteria();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Assigns `criteria` to the criteria traits object.
|
||||||
|
*/
|
||||||
|
void set_criteria(Criteria criteria);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Assigns `criteria` to the criteria traits object. If
|
||||||
|
`recalculate_bad_faces` is `false`, the list of bad faces is
|
||||||
|
let empty and the function `set_bad_faces` should be called before
|
||||||
|
`refine_mesh`.
|
||||||
|
*/
|
||||||
|
void set_criteria(Criteria criteria, bool
|
||||||
|
recalculate_bad_faces);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This method permits to set the list of bad triangles
|
||||||
|
directly, from the sequence [begin, end], so that the
|
||||||
|
algorithm will not scan the whole set of triangles to
|
||||||
|
find bad ones. To use if there is a non-naive way to
|
||||||
|
find bad triangles. \require The `value_type` of `begin` and `end` is `Face_handle`.
|
||||||
|
*/
|
||||||
|
template <class InputIterator>
|
||||||
|
void set_bad_faces(InputIterator begin,
|
||||||
|
InputIterator end);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Step by step operations
|
||||||
|
/// The `Delaunay_mesher_2` class allows, for debugging or demos, to play the
|
||||||
|
/// meshing algorithm step by step, using the following methods.
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This method must be called just before the first
|
||||||
|
call to the following step by step refinement method,
|
||||||
|
that is when all vertices and constrained edges have been
|
||||||
|
inserted into the constrained Delaunay triangulation. It
|
||||||
|
must be called again before any subsequent calls to the
|
||||||
|
step by step refinement method if new vertices or constrained
|
||||||
|
edges have been inserted since the last call.
|
||||||
|
*/
|
||||||
|
void init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Tests if the step by step refinement algorithm is done. If it returns
|
||||||
|
`true`, the following calls to `step_by_step_refine_mesh` will
|
||||||
|
not insert any points, until some new constrained segments or points are
|
||||||
|
inserted in the triangulation and `init` is called again.
|
||||||
|
*/
|
||||||
|
bool is_refinement_done();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Applies one step of the algorithm, by inserting one point, if the
|
||||||
|
algorithm is not done. Returns `false` iff no point has been inserted
|
||||||
|
because the algorithm is done.
|
||||||
|
*/
|
||||||
|
bool step_by_step_refine_mesh();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Delaunay_mesher_2 */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
Refines the default domain defined by a constrained Delaunay
|
||||||
|
triangulation without seeds into a mesh satisfying the criteria
|
||||||
|
defined by the traits `criteria`. The domain of the mesh
|
||||||
|
covers all the connected components of the plane defined by the
|
||||||
|
constrained edges of `t`, except for the unbounded component.
|
||||||
|
\pre The template parameter `CDT` must be a model of the concept `ConstrainedDelaunayTriangulation_2`. The geometric traits class of the constrained Delaunay triangulation must be a model of `DelaunayMeshTraits_2`.
|
||||||
|
\require The face of the constrained Delaunay triangulation must be a model of the concept `DelaunayMeshFaceBase_2`.
|
||||||
|
\require `Criteria` must be a model of the concept `MeshingCriteria_2`.
|
||||||
|
\require `CDT::Face_handle` must be the same as `Criteria::Face_handle`.
|
||||||
|
*/
|
||||||
|
template<class CDT, class Criteria>
|
||||||
|
void refine_Delaunay_mesh_2 (CDT &t, const Criteria& criteria = Criteria());
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
Refines the default domain defined by a constrained
|
||||||
|
Delaunay triangulation into a mesh
|
||||||
|
satisfying the criteria defined by the traits
|
||||||
|
`criteria`.The sequence [`begin`, `end`]
|
||||||
|
gives a set of seeds points, that defines the domain
|
||||||
|
to be meshed as follows. The constrained edges of
|
||||||
|
`t` partition the plane into connected components.
|
||||||
|
If `mark=true`, the mesh domain is the union of
|
||||||
|
the bounded connected components including at least
|
||||||
|
one seed. If `mark=false`, the domain is the
|
||||||
|
union of the bounded components including no seed.
|
||||||
|
Note that the unbounded component of the plane is
|
||||||
|
never meshed.
|
||||||
|
\require The `value_type` of `begin` and `end` is `CDT::Geom_traits::Point_2`.
|
||||||
|
*/
|
||||||
|
template <class CDT, class Criteria, class InputIterator>
|
||||||
|
void refine_Delaunay_mesh_2(CDT& t,
|
||||||
|
InputIterator begin, InputIterator end,
|
||||||
|
const Criteria& criteria = Criteria(),
|
||||||
|
bool mark = false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace CGAL {
|
||||||
|
namespace Mesh_2 {
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
*/
|
||||||
|
enum Face_badness { NOT_BAD, BAD, IMPERATIVELY_BAD};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,230 @@
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Refines the constrained Delaunay triangulation `t` into a
|
||||||
|
conforming Delaunay triangulation. After a call to this function,
|
||||||
|
all edges of `t` are Delaunay edges.
|
||||||
|
\require The template parameter `CDT` should be a model of the concept `ConstrainedDelaunayTriangulation_2`.
|
||||||
|
\require The geometric traits class of into the constrained Delaunay triangulation must be a model of `ConformingDelaunayTriangulationTraits_2`.
|
||||||
|
*/
|
||||||
|
template<class CDT> void make_conforming_Delaunay_2 (CDT &t);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Refines the constrained Delaunay triangulation `t` into a
|
||||||
|
conforming Gabriel triangulation. After a call to this function, all
|
||||||
|
constrained edges of `t` have the <I>Gabriel property</I>: the
|
||||||
|
circle that has \f$ e\f$ as diameter does not contain any vertex from
|
||||||
|
the triangulation.
|
||||||
|
\require The template parameter `CDT` should be a model of the concept `ConstrainedDelaunayTriangulation_2`.
|
||||||
|
\require The geometric traits class of the constrained Delaunay triangulation must be a model of `ConformingDelaunayTriangulationTraits_2`.
|
||||||
|
*/
|
||||||
|
template<class CDT> void make_conforming_Gabriel_2 (CDT &t);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2
|
||||||
|
|
||||||
|
|
||||||
|
The class `Triangulation_conformer_2` is an auxiliary class of
|
||||||
|
`Delaunay_mesher_2<CDT>`. It permits to refine a constrained
|
||||||
|
Delaunay triangulation into a conforming Delaunay or conforming
|
||||||
|
Gabriel triangulation. For standard needs, consider using the global
|
||||||
|
functions `make_conforming_Gabriel_2` and
|
||||||
|
`make_conforming_Delaunay_2`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The template parameter `CDT` should be a model of the concept
|
||||||
|
`ConstrainedDelaunayTriangulation_2`.
|
||||||
|
|
||||||
|
The geometric traits class of the instance of `CDT` has to be
|
||||||
|
a model of the concept `ConformingDelaunayTriangulationTraits_2`.
|
||||||
|
|
||||||
|
Using this class
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The constructor of the class `Triangulation_conformer_2` takes a reference to a `CDT`
|
||||||
|
as an argument. A call to the method `make_conforming_Delaunay()` or
|
||||||
|
`make_conforming_Gabriel()` will refine this constrained Delaunay
|
||||||
|
triangulation into a conforming Delaunay or conforming Gabriel
|
||||||
|
triangulation. Note that if, during the life time of the `Triangulation_conformer_2` object, the triangulation is externally modified, any further call to its
|
||||||
|
member methods may lead to undefined behavior. Consider reconstructing a
|
||||||
|
new `Triangulation_conformer_2` object if the triangulation has been modified.
|
||||||
|
|
||||||
|
The conforming methods insert points into constrained edges, thereby splitting
|
||||||
|
them into several sub-constraints. You have access to the initial inserted
|
||||||
|
constraints if you instantiate the template parameter by a
|
||||||
|
`CGAL::Constrained_triangulation_plus_2<CDT>`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename CDT >
|
||||||
|
class Triangulation_conformer_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Create a new conforming maker, working on `t`.
|
||||||
|
*/
|
||||||
|
Triangulation_conformer_2(CDT& t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Conforming methods
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Refines the triangulation into a conforming Delaunay triangulation.
|
||||||
|
After a call to this method, all triangles fulfill the Delaunay property,
|
||||||
|
that is the empty circle
|
||||||
|
property.
|
||||||
|
*/
|
||||||
|
void make_conforming_Delaunay();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Refines the triangulation into a conforming Gabriel triangulation.
|
||||||
|
After a call to this method, all constrained edges \f$ e\f$ have the
|
||||||
|
<I>Gabriel property</I>: the circle with diameter \f$ e\f$
|
||||||
|
does not contain any vertex of the triangulation.
|
||||||
|
*/
|
||||||
|
void make_conforming_Gabriel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\name Checking
|
||||||
|
The following methods verify that the constrained triangulation is
|
||||||
|
conforming Delaunay or conforming Gabriel. These methods scan the
|
||||||
|
whole triangulation and their complexity is proportional to the number
|
||||||
|
of edges.
|
||||||
|
*/
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns `true` iff all triangles fulfill the Delaunay property.
|
||||||
|
*/
|
||||||
|
bool is_conforming_Delaunay();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns `true` iff all constrained edges have the Gabriel property:
|
||||||
|
their circumsphere is empty.
|
||||||
|
*/
|
||||||
|
bool is_conforming_Gabriel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\name Step by step operations
|
||||||
|
The `Triangulation_conformer_2` class allows, for debugging or demos, to play the
|
||||||
|
conforming algorithm step by step, using the following methods. They exist
|
||||||
|
in two versions, depending on whether you want the triangulation to be
|
||||||
|
conforming Delaunay or conforming Gabriel, respectively. Any call to a
|
||||||
|
`step_by_step_conforming_XX` function requires a previous call to the
|
||||||
|
corresponding function `init_XX` and Gabriel and Delaunay methods can
|
||||||
|
not be mixed between two calls of `init_XX`.
|
||||||
|
*/
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The method must be called after all points and constrained segments
|
||||||
|
are inserted and before any call to the following methods. If some
|
||||||
|
points or segments are then inserted in the triangulation, this
|
||||||
|
method must be called again.
|
||||||
|
*/
|
||||||
|
void init_Delaunay();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Applies one step of the algorithm, by inserting one point, if the
|
||||||
|
algorithm is not done. Returns `false` iff no point has been inserted
|
||||||
|
because the algorithm is done.
|
||||||
|
*/
|
||||||
|
bool step_by_step_conforming_Delaunay ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Analog to
|
||||||
|
`init_Delaunay` for Gabriel conforming.
|
||||||
|
*/
|
||||||
|
void init_Gabriel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Analog to
|
||||||
|
`step_by_step_conforming_Delaunay()` for Gabriel conforming.
|
||||||
|
*/
|
||||||
|
bool step_by_step_conforming_Gabriel ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Tests if the step by step conforming algorithm is done. If it
|
||||||
|
returns `true`, the following calls to
|
||||||
|
`step_by_step_conforming_XX` will not insert any points, until some
|
||||||
|
new constrained segments or points are inserted in the triangulation and
|
||||||
|
`init_XX` is called again.
|
||||||
|
*/
|
||||||
|
bool is_conforming_done();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Triangulation_conformer_2 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
# Classified Reference Pages #
|
||||||
|
|
||||||
|
## Concepts ##
|
||||||
|
|
||||||
|
`ConformingDelaunayTriangulationTraits_2`
|
||||||
|
|
||||||
|
`DelaunayMeshTraits_2`
|
||||||
|
|
||||||
|
`MeshingCriteria_2`
|
||||||
|
|
||||||
|
`DelaunayMeshFaceBase_2`
|
||||||
|
|
||||||
|
## Classes ##
|
||||||
|
|
||||||
|
`CGAL::Triangulation_conformer_2<CDT>`
|
||||||
|
|
||||||
|
`CGAL::Delaunay_mesher_2<CDT, Criteria>`
|
||||||
|
|
||||||
|
`CGAL::Delaunay_mesh_face_base_2<Traits, Fb>`
|
||||||
|
|
||||||
|
`CGAL::Delaunay_mesh_criteria_2<CDT>`
|
||||||
|
|
||||||
|
`CGAL::Delaunay_mesh_size_criteria_2<CDT>`
|
||||||
|
|
||||||
|
`CGAL::Mesh_2::Face_badness`
|
||||||
|
|
||||||
|
## Global functions ##
|
||||||
|
|
||||||
|
`CGAL::make_conforming_Delaunay_2`
|
||||||
|
|
||||||
|
`CGAL::make_conforming_Gabriel_2`
|
||||||
|
|
||||||
|
`CGAL::refine_Delaunay_mesh_2`
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2Concepts
|
||||||
|
\cgalconcept
|
||||||
|
|
||||||
|
|
||||||
|
The concept `ConformingDelaunayTriangulationTraits_2` refines the concept
|
||||||
|
`ConstrainedDelaunayTriangulationTraits_2` by providing a numeric
|
||||||
|
field type `FT`, a type `Vector_2` and several constructors on
|
||||||
|
`Vector_2`, `Point_2`, and a predicate on angles.
|
||||||
|
The field type has to be a model of
|
||||||
|
the concept `SqrtFieldNumberType`. This field type and the
|
||||||
|
constructors are used by the conforming algorithm to compute Steiner
|
||||||
|
points on constrained edges.
|
||||||
|
|
||||||
|
\refines ::DelaunayTriangulationTraits_2
|
||||||
|
|
||||||
|
\hasModel Any model of `Kernel` concept. In particular, all \cgal kernels.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ConformingDelaunayTriangulationTraits_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The field type. It must be a model of
|
||||||
|
`SqrtFieldNumberType`, that is must be a number type
|
||||||
|
supporting the operations \f$ +\f$, \f$ -\f$, \f$ *\f$, \f$ /\f$, and \f$ \sqrt{\cdot}\f$.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type FT;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The vector type.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Vector_2;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor object. Must
|
||||||
|
provide the operator `Vector_2 operator()(Point a, Point b)`
|
||||||
|
that computes the vector \f$ b-a\f$.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Construct_vector_2;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor object. Must
|
||||||
|
provide the operator `Vector_2 operator()(Vector_2 v, FT scale)`
|
||||||
|
that computes the vector \f$ scale \cdot\mathbf{v}\f$.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Construct_scaled_vector_2;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor object. Must
|
||||||
|
provide the operator `Point_2 operator()(Point_2 p, Vector_2 v)`
|
||||||
|
that computes the point \f$ p + \mathbf{v}\f$.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Construct_translated_point_2;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor object. Must provide
|
||||||
|
the operator `Point_2 operator()(Point_2 a, Point_2 b)` that
|
||||||
|
computes the midpoint of the segment \f$ ab\f$.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Construct_midpoint_2;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor object. Must
|
||||||
|
provide the operator `FT operator()(Point_2 a, Point_2 b)` that
|
||||||
|
computes the squared distance between \f$ a\f$ and \f$ b\f$.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Compute_squared_distance_2;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Predicate object. Must provide the operator
|
||||||
|
`CGAL::Angle operator()(Point_2 p, Point_2 q, Point_2 r)` that
|
||||||
|
returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the three
|
||||||
|
points p, q, r (q being the vertex of the angle).
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Angle_2;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access to predicate and constructor objects
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Construct_vector_2 construct_vector_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Construct_scaled_vector_2 construct_scaled_vector_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Construct_translated_point_2
|
||||||
|
construct_translated_point_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Constructor_midpoint_2 construct_midpoint_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Compute_squared_distance_2
|
||||||
|
compute_squared_distance_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Angle_2 angle_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end ConformingDelaunayTriangulationTraits_2 */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2Concepts
|
||||||
|
\cgalconcept
|
||||||
|
|
||||||
|
|
||||||
|
The concept `DelaunayMeshFaceBase_2` refines the concept
|
||||||
|
`TriangulationFaceBase_2`. It adds two functions giving access
|
||||||
|
to a Boolean marker, that indicates if the face is in the
|
||||||
|
meshing domain or not.
|
||||||
|
|
||||||
|
\refines ::ConstrainedTriangulationFaceBase_2
|
||||||
|
|
||||||
|
\hasModel Delaunay_mesh_face_base_2<Traits, Fb>
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DelaunayMeshFaceBase_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Access Functions
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns true if this face is in the domain to be refined.
|
||||||
|
*/
|
||||||
|
bool is_in_domain() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
sets if this face is in the domain.
|
||||||
|
*/
|
||||||
|
void set_in_domain(const bool b);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end DelaunayMeshFaceBase_2 */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2Concepts
|
||||||
|
\cgalconcept
|
||||||
|
|
||||||
|
|
||||||
|
The concept `DelaunayMeshTraits_2` refines the concept
|
||||||
|
`ConformingDelaunayTriangulationTraits_2`. It provides a construction
|
||||||
|
object `Construct_circumcenter_2`.
|
||||||
|
|
||||||
|
\refines ::ConformingDelaunayTriangulationTraits_2
|
||||||
|
|
||||||
|
\hasModel Any model of the `Kernel` concept. In particular, all \cgal kernels.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DelaunayMeshTraits_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor object. Must provide
|
||||||
|
an operator `Point_2 operator()(Point_2 p,
|
||||||
|
Point_2 q,
|
||||||
|
Point_2 r);`
|
||||||
|
that constructs the center of the circle passing through the points \f$ p\f$,
|
||||||
|
\f$ q\f$, and \f$ r\f$.
|
||||||
|
\pre \f$ p\f$, \f$ q\f$, and \f$ r\f$ are not collinear.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Construct_circumcenter_2;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor object. Must provide an operator
|
||||||
|
`FT operator()(Point_2 p,
|
||||||
|
Point_2 q,
|
||||||
|
Point_2 r);`
|
||||||
|
that computes the signed area of the triangle defined by
|
||||||
|
the points \f$ p\f$, \f$ q\f$, and \f$ r\f$.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Compute_area_2;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access to predicate and constructor objects
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Construct_circumcenter_2 construct_circumcenter_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Compute_area_2 compute_area_2_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end DelaunayMeshTraits_2 */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,99 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgMesh2Concepts
|
||||||
|
\cgalconcept
|
||||||
|
|
||||||
|
|
||||||
|
The concept `MeshingCriteria_2` defines the meshing criteria to be used in the
|
||||||
|
algorithm. It provides a predicate `Is_bad` that tests a triangle
|
||||||
|
according to criteria. The return type of `Is_bad` is an enum
|
||||||
|
`Mesh_2::Face_badness`.
|
||||||
|
|
||||||
|
The possible values of `Mesh_2::Face_badness` are `NOT_BAD`,
|
||||||
|
`BAD` and `IMPERATIVELY_BAD`. If the predicate returns `BAD`,
|
||||||
|
the triangle is marked as bad and the algorithm will try to destroy it. If
|
||||||
|
the predicates returns `IMPERATIVELY_BAD`, the algorithm will destroy
|
||||||
|
the triangle unconditionally during its execution.
|
||||||
|
|
||||||
|
The termination of the algorithm is guaranteed when criteria are shape
|
||||||
|
criteria corresponding to a bound on smallest angles not less than
|
||||||
|
\f$ 20.7\f$ degrees (this corresponds to a radius-edge ratio bound not less
|
||||||
|
than \f$ \sqrt{2}\f$). Any size criteria that are satisfied by small enough
|
||||||
|
triangle can be added to the set of criteria without compromising
|
||||||
|
the termination.
|
||||||
|
|
||||||
|
Note that, in the presence of input angles smaller than \f$ 60\f$ degrees,
|
||||||
|
some bad shaped triangles can appear in the final mesh in the
|
||||||
|
neighboring of small angles. To achieve termination and the respect of
|
||||||
|
size criteria everywhere, the `Is_bad` predicate has to return
|
||||||
|
`IMPERATIVELY_BAD` when size criteria are not satisfied, and
|
||||||
|
`BAD` when shape criteria are not satisfied.
|
||||||
|
|
||||||
|
`MeshingCriteria_2` also provides a type `Quality` designed to code a quality
|
||||||
|
measure for triangles. The type `Quality` must be <I>less-than
|
||||||
|
comparable</I> as the meshing algorithm will order bad triangles by quality,
|
||||||
|
to split those with smallest quality first. The predicate `Is_bad`
|
||||||
|
computes the quality of the triangle as a by-product.
|
||||||
|
|
||||||
|
\hasModel Delaunay_mesh_criteria_2<CDT>
|
||||||
|
\hasModel Delaunay_mesh_size_criteria_2<CDT>
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class MeshingCriteria_2 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Handle to a face of the triangulation.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Face_handle;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Default constructible, copy constructible,
|
||||||
|
assignable, and less-than comparable type.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Quality;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Predicate object. Must provide two operators. The
|
||||||
|
first operator `Mesh_2::Face_badness operator()(Face_handle fh,
|
||||||
|
Quality& q)` returns `NOT_BAD` if it satisfies the desired criteria
|
||||||
|
for mesh triangles, `BAD` if it does not, and `IMPERATIVELY_BAD`
|
||||||
|
if it does not and should be refined unconditionally. In addition, this
|
||||||
|
operator assigns to `q` a value measuring the quality of the triangle
|
||||||
|
pointed by `fh`. The second operator `Mesh_2::Face_badness
|
||||||
|
operator()(Quality q)` returns `NOT_BAD` if `q` is the quality
|
||||||
|
of a good triangle, `BAD` if the `q` represents a poor quality,
|
||||||
|
and `IMPERATIVELY_BAD` if `q` represents the quality of a bad
|
||||||
|
triangle that should be refined unconditionally.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Is_bad;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access to predicate and constructor objects
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Is_bad is_bad_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end MeshingCriteria_2 */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,282 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\page user_chapter_2D_Meshes 2D Conforming Triangulations and Meshes
|
||||||
|
\author Laurent Rineau
|
||||||
|
|
||||||
|
This package implements Shewchuk's algorithm \cite s-mgdsa-00 to construct
|
||||||
|
conforming triangulations and 2D meshes. Conforming triangulations will be
|
||||||
|
described in Section \ref secMesh_2_conforming_triangulation and
|
||||||
|
meshes in Section \ref secMesh_2_meshes .
|
||||||
|
|
||||||
|
\section secMesh_2_conforming_triangulation Conforming Triangulations
|
||||||
|
|
||||||
|
\subsection secMesh_2_conforming_definitions Definitions
|
||||||
|
|
||||||
|
A triangulation is a <I>Delaunay triangulation</I> if the circumscribing
|
||||||
|
circle of any facet of the triangulation contains no vertex in its
|
||||||
|
interior. A <I>constrained</I> Delaunay triangulation is a constrained
|
||||||
|
triangulation which is as much Delaunay as possible. The circumscribing
|
||||||
|
circle of any facet of a constrained Delaunay triangulation contains in its
|
||||||
|
interior no data point <I>visible</I> from the facet.
|
||||||
|
|
||||||
|
An edge is said to be a <I>Delaunay edge</I> if it is inscribed in an empty
|
||||||
|
circle (containing no data point in its interior). This edge is said to be a
|
||||||
|
<I>Gabriel edge</I> if its diametrical circle is empty.
|
||||||
|
|
||||||
|
A constrained Delaunay triangulation is said to be a <I>conforming
|
||||||
|
Delaunay triangulation</I> if every constrained edge is a Delaunay edge.
|
||||||
|
Because any edge in a constrained Delaunay triangulation is either a
|
||||||
|
Delaunay edge or a constrained edge, a conforming Delaunay triangulation is
|
||||||
|
in fact a Delaunay triangulation. The only difference is that some of the
|
||||||
|
edges are marked as constrained edges.
|
||||||
|
|
||||||
|
A constrained Delaunay triangulation is said to be a <I>conforming
|
||||||
|
Gabriel triangulation</I> if every constrained edge is a Gabriel edge. The
|
||||||
|
Gabriel property is stronger than the Delaunay property and each Gabriel
|
||||||
|
edge is a Delaunay edge. Conforming Gabriel triangulations are thus also
|
||||||
|
conforming Delaunay triangulations.
|
||||||
|
|
||||||
|
Any constrained Delaunay triangulation can be refined into a
|
||||||
|
conforming Delaunay triangulation or into a conforming Gabriel
|
||||||
|
triangulation by adding vertices, called <I>Steiner vertices</I>, on
|
||||||
|
constrained edges until they are decomposed into subconstraints small enough
|
||||||
|
to be Delaunay or Gabriel edges.
|
||||||
|
|
||||||
|
\subsection secMesh_2_building_conforming Building Conforming Triangulations
|
||||||
|
|
||||||
|
Constrained Delaunay triangulations can be refined into
|
||||||
|
conforming triangulations
|
||||||
|
by the two following global functions:
|
||||||
|
|
||||||
|
`template<class CDT> void make_conforming_Delaunay_2 (CDT& t)` and
|
||||||
|
|
||||||
|
`template<class CDT> void make_conforming_Gabriel_2 (CDT& t)`.
|
||||||
|
|
||||||
|
In both cases, the template parameter `CDT` must be instantiated
|
||||||
|
by a constrained Delaunay triangulation class. Such a class must be a
|
||||||
|
model of the concept `ConstrainedDelaunayTriangulation_2`.
|
||||||
|
|
||||||
|
The geometric traits of the constrained
|
||||||
|
Delaunay triangulation used to instantiate the parameter `CDT` has to
|
||||||
|
be a model of the concept `ConformingDelaunayTriangulationTraits_2`.
|
||||||
|
|
||||||
|
The constrained Delaunay triangulation `t` is passed by reference
|
||||||
|
and is refined into a conforming Delaunay triangulation or into a
|
||||||
|
conforming Gabriel triangulation by adding vertices. The user is advised to
|
||||||
|
make a copy of the input triangulation in the case where the original
|
||||||
|
triangulation has to be preserved for other computations
|
||||||
|
|
||||||
|
The algorithm used by `make_conforming_Delaunay_2` and
|
||||||
|
`make_conforming_Gabriel_2` builds internal data structures that would be
|
||||||
|
computed twice if the two functions are called consecutively on the same
|
||||||
|
triangulation. In order to avoid these data to be constructed twice, the
|
||||||
|
advanced user can use the class `Triangulation_conformer_2<CDT>` to
|
||||||
|
refine a constrained Delaunay triangulation into a conforming Delaunay
|
||||||
|
triangulation and then into a conforming Gabriel triangulation. For
|
||||||
|
additional control of the refinement algorithm, this class also provides
|
||||||
|
separate functions to insert one Steiner point at a time.
|
||||||
|
|
||||||
|
\subsection secMesh_2_example_making_conforming Example: Making a Triangulation Conforming Delaunay and Then Conforming Gabriel
|
||||||
|
|
||||||
|
This example inserts several segments into a constrained Delaunay
|
||||||
|
triangulation, makes it conforming Delaunay, and then conforming
|
||||||
|
Gabriel. At each step, the number of vertices of the triangulation is
|
||||||
|
printed.
|
||||||
|
|
||||||
|
\cgalexample{Mesh_2/conforming.cpp}
|
||||||
|
|
||||||
|
See figures \ref Conformexampleconform ,
|
||||||
|
\ref ConformexampleconformDelaunay
|
||||||
|
and \ref ConformexampleconformGabriel .
|
||||||
|
|
||||||
|
\anchor Conformexampleconform
|
||||||
|
\image latex example-conform "Initial triangulation." width=8cm
|
||||||
|
\image html example-conform.png "Initial triangulation."
|
||||||
|
|
||||||
|
\anchor ConformexampleconformDelaunay
|
||||||
|
\image latex example-conform-Delaunay "The corresponding conforming Delaunay triangulation." width=8cm
|
||||||
|
\image html example-conform-Delaunay.png "The corresponding conforming Delaunay triangulation."
|
||||||
|
|
||||||
|
\anchor ConformexampleconformGabriel
|
||||||
|
\image latex example-conform-Gabriel "The corresponding conforming Gabriel triangulation." width=8cm
|
||||||
|
\image html example-conform-Gabriel.png "The corresponding conforming Gabriel triangulation."
|
||||||
|
|
||||||
|
\section secMesh_2_meshes Meshes
|
||||||
|
|
||||||
|
\subsection secMesh_2_meshes_definition Definitions
|
||||||
|
|
||||||
|
A mesh is a partition of a given region into simplices whose shapes
|
||||||
|
and sizes satisfy several criteria.
|
||||||
|
|
||||||
|
The domain is the region that the user wants to mesh. It has to be
|
||||||
|
a bounded region of the plane. The domain is defined by a <I>planar
|
||||||
|
straight line graph</I>, <span class="textsc">Pslg</span> for short, which is a set of segments
|
||||||
|
such that two segments in the set are either disjoint or share an
|
||||||
|
endpoint. The segments of the <span class="textsc">Pslg</span> are constraints that will be
|
||||||
|
represented by a union of edges in the mesh. The <span class="textsc">Pslg</span> can also
|
||||||
|
contain isolated points that will appear as vertices of the mesh.
|
||||||
|
|
||||||
|
The segments of the <span class="textsc">Pslg</span> are either segments of the
|
||||||
|
boundary or internals constraints. The segments of the <span class="textsc">Pslg</span> have to
|
||||||
|
cover the boundary of the domain.
|
||||||
|
|
||||||
|
The <span class="textsc">Pslg</span> divides the plane into several connected components. By
|
||||||
|
default, the domain is the union of the bounded connected components. The
|
||||||
|
user can override this default by providing a set of seed points. Either
|
||||||
|
seed points mark components to be meshed or they mark components not to be
|
||||||
|
meshed (holes).
|
||||||
|
|
||||||
|
See figures \ref Domain and \ref Domainmesh for an example of a domain
|
||||||
|
defined without using seed points, and a possible mesh of it. See
|
||||||
|
figure \ref Domainseeds for another domain defined with the same <span class="textsc">Pslg</span> and two seed points used to define holes.
|
||||||
|
In the corresponding mesh (figure \ref Domainseedsmesh ), these
|
||||||
|
two holes are triangulated but not meshed.
|
||||||
|
|
||||||
|
\anchor Domain
|
||||||
|
\image latex domain "A domain defined without seed points." width=8cm
|
||||||
|
\image html domain.png "A domain defined without seed points."
|
||||||
|
|
||||||
|
\anchor Domainmesh
|
||||||
|
\image latex domain-mesh "A mesh of the domain defined without seed points." width=8cm
|
||||||
|
\image html domain-mesh.png "A mesh of the domain defined without seed points."
|
||||||
|
|
||||||
|
\anchor Domainseeds
|
||||||
|
\image latex domain-seeds "A domain with two seeds points defining holes." width=8cm
|
||||||
|
\image html domain-seeds.png "A domain with two seeds points defining holes."
|
||||||
|
|
||||||
|
\anchor Domainseedsmesh
|
||||||
|
\image latex domain-seeds-mesh "A mesh of the domain with two seeds defining holes." width=8cm
|
||||||
|
\image html domain-seeds-mesh.png "A mesh of the domain with two seeds defining holes."
|
||||||
|
|
||||||
|
\subsection secMesh_2_criteria Shape and Size Criteria
|
||||||
|
|
||||||
|
The shape criterion for triangles is a lower bound \f$ B\f$ on the ratio
|
||||||
|
between the circumradius and the shortest edge length. Such a bound
|
||||||
|
implies a lower bound of \f$ \arcsin{\frac{1}{2B}}\f$ on the minimum angle
|
||||||
|
of the triangle and an upper bound of \f$ \pi - 2* \arcsin{\frac{1}{2B}}\f$
|
||||||
|
on the maximum angle. Unfortunately, the termination of the algorithm
|
||||||
|
is guaranteed only if \f$ B \ge \sqrt{2}\f$, which corresponds to a lower
|
||||||
|
bound of \f$ 20.7\f$ degrees over the angles.
|
||||||
|
|
||||||
|
The size criterion can be any criterion that tends to prefer small
|
||||||
|
triangles. For example, the size criterion can be an upper bound on the
|
||||||
|
length of longest edge of triangles, or an upper bound on the radius of the
|
||||||
|
circumcircle. The size bound can vary over the domain. For example,
|
||||||
|
the size criterion could impose a small size for the triangles intersecting
|
||||||
|
a given line.
|
||||||
|
|
||||||
|
Both types of criteria are defined in an object `criteria` passed as
|
||||||
|
parameter of the meshing functions.
|
||||||
|
|
||||||
|
## The Meshing Algorithm ##
|
||||||
|
|
||||||
|
The input to a meshing problem is a <span class="textsc">Pslg</span> and a set of seeds
|
||||||
|
describing the domain to be meshed, and a set of size and shape
|
||||||
|
criteria. The algorithm implemented in this package starts with a
|
||||||
|
constrained Delaunay triangulation of the input <span class="textsc">Pslg</span> and produces a
|
||||||
|
mesh using the Delaunay refinement method. This method inserts new vertices to
|
||||||
|
the triangulation, as far as possible from other vertices, and stops when the
|
||||||
|
criteria are satisfied.
|
||||||
|
|
||||||
|
If all angles between incident segments of the input <span class="textsc">Pslg</span>
|
||||||
|
are greater than \f$ 60\f$ degrees and if the bound on the
|
||||||
|
circumradius/edge ratio is greater than \f$ \sqrt{2}\f$,
|
||||||
|
the algorithm is guaranteed to terminate with a mesh
|
||||||
|
satisfying the size and shape criteria.
|
||||||
|
|
||||||
|
If some input angles are smaller than \f$ 60\f$ degrees, the algorithm will
|
||||||
|
end up with a mesh in which some triangles violate the criteria near small
|
||||||
|
input angles. This is unavoidable since small angles formed
|
||||||
|
by input segments cannot be suppressed. Furthermore, it has been
|
||||||
|
shown (\cite s-mgdsa-00), that some domains with small input angles
|
||||||
|
cannot be meshed with angles even smaller than the small input angles.
|
||||||
|
Note that if the domain is a polygonal region, the resulting mesh will
|
||||||
|
satisfy size and shape criteria except for the small input angles.
|
||||||
|
In addition, the algorithm may succeed in producing meshes with a lower
|
||||||
|
angle bound greater than \f$ 20.7\f$ degrees, but there is no such guarantee.
|
||||||
|
|
||||||
|
\subsection secMesh_2_building_meshes Building Meshes
|
||||||
|
|
||||||
|
Meshes are obtained from
|
||||||
|
constrained Delaunay triangulations by calling the global function
|
||||||
|
|
||||||
|
`template<class CDT, class Criteria> void refine_Delaunay_mesh_2 (CDT
|
||||||
|
&t, const Criteria& criteria)`.
|
||||||
|
|
||||||
|
The template parameter `CDT` must be instantiated by a constrained
|
||||||
|
Delaunay triangulation class, which is a model of the concept
|
||||||
|
`ConstrainedDelaunayTriangulation_2`. In order to override the domain,
|
||||||
|
a version of this function has two more arguments that define a sequence of
|
||||||
|
seed points.
|
||||||
|
|
||||||
|
The geometric traits class of `CDT` has to be a
|
||||||
|
model of the concept `DelaunayMeshTraits_2`. This concept
|
||||||
|
refines the concept `ConformingDelaunayTriangulationTraits_2`
|
||||||
|
adding the geometric predicates and constructors. The template parameter
|
||||||
|
`Criteria` must be a model of `MeshingCriteria_2`. This concept
|
||||||
|
defines criteria that the triangles have to satisfy.
|
||||||
|
\cgal provides two models for this concept:
|
||||||
|
<UL>
|
||||||
|
<LI>`Delaunay_mesh_criteria_2<CDT>`, that defines a shape criterion
|
||||||
|
that bounds the minimum angle of triangles,
|
||||||
|
<LI>`Delaunay_mesh_size_criteria_2<CDT>`, that adds to the previous
|
||||||
|
criterion a bound on the maximum edge length.
|
||||||
|
</UL>
|
||||||
|
|
||||||
|
If the function `refine_Delaunay_mesh_2` is called several times on the
|
||||||
|
same triangulation with different criteria, the algorithm rebuilds the
|
||||||
|
internal data structure used for meshing at every call. In order to avoid
|
||||||
|
rebuild the data structure at every call, the advanced user can
|
||||||
|
use the class `Delaunay_mesher_2<CDT>`. This class provides also step
|
||||||
|
by step functions. Those functions insert one vertex at a time.
|
||||||
|
|
||||||
|
Any object of type `Delaunay_mesher_2<CDT>` is constructed from a
|
||||||
|
reference to a `CDT`, and has several member functions to define the
|
||||||
|
domain to be meshed and to mesh the `CDT`. See the example given below
|
||||||
|
and the reference manual for details. Note that the `CDT` should not be
|
||||||
|
externally modified during the life time of the `Delaunay_mesher_2<CDT>`
|
||||||
|
object.
|
||||||
|
|
||||||
|
Once the mesh is constructed, one can determine which faces of the
|
||||||
|
triangulation are in the mesh domain using the `is_in_domain()` member
|
||||||
|
function of the face type (see the concept `DelaunayMeshFaceBase_2`).
|
||||||
|
|
||||||
|
## Example Using the Global Function ##
|
||||||
|
|
||||||
|
The following example inserts several segments into a constrained
|
||||||
|
triangulation and then meshes it using the global function
|
||||||
|
`refine_Delaunay_mesh_2`. The size and shape criteria are the default ones
|
||||||
|
provided by the criteria class `Delaunay_mesh_criteria_2<K>`. No seeds are
|
||||||
|
given, meaning that the mesh domain covers the whole plane except the
|
||||||
|
unbounded component.
|
||||||
|
|
||||||
|
\cgalexample{Mesh_2/mesh_global.cpp}
|
||||||
|
|
||||||
|
## Example Using the Class <TT>Delaunay_mesher_2<CDT></TT> ##
|
||||||
|
|
||||||
|
This example uses the class `Delaunay_mesher_2<CDT>` and calls
|
||||||
|
the `refine_mesh()` member function twice, changing the size and
|
||||||
|
shape criteria in between. In such a case, using twice the global
|
||||||
|
function `refine_Delaunay_mesh_2` would be less efficient,
|
||||||
|
because some internal structures needed by the algorithm would be
|
||||||
|
built twice.
|
||||||
|
|
||||||
|
\cgalexample{Mesh_2/mesh_class.cpp}
|
||||||
|
|
||||||
|
## Example Using Seeds ##
|
||||||
|
|
||||||
|
This example uses the global function `refine_Delaunay_mesh_2` but
|
||||||
|
defines a domain by using one seed. The size and shape criteria are the
|
||||||
|
default ones provided by the criteria class
|
||||||
|
`Delaunay_mesh_criteria_2<K>`.
|
||||||
|
|
||||||
|
Once the mesh is constructed, the `is_in_domain()` member function of
|
||||||
|
faces is used to count them.
|
||||||
|
|
||||||
|
\cgalexample{Mesh_2/mesh_with_seeds.cpp}
|
||||||
|
|
||||||
|
*/
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
/// \defgroup PkgMesh2 2D Conforming Triangulations and Meshes
|
||||||
|
|
||||||
|
/// \defgroup PkgMesh2Concepts Concepts
|
||||||
|
/// \ingroup PkgMesh2
|
||||||
|
/*!
|
||||||
|
\addtogroup PkgMesh2
|
||||||
|
\todo check generated documentation
|
||||||
|
\PkgDescriptionBegin{2D Conforming Triangulations and Meshes}
|
||||||
|
\PkgPicture{delaunaymesh-small.png}
|
||||||
|
\PkgAuthor{Laurent Rineau}
|
||||||
|
\PkgDesc{This package implements a Delaunay refinement algorithm to construct conforming triangulations and 2D meshes. Conforming Delaunay triangulations are obtained from constrained Delaunay triangulations by refining constrained edges until they are Delaunay edges. Conforming Gabriel triangulations are obtained by further refining constrained edges until they become Gabriel edges. The package provides also a 2D mesh generator that refines triangles and constrained edges until user defined size and shape criteria on triangles are satisfied. The package can handle intersecting input constraints and set no restriction on the angle formed by two constraints sharing an endpoint.}
|
||||||
|
\PkgSince{3.1}
|
||||||
|
\cgalbib{ cgal:r-ctm2-12 }
|
||||||
|
\license{ \ref licensesGPL GPL }
|
||||||
|
\PkgUserManual{user_chapter_2D_Meshes}
|
||||||
|
\PkgDescriptionEnd
|
||||||
|
</td>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 360 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
|
@ -0,0 +1,795 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/// \defgroup CompactContainer Compact Container
|
||||||
|
/// \ingroup PkgStlExtension
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup CompactContainer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Compact_container_base` can be used as a base class for
|
||||||
|
your own type `T`, so that `T` can be used directly within
|
||||||
|
`Compact_container<T, Allocator>`. This class stores a `void *`
|
||||||
|
pointer only for this purpose, so it may not be the most memory efficient
|
||||||
|
way to achieve this goal. The other ways are to provide in `T` the
|
||||||
|
necessary member functions so that the template
|
||||||
|
`Compact_container_traits<T>` works, or to specialize it for the
|
||||||
|
particular type `T` that you want to use.
|
||||||
|
|
||||||
|
*/
|
||||||
|
class Compact_container_base {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Returns the pointer necessary for `Compact_container_traits<T>`.
|
||||||
|
*/
|
||||||
|
void * for_compact_container() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns a reference to the pointer necessary for
|
||||||
|
`Compact_container_traits<T>`.
|
||||||
|
*/
|
||||||
|
void * & for_compact_container();
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Compact_container_base */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup CompactContainer
|
||||||
|
|
||||||
|
An object of the class `Compact_container`
|
||||||
|
is a container of objects of type `T`. It matches all the
|
||||||
|
standard requirements for reversible containers, except that
|
||||||
|
the complexity of its iterator increment and decrement operations
|
||||||
|
is not always guaranteed to be amortized constant time.
|
||||||
|
|
||||||
|
This container is not a standard <I>sequence</I> nor <I>associative</I> container,
|
||||||
|
which means the elements are stored in no particular order, and it is not
|
||||||
|
possible to specify a particular place in the iterator sequence where to
|
||||||
|
insert new objects. However, all dereferenceable iterators are
|
||||||
|
still valid after calls to `insert()` and `erase()`, except those
|
||||||
|
that have been erased (it behaves similarly to `std::list`).
|
||||||
|
|
||||||
|
The main feature of this container is that it is very memory efficient :
|
||||||
|
its memory size is `N*sizeof(T)+o(N)`, where `N` is the maximum size
|
||||||
|
that the container has had in its past history, its `capacity()`
|
||||||
|
(the memory of erased elements is not deallocated until destruction of the
|
||||||
|
container or a call to `clear()`). This container has been developed in
|
||||||
|
order to store large graph-like data structures like the triangulation and
|
||||||
|
the halfedge data structures.
|
||||||
|
|
||||||
|
It supports bidirectional iterators and allows a constant time amortized
|
||||||
|
`insert()` operation. You cannot specify where to insert new objects
|
||||||
|
(i.e. you don't know where they will end up in the iterator sequence,
|
||||||
|
although `insert()` returns an iterator pointing to the newly inserted
|
||||||
|
object). You can erase any element with a constant time complexity.
|
||||||
|
|
||||||
|
Summary of the differences with `std::list` : it is more compact in
|
||||||
|
memory since it doesn't store two additional pointers for the iterator needs.
|
||||||
|
It doesn't deallocate elements until the destruction or `clear()` of the
|
||||||
|
container. The iterator does not have constant amortized time complexity for
|
||||||
|
the increment and decrement operations in all cases, only when not too many
|
||||||
|
elements have not been freed (i.e. when the `size()` is close to the
|
||||||
|
`capacity()`). Iterating from `begin()` to `end()` takes
|
||||||
|
`O(capacity())` time, not `size()`. In the case where the container
|
||||||
|
has a small `size()` compared to its `capacity()`, we advise to
|
||||||
|
"defragment the memory" by copying the container if the iterator performance
|
||||||
|
is needed.
|
||||||
|
|
||||||
|
The iterators themselves can be used as `T`, they provide the necessary
|
||||||
|
functions to be used by `Compact_container_traits<T>`. Moreover, they
|
||||||
|
also provide a default constructor value which is not singular : it is
|
||||||
|
copyable, comparable, and guaranteed to be unique under comparison
|
||||||
|
(like `NULL` for pointers). This makes them suitable for use in
|
||||||
|
geometric graphs like handles to vertices in triangulations.
|
||||||
|
|
||||||
|
In addition, in a way inspired from the Boost.Intrusive containers, it is
|
||||||
|
possible to construct iterators from references to values in containers
|
||||||
|
using the `iterator_to` and `s_iterator_to` functions.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The parameter `T` is required to have a copy constructor and an
|
||||||
|
assignment operator. It also needs to provide access to an internal
|
||||||
|
pointer via `Compact_container_traits<T>`.
|
||||||
|
|
||||||
|
The equality test and the relational order require the operators
|
||||||
|
`==` and `<` for `T` respectively.
|
||||||
|
|
||||||
|
The parameter `Allocator` has to match the standard allocator
|
||||||
|
requirements, with value type `T`. This parameter has the default
|
||||||
|
value `CGAL_ALLOCATOR(T)`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T, typename Allocator >
|
||||||
|
class Compact_container {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type value_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type reference;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_reference;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type pointer;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_pointer;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type size_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type difference_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type reverse_iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_reverse_iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type allocator_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces an empty container, eventually specifying a particular
|
||||||
|
allocator `a` as well.
|
||||||
|
*/
|
||||||
|
explicit Compact_container(const Allocator &a = Allocator());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
a container with copies from the range [`first,last`), eventually
|
||||||
|
specifying a particular allocator.
|
||||||
|
*/
|
||||||
|
template <class InputIterator> Compact_container(
|
||||||
|
InputIterator first, InputIterator last,
|
||||||
|
const Allocator &a = Allocator());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
copy constructor. Each item in `cc` is copied. The allocator
|
||||||
|
is copied. The iterator order is preserved.
|
||||||
|
*/
|
||||||
|
Compact_container(const Compact_container<T, Allocator> &cc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
assignment. Each item in `cc` is copied. The allocator is copied.
|
||||||
|
Each item in `c` is deleted. The iterator order is preserved.
|
||||||
|
*/
|
||||||
|
Compact_container<T, Allocator> & operator=(const
|
||||||
|
Compact_container<T, Allocator> &cc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
swaps the contents of `c` and `cc` in constant time
|
||||||
|
complexity. No exception is thrown.
|
||||||
|
*/
|
||||||
|
void swap(Compact_container<T, Allocator> &cc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
if `value` is less than or equal to `capacity()`, this call
|
||||||
|
has no effect. Otherwise, it is a request for allocation of
|
||||||
|
additional memory so that then `capacity()` is greater than or
|
||||||
|
equal to value. `size()` is unchanged.
|
||||||
|
*/
|
||||||
|
void reserve(size_type value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a mutable iterator referring to the first element in `c`.
|
||||||
|
*/
|
||||||
|
iterator begin();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a constant iterator referring to the first element in `c`.
|
||||||
|
*/
|
||||||
|
const_iterator begin() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a mutable iterator which is the past-end-value of `c`.
|
||||||
|
*/
|
||||||
|
iterator end();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a constant iterator which is the past-end-value of `c`.
|
||||||
|
*/
|
||||||
|
const_iterator end() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
reverse_iterator rbegin();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
const_reverse_iterator rbegin() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
reverse_iterator rend();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
const_reverse_iterator rend() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns an iterator which points to `value`;
|
||||||
|
*/
|
||||||
|
iterator iterator_to(reference value) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns an iterator which points to `value`;
|
||||||
|
*/
|
||||||
|
const_iterator iterator_to(const_reference value) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns an iterator which points to `value`;
|
||||||
|
*/
|
||||||
|
static iterator s_iterator_to(reference value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns an iterator which points to `value`;
|
||||||
|
*/
|
||||||
|
static const_iterator s_iterator_to(const_reference value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns `true` iff `c` is empty.
|
||||||
|
*/
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the number of items in `c`.
|
||||||
|
*/
|
||||||
|
size_type size() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the maximum possible size of the container `c`.
|
||||||
|
*/
|
||||||
|
size_type max_size() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the total number of elements that `c` can hold without requiring
|
||||||
|
reallocation.
|
||||||
|
*/
|
||||||
|
size_type capacity() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the allocator.
|
||||||
|
*/
|
||||||
|
Allocator get_allocator() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts a copy of `t` in `c` and returns the iterator pointing
|
||||||
|
to it.
|
||||||
|
*/
|
||||||
|
iterator insert(const T& t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts the range [`first, last`) in `c`.
|
||||||
|
*/
|
||||||
|
template <class InputIterator>
|
||||||
|
void insert(InputIterator first, InputIterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
erases all the elements of `c`, then inserts the range
|
||||||
|
[`first, last`) in `c`.
|
||||||
|
*/
|
||||||
|
template <class InputIterator>
|
||||||
|
void assign(InputIterator first, InputIterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs an object of type `T` with the constructor that takes
|
||||||
|
`t1` as argument, inserts it in `c`, and returns the iterator pointing
|
||||||
|
to it. Overloads of this member function are defined that take additional
|
||||||
|
arguments, up to 9.
|
||||||
|
*/
|
||||||
|
template < class T1 >
|
||||||
|
iterator emplace(const T1& t1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
removes the item pointed by `pos` from `c`.
|
||||||
|
*/
|
||||||
|
void erase(iterator pos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
removes the items from the range [`first, last`) from `c`.
|
||||||
|
*/
|
||||||
|
void erase(iterator first, iterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
all items in `c` are deleted, and the memory is deallocated.
|
||||||
|
After this call, `c` is in the same state as if just default
|
||||||
|
constructed.
|
||||||
|
*/
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Ownership testing
|
||||||
|
/// The following functions are mostly helpful for efficient debugging, since
|
||||||
|
/// their complexity is \f$ O(\sqrt{c.capacity()})\f$.
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns whether `pos` is in the range [`c`.`begin()`, `c`.`end()`]
|
||||||
|
(`c`.`end()` included).
|
||||||
|
*/
|
||||||
|
bool owns(const_iterator pos);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns whether `pos` is in the range [`c`.`begin()`, `c`.`end()`)
|
||||||
|
(`c`.`end()` excluded).
|
||||||
|
*/
|
||||||
|
bool owns_dereferencable(const_iterator pos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Merging
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
adds the items of `cc` to the end of `c` and `cc` becomes empty.
|
||||||
|
The time complexity is O(`c`.`capacity()`-`c`.`size()`).
|
||||||
|
\pre `cc` must not be the same as `c`, and the allocators of `c` and `cc` need to be compatible : `c`.`get_allocator() == cc.get_allocator()`.
|
||||||
|
*/
|
||||||
|
void merge(Compact_container<T, Allocator> &cc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
test for equality: Two containers are equal, iff they have the
|
||||||
|
same size and if their corresponding elements are equal.
|
||||||
|
*/
|
||||||
|
bool operator==(const Compact_container<T, Allocator> &cc) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
test for inequality: returns !(`c` `== cc`).
|
||||||
|
*/
|
||||||
|
bool operator!=(const Compact_container<T, Allocator> &cc) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
compares in lexicographical order.
|
||||||
|
*/
|
||||||
|
bool operator<(const Compact_container<T, Allocator> &cc) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns `cc <` `c`.
|
||||||
|
*/
|
||||||
|
bool operator>(const Compact_container<T, Allocator> &cc) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns !(`c` `> cc`).
|
||||||
|
*/
|
||||||
|
bool operator<=(const Compact_container<T, Allocator> &cc) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns !(`c` `< cc`).
|
||||||
|
*/
|
||||||
|
bool operator>=(const Compact_container<T, Allocator> &cc) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Compact_container */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup CompactContainer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The traits class `Compact_container_traits` provides
|
||||||
|
the way to access the internal pointer required for `T` to be
|
||||||
|
used in a `Compact_container<T, Allocator>`. Note that this
|
||||||
|
pointer needs to be accessible even when the object is not constructed,
|
||||||
|
which means it has to reside in the same memory place as `T`.
|
||||||
|
|
||||||
|
You can specialize this class for your own type `T`
|
||||||
|
if the default template is not suitable.
|
||||||
|
|
||||||
|
You can also use `Compact_container_base` as base class for your own
|
||||||
|
types `T` to make them usable with the default `Compact_container_traits`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`T` is any type providing the following member functions:
|
||||||
|
|
||||||
|
`void * t.for_compact_container() const;`
|
||||||
|
|
||||||
|
`void *& t.for_compact_container();`.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Compact_container_traits {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Returns the pointer held by `t`.
|
||||||
|
The template version defines this function as:
|
||||||
|
|
||||||
|
return t.for_compact_container();
|
||||||
|
|
||||||
|
*/
|
||||||
|
static void * pointer(const T &t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Returns a reference to the pointer held by `t`.
|
||||||
|
The template version defines this function as:
|
||||||
|
|
||||||
|
`
|
||||||
|
return t.for_compact_container();
|
||||||
|
`
|
||||||
|
|
||||||
|
*/
|
||||||
|
static void * & pointer(T &t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Compact_container_traits */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`Compact` is a tag class. It can be used to parameterize a complexity policy
|
||||||
|
in order to specify a particularly memory compact variant of an algorithm.
|
||||||
|
For example, passing `Location_policy<Compact>` as parameter to
|
||||||
|
`Delaunay_triangulation_3` selects a slower point location which saves memory.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::DefaultConstructible, CopyConstructible
|
||||||
|
|
||||||
|
\sa `Location_policy`
|
||||||
|
\sa `Fast`
|
||||||
|
\sa `Fast_location`
|
||||||
|
\sa `Compact_location`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Compact {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Compact */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`Fast` is a tag class. It can be used to parameterize a complexity policy
|
||||||
|
in order to specify a particularly fast variant of an algorithm.
|
||||||
|
For example, passing `Location_policy<Fast>` as parameter to
|
||||||
|
`Delaunay_triangulation_3` selects a fast point location at the expense of
|
||||||
|
more memory usage.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::DefaultConstructible, CopyConstructible
|
||||||
|
|
||||||
|
\sa `Location_policy`
|
||||||
|
\sa `Compact`
|
||||||
|
\sa `Compact_location`
|
||||||
|
\sa `Fast_location`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Fast {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Fast */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`Default` is a tag class. It can be used to state that one wants
|
||||||
|
to use the default argument of a template parameter of a class template.
|
||||||
|
|
||||||
|
This can be useful in several cases: (a) when one needs a non-default value for
|
||||||
|
another template parameter coming next (since \cpp only supports defaults at
|
||||||
|
the end of lists), (b) when the default is actually a complex expression, e.g.
|
||||||
|
refering to previous template parameters (in this case, it shortens compiler
|
||||||
|
error messages and mangled symbol names), (c) when defining the default
|
||||||
|
involves circular dependencies of type instantiations (there, it breaks the
|
||||||
|
cycle in a nice way).
|
||||||
|
|
||||||
|
Using the mechanism is easy : just plug `Default` as template argument
|
||||||
|
in the place where you would like to use the default. You should refer
|
||||||
|
to the documentation of the template class you are using in order to know
|
||||||
|
whether this functionality is offered.
|
||||||
|
|
||||||
|
Also beware that the type of the instantiated template class will not be the
|
||||||
|
same when instantiating it using `Default` instead of the type of the default
|
||||||
|
argument, even though their interfaces will otherwise be the same. This may
|
||||||
|
have consequences in some cases.
|
||||||
|
|
||||||
|
\models ::DefaultConstructible
|
||||||
|
\models ::CopyConstructible
|
||||||
|
|
||||||
|
In order to help the template class writer, `Default` provides a convenient
|
||||||
|
way to extract the desired type for a template parameter which may be defaulted
|
||||||
|
using `Default`. It is enough to fetch the type as
|
||||||
|
`Default::Get<Parameter, Type>::type`, as in the example program below.
|
||||||
|
|
||||||
|
Example
|
||||||
|
--------------
|
||||||
|
|
||||||
|
\cgalexample{STL_Extension/Default.cpp}
|
||||||
|
|
||||||
|
*/
|
||||||
|
class Default {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
A nested template providing a typedef `type` which equals `Type` if
|
||||||
|
`Parameter` is `Default`, and `Parameter` otherwise.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type template <typename Parameter, typename Type> struct Get;;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Default */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
The `Fourtuple` class stores a homogeneous (same type)
|
||||||
|
fourtuple of objects of type `T`. A `Fourtuple` is much like a
|
||||||
|
container, in that it "owns" its elements. It is not actually a model of
|
||||||
|
container, though, because it does not support the standard methods (such as
|
||||||
|
iterators) for accessing the elements of a container.
|
||||||
|
|
||||||
|
\deprecated This class is deprecated, and will be removed in some future \cgal release.
|
||||||
|
Please use CGAL::cpp11::array instead.
|
||||||
|
|
||||||
|
\tparam `T` must be `Assignable`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Fourtuple {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T value_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
first element
|
||||||
|
*/
|
||||||
|
T e0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
second element
|
||||||
|
*/
|
||||||
|
T e1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
third element
|
||||||
|
*/
|
||||||
|
T e2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
fourth element
|
||||||
|
*/
|
||||||
|
T e3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a `Fourtuple` using the default
|
||||||
|
constructor of the elements.
|
||||||
|
*/
|
||||||
|
Fourtuple();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a `Fourtuple` such
|
||||||
|
that `e0` is constructed from `x`, `e1` from `y`,
|
||||||
|
`e2` from `z` and `e3` from `t`.
|
||||||
|
*/
|
||||||
|
Fourtuple(T x, T y, T z, T t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Fourtuple */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,799 @@
|
||||||
|
/// \defgroup inplacelist Doubly-Connected List Managing Items in Place
|
||||||
|
/// \ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup inplacelist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The node base classes provides pointers to build
|
||||||
|
linked lists. The class `In_place_sl_list_base<T>` provides
|
||||||
|
a pointer `next_link` for a single linked list. The class
|
||||||
|
`In_place_list_base<T>` provides an additional pointer
|
||||||
|
`prev_link` for doubly linked lists. These names conform to
|
||||||
|
the default parameters used in the template argument lists of the
|
||||||
|
container classes. The pointers are public members.
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class In_place_list_base {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
forward pointer
|
||||||
|
*/
|
||||||
|
T* next_link;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
backward pointer
|
||||||
|
*/
|
||||||
|
T* prev_link;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end In_place_list_base */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup inplacelist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
An object of the class `In_place_list`
|
||||||
|
represents a sequence of items of type `T` that supports
|
||||||
|
bidirectional iterators and allows constant time insert and erase
|
||||||
|
operations anywhere within the sequence. The functionality is
|
||||||
|
similar to the `list<T>` in the \stl.
|
||||||
|
|
||||||
|
The `In_place_list` manages the items in place, i.e., inserted
|
||||||
|
items are not copied. Two pointers of type `T*` are expected
|
||||||
|
to be reserved in `T` for the list management. The base class
|
||||||
|
`In_place_list_base<T>` can be used to obtain such pointers.
|
||||||
|
|
||||||
|
The `In_place_list` does not copy element items during
|
||||||
|
insertion (unless otherwise stated for a function). On removal of an
|
||||||
|
item or destruction of the list the items are not deleted by
|
||||||
|
default. The second template parameter `bool` is set to
|
||||||
|
`false` in this case. If the `In_place_list` should
|
||||||
|
take the responsibility for the stored objects the `bool`
|
||||||
|
parameter could be set to `true`, in which case the list
|
||||||
|
will delete removed items and will delete all remaining items on
|
||||||
|
destruction. In any case, the `destroy()` member function
|
||||||
|
deletes all items. Note that these two possible versions of
|
||||||
|
`In_place_list` are not assignable to each other to avoid
|
||||||
|
confusions between the different storage responsibilities.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The full class name is `In_place_list<T, bool managed =
|
||||||
|
false, class Alloc = CGAL_ALLOCATOR(T)>`.
|
||||||
|
|
||||||
|
The parameter `T` is supposed to have a default constructor,
|
||||||
|
a copy constructor and an assignment operator. The copy constructor
|
||||||
|
and the assignment may copy the pointers in `T` for the list
|
||||||
|
management, but they do not have to. The equality test and the
|
||||||
|
relational order require the operators `==` and `<`
|
||||||
|
for \f$ T\f$ respectively. These operators must not compare the pointers
|
||||||
|
in `T`.
|
||||||
|
|
||||||
|
Example
|
||||||
|
--------------
|
||||||
|
|
||||||
|
\cgalexample{STL_Extension/in_place_list_prog.cpp}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T, bool >
|
||||||
|
class In_place_list {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type value_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type reference;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_reference;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type size_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type difference_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type reverse_iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_reverse_iterator;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type allocator_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces an empty list.
|
||||||
|
*/
|
||||||
|
In_place_list();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
copy constructor.
|
||||||
|
Each item in `l1` is copied.
|
||||||
|
*/
|
||||||
|
In_place_list(const list<T> &l1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a list with \f$ n\f$ items, all initialized with copies
|
||||||
|
of \f$ t\f$.
|
||||||
|
*/
|
||||||
|
In_place_list(size_type n, const T& t = T()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
a list with copies from
|
||||||
|
the range [`first,last`).
|
||||||
|
*/
|
||||||
|
template <class InputIterator> In_place_list(
|
||||||
|
InputIterator first, InputIterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
non-member-template version.
|
||||||
|
*/
|
||||||
|
In_place_list( const T* first, const T*
|
||||||
|
last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
assignment. Each item in `l1`
|
||||||
|
is copied. Each item in `l` is deleted if the `bool`
|
||||||
|
parameter is `true`.
|
||||||
|
*/
|
||||||
|
In_place_list<T,bool> & operator=(const
|
||||||
|
In_place_list<T,bool> &l1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
swaps the
|
||||||
|
contents of `l` with `l1`.
|
||||||
|
*/
|
||||||
|
void swap( const In_place_list<T,bool> &l1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
all items in `l` are deleted
|
||||||
|
regardless of the `bool` parameter.
|
||||||
|
*/
|
||||||
|
void destroy();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
test for equality: Two lists are equal, iff they have the
|
||||||
|
same size and if their corresponding elements are equal.
|
||||||
|
*/
|
||||||
|
bool operator==(const In_place_list<T,bool> &l1)
|
||||||
|
const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
compares in lexicographical order.
|
||||||
|
*/
|
||||||
|
bool operator<(const In_place_list<T,bool> &l1)
|
||||||
|
const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a mutable iterator referring to the first
|
||||||
|
element in `l`.
|
||||||
|
*/
|
||||||
|
iterator
|
||||||
|
begin();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a constant
|
||||||
|
iterator referring to the first element in `l`.
|
||||||
|
*/
|
||||||
|
const_iterator begin() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a mutable iterator which
|
||||||
|
is the past-end-value of `l`.
|
||||||
|
*/
|
||||||
|
iterator end();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a constant
|
||||||
|
iterator which is the past-end-value of `l`.
|
||||||
|
*/
|
||||||
|
const_iterator end() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns `true` if `l` is
|
||||||
|
empty.
|
||||||
|
*/
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the number of
|
||||||
|
items in list `l`.
|
||||||
|
*/
|
||||||
|
size_type size() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the maximum
|
||||||
|
possible size of the list `l`.
|
||||||
|
*/
|
||||||
|
size_type max_size() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the first item in list `l`.
|
||||||
|
*/
|
||||||
|
T& front();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the last item in list `l`.
|
||||||
|
*/
|
||||||
|
T& back();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the allocator.
|
||||||
|
*/
|
||||||
|
allocator_type get_allocator() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts an item in front of
|
||||||
|
list `l`.
|
||||||
|
*/
|
||||||
|
void push_front( T&);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts an item at the back
|
||||||
|
of list `l`.
|
||||||
|
*/
|
||||||
|
void push_back( T&);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
iterator insert(iterator pos, T& t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts `t`
|
||||||
|
in front of `pos`. The return value points to the
|
||||||
|
inserted item.
|
||||||
|
*/
|
||||||
|
iterator insert(T* pos, T& t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
void insert(iterator pos, size_type n, const T& t = T());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts \f$ n\f$ copies of `t` in front of
|
||||||
|
`pos`.
|
||||||
|
*/
|
||||||
|
void insert(T* pos, size_type n, const T& t =
|
||||||
|
T());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
template <class InputIterator> void insert(iterator pos,
|
||||||
|
InputIterator first, InputIterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts the range
|
||||||
|
[`first, last`) in front of iterator `pos`.
|
||||||
|
*/
|
||||||
|
template <class InputIterator> void insert(T* pos,
|
||||||
|
InputIterator first, InputIterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
removes the first item from
|
||||||
|
list `l`.
|
||||||
|
*/
|
||||||
|
void pop_front();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
removes the last item from
|
||||||
|
list `l`.
|
||||||
|
*/
|
||||||
|
void pop_back();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
removes the item from
|
||||||
|
list `l`, where `pos` refers to.
|
||||||
|
*/
|
||||||
|
void erase(iterator pos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
removes the item from
|
||||||
|
list `l`, where `pos` refers to.
|
||||||
|
*/
|
||||||
|
void erase(T* pos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
void erase(iterator first, iterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
removes the items
|
||||||
|
in the range [`first, last`) from `l`.
|
||||||
|
*/
|
||||||
|
void erase(T* first, T* last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
void splice(iterator pos, In_place_list<T,bool>& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts the list \f$ x\f$ before position `pos` and \f$ x\f$
|
||||||
|
becomes empty. It takes constant time. \pre `&` `l``!= &x`.
|
||||||
|
*/
|
||||||
|
void splice(T* pos, In_place_list<T,bool>&
|
||||||
|
x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
void splice(iterator pos, In_place_list<T,bool>& x,
|
||||||
|
iterator i);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts an element pointed to by \f$ i\f$ from list \f$ x\f$ before
|
||||||
|
position `pos` and removes the element from \f$ x\f$. It takes
|
||||||
|
constant time. \f$ i\f$ is a valid dereferenceable iterator of \f$ x\f$.
|
||||||
|
The result is unchanged if `pos == i` or `pos ==
|
||||||
|
++i`.
|
||||||
|
*/
|
||||||
|
void splice(T* pos, In_place_list<T,bool>& x, T*
|
||||||
|
i);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
void splice(iterator pos, In_place_list<T,bool>& x,
|
||||||
|
iterator first, iterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inserts elements in the range [`first,
|
||||||
|
last`) before position `pos` and removes the elements
|
||||||
|
from \f$ x\f$. It takes constant time if `&x == &``l`;
|
||||||
|
otherwise, it takes linear time. [`first, last`) is a
|
||||||
|
valid range in \f$ x\f$. \pre `pos` is not in the range [`first, last`).
|
||||||
|
*/
|
||||||
|
void splice(T* pos, In_place_list<T,bool>& x, T*
|
||||||
|
first, T* last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
erases all elements \f$ e\f$ in
|
||||||
|
the list `l` for which `e == value`. It is stable.
|
||||||
|
\pre a suitable `operator==` for the type \f$ T\f$.
|
||||||
|
*/
|
||||||
|
void remove(const T& value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
erases all but the first element from
|
||||||
|
every consecutive group of equal elements in the list `l`.
|
||||||
|
\pre a suitable `operator==` for the type \f$ T\f$.
|
||||||
|
*/
|
||||||
|
void unique();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
merges the list \f$ x\f$
|
||||||
|
into the list `l` and \f$ x\f$ becomes empty. It is stable.
|
||||||
|
\pre Both lists are increasingly sorted. A suitable `operator<` for the type \f$ T\f$.
|
||||||
|
*/
|
||||||
|
void merge(In_place_list<T,bool>& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
reverses the order of the elements in
|
||||||
|
`l` in linear time.
|
||||||
|
*/
|
||||||
|
void reverse();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special List Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
sorts the list `l` according to the
|
||||||
|
`operator<` in time \f$ O(n \logn)\f$ where `n =
|
||||||
|
size()`. It is stable. \pre a suitable `operator<` for the type \f$ T\f$.
|
||||||
|
*/
|
||||||
|
void sort();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end In_place_list */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
A typedef to `Location_policy<Compact>`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\sa `Compact`
|
||||||
|
\sa `Fast`
|
||||||
|
\sa `Location_policy`
|
||||||
|
\sa `Fast_location`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Compact_location {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Compact_location */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
A typedef to `Location_policy<Fast>`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\sa `Compact`
|
||||||
|
\sa `Fast`
|
||||||
|
\sa `Location_policy`
|
||||||
|
\sa `Compact_location`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Fast_location {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Fast_location */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`Location_policy` is a policy class which can be used to specify a trade-off
|
||||||
|
between memory usage and time complexity for the point location strategy
|
||||||
|
used in a data-structure.
|
||||||
|
For example, passing `Location_policy<Compact>` as parameter to
|
||||||
|
`Delaunay_triangulation_3` selects a slower point location which saves memory.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`Tag` can only be either `Fast` or `Compact` currently.
|
||||||
|
|
||||||
|
\models ::DefaultConstructible, CopyConstructible
|
||||||
|
|
||||||
|
\sa `Compact`
|
||||||
|
\sa `Fast`
|
||||||
|
\sa `Fast_location`
|
||||||
|
\sa `Compact_location`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Tag >
|
||||||
|
class Location_policy {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Location_policy */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,669 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
\anchor classcgal_multimap
|
||||||
|
|
||||||
|
|
||||||
|
An instance `s` of the parametrized data type `Multiset` is a
|
||||||
|
multi-set of elements of type `Type`, represented as a red-black tree
|
||||||
|
(see [\cite Chapter 13 for an excellent introduction to red-black
|
||||||
|
trees).
|
||||||
|
The main difference between `Multiset` and \stl's `multiset` is that
|
||||||
|
the latter uses a less-than functor with a Boolean return type, while our
|
||||||
|
`Multiset` class is parameterized by a comparison functor `Compare` that
|
||||||
|
returns the three-valued `Comparison_result` (namely it returns either
|
||||||
|
`SMALLER`, `EQUAL`, or `LARGER`). It is thus possible to maintain
|
||||||
|
the underlying red-black tree with less invocations of the comparison functor.
|
||||||
|
This leads to a speedup of about 5% even if we maintain a set of integers.
|
||||||
|
When each comparison of two elements of type `Type` is an expensive
|
||||||
|
operation (for example, when they are geometric entities represented using
|
||||||
|
exact arithmetic), the usage of a three-valued comparison functor can lead to
|
||||||
|
considerable decrease in the running times.
|
||||||
|
|
||||||
|
Moreover, `Multiset` allows the insertion of an element into the set given
|
||||||
|
its <I>exact</I> position, and not just using an insertion hint, as done by
|
||||||
|
`std::multiset`. This can further reduce the running times, as additional
|
||||||
|
comparison operations can be avoided.
|
||||||
|
|
||||||
|
In addition, the `Multiset` guarantees that the order of elements sent to the
|
||||||
|
comparison functor is fixed. For example, if we insert a new element `x`
|
||||||
|
into the set (or erase an element from the set), then we always invoke
|
||||||
|
`Compare() (x, y)` (and never `Compare() (y, x)`), where `y` is an
|
||||||
|
element already stored in the set. This behavior, not supported by
|
||||||
|
`std::multiset`, is sometimes crucial for designing more efficient
|
||||||
|
comparison predicates.
|
||||||
|
|
||||||
|
`Multiset` also allows for look-up of keys whose type may differ from
|
||||||
|
`Type`, as long as users supply a comparison functor `CompareKey`,
|
||||||
|
where `CompareKey() (key, y)` returns the three-valued
|
||||||
|
`Comparison_result` (`key` is the look-up key and `y` is an
|
||||||
|
element of type `Type`). Indeed, it is very convenient to look-up
|
||||||
|
equivalent objects in the set given just by their key. We note however that
|
||||||
|
it is also possible to use a key of type `Type` and to employ the default
|
||||||
|
`Compare` functor for the look-up, as done when using the
|
||||||
|
`std::multiset` class.
|
||||||
|
|
||||||
|
\warning Finally, `Multiset` introduces the `catenate()` and `split()`
|
||||||
|
functions. The first function operates on `s` and accepts a second
|
||||||
|
set `s`', such that the maximum element in `s` is not greater than
|
||||||
|
the minimal element in `s`', and concatenates `s`' to `s`. The
|
||||||
|
second function splits `s` into two sets,one containing all the
|
||||||
|
elements that are less than a given key, and the other contains all
|
||||||
|
elements greater than (or equal to) this key.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The `Multiset` class-template has three parameters:
|
||||||
|
<UL>
|
||||||
|
<LI>`Type` - the type of the stored elements.
|
||||||
|
<LI>`Compare` - the comparison-functor type. This type should provide
|
||||||
|
the following operator for comparing two `Type` elements, namely:
|
||||||
|
|
||||||
|
`Comparison_result operator() (const Type& t1, const Type& t2) const;`
|
||||||
|
|
||||||
|
The `CGAL::Compare<Type>` functor is used by default. In this case,
|
||||||
|
`Type` must support an equality operator (`operator==`) and a
|
||||||
|
less-than operator (`operator<`).
|
||||||
|
<LI>`Allocator` - the allocator type.
|
||||||
|
|
||||||
|
`CGAL_ALLOCATOR` is used by default.
|
||||||
|
</UL>
|
||||||
|
|
||||||
|
Assertions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The assertion and precondition flags for the `Multiset` class
|
||||||
|
use `MULTISET` in their names (i.e., `CGAL_MULTISET_NO_ASSERTIONS` and
|
||||||
|
`CGAL_MULTISET_NO_PRECONDITIONS`).
|
||||||
|
|
||||||
|
Implementation
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`Multiset` uses a proprietary implementation of a red-black tree
|
||||||
|
data-structure. The red-black tree invariants guarantee that the height of a
|
||||||
|
tree containing \f$ n\f$ elements is \f$ O(\log{n})\f$ (more precisely, it is bounded by
|
||||||
|
\f$ 2 \log_{2}{n}\f$). As a consequence, all methods that accept an element and need
|
||||||
|
to locate it in the tree (namely `insert(x)`, `erase(x)`,
|
||||||
|
`find(x)`, `count(x)`, `lower_bound(x)` , `upper_bound(x)`,
|
||||||
|
`find_lower(x)` and `equal_range(x)`) take \f$ O(\log{n})\f$ time and
|
||||||
|
perform \f$ O(\log{n})\f$ comparison operations.
|
||||||
|
|
||||||
|
On the other hand, the set operations that accept a position iterator (namely
|
||||||
|
`insert_before(pos, x)`, `insert_after(pos, x)` and `erase(pos)`)
|
||||||
|
are much more efficient as they can be performed at a <I>constant</I> amortized
|
||||||
|
cost (see \cite gs-dfbt-78 and \cite t-dsna-83 for more details).
|
||||||
|
More important, these set operations require <I>no</I> comparison operations.
|
||||||
|
Therefore, it is highly recommended to maintain the set via iterators
|
||||||
|
to the stored elements, whenever possible. The function `insert(pos, x)`
|
||||||
|
is safer to use, but it takes amortized \f$ O(\min\{d,\log{n}\})\f$ time, where \f$ d\f$
|
||||||
|
is the distance between the given position and the true position of `x`.
|
||||||
|
In addition, it always performs at least two comparison operations.
|
||||||
|
|
||||||
|
The `catenate()` and `split()` functions are also very efficient, and
|
||||||
|
can be performed in \f$ O(\log{n})\f$ time, where \f$ n\f$ is the total number of
|
||||||
|
elements in the sets, and without performing any comparison operations
|
||||||
|
(see \cite t-dsna-83 for the details).
|
||||||
|
Note however that the size of two sets resulting from a split operation is
|
||||||
|
initially unknown, as it is impossible to compute it in less than linear time.
|
||||||
|
Thus, the first invocation of `size()` on such a set takes linear time,
|
||||||
|
and <I>not</I> constant time.
|
||||||
|
|
||||||
|
The design is derived from the \stl `multiset` class-template (see,
|
||||||
|
e.g, \cite cgal:ms-strg-96), where the main differences between the two
|
||||||
|
classes are highlighted in the class definition above.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Type, typename Compare, typename Allocator >
|
||||||
|
class Multiset {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\name Types
|
||||||
|
In compliance with \stl, the types `value_type` and `key_type`
|
||||||
|
(both equivalent to `Type`), `reference` and `const_reference`
|
||||||
|
(reference to a value-type), `key_compare` and `value_compare`
|
||||||
|
(both equivalent to `Compare`), `size_type` and `difference_type`
|
||||||
|
are defined as well.
|
||||||
|
*/
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type iterator;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
bi-directional iterators for the elements stored in the set.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_iterator;
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef Hidden_type reverse_iterator;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
reverse bi-directional iterators for the elements stored in the set.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type const_reverse_iterator;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
creates an an empty set `s` that uses a default comparison
|
||||||
|
functor.
|
||||||
|
*/
|
||||||
|
Multiset<Type,Compare,Allocator>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
creates an an empty set `s` that uses the given comparison
|
||||||
|
functor `comp`.
|
||||||
|
*/
|
||||||
|
Multiset<Type,Compare,Allocator>(
|
||||||
|
const Compare& comp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
creates a set `s` containing all elements in the range
|
||||||
|
`[first, last)`, that uses the comparison
|
||||||
|
functor `comp`.
|
||||||
|
*/
|
||||||
|
template <class InputIterator>
|
||||||
|
Multiset<Type,Compare,Allocator>(
|
||||||
|
InputIterator first, InputIterator last,
|
||||||
|
const Compare& comp = Compare());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
copy constructor.
|
||||||
|
*/
|
||||||
|
Multiset<Type,Compare,Allocator>(
|
||||||
|
const Multiset<Type,Compare,Allocator>& other);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
assignment operator.
|
||||||
|
*/
|
||||||
|
const Multiset<Type,Compare,Allocator>& operator= (
|
||||||
|
const Multiset<Type,Compare,Allocator>& other);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
swaps the contents of `s` with those of the other set.
|
||||||
|
*/
|
||||||
|
void swap (Multiset<Type,Compare,Allocator>& other);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
the comparison functor used.
|
||||||
|
*/
|
||||||
|
Compare key_comp() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
the comparison functor used (same as above).
|
||||||
|
Both functions have a non-const version that return a reference
|
||||||
|
to the comparison functor.
|
||||||
|
*/
|
||||||
|
Compare value_comp() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `true` if the set is empty, `false` otherwise.
|
||||||
|
*/
|
||||||
|
bool empty ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the number of elements stored in the set.
|
||||||
|
*/
|
||||||
|
size_t size ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the maximal number of elements the set can store
|
||||||
|
(same as `size()`).
|
||||||
|
*/
|
||||||
|
size_t max_size ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns an iterator pointing to the first element stored in the set
|
||||||
|
(a `const` version is also available).
|
||||||
|
*/
|
||||||
|
iterator begin();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns an iterator pointing beyond the last element stored in the set
|
||||||
|
(a `const` version is also available).
|
||||||
|
*/
|
||||||
|
iterator end();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns a reverse iterator pointing beyond the last element stored in the
|
||||||
|
set (a `const` version is also available).
|
||||||
|
*/
|
||||||
|
reverse_iterator rbegin();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Member Functions
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns a reverse iterator pointing to the first element stored in the set
|
||||||
|
(a `const` version is also available).
|
||||||
|
*/
|
||||||
|
reverse_iterator rend();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `true` if the sequences of elements in the two sets are
|
||||||
|
pairwise equal (using the comparison functor).
|
||||||
|
*/
|
||||||
|
bool operator== (
|
||||||
|
const Multiset<Type,Compare,Allocator>& other) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Comparison Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `true` if the element sequence in `s` is
|
||||||
|
lexicographically smaller than the element sequence of `other`.
|
||||||
|
*/
|
||||||
|
bool operator< (
|
||||||
|
const Multiset<Type,Compare,Allocator>& other) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
inserts the element `x` into the set and returns an iterator pointing
|
||||||
|
to the newly inserted element.
|
||||||
|
*/
|
||||||
|
iterator insert (const Type& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
inserts all elements in the range `[first, last)` into
|
||||||
|
the set.
|
||||||
|
*/
|
||||||
|
template <class InputIterator>
|
||||||
|
void insert (InputIterator first, InputIterator last);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
inserts the element `x` with a given iterator used as a hint for the
|
||||||
|
position of the new element. It Returns an iterator pointing to the
|
||||||
|
newly inserted element.
|
||||||
|
*/
|
||||||
|
iterator insert (iterator position, const Type& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
inserts the element `x` as the predecessor of the element at the given
|
||||||
|
position.
|
||||||
|
\pre The operation does not violate the set order - that is,
|
||||||
|
`x` is not greater than the element pointed by
|
||||||
|
`position` and not less than its current predecessor.
|
||||||
|
*/
|
||||||
|
iterator insert_before (iterator position, const Type& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Insertion Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
inserts the element `x` as the successor of the element at the given
|
||||||
|
position.
|
||||||
|
\pre The operation does not violate the set order - that is,
|
||||||
|
`x` is not less than the element pointed by
|
||||||
|
`position` and not greater than its current successor.
|
||||||
|
*/
|
||||||
|
iterator insert_after (iterator position, const Type& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
erases all elements equivalent to `x` from the set and returns the
|
||||||
|
number of erased elements.
|
||||||
|
*/
|
||||||
|
size_t erase (const Type& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
erases the element pointed by `position`.
|
||||||
|
*/
|
||||||
|
void erase (iterator position);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Removal Methods
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
clears the set (erases all stored elements).
|
||||||
|
*/
|
||||||
|
void clear ();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\name Look-up Methods
|
||||||
|
All methods listed in this section can also accept a `Type` element
|
||||||
|
as a look-up key. In this case, it is not necessary to supply a `CompareKey`
|
||||||
|
functor, as the `Compare` functor will be used by default.
|
||||||
|
*/
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
searches for the an element equivalent to `key` in the set. If the
|
||||||
|
set contains objects equivalent to `key`, it returns an iterator
|
||||||
|
pointing to the first one. Otherwise, `end()` is returned (a
|
||||||
|
`const` version is also available).
|
||||||
|
*/
|
||||||
|
template <class Key, class CompareKey>
|
||||||
|
iterator find (const Key& key, const CompareKey& comp_key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the number of elements equivalent to `key` in the set.
|
||||||
|
*/
|
||||||
|
template <class Key, class CompareKey>
|
||||||
|
size_t count (const Key& key, const CompareKey& comp_key) const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns an iterator pointing to the first element in the set that is not
|
||||||
|
less than `key`. If all set elements are less than `key`,
|
||||||
|
`end()` is returned (a `const` version is also available).
|
||||||
|
*/
|
||||||
|
template <class Key, class CompareKey>
|
||||||
|
iterator lower_bound (const Key& key, const CompareKey& comp_key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns an iterator pointing to the first element in the set that is
|
||||||
|
greater than `key`. If no set element is greater than `key`,
|
||||||
|
`end()` is returned (a `const` version is also available).
|
||||||
|
*/
|
||||||
|
template <class Key, class CompareKey>
|
||||||
|
iterator upper_bound (const Key& key, const CompareKey& comp_key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the range of set elements equivalent to the given key, namely
|
||||||
|
`(lower_bound(key), upper_bound(key))` (a `const` version is
|
||||||
|
also available).
|
||||||
|
*/
|
||||||
|
template <class Key, class CompareKey>
|
||||||
|
std::pair<iterator,iterator>
|
||||||
|
equal_range (const Key& key, const CompareKey& comp_key);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns a pair comprised of `lower_bound(key)` and a Boolean flag
|
||||||
|
indicating whether this iterator points to an element equivalent to
|
||||||
|
the given key (a `const` version is also available).
|
||||||
|
*/
|
||||||
|
template <class Key, class CompareKey>
|
||||||
|
std::pair<iterator,bool>
|
||||||
|
find_lower (const Key& key, const CompareKey& comp_key);
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
replaces the element stored at the given position with `x`.
|
||||||
|
\pre The operation does not violate the set order - that is,
|
||||||
|
`x` is not less that `position`'s predecessor and
|
||||||
|
not greater than its successor.
|
||||||
|
*/
|
||||||
|
void replace (iterator position, const Type& x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
swaps places between the two elements given by `pos1` and `pos2`.
|
||||||
|
\pre The operation does not violate the set order - that is,
|
||||||
|
`pos1` and `pos2` store equivalent elements.
|
||||||
|
*/
|
||||||
|
void swap (iterator pos1, iterator pos2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
concatenates all elements in `s_prime` into `s` and clears
|
||||||
|
`s_prime`.
|
||||||
|
All iterators to `s` and to `s_prime` remain valid.
|
||||||
|
\pre The maximal element in `s` is not greater than the minimal
|
||||||
|
element in `s_prime`.
|
||||||
|
*/
|
||||||
|
void catenate (Self& s_prime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
splits `s` such that it contains all elements that are less than
|
||||||
|
the given `key` and such that `s_prime` contains all other elements.
|
||||||
|
\pre `s_prime` is initially empty.
|
||||||
|
*/
|
||||||
|
template <class Key, class CompareKey>
|
||||||
|
void split (Key key, CompareKey comp_key, Self& s_prime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Special Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
splits `s` such that it contains all set elements in the range
|
||||||
|
`[begin, position)` and such that `s_prime` contains all elements
|
||||||
|
in the range `[position, end())`.
|
||||||
|
\pre `s_prime` is initially empty.
|
||||||
|
*/
|
||||||
|
void split (iterator position, Self& s_prime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Multiset */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,194 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
Some functions can return different types of objects. A typical
|
||||||
|
\cpp solution to this problem is to derive all possible return
|
||||||
|
types from a common base class, to return a pointer to this
|
||||||
|
class and to perform a dynamic cast on this pointer. The class
|
||||||
|
`Object` provides an abstraction.
|
||||||
|
An object `obj` of the class `Object` can
|
||||||
|
represent an arbitrary class. The only operations it provides is
|
||||||
|
to make copies and assignments, so that you can put them in lists
|
||||||
|
or arrays. Note that `Object` is NOT a common base class for the
|
||||||
|
elementary classes. Therefore, there is no
|
||||||
|
automatic conversion from these classes to `Object`. Rather
|
||||||
|
this is done with the global function `make_object`. This
|
||||||
|
encapsulation mechanism requires the use of `assign` or
|
||||||
|
`object_cast` to use the functionality of the encapsulated class.
|
||||||
|
|
||||||
|
This class is similar in spirit to `boost::any`.
|
||||||
|
|
||||||
|
Example
|
||||||
|
--------------
|
||||||
|
|
||||||
|
In the following example, the object class is used as return value for the
|
||||||
|
intersection computation, as there are possibly different return values.
|
||||||
|
|
||||||
|
\code{.cpp}
|
||||||
|
{
|
||||||
|
typedef Cartesian<double> K;
|
||||||
|
typedef K::Point_2 Point_2;
|
||||||
|
typedef K::Segment_2 Segment_2;
|
||||||
|
|
||||||
|
Point_2 point;
|
||||||
|
Segment_2 segment, segment_1, segment_2;
|
||||||
|
|
||||||
|
std::cin >> segment_1 >> segment_2;
|
||||||
|
|
||||||
|
Object obj = intersection(segment_1, segment_2);
|
||||||
|
|
||||||
|
if (assign(point, obj)) {
|
||||||
|
//do something with point
|
||||||
|
} else if (assign(segment, obj)) {
|
||||||
|
// do something with segment
|
||||||
|
}
|
||||||
|
//there was no intersection
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
A more efficient way to access the object is to use `object_cast`,
|
||||||
|
which allows to skip a default construction and assignment :
|
||||||
|
|
||||||
|
\code{.cpp}
|
||||||
|
{
|
||||||
|
typedef Cartesian<double> K;
|
||||||
|
typedef K::Point_2 Point_2;
|
||||||
|
typedef K::Segment_2 Segment_2;
|
||||||
|
|
||||||
|
Segment_2 segment_1, segment_2;
|
||||||
|
|
||||||
|
std::cin >> segment_1 >> segment_2;
|
||||||
|
|
||||||
|
Object obj = intersection(segment_1, segment_2);
|
||||||
|
|
||||||
|
if (const Point_2 * point = object_cast<Point_2>(&obj)) {
|
||||||
|
// do something with *point
|
||||||
|
} else if (const Segment_2 * segment = object_cast<Segment_2>(&obj)) {
|
||||||
|
// do something with *segment
|
||||||
|
}
|
||||||
|
// there was no intersection
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
The intersection routine itself looks roughly as follows:
|
||||||
|
|
||||||
|
\code{.cpp}
|
||||||
|
template < class Kernel >
|
||||||
|
Object intersection(Segment_2<Kernel> s1, Segment_2<Kernel> s2)
|
||||||
|
{
|
||||||
|
if ( intersection_is_a_point ) {
|
||||||
|
Point_2<Kernel> p = ... ;
|
||||||
|
return make_object(p);
|
||||||
|
} else if ( intersection_is_a_segment ) {
|
||||||
|
Segment_2<Kernel> s = ... ;
|
||||||
|
return make_object(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
// empty intersection
|
||||||
|
return Object();
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
*/
|
||||||
|
class Object {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// Objects of type `Object` are normally created using the global function `make_object`.
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces an empty object.
|
||||||
|
*/
|
||||||
|
Object();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Copy constructor.
|
||||||
|
*/
|
||||||
|
Object(const Object &o);
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Assignment.
|
||||||
|
*/
|
||||||
|
Object &operator=(const Object &o);
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns true, if `obj` does not
|
||||||
|
contain an object.
|
||||||
|
*/
|
||||||
|
bool empty();
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns true, iff `obj` contains an object of type `T`.
|
||||||
|
*/
|
||||||
|
template<class T> bool is();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the type information of the contained type,
|
||||||
|
or `typeid(void)` if empty.
|
||||||
|
*/
|
||||||
|
const std::type_info & type() const;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Object */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Creates an object that contains `t`.
|
||||||
|
|
||||||
|
\relates Object
|
||||||
|
*/
|
||||||
|
template <class T> Object make_object(const T &t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
assigns `o` to `c` if `o` was constructed from an object of type `T`.
|
||||||
|
Returns `true`, if the assignment was possible. For efficiency
|
||||||
|
reasons, we recommend using `object_cast` instead.
|
||||||
|
|
||||||
|
\relates Object
|
||||||
|
*/
|
||||||
|
|
||||||
|
template <class T> bool assign(T& c, const Object& o);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns a pointer to the object of type `T` stored by `o`,
|
||||||
|
if any, otherwise returns `NULL`.
|
||||||
|
\relates Object
|
||||||
|
*/
|
||||||
|
template <class T> const T * object_cast(const Object * o);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns a copy of the object of type `T` stored by `o`,
|
||||||
|
if any, otherwise throws an exception of type `Bad_object_cast`.
|
||||||
|
\relates Object
|
||||||
|
*/
|
||||||
|
template <class T> T object_cast(const Object & o);
|
||||||
|
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,138 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
The `Sixtuple` class stores a homogeneous (same type)
|
||||||
|
sixtuple of objects of type `T`. A `Sixtuple` is much like a
|
||||||
|
container, in that it "owns" its elements. It is not actually a model of
|
||||||
|
container, though, because it does not support the standard methods (such as
|
||||||
|
iterators) for accessing the elements of a container.
|
||||||
|
|
||||||
|
\deprecated This class is deprecated, and will be removed in some future \cgal release.
|
||||||
|
Please use CGAL::cpp11::array instead.
|
||||||
|
|
||||||
|
\require `T` must be `Assignable`.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Sixtuple {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T value_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
first element
|
||||||
|
*/
|
||||||
|
T e0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
second element
|
||||||
|
*/
|
||||||
|
T e1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
third element
|
||||||
|
*/
|
||||||
|
T e2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
fourth element
|
||||||
|
*/
|
||||||
|
T e3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
fifth element
|
||||||
|
*/
|
||||||
|
T e4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
sixth element
|
||||||
|
*/
|
||||||
|
T e5;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a `Sixtuple` using the default
|
||||||
|
constructor of the elements.
|
||||||
|
*/
|
||||||
|
Sixtuple();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a
|
||||||
|
`Sixtuple` such that `e0` is constructed from `x`, `e1` from
|
||||||
|
`y`, `e2` from `z`, `e3` from `t`, `e4` from
|
||||||
|
`u` and `e5` from `v`.
|
||||||
|
*/
|
||||||
|
Sixtuple(T x, T y, T z, T t, T u, T v);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Sixtuple */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
\deprecated This class is deprecated, and will be removed in some future \cgal release.
|
||||||
|
Please use CGAL::cpp0x::array instead.
|
||||||
|
|
||||||
|
The `Threetuple` class stores a homogeneous (same type) triple
|
||||||
|
of objects of type `T`. A `Threetuple` is much like a container, in that
|
||||||
|
it "owns" its elements. It is not actually a model of container, though,
|
||||||
|
because it does not support the standard methods (such as iterators) for
|
||||||
|
accessing the elements of a container.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`T` must be `Assignable`.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Threetuple {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T value_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
first element
|
||||||
|
*/
|
||||||
|
T e0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
second element
|
||||||
|
*/
|
||||||
|
T e1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
third element
|
||||||
|
*/
|
||||||
|
T e2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a `Threetuple` using the default
|
||||||
|
constructor of the elements.
|
||||||
|
*/
|
||||||
|
Threetuple();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a `Threetuple` such
|
||||||
|
that `e0` is constructed from `x`, `e1` is
|
||||||
|
constructed from `y` and `e2` is constructed from `z`.
|
||||||
|
*/
|
||||||
|
Threetuple(T x, T y, T z);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Threetuple */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
The `Twotuple` class stores a homogeneous (same type) pair
|
||||||
|
of objects of type `T`. A `Twotuple` is much like a container, in that
|
||||||
|
it "owns" its elements. It is not actually a model of container, though,
|
||||||
|
because it does not support the standard methods (such as iterators) for
|
||||||
|
accessing the elements of a container.
|
||||||
|
|
||||||
|
\deprecated This class is deprecated, and will be removed in some future \cgal release.
|
||||||
|
Please use CGAL::cpp11::array instead.
|
||||||
|
|
||||||
|
\tparam T must be `Assignable`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Twotuple {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T value_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
first element
|
||||||
|
*/
|
||||||
|
T e0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
second element
|
||||||
|
*/
|
||||||
|
T e1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a `Twotuple` using the default
|
||||||
|
constructor of the elements.
|
||||||
|
*/
|
||||||
|
Twotuple();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a `Twotuple` such
|
||||||
|
that `e0` is constructed from `x` and `e1` is
|
||||||
|
constructed from `y`.
|
||||||
|
*/
|
||||||
|
Twotuple(T x, T y);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Twotuple */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,652 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
An object of the class `Uncertain` represents an uncertainty on the
|
||||||
|
value of type `T`. This uncertainty is represented by a non-empty range of
|
||||||
|
values of type `T`.
|
||||||
|
|
||||||
|
The idea is that sometimes you are not sure of the result of a function, and
|
||||||
|
you would like to communicate that to the caller. `Uncertain<T>` allows
|
||||||
|
just that.
|
||||||
|
|
||||||
|
`Uncertain<T>` is also meant to be used as a drop-in replacement for
|
||||||
|
`T` in some template contexts, as much as possible. This is why it
|
||||||
|
provides overloaded operators and functions to naturally extend the Boolean
|
||||||
|
operations for `Uncertain<bool>` for example, or the operations on
|
||||||
|
enumeration types.
|
||||||
|
|
||||||
|
`Uncertain<T>` is used in \cgal as the return type of geometric predicates
|
||||||
|
when the number type used is interval arithmetic like `Interval_nt`. End
|
||||||
|
users typically do not see it, as it is hidden in the implementation of the
|
||||||
|
filtered predicates provided by the various filtered kernels, but it is
|
||||||
|
important that providers of predicates that are meant to be filtered by
|
||||||
|
`Filtered_predicate`, know about it.
|
||||||
|
|
||||||
|
Note concerning \cgal assertions: assertions checking an expression of type
|
||||||
|
`Uncertain<bool>` will trigger an assertion failure only if the assertion
|
||||||
|
is certainly `false`. In case of an indeterminate value, the assertion is not
|
||||||
|
triggered. This means that we assume, in case of doubt, that there is no
|
||||||
|
error.
|
||||||
|
|
||||||
|
It can also be used in other contexts as well, as it is a general tool.
|
||||||
|
This can be seen as support for non-deterministic programming.
|
||||||
|
Finally, note that this class has some common points with `boost::tribool`.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The parameter `T` can either be `bool` or one of the three-valued
|
||||||
|
(-1, 0, 1) enumeration types: `Sign`, `Comparison_result`,
|
||||||
|
`Orientation`, `Oriented_side`, `Bounded_side` or `Angle`.
|
||||||
|
|
||||||
|
Some functions are defined only when `T` is `bool` or alternatively
|
||||||
|
when it is one of the enumeration types listed previously.
|
||||||
|
|
||||||
|
\sa `CGAL::Interval_nt<bool>`
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Uncertain {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
The type `T`.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type value_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
The type of the exception
|
||||||
|
thrown for uncertain conversions. It is a typedef to the type
|
||||||
|
`CGAL::Uncertain_conversion_exception` which derives from `std::range_error`.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type Uncertain_conversion_exception;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a certain object with value `T()`.
|
||||||
|
*/
|
||||||
|
Uncertain();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a certain object with value `t`.
|
||||||
|
*/
|
||||||
|
Uncertain(T t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
assigns the certain value `t` to `u`.
|
||||||
|
*/
|
||||||
|
Uncertain& operator=(T t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces an object representing the range with lower bound `i` and
|
||||||
|
upper bound `s`. \pre \f$ i<= s\f$.
|
||||||
|
*/
|
||||||
|
Uncertain(T i, T s);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Access Functions
|
||||||
|
/// The following functions are meant to be used very rarely, they provide ways to inspect
|
||||||
|
/// the content of an `Uncertain<T>` object.
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns the lower bound of the range represented by `u`.
|
||||||
|
*/
|
||||||
|
T inf() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns the upper bound of the range represented by `u`.
|
||||||
|
*/
|
||||||
|
T sup() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns true whether `u` and `u` are the same range (equality as sets).
|
||||||
|
*/
|
||||||
|
bool is_same(Uncertain u) const;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Uncertainty testing and conversion
|
||||||
|
/// There are several ways to extract the content of an `Uncertain` object. The simplest way is to
|
||||||
|
/// rely on the implicit conversion from `Uncertain<T>` to `T`. In this case, no special
|
||||||
|
/// code has to be written, apart from an exception handler (anywhere higher in the call stack) to manage
|
||||||
|
/// the uncertain case. The more involved one is more efficient, but requires manual treatment
|
||||||
|
/// of the uncertain case, such as:
|
||||||
|
///
|
||||||
|
/// \code{.cpp}
|
||||||
|
///
|
||||||
|
/// Uncertain<bool> b = ...;
|
||||||
|
/// if (is_certain(b))
|
||||||
|
/// bool cert_b = get_certain(b); // Extract the certain bool it contains
|
||||||
|
/// ...
|
||||||
|
/// else
|
||||||
|
/// ... // b is indeterminate
|
||||||
|
///
|
||||||
|
/// \endcode
|
||||||
|
///
|
||||||
|
/// Another option is :
|
||||||
|
///
|
||||||
|
/// \code{.cpp}
|
||||||
|
///
|
||||||
|
/// Uncertain<bool> b = ...;
|
||||||
|
/// if (certainly(b))
|
||||||
|
/// ... // b is certainly true
|
||||||
|
/// else if (certainly_not(b))
|
||||||
|
/// ... // b is certainly false
|
||||||
|
/// else
|
||||||
|
/// ... // b is indeterminate
|
||||||
|
///
|
||||||
|
/// \endcode
|
||||||
|
///
|
||||||
|
/// There are many other handy functions which can be used for easier usage depending
|
||||||
|
/// on the context. They are listed in the sequel.
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `true` iff the value is certain, that is, it is unique, the range
|
||||||
|
is a singleton. That is, `u.inf() == u.sup()`.
|
||||||
|
*/
|
||||||
|
bool is_certain() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
if `u`.`is_certain()`, then returns the certain value which is represented.
|
||||||
|
Otherwise, throws an exception of type `Uncertain_conversion_exception`.
|
||||||
|
A profile counter of the number of such exceptions thrown during the execution of
|
||||||
|
the program is available with `CGAL_PROFILE`.
|
||||||
|
*/
|
||||||
|
T make_certain() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
conversion operator to `T`. It does and returns the same thing as
|
||||||
|
`u`. `make_certain()`. Note that relying on the automatic conversion
|
||||||
|
can throw exceptions, which defeats the purpose of propagating uncertainty.
|
||||||
|
Nevertheless, in many cases, it is hard to avoid it, for example for the
|
||||||
|
`&&` and \f$ ||\f$ operators for `bool` (see below).
|
||||||
|
*/
|
||||||
|
operator T() const;
|
||||||
|
|
||||||
|
///@}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns an indeterminate range.
|
||||||
|
*/
|
||||||
|
static Uncertain<T> indeterminate();
|
||||||
|
|
||||||
|
/*! \name Overloaded Operators
|
||||||
|
The overloaded operators and functions are defined as preserving the set-inclusion property.
|
||||||
|
Similarly to interval arithmetic, the returned range is guaranteed to contain
|
||||||
|
the result of the operation over all values of the input range(s).
|
||||||
|
In the following documentation we express this as the extension of the corresponding function
|
||||||
|
over the type `T`.
|
||||||
|
*/
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns the extension of the equality operator over `u` and `v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator==(Uncertain<T> u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u == make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator==(Uncertain<T> u, T v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `v == u`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator==(T u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns the extension of the inequality operator over `u` and `v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator!=(Uncertain<T> u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u != make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator!=(Uncertain<T> u, T v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `v != u`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator!=(T u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\name Overloaded operators for Uncertain<bool>
|
||||||
|
|
||||||
|
The overloaded operators and functions are defined as preserving the set-inclusion property.
|
||||||
|
Similarly to interval arithmetic, the returned range is guaranteed to contain
|
||||||
|
the result of the operation over all values of the input range(s).
|
||||||
|
In the following documentation we express this as the extension of the corresponding function
|
||||||
|
over the type `T`.
|
||||||
|
|
||||||
|
\note The logical operators \f$ \&\&\f$ and \f$ ||\f$ are not overloaded on purpose. The reason
|
||||||
|
is that, when `f() && g()` is evaluated and they return `bool`, then `g()`
|
||||||
|
is only evaluated when `f()` returns `true`. One could have a dependency so
|
||||||
|
that `g()` has an internal precondition that required that `f()` had returned `true`.
|
||||||
|
The overloaded operators for user-defined types can not provide this short-circuiting
|
||||||
|
property, and so, if the overloaded operators where provided, then `g()` would
|
||||||
|
be evaluated, no matter the result of `f()`, which could lead to an unwanted
|
||||||
|
situation, or a performance loss. The \f$ \&\f$ and \f$ |\f$ operators do not have
|
||||||
|
this short-circuiting property, and are therefore overloaded safely.
|
||||||
|
|
||||||
|
When translating normal code to use and propagate uncertainty, such as :
|
||||||
|
|
||||||
|
\code{.cpp}
|
||||||
|
|
||||||
|
// Logical AND
|
||||||
|
if ( (p.x() == 0) && (p.y() == 0) )
|
||||||
|
...
|
||||||
|
else
|
||||||
|
...
|
||||||
|
|
||||||
|
// Logical OR
|
||||||
|
if ( (q.x() == 0) || (q.y() == 0) )
|
||||||
|
...
|
||||||
|
else
|
||||||
|
...
|
||||||
|
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
One can do, for example :
|
||||||
|
|
||||||
|
\code{.cpp}
|
||||||
|
|
||||||
|
// Logical AND
|
||||||
|
Uncertain<bool> tmp = (p.x() == 0);
|
||||||
|
Uncertain<bool> res = certainly_not(tmp) ? make_uncertain(false) : tmp & (p.y() == 0);
|
||||||
|
|
||||||
|
... // Use res
|
||||||
|
|
||||||
|
// Logical OR
|
||||||
|
Uncertain<bool> tmp = (q.x() == 0);
|
||||||
|
Uncertain<bool> res = certainly(tmp) ? make_uncertain(true) : tmp | (q.y() == 0);
|
||||||
|
|
||||||
|
... // Use res
|
||||||
|
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
This ensures that the first expression is not evaluated twice, and that the second is
|
||||||
|
evaluated only if needed.
|
||||||
|
|
||||||
|
This behavior can also be emulated through the use of macros, but only using
|
||||||
|
non-standard features ("statement expressions", such as provided by GCC). The
|
||||||
|
macros `CGAL_AND` and `CGAL_OR` are provided that perform the lazy
|
||||||
|
evaluation of these logical operations. On compilers that do not support
|
||||||
|
statement expressions, the macros simply expand to the \f$ \&\&\f$ and \f$ ||\f$
|
||||||
|
operators (which will throw an exception instead of propagating the uncertainty).
|
||||||
|
|
||||||
|
\code{.cpp}
|
||||||
|
|
||||||
|
// Logical AND
|
||||||
|
Uncertain<bool> res = CGAL_AND( p.x() == 0 , p.y() == 0 );
|
||||||
|
|
||||||
|
... // Use res
|
||||||
|
|
||||||
|
// Logical OR
|
||||||
|
Uncertain<bool> res = CGAL_OR( q.x() == 0 , q.y() == 0 );
|
||||||
|
|
||||||
|
... // Use res
|
||||||
|
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
*/
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the range containing the negated values of `u`.
|
||||||
|
*/
|
||||||
|
Uncertain<bool> operator!(Uncertain<bool> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the range containing the values computed as logical or from `u` and `v`.
|
||||||
|
*/
|
||||||
|
Uncertain<bool> operator|(Uncertain<bool> u, Uncertain<bool> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `u | make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
Uncertain<bool> operator|(Uncertain<bool> u, bool v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `v | u`.
|
||||||
|
*/
|
||||||
|
Uncertain<bool> operator|(bool u, Uncertain<bool> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the range containing the values computed as logical and from `u` and `v`.
|
||||||
|
*/
|
||||||
|
Uncertain<bool> operator&(Uncertain<bool> u, Uncertain<bool> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `u & make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
Uncertain<bool> operator&(Uncertain<bool> u, bool v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `v & u`.
|
||||||
|
*/
|
||||||
|
Uncertain<bool> operator&(bool u, Uncertain<bool> v);
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Overloaded operators and functions for `Uncertain<enum T>` only
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the extension of the less-than operator over `u` and `v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator<(Uncertain<T> u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `u < make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator<(Uncertain<T> u, T v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `make_uncertain(u) < v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator<(T u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the extension of the greater-than operator over `u` and `v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator>(Uncertain<T> u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `u > make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator>(Uncertain<T> u, T v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `make_uncertain(u) > v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator>(T u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the extension of the less-than or equal operator over `u` and `v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator<=(Uncertain<T> u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `u <= make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator<=(Uncertain<T> u, T v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `make_uncertain(u) <= v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator<=(T u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the extension of the greater-than or equal operator over `u` and `v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator>=(Uncertain<T> u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `u > make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator>=(Uncertain<T> u, T v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `make_uncertain(u) >= v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<bool> operator>=(T u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the extension of the multiplication operator over `u` and `v`.
|
||||||
|
This requires `T` to have a multiplication operator as well.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<T> operator*(Uncertain<T> u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `u * make_uncertain(v)`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<T> operator*(Uncertain<T> u, T v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns `make_uncertain(u) * v`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<T> operator<(T u, Uncertain<T> v);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the extension of the unary minus operator over `u`.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
Uncertain<T> operator-(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
returns the extension of the `enum_cast<T>` function over `u`.
|
||||||
|
*/
|
||||||
|
template <class T, class U>
|
||||||
|
Uncertain<T> enum_cast(Uncertain<U> u);
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Uncertain */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u.inf()`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> T inf(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u.sup()`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> T sup(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `true`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> bool is_certain(T t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u`.`is_certain`().
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> bool is_certain(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `U::indeterminate()` if `U` is `Uncertain<T>`,
|
||||||
|
and `U()` otherwise.
|
||||||
|
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class U> U indeterminate();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `false`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> bool is_indeterminate(T u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `!is_certain(u)`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> bool is_indeterminate(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `t`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> T get_certain(T t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u`.`make_certain`(). \pre `u`.`is_certain`().
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> T get_certain(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `t`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> T make_certain(T t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u`.`make_certain`().
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> T make_certain(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `Uncertain<T>(u)`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> Uncertain<T> make_uncertain(T t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
template <class T> Uncertain<T> make_uncertain(Uncertain<T> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Boolean operation with 3 arguments.
|
||||||
|
\relates CGAL::Uncertain
|
||||||
|
*/
|
||||||
|
#define CGAL_AND_3
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Boolean operation with 3 arguments.
|
||||||
|
\relates CGAL::Uncertain
|
||||||
|
*/
|
||||||
|
#define CGAL_OR_3
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `true` iff `u`.`is_certain()`, and the `u`.`make_certain`()
|
||||||
|
returns `true`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool certainly(Uncertain<bool> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool certainly(bool u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `true` iff `u`.`is_certain()` returns `false`, or if
|
||||||
|
`u`.`make_certain`() returns `true`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool possibly(Uncertain<bool> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `u`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool possibly(bool u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `true` iff `u`.`is_certain()`, and the `u`.`make_certain`()
|
||||||
|
returns `false`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool certainly_not(Uncertain<bool> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `!u`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool certainly_not(bool u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `true` iff `u`.`is_certain()` returns `false`, or if
|
||||||
|
`u`.`make_certain`() returns `false`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool possibly_not(Uncertain<bool> u);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
returns `!u`.
|
||||||
|
\relates Uncertain
|
||||||
|
*/
|
||||||
|
bool possibly_not(bool u);
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,202 @@
|
||||||
|
/// \defgroup STLAlgos Generic Algorithms
|
||||||
|
/// \ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
\deprecated This function is deprecated, CGAL::cpp0x::copy_n should be
|
||||||
|
used instead.
|
||||||
|
|
||||||
|
The function `copy_n` copies \f$ n\f$ items from an input iterator to
|
||||||
|
an output iterator which is useful for possibly infinite sequences of
|
||||||
|
random geometric objects.
|
||||||
|
|
||||||
|
\note The \stl release June 13, 1997, from SGI contains an equivalent
|
||||||
|
function, but it is not part of the ISO standard.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\sa `CGAL::Counting_iterator<Iterator, Value>`
|
||||||
|
|
||||||
|
copies the first \f$ n\f$ items from `first` to `result`. Returns the
|
||||||
|
value of `result` after inserting the \f$ n\f$ items.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template <class InputIterator, class Size, class
|
||||||
|
OutputIterator> OutputIterator copy_n(InputIterator first, Size n,
|
||||||
|
OutputIterator result);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
|
||||||
|
The function `min_max_element` computes the minimal and the
|
||||||
|
maximal element of a range. It is modeled after the STL functions
|
||||||
|
`min_element` and `max_element`. The advantage of
|
||||||
|
`min_max_element` compared to calling both STL functions is that
|
||||||
|
one only iterates once over the sequence. This is more efficient
|
||||||
|
especially for large and/or complex sequences.
|
||||||
|
|
||||||
|
Example
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The following example program computes the minimal and
|
||||||
|
maximal element of the sequence \f$ (3,\,6,\,5)\f$. Hence the output is
|
||||||
|
`min = 3, max = 6`.
|
||||||
|
|
||||||
|
\cgalexample{STL_Extension/min_max_element_example.cpp}
|
||||||
|
|
||||||
|
\returns a pair of iterators where
|
||||||
|
the first component refers to the minimal and the second component
|
||||||
|
refers to the maximal element in the range [`first`,
|
||||||
|
`last`). The ordering is defined by `operator<` on the
|
||||||
|
value type of `ForwardIterator`.
|
||||||
|
*/
|
||||||
|
template < class ForwardIterator > std::pair<
|
||||||
|
ForwardIterator, ForwardIterator > min_max_element(ForwardIterator
|
||||||
|
first, ForwardIterator last);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
The function `min_max_element` computes the minimal and the
|
||||||
|
maximal element of a range. It is modeled after the STL functions
|
||||||
|
`min_element` and `max_element`. The advantage of
|
||||||
|
`min_max_element` compared to calling both STL functions is that
|
||||||
|
one only iterates once over the sequence. This is more efficient
|
||||||
|
especially for large and/or complex sequences.
|
||||||
|
|
||||||
|
Example
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The following example program computes the minimal and
|
||||||
|
maximal element of the sequence \f$ (3,\,6,\,5)\f$. Hence the output is
|
||||||
|
`min = 3, max = 6`.
|
||||||
|
|
||||||
|
\cgalexample{STL_Extension/min_max_element_example.cpp}
|
||||||
|
|
||||||
|
\returns a pair of iterators where the first component refers to the minimal and the
|
||||||
|
second component refers to the maximal element in the range
|
||||||
|
[`first`, `last`).
|
||||||
|
|
||||||
|
\require `CompareMin` and `CompareMax` are adaptable binary
|
||||||
|
function objects: `VT` \f$ \times\f$ `VT` \f$ \rightarrow\f$ `bool` where `VT`
|
||||||
|
is the value type of `ForwardIterator`.
|
||||||
|
*/
|
||||||
|
template < class ForwardIterator, class CompareMin,
|
||||||
|
class CompareMax > std::pair< ForwardIterator, ForwardIterator >
|
||||||
|
min_max_element(ForwardIterator first, ForwardIterator last,
|
||||||
|
CompareMin comp_min, CompareMax comp_max);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
\deprecated This function is deprecated. `CGAL::cpp0x::prev` should be used
|
||||||
|
instead.
|
||||||
|
|
||||||
|
The function `predecessor` returns the previous iterator,
|
||||||
|
i.e. the result of `operator--` on a bidirectional iterator.
|
||||||
|
|
||||||
|
\sa `CGAL::successor`
|
||||||
|
|
||||||
|
\returns `--it`.
|
||||||
|
*/
|
||||||
|
template <class BidirectionalIterator>
|
||||||
|
BidirectionalIterator predecessor(BidirectionalIterator it);
|
||||||
|
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
\deprecated This function is deprecated. `CGAL::cpp0x::next` should be used
|
||||||
|
instead.
|
||||||
|
|
||||||
|
The function `successor` returns the next iterator, i.e.
|
||||||
|
the result of `operator++` on a forward iterator.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\sa `CGAL::predecessor`
|
||||||
|
|
||||||
|
\returns `++it`.
|
||||||
|
*/
|
||||||
|
template <class ForwardIterator>
|
||||||
|
ForwardIterator successor(ForwardIterator it);
|
||||||
|
|
||||||
|
namespace cpp0x {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
The function returns the result of `operator++` on a
|
||||||
|
ForwardIterator. The exact behaviour is described in \f$ \mathsection 24.4.4 \f$
|
||||||
|
of the C++ standard draft
|
||||||
|
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf">N3242</a>.
|
||||||
|
|
||||||
|
\note There is actually no function in namespace `CGAL::cpp0x` with this
|
||||||
|
name, but a using declaration which imports a function from another
|
||||||
|
namespace. By order of priority: the one in namespace `std` is used
|
||||||
|
(provided by C++0x), if not found, then the one in namespace `boost`
|
||||||
|
is used.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\sa <a href="http://www.boost.org/doc/libs/1_46_1/libs/utility/utility.htm#functions_next_prior">boost::next</a>
|
||||||
|
\sa CGAL::cpp0x::prev
|
||||||
|
|
||||||
|
*/
|
||||||
|
template <typename ForwardIterator>
|
||||||
|
Iterator next(ForwardIterator it);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
The function returns the result of `operator--` on
|
||||||
|
a BidirectionalIterator. The exact behaviour is described in
|
||||||
|
\f$\mathsection 24.4.4\f$ of the C++ standard draft
|
||||||
|
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf">N3242</a>.
|
||||||
|
|
||||||
|
\note If C++0x is available the function `std::prev` is imported into
|
||||||
|
the namespace `CGAL::cpp0x`, otherwise `CGAL::cpp0x::prev` is declared with the
|
||||||
|
signature as given in \f$\mathsection 24.4.4\f$ of the ISO C++ Standard
|
||||||
|
and forwarded to `boost::prior`.
|
||||||
|
*/
|
||||||
|
template <typename BidirectionalIterator>
|
||||||
|
Iterator prev(BidirectionalIterator it);
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLAlgos
|
||||||
|
|
||||||
|
The function `copy_n` copies `n` items from an
|
||||||
|
input iterator to an output iterator. Its exact behaviour is defined
|
||||||
|
in \f$\mathsection 25.3.1\f$ of the C++ standard draft
|
||||||
|
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf">N3242</a>.
|
||||||
|
|
||||||
|
\note This provides an implementation of the standard function
|
||||||
|
`copy_n` from the C++0x standard. If `copy_n` is available
|
||||||
|
in the `std::` namespace a using declaration is used, otherwise
|
||||||
|
an alternative implementation from \cgal is used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template< class InputIterator, class Size, class OutputIterator>
|
||||||
|
OutputIterator copy_n(InputIterator first, Size count, OutputIterator result);
|
||||||
|
|
||||||
|
} /* namespace cpp11 */
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
namespace cpp11 {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
An object of the class `cpp11::array` represents an array of elements
|
||||||
|
of type `T`, the number of which is specified by the second template argument.
|
||||||
|
|
||||||
|
There is actually no class in namespace `CGAL::cpp11` with this name, but a using declaration which
|
||||||
|
imports a class from another namespace. By order of priority: the one in namespace
|
||||||
|
`std` is used (provided by C++0x), if not found, then the one in namespace
|
||||||
|
`std::tr1` is used (provided by TR1), and finally, the fallback solution
|
||||||
|
is taken from Boost.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The parameter `T` is the value type. The second parameter is the
|
||||||
|
dimension of the array.
|
||||||
|
|
||||||
|
Construction functions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The array class does not provide a constructor which can be used to initialize
|
||||||
|
data members. \cgal therefore provides a `make_array` function for
|
||||||
|
this purpose, up to a certain number of arguments.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T, int >
|
||||||
|
class array {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end cpp11::array */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\relates cpp11::array
|
||||||
|
returns an array of dimension 1 whose first element is `a`.
|
||||||
|
*/
|
||||||
|
template <class T> array<T, 1> make_array(const T& a);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\relates cpp11::array
|
||||||
|
returns an array of dimension 2 whose first element is `a1`
|
||||||
|
and second element is `a2`.
|
||||||
|
*/
|
||||||
|
template <class T> array<T, 2> make_array(const T& a1, const T& a2);
|
||||||
|
|
||||||
|
} /* end namespace cpp11 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,836 @@
|
||||||
|
/// \defgroup STLIterators Iterators and Iterator/Circulator Adaptors
|
||||||
|
/// \ingroup PkgStlExtension
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
The class `Const_oneset_iterator` defines an
|
||||||
|
`RandomAccessIterator` that always refers to a copy of a
|
||||||
|
specific object of type `T`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::RandomAccessIterator
|
||||||
|
|
||||||
|
\sa `CGAL::Emptyset_iterator`
|
||||||
|
\sa `CGAL::Oneset_iterator`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Const_oneset_iterator {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
creates an iterator that always refers to some copy of
|
||||||
|
`t`. The copy is constructed by invoking `T`'s copy
|
||||||
|
constructor and remains constant during \f$ i\f$'s
|
||||||
|
lifetime.
|
||||||
|
*/
|
||||||
|
Const_oneset_iterator(T&
|
||||||
|
t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Const_oneset_iterator */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
The iterator adaptor `Counting_iterator` adds a
|
||||||
|
counter to the internal iterator of type `Iterator` and defines
|
||||||
|
equality of two instances in terms of this counter. It can be used
|
||||||
|
to create finite sequences of possibly infinite sequences of values
|
||||||
|
from input iterators.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::InputIterator
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`Iterator` is a model for
|
||||||
|
`InputIterator`.
|
||||||
|
|
||||||
|
\sa `CGAL::copy_n`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Iterator, typename Value >
|
||||||
|
class Counting_iterator {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
initializes
|
||||||
|
the internal counter to \f$ n\f$ and `i` has a singular value.
|
||||||
|
*/
|
||||||
|
Counting_iterator( std::size_t n = 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
initializes the internal counter to \f$ n\f$ and `i` to \f$ j\f$.
|
||||||
|
*/
|
||||||
|
Counting_iterator( Iterator j, std::size_t n = 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Counting_iterator */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Dispatch_or_drop_output_iterator` defines an
|
||||||
|
`OutputIterator` that contains a tuple of output iterators, and dispatches
|
||||||
|
among those based on the type of the value type which is put in it.
|
||||||
|
Other types are also accepted, and the object is simply discarded in this case.
|
||||||
|
It also inherits from `O`, which makes it easy to treat like a tuple.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`V` must be a `CGAL::cpp0x::tuple<...>` of the types of values to be accepted and dispatched.
|
||||||
|
`O` must be a `CGAL::cpp0x::tuple<...>` of the types of corresponding output iterators.
|
||||||
|
|
||||||
|
\models ::OutputIterator
|
||||||
|
|
||||||
|
\sa `CGAL::Dispatch_output_iterator<V,O>`
|
||||||
|
*/
|
||||||
|
template< typename V, typename O >
|
||||||
|
class Dispatch_or_drop_output_iterator : public O {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef V Value_type_tuple;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef O Iterator_tuple;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Constructor taking all the output iterators.
|
||||||
|
*/
|
||||||
|
Dispatch_or_drop_output_iterator(I...o);
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a reference to the tuple of output iterators.
|
||||||
|
*/
|
||||||
|
const Iterator_tuple& get_iterator_tuple() const;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Dispatch_or_drop_output_iterator */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\returns a `Dispatch_or_drop_output_iterator` constructed from the arguments.
|
||||||
|
\relates Dispatch_or_drop_output_iterator
|
||||||
|
*/
|
||||||
|
template < typename... V, typename... O>
|
||||||
|
Dispatch_or_drop_output_iterator<tuple<V...>, tuple<O...> >
|
||||||
|
dispatch_or_drop_output(O... o);
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Dispatch_output_iterator` defines an
|
||||||
|
`OutputIterator` that contains a tuple of output iterators, and dispatches
|
||||||
|
among those based on the type of the value type which is put in it.
|
||||||
|
It also inherits from `O`, which makes it easy to treat like a tuple.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`V` must be a `CGAL::cpp0x::tuple<...>` of the types of values to be accepted and dispatched.
|
||||||
|
`O` must be a `CGAL::cpp0x::tuple<...>` of the types of corresponding output iterators.
|
||||||
|
|
||||||
|
\models ::OutputIterator
|
||||||
|
|
||||||
|
\sa `CGAL::Dispatch_or_drop_output_iterator<V,O>`
|
||||||
|
*/
|
||||||
|
template< typename V, typename O >
|
||||||
|
class Dispatch_output_iterator : public O {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef V Value_type_tuple;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef O Iterator_tuple;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Constructor taking all the output iterators.
|
||||||
|
*/
|
||||||
|
Dispatch_output_iterator(I...o);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a reference to the tuple of output iterators.
|
||||||
|
*/
|
||||||
|
const Iterator_tuple& get_iterator_tuple() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Dispatch_output_iterator */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\returns a `Dispatch_output_iterator` constructed from the arguments.
|
||||||
|
\relates Dispatch_output_iterator
|
||||||
|
*/
|
||||||
|
template < typename... V, typename... O>
|
||||||
|
Dispatch_output_iterator<tuple<V...>, tuple<O...> >
|
||||||
|
dispatch_output(O... o);
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
The class `Emptyset_iterator` defines an
|
||||||
|
`OutputIterator` that ignores everything written to it. One can
|
||||||
|
think of it as being connected to <TT>/dev/null</TT>.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::OutputIterator
|
||||||
|
|
||||||
|
\sa `CGAL::Oneset_iterator`
|
||||||
|
\sa `CGAL::Const_oneset_iterator`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Emptyset_iterator {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
default constructor.
|
||||||
|
*/
|
||||||
|
Emptyset_iterator();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Emptyset_iterator */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
Constructs `Filter_iterator<Iterator, Predicate>(e, p, c)`.
|
||||||
|
\relates Filter_iterator
|
||||||
|
*/
|
||||||
|
template < class Iterator, class Predicate >
|
||||||
|
inline Filter_iterator< Iterator, Predicate >
|
||||||
|
filter_iterator(Iterator e, const Predicate& p, Iterator c = e);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The iterator adaptor `Filter_iterator` acts as a
|
||||||
|
filter on a given range. Whenever the iterator is in- or
|
||||||
|
decremented, it ignores all iterators for which the given
|
||||||
|
`Predicate` is true. The iterator category is the same as for
|
||||||
|
`Iterator`.
|
||||||
|
|
||||||
|
\note Boost also provides the same functionality via the
|
||||||
|
`boost::filter_iterator` class. Unfortunately, the semantics
|
||||||
|
chosen for accepting or rejecting elements based on the predicate's
|
||||||
|
result are opposite as the semantic chosen here. What is more, the
|
||||||
|
argument of the predicate is different: the predicate used with
|
||||||
|
`boost::filter_iterator` must take the value type of the iterator, as
|
||||||
|
argument, and not the iterator itself.
|
||||||
|
|
||||||
|
|
||||||
|
\tparam Iterator must be a model of `ForwardIterator`
|
||||||
|
\tparam Predicate must be a functor `Iterator` \f$ \rightarrow\f$ `bool`
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Iterator, typename Predicate >
|
||||||
|
class Filter_iterator {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
Filter_iterator();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
creates an iterator which filters values according to `p`.
|
||||||
|
Initializes by taking the first valid iterator (according to `p`),
|
||||||
|
starting at `c`, and stopping at `e` if none is found.
|
||||||
|
*/
|
||||||
|
Filter_iterator(Iterator e, Predicate p, Iterator c = e);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Filter_iterator */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructs `Insert_iterator<Container>(x)`.
|
||||||
|
\relates Insert_iterator
|
||||||
|
*/
|
||||||
|
template < class Container >
|
||||||
|
Insert_iterator<Container>
|
||||||
|
inserter(Container &x);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The output iterator `Insert_iterator` is similar
|
||||||
|
to `std::insert_iterator`, but differs in that it calls the
|
||||||
|
`insert()` function of the container without the iterator
|
||||||
|
additional argument.
|
||||||
|
|
||||||
|
\models ::OutputIterator
|
||||||
|
|
||||||
|
\require `Container` provides a member function `insert(const Container::const_reference&)`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Container >
|
||||||
|
class Insert_iterator {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
initializes
|
||||||
|
the internal container reference to \f$ c\f$.
|
||||||
|
*/
|
||||||
|
Insert_iterator( Container &c );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Insert_iterator */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Inverse_index` constructs an inverse
|
||||||
|
index for a given range [\f$ i,j\f$) of two iterators or circulators of
|
||||||
|
type `IC`. The first element \f$ I\f$ in the range [\f$ i,j\f$) has the
|
||||||
|
index 0. Consecutive elements are numbered incrementally. The
|
||||||
|
inverse index provides a query for a given iterator or circulator
|
||||||
|
\f$ k\f$ to retrieve its index number. <I>Precondition:</I>/ The iterator
|
||||||
|
or circulator must be either of the random access category or the
|
||||||
|
dereference operator must return stable and distinguishable
|
||||||
|
addresses for the values, e.g. proxies or non-modifiable iterator
|
||||||
|
with opaque values will not work.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Implementation
|
||||||
|
--------------
|
||||||
|
|
||||||
|
For random access iterators or circulators, it is done in constant
|
||||||
|
time by subtracting \f$ i\f$. For other iterator categories, an \stl
|
||||||
|
`map` is used, which results in a \f$ \log j-i\f$ query time. The
|
||||||
|
comparisons are done using the operator `operator<` on pointers.
|
||||||
|
|
||||||
|
\sa `CGAL::Random_access_adaptor<IC>`
|
||||||
|
\sa `CGAL::Random_access_value_adaptor<IC,T>`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename IC >
|
||||||
|
class Inverse_index {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
invalid index.
|
||||||
|
*/
|
||||||
|
Inverse_index();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
empty inverse
|
||||||
|
index initialized to start at \f$ i\f$.
|
||||||
|
*/
|
||||||
|
Inverse_index( const IC& i);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
inverse index initialized with range [\f$ i,j\f$).
|
||||||
|
*/
|
||||||
|
Inverse_index( const IC& i, const IC& j);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns inverse
|
||||||
|
index of \f$ k\f$. \pre \f$k\f$ has been stored in the inverse
|
||||||
|
index.
|
||||||
|
*/
|
||||||
|
std::size_t operator[]( const IC& k);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
adds \f$ k\f$ at the end of the
|
||||||
|
indices.
|
||||||
|
*/
|
||||||
|
void push_back( const IC& k);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Inverse_index */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Join_input_iterator_1` joins an iterator and a creator
|
||||||
|
function object. The result is again an iterator (of the same
|
||||||
|
iterator category type as the original iterator) that reads an object
|
||||||
|
from the stream and applies a creator function object to that
|
||||||
|
object.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::InputIterator
|
||||||
|
|
||||||
|
\sa `CGAL::Creator_1<Arg, Result>`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename Iterator, typename Creator >
|
||||||
|
class Join_input_iterator_1 {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
typedef to `Creator::result_type`.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type value_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
creates a join iterator from the given iterator \f$ i\f$
|
||||||
|
and the functor `creator`. Applies `creator` to each item
|
||||||
|
read from \f$ i\f$.
|
||||||
|
*/
|
||||||
|
Join_input_iterator_1( Iterator i, const Creator&
|
||||||
|
creator);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
creates a join
|
||||||
|
iterator from the given iterator \f$ i\f$ and a default constructed
|
||||||
|
instance of `Creator`. The latter instance is applied to each
|
||||||
|
item read from \f$ i\f$.
|
||||||
|
*/
|
||||||
|
Join_input_iterator_1( Iterator i);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Join_input_iterator_1 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The adaptor `N_step_adaptor` changes the step width of the
|
||||||
|
iterator or circulator class `I` to \f$ N\f$. It is itself an
|
||||||
|
iterator or circulator respectively. The behavior is undefined if
|
||||||
|
the adaptor is used on a range [\f$ i,j\f$) where \f$ j-i\f$ is not a multiple
|
||||||
|
of \f$ n\f$.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename I, typename int N >
|
||||||
|
class N_step_adaptor {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
down cast.
|
||||||
|
*/
|
||||||
|
N_step_adaptor(const I& j);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end N_step_adaptor */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Oneset_iterator` defines an
|
||||||
|
`BidirectionalIterator` that always refers to one specific
|
||||||
|
object of type `T`. Internally, `Oneset_iterator` stores a
|
||||||
|
pointer to the referred object.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\models ::BidirectionalIterator
|
||||||
|
|
||||||
|
\sa `CGAL::Emptyset_iterator`
|
||||||
|
\sa `CGAL::Const_oneset_iterator`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
class Oneset_iterator {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
creates
|
||||||
|
an iterator referring to `t`.
|
||||||
|
*/
|
||||||
|
Oneset_iterator(T& t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Oneset_iterator */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Random_access_adaptor` provides a random
|
||||||
|
access for data structures. Either the data structure supports
|
||||||
|
random access iterators or circulators where this class maps
|
||||||
|
function calls to the iterator or circulator, or a \stl
|
||||||
|
`std::vector` is used to provide the random access. The iterator
|
||||||
|
or circulator of the data structure are of type `IC`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\sa `CGAL::Inverse_index<IC>`
|
||||||
|
\sa `CGAL::Random_access_value_adaptor<IC,T>`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename IC >
|
||||||
|
class Random_access_adaptor {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
size type of the \stl `std::vector`.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type size_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
invalid index.
|
||||||
|
*/
|
||||||
|
Random_access_adaptor();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
empty random
|
||||||
|
access index initialized to start at \f$ i\f$.
|
||||||
|
*/
|
||||||
|
Random_access_adaptor( const IC& i);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
random access index initialized to the range [\f$ i,j\f$).
|
||||||
|
*/
|
||||||
|
Random_access_adaptor( const IC& i, const IC& j);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
reserve \f$ r\f$ entries, if a
|
||||||
|
`std::vector` is used internally.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
reserve( size_type r);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns iterator or
|
||||||
|
circulator to the \f$ n\f$-th item. \pre \f$n <\f$ number of items
|
||||||
|
in `random_access`.
|
||||||
|
*/
|
||||||
|
IC operator[]( size_type n);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
adds \f$ k\f$ at the end of the
|
||||||
|
indices.
|
||||||
|
*/
|
||||||
|
void push_back( const IC& k);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Random_access_adaptor */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup STLIterators
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The class `Random_access_value_adaptor` provides a random
|
||||||
|
access for data structures. It is derived from
|
||||||
|
`Random_access_adaptor<IC>`. Instead of returning iterators from
|
||||||
|
the `operator[]` methods, it returns the dereferenced value of
|
||||||
|
the iterator. The iterator or circulator of the data structure are
|
||||||
|
of type `IC`. Their value type is \f$ T\f$.
|
||||||
|
|
||||||
|
\sa `CGAL::Inverse_index<IC>`
|
||||||
|
\sa `CGAL::Random_access_adaptor<IC>`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename IC, typename T >
|
||||||
|
class Random_access_value_adaptor {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// Creation and operations see `Random_access_adaptor<IC>`, with
|
||||||
|
/// the exception of:
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
returns a reference to the
|
||||||
|
\f$ n\f$-th item. \pre \f$n <\f$ number of items in `random_access`.
|
||||||
|
*/
|
||||||
|
T& operator[]( size_type n);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Random_access_value_adaptor */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
Depending on `bool value` the class `Boolean_tag` indicates that
|
||||||
|
something is `true` or `false` respectively.
|
||||||
|
|
||||||
|
\sa `CGAL::Tag_true`
|
||||||
|
\sa `CGAL::Tag_false`
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename bool value >
|
||||||
|
class Boolean_tag {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Constants
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
static const bool value;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Boolean_tag */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
The typedef `Tag_false` is `Boolean_tag<false>`.
|
||||||
|
It is used to indicate, for example,
|
||||||
|
that a certain feature is not available in a class.
|
||||||
|
|
||||||
|
\sa `CGAL::Boolean_tag<bool value>`
|
||||||
|
\sa `CGAL::Tag_true`
|
||||||
|
*/
|
||||||
|
class Tag_false {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Definition
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
is `false`
|
||||||
|
*/
|
||||||
|
static const bool value;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Tag_false */
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
The typedef `Tag_true` is `Boolean_tag<true>`.
|
||||||
|
It is used to indicate, for example,
|
||||||
|
that a certain feature is available in a class.
|
||||||
|
|
||||||
|
\sa `CGAL::Boolean_tag<bool value>`
|
||||||
|
\sa `CGAL::Tag_false`
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
class Tag_true {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Definition
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
is `true`
|
||||||
|
*/
|
||||||
|
static const bool value;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
}; /* end Tag_true */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
Class indicating the absence of a functor.
|
||||||
|
\models ::DefaultConstructible
|
||||||
|
|
||||||
|
\sa `AlgebraicStructureTraits`
|
||||||
|
\sa `RealEmbeddableTraits`
|
||||||
|
*/
|
||||||
|
struct Null_functor {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
General tag indicating that non of any other possible tags is valid.
|
||||||
|
|
||||||
|
\models ::DefaultConstructible
|
||||||
|
|
||||||
|
\sa `AlgebraicStructureTraits`
|
||||||
|
|
||||||
|
*/
|
||||||
|
class Null_tag {
|
||||||
|
public:
|
||||||
|
}; /* end Null_tag */
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
namespace cpp11 {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
An object of the class `cpp11::tuple` represents a heterogeneous tuple of elements
|
||||||
|
of the types specified in parameters, which are in variadic number.
|
||||||
|
|
||||||
|
There is actually no class in namespace `CGAL::cpp11` with this name, but a using declaration which
|
||||||
|
imports a class from another namespace. By order of priority: the one in namespace
|
||||||
|
`std` is used (provided by C++0x), if not found, then the one in namespace
|
||||||
|
`std::tr1` is used (provided by TR1), and finally, the fallback solution
|
||||||
|
is taken from Boost.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
--------------
|
||||||
|
|
||||||
|
The parameters `...` are the value types.
|
||||||
|
|
||||||
|
Free functions and helper classes
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Some free functions part of the standard interface of `tuple` are also
|
||||||
|
brought in namespace `CGAL::cpp11` with using declarations, these are `make_tuple`,
|
||||||
|
`get`, `tie`. Like in C++0x, the `get` function template is
|
||||||
|
specialized so that it can take `std::pair` as argument.
|
||||||
|
Two standard helper classes are also provided for convenience (`tuple_size` and `tuple_element`).
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename ... >
|
||||||
|
class tuple {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end cpp11::tuple */
|
||||||
|
} /* end namespace cpp11 */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,428 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
The Quadruple class is an extension of
|
||||||
|
`std::pair`. `Quadruple` is a heterogeneous quadruple: it holds
|
||||||
|
one object of type `T1`, one of type `T2`, one of type
|
||||||
|
`T3`, and one of type `T4`. A `Quadruple` is much like a
|
||||||
|
container, in that it ``owns'' its elements. It is not actually a
|
||||||
|
model of container, though, because it does not support the standard
|
||||||
|
methods (such as iterators) for accessing the elements of a
|
||||||
|
container.
|
||||||
|
|
||||||
|
`CGAL::cpp0x::tuple` or `CGAL::cpp0x::array` instead for new uses.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`T1`, `T2`, `T3` and `T4` must be
|
||||||
|
`Assignable`. Additional operations have additional requirements.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T1, typename T2, typename T3, typename T4 >
|
||||||
|
class Quadruple {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T1 first_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T2 second_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T3 third_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T4 fourth_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
first element. Please access it using `get<0>()`.
|
||||||
|
*/
|
||||||
|
T1 first;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
second element. Please access it using `get<1>()`.
|
||||||
|
*/
|
||||||
|
T2 second;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
third element. Please access it using `get<2>()`.
|
||||||
|
*/
|
||||||
|
T3 third;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
fourth element. Please access it using `get<3>()`.
|
||||||
|
*/
|
||||||
|
T4 fourth;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a quadruple using the
|
||||||
|
default constructor of the four elements.
|
||||||
|
*/
|
||||||
|
Quadruple();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a
|
||||||
|
quadruple such that `first` is constructed from `x`,
|
||||||
|
`second` is constructed from `y`, `third` is
|
||||||
|
constructed from `z`, and `fourth` is constructed from
|
||||||
|
`w`.
|
||||||
|
*/
|
||||||
|
Quadruple(T1 x, T2 y, T3 z, T4 w);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a quadruple such that
|
||||||
|
`first` is constructed from `u`, `second` is
|
||||||
|
constructed from `v`, `third` is constructed from `w`,
|
||||||
|
and `fourth` is constructed from `x`. \require Proper conversion operators exist from `U` to `T1`, `V` to `T2`, `W` to `T3`, and `X` to `T4`.
|
||||||
|
*/
|
||||||
|
template <class U, class V, class W, class X>
|
||||||
|
Quadruple(U u, V v, W w, X x);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Gives access to `first`, `second`, `third` or `fourth`
|
||||||
|
whenever `i` is 0, 1, 2 or 3, via a, potentially const, reference.
|
||||||
|
Note: `T` stands for `T1`, `T2`, `T3` or `T4`
|
||||||
|
depending on `i`.
|
||||||
|
*/
|
||||||
|
template <int i> T get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The comparison operator. It uses lexicographic comparison:
|
||||||
|
the return value is true if the first element of `x` is less
|
||||||
|
than the first element of `y`, and false if the first element
|
||||||
|
of `y` is less than the first element of `x`. If neither
|
||||||
|
of these is the case, then it returns true if the second element
|
||||||
|
of `x` is less than the second element of `y`, and false
|
||||||
|
if the second element of `y` is less than the second element
|
||||||
|
of `x`. If neither of these is the case, then it returns true
|
||||||
|
if the third element of `x` is less than the third element of
|
||||||
|
`y`, and false if the third element of `y` is less than
|
||||||
|
the third element of `x`. If neither of these is the case,
|
||||||
|
then it returns the result of comparing the fourth elements of
|
||||||
|
`x` and `y`. This operator may only be used if `T1`,
|
||||||
|
`T2`, `T3`, and `T4` define the comparison operator.
|
||||||
|
*/
|
||||||
|
template <class T1, class T2, class T3, class T4> bool
|
||||||
|
operator<(Quadruple<T1, T2, T3, T4> x, Quadruple<T1, T2, T3, T4>
|
||||||
|
y);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The equality operator. The return value is true if and only
|
||||||
|
the first elements of `x` and `y` are equal, the second
|
||||||
|
elements of `x` and `y` are equal, the third elements of
|
||||||
|
`x` and `y` are equal, and the fourth elements of `x`
|
||||||
|
and `y` are equal. This operator may only be used if
|
||||||
|
`T1`, `T2`, `T3`, and `T4` define the equality
|
||||||
|
operator.
|
||||||
|
*/
|
||||||
|
template <class T1, class T2, class T3, class T4> bool
|
||||||
|
operator==(Quadruple<T1, T2, T3, T4> x, Quadruple<T1, T2, T3, T4>
|
||||||
|
y);
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Quadruple */
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtension
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The Triple class is an extension of `std::pair`.
|
||||||
|
`Triple` is a heterogeneous triple: it holds one object of type
|
||||||
|
`T1`, one of type `T2`, and one of type `T3`. A
|
||||||
|
`Triple` is much like a container, in that it "owns" its
|
||||||
|
elements. It is not actually a model of container, though, because
|
||||||
|
it does not support the standard methods (such as iterators) for
|
||||||
|
accessing the elements of a container.
|
||||||
|
|
||||||
|
`CGAL::cpp0x::tuple` or `CGAL::cpp0x::array` instead for new uses.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
--------------
|
||||||
|
|
||||||
|
`T1`, `T2` and `T3` must be `Assignable`.
|
||||||
|
Additional operations have additional requirements.
|
||||||
|
|
||||||
|
*/
|
||||||
|
template< typename T1, typename T2, typename T3 >
|
||||||
|
class Triple {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T1 first_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T2 second_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Types
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
typedef T3 third_type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
first element. Please access it using `get<0>()`.
|
||||||
|
*/
|
||||||
|
T1 first;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
second element. Please access it using `get<1>()`.
|
||||||
|
*/
|
||||||
|
T2 second;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Variables
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
third element. Please access it using `get<2>()`.
|
||||||
|
*/
|
||||||
|
T3 third;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
introduces a triple using the default
|
||||||
|
constructor of the three elements.
|
||||||
|
*/
|
||||||
|
Triple();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a triple such
|
||||||
|
that `first` is constructed from `x`, `second` is
|
||||||
|
constructed from `y`, and `third` is constructed from
|
||||||
|
`z`.
|
||||||
|
*/
|
||||||
|
Triple(T1 x, T2 y, T3 z);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
constructs a triple such that `first` is constructed
|
||||||
|
from `u`, `second` is constructed from `v`, and
|
||||||
|
`third` is constructed from `w`. \require Proper conversion operators exist from `U` to `T1`, `V` to `T2`, and `W` to `T3`.
|
||||||
|
*/
|
||||||
|
template <class U, class V, class W> Triple(U u, V v,
|
||||||
|
W w);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
Gives access to `first`, `second` or `third` whenever
|
||||||
|
`i` is 0, 1 or 2, via a, potentially const, reference.
|
||||||
|
Note: `T` stands for `T1`, `T2` or `T3` depending
|
||||||
|
on `i`.
|
||||||
|
*/
|
||||||
|
template <int i> T get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The
|
||||||
|
comparison operator. It uses lexicographic comparison: the return
|
||||||
|
value is true if the first element of `x` is less than the
|
||||||
|
first element of `y`, and false if the first element of
|
||||||
|
`y` is less than the first element of `x`. If neither of
|
||||||
|
these is the case, then it returns true if the second element of
|
||||||
|
`x` is less than the second element of `y`, and false if
|
||||||
|
the second element of `y` is less than the second element of
|
||||||
|
`x`. If neither of these is the case, then it returns the
|
||||||
|
result of comparing the third elements of `x` and `y`.
|
||||||
|
This operator may only be used if `T1`, `T2` and `T3`
|
||||||
|
define the comparison operator.
|
||||||
|
*/
|
||||||
|
template <class T1, class T2, class T3> bool
|
||||||
|
operator<(Triple<T1, T2, T3> x, Triple<T1, T2, T3> y);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
The
|
||||||
|
equality operator. The return value is true if and only the first
|
||||||
|
elements of `x` and `y` are equal, the second elements of
|
||||||
|
`x` and `y` are equal, and the third elements of `x`
|
||||||
|
and `y` are equal. This operator may only be used if
|
||||||
|
`T1`, `T2` and `T3` define the equality operator.
|
||||||
|
*/
|
||||||
|
template <class T1, class T2, class T3> bool
|
||||||
|
operator==(Triple<T1, T2, T3> x, Triple<T1, T2, T3> y);
|
||||||
|
|
||||||
|
}; /* end Triple */
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Equivalent to `Quadruple<T1, T2, T3, T4>(x, y, z, w)`.
|
||||||
|
\relates Quadruple
|
||||||
|
*/
|
||||||
|
template <class T1, class T2, class T3, class T4>
|
||||||
|
Quadruple<T1, T2, T3, T4> make_quadruple(T1 x, T2 y, T3 z, T4 w);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Equivalent to `Quadruple<T1, T2, T3, T4>(x, y, z, w)`.
|
||||||
|
\relates Quadruple
|
||||||
|
*/
|
||||||
|
template <class T1, class T2, class T3, class T4>
|
||||||
|
Quadruple<T1, T2, T3, T4> make_tuple(T1 x, T2 y, T3 z, T4 w);
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup PkgStlExtensionConcepts
|
||||||
|
\cgalconcept
|
||||||
|
|
||||||
|
\anchor sectionProjectionFunctionObjects
|
||||||
|
|
||||||
|
|
||||||
|
The concept `Projection_object` is modeled after the STL
|
||||||
|
concept `UnaryFunction`, but takes also care of (const)
|
||||||
|
references.
|
||||||
|
|
||||||
|
\hasModel CGAL::Identity
|
||||||
|
\hasModel CGAL::Dereference
|
||||||
|
\hasModel CGAL::Get_address
|
||||||
|
\hasModel CGAL::Cast_function_object
|
||||||
|
\hasModel CGAL::Project_vertex
|
||||||
|
\hasModel CGAL::Project_facet
|
||||||
|
\hasModel CGAL::Project_point
|
||||||
|
\hasModel CGAL::Project_normal
|
||||||
|
\hasModel CGAL::Project_plane
|
||||||
|
\hasModel CGAL::Project_next
|
||||||
|
\hasModel CGAL::Project_prev
|
||||||
|
\hasModel CGAL::Project_next_opposite
|
||||||
|
\hasModel CGAL::Project_opposite_prev
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Projection_object {
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Definition
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
argument type.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type argument_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Definition
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
result type.
|
||||||
|
*/
|
||||||
|
typedef Hidden_type result_type;
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// \name Creation
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
default constructor.
|
||||||
|
*/
|
||||||
|
Projection_object();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
result_type& operator()(argument_type &) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
/// \name Operations
|
||||||
|
/// @{
|
||||||
|
/*!
|
||||||
|
|
||||||
|
*/
|
||||||
|
const result_type& operator()(const argument_type &) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}; /* end Projection_object */
|
||||||
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
/// \defgroup PkgStlExtension STL Extensions for CGAL
|
||||||
|
|
||||||
|
/// \defgroup PkgStlExtensionConcepts Concepts
|
||||||
|
/// \ingroup PkgStlExtension
|
||||||
|
/*!
|
||||||
|
\addtogroup PkgStlExtension
|
||||||
|
<table cellpadding="2" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td rowspan="2">\image html plusplus.png "" </td>
|
||||||
|
<td>
|
||||||
|
\par Michael Hoffmann, Lutz Kettner, Sylvain Pion, and Ron Wein
|
||||||
|
\par"" \cgal is designed in the spirit of the generic programming paradigm to work together with the Standard Template Library (\stl). This package provides non-geometric \stl-like algorithms and datastructures that are not provided in the \stl standard but in \cgal
|
||||||
|
|
||||||
|
\since \cgal 1.0
|
||||||
|
|
||||||
|
\cgalbib{ cgal:hkpw-se-12 }
|
||||||
|
|
||||||
|
\license{ \ref licensesLGPL LGPL }
|
||||||
|
\par Resources:
|
||||||
|
\ref stl_ext_user "User Manual"
|
||||||
|
</td>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
/*!
|
||||||
|
|
||||||
|
\page stl_ext_user STL Extensions for CGAL
|
||||||
|
\author Michael Hoffmann, Lutz Kettner, Sylvain Pion, and Ron Wein
|
||||||
|
|
||||||
|
\cgal is designed in the spirit of the generic programming paradigm
|
||||||
|
to work together with the Standard Template Library (\stl)
|
||||||
|
\cite cgal:ansi-is14882-98,cgal:a-gps-98. This chapter documents non-geometric
|
||||||
|
\stl-like components that are not provided in the \stl standard but
|
||||||
|
in \cgal: a doubly-connected list managing items in place (where
|
||||||
|
inserted items are not copied), a compact container, a multi-set class that
|
||||||
|
uses three-valued comparisons and offers additional functionality,
|
||||||
|
generic algorithms, iterators, functor adaptors for binding and swapping
|
||||||
|
arguments and for composition, functors for projection and creation and
|
||||||
|
adaptor classes around iterators and circulators. See also circulators in
|
||||||
|
Chapter \ref chapterCirculators . A class storing polymorphic objects
|
||||||
|
is also provided, as well as a class to manage the uncertainty of some values.
|
||||||
|
Finally, tags and policy classes to specify complexity trade-offs of data-structures,
|
||||||
|
and a class which helps specifying that the default types in template
|
||||||
|
parameter lists are desired is also provided.
|
||||||
|
|
||||||
|
# Doubly-Connected List Managing Items in Place #
|
||||||
|
|
||||||
|
The class `In_place_list<T,bool>` manages a
|
||||||
|
sequence of items in place in a doubly-connected list. Its goals are
|
||||||
|
the flexible handling of memory management and performance
|
||||||
|
optimization. The item type has to provide the two necessary
|
||||||
|
pointers `&T::next_link` and `&T::prev_link`. One possibility
|
||||||
|
to obtain these pointers is to inherit them from the base class
|
||||||
|
`In_place_list_base<T>`.
|
||||||
|
|
||||||
|
The class `In_place_list<T,bool>` is a container quite similar
|
||||||
|
to \stl containers, with the advantage that it is able to handle the
|
||||||
|
stored elements by reference instead of copying them. It is possible
|
||||||
|
to delete an element only knowing its address and no iterator to it.
|
||||||
|
This used to simplify mutually pointed data structures like a halfedge
|
||||||
|
data structure for planar maps or polyhedral surfaces (the current design
|
||||||
|
does not need this anymore). The usual iterators are also available.
|
||||||
|
|
||||||
|
# Compact Container #
|
||||||
|
|
||||||
|
The class `Compact_container<T, Allocator>` is an \stl like container
|
||||||
|
which provides a very compact storage for its elements. It achieves this goal
|
||||||
|
by requiring `T` to provide access to a pointer in it, which is going to be
|
||||||
|
used by `Compact_container<T, Allocator>` for its internal management.
|
||||||
|
The traits class `Compact_container_traits<T>` specifies the way to
|
||||||
|
access that pointer. The class `Compact_container_base` can be
|
||||||
|
used as a base class to provide the pointer, although in this case you do not
|
||||||
|
get the most compact representation. The values that this pointer can have
|
||||||
|
during valid use of the object are valid pointer values to 4 bytes aligned
|
||||||
|
objects (i.e., the two least significant bits of the pointer need to be zero
|
||||||
|
when the object is constructed). Another interesting property of this
|
||||||
|
container is that iterators are not invalidated during `insert` or
|
||||||
|
`erase` operations.
|
||||||
|
|
||||||
|
The main deviation from the \stl container concept is that the `++` and
|
||||||
|
`--` operators of the iterator do not have a constant time complexity in
|
||||||
|
all cases. The actual complexity is related to the maximum size that the
|
||||||
|
container has had during its life time compared to its current size, because
|
||||||
|
the iterator has to go over the "erased" elements as well, so the bad case is
|
||||||
|
when the container used to contain lots of elements, but now has far less. In
|
||||||
|
this case, we suggest to do a copy of the container in order to "defragment"
|
||||||
|
the internal representation.
|
||||||
|
|
||||||
|
This container has been developed in order to efficiently handle large data
|
||||||
|
structures like the triangulation and halfedge data structures. It can
|
||||||
|
probably be useful for other kinds of graphs as well.
|
||||||
|
|
||||||
|
# Multiset with Extended Functionality #
|
||||||
|
|
||||||
|
The class `Multiset<Type,Compare,Allocator>` represents a
|
||||||
|
multi-set of elements of type `Type`, represented as a red-black tree
|
||||||
|
(see [\cite Chapter 13 for an excellent introduction to red-black
|
||||||
|
trees). It differs from the \stl's `multiset` class-template mainly due
|
||||||
|
to the fact that it is parameterized by a comparison functor `Compare`
|
||||||
|
that returns the three-valued `Comparison_result` (namely it returns
|
||||||
|
either `SMALLER`, `EQUAL`, or `LARGER`), rather than a <I>less</I>
|
||||||
|
functor returning `bool`. Thus, it is possible to maintain
|
||||||
|
the underlying red-black tree with less invocations of the comparison functor,
|
||||||
|
which can considerably decrease running times, especially when comparing
|
||||||
|
elements of type `Type` is an expensive operation.
|
||||||
|
|
||||||
|
`Multiset<Type,Compare,Allocator>` also guarantees that the order of
|
||||||
|
elements sent to the comparison functor is fixed. For example, if we insert
|
||||||
|
a new element `x` into the set (or erase an element from the set), then
|
||||||
|
we always invoke `Compare() (x, y)` (and never `Compare() (y, x)`),
|
||||||
|
where `y` is an element already stored in the set. This behavior, not
|
||||||
|
supported by `std::multiset`, is sometimes crucial for designing more
|
||||||
|
efficient comparison predicates.
|
||||||
|
|
||||||
|
The interface of `Multiset<Type,Compare,Allocator>` is in general
|
||||||
|
derived from `std::multiset`. However, it extends the interface by
|
||||||
|
offering some additional operations, such as: inserting of an element into
|
||||||
|
the set given its <I>exact</I> position (and not just using an insertion hint);
|
||||||
|
looking up keys whose type may differ from `Type`, as long as users supply
|
||||||
|
a comparison functor `CompareKey`, between the keys and set elements;
|
||||||
|
and catenating and splitting sets.
|
||||||
|
|
||||||
|
# Polymorphic Object #
|
||||||
|
|
||||||
|
The class `Object` can store an object of whatever other type.
|
||||||
|
It can be used by a function to return objects of different types.
|
||||||
|
A mechanism to extract the stored object based on its type is also provided.
|
||||||
|
This class is similar to `boost::any`.
|
||||||
|
|
||||||
|
# Uncertainty Management #
|
||||||
|
|
||||||
|
The class `Uncertain<T>` represents a range of values of type `T`.
|
||||||
|
`T` is allowed to stand for `bool`, or \cgal's enumeration types
|
||||||
|
`Sign`, `Comparison_result`, `Orientation`, `Oriented_side`,
|
||||||
|
`Bounded_side` and `Angle`.
|
||||||
|
|
||||||
|
The idea is that sometimes you are not sure of the result of a function,
|
||||||
|
and you would like to communicate that to the caller. `Uncertain<T>`
|
||||||
|
allows just that. It also provides functions to naturally extend the
|
||||||
|
Boolean operations for `Uncertain<bool>` for example.
|
||||||
|
|
||||||
|
`Uncertain<T>` is used in \cgal as the return type of geometric predicates
|
||||||
|
when the number type used is interval arithmetic like `Interval_nt`.
|
||||||
|
End users typically do not see it as it is hidden in the implementation
|
||||||
|
of the filtered predicates provided by the various filtered kernels,
|
||||||
|
but it is important that providers of predicates that are meant to be
|
||||||
|
filtered by `Filtered_predicate`, know about it.
|
||||||
|
|
||||||
|
It can also be used in other contexts as well, as it is a general tool.
|
||||||
|
|
||||||
|
# Complexity tags and policies #
|
||||||
|
|
||||||
|
Some data structures and algorithms can be implemented with different
|
||||||
|
complexity trade-offs between memory usage and time complexity. \cgal provides
|
||||||
|
the tags `Fast` and `Compact` which can be used to select between those
|
||||||
|
variants. For example, the `Location_policy` class is parameterized by
|
||||||
|
these tags and allows to specify the complexity of point location (currently in
|
||||||
|
`Delaunay_triangulation_3` only). Convenient typedefs `Fast_location`
|
||||||
|
and `Compact_location` are also provided.
|
||||||
|
|
||||||
|
# Default Arguments in Template Parameter Lists #
|
||||||
|
|
||||||
|
In \cpp, it is possible to specify defaults at the end of a template parameter
|
||||||
|
list. Specifying that one wishes to use the default is simply done by omitting
|
||||||
|
it. This is however possible only at the end of the list. `CGAL::Default`
|
||||||
|
provides a simple mechanism that performs something equivalent anywhere in the
|
||||||
|
sequence.
|
||||||
|
|
||||||
|
# C++ 11 wrappers #
|
||||||
|
|
||||||
|
Wrappers for the classes `array` and `tuple` which, based on
|
||||||
|
availability, either use the version of <I>Boost</I> or the one
|
||||||
|
provided by the standard library are provided in the namespace
|
||||||
|
`CGAL::cpp11`. The namespace alias `CGAL::cpp0x` is provided
|
||||||
|
for backward compatibility. Those are documented for completeness and
|
||||||
|
implementers. They are not intended to be used by users of the
|
||||||
|
library.
|
||||||
|
|
||||||
|
*/
|
||||||
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 581 B |