mirror of https://github.com/CGAL/cgal
Formatting, ran astyle:
for i in `find . -name "*.h" -or -name "*.cpp"`; do echo $i; astyle -A7 -bps2 $i; done
This commit is contained in:
parent
a980dfc210
commit
d69d0e303b
|
|
@ -1,42 +1,43 @@
|
|||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2MainClasses
|
||||
|
||||
The class `Periodic_2_Delaunay_triangulation_2` represents a
|
||||
Delaunay triangulation in two-dimensional periodic space.
|
||||
The class `Periodic_2_Delaunay_triangulation_2` represents a
|
||||
Delaunay triangulation in two-dimensional periodic space.
|
||||
|
||||
### Parameters ###
|
||||
|
||||
The class `Periodic_2_Delaunay_triangulation_2` has two template parameters. The first one
|
||||
`Traits` is the geometric traits, it is to be instantiated by a
|
||||
model of the concept `Periodic_2DelaunayTriangulationTraits_2`.
|
||||
The class `Periodic_2_Delaunay_triangulation_2` has two template parameters. The first one
|
||||
`Traits` is the geometric traits, it is to be instantiated by a
|
||||
model of the concept `Periodic_2DelaunayTriangulationTraits_2`.
|
||||
|
||||
The second parameter is the triangulation data structure, it has to be
|
||||
instantiated by a model of the concept
|
||||
`TriangulationDataStructure_2` with some additional functionality
|
||||
in faces. By default, the triangulation data structure is instantiated
|
||||
by
|
||||
`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2<Gt>, CGAL::Periodic_2_triangulation_face_base_2<Gt> > >`.
|
||||
The second parameter is the triangulation data structure, it has to be
|
||||
instantiated by a model of the concept
|
||||
`TriangulationDataStructure_2` with some additional functionality
|
||||
in faces. By default, the triangulation data structure is instantiated
|
||||
by
|
||||
`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2<Gt>, CGAL::Periodic_2_triangulation_face_base_2<Gt> > >`.
|
||||
|
||||
### Implementation ###
|
||||
|
||||
Insertion is implemented by inserting in the triangulation, then
|
||||
performing a sequence of Delaunay flips. The number of flips is \f$ O(d)\f$
|
||||
if the new vertex is of degree \f$ d\f$ in the new triangulation. For
|
||||
points distributed uniformly at random, insertion takes time \f$ O(1)\f$ on
|
||||
average.
|
||||
Insertion is implemented by inserting in the triangulation, then
|
||||
performing a sequence of Delaunay flips. The number of flips is \f$ O(d)\f$
|
||||
if the new vertex is of degree \f$ d\f$ in the new triangulation. For
|
||||
points distributed uniformly at random, insertion takes time \f$ O(1)\f$ on
|
||||
average.
|
||||
|
||||
Removal calls the removal in the triangulation and then
|
||||
re-triangulates the hole in such a way that the Delaunay criterion is
|
||||
satisfied. Removal of a vertex of degree \f$ d\f$ takes time \f$ O(d^2)\f$. The
|
||||
expected degree \f$ d\f$ is \f$ O(1)\f$ for a random vertex in the
|
||||
triangulation.
|
||||
Removal calls the removal in the triangulation and then
|
||||
re-triangulates the hole in such a way that the Delaunay criterion is
|
||||
satisfied. Removal of a vertex of degree \f$ d\f$ takes time \f$ O(d^2)\f$. The
|
||||
expected degree \f$ d\f$ is \f$ O(1)\f$ for a random vertex in the
|
||||
triangulation.
|
||||
|
||||
After a point location step, the nearest neighbor is found in time
|
||||
\f$ O(n)\f$ in the worst case, but in expected time \f$ O(1)\f$ on average for
|
||||
vertices distributed uniformly at random and any query point.
|
||||
After a point location step, the nearest neighbor is found in time
|
||||
\f$ O(n)\f$ in the worst case, but in expected time \f$ O(1)\f$ on average for
|
||||
vertices distributed uniformly at random and any query point.
|
||||
|
||||
\sa `CGAL::Periodic_2_triangulation_2<Traits,Tds>`
|
||||
\sa `CGAL::Delaunay_triangulation_2<Traits,Tds>`
|
||||
|
|
@ -46,43 +47,44 @@ vertices distributed uniformly at random and any query point.
|
|||
|
||||
*/
|
||||
template< typename Traits, typename Tds >
|
||||
class Periodic_2_Delaunay_triangulation_2 : public Periodic_2_triangulation_2<Traits,Tds> {
|
||||
class Periodic_2_Delaunay_triangulation_2 : public Periodic_2_triangulation_2<Traits, Tds>
|
||||
{
|
||||
public:
|
||||
|
||||
/// \name Creation
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Creates an empty periodic Delaunay triangulation `dt`, with
|
||||
`domain` as original domain and possibly specifying
|
||||
a traits class `traits`.
|
||||
\pre `domain` is a square.
|
||||
*/
|
||||
Periodic_2_Delaunay_triangulation_2(
|
||||
const Iso_rectangle & domain = Iso_rectangle(0,0,1,1),
|
||||
const Geom_traits & traits = Geom_traits());
|
||||
/*!
|
||||
Creates an empty periodic Delaunay triangulation `dt`, with
|
||||
`domain` as original domain and possibly specifying
|
||||
a traits class `traits`.
|
||||
\pre `domain` is a square.
|
||||
*/
|
||||
Periodic_2_Delaunay_triangulation_2(
|
||||
const Iso_rectangle & domain = Iso_rectangle(0, 0, 1, 1),
|
||||
const Geom_traits & traits = Geom_traits());
|
||||
|
||||
/*!
|
||||
Copy constructor.
|
||||
*/
|
||||
Periodic_2_Delaunay_triangulation_2 (const
|
||||
Periodic_2_Delaunay_triangulation_2 & dt1);
|
||||
/*!
|
||||
Copy constructor.
|
||||
*/
|
||||
Periodic_2_Delaunay_triangulation_2 (const
|
||||
Periodic_2_Delaunay_triangulation_2 & dt1);
|
||||
|
||||
/*!
|
||||
Equivalent to constructing an empty triangulation with the optional
|
||||
domain and traits class arguments and calling `insert(first,last)`.
|
||||
\pre The `value_type` of `first` and `last` are `Point`s lying inside `domain` and `domain` is a square.
|
||||
*/
|
||||
template < class InputIterator >
|
||||
Periodic_2_Delaunay_triangulation_2 (
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
const Iso_rectangle & domain = Iso_rectangle(0,0,1,1),
|
||||
const Geom_traits & traits = Geom_traits());
|
||||
/*!
|
||||
Equivalent to constructing an empty triangulation with the optional
|
||||
domain and traits class arguments and calling `insert(first,last)`.
|
||||
\pre The `value_type` of `first` and `last` are `Point`s lying inside `domain` and `domain` is a square.
|
||||
*/
|
||||
template < class InputIterator >
|
||||
Periodic_2_Delaunay_triangulation_2 (
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
const Iso_rectangle & domain = Iso_rectangle(0, 0, 1, 1),
|
||||
const Geom_traits & traits = Geom_traits());
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Insertion and removal
|
||||
/// \name Insertion and removal
|
||||
/// The following methods insert points in the triangulation ensuring
|
||||
/// the empty circle property of Delaunay triangulations. The inserted
|
||||
/// points need to lie in the original domain (see Section \ref
|
||||
|
|
@ -96,89 +98,89 @@ const Geom_traits & traits = Geom_traits());
|
|||
/// some `Vertex_handle`s and `Face_handle`s.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Inserts point `p` in the triangulation and returns the
|
||||
corresponding vertex. The optional argument `start` is used as a
|
||||
starting place for the point location. \pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle insert(const Point & p, Face_handle start =
|
||||
Face_handle() );
|
||||
/*!
|
||||
Inserts point `p` in the triangulation and returns the
|
||||
corresponding vertex. The optional argument `start` is used as a
|
||||
starting place for the point location. \pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle insert(const Point & p, Face_handle start =
|
||||
Face_handle() );
|
||||
|
||||
/*!
|
||||
Inserts point `p` in the triangulation and returns the
|
||||
corresponding vertex. Similar to the above `insert()` function,
|
||||
but takes as additional parameter the return values of a previous
|
||||
location query. See description of
|
||||
`Periodic_2_triangulation_2::locate()`. \pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle insert(const Point & p, Locate_type lt,
|
||||
Face_handle loc, int li, int lj);
|
||||
/*!
|
||||
Inserts point `p` in the triangulation and returns the
|
||||
corresponding vertex. Similar to the above `insert()` function,
|
||||
but takes as additional parameter the return values of a previous
|
||||
location query. See description of
|
||||
`Periodic_2_triangulation_2::locate()`. \pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle insert(const Point & p, Locate_type lt,
|
||||
Face_handle loc, int li, int lj);
|
||||
|
||||
/*!
|
||||
Equivalent to `insert(p)`.
|
||||
*/
|
||||
Vertex_handle push_back(const Point& p);
|
||||
/*!
|
||||
Equivalent to `insert(p)`.
|
||||
*/
|
||||
Vertex_handle push_back(const Point& p);
|
||||
|
||||
/*!
|
||||
Inserts the points in the iterator range `[first, last)`.
|
||||
Returns the number of inserted points. This function uses spatial
|
||||
sorting (cf. chapter \ref secspatial_sorting) and therefore is
|
||||
not guaranteed to insert the points following the order of
|
||||
`InputIterator`. If the third argument `is_large_point_set`
|
||||
is set to `true` a heuristic for optimizing the insertion of
|
||||
large point sets is applied. \pre The `value_type` of `first` and `last` are `Point`s and all points in the range lie inside `domain`.
|
||||
*/
|
||||
template < class InputIterator > std::ptrdiff_t
|
||||
insert(InputIterator first, InputIterator last, bool
|
||||
is_large_point_set = false);
|
||||
/*!
|
||||
Inserts the points in the iterator range `[first, last)`.
|
||||
Returns the number of inserted points. This function uses spatial
|
||||
sorting (cf. chapter \ref secspatial_sorting) and therefore is
|
||||
not guaranteed to insert the points following the order of
|
||||
`InputIterator`. If the third argument `is_large_point_set`
|
||||
is set to `true` a heuristic for optimizing the insertion of
|
||||
large point sets is applied. \pre The `value_type` of `first` and `last` are `Point`s and all points in the range lie inside `domain`.
|
||||
*/
|
||||
template < class InputIterator > std::ptrdiff_t
|
||||
insert(InputIterator first, InputIterator last, bool
|
||||
is_large_point_set = false);
|
||||
|
||||
/*!
|
||||
Removes the vertex from the triangulation.
|
||||
*/
|
||||
void remove(Vertex_handle v);
|
||||
/*!
|
||||
Removes the vertex from the triangulation.
|
||||
*/
|
||||
void remove(Vertex_handle v);
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Point moving
|
||||
/// \name Point moving
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
if there is not already another vertex placed on `p`, the
|
||||
triangulation is modified such that the new position of vertex
|
||||
`v` is `p`, and `v` is returned. Otherwise, the
|
||||
triangulation is not modified and the vertex at point `p` is
|
||||
returned. \pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle move_if_no_collision(Vertex_handle v, const
|
||||
Point & p);
|
||||
/*!
|
||||
if there is not already another vertex placed on `p`, the
|
||||
triangulation is modified such that the new position of vertex
|
||||
`v` is `p`, and `v` is returned. Otherwise, the
|
||||
triangulation is not modified and the vertex at point `p` is
|
||||
returned. \pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle move_if_no_collision(Vertex_handle v, const
|
||||
Point & p);
|
||||
|
||||
/*!
|
||||
Moves the point stored in `v` to `p`, while preserving the
|
||||
Delaunay property. This performs an action semantically equivalent
|
||||
to `remove(v)` followed by `insert(p)`, but is supposedly
|
||||
faster to performing these two operations separately when the point
|
||||
has not moved much. Returns the handle to the new vertex.
|
||||
\pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle move_point(Vertex_handle v, const Point &
|
||||
p);
|
||||
/*!
|
||||
Moves the point stored in `v` to `p`, while preserving the
|
||||
Delaunay property. This performs an action semantically equivalent
|
||||
to `remove(v)` followed by `insert(p)`, but is supposedly
|
||||
faster to performing these two operations separately when the point
|
||||
has not moved much. Returns the handle to the new vertex.
|
||||
\pre `p` lies in the original domain `domain`.
|
||||
*/
|
||||
Vertex_handle move_point(Vertex_handle v, const Point &
|
||||
p);
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Queries
|
||||
/// \name Queries
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Returns any nearest vertex to the point `p`, or the default constructed
|
||||
handle if the triangulation is empty. The optional argument `f` is a hint
|
||||
specifying where to start the search. It always returns a vertex
|
||||
corresponding to a point inside \f$ \ccc{domain}\f$ even if computing in a
|
||||
multiply sheeted covering space.
|
||||
\pre `f` is a face of `dt` and `p` lies in the original domain `domain`.
|
||||
/*!
|
||||
Returns any nearest vertex to the point `p`, or the default constructed
|
||||
handle if the triangulation is empty. The optional argument `f` is a hint
|
||||
specifying where to start the search. It always returns a vertex
|
||||
corresponding to a point inside \f$ \ccc{domain}\f$ even if computing in a
|
||||
multiply sheeted covering space.
|
||||
\pre `f` is a face of `dt` and `p` lies in the original domain `domain`.
|
||||
|
||||
*/
|
||||
Vertex_handle nearest_vertex(Point p,
|
||||
Face_handle f = Face_handle());
|
||||
*/
|
||||
Vertex_handle nearest_vertex(Point p,
|
||||
Face_handle f = Face_handle());
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
@ -189,119 +191,119 @@ Face_handle f = Face_handle());
|
|||
/// (`p`,`off`) is star-shaped.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
`OutputItFaces` is an output iterator with `Face_handle` as
|
||||
value type. `OutputItBoundaryEdges` stands for an output
|
||||
iterator with `Edge` as value type. This members function
|
||||
outputs in the container pointed to by `fit` the faces which are
|
||||
in conflict with point `p` i. e. the faces whose circumcircle
|
||||
contains `p`. It outputs in the container pointed to by
|
||||
`eit` the boundary of the zone in conflict with `p`.
|
||||
The boundary edges of the conflict zone are output in
|
||||
counter-clockwise order and each edge is described through its
|
||||
incident face which is not in conflict with `p`. The function
|
||||
returns in a std::pair the resulting output
|
||||
iterators. \pre `start` is in conflict with `p` and `p` lies in the original domain `domain`.
|
||||
*/
|
||||
template <class OutputItFaces, class OutputItBoundaryEdges>
|
||||
std::pair<OutputItFaces,OutputItBoundaryEdges>
|
||||
get_conflicts_and_boundary(const Point &p, OutputItFaces fit,
|
||||
OutputItBoundaryEdges eit, Face_handle start) const;
|
||||
/*!
|
||||
`OutputItFaces` is an output iterator with `Face_handle` as
|
||||
value type. `OutputItBoundaryEdges` stands for an output
|
||||
iterator with `Edge` as value type. This members function
|
||||
outputs in the container pointed to by `fit` the faces which are
|
||||
in conflict with point `p` i. e. the faces whose circumcircle
|
||||
contains `p`. It outputs in the container pointed to by
|
||||
`eit` the boundary of the zone in conflict with `p`.
|
||||
The boundary edges of the conflict zone are output in
|
||||
counter-clockwise order and each edge is described through its
|
||||
incident face which is not in conflict with `p`. The function
|
||||
returns in a std::pair the resulting output
|
||||
iterators. \pre `start` is in conflict with `p` and `p` lies in the original domain `domain`.
|
||||
*/
|
||||
template <class OutputItFaces, class OutputItBoundaryEdges>
|
||||
std::pair<OutputItFaces, OutputItBoundaryEdges>
|
||||
get_conflicts_and_boundary(const Point &p, OutputItFaces fit,
|
||||
OutputItBoundaryEdges eit, Face_handle start) const;
|
||||
|
||||
/*!
|
||||
same as above except that only the faces in conflict with `p` are
|
||||
output. The function returns the resulting output
|
||||
iterator. \pre `start` is in conflict with `p` and `p` lies in the original domain `domain`.
|
||||
*/
|
||||
template <class OutputItFaces> OutputItFaces get_conflicts
|
||||
(const Point &p, OutputItFaces fit, Face_handle start) const;
|
||||
/*!
|
||||
same as above except that only the faces in conflict with `p` are
|
||||
output. The function returns the resulting output
|
||||
iterator. \pre `start` is in conflict with `p` and `p` lies in the original domain `domain`.
|
||||
*/
|
||||
template <class OutputItFaces> OutputItFaces get_conflicts
|
||||
(const Point &p, OutputItFaces fit, Face_handle start) const;
|
||||
|
||||
/*!
|
||||
`OutputItBoundaryEdges` stands for an output iterator with
|
||||
`Edge` as value type. This function outputs in the container
|
||||
pointed to by `eit`, the boundary of the zone in conflict with
|
||||
`p`. The boundary edges of the conflict zone are output in
|
||||
counterclockwise order and each edge is described through the
|
||||
incident face which is not in conflict with `p`. The function
|
||||
returns the resulting output iterator. \pre `start` is in conflict with `p` and `p` lies in the original domain `domain`.
|
||||
*/
|
||||
template <class OutputItBoundaryEdges> OutputItBoundaryEdges
|
||||
get_boundary_of_conflicts(const Point &p, OutputItBoundaryEdges eit,
|
||||
Face_handle start) const;
|
||||
/*!
|
||||
`OutputItBoundaryEdges` stands for an output iterator with
|
||||
`Edge` as value type. This function outputs in the container
|
||||
pointed to by `eit`, the boundary of the zone in conflict with
|
||||
`p`. The boundary edges of the conflict zone are output in
|
||||
counterclockwise order and each edge is described through the
|
||||
incident face which is not in conflict with `p`. The function
|
||||
returns the resulting output iterator. \pre `start` is in conflict with `p` and `p` lies in the original domain `domain`.
|
||||
*/
|
||||
template <class OutputItBoundaryEdges> OutputItBoundaryEdges
|
||||
get_boundary_of_conflicts(const Point &p, OutputItBoundaryEdges eit,
|
||||
Face_handle start) const;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Voronoi diagram
|
||||
/// \name Voronoi diagram
|
||||
/// The following member functions provide the elements of the dual Voronoi diagram.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Returns the center of the circle circumscribed to face `f`.
|
||||
*/
|
||||
Point dual(const Face_handle &f) const;
|
||||
/*!
|
||||
Returns the center of the circle circumscribed to face `f`.
|
||||
*/
|
||||
Point dual(const Face_handle &f) const;
|
||||
|
||||
/*!
|
||||
returns a segment whose endpoints are the duals of both incident
|
||||
faces.
|
||||
*/
|
||||
Segment dual(const Edge &e) const;
|
||||
/*!
|
||||
returns a segment whose endpoints are the duals of both incident
|
||||
faces.
|
||||
*/
|
||||
Segment dual(const Edge &e) const;
|
||||
|
||||
/*!
|
||||
Idem
|
||||
*/
|
||||
Segment dual(const Edge_circulator& ec) const;
|
||||
/*!
|
||||
Idem
|
||||
*/
|
||||
Segment dual(const Edge_circulator& ec) const;
|
||||
|
||||
/*!
|
||||
Idem
|
||||
*/
|
||||
Segment dual(const Edge_iterator& ei) const;
|
||||
/*!
|
||||
Idem
|
||||
*/
|
||||
Segment dual(const Edge_iterator& ei) const;
|
||||
|
||||
/*!
|
||||
output the dual Voronoi diagram to stream `ps`.
|
||||
*/
|
||||
template < class Stream> Stream& draw_dual(Stream & ps);
|
||||
/*!
|
||||
output the dual Voronoi diagram to stream `ps`.
|
||||
*/
|
||||
template < class Stream> Stream& draw_dual(Stream & ps);
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Predicates
|
||||
/// \name Predicates
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Returns the side of `p` with respect to the circle circumscribing the
|
||||
triangle associated with `f`. Periodic copies are checked if
|
||||
necessary.
|
||||
*/
|
||||
Oriented_side side_of_oriented_circle(Face_handle f, const
|
||||
Point& p, bool perturb ) const;
|
||||
/*!
|
||||
Returns the side of `p` with respect to the circle circumscribing the
|
||||
triangle associated with `f`. Periodic copies are checked if
|
||||
necessary.
|
||||
*/
|
||||
Oriented_side side_of_oriented_circle(Face_handle f, const
|
||||
Point& p, bool perturb ) const;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Checking
|
||||
/// \name Checking
|
||||
/// \cgalAdvanced These methods are mainly a debugging help for the users of advanced features.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Checks the combinatorial validity of the triangulation and the
|
||||
validity of its geometric embedding (see
|
||||
Section \ref P2Triangulation2secintro). Also checks that all the
|
||||
circumscribing circles of cells are empty.
|
||||
/*!
|
||||
Checks the combinatorial validity of the triangulation and the
|
||||
validity of its geometric embedding (see
|
||||
Section \ref P2Triangulation2secintro). Also checks that all the
|
||||
circumscribing circles of cells are empty.
|
||||
|
||||
When `verbose` is set to true, messages describing the first
|
||||
invalidity encountered are printed.
|
||||
*/
|
||||
bool
|
||||
is_valid(bool verbose = false) const;
|
||||
When `verbose` is set to true, messages describing the first
|
||||
invalidity encountered are printed.
|
||||
*/
|
||||
bool
|
||||
is_valid(bool verbose = false) const;
|
||||
|
||||
/*!
|
||||
Checks the combinatorial and geometric validity of the cell (see
|
||||
Section \ref P2Triangulation2secintro). Also checks that the
|
||||
circumscribing circle of cells is empty.
|
||||
/*!
|
||||
Checks the combinatorial and geometric validity of the cell (see
|
||||
Section \ref P2Triangulation2secintro). Also checks that the
|
||||
circumscribing circle of cells is empty.
|
||||
|
||||
When `verbose` is set to true, messages are printed to give
|
||||
a precise indication of the kind of invalidity encountered.
|
||||
*/
|
||||
bool
|
||||
is_valid(Face_handle f, bool verbose = false) const;
|
||||
When `verbose` is set to true, messages are printed to give
|
||||
a precise indication of the kind of invalidity encountered.
|
||||
*/
|
||||
bool
|
||||
is_valid(Face_handle f, bool verbose = false) const;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,29 @@
|
|||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2
|
||||
|
||||
The class `Periodic_2_Delaunay_triangulation_traits_2`is designed as a default traits class for the
|
||||
class `Periodic_2_Delaunay_triangulation_2<Traits, Tds>`.
|
||||
The class `Periodic_2_Delaunay_triangulation_traits_2`is designed as a default traits class for the
|
||||
class `Periodic_2_Delaunay_triangulation_2<Traits, Tds>`.
|
||||
|
||||
The argument `Traits` must be a model of the
|
||||
`DelaunayTriangulationTraits_2` concept. The argument
|
||||
`Periodic_2Offset_2` must be a model of the concept
|
||||
`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`.
|
||||
The argument `Traits` must be a model of the
|
||||
`DelaunayTriangulationTraits_2` concept. The argument
|
||||
`Periodic_2Offset_2` must be a model of the concept
|
||||
`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`.
|
||||
|
||||
Note that this template class is specialized for
|
||||
`CGAL::Filtered_kernel`, so that it automatically provides filtered
|
||||
predicates. This holds implicitly for
|
||||
`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an
|
||||
instantiation of `CGAL::Filtered_kernel`.
|
||||
Note that this template class is specialized for
|
||||
`CGAL::Filtered_kernel`, so that it automatically provides filtered
|
||||
predicates. This holds implicitly for
|
||||
`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an
|
||||
instantiation of `CGAL::Filtered_kernel`.
|
||||
|
||||
\alModels ::Periodic_2DelaunayTriangulationTraits_2
|
||||
\alModels ::Periodic_2DelaunayTriangulationTraits_2
|
||||
*/
|
||||
template< typename Traits, typename Periodic_2Offset_2 >
|
||||
class Periodic_2_Delaunay_triangulation_traits_2
|
||||
: public Periodic_2_triangulation_traits_2<Traits,Periodic_2Offset_2> {
|
||||
class Periodic_2_Delaunay_triangulation_traits_2
|
||||
: public Periodic_2_triangulation_traits_2<Traits, Periodic_2Offset_2>
|
||||
{
|
||||
}; /* end Periodic_2_Delaunay_triangulation_traits_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2
|
||||
|
||||
The class `Periodic_2_offset_2` is a model of the concept `Periodic_2Offset_2`.
|
||||
The class `Periodic_2_offset_2` is a model of the concept `Periodic_2Offset_2`.
|
||||
|
||||
*/
|
||||
class Periodic_2_offset_2 {
|
||||
class Periodic_2_offset_2
|
||||
{
|
||||
}; /* end Periodic_2_offset_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,13 +1,14 @@
|
|||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2MainClasses
|
||||
|
||||
The class `Periodic_2_triangulation_face_base_2` is a model of
|
||||
the concept `Periodic_2TriangulationFaceBase_2` to be used by
|
||||
`Triangulation_data_structure_2` to represent faces of a periodic
|
||||
triangulation.
|
||||
The class `Periodic_2_triangulation_face_base_2` is a model of
|
||||
the concept `Periodic_2TriangulationFaceBase_2` to be used by
|
||||
`Triangulation_data_structure_2` to represent faces of a periodic
|
||||
triangulation.
|
||||
|
||||
The first one `Traits` is the geometric traits, it is to be
|
||||
instantiated by a model of the concept
|
||||
|
|
@ -15,26 +16,27 @@ instantiated by a model of the concept
|
|||
class to which the additional information for the periodic vertex is
|
||||
added and should be a model of `TriangulationDSFaceBase_2`
|
||||
|
||||
As faces cannot span more than one domain per direction of space in a
|
||||
periodic Delaunay triangulation, it is enough to store offsets in the
|
||||
range \f$ \{0,1\}^2\f$. For optimization purposes we encode all three
|
||||
offsets in one integer. Each offset needs two bits (for the offset in
|
||||
the \f$ x\f$- and \f$ y\f$-direction). If we number the bits from <I>least
|
||||
significant to most significant</I> then bits \f$ 2*i\f$ and \f$ 2*i+1\f$ contain
|
||||
the offset corresponding to vertex \f$ i\f$.
|
||||
As faces cannot span more than one domain per direction of space in a
|
||||
periodic Delaunay triangulation, it is enough to store offsets in the
|
||||
range \f$ \{0,1\}^2\f$. For optimization purposes we encode all three
|
||||
offsets in one integer. Each offset needs two bits (for the offset in
|
||||
the \f$ x\f$- and \f$ y\f$-direction). If we number the bits from <I>least
|
||||
significant to most significant</I> then bits \f$ 2*i\f$ and \f$ 2*i+1\f$ contain
|
||||
the offset corresponding to vertex \f$ i\f$.
|
||||
|
||||
The implementation of `has_zero_offsets()` results in checking
|
||||
whether all offsets are zero.
|
||||
The implementation of `has_zero_offsets()` results in checking
|
||||
whether all offsets are zero.
|
||||
|
||||
\cgalModels ::Periodic_2TriangulationFaceBase_2
|
||||
\cgalModels ::Periodic_2TriangulationFaceBase_2
|
||||
|
||||
\sa `CGAL::Triangulation_face_base_2`
|
||||
\sa `CGAL::Triangulation_face_base_with_info_2`
|
||||
\sa `CGAL::Triangulation_face_base_with_circumcenter_2`
|
||||
\sa `CGAL::Triangulation_face_base_2`
|
||||
\sa `CGAL::Triangulation_face_base_with_info_2`
|
||||
\sa `CGAL::Triangulation_face_base_with_circumcenter_2`
|
||||
|
||||
*/
|
||||
template< >
|
||||
class Periodic_2_triangulation_face_base_2 {
|
||||
class Periodic_2_triangulation_face_base_2
|
||||
{
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -1,64 +1,66 @@
|
|||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2
|
||||
|
||||
The class `Periodic_2_triangulation_hierarchy_2` implements a
|
||||
triangulation augmented with a data structure which allows fast point
|
||||
location queries.
|
||||
The class `Periodic_2_triangulation_hierarchy_2` implements a
|
||||
triangulation augmented with a data structure which allows fast point
|
||||
location queries.
|
||||
|
||||
### Parameters ###
|
||||
|
||||
It is templated by a parameter which must be instantiated by one of the \cgal periodic triangulation classes. <I>In the current
|
||||
implementation, only `Periodic_2_Delaunay_triangulation_2` is
|
||||
supported for `PTr`.</I>
|
||||
It is templated by a parameter which must be instantiated by one of the \cgal periodic triangulation classes. <I>In the current
|
||||
implementation, only `Periodic_2_Delaunay_triangulation_2` is
|
||||
supported for `PTr`.</I>
|
||||
|
||||
`PTr::Vertex` has to be a model of the concept
|
||||
`Periodic_2TriangulationHierarchyVertexBase_2`.
|
||||
`PTr::Vertex` has to be a model of the concept
|
||||
`Periodic_2TriangulationHierarchyVertexBase_2`.
|
||||
|
||||
`PTr::Geom_traits` has to be a model of the concept
|
||||
`Periodic_2DelaunayTriangulationTraits_2`.
|
||||
`PTr::Geom_traits` has to be a model of the concept
|
||||
`Periodic_2DelaunayTriangulationTraits_2`.
|
||||
|
||||
### Inherits From ###
|
||||
|
||||
`Periodic_2_triangulation_hierarchy_2` offers exactly the same functionalities as `PTr`.
|
||||
Most of them (point location, insertion, removal \f$ \ldots\f$ ) are overloaded to
|
||||
improve their efficiency by using the hierarchical structure.
|
||||
`Periodic_2_triangulation_hierarchy_2` offers exactly the same functionalities as `PTr`.
|
||||
Most of them (point location, insertion, removal \f$ \ldots\f$ ) are overloaded to
|
||||
improve their efficiency by using the hierarchical structure.
|
||||
|
||||
Note that, since the algorithms that are provided are randomized, the
|
||||
running time of constructing a triangulation with a hierarchy may be
|
||||
improved when shuffling the data points.
|
||||
Note that, since the algorithms that are provided are randomized, the
|
||||
running time of constructing a triangulation with a hierarchy may be
|
||||
improved when shuffling the data points.
|
||||
|
||||
However, the I/O operations are not overloaded. So, writing a
|
||||
hierarchy into a file will lose the hierarchical structure and reading
|
||||
it from the file will result in an ordinary triangulation whose
|
||||
efficiency will be the same as `PTr`.
|
||||
However, the I/O operations are not overloaded. So, writing a
|
||||
hierarchy into a file will lose the hierarchical structure and reading
|
||||
it from the file will result in an ordinary triangulation whose
|
||||
efficiency will be the same as `PTr`.
|
||||
|
||||
### Implementation ###
|
||||
|
||||
The data structure is a hierarchy of triangulations. The triangulation
|
||||
at the lowest level is the original triangulation where operations and
|
||||
point location are to be performed.
|
||||
Then at each succeeding level, the data structure
|
||||
stores a triangulation of a small random sample of the vertices
|
||||
of the triangulation at the preceding level. Point location
|
||||
is done through a top-down nearest neighbor query.
|
||||
The nearest neighbor query is first
|
||||
performed naively in the top level triangulation.
|
||||
Then, at each following level, the nearest neighbor at that level
|
||||
is found through a randomized walk performed from
|
||||
the nearest neighbor found at the preceding level.
|
||||
Because the number of vertices in each triangulation is only a small
|
||||
fraction of the number of vertices of the preceding triangulation
|
||||
the data structure remains small and achieves fast point location
|
||||
queries on real data.
|
||||
The data structure is a hierarchy of triangulations. The triangulation
|
||||
at the lowest level is the original triangulation where operations and
|
||||
point location are to be performed.
|
||||
Then at each succeeding level, the data structure
|
||||
stores a triangulation of a small random sample of the vertices
|
||||
of the triangulation at the preceding level. Point location
|
||||
is done through a top-down nearest neighbor query.
|
||||
The nearest neighbor query is first
|
||||
performed naively in the top level triangulation.
|
||||
Then, at each following level, the nearest neighbor at that level
|
||||
is found through a randomized walk performed from
|
||||
the nearest neighbor found at the preceding level.
|
||||
Because the number of vertices in each triangulation is only a small
|
||||
fraction of the number of vertices of the preceding triangulation
|
||||
the data structure remains small and achieves fast point location
|
||||
queries on real data.
|
||||
|
||||
\sa `CGAL::Periodic_2_triangulation_hierarchy_vertex_base_2`
|
||||
\sa `CGAL::Periodic_2_Delaunay_triangulation_2`
|
||||
\sa `CGAL::Periodic_2_triangulation_hierarchy_vertex_base_2`
|
||||
\sa `CGAL::Periodic_2_Delaunay_triangulation_2`
|
||||
|
||||
*/
|
||||
template< typename PTr >
|
||||
class Periodic_2_triangulation_hierarchy_2 : public PTr {
|
||||
class Periodic_2_triangulation_hierarchy_2 : public PTr
|
||||
{
|
||||
}; /* end Periodic_2_triangulation_hierarchy_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2TraitsClasses
|
||||
|
|
@ -8,23 +9,24 @@ The class `Periodic_2_triangulation_traits_2` is designed as a default
|
|||
traits class for the class
|
||||
`Periodic_2_triangulation_2<Periodic_2TriangulationTraits_2,TriangulationDataStructure_2>`.
|
||||
|
||||
The argument `Traits` must be a model of the
|
||||
`TriangulationTraits_2` concept. The argument
|
||||
`Periodic_2Offset_2` must be a model of the concept
|
||||
`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`.
|
||||
The argument `Traits` must be a model of the
|
||||
`TriangulationTraits_2` concept. The argument
|
||||
`Periodic_2Offset_2` must be a model of the concept
|
||||
`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`.
|
||||
|
||||
Note that this template class is specialized for
|
||||
`CGAL::Filtered_kernel`, so that it automatically provides filtered
|
||||
predicates. This holds implicitly for
|
||||
`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an
|
||||
instantiation of `CGAL::Filtered_kernel`.
|
||||
Note that this template class is specialized for
|
||||
`CGAL::Filtered_kernel`, so that it automatically provides filtered
|
||||
predicates. This holds implicitly for
|
||||
`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an
|
||||
instantiation of `CGAL::Filtered_kernel`.
|
||||
|
||||
\alModels `Periodic_2TriangulationTraits_2` and
|
||||
\alModels `Periodic_2DelaunayTriangulationTraits_2` if the template parameter `Traits` is a model of the
|
||||
`DelaunayTriangulationTraits_2` concept.
|
||||
\alModels `Periodic_2TriangulationTraits_2` and
|
||||
\alModels `Periodic_2DelaunayTriangulationTraits_2` if the template parameter `Traits` is a model of the
|
||||
`DelaunayTriangulationTraits_2` concept.
|
||||
|
||||
*/
|
||||
template< typename Traits, typename Periodic_2Offset_2 >
|
||||
class Periodic_2_triangulation_traits_2 : public Traits {
|
||||
class Periodic_2_triangulation_traits_2 : public Traits
|
||||
{
|
||||
}; /* end Periodic_2_triangulation_traits_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2MainClasses
|
||||
|
||||
The class `Periodic_2_triangulation_vertex_base_2` is a model
|
||||
of the concept `Periodic_2TriangulationVertexBase_2` to be used by
|
||||
`Triangulation_data_structure_2` to represent vertices of a
|
||||
periodic triangulation.
|
||||
The class `Periodic_2_triangulation_vertex_base_2` is a model
|
||||
of the concept `Periodic_2TriangulationVertexBase_2` to be used by
|
||||
`Triangulation_data_structure_2` to represent vertices of a
|
||||
periodic triangulation.
|
||||
|
||||
The first one `Traits` is the geometric traits, it is to be
|
||||
instantiated by a model of the concept
|
||||
|
|
@ -18,13 +19,14 @@ added and should be a model of `TriangulationDSVertexBase_2`
|
|||
|
||||
\cgalModels `Periodic_2TriangulationVertexBase_2`
|
||||
|
||||
\sa `CGAL::Periodic_2_triangulation_face_base_2`
|
||||
\sa `CGAL::Triangulation_vertex_base_2`
|
||||
\sa `CGAL::Triangulation_vertex_base_with_info_2`
|
||||
\sa `CGAL::Periodic_2_triangulation_face_base_2`
|
||||
\sa `CGAL::Triangulation_vertex_base_2`
|
||||
\sa `CGAL::Triangulation_vertex_base_with_info_2`
|
||||
|
||||
*/
|
||||
template< >
|
||||
class Periodic_2_triangulation_vertex_base_2 {
|
||||
class Periodic_2_triangulation_vertex_base_2
|
||||
{
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -3,121 +3,122 @@
|
|||
\ingroup PkgPeriodic2Triangulation2Concepts
|
||||
\cgalConcept
|
||||
|
||||
The concept `Periodic_2DelaunayTriangulationTraits_2` is the first template parameter of the class
|
||||
`Periodic_2_Delaunay_triangulation_2`. It refines the concept
|
||||
`Periodic_2TriangulationTraits_2` and
|
||||
`DelaunayTriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the
|
||||
geometric objects, predicates and constructions to work with
|
||||
point-offset pairs. In most cases the offsets will be (0,0) and the
|
||||
predicates from `DelaunayTriangulationTraits_2` can be used
|
||||
directly. For efficiency reasons we maintain for each functor the
|
||||
version without offsets.
|
||||
The concept `Periodic_2DelaunayTriangulationTraits_2` is the first template parameter of the class
|
||||
`Periodic_2_Delaunay_triangulation_2`. It refines the concept
|
||||
`Periodic_2TriangulationTraits_2` and
|
||||
`DelaunayTriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the
|
||||
geometric objects, predicates and constructions to work with
|
||||
point-offset pairs. In most cases the offsets will be (0,0) and the
|
||||
predicates from `DelaunayTriangulationTraits_2` can be used
|
||||
directly. For efficiency reasons we maintain for each functor the
|
||||
version without offsets.
|
||||
|
||||
\cgalRefines ::DelaunayTriangulationTraits_2 and ::Periodic_2TriangulationTraits_2
|
||||
\cgalRefines ::DelaunayTriangulationTraits_2 and ::Periodic_2TriangulationTraits_2
|
||||
|
||||
In addition to the requirements of the concept
|
||||
::Periodic_2TriangulationTraits_2, the concept ::Periodic_2DelaunayTriangulationTraits_2 provides a predicate to check the empty circle property. The
|
||||
corresponding predicate type is called type ::Periodic_2DelaunayTriangulationTraits_2::Side_of_oriented_circle_2.
|
||||
In addition to the requirements of the concept
|
||||
::Periodic_2TriangulationTraits_2, the concept ::Periodic_2DelaunayTriangulationTraits_2 provides a predicate to check the empty circle property. The
|
||||
corresponding predicate type is called type ::Periodic_2DelaunayTriangulationTraits_2::Side_of_oriented_circle_2.
|
||||
|
||||
The additional constructor object ::Periodic_2DelaunayTriangulationTraits_2::Construct_circumcenter_2 is
|
||||
used to build the dual Voronoi diagram and are required only if the
|
||||
dual functions are called. The additional predicate type
|
||||
::Periodic_2DelaunayTriangulationTraits_2::Compare_distance_2 is required if calls to
|
||||
nearest_vertex(..) are issued.
|
||||
The additional constructor object ::Periodic_2DelaunayTriangulationTraits_2::Construct_circumcenter_2 is
|
||||
used to build the dual Voronoi diagram and are required only if the
|
||||
dual functions are called. The additional predicate type
|
||||
::Periodic_2DelaunayTriangulationTraits_2::Compare_distance_2 is required if calls to
|
||||
nearest_vertex(..) are issued.
|
||||
|
||||
\cgalHasModel `CGAL::Periodic_2_Delaunay_triangulation_traits_2<Traits, Offset>`
|
||||
\cgalHasModel `CGAL::Periodic_2_triangulation_traits_2<Traits, Offset>`, which implements
|
||||
additional the Delaunay predicates as well if the template parameter Traits is a model of `DelaunayTriangulationTraits_2`.
|
||||
\cgalHasModel `CGAL::Periodic_2_triangulation_traits_2<Traits, Offset>`, which implements
|
||||
additional the Delaunay predicates as well if the template parameter Traits is a model of `DelaunayTriangulationTraits_2`.
|
||||
|
||||
\sa `DelaunayTriangulationTraits_2`
|
||||
\sa `DelaunayTriangulationTraits_2`
|
||||
*/
|
||||
class Periodic_2DelaunayTriangulationTraits_2 {
|
||||
class Periodic_2DelaunayTriangulationTraits_2
|
||||
{
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Predicate object. Must
|
||||
provide the operators
|
||||
/*!
|
||||
Predicate object. Must
|
||||
provide the operators
|
||||
|
||||
`Oriented_side operator()(Point p, Point q, Point r, Point s)`
|
||||
which takes four points \f$ p, q, r, s\f$ as arguments and returns
|
||||
`ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or,
|
||||
`ON_ORIENTED_BOUNDARY` according to the position of points `s`
|
||||
with respect to the oriented circle through through \f$ p,q\f$
|
||||
and \f$ r\f$ and
|
||||
`Oriented_side operator()(Point p, Point q, Point r, Point s)`
|
||||
which takes four points \f$ p, q, r, s\f$ as arguments and returns
|
||||
`ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or,
|
||||
`ON_ORIENTED_BOUNDARY` according to the position of points `s`
|
||||
with respect to the oriented circle through through \f$ p,q\f$
|
||||
and \f$ r\f$ and
|
||||
|
||||
`Oriented_side operator()( Point p, Point q, Point r, Point s, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r, Periodic_2_offset_2 o_s)`
|
||||
which takes four points \f$ (p, o_p), (q, o_q), (r, o_r), (s, o_s)\f$ as arguments and returns
|
||||
`ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or,
|
||||
`ON_ORIENTED_BOUNDARY` according to the position of points `(s, o_s)`
|
||||
with respect to the oriented circle through through `(p, o_p), (q, o_q)`
|
||||
and `(r, o_r)`.
|
||||
`Oriented_side operator()( Point p, Point q, Point r, Point s, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r, Periodic_2_offset_2 o_s)`
|
||||
which takes four points \f$ (p, o_p), (q, o_q), (r, o_r), (s, o_s)\f$ as arguments and returns
|
||||
`ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or,
|
||||
`ON_ORIENTED_BOUNDARY` according to the position of points `(s, o_s)`
|
||||
with respect to the oriented circle through through `(p, o_p), (q, o_q)`
|
||||
and `(r, o_r)`.
|
||||
|
||||
This type is required only if the function
|
||||
`side_of_oriented_circle(Face_handle f, Point p)` is called.
|
||||
*/
|
||||
typedef Hidden_type Side_of_oriented_circle_2;
|
||||
This type is required only if the function
|
||||
`side_of_oriented_circle(Face_handle f, Point p)` is called.
|
||||
*/
|
||||
typedef Hidden_type Side_of_oriented_circle_2;
|
||||
|
||||
/*!
|
||||
Constructor
|
||||
object. Provides the operators:
|
||||
/*!
|
||||
Constructor
|
||||
object. Provides the operators:
|
||||
|
||||
`Point operator()(Point p, Point q, Point r)`
|
||||
`Point operator()(Point p, Point q, Point r)`
|
||||
|
||||
which returns
|
||||
the circumcenter of the three points `p, q` and `r`.
|
||||
which returns
|
||||
the circumcenter of the three points `p, q` and `r`.
|
||||
|
||||
`Point operator()(Point p, Point q, Point r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)`
|
||||
`Point operator()(Point p, Point q, Point r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)`
|
||||
|
||||
which returns the circumcenter of the three points `(p, o_p), (q, o_q)` and `(r, o_r)`.
|
||||
which returns the circumcenter of the three points `(p, o_p), (q, o_q)` and `(r, o_r)`.
|
||||
|
||||
This type is required only if the function `Point circumcenter(Face_handle f)`is called.
|
||||
*/
|
||||
typedef Hidden_type Construct_circumcenter_2;
|
||||
This type is required only if the function `Point circumcenter(Face_handle f)`is called.
|
||||
*/
|
||||
typedef Hidden_type Construct_circumcenter_2;
|
||||
|
||||
/*!
|
||||
Predicate type. Provides
|
||||
the operators:
|
||||
/*!
|
||||
Predicate type. Provides
|
||||
the operators:
|
||||
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r)`
|
||||
which returns `SMALLER`, `EQUAL` or `LARGER` according
|
||||
to the distance between p and q being smaller, equal or larger than
|
||||
the distance between p and r.
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r)`
|
||||
which returns `SMALLER`, `EQUAL` or `LARGER` according
|
||||
to the distance between p and q being smaller, equal or larger than
|
||||
the distance between p and r.
|
||||
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)` which returns `SMALLER`, `EQUAL`
|
||||
or `LARGER` according to the distance between `(p, o_p)`,
|
||||
and `(q, o_q)` being smaller, equal or larger than
|
||||
the distance between `(p, o_p)` and `(r, o_r)`.
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)` which returns `SMALLER`, `EQUAL`
|
||||
or `LARGER` according to the distance between `(p, o_p)`,
|
||||
and `(q, o_q)` being smaller, equal or larger than
|
||||
the distance between `(p, o_p)` and `(r, o_r)`.
|
||||
|
||||
This type is only require if
|
||||
`nearest_vertex` queries are issued.
|
||||
*/
|
||||
typedef Hidden_type Compare_distance_2;
|
||||
This type is only require if
|
||||
`nearest_vertex` queries are issued.
|
||||
*/
|
||||
typedef Hidden_type Compare_distance_2;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Predicate functions
|
||||
/// \name Predicate functions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Required only
|
||||
if `side_of_oriented_circle` is called
|
||||
called.
|
||||
*/
|
||||
Side_of_oriented_circle_2
|
||||
side_of_oriented_circle_2_object();
|
||||
/*!
|
||||
Required only
|
||||
if `side_of_oriented_circle` is called
|
||||
called.
|
||||
*/
|
||||
Side_of_oriented_circle_2
|
||||
side_of_oriented_circle_2_object();
|
||||
|
||||
/*!
|
||||
Required only if `circumcenter` is called.
|
||||
*/
|
||||
Construct_circumcenter_2 construct_circumcenter_2_object();
|
||||
/*!
|
||||
Required only if `circumcenter` is called.
|
||||
*/
|
||||
Construct_circumcenter_2 construct_circumcenter_2_object();
|
||||
|
||||
/*!
|
||||
Required only if `compare_distance` is called.
|
||||
*/
|
||||
Compare_distance_2 compare_distance_2_object();
|
||||
/*!
|
||||
Required only if `compare_distance` is called.
|
||||
*/
|
||||
Compare_distance_2 compare_distance_2_object();
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,125 +3,126 @@
|
|||
\ingroup PkgPeriodic2Triangulation2Concepts
|
||||
\cgalConcept
|
||||
|
||||
The concept `Periodic_2Offset_2` describes a two-/dimensional integer vector with some specialized access functions and operations.
|
||||
The concept `Periodic_2Offset_2` describes a two-/dimensional integer vector with some specialized access functions and operations.
|
||||
|
||||
\cgalHasModel CGAL::Periodic_2_offset_2
|
||||
\cgalHasModel CGAL::Periodic_2_offset_2
|
||||
|
||||
\sa `Periodic_2TriangulationTraits_2`
|
||||
\sa `Periodic_2DelaunayTriangulationTraits_2`
|
||||
\sa `Periodic_2TriangulationTraits_2`
|
||||
\sa `Periodic_2DelaunayTriangulationTraits_2`
|
||||
|
||||
*/
|
||||
|
||||
class Periodic_2Offset_2 {
|
||||
class Periodic_2Offset_2
|
||||
{
|
||||
public:
|
||||
|
||||
/// \name Creation
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Default constructor.
|
||||
*/
|
||||
Periodic_2Offset_2();
|
||||
/*!
|
||||
Default constructor.
|
||||
*/
|
||||
Periodic_2Offset_2();
|
||||
|
||||
/*!
|
||||
Constructs the offset (x,y).
|
||||
*/
|
||||
Periodic_2Offset_2(int x, int y);
|
||||
/*!
|
||||
Constructs the offset (x,y).
|
||||
*/
|
||||
Periodic_2Offset_2(int x, int y);
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Return the vector sum of `this` and `o`.
|
||||
*/
|
||||
Periodic_2Offset_2 operator+(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
/*!
|
||||
Return the vector sum of `this` and `o`.
|
||||
*/
|
||||
Periodic_2Offset_2 operator+(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
|
||||
/*!
|
||||
Return the vector difference of `this` and `o`.
|
||||
*/
|
||||
Periodic_2Offset_2 operator-(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
/*!
|
||||
Return the vector difference of `this` and `o`.
|
||||
*/
|
||||
Periodic_2Offset_2 operator-(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
|
||||
/*!
|
||||
Return the negative vector of `this`.
|
||||
*/
|
||||
Periodic_2Offset_2 operator-() const;
|
||||
/*!
|
||||
Return the negative vector of `this`.
|
||||
*/
|
||||
Periodic_2Offset_2 operator-() const;
|
||||
|
||||
/*!
|
||||
Add `o` to `this` using vector addition.
|
||||
*/
|
||||
void operator+=(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
/*!
|
||||
Add `o` to `this` using vector addition.
|
||||
*/
|
||||
void operator+=(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
|
||||
/*!
|
||||
Subtract `o` from `this` using vector subtraction.
|
||||
*/
|
||||
void operator-=(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
/*!
|
||||
Subtract `o` from `this` using vector subtraction.
|
||||
*/
|
||||
void operator-=(const Periodic_2Offset_2 & o)
|
||||
const;
|
||||
|
||||
/*!
|
||||
Return `true` if `o` and `this` represent the same vector.
|
||||
*/
|
||||
bool operator==(const Periodic_2Offset_2 & o) const;
|
||||
/*!
|
||||
Return `true` if `o` and `this` represent the same vector.
|
||||
*/
|
||||
bool operator==(const Periodic_2Offset_2 & o) const;
|
||||
|
||||
/*!
|
||||
Return `true` if `o` and `this` do not represent the same
|
||||
vector.
|
||||
*/
|
||||
bool operator!=(const Periodic_2Offset_2 & o) const;
|
||||
/*!
|
||||
Return `true` if `o` and `this` do not represent the same
|
||||
vector.
|
||||
*/
|
||||
bool operator!=(const Periodic_2Offset_2 & o) const;
|
||||
|
||||
/*!
|
||||
Compare `this` and `o` lexicographically.
|
||||
*/
|
||||
bool operator<(const Periodic_2Offset_2 & o) const;
|
||||
/*!
|
||||
Compare `this` and `o` lexicographically.
|
||||
*/
|
||||
bool operator<(const Periodic_2Offset_2 & o) const;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Access Functions
|
||||
/// \name Access Functions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Return the \f$ i\f$-th entry of `this`.
|
||||
\pre \f$ i\in\{0,1\}\f$
|
||||
*/
|
||||
int operator[](int i);
|
||||
/*!
|
||||
Return the \f$ i\f$-th entry of `this`.
|
||||
\pre \f$ i\in\{0,1\}\f$
|
||||
*/
|
||||
int operator[](int i);
|
||||
|
||||
/*!
|
||||
Return the \f$ x\f$-entry of `this`.
|
||||
*/
|
||||
int x() const;
|
||||
/*!
|
||||
Return the \f$ x\f$-entry of `this`.
|
||||
*/
|
||||
int x() const;
|
||||
|
||||
/*!
|
||||
Return the \f$ y\f$-entry of `this`.
|
||||
*/
|
||||
int y() const;
|
||||
/*!
|
||||
Return the \f$ y\f$-entry of `this`.
|
||||
*/
|
||||
int y() const;
|
||||
|
||||
/*!
|
||||
Returns `true` if `this` is equal to (0,0).
|
||||
*/
|
||||
bool is_null() const;
|
||||
/*!
|
||||
Returns `true` if `this` is equal to (0,0).
|
||||
*/
|
||||
bool is_null() const;
|
||||
|
||||
/*!
|
||||
Returns `true` if `this` is equal to (0,0).
|
||||
*/
|
||||
bool is_zero() const;
|
||||
/*!
|
||||
Returns `true` if `this` is equal to (0,0).
|
||||
*/
|
||||
bool is_zero() const;
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Periodic_2Offset_2 */
|
||||
|
||||
|
||||
/*!
|
||||
Inputs an offset from `is`.
|
||||
\relates Periodic_2Offset_2
|
||||
*/
|
||||
istream& operator>>(istream & is, Periodic_2Offset_2 & off);
|
||||
/*!
|
||||
Inputs an offset from `is`.
|
||||
\relates Periodic_2Offset_2
|
||||
*/
|
||||
istream& operator>>(istream & is, Periodic_2Offset_2 & off);
|
||||
|
||||
/*!
|
||||
Outputs an offset from `os`.
|
||||
\relates Periodic_2Offset_2
|
||||
*/
|
||||
ostream& operator<<(ostream & os, Periodic_2Offset_2 & off) const;
|
||||
/*!
|
||||
Outputs an offset from `os`.
|
||||
\relates Periodic_2Offset_2
|
||||
*/
|
||||
ostream& operator<<(ostream & os, Periodic_2Offset_2 & off) const;
|
||||
|
|
|
|||
|
|
@ -9,42 +9,43 @@ its four vertices and to its four neighbor faces. The vertices and
|
|||
neighbors are indexed 0, 1 and 2. Neighbor \f$ i\f$ lies opposite to
|
||||
vertex \f$ i\f$.
|
||||
|
||||
\cgalRefines ::TriangulationFaceBase_2
|
||||
\cgalRefines ::TriangulationFaceBase_2
|
||||
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_face_base_2
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_face_base_2
|
||||
|
||||
\sa `TriangulationDataStructure_2`
|
||||
\sa `TriangulationFaceBase_2`
|
||||
\sa `Periodic_2TriangulationVertexBase_2`
|
||||
\sa `TriangulationDataStructure_2`
|
||||
\sa `TriangulationFaceBase_2`
|
||||
\sa `Periodic_2TriangulationVertexBase_2`
|
||||
|
||||
*/
|
||||
|
||||
class Periodic_2TriangulationFaceBase_2 {
|
||||
class Periodic_2TriangulationFaceBase_2
|
||||
{
|
||||
public:
|
||||
|
||||
/// \name Access Functions
|
||||
/// \name Access Functions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Returns the offset of vertex `i`.
|
||||
\pre \f$ i \in\{0, 1, 2\}\f$.
|
||||
*/
|
||||
int offset(int i) const;
|
||||
/*!
|
||||
Returns the offset of vertex `i`.
|
||||
\pre \f$ i \in\{0, 1, 2\}\f$.
|
||||
*/
|
||||
int offset(int i) const;
|
||||
|
||||
/*!
|
||||
Returns true if the offset of vertex `i` is zero for \f$ i \in\{0, 1, 2\}\f$.
|
||||
*/
|
||||
bool has_zero_offsets() const;
|
||||
/*!
|
||||
Returns true if the offset of vertex `i` is zero for \f$ i \in\{0, 1, 2\}\f$.
|
||||
*/
|
||||
bool has_zero_offsets() const;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Setting
|
||||
/// \name Setting
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Sets the vertex offsets according to `off0` to `off2`.
|
||||
*/
|
||||
void set_offsets(int off0, int off1, int off2);
|
||||
/*!
|
||||
Sets the vertex offsets according to `off0` to `off2`.
|
||||
*/
|
||||
void set_offsets(int off0, int off1, int off2);
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,300 +3,301 @@
|
|||
\ingroup PkgPeriodic2Triangulation2Concepts
|
||||
\cgalConcept
|
||||
|
||||
The concept `Periodic_2TriangulationTraits_2` is the first template parameter of the classes
|
||||
`Periodic_2_triangulation_2<Traits, Tds>`. This concept provides the types of
|
||||
the geometric primitives used in the triangulation and some function
|
||||
object types for the required predicates on those primitives.
|
||||
The concept `Periodic_2TriangulationTraits_2` is the first template parameter of the classes
|
||||
`Periodic_2_triangulation_2<Traits, Tds>`. This concept provides the types of
|
||||
the geometric primitives used in the triangulation and some function
|
||||
object types for the required predicates on those primitives.
|
||||
|
||||
It refines the concept
|
||||
`TriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the
|
||||
geometric objects, predicates and constructions to work with
|
||||
point-offset pairs. In most cases the offsets will be (0,0) and the
|
||||
predicates from `TriangulationTraits_2` can be used
|
||||
directly. For efficiency reasons we maintain for each functor the
|
||||
version without offsets.
|
||||
It refines the concept
|
||||
`TriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the
|
||||
geometric objects, predicates and constructions to work with
|
||||
point-offset pairs. In most cases the offsets will be (0,0) and the
|
||||
predicates from `TriangulationTraits_2` can be used
|
||||
directly. For efficiency reasons we maintain for each functor the
|
||||
version without offsets.
|
||||
|
||||
\cgalRefines ::TriangulationTraits_2
|
||||
In addition to the requirements described for the traits class
|
||||
::TriangulationTraits_2, the geometric traits class of a
|
||||
Periodic triangulation must fulfill the following
|
||||
requirements:
|
||||
\cgalRefines ::TriangulationTraits_2
|
||||
In addition to the requirements described for the traits class
|
||||
::TriangulationTraits_2, the geometric traits class of a
|
||||
Periodic triangulation must fulfill the following
|
||||
requirements:
|
||||
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_traits_2
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_traits_2
|
||||
|
||||
\sa `TriangulationTraits_2`
|
||||
\sa `CGAL::Periodic_2_triangulation_2<Traits,Tds>`
|
||||
\sa `TriangulationTraits_2`
|
||||
\sa `CGAL::Periodic_2_triangulation_2<Traits,Tds>`
|
||||
|
||||
*/
|
||||
|
||||
class Periodic_2TriangulationTraits_2 {
|
||||
class Periodic_2TriangulationTraits_2
|
||||
{
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
The point type. It must be a model of
|
||||
`Kernel::Point_2`.
|
||||
*/
|
||||
typedef Hidden_type Point_2;
|
||||
/*!
|
||||
The point type. It must be a model of
|
||||
`Kernel::Point_2`.
|
||||
*/
|
||||
typedef Hidden_type Point_2;
|
||||
|
||||
/*!
|
||||
The segment type. It must be a model
|
||||
of `Kernel::Segment_2`.
|
||||
*/
|
||||
typedef Hidden_type Segment_2;
|
||||
/*!
|
||||
The segment type. It must be a model
|
||||
of `Kernel::Segment_2`.
|
||||
*/
|
||||
typedef Hidden_type Segment_2;
|
||||
|
||||
/*!
|
||||
The vector type. It must be a model
|
||||
of `Kernel::Vector_2`.
|
||||
*/
|
||||
typedef Hidden_type Vector_2;
|
||||
/*!
|
||||
The vector type. It must be a model
|
||||
of `Kernel::Vector_2`.
|
||||
*/
|
||||
typedef Hidden_type Vector_2;
|
||||
|
||||
/*!
|
||||
The triangle type. It must be a
|
||||
model of `Kernel::Triangle_2`.
|
||||
*/
|
||||
typedef Hidden_type Triangle_2;
|
||||
/*!
|
||||
The triangle type. It must be a
|
||||
model of `Kernel::Triangle_2`.
|
||||
*/
|
||||
typedef Hidden_type Triangle_2;
|
||||
|
||||
/*!
|
||||
A type representing an
|
||||
axis-aligned rectangle. It must be a model of
|
||||
`Kernel::Iso_rectangle_2`.
|
||||
*/
|
||||
typedef Hidden_type Iso_rectangle_2;
|
||||
/*!
|
||||
A type representing an
|
||||
axis-aligned rectangle. It must be a model of
|
||||
`Kernel::Iso_rectangle_2`.
|
||||
*/
|
||||
typedef Hidden_type Iso_rectangle_2;
|
||||
|
||||
/*!
|
||||
The offset type. It must
|
||||
be a model of the concept `Periodic_2Offset_2`.
|
||||
*/
|
||||
typedef Hidden_type Periodic_2_offset_2;
|
||||
/*!
|
||||
The offset type. It must
|
||||
be a model of the concept `Periodic_2Offset_2`.
|
||||
*/
|
||||
typedef Hidden_type Periodic_2_offset_2;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Predicate types
|
||||
/// \name Predicate types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
A predicate object that must provide the function operators
|
||||
A predicate object that must provide the function operators
|
||||
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q)`,
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q)`,
|
||||
|
||||
which returns `EQUAL` if the \f$ x\f$-coordinates of the two points are equal and
|
||||
which returns `EQUAL` if the \f$ x\f$-coordinates of the two points are equal and
|
||||
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`,
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`,
|
||||
|
||||
which returns `EQUAL` if the \f$ x\f$-coordinates and \f$ x\f$-offsets of
|
||||
the two point-offset pairs are equal. Otherwise it must return a
|
||||
consistent order for any two points. \pre `p`, `q` lie inside the domain.
|
||||
*/
|
||||
typedef Hidden_type Compare_x_2;
|
||||
which returns `EQUAL` if the \f$ x\f$-coordinates and \f$ x\f$-offsets of
|
||||
the two point-offset pairs are equal. Otherwise it must return a
|
||||
consistent order for any two points. \pre `p`, `q` lie inside the domain.
|
||||
*/
|
||||
typedef Hidden_type Compare_x_2;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
A predicate object that must provide the function operators
|
||||
A predicate object that must provide the function operators
|
||||
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q)`,
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q)`,
|
||||
|
||||
which returns `EQUAL` if the \f$ y\f$-coordinates of the two points are equal and
|
||||
which returns `EQUAL` if the \f$ y\f$-coordinates of the two points are equal and
|
||||
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`,
|
||||
`Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`,
|
||||
|
||||
which returns `EQUAL` if the \f$ y\f$-coordinates and \f$ y\f$-offsets of
|
||||
the two point-offset pairs are equal. Otherwise it must return a
|
||||
consistent order for any two points. \pre `p`, `q` lie inside the domain.
|
||||
*/
|
||||
typedef Hidden_type Compare_y_2;
|
||||
which returns `EQUAL` if the \f$ y\f$-coordinates and \f$ y\f$-offsets of
|
||||
the two point-offset pairs are equal. Otherwise it must return a
|
||||
consistent order for any two points. \pre `p`, `q` lie inside the domain.
|
||||
*/
|
||||
typedef Hidden_type Compare_y_2;
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
Predicate object. Provides the operators:
|
||||
Predicate object. Provides the operators:
|
||||
|
||||
`bool operator()(Point p, Point q)` and
|
||||
`bool operator()(Point p, Point q)` and
|
||||
|
||||
`bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`
|
||||
`bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`
|
||||
|
||||
which returns `true` if `p` is before `q`
|
||||
according to the \f$ x\f$-ordering of points.
|
||||
which returns `true` if `p` is before `q`
|
||||
according to the \f$ x\f$-ordering of points.
|
||||
|
||||
This predicate is only necessary if the insert function with a range
|
||||
of points (using Hilbert sorting) is used.
|
||||
*/
|
||||
typedef Hidden_type Less_x_2;
|
||||
This predicate is only necessary if the insert function with a range
|
||||
of points (using Hilbert sorting) is used.
|
||||
*/
|
||||
typedef Hidden_type Less_x_2;
|
||||
|
||||
/*!
|
||||
Predicate object. Provides
|
||||
the operators:
|
||||
/*!
|
||||
Predicate object. Provides
|
||||
the operators:
|
||||
|
||||
`bool operator()(Point p, Point q)` and
|
||||
`bool operator()(Point p, Point q)` and
|
||||
|
||||
`bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`
|
||||
`bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`
|
||||
|
||||
which returns `true` if `p` is before `q`
|
||||
according to the \f$ y\f$-ordering of points.
|
||||
which returns `true` if `p` is before `q`
|
||||
according to the \f$ y\f$-ordering of points.
|
||||
|
||||
This predicate is only necessary if the insert function with a range of
|
||||
points (using Hilbert sorting) is used.
|
||||
This predicate is only necessary if the insert function with a range of
|
||||
points (using Hilbert sorting) is used.
|
||||
|
||||
*/
|
||||
typedef Hidden_type Less_y_2;
|
||||
*/
|
||||
typedef Hidden_type Less_y_2;
|
||||
|
||||
/*!
|
||||
A predicate object that must provide the function operators
|
||||
/*!
|
||||
A predicate object that must provide the function operators
|
||||
|
||||
`Orientation operator()(Point_2 p, Point_2 q, Point_2 r)`,
|
||||
`Orientation operator()(Point_2 p, Point_2 q, Point_2 r)`,
|
||||
|
||||
which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR`
|
||||
depending on \f$ r\f$ being, with respect to the oriented line `pq`,
|
||||
on the left side, on the right side or on the line.
|
||||
and
|
||||
which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR`
|
||||
depending on \f$ r\f$ being, with respect to the oriented line `pq`,
|
||||
on the left side, on the right side or on the line.
|
||||
and
|
||||
|
||||
`Orientation operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`,
|
||||
`Orientation operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`,
|
||||
|
||||
which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR`
|
||||
depending on `(r,o_r)` being, with respect to the oriented line
|
||||
defined by `(p,o_p)(q,o_q)` on the left side, on the right side
|
||||
or on the line.
|
||||
*/
|
||||
typedef Hidden_type Orientation_2;
|
||||
which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR`
|
||||
depending on `(r,o_r)` being, with respect to the oriented line
|
||||
defined by `(p,o_p)(q,o_q)` on the left side, on the right side
|
||||
or on the line.
|
||||
*/
|
||||
typedef Hidden_type Orientation_2;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Constructor types:
|
||||
/// \name Constructor types:
|
||||
/// Note that the traits must provide exact constructions in order to
|
||||
/// guarantee exactness of the following construction functors.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
A constructor object for
|
||||
`Point_2`. Provides:
|
||||
/*!
|
||||
A constructor object for
|
||||
`Point_2`. Provides:
|
||||
|
||||
`Point_2 operator()(Point_2 p,Periodic_2_offset_2 p_o)`,
|
||||
`Point_2 operator()(Point_2 p,Periodic_2_offset_2 p_o)`,
|
||||
|
||||
which constructs a point from a point-offset pair.
|
||||
\pre `p` lies inside the domain.
|
||||
which constructs a point from a point-offset pair.
|
||||
\pre `p` lies inside the domain.
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_point_2;
|
||||
*/
|
||||
typedef Hidden_type Construct_point_2;
|
||||
|
||||
/*!
|
||||
A constructor object for
|
||||
`Segment_2`. Provides:
|
||||
/*!
|
||||
A constructor object for
|
||||
`Segment_2`. Provides:
|
||||
|
||||
`Segment_2 operator()(Point_2 p,Point_2 q)`,
|
||||
`Segment_2 operator()(Point_2 p,Point_2 q)`,
|
||||
|
||||
which constructs a segment from two points and
|
||||
which constructs a segment from two points and
|
||||
|
||||
`Segment_2 operator()(Point_2 p,Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`,
|
||||
`Segment_2 operator()(Point_2 p,Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`,
|
||||
|
||||
which constructs a segment from the points `(p,o_p)` and `(q,o_q)`.
|
||||
which constructs a segment from the points `(p,o_p)` and `(q,o_q)`.
|
||||
|
||||
*/
|
||||
typedef Hidden_type Construct_segment_2;
|
||||
*/
|
||||
typedef Hidden_type Construct_segment_2;
|
||||
|
||||
/*!
|
||||
A constructor object for
|
||||
`Triangle_2`. Provides:
|
||||
/*!
|
||||
A constructor object for
|
||||
`Triangle_2`. Provides:
|
||||
|
||||
`Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r )`,
|
||||
`Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r )`,
|
||||
|
||||
which constructs a triangle from three points and
|
||||
which constructs a triangle from three points and
|
||||
|
||||
`Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`,
|
||||
`Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`,
|
||||
|
||||
which constructs a triangle from the three points `(p,o_p)`,
|
||||
`(q,o_q)` and `(r,o_r)`.
|
||||
*/
|
||||
typedef Hidden_type Construct_triangle_2;
|
||||
which constructs a triangle from the three points `(p,o_p)`,
|
||||
`(q,o_q)` and `(r,o_r)`.
|
||||
*/
|
||||
typedef Hidden_type Construct_triangle_2;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// \name Creation
|
||||
/// Only a default constructor, copy constructor and an assignment
|
||||
/// operator are required. Note that further constructors can be
|
||||
/// provided.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
default constructor.
|
||||
*/
|
||||
Periodic_2TriangulationTraits_2();
|
||||
/*!
|
||||
default constructor.
|
||||
*/
|
||||
Periodic_2TriangulationTraits_2();
|
||||
|
||||
/*!
|
||||
Copy constructor
|
||||
*/
|
||||
Periodic_2TriangulationTraits_2(Periodic_2TriangulationTraits_2 gtr);
|
||||
/*!
|
||||
Copy constructor
|
||||
*/
|
||||
Periodic_2TriangulationTraits_2(Periodic_2TriangulationTraits_2 gtr);
|
||||
|
||||
/*!
|
||||
Assignment operator.
|
||||
*/
|
||||
Periodic_2TriangulationTraits_2 operator=(Periodic_2TriangulationTraits_2 gtr);
|
||||
/*!
|
||||
Assignment operator.
|
||||
*/
|
||||
Periodic_2TriangulationTraits_2 operator=(Periodic_2TriangulationTraits_2 gtr);
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Predicate functions
|
||||
/// \name Predicate functions
|
||||
/// The following functions give access to the predicate and constructor objects.
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Compare_x_2 compare_x_2_object();
|
||||
*/
|
||||
Compare_x_2 compare_x_2_object();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Compare_y_2 compare_y_2_object();
|
||||
*/
|
||||
Compare_y_2 compare_y_2_object();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Less_x_2 less_x_2_object();
|
||||
*/
|
||||
Less_x_2 less_x_2_object();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Less_y_2 less_y_2_object();
|
||||
*/
|
||||
Less_y_2 less_y_2_object();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Orientation_2 orientation_2_object();
|
||||
*/
|
||||
Orientation_2 orientation_2_object();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Construct_point_2 construct_point_2_object();
|
||||
*/
|
||||
Construct_point_2 construct_point_2_object();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Construct_segment_2 construct_segment_2_object();
|
||||
*/
|
||||
Construct_segment_2 construct_segment_2_object();
|
||||
|
||||
/*!
|
||||
/*!
|
||||
|
||||
*/
|
||||
Construct_triangle_2 construct_triangle_2_object();
|
||||
*/
|
||||
Construct_triangle_2 construct_triangle_2_object();
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Access Functions
|
||||
/// \name Access Functions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Sets the
|
||||
fundamental domain. This is necessary to evaluate predicates
|
||||
correctly.
|
||||
\pre `domain` represents a square.
|
||||
*/
|
||||
void set_domain(Iso_rectangle_2 domain);
|
||||
/*!
|
||||
Sets the
|
||||
fundamental domain. This is necessary to evaluate predicates
|
||||
correctly.
|
||||
\pre `domain` represents a square.
|
||||
*/
|
||||
void set_domain(Iso_rectangle_2 domain);
|
||||
|
||||
/*!
|
||||
Returns the
|
||||
fundamental domain.
|
||||
*/
|
||||
Iso_rectangle_2 get_domain() const;
|
||||
/*!
|
||||
Returns the
|
||||
fundamental domain.
|
||||
*/
|
||||
Iso_rectangle_2 get_domain() const;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
\ingroup PkgPeriodic2Triangulation2Concepts
|
||||
\cgalConcept
|
||||
|
||||
A refinement of the concept `TriangulationVertexBase_2`
|
||||
A refinement of the concept `TriangulationVertexBase_2`
|
||||
which adds an API for offset.
|
||||
|
||||
At the base level of 2D-triangulations (see Section \ref
|
||||
|
|
@ -12,54 +12,55 @@ to one of its incident faces through a handle.
|
|||
|
||||
The storage of the offset is only needed when a triangulation is copied.
|
||||
|
||||
\cgalRefines `TriangulationVertexBase_2`
|
||||
\cgalRefines `TriangulationVertexBase_2`
|
||||
|
||||
|
||||
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_vertex_base_2
|
||||
|
||||
\sa `TriangulationDataStructure_2`
|
||||
\sa `TriangulationVertexBase_2`
|
||||
\sa `Periodic_2TriangulationFaceBase_2`
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_vertex_base_2
|
||||
|
||||
\sa `TriangulationDataStructure_2`
|
||||
\sa `TriangulationVertexBase_2`
|
||||
\sa `Periodic_2TriangulationFaceBase_2`
|
||||
|
||||
*/
|
||||
|
||||
class Periodic_2TriangulationVertexBase_2 {
|
||||
class Periodic_2TriangulationVertexBase_2
|
||||
{
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
A model of the concept
|
||||
`Periodic_2Offset_2`
|
||||
*/
|
||||
typedef Hidden_type Periodic_2_offset_2;
|
||||
/*!
|
||||
A model of the concept
|
||||
`Periodic_2Offset_2`
|
||||
*/
|
||||
typedef Hidden_type Periodic_2_offset_2;
|
||||
|
||||
/// @}
|
||||
/// @}
|
||||
|
||||
/// \name Access Functions
|
||||
/// \name Access Functions
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Returns the offset stored in the vertex.
|
||||
*/
|
||||
Periodic_2_offset_2 offset() const;
|
||||
/*!
|
||||
Returns the offset stored in the vertex.
|
||||
*/
|
||||
Periodic_2_offset_2 offset() const;
|
||||
|
||||
/*!
|
||||
Returns `true` if the offset has been set, `false` otherwise.
|
||||
*/
|
||||
bool get_offset_flag() const;
|
||||
/*!
|
||||
Returns `true` if the offset has been set, `false` otherwise.
|
||||
*/
|
||||
bool get_offset_flag() const;
|
||||
|
||||
/*!
|
||||
Sets the offset and sets the offset flag to `true`.
|
||||
*/
|
||||
void set_offset(Periodic_2_offset_2 o);
|
||||
/*!
|
||||
Sets the offset and sets the offset flag to `true`.
|
||||
*/
|
||||
void set_offset(Periodic_2_offset_2 o);
|
||||
|
||||
/*!
|
||||
Sets the offset flag to `false` and clears the offset.
|
||||
*/
|
||||
void clear_offset();
|
||||
/*!
|
||||
Sets the offset flag to `false` and clears the offset.
|
||||
*/
|
||||
void clear_offset();
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ public:
|
|||
typedef typename Vb::Point Point;
|
||||
|
||||
template < typename Tds2 >
|
||||
struct Rebind_TDS {
|
||||
struct Rebind_TDS
|
||||
{
|
||||
typedef typename Vb::template Rebind_TDS<Tds2>::Other Vb2;
|
||||
typedef My_vertex_base<GT, Vb2> Other;
|
||||
};
|
||||
|
|
@ -34,11 +35,11 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
|||
typedef CGAL::Periodic_2_triangulation_filtered_traits_2<K> GT;
|
||||
|
||||
typedef CGAL::Periodic_2_triangulation_vertex_base_2<GT> VbDS;
|
||||
typedef My_vertex_base<GT,VbDS> Vb;
|
||||
typedef My_vertex_base<GT, VbDS> Vb;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<GT> Fb;
|
||||
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<GT,Tds> PDT;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<GT, Tds> PDT;
|
||||
|
||||
typedef PDT::Vertex_handle Vertex_handle;
|
||||
typedef PDT::Point Point;
|
||||
|
|
@ -47,12 +48,12 @@ int main()
|
|||
{
|
||||
PDT T;
|
||||
|
||||
Vertex_handle v0 = T.insert(Point(0,0));
|
||||
Vertex_handle v1 = T.insert(Point(.1,0));
|
||||
Vertex_handle v2 = T.insert(Point(0,.1));
|
||||
Vertex_handle v3 = T.insert(Point(0,0.2));
|
||||
Vertex_handle v4 = T.insert(Point(.2,.2));
|
||||
Vertex_handle v5 = T.insert(Point(.9,0));
|
||||
Vertex_handle v0 = T.insert(Point(0, 0));
|
||||
Vertex_handle v1 = T.insert(Point(.1, 0));
|
||||
Vertex_handle v2 = T.insert(Point(0, .1));
|
||||
Vertex_handle v3 = T.insert(Point(0, 0.2));
|
||||
Vertex_handle v4 = T.insert(Point(.2, .2));
|
||||
Vertex_handle v5 = T.insert(Point(.9, 0));
|
||||
|
||||
// Now we can link the vertices as we like.
|
||||
v0->vh = v1;
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ int main()
|
|||
{
|
||||
PDT T;
|
||||
|
||||
T.insert(Point(0,0));
|
||||
T.insert(Point(.1,0));
|
||||
T.insert(Point(0,.1));
|
||||
T.insert(Point(.2,.2));
|
||||
T.insert(Point(.9,0));
|
||||
T.insert(Point(0, 0));
|
||||
T.insert(Point(.1, 0));
|
||||
T.insert(Point(0, .1));
|
||||
T.insert(Point(.2, .2));
|
||||
T.insert(Point(.9, 0));
|
||||
|
||||
// Set the color of vertices with degree 6 to red.
|
||||
PDT::Vertex_iterator vit;
|
||||
|
|
|
|||
|
|
@ -18,32 +18,35 @@ int main()
|
|||
PDT T;
|
||||
|
||||
// Input point grid (27 points)
|
||||
for (double x=0. ; x < .9 ; x += 0.4) {
|
||||
for (double y=0. ; y < .9 ; y += 0.4) {
|
||||
T.insert(Point(x,y));
|
||||
}
|
||||
}
|
||||
for (double x = 0. ; x < .9 ; x += 0.4)
|
||||
{
|
||||
for (double y = 0. ; y < .9 ; y += 0.4)
|
||||
{
|
||||
T.insert(Point(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
Covering_sheets cs = T.number_of_sheets();
|
||||
std::cout<<"Current covering: "<<cs[0]<<' '<<cs[1]<<std::endl;
|
||||
|
||||
if ( T.is_triangulation_in_1_sheet() ) { // = true
|
||||
bool is_extensible = T.is_extensible_triangulation_in_1_sheet_h1()
|
||||
|| T.is_extensible_triangulation_in_1_sheet_h2(); // = false
|
||||
T.convert_to_1_sheeted_covering();
|
||||
cs = T.number_of_sheets();
|
||||
std::cout<<"Current covering: "<<cs[0]<<' '<<cs[1]<<std::endl;
|
||||
if ( is_extensible ) // = false
|
||||
std::cout<<"It is safe to change the triangulation here."<<std::endl;
|
||||
else
|
||||
std::cout<<"It is NOT safe to change the triangulation here!"<<std::endl;
|
||||
|
||||
T.convert_to_9_sheeted_covering();
|
||||
cs = T.number_of_sheets();
|
||||
std::cout<<"Current covering: "<<cs[0]<<' '<<cs[1]<<std::endl;
|
||||
}
|
||||
|
||||
std::cout<<"It is (again) safe to modify the triangulation."<<std::endl;
|
||||
|
||||
std::cout << "Current covering: " << cs[0] << ' ' << cs[1] << std::endl;
|
||||
|
||||
if ( T.is_triangulation_in_1_sheet() ) // = true
|
||||
{
|
||||
bool is_extensible = T.is_extensible_triangulation_in_1_sheet_h1()
|
||||
|| T.is_extensible_triangulation_in_1_sheet_h2(); // = false
|
||||
T.convert_to_1_sheeted_covering();
|
||||
cs = T.number_of_sheets();
|
||||
std::cout << "Current covering: " << cs[0] << ' ' << cs[1] << std::endl;
|
||||
if ( is_extensible ) // = false
|
||||
std::cout << "It is safe to change the triangulation here." << std::endl;
|
||||
else
|
||||
std::cout << "It is NOT safe to change the triangulation here!" << std::endl;
|
||||
|
||||
T.convert_to_9_sheeted_covering();
|
||||
cs = T.number_of_sheets();
|
||||
std::cout << "Current covering: " << cs[0] << ' ' << cs[1] << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "It is (again) safe to modify the triangulation." << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,34 +16,35 @@ typedef Delaunay::Face_handle Face_handle;
|
|||
int main()
|
||||
{
|
||||
Delaunay T;
|
||||
CGAL::Random_points_in_iso_rectangle_2<Point> rnd(Point(0,0), Point(1,1));
|
||||
CGAL::Random_points_in_iso_rectangle_2<Point> rnd(Point(0, 0), Point(1, 1));
|
||||
|
||||
// First, make sure the triangulation is 2D.
|
||||
T.insert(Point(0,0));
|
||||
T.insert(Point(.1,0));
|
||||
T.insert(Point(0,.1));
|
||||
T.insert(Point(0, 0));
|
||||
T.insert(Point(.1, 0));
|
||||
T.insert(Point(0, .1));
|
||||
|
||||
// Gets the conflict region of 100 random points
|
||||
// in the Delaunay tetrahedralization
|
||||
for (int i = 0; i != 100; ++i) {
|
||||
Point p = (*rnd++);
|
||||
for (int i = 0; i != 100; ++i)
|
||||
{
|
||||
Point p = (*rnd++);
|
||||
|
||||
// Locate the point
|
||||
Delaunay::Locate_type lt;
|
||||
int li;
|
||||
Face_handle f = T.locate(p, lt, li);
|
||||
if (lt == Delaunay::VERTEX)
|
||||
continue; // Point already exists
|
||||
// Locate the point
|
||||
Delaunay::Locate_type lt;
|
||||
int li;
|
||||
Face_handle f = T.locate(p, lt, li);
|
||||
if (lt == Delaunay::VERTEX)
|
||||
continue; // Point already exists
|
||||
|
||||
// Get the cells that conflict with p in a vector V,
|
||||
// and a facet on the boundary of this hole in f.
|
||||
std::vector<Face_handle> V;
|
||||
// Get the cells that conflict with p in a vector V,
|
||||
// and a facet on the boundary of this hole in f.
|
||||
std::vector<Face_handle> V;
|
||||
|
||||
T.get_conflicts(p,
|
||||
std::back_inserter(V), // Conflict cells in V
|
||||
f);
|
||||
}
|
||||
|
||||
T.get_conflicts(p,
|
||||
std::back_inserter(V), // Conflict cells in V
|
||||
f);
|
||||
}
|
||||
|
||||
std::cout << "Final triangulation has " << T.number_of_vertices()
|
||||
<< " vertices." << std::endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ typedef P2DT2::Periodic_triangle Periodic_triangle;
|
|||
typedef P2DT2::Periodic_triangle_iterator Periodic_triangle_iterator;
|
||||
typedef P2DT2::Iterator_type Iterator_type;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
P2DT2 T;
|
||||
|
||||
T.insert(Point(0, 0));
|
||||
|
|
@ -22,17 +23,19 @@ int main() {
|
|||
|
||||
Periodic_triangle pt;
|
||||
Triangle t_bd;
|
||||
|
||||
|
||||
// Extracting the triangles that have a non-empty intersection with
|
||||
// the original domain of the 1-sheeted covering space
|
||||
for (Periodic_triangle_iterator ptit = T.periodic_triangles_begin(P2DT2::UNIQUE_COVER_DOMAIN);
|
||||
ptit != T.periodic_triangles_end(P2DT2::UNIQUE_COVER_DOMAIN); ++ptit) {
|
||||
pt = *ptit;
|
||||
if (! (pt[0].second.is_null() && pt[1].second.is_null() && pt[2].second.is_null()) ) {
|
||||
// Convert the current Periodic_triangle to a Triangle if it is
|
||||
// not strictly contained inside the original domain.
|
||||
// Note that this requires EXACT constructions to be exact!
|
||||
t_bd = T.triangle(pt);
|
||||
ptit != T.periodic_triangles_end(P2DT2::UNIQUE_COVER_DOMAIN); ++ptit)
|
||||
{
|
||||
pt = *ptit;
|
||||
if (! (pt[0].second.is_null() && pt[1].second.is_null() && pt[2].second.is_null()) )
|
||||
{
|
||||
// Convert the current Periodic_triangle to a Triangle if it is
|
||||
// not strictly contained inside the original domain.
|
||||
// Note that this requires EXACT constructions to be exact!
|
||||
t_bd = T.triangle(pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,17 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
|||
typedef CGAL::Triangulation_vertex_base_2<K> Vbb;
|
||||
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbb> Vb;
|
||||
typedef CGAL::Triangulation_face_base_2<K> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
typedef CGAL::Delaunay_triangulation_2<K,Tds> Dt;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
|
||||
typedef CGAL::Delaunay_triangulation_2<K, Tds> Dt;
|
||||
typedef CGAL::Triangulation_hierarchy_2<Dt> Triangulation;
|
||||
typedef Triangulation::Point Point;
|
||||
typedef CGAL::Creator_uniform_2<double,Point> Creator;
|
||||
typedef CGAL::Creator_uniform_2<double, Point> Creator;
|
||||
|
||||
int main( )
|
||||
{
|
||||
std::cout << "insertion of 1000 random points" << std::endl;
|
||||
Triangulation t;
|
||||
CGAL::Random_points_in_square_2<Point,Creator> g(1.);
|
||||
CGAL::Random_points_in_square_2<Point, Creator> g(1.);
|
||||
CGAL::cpp11::copy_n( g, 1000, std::back_inserter(t));
|
||||
|
||||
//verbose mode of is_valid ; shows the number of vertices at each level
|
||||
|
|
|
|||
|
|
@ -8,32 +8,33 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
|||
typedef CGAL::Periodic_2_triangulation_traits_2<K> Gt;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, Gt> Vb;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<Gt> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt, Tds> Delaunay;
|
||||
typedef Delaunay::Point Point;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector< std::pair<Point,unsigned> > points;
|
||||
points.push_back( std::make_pair(Point(0.0,0.0), 0) );
|
||||
points.push_back( std::make_pair(Point(0.1,0.0), 1) );
|
||||
points.push_back( std::make_pair(Point(0.0,0.1), 2) );
|
||||
points.push_back( std::make_pair(Point(0.1,0.4), 3) );
|
||||
points.push_back( std::make_pair(Point(0.2,0.2), 4) );
|
||||
points.push_back( std::make_pair(Point(0.4,0.0), 5) );
|
||||
std::vector< std::pair<Point, unsigned> > points;
|
||||
points.push_back( std::make_pair(Point(0.0, 0.0), 0) );
|
||||
points.push_back( std::make_pair(Point(0.1, 0.0), 1) );
|
||||
points.push_back( std::make_pair(Point(0.0, 0.1), 2) );
|
||||
points.push_back( std::make_pair(Point(0.1, 0.4), 3) );
|
||||
points.push_back( std::make_pair(Point(0.2, 0.2), 4) );
|
||||
points.push_back( std::make_pair(Point(0.4, 0.0), 5) );
|
||||
|
||||
Delaunay T;
|
||||
T.insert( points.begin(),points.end() );
|
||||
T.insert( points.begin(), points.end() );
|
||||
|
||||
CGAL_assertion( T.number_of_vertices() == 6 );
|
||||
|
||||
// check that the info was correctly set.
|
||||
Delaunay::Finite_vertices_iterator vit;
|
||||
for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
|
||||
if( points[ vit->info() ].first != vit->point() ){
|
||||
std::cerr << "Error different info" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if( points[ vit->info() ].first != vit->point() )
|
||||
{
|
||||
std::cerr << "Error different info" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
std::cout << "OK" << std::endl;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -8,45 +8,48 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
|||
typedef CGAL::Periodic_2_triangulation_traits_2<K> Gt;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, Gt> Vb;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<Gt> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt, Tds> Delaunay;
|
||||
typedef Delaunay::Point Point;
|
||||
|
||||
//a functor that returns a std::pair<Point,unsigned>.
|
||||
//the unsigned integer is incremented at each call to
|
||||
//the unsigned integer is incremented at each call to
|
||||
//operator()
|
||||
struct Auto_count : public std::unary_function<const Point&,std::pair<Point,unsigned> >{
|
||||
struct Auto_count : public std::unary_function<const Point&, std::pair<Point, unsigned> >
|
||||
{
|
||||
mutable unsigned i;
|
||||
Auto_count() : i(0){}
|
||||
std::pair<Point,unsigned> operator()(const Point& p) const {
|
||||
return std::make_pair(p,i++);
|
||||
Auto_count() : i(0) {}
|
||||
std::pair<Point, unsigned> operator()(const Point& p) const
|
||||
{
|
||||
return std::make_pair(p, i++);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<Point> points;
|
||||
points.push_back( Point(0.0,0.0) );
|
||||
points.push_back( Point(0.1,0.0) );
|
||||
points.push_back( Point(0.0,0.1) );
|
||||
points.push_back( Point(0.1,0.4) );
|
||||
points.push_back( Point(0.2,0.2) );
|
||||
points.push_back( Point(0.4,0.0) );
|
||||
points.push_back( Point(0.0, 0.0) );
|
||||
points.push_back( Point(0.1, 0.0) );
|
||||
points.push_back( Point(0.0, 0.1) );
|
||||
points.push_back( Point(0.1, 0.4) );
|
||||
points.push_back( Point(0.2, 0.2) );
|
||||
points.push_back( Point(0.4, 0.0) );
|
||||
|
||||
Delaunay T;
|
||||
T.insert( boost::make_transform_iterator(points.begin(),Auto_count()),
|
||||
T.insert( boost::make_transform_iterator(points.begin(), Auto_count()),
|
||||
boost::make_transform_iterator(points.end(), Auto_count() ) );
|
||||
|
||||
CGAL_assertion( T.number_of_vertices() == 6 );
|
||||
|
||||
|
||||
// check that the info was correctly set.
|
||||
Delaunay::Finite_vertices_iterator vit;
|
||||
for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
|
||||
if( points[ vit->info() ] != vit->point() ){
|
||||
std::cerr << "Error different info" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if( points[ vit->info() ] != vit->point() )
|
||||
{
|
||||
std::cerr << "Error different info" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
std::cout << "OK" << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
|||
typedef CGAL::Periodic_2_triangulation_traits_2<K> Gt;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, Gt> Vb;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<Gt> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt, Tds> Delaunay;
|
||||
typedef Delaunay::Point Point;
|
||||
|
||||
|
|
@ -21,30 +21,31 @@ int main()
|
|||
indices.push_back(2);
|
||||
indices.push_back(3);
|
||||
indices.push_back(4);
|
||||
indices.push_back(5);
|
||||
|
||||
indices.push_back(5);
|
||||
|
||||
std::vector<Point> points;
|
||||
points.push_back( Point(0.0,0.0) );
|
||||
points.push_back( Point(0.1,0.0) );
|
||||
points.push_back( Point(0.0,0.1) );
|
||||
points.push_back( Point(0.1,0.4) );
|
||||
points.push_back( Point(0.2,0.2) );
|
||||
points.push_back( Point(0.4,0.0) );
|
||||
points.push_back( Point(0.0, 0.0) );
|
||||
points.push_back( Point(0.1, 0.0) );
|
||||
points.push_back( Point(0.0, 0.1) );
|
||||
points.push_back( Point(0.1, 0.4) );
|
||||
points.push_back( Point(0.2, 0.2) );
|
||||
points.push_back( Point(0.4, 0.0) );
|
||||
|
||||
Delaunay T;
|
||||
T.insert( boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )),
|
||||
boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) );
|
||||
T.insert( boost::make_zip_iterator(boost::make_tuple( points.begin(), indices.begin() )),
|
||||
boost::make_zip_iterator(boost::make_tuple( points.end(), indices.end() ) ) );
|
||||
|
||||
CGAL_assertion( T.number_of_vertices() == 6 );
|
||||
|
||||
|
||||
|
||||
|
||||
// check that the info was correctly set.
|
||||
Delaunay::Finite_vertices_iterator vit;
|
||||
for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
|
||||
if( points[ vit->info() ] != vit->point() ){
|
||||
std::cerr << "Error different info" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if( points[ vit->info() ] != vit->point() )
|
||||
{
|
||||
std::cerr << "Error different info" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
std::cout << "OK" << std::endl;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -29,33 +29,35 @@ int main()
|
|||
PDT PT1, PT2, PT3;
|
||||
|
||||
// Generating n random points
|
||||
for (int i=0 ; i < n ; i++) {
|
||||
Point p = *in_square;
|
||||
in_square++;
|
||||
pts.push_back(Point(p.x()+.5, p.y()+.5));
|
||||
}
|
||||
for (int i = 0 ; i < n ; i++)
|
||||
{
|
||||
Point p = *in_square;
|
||||
in_square++;
|
||||
pts.push_back(Point(p.x() + .5, p.y() + .5));
|
||||
}
|
||||
|
||||
// Standard insertion
|
||||
t.start();
|
||||
for (int i=0 ; i < n ; i++) {
|
||||
PT1.insert(pts[i]);
|
||||
}
|
||||
for (int i = 0 ; i < n ; i++)
|
||||
{
|
||||
PT1.insert(pts[i]);
|
||||
}
|
||||
t.stop();
|
||||
std::cout<<" Time: "<<t.time()<<" sec. (Standard insertion)"<<std::endl;
|
||||
std::cout << " Time: " << t.time() << " sec. (Standard insertion)" << std::endl;
|
||||
t.reset();
|
||||
|
||||
// Iterator range insertion using spatial sorting but no dummy points
|
||||
t.start();
|
||||
PT2.insert(pts.begin(), pts.end()); // third parameter defaults to false
|
||||
t.stop();
|
||||
std::cout<<" Time: "<<t.time()<<" sec. (with spatial sorting)"<<std::endl;
|
||||
std::cout << " Time: " << t.time() << " sec. (with spatial sorting)" << std::endl;
|
||||
t.reset();
|
||||
|
||||
// Iterator range insertion using spatial sorting and dummy point heuristic
|
||||
t.start();
|
||||
PT3.insert(pts.begin(), pts.end(), true);
|
||||
t.stop();
|
||||
std::cout<<" Time: "<<t.time()<<" sec. (Dummy point heuristic)"<<std::endl;
|
||||
std::cout << " Time: " << t.time() << " sec. (Dummy point heuristic)" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ typedef PDT::Iso_rectangle Iso_rectangle;
|
|||
|
||||
int main()
|
||||
{
|
||||
Iso_rectangle domain(-1,-1,2,2); // The cube for the periodic domain
|
||||
Iso_rectangle domain(-1, -1, 2, 2); // The cube for the periodic domain
|
||||
|
||||
// construction from a list of points :
|
||||
std::list<Point> L;
|
||||
L.push_front(Point(0,0));
|
||||
L.push_front(Point(1,0));
|
||||
L.push_front(Point(0,1));
|
||||
L.push_front(Point(0, 0));
|
||||
L.push_front(Point(1, 0));
|
||||
L.push_front(Point(0, 1));
|
||||
|
||||
PDT T(L.begin(), L.end(), domain); // Put the domain with the constructor
|
||||
|
||||
|
|
@ -35,9 +35,9 @@ int main()
|
|||
|
||||
// insertion from a vector :
|
||||
std::vector<Point> V(3);
|
||||
V[0] = Point(0,0);
|
||||
V[1] = Point(1,1);
|
||||
V[2] = Point(-1,-1);
|
||||
V[0] = Point(0, 0);
|
||||
V[1] = Point(1, 1);
|
||||
V[2] = Point(-1, -1);
|
||||
|
||||
n = n + T.insert(V.begin(), V.end());
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ int main()
|
|||
|
||||
Locate_type lt;
|
||||
int li;
|
||||
Point p(0,0);
|
||||
Point p(0, 0);
|
||||
Face_handle fh = T.locate(p, lt, li);
|
||||
// p is the vertex of c of index li :
|
||||
assert( lt == PDT::VERTEX );
|
||||
assert( fh->vertex(li)->point() == p );
|
||||
|
||||
Vertex_handle v = fh->vertex( (li+1)&3 );
|
||||
Vertex_handle v = fh->vertex( (li + 1) & 3 );
|
||||
// v is another vertex of c
|
||||
Face_handle nb = fh->neighbor(li);
|
||||
// nb = neighbor of fh opposite to the vertex associated with p
|
||||
|
|
@ -61,14 +61,14 @@ int main()
|
|||
assert( nb->has_vertex( v, nli ) );
|
||||
// nli is the index of v in nc
|
||||
|
||||
std::ofstream oFileT("output.tri",std::ios::out);
|
||||
// writing file output;
|
||||
oFileT << T;
|
||||
std::ofstream oFileT("output.tri", std::ios::out);
|
||||
// writing file output;
|
||||
oFileT << T;
|
||||
|
||||
PDT T1;
|
||||
std::ifstream iFileT("output.tri",std::ios::in);
|
||||
// reading file output;
|
||||
iFileT >> T1;
|
||||
std::ifstream iFileT("output.tri", std::ios::in);
|
||||
// reading file output;
|
||||
iFileT >> T1;
|
||||
assert( T1.is_valid() );
|
||||
assert( T1.number_of_vertices() == T.number_of_vertices() );
|
||||
assert( T1.number_of_faces() == T.number_of_faces() );
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// $URL: svn+ssh://cgal/svn/cgal/branches/experimental-packages/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_traits_2.h $
|
||||
// $Id: Periodic_2_triangulation_traits_2.h 60448 2010-12-21 15:40:31Z nicokruithof $
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
|
@ -22,13 +22,15 @@
|
|||
|
||||
#include <CGAL/Periodic_2_Delaunay_triangulation_traits_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/// The Periodic_2_Delaunay_triangulation_traits_2 is equal to
|
||||
/// Periodic_2_triangulation_traits_2
|
||||
template < typename K, typename Off = CGAL::Periodic_2_offset_2 >
|
||||
class Periodic_2_Delaunay_triangulation_traits_2 :
|
||||
public Periodic_2_triangulation_traits_2<K, Off> {
|
||||
public Periodic_2_triangulation_traits_2<K, Off>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
|
@ -24,14 +24,16 @@
|
|||
#include <CGAL/triangulation_assertions.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
/// The class Periodic_2_offset_2 is a model of the concept Periodic_2Offset_2.
|
||||
class Periodic_2_offset_2 {
|
||||
class Periodic_2_offset_2
|
||||
{
|
||||
// template <class K2>
|
||||
// friend std::ostream & operator<<(std::ostream &os,
|
||||
// friend std::ostream & operator<<(std::ostream &os,
|
||||
// const Periodic_2_offset_2 &off);
|
||||
|
||||
|
||||
public:
|
||||
/// Default constructor.
|
||||
Periodic_2_offset_2() : _offx(0), _offy(0) {}
|
||||
|
|
@ -39,109 +41,139 @@ public:
|
|||
Periodic_2_offset_2(int x, int y) : _offx(x), _offy(y) {}
|
||||
|
||||
/// Returns true if o is equal to (0,0).
|
||||
inline bool is_null() const {
|
||||
inline bool is_null() const
|
||||
{
|
||||
return is_zero();
|
||||
}
|
||||
/// Returns true if o is equal to (0,0).
|
||||
inline bool is_zero() const {
|
||||
inline bool is_zero() const
|
||||
{
|
||||
return ((_offx | _offy) == 0);
|
||||
}
|
||||
|
||||
/// Return the x-entry of o.
|
||||
int& x() { return _offx; }
|
||||
int& x()
|
||||
{
|
||||
return _offx;
|
||||
}
|
||||
/// Return the x-entry of o.
|
||||
int x() const { return _offx; }
|
||||
int x() const
|
||||
{
|
||||
return _offx;
|
||||
}
|
||||
/// Return the y-entry of o.
|
||||
int& y() { return _offy; }
|
||||
int& y()
|
||||
{
|
||||
return _offy;
|
||||
}
|
||||
/// Return the y-entry of o.
|
||||
int y() const { return _offy; }
|
||||
int y() const
|
||||
{
|
||||
return _offy;
|
||||
}
|
||||
|
||||
/// Return the i-th entry of o.
|
||||
int &operator[](int i) {
|
||||
if (i==0) return _offx;
|
||||
CGAL_triangulation_assertion(i==1);
|
||||
int &operator[](int i)
|
||||
{
|
||||
if (i == 0) return _offx;
|
||||
CGAL_triangulation_assertion(i == 1);
|
||||
return _offy;
|
||||
}
|
||||
/// Return the i-th entry of o.
|
||||
int operator[](int i) const {
|
||||
if (i==0) return _offx;
|
||||
CGAL_triangulation_assertion(i==1);
|
||||
int operator[](int i) const
|
||||
{
|
||||
if (i == 0) return _offx;
|
||||
CGAL_triangulation_assertion(i == 1);
|
||||
return _offy;
|
||||
}
|
||||
/// Add o' to o using vector addition.
|
||||
void operator+=(const Periodic_2_offset_2 &other) {
|
||||
void operator+=(const Periodic_2_offset_2 &other)
|
||||
{
|
||||
_offx += other._offx;
|
||||
_offy += other._offy;
|
||||
}
|
||||
/// Subtract o' from o using vector subtraction.
|
||||
void operator-=(const Periodic_2_offset_2 &other) {
|
||||
void operator-=(const Periodic_2_offset_2 &other)
|
||||
{
|
||||
_offx -= other._offx;
|
||||
_offy -= other._offy;
|
||||
}
|
||||
/// Return the negative vector of o.
|
||||
Periodic_2_offset_2 operator-() const {
|
||||
return Periodic_2_offset_2(-_offx,-_offy);
|
||||
Periodic_2_offset_2 operator-() const
|
||||
{
|
||||
return Periodic_2_offset_2(-_offx, -_offy);
|
||||
}
|
||||
/// Return true if o' and o represent the same vector.
|
||||
bool operator==(const Periodic_2_offset_2 &other) const {
|
||||
bool operator==(const Periodic_2_offset_2 &other) const
|
||||
{
|
||||
return ((_offx == other._offx) &&
|
||||
(_offy == other._offy));
|
||||
(_offy == other._offy));
|
||||
}
|
||||
/// Return true if o' and o do not represent the same vector.
|
||||
bool operator!=(const Periodic_2_offset_2 &other) const {
|
||||
bool operator!=(const Periodic_2_offset_2 &other) const
|
||||
{
|
||||
return ((_offx != other._offx) ||
|
||||
(_offy != other._offy));
|
||||
(_offy != other._offy));
|
||||
}
|
||||
/// Compare o and o' lexicographically.
|
||||
bool operator<(const Periodic_2_offset_2 &other) const {
|
||||
bool operator<(const Periodic_2_offset_2 &other) const
|
||||
{
|
||||
if (_offx != other._offx)
|
||||
return (_offx < other._offx);
|
||||
else {
|
||||
return (_offy < other._offy);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (_offy < other._offy);
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the vector sum of o and o'.
|
||||
Periodic_2_offset_2 operator+(const Periodic_2_offset_2 &off2) const {
|
||||
return Periodic_2_offset_2(_offx+off2.x(), _offy+off2.y());
|
||||
Periodic_2_offset_2 operator+(const Periodic_2_offset_2 &off2) const
|
||||
{
|
||||
return Periodic_2_offset_2(_offx + off2.x(), _offy + off2.y());
|
||||
}
|
||||
/// Return the vector difference of o and o'.
|
||||
Periodic_2_offset_2 operator-(const Periodic_2_offset_2 &off2) const {
|
||||
return Periodic_2_offset_2(_offx-off2.x(), _offy-off2.y());
|
||||
Periodic_2_offset_2 operator-(const Periodic_2_offset_2 &off2) const
|
||||
{
|
||||
return Periodic_2_offset_2(_offx - off2.x(), _offy - off2.y());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
int _offx, _offy;
|
||||
};
|
||||
|
||||
template <class K>
|
||||
inline Point_3<K> operator+(const Point_3<K> &p, const Periodic_2_offset_2 &off) {
|
||||
return (off.is_null() ? p : Point_3<K>(p.x()+off.x(), p.y()+off.y()));
|
||||
inline Point_3<K> operator+(const Point_3<K> &p, const Periodic_2_offset_2 &off)
|
||||
{
|
||||
return (off.is_null() ? p : Point_3<K>(p.x() + off.x(), p.y() + off.y()));
|
||||
}
|
||||
|
||||
/// Inputs an Periodic_2_offset_2 from is.
|
||||
inline std::ostream
|
||||
&operator<<(std::ostream &os, const Periodic_2_offset_2 &off) {
|
||||
inline std::ostream
|
||||
&operator<<(std::ostream &os, const Periodic_2_offset_2 &off)
|
||||
{
|
||||
if (is_ascii(os))
|
||||
os << off.x() << " " << off.y();
|
||||
else {
|
||||
write(os,off.x());
|
||||
write(os,off.y());
|
||||
}
|
||||
else
|
||||
{
|
||||
write(os, off.x());
|
||||
write(os, off.y());
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
/// Outputs an Periodic_2_offset_2 to os.
|
||||
inline std::istream
|
||||
&operator>>(std::istream &is, Periodic_2_offset_2 &off) {
|
||||
int x=0,y=0;
|
||||
&operator>>(std::istream &is, Periodic_2_offset_2 &off)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
if (is_ascii(is))
|
||||
is >> x >> y;
|
||||
else {
|
||||
read(is,x);
|
||||
read(is,y);
|
||||
}
|
||||
off = Periodic_2_offset_2(x,y);
|
||||
else
|
||||
{
|
||||
read(is, x);
|
||||
read(is, y);
|
||||
}
|
||||
off = Periodic_2_offset_2(x, y);
|
||||
return is;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
|
@ -22,116 +22,120 @@
|
|||
#define CGAL_PERIODIC_2_TRIANGULATION_DUMMY_12_H
|
||||
|
||||
template < class GT, class Tds >
|
||||
inline std::vector<typename Periodic_2_triangulation_2<GT,Tds>::Vertex_handle >
|
||||
Periodic_2_triangulation_2<GT,Tds>::insert_dummy_points() {
|
||||
inline std::vector<typename Periodic_2_triangulation_2<GT, Tds>::Vertex_handle >
|
||||
Periodic_2_triangulation_2<GT, Tds>::insert_dummy_points()
|
||||
{
|
||||
clear();
|
||||
|
||||
Vertex_handle vertices[12];
|
||||
// 6 faces per row, 4 rows
|
||||
Face_handle faces[24];
|
||||
|
||||
|
||||
// Initialise vertices:
|
||||
for (int i=0; i<4; i++) {
|
||||
for (int j=0; j<3; j++) {
|
||||
// Initialise virtual vertices out of the domain for debugging
|
||||
vertices[3*i+j] = _tds.create_vertex();
|
||||
Point p(j*(1.0/3.0) + i*(1.0/6.0), i*(1.0/4.0) );
|
||||
p = Point((p.x() > FT(0.9375) ? (std::max)( p.x()-1, FT(0) ) : p.x()),
|
||||
p.y());
|
||||
p = Point((_domain.xmax()-_domain.xmin())*p.x(),
|
||||
(_domain.xmax()-_domain.xmin())*p.y());
|
||||
p = Point(p.x() + _domain.xmin(),
|
||||
p.y() + _domain.ymin());
|
||||
vertices[3*i+j]->set_point(p);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
// Initialise virtual vertices out of the domain for debugging
|
||||
vertices[3 * i + j] = _tds.create_vertex();
|
||||
Point p(j * (1.0 / 3.0) + i * (1.0 / 6.0), i * (1.0 / 4.0) );
|
||||
p = Point((p.x() > FT(0.9375) ? (std::max)( p.x() - 1, FT(0) ) : p.x()),
|
||||
p.y());
|
||||
p = Point((_domain.xmax() - _domain.xmin()) * p.x(),
|
||||
(_domain.xmax() - _domain.xmin()) * p.y());
|
||||
p = Point(p.x() + _domain.xmin(),
|
||||
p.y() + _domain.ymin());
|
||||
vertices[3 * i + j]->set_point(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create faces:
|
||||
for (int i=0; i<24; i++) {
|
||||
faces[i] = _tds.create_face();
|
||||
}
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
faces[i] = _tds.create_face();
|
||||
}
|
||||
|
||||
// bottom row
|
||||
faces[0]->set_vertices(vertices[0],vertices[1],vertices[3]);
|
||||
faces[1]->set_vertices(vertices[1],vertices[2],vertices[4]);
|
||||
faces[2]->set_vertices(vertices[2],vertices[0],vertices[5]);
|
||||
faces[3]->set_vertices(vertices[0],vertices[3],vertices[5]);
|
||||
faces[4]->set_vertices(vertices[1],vertices[4],vertices[3]);
|
||||
faces[5]->set_vertices(vertices[2],vertices[5],vertices[4]);
|
||||
faces[0]->set_vertices(vertices[0], vertices[1], vertices[3]);
|
||||
faces[1]->set_vertices(vertices[1], vertices[2], vertices[4]);
|
||||
faces[2]->set_vertices(vertices[2], vertices[0], vertices[5]);
|
||||
faces[3]->set_vertices(vertices[0], vertices[3], vertices[5]);
|
||||
faces[4]->set_vertices(vertices[1], vertices[4], vertices[3]);
|
||||
faces[5]->set_vertices(vertices[2], vertices[5], vertices[4]);
|
||||
// second row
|
||||
faces[6]->set_vertices(vertices[3],vertices[4],vertices[6]);
|
||||
faces[7]->set_vertices(vertices[4],vertices[5],vertices[7]);
|
||||
faces[8]->set_vertices(vertices[5],vertices[3],vertices[8]);
|
||||
faces[9]->set_vertices(vertices[3],vertices[6],vertices[8]);
|
||||
faces[10]->set_vertices(vertices[4],vertices[7],vertices[6]);
|
||||
faces[11]->set_vertices(vertices[5],vertices[8],vertices[7]);
|
||||
faces[6]->set_vertices(vertices[3], vertices[4], vertices[6]);
|
||||
faces[7]->set_vertices(vertices[4], vertices[5], vertices[7]);
|
||||
faces[8]->set_vertices(vertices[5], vertices[3], vertices[8]);
|
||||
faces[9]->set_vertices(vertices[3], vertices[6], vertices[8]);
|
||||
faces[10]->set_vertices(vertices[4], vertices[7], vertices[6]);
|
||||
faces[11]->set_vertices(vertices[5], vertices[8], vertices[7]);
|
||||
// third row
|
||||
faces[12]->set_vertices(vertices[6],vertices[7],vertices[9]);
|
||||
faces[13]->set_vertices(vertices[7],vertices[8],vertices[10]);
|
||||
faces[14]->set_vertices(vertices[8],vertices[6],vertices[11]);
|
||||
faces[15]->set_vertices(vertices[6],vertices[9],vertices[11]);
|
||||
faces[16]->set_vertices(vertices[7],vertices[10],vertices[9]);
|
||||
faces[17]->set_vertices(vertices[8],vertices[11],vertices[10]);
|
||||
faces[12]->set_vertices(vertices[6], vertices[7], vertices[9]);
|
||||
faces[13]->set_vertices(vertices[7], vertices[8], vertices[10]);
|
||||
faces[14]->set_vertices(vertices[8], vertices[6], vertices[11]);
|
||||
faces[15]->set_vertices(vertices[6], vertices[9], vertices[11]);
|
||||
faces[16]->set_vertices(vertices[7], vertices[10], vertices[9]);
|
||||
faces[17]->set_vertices(vertices[8], vertices[11], vertices[10]);
|
||||
// fourth row
|
||||
faces[18]->set_vertices(vertices[9],vertices[10],vertices[2]);
|
||||
faces[19]->set_vertices(vertices[10],vertices[11],vertices[0]);
|
||||
faces[20]->set_vertices(vertices[11],vertices[9],vertices[1]);
|
||||
faces[21]->set_vertices(vertices[9],vertices[2],vertices[1]);
|
||||
faces[22]->set_vertices(vertices[10],vertices[0],vertices[2]);
|
||||
faces[23]->set_vertices(vertices[11],vertices[1],vertices[0]);
|
||||
faces[18]->set_vertices(vertices[9], vertices[10], vertices[2]);
|
||||
faces[19]->set_vertices(vertices[10], vertices[11], vertices[0]);
|
||||
faces[20]->set_vertices(vertices[11], vertices[9], vertices[1]);
|
||||
faces[21]->set_vertices(vertices[9], vertices[2], vertices[1]);
|
||||
faces[22]->set_vertices(vertices[10], vertices[0], vertices[2]);
|
||||
faces[23]->set_vertices(vertices[11], vertices[1], vertices[0]);
|
||||
|
||||
faces[0]->set_neighbors(faces[4],faces[3],faces[23]);
|
||||
faces[1]->set_neighbors(faces[5],faces[4],faces[21]);
|
||||
faces[2]->set_neighbors(faces[3],faces[5],faces[22]);
|
||||
faces[3]->set_neighbors(faces[8],faces[2],faces[0]);
|
||||
faces[4]->set_neighbors(faces[6],faces[0],faces[1]);
|
||||
faces[5]->set_neighbors(faces[7],faces[1],faces[2]);
|
||||
faces[0]->set_neighbors(faces[4], faces[3], faces[23]);
|
||||
faces[1]->set_neighbors(faces[5], faces[4], faces[21]);
|
||||
faces[2]->set_neighbors(faces[3], faces[5], faces[22]);
|
||||
faces[3]->set_neighbors(faces[8], faces[2], faces[0]);
|
||||
faces[4]->set_neighbors(faces[6], faces[0], faces[1]);
|
||||
faces[5]->set_neighbors(faces[7], faces[1], faces[2]);
|
||||
|
||||
faces[6]->set_neighbors(faces[10],faces[9],faces[4]);
|
||||
faces[7]->set_neighbors(faces[11],faces[10],faces[5]);
|
||||
faces[8]->set_neighbors(faces[9],faces[11],faces[3]);
|
||||
faces[9]->set_neighbors(faces[14],faces[8],faces[6]);
|
||||
faces[10]->set_neighbors(faces[12],faces[6],faces[7]);
|
||||
faces[11]->set_neighbors(faces[13],faces[7],faces[8]);
|
||||
faces[6]->set_neighbors(faces[10], faces[9], faces[4]);
|
||||
faces[7]->set_neighbors(faces[11], faces[10], faces[5]);
|
||||
faces[8]->set_neighbors(faces[9], faces[11], faces[3]);
|
||||
faces[9]->set_neighbors(faces[14], faces[8], faces[6]);
|
||||
faces[10]->set_neighbors(faces[12], faces[6], faces[7]);
|
||||
faces[11]->set_neighbors(faces[13], faces[7], faces[8]);
|
||||
|
||||
faces[12]->set_neighbors(faces[16],faces[15],faces[10]);
|
||||
faces[13]->set_neighbors(faces[17],faces[16],faces[11]);
|
||||
faces[14]->set_neighbors(faces[15],faces[17],faces[9]);
|
||||
faces[15]->set_neighbors(faces[20],faces[14],faces[12]);
|
||||
faces[16]->set_neighbors(faces[18],faces[12],faces[13]);
|
||||
faces[17]->set_neighbors(faces[19],faces[13],faces[14]);
|
||||
faces[12]->set_neighbors(faces[16], faces[15], faces[10]);
|
||||
faces[13]->set_neighbors(faces[17], faces[16], faces[11]);
|
||||
faces[14]->set_neighbors(faces[15], faces[17], faces[9]);
|
||||
faces[15]->set_neighbors(faces[20], faces[14], faces[12]);
|
||||
faces[16]->set_neighbors(faces[18], faces[12], faces[13]);
|
||||
faces[17]->set_neighbors(faces[19], faces[13], faces[14]);
|
||||
|
||||
faces[18]->set_neighbors(faces[22],faces[21],faces[16]);
|
||||
faces[19]->set_neighbors(faces[23],faces[22],faces[17]);
|
||||
faces[20]->set_neighbors(faces[21],faces[23],faces[15]);
|
||||
faces[21]->set_neighbors(faces[1],faces[20],faces[18]);
|
||||
faces[22]->set_neighbors(faces[2],faces[18],faces[19]);
|
||||
faces[23]->set_neighbors(faces[0],faces[19],faces[20]);
|
||||
faces[18]->set_neighbors(faces[22], faces[21], faces[16]);
|
||||
faces[19]->set_neighbors(faces[23], faces[22], faces[17]);
|
||||
faces[20]->set_neighbors(faces[21], faces[23], faces[15]);
|
||||
faces[21]->set_neighbors(faces[1], faces[20], faces[18]);
|
||||
faces[22]->set_neighbors(faces[2], faces[18], faces[19]);
|
||||
faces[23]->set_neighbors(faces[0], faces[19], faces[20]);
|
||||
|
||||
set_offsets(faces[0],0,0,0);
|
||||
set_offsets(faces[1],0,0,0);
|
||||
set_offsets(faces[2],0,2,0);
|
||||
set_offsets(faces[3],2,2,0);
|
||||
set_offsets(faces[4],0,0,0);
|
||||
set_offsets(faces[5],0,0,0);
|
||||
set_offsets(faces[6],0,0,0);
|
||||
set_offsets(faces[7],0,0,0);
|
||||
set_offsets(faces[8],0,2,2);
|
||||
set_offsets(faces[9],0,0,0);
|
||||
set_offsets(faces[10],0,0,0);
|
||||
set_offsets(faces[11],0,2,0);
|
||||
set_offsets(faces[12],0,0,0);
|
||||
set_offsets(faces[13],0,2,0);
|
||||
set_offsets(faces[14],0,0,0);
|
||||
set_offsets(faces[15],0,0,0);
|
||||
set_offsets(faces[16],0,0,0);
|
||||
set_offsets(faces[17],2,2,0);
|
||||
set_offsets(faces[18],0,0,1);
|
||||
set_offsets(faces[19],0,2,3);
|
||||
set_offsets(faces[20],0,0,1);
|
||||
set_offsets(faces[21],0,1,1);
|
||||
set_offsets(faces[22],0,3,1);
|
||||
set_offsets(faces[23],0,1,1);
|
||||
set_offsets(faces[0], 0, 0, 0);
|
||||
set_offsets(faces[1], 0, 0, 0);
|
||||
set_offsets(faces[2], 0, 2, 0);
|
||||
set_offsets(faces[3], 2, 2, 0);
|
||||
set_offsets(faces[4], 0, 0, 0);
|
||||
set_offsets(faces[5], 0, 0, 0);
|
||||
set_offsets(faces[6], 0, 0, 0);
|
||||
set_offsets(faces[7], 0, 0, 0);
|
||||
set_offsets(faces[8], 0, 2, 2);
|
||||
set_offsets(faces[9], 0, 0, 0);
|
||||
set_offsets(faces[10], 0, 0, 0);
|
||||
set_offsets(faces[11], 0, 2, 0);
|
||||
set_offsets(faces[12], 0, 0, 0);
|
||||
set_offsets(faces[13], 0, 2, 0);
|
||||
set_offsets(faces[14], 0, 0, 0);
|
||||
set_offsets(faces[15], 0, 0, 0);
|
||||
set_offsets(faces[16], 0, 0, 0);
|
||||
set_offsets(faces[17], 2, 2, 0);
|
||||
set_offsets(faces[18], 0, 0, 1);
|
||||
set_offsets(faces[19], 0, 2, 3);
|
||||
set_offsets(faces[20], 0, 0, 1);
|
||||
set_offsets(faces[21], 0, 1, 1);
|
||||
set_offsets(faces[22], 0, 3, 1);
|
||||
set_offsets(faces[23], 0, 1, 1);
|
||||
|
||||
vertices[0]->set_face(faces[0]);
|
||||
vertices[1]->set_face(faces[1]);
|
||||
|
|
@ -147,12 +151,13 @@ Periodic_2_triangulation_2<GT,Tds>::insert_dummy_points() {
|
|||
vertices[11]->set_face(faces[14]);
|
||||
|
||||
_tds.set_dimension(2);
|
||||
_cover = make_array(1,1);
|
||||
_cover = make_array(1, 1);
|
||||
|
||||
std::vector<Vertex_handle> ret_vector(12);
|
||||
for (int i=0; i<12; i++) {
|
||||
ret_vector[i] = vertices[i];
|
||||
}
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
ret_vector[i] = vertices[i];
|
||||
}
|
||||
|
||||
CGAL_assertion(is_valid());
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
|
@ -25,10 +25,11 @@
|
|||
#include <CGAL/Triangulation_utils_2.h>
|
||||
#include <CGAL/Dummy_tds_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
template < typename Gt, typename Fb = Triangulation_face_base_2<Gt> >
|
||||
class Periodic_2_triangulation_face_base_2
|
||||
class Periodic_2_triangulation_face_base_2
|
||||
: public Fb
|
||||
{
|
||||
typedef Fb Base;
|
||||
|
|
@ -40,7 +41,8 @@ public:
|
|||
typedef typename Tds::Face_handle Face_handle;
|
||||
|
||||
template < typename TDS2 >
|
||||
struct Rebind_TDS {
|
||||
struct Rebind_TDS
|
||||
{
|
||||
typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
|
||||
typedef Periodic_2_triangulation_face_base_2<Gt, Fb2> Other;
|
||||
};
|
||||
|
|
@ -49,67 +51,72 @@ public:
|
|||
Periodic_2_triangulation_face_base_2()
|
||||
: Fb(), _off(0) {}
|
||||
|
||||
Periodic_2_triangulation_face_base_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2)
|
||||
: Fb(v0,v1,v2) , _off(0){}
|
||||
Periodic_2_triangulation_face_base_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2)
|
||||
: Fb(v0, v1, v2) , _off(0) {}
|
||||
|
||||
Periodic_2_triangulation_face_base_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Face_handle n0,
|
||||
Face_handle n1,
|
||||
Face_handle n2)
|
||||
: Fb(v0,v1,v2,n0,n1,n2), _off(0) {}
|
||||
Periodic_2_triangulation_face_base_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Face_handle n0,
|
||||
Face_handle n1,
|
||||
Face_handle n2)
|
||||
: Fb(v0, v1, v2, n0, n1, n2), _off(0) {}
|
||||
|
||||
/// Periodic functions
|
||||
int offset(int i) const
|
||||
{
|
||||
CGAL_triangulation_precondition( i >= 0 && i < 3 );
|
||||
return ((_off>>2*i)&3);
|
||||
return ((_off >> 2 * i) & 3);
|
||||
}
|
||||
bool has_zero_offsets() const {
|
||||
return (_off&63) == 0;
|
||||
bool has_zero_offsets() const
|
||||
{
|
||||
return (_off & 63) == 0;
|
||||
}
|
||||
|
||||
void set_offsets(unsigned int o0, unsigned int o1, unsigned int o2) {
|
||||
void set_offsets(unsigned int o0, unsigned int o1, unsigned int o2)
|
||||
{
|
||||
// 192=11000000
|
||||
_off = _off | 192;
|
||||
unsigned int off0[2] = {(o0>>1)&1, (o0&1)};
|
||||
unsigned int off1[2] = {(o1>>1)&1, (o1&1)};
|
||||
unsigned int off2[2] = {(o2>>1)&1, (o2&1)};
|
||||
for (int i=0; i<2; i++) {
|
||||
unsigned int _off0 = ( _off &3);
|
||||
unsigned int _off1 = ((_off>>2)&3);
|
||||
unsigned int _off2 = ((_off>>4)&3);
|
||||
|
||||
_off0 = ( (_off0<<1) + off0[i]);
|
||||
_off1 = ( (_off1<<1) + off1[i]);
|
||||
_off2 = ( (_off2<<1) + off2[i]);
|
||||
|
||||
// 252=11111100
|
||||
// 243=11110011
|
||||
// 207=11001111
|
||||
_off = ((_off&252) | (_off0 ));
|
||||
_off = ((_off&243) | (_off1<<2));
|
||||
_off = ((_off&207) | (_off2<<4));
|
||||
}
|
||||
unsigned int off0[2] = {(o0 >> 1) & 1, (o0 & 1)};
|
||||
unsigned int off1[2] = {(o1 >> 1) & 1, (o1 & 1)};
|
||||
unsigned int off2[2] = {(o2 >> 1) & 1, (o2 & 1)};
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
unsigned int _off0 = ( _off & 3);
|
||||
unsigned int _off1 = ((_off >> 2) & 3);
|
||||
unsigned int _off2 = ((_off >> 4) & 3);
|
||||
|
||||
_off0 = ( (_off0 << 1) + off0[i]);
|
||||
_off1 = ( (_off1 << 1) + off1[i]);
|
||||
_off2 = ( (_off2 << 1) + off2[i]);
|
||||
|
||||
// 252=11111100
|
||||
// 243=11110011
|
||||
// 207=11001111
|
||||
_off = ((_off & 252) | (_off0 ));
|
||||
_off = ((_off & 243) | (_off1 << 2));
|
||||
_off = ((_off & 207) | (_off2 << 4));
|
||||
}
|
||||
}
|
||||
|
||||
void set_additional_flag(unsigned char b) {
|
||||
|
||||
void set_additional_flag(unsigned char b)
|
||||
{
|
||||
CGAL_assertion(b < 4);
|
||||
// 63=00111111
|
||||
_off = ((_off & 63) | (b<<6));
|
||||
_off = ((_off & 63) | (b << 6));
|
||||
}
|
||||
unsigned char get_additional_flag() {
|
||||
return (_off>>6);
|
||||
unsigned char get_additional_flag()
|
||||
{
|
||||
return (_off >> 6);
|
||||
}
|
||||
|
||||
private:
|
||||
// 2 respective bits are the _offset in x and y
|
||||
// right to left:
|
||||
// right to left:
|
||||
// bit[0]-bit[1]: vertex(0),
|
||||
// bit[2]-bit[3]: vertex(1) and
|
||||
// bit[2]-bit[3]: vertex(1) and
|
||||
// bit[4]-bit[5]: vertex(2)
|
||||
// Thus the underlying data type needs to have at least 6 bit,
|
||||
// which is true for an unsigned char.
|
||||
|
|
@ -135,6 +142,6 @@ operator<<(std::ostream &os, const Periodic_2_triangulation_face_base_2<Tds> &)
|
|||
return os;
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
} //namespace CGAL
|
||||
|
||||
#endif //CGAL_PERIODIC_2_TRIANGULATION_FACE_BASE_2_H
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
|
@ -31,7 +31,8 @@
|
|||
#include <CGAL/Profile_counter.h>
|
||||
#include <CGAL/Periodic_2_triangulation_traits_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
// This template class is a wrapper that implements the filtering for any
|
||||
// predicate (dynamic filters with IA).
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ public:
|
|||
// These constructors are used for constructive predicates.
|
||||
// You should try to avoid constructive predicates, as they will construct
|
||||
// the exact values systematically (in the ctor), rather than lazily.
|
||||
template <class OE, class OA>
|
||||
template <class OE, class OA>
|
||||
Filtered_periodic_predicate_2(const OE * oe, const OA * oa) : Base(EP(oe), AP(oa)) {}
|
||||
|
||||
|
||||
|
|
@ -76,14 +77,14 @@ struct Offset_converter_2
|
|||
typedef typename Converter::Target_kernel Target_kernel;
|
||||
|
||||
typedef typename Periodic_2_triangulation_traits_base_2<Source_kernel>
|
||||
::Offset_2 Source_off;
|
||||
/* typedef typename Periodic_2_triangulation_traits_base_2<Source_kernel> */
|
||||
/* ::Point_2 Source_pt; */
|
||||
::Offset_2 Source_off;
|
||||
/* typedef typename Periodic_2_triangulation_traits_base_2<Source_kernel> */
|
||||
/* ::Point_2 Source_pt; */
|
||||
|
||||
typedef typename Periodic_2_triangulation_traits_base_2<Target_kernel>
|
||||
::Offset_2 Target_off;
|
||||
/* typedef typename Periodic_2_triangulation_traits_base_2<Target_kernel> */
|
||||
/* ::Point_2 Target_pt; */
|
||||
::Offset_2 Target_off;
|
||||
/* typedef typename Periodic_2_triangulation_traits_base_2<Target_kernel> */
|
||||
/* ::Point_2 Target_pt; */
|
||||
|
||||
|
||||
using Converter::operator();
|
||||
|
|
@ -104,24 +105,25 @@ class Periodic_2_triangulation_filtered_traits_base_2
|
|||
|
||||
// Exact traits is based on the exact kernel.
|
||||
typedef Periodic_2_triangulation_traits_2<typename K::Exact_kernel, Off>
|
||||
Exact_traits;
|
||||
Exact_traits;
|
||||
// Filtering traits is based on the filtering kernel.
|
||||
typedef Periodic_2_triangulation_traits_2<typename K::Approximate_kernel, Off>
|
||||
Filtering_traits;
|
||||
Filtering_traits;
|
||||
private:
|
||||
typedef typename K::C2E C2E;
|
||||
typedef typename K::C2F C2F;
|
||||
|
||||
typedef typename C2E::Target_kernel::Iso_rectangle_2 Exact_iso_rectangle_2;
|
||||
typedef typename C2F::Target_kernel::Iso_rectangle_2 Approximate_iso_rectangle_2;
|
||||
|
||||
|
||||
public:
|
||||
typedef typename K::Iso_rectangle_2 Iso_rectangle_2;
|
||||
|
||||
Periodic_2_triangulation_filtered_traits_base_2() {}
|
||||
|
||||
|
||||
void set_domain(const Iso_rectangle_2& domain) {
|
||||
void set_domain(const Iso_rectangle_2& domain)
|
||||
{
|
||||
C2E c2e;
|
||||
C2F c2f;
|
||||
this->_domain = domain;
|
||||
|
|
@ -129,40 +131,51 @@ public:
|
|||
this->_domain_f = c2f(this->_domain);
|
||||
}
|
||||
|
||||
typedef Filtered_periodic_predicate_2<
|
||||
typename Exact_traits::Less_x_2,
|
||||
typename Filtering_traits::Less_x_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Less_x_2;
|
||||
typedef Filtered_periodic_predicate_2<
|
||||
typename Exact_traits::Less_y_2,
|
||||
typename Filtering_traits::Less_y_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Less_y_2;
|
||||
typedef Filtered_periodic_predicate_2<
|
||||
typename Exact_traits::Orientation_2,
|
||||
typename Filtering_traits::Orientation_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Orientation_2;
|
||||
typedef Filtered_periodic_predicate_2<
|
||||
typename Exact_traits::Side_of_oriented_circle_2,
|
||||
typename Filtering_traits::Side_of_oriented_circle_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Side_of_oriented_circle_2;
|
||||
typedef Filtered_periodic_predicate_2<
|
||||
typename Exact_traits::Compare_distance_2,
|
||||
typename Filtering_traits::Compare_distance_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Compare_distance_2;
|
||||
typedef Filtered_periodic_predicate_2 <
|
||||
typename Exact_traits::Less_x_2,
|
||||
typename Filtering_traits::Less_x_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Less_x_2;
|
||||
typedef Filtered_periodic_predicate_2 <
|
||||
typename Exact_traits::Less_y_2,
|
||||
typename Filtering_traits::Less_y_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Less_y_2;
|
||||
typedef Filtered_periodic_predicate_2 <
|
||||
typename Exact_traits::Orientation_2,
|
||||
typename Filtering_traits::Orientation_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Orientation_2;
|
||||
typedef Filtered_periodic_predicate_2 <
|
||||
typename Exact_traits::Side_of_oriented_circle_2,
|
||||
typename Filtering_traits::Side_of_oriented_circle_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Side_of_oriented_circle_2;
|
||||
typedef Filtered_periodic_predicate_2 <
|
||||
typename Exact_traits::Compare_distance_2,
|
||||
typename Filtering_traits::Compare_distance_2,
|
||||
Offset_converter_2<C2E>,
|
||||
Offset_converter_2<C2F> > Compare_distance_2;
|
||||
|
||||
Less_x_2 less_x_2_object() const { return Less_x_2(&_domain_e,&_domain_f); }
|
||||
Less_y_2 less_y_2_object() const { return Less_y_2(&_domain_e,&_domain_f); }
|
||||
Orientation_2 orientation_2_object() const { return Orientation_2(&_domain_e,&_domain_f); }
|
||||
Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const {
|
||||
return Side_of_oriented_circle_2(&_domain_e,&_domain_f);
|
||||
Less_x_2 less_x_2_object() const
|
||||
{
|
||||
return Less_x_2(&_domain_e, &_domain_f);
|
||||
}
|
||||
Compare_distance_2 compare_distance_2_object() const {
|
||||
return Compare_distance_2(&_domain_e,&_domain_f);
|
||||
Less_y_2 less_y_2_object() const
|
||||
{
|
||||
return Less_y_2(&_domain_e, &_domain_f);
|
||||
}
|
||||
Orientation_2 orientation_2_object() const
|
||||
{
|
||||
return Orientation_2(&_domain_e, &_domain_f);
|
||||
}
|
||||
Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const
|
||||
{
|
||||
return Side_of_oriented_circle_2(&_domain_e, &_domain_f);
|
||||
}
|
||||
Compare_distance_2 compare_distance_2_object() const
|
||||
{
|
||||
return Compare_distance_2(&_domain_e, &_domain_f);
|
||||
}
|
||||
|
||||
// The following are inherited since they are constructions :
|
||||
|
|
@ -185,18 +198,19 @@ protected:
|
|||
|
||||
#include <CGAL/Periodic_2_triangulation_statically_filtered_traits_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
template < typename K, typename Off = typename CGAL::Periodic_2_offset_2, bool Has_static_filters = K::Has_static_filters >
|
||||
class Periodic_2_triangulation_filtered_traits_2;
|
||||
|
||||
template < typename K, typename Off, bool Has_static_filters >
|
||||
template < typename K, typename Off, bool Has_static_filters >
|
||||
class Periodic_2_triangulation_filtered_traits_2
|
||||
: public Periodic_2_triangulation_filtered_traits_base_2<K, Off> {};
|
||||
|
||||
|
||||
template < typename K, typename Off >
|
||||
class Periodic_2_triangulation_filtered_traits_2<K,Off,true>
|
||||
: public Periodic_2_triangulation_statically_filtered_traits_2<
|
||||
class Periodic_2_triangulation_filtered_traits_2<K, Off, true>
|
||||
: public Periodic_2_triangulation_statically_filtered_traits_2 <
|
||||
Periodic_2_triangulation_filtered_traits_base_2<K, Off> > {};
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Olivier Devillers <Olivivier.Devillers@sophia.inria.fr>
|
||||
// Mariette Yvinec <Mariette.Yvinec@sophia.inria.fr>
|
||||
|
|
@ -31,7 +31,8 @@
|
|||
#include <boost/random/geometric_distribution.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
template < class PTr>
|
||||
class Periodic_2_triangulation_hierarchy_2
|
||||
|
|
@ -44,7 +45,7 @@ class Periodic_2_triangulation_hierarchy_2
|
|||
// maximal number of points is 30^5 = 24 millions !
|
||||
|
||||
|
||||
public:
|
||||
public:
|
||||
typedef PTr PTr_Base;
|
||||
typedef typename PTr::Geom_traits Geom_traits;
|
||||
typedef typename PTr::Point Point;
|
||||
|
|
@ -63,7 +64,7 @@ class Periodic_2_triangulation_hierarchy_2
|
|||
using PTr_Base::geom_traits;
|
||||
#endif
|
||||
|
||||
private:
|
||||
private:
|
||||
// here is the stack of triangulations which form the hierarchy
|
||||
PTr_Base* hierarchy[m_maxlevel];
|
||||
boost::rand48 random;
|
||||
|
|
@ -71,21 +72,21 @@ class Periodic_2_triangulation_hierarchy_2
|
|||
|
||||
public:
|
||||
Periodic_2_triangulation_hierarchy_2(
|
||||
const Iso_rectangle& domain = Iso_rectangle(0,0,1,1),
|
||||
const Geom_traits& traits = Geom_traits());
|
||||
const Iso_rectangle& domain = Iso_rectangle(0, 0, 1, 1),
|
||||
const Geom_traits& traits = Geom_traits());
|
||||
|
||||
Periodic_2_triangulation_hierarchy_2(
|
||||
const Periodic_2_triangulation_hierarchy_2& tr);
|
||||
const Periodic_2_triangulation_hierarchy_2& tr);
|
||||
|
||||
template < typename InputIterator >
|
||||
Periodic_2_triangulation_hierarchy_2(InputIterator first, InputIterator last,
|
||||
const Iso_rectangle& domain = Iso_rectangle(0,0,1,1),
|
||||
const Geom_traits& traits = Geom_traits())
|
||||
: PTr_Base(domain,traits), level_mult_cover(0)
|
||||
const Iso_rectangle& domain = Iso_rectangle(0, 0, 1, 1),
|
||||
const Geom_traits& traits = Geom_traits())
|
||||
: PTr_Base(domain, traits), level_mult_cover(0)
|
||||
{
|
||||
hierarchy[0] = this;
|
||||
for(int i=1; i<m_maxlevel; ++i)
|
||||
hierarchy[i] = new PTr_Base(domain,traits);
|
||||
hierarchy[0] = this;
|
||||
for(int i = 1; i < m_maxlevel; ++i)
|
||||
hierarchy[i] = new PTr_Base(domain, traits);
|
||||
insert(first, last);
|
||||
}
|
||||
|
||||
|
|
@ -104,10 +105,10 @@ public:
|
|||
Vertex_handle insert(const Point &p,
|
||||
Face_handle start = Face_handle() );
|
||||
Vertex_handle insert(const Point& p,
|
||||
Locate_type lt,
|
||||
Face_handle loc, int li );
|
||||
Locate_type lt,
|
||||
Face_handle loc, int li );
|
||||
Vertex_handle push_back(const Point &p);
|
||||
|
||||
|
||||
template < class InputIterator >
|
||||
std::ptrdiff_t insert(InputIterator first, InputIterator last, bool /* is_large_point_set */ = false)
|
||||
{
|
||||
|
|
@ -115,34 +116,37 @@ public:
|
|||
|
||||
std::vector<Point> points (first, last);
|
||||
CGAL::spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
|
||||
|
||||
// hints[i] is the face of the previously inserted point in level i.
|
||||
// Thanks to spatial sort, they are better hints than what the hierarchy
|
||||
// would give us.
|
||||
Face_handle hints[m_maxlevel];
|
||||
for (typename std::vector<Point>::const_iterator p = points.begin(), end = points.end();
|
||||
p != end; ++p) {
|
||||
int vertex_level = random_level();
|
||||
|
||||
Vertex_handle v = hierarchy[0]->insert (*p, hints[0]);
|
||||
hints[0] = v->face();
|
||||
|
||||
Vertex_handle prev = v;
|
||||
|
||||
for (int level = 1; level <= vertex_level; ++level) {
|
||||
v = hierarchy[level]->insert (*p, hints[level]);
|
||||
hints[level] = v->face();
|
||||
|
||||
v->set_down (prev);
|
||||
if (hierarchy[level]->number_of_sheets()[0] != 1) {
|
||||
std::vector<Vertex_handle> vtc = hierarchy[level]->periodic_copies(v);
|
||||
for (unsigned int i=0 ; i<vtc.size() ; i++) vtc[i]->set_down(prev);
|
||||
}
|
||||
|
||||
prev->set_up (v);
|
||||
prev = v;
|
||||
p != end; ++p)
|
||||
{
|
||||
int vertex_level = random_level();
|
||||
|
||||
Vertex_handle v = hierarchy[0]->insert (*p, hints[0]);
|
||||
hints[0] = v->face();
|
||||
|
||||
Vertex_handle prev = v;
|
||||
|
||||
for (int level = 1; level <= vertex_level; ++level)
|
||||
{
|
||||
v = hierarchy[level]->insert (*p, hints[level]);
|
||||
hints[level] = v->face();
|
||||
|
||||
v->set_down (prev);
|
||||
if (hierarchy[level]->number_of_sheets()[0] != 1)
|
||||
{
|
||||
std::vector<Vertex_handle> vtc = hierarchy[level]->periodic_copies(v);
|
||||
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(prev);
|
||||
}
|
||||
|
||||
prev->set_up (v);
|
||||
prev = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::ptrdiff_t m = this->number_of_vertices();
|
||||
return m - n;
|
||||
}
|
||||
|
|
@ -157,13 +161,13 @@ public:
|
|||
//LOCATE
|
||||
Face_handle
|
||||
locate(const Point& p,
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle start = Face_handle()) const;
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle start = Face_handle()) const;
|
||||
|
||||
Face_handle
|
||||
locate(const Point &p,
|
||||
Face_handle start = Face_handle()) const;
|
||||
Face_handle start = Face_handle()) const;
|
||||
|
||||
Vertex_handle
|
||||
nearest_vertex(const Point& p, Face_handle start = Face_handle()) const
|
||||
|
|
@ -173,10 +177,10 @@ public:
|
|||
|
||||
private:
|
||||
void locate_in_all(const Point& p,
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle loc,
|
||||
Face_handle pos[m_maxlevel]) const;
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle loc,
|
||||
Face_handle pos[m_maxlevel]) const;
|
||||
int random_level();
|
||||
};
|
||||
|
||||
|
|
@ -186,10 +190,10 @@ template <class PTr >
|
|||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2(const Iso_rectangle& domain, const Geom_traits& traits)
|
||||
: PTr_Base(domain, traits)
|
||||
{
|
||||
{
|
||||
level_mult_cover = 0;
|
||||
hierarchy[0] = this;
|
||||
for(int i=1;i<m_maxlevel;++i)
|
||||
hierarchy[0] = this;
|
||||
for(int i = 1; i < m_maxlevel; ++i)
|
||||
hierarchy[i] = new PTr_Base(domain, traits);
|
||||
}
|
||||
|
||||
|
|
@ -198,15 +202,15 @@ Periodic_2_triangulation_hierarchy_2(const Iso_rectangle& domain, const Geom_tra
|
|||
template <class PTr>
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
||||
: PTr_Base()
|
||||
{
|
||||
: PTr_Base()
|
||||
{
|
||||
// create an empty triangulation to be able to delete it !
|
||||
hierarchy[0] = this;
|
||||
for(int i=1;i<m_maxlevel;++i)
|
||||
hierarchy[0] = this;
|
||||
for(int i = 1; i < m_maxlevel; ++i)
|
||||
hierarchy[i] = new PTr_Base(tr.domain(), tr.geom_traits());
|
||||
copy_triangulation(tr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Assignement
|
||||
template <class PTr>
|
||||
|
|
@ -222,40 +226,44 @@ operator=(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
|||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
copy_triangulation(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
||||
{
|
||||
{
|
||||
for(int i=0;i<m_maxlevel;++i)
|
||||
hierarchy[i]->copy_triangulation(*tr.hierarchy[i]);
|
||||
for(int i = 0; i < m_maxlevel; ++i)
|
||||
hierarchy[i]->copy_triangulation(*tr.hierarchy[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//up and down have been copied in straightforward way
|
||||
// compute a map at lower level
|
||||
std::map<Vertex_handle, Vertex_handle > V;
|
||||
{
|
||||
for(Finite_vertices_iterator it=hierarchy[0]->finite_vertices_begin();
|
||||
it != hierarchy[0]->finite_vertices_end(); ++it) {
|
||||
if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it;
|
||||
}
|
||||
for(Finite_vertices_iterator it = hierarchy[0]->finite_vertices_begin();
|
||||
it != hierarchy[0]->finite_vertices_end(); ++it)
|
||||
{
|
||||
if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for(int i=1;i<m_maxlevel;++i) {
|
||||
for( Finite_vertices_iterator it=hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it) {
|
||||
if (hierarchy[i]->is_virtual(it)) {
|
||||
// down pointer goes in original instead in copied triangulation
|
||||
it->set_down(V[it->down()]);
|
||||
// make reverse link
|
||||
it->down()->set_up(it);
|
||||
// I think the next line is unnecessary (my)
|
||||
// make map for next level
|
||||
if (it->up()!= Vertex_handle() ) V[ it->up()->down() ] = it;
|
||||
}
|
||||
for(int i = 1; i < m_maxlevel; ++i)
|
||||
{
|
||||
for( Finite_vertices_iterator it = hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it)
|
||||
{
|
||||
if (hierarchy[i]->is_virtual(it))
|
||||
{
|
||||
// down pointer goes in original instead in copied triangulation
|
||||
it->set_down(V[it->down()]);
|
||||
// make reverse link
|
||||
it->down()->set_up(it);
|
||||
// I think the next line is unnecessary (my)
|
||||
// make map for next level
|
||||
if (it->up() != Vertex_handle() ) V[ it->up()->down() ] = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,73 +292,75 @@ copy_triangulation(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
|||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
swap(Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
||||
{
|
||||
PTr_Base::swap(tr);
|
||||
for(int i=1; i<m_maxlevel; ++i)
|
||||
std::swap(hierarchy[i], tr.hierarchy[i]);
|
||||
for(int i = 1; i < m_maxlevel; ++i)
|
||||
std::swap(hierarchy[i], tr.hierarchy[i]);
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
~Periodic_2_triangulation_hierarchy_2()
|
||||
{
|
||||
clear();
|
||||
for(int i= 1; i<m_maxlevel; ++i){
|
||||
delete hierarchy[i];
|
||||
}
|
||||
for(int i = 1; i < m_maxlevel; ++i)
|
||||
{
|
||||
delete hierarchy[i];
|
||||
}
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
clear()
|
||||
{
|
||||
for(int i=0;i<m_maxlevel;++i)
|
||||
for(int i = 0; i < m_maxlevel; ++i)
|
||||
hierarchy[i]->clear();
|
||||
}
|
||||
|
||||
|
||||
template <class PTr>
|
||||
bool
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
is_valid(bool verbose, int level) const
|
||||
{
|
||||
bool result = true;
|
||||
int i;
|
||||
Finite_vertices_iterator it;
|
||||
//verify correctness of triangulation at all levels
|
||||
for(i=0;i<m_maxlevel;++i) {
|
||||
if(verbose) // print number of vertices at each level
|
||||
std::cout << "number_of_vertices "
|
||||
<< hierarchy[i]->number_of_vertices() << std::endl;
|
||||
result = result && hierarchy[i]->is_valid(verbose,level);
|
||||
}
|
||||
//verify that lower level has no down pointers
|
||||
for( it = hierarchy[0]->finite_vertices_begin();
|
||||
it != hierarchy[0]->finite_vertices_end(); ++it)
|
||||
for(i = 0; i < m_maxlevel; ++i)
|
||||
{
|
||||
if(verbose) // print number of vertices at each level
|
||||
std::cout << "number_of_vertices "
|
||||
<< hierarchy[i]->number_of_vertices() << std::endl;
|
||||
result = result && hierarchy[i]->is_valid(verbose, level);
|
||||
}
|
||||
//verify that lower level has no down pointers
|
||||
for( it = hierarchy[0]->finite_vertices_begin();
|
||||
it != hierarchy[0]->finite_vertices_end(); ++it)
|
||||
if (!hierarchy[0]->is_virtual(it))
|
||||
result = result && (it->down() == Vertex_handle());
|
||||
|
||||
//verify that other levels have down pointer and reciprocal link is fine
|
||||
for(i=1;i<m_maxlevel;++i)
|
||||
for( it = hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it)
|
||||
for(i = 1; i < m_maxlevel; ++i)
|
||||
for( it = hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it)
|
||||
if (!hierarchy[i]->is_virtual(it))
|
||||
result = result && (&*(it->down()->up()) == &*(it));
|
||||
|
||||
//verify that levels have up pointer and reciprocal link is fine
|
||||
for(i=0;i<m_maxlevel-1;++i)
|
||||
for( it = hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it)
|
||||
for(i = 0; i < m_maxlevel - 1; ++i)
|
||||
for( it = hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it)
|
||||
if (!hierarchy[i]->is_virtual(it))
|
||||
result = result && ( it->up() == Vertex_handle() || &*it == &*(it->up())->down() );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
|
|
@ -361,23 +371,25 @@ insert(const Point &p, Face_handle loc)
|
|||
int i;
|
||||
// locate using hierarchy
|
||||
Face_handle positions[m_maxlevel];
|
||||
locate_in_all(p,lt,i,loc,positions);
|
||||
Vertex_handle vertex=hierarchy[0]->PTr_Base::insert(p,lt,positions[0],i);
|
||||
Vertex_handle previous=vertex;
|
||||
locate_in_all(p, lt, i, loc, positions);
|
||||
Vertex_handle vertex = hierarchy[0]->PTr_Base::insert(p, lt, positions[0], i);
|
||||
Vertex_handle previous = vertex;
|
||||
Vertex_handle first = vertex;
|
||||
|
||||
|
||||
int level = 1;
|
||||
while (level <= vertex_level ){
|
||||
vertex=hierarchy[level]->PTr_Base::insert(p,positions[level]);
|
||||
vertex->set_down(previous);// link with level above
|
||||
if (hierarchy[level]->number_of_sheets()[0] != 1) {
|
||||
std::vector<Vertex_handle> vtc = hierarchy[level]->periodic_copies(vertex);
|
||||
for (unsigned int i=0 ; i<vtc.size() ; i++) vtc[i]->set_down(previous);
|
||||
while (level <= vertex_level )
|
||||
{
|
||||
vertex = hierarchy[level]->PTr_Base::insert(p, positions[level]);
|
||||
vertex->set_down(previous);// link with level above
|
||||
if (hierarchy[level]->number_of_sheets()[0] != 1)
|
||||
{
|
||||
std::vector<Vertex_handle> vtc = hierarchy[level]->periodic_copies(vertex);
|
||||
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(previous);
|
||||
}
|
||||
previous->set_up(vertex);
|
||||
previous = vertex;
|
||||
level++;
|
||||
}
|
||||
previous->set_up(vertex);
|
||||
previous=vertex;
|
||||
level++;
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
|
|
@ -386,35 +398,38 @@ typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
|||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
insert(const Point& p,
|
||||
Locate_type lt,
|
||||
Face_handle loc,
|
||||
Face_handle loc,
|
||||
int li )
|
||||
{
|
||||
int vertex_level = random_level();
|
||||
//insert at level 0
|
||||
Vertex_handle vertex=hierarchy[0]->PTr_Base::insert(p,lt,loc,li);
|
||||
Vertex_handle previous=vertex;
|
||||
Vertex_handle vertex = hierarchy[0]->PTr_Base::insert(p, lt, loc, li);
|
||||
Vertex_handle previous = vertex;
|
||||
Vertex_handle first = vertex;
|
||||
|
||||
if (vertex_level > 0) {
|
||||
// locate using hierarchy
|
||||
Locate_type ltt;
|
||||
int lii;
|
||||
Face_handle positions[m_maxlevel];
|
||||
locate_in_all(p,ltt,lii,loc,positions);
|
||||
//insert in higher levels
|
||||
int level = 1;
|
||||
while (level <= vertex_level ){
|
||||
vertex=hierarchy[level]->PTr_Base::insert(p,positions[level]);
|
||||
vertex->set_down(previous);// link with level above
|
||||
if (hierarchy[level]->number_of_sheets()[0] != 1) {
|
||||
std::vector<Vertex_handle> vtc = hierarchy[level]->periodic_copies(vertex);
|
||||
for (unsigned int i=0 ; i<vtc.size() ; i++) vtc[i]->set_down(previous);
|
||||
}
|
||||
previous->set_up(vertex);
|
||||
previous=vertex;
|
||||
level++;
|
||||
if (vertex_level > 0)
|
||||
{
|
||||
// locate using hierarchy
|
||||
Locate_type ltt;
|
||||
int lii;
|
||||
Face_handle positions[m_maxlevel];
|
||||
locate_in_all(p, ltt, lii, loc, positions);
|
||||
//insert in higher levels
|
||||
int level = 1;
|
||||
while (level <= vertex_level )
|
||||
{
|
||||
vertex = hierarchy[level]->PTr_Base::insert(p, positions[level]);
|
||||
vertex->set_down(previous);// link with level above
|
||||
if (hierarchy[level]->number_of_sheets()[0] != 1)
|
||||
{
|
||||
std::vector<Vertex_handle> vtc = hierarchy[level]->periodic_copies(vertex);
|
||||
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(previous);
|
||||
}
|
||||
previous->set_up(vertex);
|
||||
previous = vertex;
|
||||
level++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
|
|
@ -428,22 +443,24 @@ push_back(const Point &p)
|
|||
}
|
||||
|
||||
template <class PTr>
|
||||
void
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
remove(Vertex_handle v )
|
||||
{
|
||||
Vertex_handle u=v->up();
|
||||
Vertex_handle u = v->up();
|
||||
int l = 0 ;
|
||||
while(1){
|
||||
hierarchy[l++]->remove(v);
|
||||
if (u == Vertex_handle()) break;
|
||||
if (l >= m_maxlevel) break;
|
||||
v=u; u=v->up();
|
||||
}
|
||||
while(1)
|
||||
{
|
||||
hierarchy[l++]->remove(v);
|
||||
if (u == Vertex_handle()) break;
|
||||
if (l >= m_maxlevel) break;
|
||||
v = u;
|
||||
u = v->up();
|
||||
}
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
inline void
|
||||
inline void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
remove_degree_3(Vertex_handle v )
|
||||
{
|
||||
|
|
@ -451,7 +468,7 @@ remove_degree_3(Vertex_handle v )
|
|||
}
|
||||
|
||||
template <class PTr>
|
||||
inline void
|
||||
inline void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
remove_first(Vertex_handle v )
|
||||
{
|
||||
|
|
@ -461,29 +478,35 @@ remove_first(Vertex_handle v )
|
|||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
move_if_no_collision(Vertex_handle v, const Point &p) {
|
||||
move_if_no_collision(Vertex_handle v, const Point &p)
|
||||
{
|
||||
CGAL_triangulation_precondition(v != Vertex_handle());
|
||||
Vertex_handle old, ret;
|
||||
|
||||
for (int l = 0; l < m_maxlevel; ++l) {
|
||||
Vertex_handle u = v->up();
|
||||
CGAL_triangulation_assertion(hierarchy[l]->is_valid());
|
||||
Vertex_handle w = hierarchy[l]->move_if_no_collision(v, p);
|
||||
if (l == 0) {
|
||||
ret = w;
|
||||
} else {
|
||||
old->set_up(w);
|
||||
w->set_down(old);
|
||||
if (hierarchy[l]->number_of_sheets()[0] != 1) {
|
||||
std::vector<Vertex_handle> vtc = hierarchy[l]->periodic_copies(w);
|
||||
for (unsigned int i=0 ; i<vtc.size() ; i++) vtc[i]->set_down(old);
|
||||
}
|
||||
for (int l = 0; l < m_maxlevel; ++l)
|
||||
{
|
||||
Vertex_handle u = v->up();
|
||||
CGAL_triangulation_assertion(hierarchy[l]->is_valid());
|
||||
Vertex_handle w = hierarchy[l]->move_if_no_collision(v, p);
|
||||
if (l == 0)
|
||||
{
|
||||
ret = w;
|
||||
}
|
||||
else
|
||||
{
|
||||
old->set_up(w);
|
||||
w->set_down(old);
|
||||
if (hierarchy[l]->number_of_sheets()[0] != 1)
|
||||
{
|
||||
std::vector<Vertex_handle> vtc = hierarchy[l]->periodic_copies(w);
|
||||
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(old);
|
||||
}
|
||||
}
|
||||
if (u == Vertex_handle())
|
||||
break;
|
||||
old = w;
|
||||
v = u;
|
||||
}
|
||||
if (u == Vertex_handle())
|
||||
break;
|
||||
old = w;
|
||||
v = u;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -491,44 +514,50 @@ move_if_no_collision(Vertex_handle v, const Point &p) {
|
|||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
move_point(Vertex_handle v, const Point &p) {
|
||||
move_point(Vertex_handle v, const Point &p)
|
||||
{
|
||||
CGAL_triangulation_precondition(v != Vertex_handle());
|
||||
Vertex_handle old, ret;
|
||||
|
||||
for (int l = 0; l < m_maxlevel; ++l) {
|
||||
Vertex_handle u = v->up();
|
||||
CGAL_triangulation_assertion(hierarchy[l]->is_valid());
|
||||
Vertex_handle w = hierarchy[l]->move_point(v, p);
|
||||
if (l == 0) {
|
||||
ret = w;
|
||||
} else {
|
||||
old->set_up(w);
|
||||
w->set_down(old);
|
||||
if (hierarchy[l]->number_of_sheets()[0] != 1) {
|
||||
std::vector<Vertex_handle> vtc = hierarchy[l]->periodic_copies(w);
|
||||
for (unsigned int i=0 ; i<vtc.size() ; i++) vtc[i]->set_down(old);
|
||||
}
|
||||
for (int l = 0; l < m_maxlevel; ++l)
|
||||
{
|
||||
Vertex_handle u = v->up();
|
||||
CGAL_triangulation_assertion(hierarchy[l]->is_valid());
|
||||
Vertex_handle w = hierarchy[l]->move_point(v, p);
|
||||
if (l == 0)
|
||||
{
|
||||
ret = w;
|
||||
}
|
||||
else
|
||||
{
|
||||
old->set_up(w);
|
||||
w->set_down(old);
|
||||
if (hierarchy[l]->number_of_sheets()[0] != 1)
|
||||
{
|
||||
std::vector<Vertex_handle> vtc = hierarchy[l]->periodic_copies(w);
|
||||
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(old);
|
||||
}
|
||||
}
|
||||
if (u == Vertex_handle())
|
||||
break;
|
||||
old = w;
|
||||
v = u;
|
||||
}
|
||||
if (u == Vertex_handle())
|
||||
break;
|
||||
old = w;
|
||||
v = u;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Face_handle
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Face_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
locate(const Point& p, Locate_type& lt, int& li, Face_handle loc) const
|
||||
{
|
||||
Face_handle positions[m_maxlevel];
|
||||
locate_in_all(p,lt,li,loc,positions);
|
||||
locate_in_all(p, lt, li, loc, positions);
|
||||
return positions[0];
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Face_handle
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Face_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
locate(const Point& p, Face_handle loc ) const
|
||||
{
|
||||
|
|
@ -542,61 +571,71 @@ template <class PTr>
|
|||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
locate_in_all(const Point& p,
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle loc,
|
||||
Face_handle pos[m_maxlevel]) const
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle loc,
|
||||
Face_handle pos[m_maxlevel]) const
|
||||
{
|
||||
Face_handle position;
|
||||
Vertex_handle nearest;
|
||||
int level = m_maxlevel;
|
||||
typename Geom_traits::Compare_distance_2
|
||||
closer = this->geom_traits().compare_distance_2_object();
|
||||
typename Geom_traits::Compare_distance_2
|
||||
closer = this->geom_traits().compare_distance_2_object();
|
||||
|
||||
// find the highest level with enough vertices that is at the same time 2D
|
||||
while ( (hierarchy[--level]->number_of_vertices()
|
||||
< static_cast<size_type> (m_minsize ))
|
||||
|| (hierarchy[level]->dimension()<2) ){
|
||||
if ( ! level) break; // do not go below 0
|
||||
}
|
||||
if((level>0) && (hierarchy[level]->dimension()<2)){
|
||||
level--;
|
||||
}
|
||||
|
||||
for (int i=level+1; i<m_maxlevel;++i) pos[i]=0;
|
||||
while(level > 0) {
|
||||
pos[level]=position=hierarchy[level]->locate(p,position);
|
||||
// locate at that level from "position"
|
||||
// result is stored in "position" for the next level
|
||||
// find the nearest between vertices 0 and 1
|
||||
if (hierarchy[level]->is_infinite(position->vertex(0))){
|
||||
|
||||
nearest = position->vertex(1);
|
||||
while ( (hierarchy[--level]->number_of_vertices()
|
||||
< static_cast<size_type> (m_minsize ))
|
||||
|| (hierarchy[level]->dimension() < 2) )
|
||||
{
|
||||
if ( ! level) break; // do not go below 0
|
||||
}
|
||||
else if (hierarchy[level]->is_infinite(position->vertex(1))){
|
||||
nearest = position->vertex(0);
|
||||
} else if ( closer(p,
|
||||
position->vertex(0)->point(),
|
||||
position->vertex(1)->point()) == SMALLER){
|
||||
nearest = position->vertex(0);
|
||||
}
|
||||
else{
|
||||
nearest = position->vertex(1);
|
||||
}
|
||||
// compare to vertex 2, but only if the triangulation is 2D, because otherwise vertex(2) is NULL
|
||||
if ( (hierarchy[level]->dimension()==2) && (! hierarchy[level]->is_infinite(position->vertex(2)))){
|
||||
if ( closer( p,
|
||||
position->vertex(2)->point(),
|
||||
nearest->point()) == SMALLER ){
|
||||
nearest = position->vertex(2);
|
||||
}
|
||||
if((level > 0) && (hierarchy[level]->dimension() < 2))
|
||||
{
|
||||
level--;
|
||||
}
|
||||
// go at the same vertex on level below
|
||||
nearest = nearest->down();
|
||||
position = nearest->face(); // incident face
|
||||
--level;
|
||||
}
|
||||
pos[0]=hierarchy[0]->locate(p,lt,li,loc == Face_handle() ? position : loc); // at level 0
|
||||
|
||||
for (int i = level + 1; i < m_maxlevel; ++i) pos[i] = 0;
|
||||
while(level > 0)
|
||||
{
|
||||
pos[level] = position = hierarchy[level]->locate(p, position);
|
||||
// locate at that level from "position"
|
||||
// result is stored in "position" for the next level
|
||||
// find the nearest between vertices 0 and 1
|
||||
if (hierarchy[level]->is_infinite(position->vertex(0)))
|
||||
{
|
||||
|
||||
nearest = position->vertex(1);
|
||||
}
|
||||
else if (hierarchy[level]->is_infinite(position->vertex(1)))
|
||||
{
|
||||
nearest = position->vertex(0);
|
||||
}
|
||||
else if ( closer(p,
|
||||
position->vertex(0)->point(),
|
||||
position->vertex(1)->point()) == SMALLER)
|
||||
{
|
||||
nearest = position->vertex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
nearest = position->vertex(1);
|
||||
}
|
||||
// compare to vertex 2, but only if the triangulation is 2D, because otherwise vertex(2) is NULL
|
||||
if ( (hierarchy[level]->dimension() == 2) && (! hierarchy[level]->is_infinite(position->vertex(2))))
|
||||
{
|
||||
if ( closer( p,
|
||||
position->vertex(2)->point(),
|
||||
nearest->point()) == SMALLER )
|
||||
{
|
||||
nearest = position->vertex(2);
|
||||
}
|
||||
}
|
||||
// go at the same vertex on level below
|
||||
nearest = nearest->down();
|
||||
position = nearest->face(); // incident face
|
||||
--level;
|
||||
}
|
||||
pos[0] = hierarchy[0]->locate(p, lt, li, loc == Face_handle() ? position : loc); // at level 0
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
|
|
@ -605,13 +644,13 @@ Periodic_2_triangulation_hierarchy_2<PTr>::
|
|||
random_level()
|
||||
{
|
||||
if ( level_mult_cover < m_maxlevel
|
||||
&& hierarchy[level_mult_cover]->number_of_sheets() == make_array(1,1) )
|
||||
&& hierarchy[level_mult_cover]->number_of_sheets() == make_array(1, 1) )
|
||||
++level_mult_cover;
|
||||
|
||||
boost::geometric_distribution<> proba(1.0/m_ratio);
|
||||
|
||||
boost::geometric_distribution<> proba(1.0 / m_ratio);
|
||||
boost::variate_generator<boost::rand48&, boost::geometric_distribution<> >
|
||||
die(random, proba);
|
||||
return (std::min)(die()-1, level_mult_cover);
|
||||
die(random, proba);
|
||||
return (std::min)(die() - 1, level_mult_cover);
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Olivier Devillers <Olivivier.Devillers@sophia.inria.fr>
|
||||
// Mariette Yvinec <Mariette.Yvinec@sophia.inria.fr>
|
||||
|
|
@ -25,11 +25,12 @@
|
|||
|
||||
#include <CGAL/basic.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
template < class Gt, class Vb = CGAL::Periodic_2_triangulation_vertex_base_2<Gt> >
|
||||
class Periodic_2_triangulation_hierarchy_vertex_base_2
|
||||
: public Vb
|
||||
: public Vb
|
||||
{
|
||||
typedef typename Vb::Triangulation_data_structure Tds;
|
||||
typedef Gt Geom_traits;
|
||||
|
|
@ -39,7 +40,8 @@ class Periodic_2_triangulation_hierarchy_vertex_base_2
|
|||
typedef typename Tds::Vertex_handle Vertex_handle;
|
||||
|
||||
template < typename Tds2 >
|
||||
struct Rebind_Tds {
|
||||
struct Rebind_Tds
|
||||
{
|
||||
typedef typename Vb::template Rebind_Tds<Tds2>::Other Vb2;
|
||||
typedef Triangulation_vertex_base_2<Gt, Vb2> Other;
|
||||
};
|
||||
|
|
@ -47,21 +49,33 @@ class Periodic_2_triangulation_hierarchy_vertex_base_2
|
|||
|
||||
Periodic_2_triangulation_hierarchy_vertex_base_2()
|
||||
: Base(), _up(0), _down(0)
|
||||
{}
|
||||
{}
|
||||
Periodic_2_triangulation_hierarchy_vertex_base_2(const Point & p, Face_handle f)
|
||||
: Base(p,f), _up(0), _down(0)
|
||||
{}
|
||||
: Base(p, f), _up(0), _down(0)
|
||||
{}
|
||||
Periodic_2_triangulation_hierarchy_vertex_base_2(const Point & p)
|
||||
: Base(p), _up(0), _down(0)
|
||||
{}
|
||||
{}
|
||||
|
||||
Vertex_handle up() {return _up;}
|
||||
Vertex_handle down() {return _down;}
|
||||
void set_up(Vertex_handle u) {_up=u;}
|
||||
void set_down(Vertex_handle d) { _down=d;}
|
||||
Vertex_handle up()
|
||||
{
|
||||
return _up;
|
||||
}
|
||||
Vertex_handle down()
|
||||
{
|
||||
return _down;
|
||||
}
|
||||
void set_up(Vertex_handle u)
|
||||
{
|
||||
_up = u;
|
||||
}
|
||||
void set_down(Vertex_handle d)
|
||||
{
|
||||
_down = d;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
Vertex_handle _up; // same vertex one level above
|
||||
Vertex_handle _down; // same vertex one level below
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -13,10 +13,10 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
||||
#ifndef CGAL_PERIODIC_2_TRIANGULATION_STATICALLY_FILTERED_TRAITS_2_H
|
||||
#define CGAL_PERIODIC_2_TRIANGULATION_STATICALLY_FILTERED_TRAITS_2_H
|
||||
|
||||
|
|
@ -40,7 +40,8 @@
|
|||
// TODO :
|
||||
// - add more predicates :
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
// The K_base argument is supposed to provide exact primitives.
|
||||
template < typename Traits >
|
||||
|
|
@ -52,14 +53,16 @@ public:
|
|||
Periodic_2_triangulation_statically_filtered_traits_2() {}
|
||||
|
||||
typedef internal::Static_filters_predicates::Periodic_2_orientation_2<Traits>
|
||||
Orientation_2;
|
||||
Orientation_2;
|
||||
typedef internal::Static_filters_predicates::Periodic_2_side_of_oriented_circle_2<Traits>
|
||||
Side_of_oriented_circle_2;
|
||||
Side_of_oriented_circle_2;
|
||||
|
||||
Orientation_2 orientation_2_object() const {
|
||||
return Orientation_2(&this->_domain,&this->_domain_e,&this->_domain_f);
|
||||
Orientation_2 orientation_2_object() const
|
||||
{
|
||||
return Orientation_2(&this->_domain, &this->_domain_e, &this->_domain_f);
|
||||
}
|
||||
Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const {
|
||||
Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const
|
||||
{
|
||||
return Side_of_oriented_circle_2(&this->_domain,
|
||||
&this->_domain_e,
|
||||
&this->_domain_f);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
|
@ -34,13 +34,15 @@
|
|||
|
||||
#include <CGAL/Periodic_2_offset_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
template < class K, class Predicate_ >
|
||||
class Traits_with_offsets_2_adaptor {
|
||||
class Traits_with_offsets_2_adaptor
|
||||
{
|
||||
typedef K Kernel;
|
||||
typedef Predicate_ Predicate;
|
||||
|
||||
|
||||
typedef typename Kernel::Point_2 Point;
|
||||
typedef typename Kernel::Offset_2 Offset;
|
||||
|
||||
|
|
@ -48,45 +50,52 @@ class Traits_with_offsets_2_adaptor {
|
|||
typedef typename Kernel::Construct_point_2 Construct_point_2;
|
||||
public:
|
||||
typedef typename Kernel::Iso_rectangle_2 Iso_rectangle_2;
|
||||
|
||||
|
||||
public:
|
||||
typedef typename Predicate::result_type result_type;
|
||||
|
||||
|
||||
Traits_with_offsets_2_adaptor(const Iso_rectangle_2 * dom) : _domain(dom) { }
|
||||
|
||||
|
||||
result_type operator()(const Point& p0, const Point& p1,
|
||||
const Offset& o0, const Offset& o1) const {
|
||||
return Predicate()(pp(p0,o0),pp(p1,o1));
|
||||
const Offset& o0, const Offset& o1) const
|
||||
{
|
||||
return Predicate()(pp(p0, o0), pp(p1, o1));
|
||||
}
|
||||
result_type operator()(const Point& p0, const Point& p1, const Point& p2,
|
||||
const Offset& o0, const Offset& o1, const Offset& o2) const {
|
||||
return Predicate()(pp(p0,o0),pp(p1,o1),pp(p2,o2));
|
||||
const Offset& o0, const Offset& o1, const Offset& o2) const
|
||||
{
|
||||
return Predicate()(pp(p0, o0), pp(p1, o1), pp(p2, o2));
|
||||
}
|
||||
result_type operator()(const Point& p0, const Point& p1,
|
||||
const Point& p2, const Point& p3,
|
||||
const Offset& o0, const Offset& o1,
|
||||
const Offset& o2, const Offset& o3) const {
|
||||
return Predicate()(pp(p0,o0),pp(p1,o1),pp(p2,o2),pp(p3,o3));
|
||||
const Point& p2, const Point& p3,
|
||||
const Offset& o0, const Offset& o1,
|
||||
const Offset& o2, const Offset& o3) const
|
||||
{
|
||||
return Predicate()(pp(p0, o0), pp(p1, o1), pp(p2, o2), pp(p3, o3));
|
||||
}
|
||||
|
||||
result_type operator()(const Point& p0, const Point& p1) const {
|
||||
result_type operator()(const Point& p0, const Point& p1) const
|
||||
{
|
||||
return Predicate()(p0, p1);
|
||||
}
|
||||
result_type operator()(const Point& p0, const Point& p1,
|
||||
const Point& p2) const {
|
||||
const Point& p2) const
|
||||
{
|
||||
return Predicate()(p0, p1, p2);
|
||||
}
|
||||
result_type operator()(const Point& p0, const Point& p1,
|
||||
const Point& p2, const Point& p3) const {
|
||||
const Point& p2, const Point& p3) const
|
||||
{
|
||||
return Predicate()(p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
Point pp(const Point &p, const Offset &o) const {
|
||||
return Point(p.x()+(_domain->xmax()-_domain->xmin())*o.x(),
|
||||
p.y()+(_domain->ymax()-_domain->ymin())*o.y());
|
||||
Point pp(const Point &p, const Offset &o) const
|
||||
{
|
||||
return Point(p.x() + (_domain->xmax() - _domain->xmin()) * o.x(),
|
||||
p.y() + (_domain->ymax() - _domain->ymin()) * o.y());
|
||||
}
|
||||
public:
|
||||
public:
|
||||
const Iso_rectangle_2* _domain;
|
||||
};
|
||||
|
||||
|
|
@ -104,9 +113,10 @@ public:
|
|||
|
||||
Periodic_2_construct_point_2(const Iso_rectangle_2 & dom) : _dom(dom) { }
|
||||
|
||||
Point operator() ( const Point& p, const Offset& o ) const {
|
||||
return Point(p.x()+(_dom.xmax()-_dom.xmin())*o.x(),
|
||||
p.y()+(_dom.ymax()-_dom.ymin())*o.y());
|
||||
Point operator() ( const Point& p, const Offset& o ) const
|
||||
{
|
||||
return Point(p.x() + (_dom.xmax() - _dom.xmin()) * o.x(),
|
||||
p.y() + (_dom.ymax() - _dom.ymin()) * o.y());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -115,12 +125,13 @@ private:
|
|||
|
||||
|
||||
template < class Kernel, class Off = typename CGAL::Periodic_2_offset_2 >
|
||||
class Periodic_2_triangulation_traits_base_2 : public Kernel {
|
||||
class Periodic_2_triangulation_traits_base_2 : public Kernel
|
||||
{
|
||||
public: // Undocumented
|
||||
typedef Kernel K;
|
||||
typedef Kernel Kernel_base;
|
||||
typedef Off Offset_2;
|
||||
typedef Periodic_2_triangulation_traits_base_2<Kernel, Off> Self;
|
||||
typedef Periodic_2_triangulation_traits_base_2<Kernel, Off> Self;
|
||||
|
||||
typedef typename K::FT FT;
|
||||
typedef typename K::RT RT;
|
||||
|
|
@ -154,20 +165,25 @@ public:
|
|||
typedef Traits_with_offsets_2_adaptor<Self, typename K::Construct_triangle_2> Construct_triangle_2;
|
||||
typedef Traits_with_offsets_2_adaptor<Self, typename K::Construct_direction_2> Construct_direction_2;
|
||||
typedef Traits_with_offsets_2_adaptor<Self, typename K::Construct_ray_2> Construct_ray_2;
|
||||
|
||||
Periodic_2_triangulation_traits_base_2() : _domain(Iso_rectangle_2(0,0,1,1)) {
|
||||
|
||||
Periodic_2_triangulation_traits_base_2() : _domain(Iso_rectangle_2(0, 0, 1, 1))
|
||||
{
|
||||
}
|
||||
Periodic_2_triangulation_traits_base_2(const Periodic_2_triangulation_traits_base_2 &) {}
|
||||
Periodic_2_triangulation_traits_base_2 &operator=
|
||||
(const Periodic_2_triangulation_traits_base_2 &)
|
||||
{return *this;}
|
||||
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Access
|
||||
void set_domain(const Iso_rectangle_2& domain) {
|
||||
void set_domain(const Iso_rectangle_2& domain)
|
||||
{
|
||||
_domain = domain;
|
||||
}
|
||||
|
||||
Iso_rectangle_2 get_domain() const {
|
||||
|
||||
Iso_rectangle_2 get_domain() const
|
||||
{
|
||||
return _domain;
|
||||
}
|
||||
|
||||
|
|
@ -175,40 +191,61 @@ public:
|
|||
|
||||
Compare_x_2
|
||||
compare_x_2_object() const
|
||||
{ return Compare_x_2(&_domain);}
|
||||
|
||||
{
|
||||
return Compare_x_2(&_domain);
|
||||
}
|
||||
|
||||
Compare_y_2
|
||||
compare_y_2_object() const
|
||||
{ return Compare_y_2(&_domain);}
|
||||
|
||||
{
|
||||
return Compare_y_2(&_domain);
|
||||
}
|
||||
|
||||
Compare_xy_2
|
||||
compare_xy_2_object() const
|
||||
{ return Compare_xy_2(&_domain);}
|
||||
|
||||
{
|
||||
return Compare_xy_2(&_domain);
|
||||
}
|
||||
|
||||
Orientation_2
|
||||
orientation_2_object() const { return Orientation_2(&_domain); }
|
||||
|
||||
orientation_2_object() const
|
||||
{
|
||||
return Orientation_2(&_domain);
|
||||
}
|
||||
|
||||
Side_of_oriented_circle_2
|
||||
side_of_oriented_circle_2_object() const
|
||||
{return Side_of_oriented_circle_2(&_domain);}
|
||||
|
||||
{
|
||||
return Side_of_oriented_circle_2(&_domain);
|
||||
}
|
||||
|
||||
Construct_circumcenter_2
|
||||
construct_circumcenter_2_object() const
|
||||
{ return Construct_circumcenter_2(&_domain);}
|
||||
|
||||
{
|
||||
return Construct_circumcenter_2(&_domain);
|
||||
}
|
||||
|
||||
Compare_distance_2
|
||||
compare_distance_2_object() const
|
||||
{return Compare_distance_2(&_domain);}
|
||||
|
||||
{
|
||||
return Compare_distance_2(&_domain);
|
||||
}
|
||||
|
||||
Construct_point_2 construct_point_2_object() const
|
||||
{return Construct_point_2(_domain);}
|
||||
{
|
||||
return Construct_point_2(_domain);
|
||||
}
|
||||
|
||||
Construct_segment_2 construct_segment_2_object() const
|
||||
{return Construct_segment_2(&_domain);}
|
||||
{
|
||||
return Construct_segment_2(&_domain);
|
||||
}
|
||||
|
||||
Construct_triangle_2 construct_triangle_2_object() const
|
||||
{return Construct_triangle_2(&_domain);}
|
||||
|
||||
{
|
||||
return Construct_triangle_2(&_domain);
|
||||
}
|
||||
|
||||
protected:
|
||||
Iso_rectangle_2 _domain;
|
||||
};
|
||||
|
|
@ -218,7 +255,7 @@ protected:
|
|||
template < typename K, typename Off = CGAL::Periodic_2_offset_2, bool Has_filtered_predicates = K::Has_filtered_predicates >
|
||||
class Periodic_2_triangulation_traits_2;
|
||||
|
||||
} //namespace CGAL
|
||||
} //namespace CGAL
|
||||
|
||||
|
||||
// Partial specialization for Filtered_kernel<CK>.
|
||||
|
|
@ -227,7 +264,8 @@ class Periodic_2_triangulation_traits_2;
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Periodic_2_triangulation_filtered_traits_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
// This declaration is needed to break the cyclic dependency.
|
||||
template < typename K, typename Off >
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// $URL: svn+ssh://nicokruithof@scm.gforge.inria.fr/svnroot/cgal/trunk/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_vertex_base_2.h $
|
||||
// $Id: Periodic_2_triangulation_vertex_base_2.h 56667 2010-06-09 07:37:13Z sloriot $
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr>
|
||||
// Manuel Caroli <Manuel.Caroli@sophia.inria.fr>
|
||||
|
|
@ -26,7 +26,8 @@
|
|||
#include <CGAL/Dummy_tds_2.h>
|
||||
#include <CGAL/Periodic_2_offset_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
|
||||
template < class Gt, class Vb = CGAL::Triangulation_vertex_base_2<Gt> >
|
||||
|
|
@ -45,9 +46,10 @@ public:
|
|||
typedef Periodic_2_offset_2 Offset;
|
||||
|
||||
template < typename Tds2 >
|
||||
struct Rebind_TDS {
|
||||
struct Rebind_TDS
|
||||
{
|
||||
typedef typename Vb::template Rebind_TDS<Tds2>::Other Vb2;
|
||||
typedef Periodic_2_triangulation_vertex_base_2<Gt,Vb2> Other;
|
||||
typedef Periodic_2_triangulation_vertex_base_2<Gt, Vb2> Other;
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
@ -55,24 +57,29 @@ public:
|
|||
Periodic_2_triangulation_vertex_base_2(const Point & p)
|
||||
: Base(p), _off(), _offset_flag(false) {}
|
||||
Periodic_2_triangulation_vertex_base_2(const Point & p, Face_handle f)
|
||||
: Base(f,p), _off(), _offset_flag(false) {}
|
||||
: Base(f, p), _off(), _offset_flag(false) {}
|
||||
Periodic_2_triangulation_vertex_base_2(Face_handle f)
|
||||
: Base(f), _off(), _offset_flag(false) {}
|
||||
|
||||
const Offset& offset() const {
|
||||
const Offset& offset() const
|
||||
{
|
||||
return _off;
|
||||
}
|
||||
|
||||
void set_offset(const Offset& off) {
|
||||
_off = off; _offset_flag=true;
|
||||
|
||||
void set_offset(const Offset& off)
|
||||
{
|
||||
_off = off;
|
||||
_offset_flag = true;
|
||||
}
|
||||
|
||||
void clear_offset() {
|
||||
_offset_flag=false;
|
||||
void clear_offset()
|
||||
{
|
||||
_offset_flag = false;
|
||||
_off = Offset();
|
||||
}
|
||||
|
||||
bool get_offset_flag() const {
|
||||
bool get_offset_flag() const
|
||||
{
|
||||
return _offset_flag;
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +99,7 @@ template < class Tds >
|
|||
inline
|
||||
std::istream&
|
||||
operator>>(std::istream &is, Periodic_2_triangulation_vertex_base_2<Tds> &)
|
||||
// no combinatorial information.
|
||||
// no combinatorial information.
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
|
@ -101,8 +108,8 @@ template < class Tds >
|
|||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream &os,
|
||||
const Periodic_2_triangulation_vertex_base_2<Tds> &)
|
||||
// no combinatorial information.
|
||||
const Periodic_2_triangulation_vertex_base_2<Tds> &)
|
||||
// no combinatorial information.
|
||||
{
|
||||
return os;
|
||||
}
|
||||
|
|
@ -116,7 +123,8 @@ public:
|
|||
typedef Triangulation_data_structure::Vertex_handle Vertex_handle;
|
||||
typedef Triangulation_data_structure::Face_handle Face_handle;
|
||||
template <typename Tds2>
|
||||
struct Rebind_Tds {
|
||||
struct Rebind_Tds
|
||||
{
|
||||
typedef Periodic_2_triangulation_vertex_base_2<Tds2> Other;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
|
|
@ -79,7 +79,12 @@
|
|||
}
|
||||
*/
|
||||
|
||||
namespace CGAL { namespace internal { namespace Static_filters_predicates {
|
||||
namespace CGAL
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
namespace Static_filters_predicates
|
||||
{
|
||||
|
||||
template < typename K_base >
|
||||
class Periodic_2_orientation_2 : public K_base::Orientation_2
|
||||
|
|
@ -92,174 +97,183 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
|
|||
|
||||
typedef typename K_base::Orientation_2 Base;
|
||||
|
||||
public:
|
||||
public:
|
||||
const Iso_rectangle_2 * const _dom;
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
typedef typename Base::result_type result_type;
|
||||
|
||||
template <class EX, class AP>
|
||||
Periodic_2_orientation_2(const Iso_rectangle_2 * const dom,
|
||||
const EX * dom_e, const AP * dom_f) : Base(dom_e,dom_f), _dom(dom) {
|
||||
Periodic_2_orientation_2(const Iso_rectangle_2 * const dom,
|
||||
const EX * dom_e, const AP * dom_f) : Base(dom_e, dom_f), _dom(dom)
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef CGAL_CFG_MATCHING_BUG_6
|
||||
using Base::operator();
|
||||
#else
|
||||
#else
|
||||
result_type
|
||||
operator()(const Vector_2& u, const Vector_2& v) const
|
||||
{
|
||||
return Base::operator()(u,v);
|
||||
operator()(const Vector_2& u, const Vector_2& v) const
|
||||
{
|
||||
return Base::operator()(u, v);
|
||||
}
|
||||
|
||||
|
||||
result_type
|
||||
operator()(const Circle_2& c) const
|
||||
operator()(const Circle_2& c) const
|
||||
{
|
||||
return Base::operator()(c);
|
||||
}
|
||||
|
||||
result_type operator()(const Point_2 &p,
|
||||
const Point_2 &q,
|
||||
result_type operator()(const Point_2 &p,
|
||||
const Point_2 &q,
|
||||
const Point_2 &r,
|
||||
const Offset_2 &o_p,
|
||||
const Offset_2 &o_q,
|
||||
const Offset_2 &o_r) const {
|
||||
const Offset_2 &o_q,
|
||||
const Offset_2 &o_r) const
|
||||
{
|
||||
return Base::operator()(p, q, r, o_p, o_q, o_r);
|
||||
}
|
||||
#endif
|
||||
/// Normal static orientation test, copied from Orientation_2
|
||||
result_type operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r) const
|
||||
{
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 calls");
|
||||
{
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 calls");
|
||||
|
||||
double px, py, qx, qy, rx, ry;
|
||||
double px, py, qx, qy, rx, ry;
|
||||
|
||||
if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
|
||||
fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) &&
|
||||
fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry))
|
||||
if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
|
||||
fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) &&
|
||||
fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry))
|
||||
{
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 semi-static attempts");
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 semi-static attempts");
|
||||
|
||||
double pqx = qx - px;
|
||||
double pqy = qy - py;
|
||||
double prx = rx - px;
|
||||
double pry = ry - py;
|
||||
double pqx = qx - px;
|
||||
double pqy = qy - py;
|
||||
double prx = rx - px;
|
||||
double pry = ry - py;
|
||||
|
||||
// Then semi-static filter.
|
||||
double maxx = CGAL::abs(pqx);
|
||||
double maxy = CGAL::abs(pqy);
|
||||
// Then semi-static filter.
|
||||
double maxx = CGAL::abs(pqx);
|
||||
double maxy = CGAL::abs(pqy);
|
||||
|
||||
double aprx = CGAL::abs(prx);
|
||||
double apry = CGAL::abs(pry);
|
||||
double aprx = CGAL::abs(prx);
|
||||
double apry = CGAL::abs(pry);
|
||||
|
||||
if (maxx < aprx) maxx = aprx;
|
||||
if (maxy < apry) maxy = apry;
|
||||
double eps = 5.1107127829973299e-15 * maxx * maxy;
|
||||
double det = CGAL::determinant(pqx, pqy,
|
||||
prx, pry);
|
||||
if (maxx < aprx) maxx = aprx;
|
||||
if (maxy < apry) maxy = apry;
|
||||
double eps = 5.1107127829973299e-15 * maxx * maxy;
|
||||
double det = CGAL::determinant(pqx, pqy,
|
||||
prx, pry);
|
||||
|
||||
// Sort maxx < maxy
|
||||
if (maxx > maxy)
|
||||
std::swap(maxx, maxy);
|
||||
// Sort maxx < maxy
|
||||
if (maxx > maxy)
|
||||
std::swap(maxx, maxy);
|
||||
|
||||
// Protect against underflow in the computation of eps.
|
||||
if (maxx < 1e-97) /* cbrt(min_double/eps) */ {
|
||||
// Protect against underflow in the computation of eps.
|
||||
if (maxx < 1e-97) /* cbrt(min_double/eps) */
|
||||
{
|
||||
if (maxx == 0)
|
||||
return ZERO;
|
||||
}
|
||||
// Protect against overflow in the computation of det.
|
||||
else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */ {
|
||||
// Protect against overflow in the computation of det.
|
||||
else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */
|
||||
{
|
||||
if (det > eps) return POSITIVE;
|
||||
if (det < -eps) return NEGATIVE;
|
||||
}
|
||||
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 semi-static failures");
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 semi-static failures");
|
||||
}
|
||||
|
||||
return Base::operator()(p, q, r);
|
||||
return Base::operator()(p, q, r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Static orientation test with offsets
|
||||
result_type operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r,
|
||||
const Offset_2 &o_p, const Offset_2 &o_q, const Offset_2 &o_r) const {
|
||||
const Offset_2 &o_p, const Offset_2 &o_q, const Offset_2 &o_r) const
|
||||
{
|
||||
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 with offset calls");
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 with offset calls");
|
||||
|
||||
double px, py, qx, qy, rx, ry;
|
||||
double domxmax, domxmin, domymax, domymin;
|
||||
int opx = o_p.x();
|
||||
int opy = o_p.y();
|
||||
double px, py, qx, qy, rx, ry;
|
||||
double domxmax, domxmin, domymax, domymin;
|
||||
int opx = o_p.x();
|
||||
int opy = o_p.y();
|
||||
|
||||
if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
|
||||
fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) &&
|
||||
fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) &&
|
||||
fit_in_double(_dom->xmax(), domxmax) &&
|
||||
fit_in_double(_dom->xmin(), domxmin) &&
|
||||
fit_in_double(_dom->ymax(), domymax) &&
|
||||
fit_in_double(_dom->ymin(), domymin))
|
||||
if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) &&
|
||||
fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) &&
|
||||
fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) &&
|
||||
fit_in_double(_dom->xmax(), domxmax) &&
|
||||
fit_in_double(_dom->xmin(), domxmin) &&
|
||||
fit_in_double(_dom->ymax(), domymax) &&
|
||||
fit_in_double(_dom->ymin(), domymin))
|
||||
{
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static attempts");
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static attempts");
|
||||
|
||||
double domx = domxmax - domxmin;
|
||||
double domy = domymax - domymin;
|
||||
double domx = domxmax - domxmin;
|
||||
double domy = domymax - domymin;
|
||||
|
||||
double pqx = qx - px + domx * ( o_q.x() - opx );
|
||||
double pqy = qy - py + domy * ( o_q.y() - opy );
|
||||
double prx = rx - px + domx * ( o_r.x() - opx );
|
||||
double pry = ry - py + domy * ( o_r.y() - opy );
|
||||
double pqx = qx - px + domx * ( o_q.x() - opx );
|
||||
double pqy = qy - py + domy * ( o_q.y() - opy );
|
||||
double prx = rx - px + domx * ( o_r.x() - opx );
|
||||
double pry = ry - py + domy * ( o_r.y() - opy );
|
||||
|
||||
// Then semi-static filter.
|
||||
double maxx = CGAL::abs(pqx);
|
||||
double maxy = CGAL::abs(pqy);
|
||||
// Then semi-static filter.
|
||||
double maxx = CGAL::abs(pqx);
|
||||
double maxy = CGAL::abs(pqy);
|
||||
|
||||
double aprx = CGAL::abs(prx);
|
||||
double apry = CGAL::abs(pry);
|
||||
double aprx = CGAL::abs(prx);
|
||||
double apry = CGAL::abs(pry);
|
||||
|
||||
if (maxx < aprx) maxx = aprx;
|
||||
if (maxy < apry) maxy = apry;
|
||||
double eps = 4.111024169857068197e-15 * maxx * maxy;
|
||||
double det = CGAL::determinant(pqx, pqy,
|
||||
prx, pry);
|
||||
if (maxx < aprx) maxx = aprx;
|
||||
if (maxy < apry) maxy = apry;
|
||||
double eps = 4.111024169857068197e-15 * maxx * maxy;
|
||||
double det = CGAL::determinant(pqx, pqy,
|
||||
prx, pry);
|
||||
|
||||
// Sort maxx < maxy.
|
||||
if (maxx > maxy)
|
||||
std::swap(maxx, maxy);
|
||||
// Sort maxx < maxy.
|
||||
if (maxx > maxy)
|
||||
std::swap(maxx, maxy);
|
||||
|
||||
// Protect against underflow in the computation of eps.
|
||||
if (maxx < 1e-97) /* cbrt(min_double/eps) */ {
|
||||
// Protect against underflow in the computation of eps.
|
||||
if (maxx < 1e-97) /* cbrt(min_double/eps) */
|
||||
{
|
||||
if (maxx == 0)
|
||||
return ZERO;
|
||||
}
|
||||
// Protect against overflow in the computation of det.
|
||||
else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */ {
|
||||
// Protect against overflow in the computation of det.
|
||||
else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */
|
||||
{
|
||||
if (det > eps) return POSITIVE;
|
||||
if (det < -eps) return NEGATIVE;
|
||||
}
|
||||
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static failures");
|
||||
CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static failures");
|
||||
}
|
||||
|
||||
return Base::operator()(p,q,r,o_p,o_q,o_r);
|
||||
return Base::operator()(p, q, r, o_p, o_q, o_r);
|
||||
}
|
||||
|
||||
// Computes the epsilon for Periodic_2_orientation_2.
|
||||
static double compute_epsilon()
|
||||
{
|
||||
typedef Static_filter_error F;
|
||||
F t1 = F(1, F::ulp()/4); // First translation
|
||||
F t1 = F(1, F::ulp() / 4); // First translation
|
||||
F det = CGAL::determinant(t1, t1, t1,
|
||||
t1, t1, t1,
|
||||
t1, t1, t1); // Full det
|
||||
double err = det.error();
|
||||
err += err * 2 * F::ulp(); // Correction due to "eps * maxx * maxy...".
|
||||
std::cerr << "*** epsilon for Periodic_2_orientation_2 = " << err
|
||||
<< std::endl;
|
||||
std::cerr << "*** epsilon for Periodic_2_orientation_2 = " << err
|
||||
<< std::endl;
|
||||
return err;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} } } // namespace CGAL::internal::Static_filters_predicates
|
||||
}
|
||||
}
|
||||
} // namespace CGAL::internal::Static_filters_predicates
|
||||
|
||||
#endif // CGAL_INTERNAL_STATIC_FILTERS_PERIODIC_2_ORIENTATION_2_H
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//
|
||||
// $URL: svn+ssh://nicokruithof@scm.gforge.inria.fr/svnroot/cgal/trunk/Periodic_3_triangulation_3/include/CGAL/internal/Static_filters/Periodic_3_side_of_oriented_sphere_3.h $
|
||||
// $Id: Periodic_3_side_of_oriented_sphere_3.h 63134 2011-04-26 17:01:34Z sloriot $
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion <Sylvain.Pion@sophia.inria.fr>
|
||||
// Manuel Caroli <Manuel.Caroli@sophia.inria.fr>
|
||||
|
|
@ -27,7 +27,12 @@
|
|||
|
||||
#include <CGAL/Periodic_2_offset_2.h>
|
||||
|
||||
namespace CGAL { namespace internal { namespace Static_filters_predicates {
|
||||
namespace CGAL
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
namespace Static_filters_predicates
|
||||
{
|
||||
|
||||
template < typename K_base >
|
||||
class Periodic_2_side_of_oriented_circle_2
|
||||
|
|
@ -47,9 +52,9 @@ public:
|
|||
|
||||
template <class EX, class AP>
|
||||
Periodic_2_side_of_oriented_circle_2(const Iso_rectangle_2 * dom,
|
||||
const EX * dom_e,
|
||||
const AP * dom_f)
|
||||
: Base(dom_e,dom_f), _dom(dom) { }
|
||||
const EX * dom_e,
|
||||
const AP * dom_f)
|
||||
: Base(dom_e, dom_f), _dom(dom) { }
|
||||
|
||||
Oriented_side
|
||||
operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r,
|
||||
|
|
@ -58,7 +63,7 @@ public:
|
|||
CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Periodic_2_side_of_oriented_circle_2", tmp);
|
||||
|
||||
Get_approx<Point_2> get_approx; // Identity functor for all points
|
||||
// but lazy points.
|
||||
// but lazy points.
|
||||
|
||||
double px, py, qx, qy, rx, ry, tx, ty;
|
||||
|
||||
|
|
@ -66,23 +71,23 @@ public:
|
|||
fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) &&
|
||||
fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry) &&
|
||||
fit_in_double(get_approx(t).x(), tx) && fit_in_double(get_approx(t).y(), ty))
|
||||
{
|
||||
{
|
||||
CGAL_BRANCH_PROFILER_BRANCH_1(tmp);
|
||||
|
||||
double qpx = qx-px;
|
||||
double qpy = qy-py;
|
||||
double rpx = rx-px;
|
||||
double rpy = ry-py;
|
||||
double tpx = tx-px;
|
||||
double tpy = ty-py;
|
||||
double qpx = qx - px;
|
||||
double qpy = qy - py;
|
||||
double rpx = rx - px;
|
||||
double rpy = ry - py;
|
||||
double tpx = tx - px;
|
||||
double tpy = ty - py;
|
||||
|
||||
double tqx = tx-qx;
|
||||
double tqy = ty-qy;
|
||||
double rqx = rx-qx;
|
||||
double rqy = ry-qy;
|
||||
double tqx = tx - qx;
|
||||
double tqy = ty - qy;
|
||||
double rqx = rx - qx;
|
||||
double rqy = ry - qy;
|
||||
|
||||
double det = CGAL::determinant(qpx*tpy - qpy*tpx, tpx*tqx + tpy*tqy,
|
||||
qpx*rpy - qpy*rpx, rpx*rqx + rpy*rqy);
|
||||
double det = CGAL::determinant(qpx * tpy - qpy * tpx, tpx * tqx + tpy * tqy,
|
||||
qpx * rpy - qpy * rpx, rpx * rqx + rpy * rqy);
|
||||
|
||||
// We compute the semi-static bound.
|
||||
double maxx = CGAL::abs(qpx);
|
||||
|
|
@ -113,18 +118,20 @@ public:
|
|||
if (maxx > maxy) std::swap(maxx, maxy);
|
||||
|
||||
// Protect against underflow in the computation of eps.
|
||||
if (maxx < 1e-73) {
|
||||
if (maxx == 0)
|
||||
return ON_ORIENTED_BOUNDARY;
|
||||
}
|
||||
else if (maxy < 1e76) /* sqrt(sqrt(max_double/16 [hadamard])) */ {
|
||||
double eps = 8.8878565762001373e-15 * maxx * maxy * (maxy*maxy);
|
||||
if (det > eps) return ON_POSITIVE_SIDE;
|
||||
if (det < -eps) return ON_NEGATIVE_SIDE;
|
||||
}
|
||||
if (maxx < 1e-73)
|
||||
{
|
||||
if (maxx == 0)
|
||||
return ON_ORIENTED_BOUNDARY;
|
||||
}
|
||||
else if (maxy < 1e76) /* sqrt(sqrt(max_double/16 [hadamard])) */
|
||||
{
|
||||
double eps = 8.8878565762001373e-15 * maxx * maxy * (maxy * maxy);
|
||||
if (det > eps) return ON_POSITIVE_SIDE;
|
||||
if (det < -eps) return ON_NEGATIVE_SIDE;
|
||||
}
|
||||
|
||||
CGAL_BRANCH_PROFILER_BRANCH_2(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
return Base::operator()(p, q, r, t);
|
||||
}
|
||||
|
|
@ -133,7 +140,8 @@ public:
|
|||
operator()(const Point_2 &p, const Point_2 &q,
|
||||
const Point_2 &r, const Point_2 &s,
|
||||
const Offset &o_p, const Offset &o_q,
|
||||
const Offset &o_r, const Offset &o_s) const {
|
||||
const Offset &o_r, const Offset &o_s) const
|
||||
{
|
||||
|
||||
CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 calls");
|
||||
|
||||
|
|
@ -146,65 +154,68 @@ public:
|
|||
fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) &&
|
||||
fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) &&
|
||||
fit_in_double(s.x(), sx) && fit_in_double(s.y(), sy) &&
|
||||
fit_in_double(_dom->xmax(), domxmax) &&
|
||||
fit_in_double(_dom->xmin(), domxmin) &&
|
||||
fit_in_double(_dom->ymax(), domymax) &&
|
||||
fit_in_double(_dom->ymin(), domymin)) {
|
||||
fit_in_double(_dom->xmax(), domxmax) &&
|
||||
fit_in_double(_dom->xmin(), domxmin) &&
|
||||
fit_in_double(_dom->ymax(), domymax) &&
|
||||
fit_in_double(_dom->ymin(), domymin))
|
||||
{
|
||||
|
||||
CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static attempts");
|
||||
CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static attempts");
|
||||
|
||||
double domx = domxmax - domxmin;
|
||||
double domy = domymax - domymin;
|
||||
double domx = domxmax - domxmin;
|
||||
double domy = domymax - domymin;
|
||||
|
||||
double psx = px - sx + domx * (o_p.x() - osx);
|
||||
double psy = py - sy + domy * (o_p.y() - osy);
|
||||
double pt2 = CGAL_NTS square(psx) + CGAL_NTS square(psy);
|
||||
double qsx = qx - sx + domx * (o_q.x() - osx);
|
||||
double qsy = qy - sy + domy * (o_q.y() - osy);
|
||||
double qt2 = CGAL_NTS square(qsx) + CGAL_NTS square(qsy);
|
||||
double rsx = rx - sx + domx * (o_r.x() - osx);
|
||||
double rsy = ry - sy + domy * (o_r.y() - osy);
|
||||
double rt2 = CGAL_NTS square(rsx) + CGAL_NTS square(rsy);
|
||||
double psx = px - sx + domx * (o_p.x() - osx);
|
||||
double psy = py - sy + domy * (o_p.y() - osy);
|
||||
double pt2 = CGAL_NTS square(psx) + CGAL_NTS square(psy);
|
||||
double qsx = qx - sx + domx * (o_q.x() - osx);
|
||||
double qsy = qy - sy + domy * (o_q.y() - osy);
|
||||
double qt2 = CGAL_NTS square(qsx) + CGAL_NTS square(qsy);
|
||||
double rsx = rx - sx + domx * (o_r.x() - osx);
|
||||
double rsy = ry - sy + domy * (o_r.y() - osy);
|
||||
double rt2 = CGAL_NTS square(rsx) + CGAL_NTS square(rsy);
|
||||
|
||||
// Compute the semi-static bound.
|
||||
double maxx = CGAL::abs(psx);
|
||||
double maxy = CGAL::abs(psy);
|
||||
|
||||
double aqsx = CGAL::abs(qsx);
|
||||
double aqsy = CGAL::abs(qsy);
|
||||
// Compute the semi-static bound.
|
||||
double maxx = CGAL::abs(psx);
|
||||
double maxy = CGAL::abs(psy);
|
||||
|
||||
double arsx = CGAL::abs(rsx);
|
||||
double arsy = CGAL::abs(rsy);
|
||||
|
||||
if (maxx < aqsx) maxx = aqsx;
|
||||
if (maxx < arsx) maxx = arsx;
|
||||
double aqsx = CGAL::abs(qsx);
|
||||
double aqsy = CGAL::abs(qsy);
|
||||
|
||||
if (maxy < aqsy) maxy = aqsy;
|
||||
if (maxy < arsy) maxy = arsy;
|
||||
double arsx = CGAL::abs(rsx);
|
||||
double arsy = CGAL::abs(rsy);
|
||||
|
||||
// Sort maxx < maxy.
|
||||
if (maxx > maxy)
|
||||
if (maxx < aqsx) maxx = aqsx;
|
||||
if (maxx < arsx) maxx = arsx;
|
||||
|
||||
if (maxy < aqsy) maxy = aqsy;
|
||||
if (maxy < arsy) maxy = arsy;
|
||||
|
||||
// Sort maxx < maxy.
|
||||
if (maxx > maxy)
|
||||
std::swap(maxx, maxy);
|
||||
|
||||
double eps = 1.0466759304746772485e-13 * maxx * maxy * (maxy * maxy);
|
||||
|
||||
double det = CGAL::determinant(psx, psy, pt2,
|
||||
qsx, qsy, qt2,
|
||||
rsx, rsy, rt2);
|
||||
double eps = 1.0466759304746772485e-13 * maxx * maxy * (maxy * maxy);
|
||||
|
||||
// Protect against underflow in the computation of eps.
|
||||
if (maxx < 1e-58) /* sqrt^5(min_double/eps) */ {
|
||||
if (maxx == 0)
|
||||
return ON_ORIENTED_BOUNDARY;
|
||||
}
|
||||
// Protect against overflow in the computation of det.
|
||||
else if (maxy < 1e61) /* sqrt^5(max_double/4 [hadamard]) */ {
|
||||
if (det > eps) return ON_POSITIVE_SIDE;
|
||||
if (det < -eps) return ON_NEGATIVE_SIDE;
|
||||
}
|
||||
double det = CGAL::determinant(psx, psy, pt2,
|
||||
qsx, qsy, qt2,
|
||||
rsx, rsy, rt2);
|
||||
|
||||
CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static failures");
|
||||
}
|
||||
// Protect against underflow in the computation of eps.
|
||||
if (maxx < 1e-58) /* sqrt^5(min_double/eps) */
|
||||
{
|
||||
if (maxx == 0)
|
||||
return ON_ORIENTED_BOUNDARY;
|
||||
}
|
||||
// Protect against overflow in the computation of det.
|
||||
else if (maxy < 1e61) /* sqrt^5(max_double/4 [hadamard]) */
|
||||
{
|
||||
if (det > eps) return ON_POSITIVE_SIDE;
|
||||
if (det < -eps) return ON_NEGATIVE_SIDE;
|
||||
}
|
||||
|
||||
CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static failures");
|
||||
}
|
||||
return Base::operator()(p, q, r, s, o_p, o_q, o_r, o_s);
|
||||
}
|
||||
|
||||
|
|
@ -212,8 +223,8 @@ public:
|
|||
static double compute_epsilon()
|
||||
{
|
||||
typedef Static_filter_error F;
|
||||
F t1 = F(1,F::ulp()/4); // First translations
|
||||
F sq = t1*t1+t1*t1+t1*t1; // squares
|
||||
F t1 = F(1, F::ulp() / 4); // First translations
|
||||
F sq = t1 * t1 + t1 * t1 + t1 * t1; // squares
|
||||
F det = CGAL::determinant(t1, t1, t1, sq,
|
||||
t1, t1, t1, sq,
|
||||
t1, t1, t1, sq,
|
||||
|
|
@ -222,11 +233,13 @@ public:
|
|||
err += err * 3 * F::ulp(); // Correction due to "eps * maxx * ...".
|
||||
|
||||
std::cerr << "*** epsilon for Periodic_2_side_of_oriented_circle_2 = "
|
||||
<< err << std::endl;
|
||||
<< err << std::endl;
|
||||
return err;
|
||||
}
|
||||
};
|
||||
|
||||
} } } // namespace CGAL::internal::Static_filters_predicates
|
||||
}
|
||||
}
|
||||
} // namespace CGAL::internal::Static_filters_predicates
|
||||
|
||||
#endif // CGAL_INTERNAL_STATIC_FILTERS_PERIODIC_2_SIDE_OF_ORIENTED_CIRCLE_2_H
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
template <class T>
|
||||
void test_constructor() {
|
||||
void test_constructor()
|
||||
{
|
||||
typedef typename T::Iso_rectangle Iso_rectangle;
|
||||
typedef typename T::Geom_traits Geom_traits;
|
||||
typedef typename T::Point Point;
|
||||
|
|
@ -14,8 +15,8 @@ void test_constructor() {
|
|||
CGAL_assertion(t == t2);
|
||||
T t3 = t2;
|
||||
CGAL_assertion(t == t3);
|
||||
T t4(Iso_rectangle(0,0,2,2));
|
||||
T t5(Iso_rectangle(0,0,2,2), Geom_traits());
|
||||
T t4(Iso_rectangle(0, 0, 2, 2));
|
||||
T t5(Iso_rectangle(0, 0, 2, 2), Geom_traits());
|
||||
t5.clear();
|
||||
|
||||
t.insert(Point(0.5, 0.5));
|
||||
|
|
@ -38,7 +39,8 @@ void test_constructor() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_global_access() {
|
||||
void test_global_access()
|
||||
{
|
||||
T t;
|
||||
const T &t_const = t;
|
||||
|
||||
|
|
@ -76,7 +78,8 @@ void test_global_access() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_geometric_access() {
|
||||
void test_geometric_access()
|
||||
{
|
||||
typedef typename T::Point Point;
|
||||
typedef typename T::Segment Segment;
|
||||
typedef typename T::Triangle Triangle;
|
||||
|
|
@ -116,7 +119,8 @@ void test_geometric_access() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_predicates() {
|
||||
void test_predicates()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Face_handle Face_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
|
@ -128,15 +132,17 @@ void test_predicates() {
|
|||
Vertex_handle vh2 = t.insert(Point(0.7, 0.7));
|
||||
|
||||
t.is_edge(vh0, vh1);
|
||||
Face_handle fh; int i;
|
||||
Face_handle fh;
|
||||
int i;
|
||||
t.is_edge(vh0, vh1, fh, i);
|
||||
|
||||
|
||||
t.is_face(vh0, vh1, vh2);
|
||||
t.is_face(vh0, vh1, vh2, fh);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_queries() {
|
||||
void test_queries()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Face_handle Face_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
|
@ -156,7 +162,8 @@ void test_queries() {
|
|||
Face_handle fh = t_const.locate(p0);
|
||||
fh = t_const.locate(Point(0.5, 0.5), fh);
|
||||
|
||||
typename T::Locate_type lt; int li;
|
||||
typename T::Locate_type lt;
|
||||
int li;
|
||||
fh = t_const.locate(p0, lt, li);
|
||||
fh = t_const.locate(p0, lt, li, fh);
|
||||
|
||||
|
|
@ -164,7 +171,8 @@ void test_queries() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_iterators() {
|
||||
void test_iterators()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Face_handle Face_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
|
@ -183,116 +191,139 @@ void test_iterators() {
|
|||
// vertices
|
||||
size_t size = 0;
|
||||
for (typename T::Vertex_iterator vit = t_const.vertices_begin();
|
||||
vit != t_const.vertices_end(); ++vit) {
|
||||
++size;
|
||||
}
|
||||
vit != t_const.vertices_end(); ++vit)
|
||||
{
|
||||
++size;
|
||||
}
|
||||
CGAL_assertion(size == t_const.number_of_stored_vertices());
|
||||
size = 0;
|
||||
for (typename T::Unique_vertex_iterator uvit = t_const.unique_vertices_begin();
|
||||
uvit != t_const.unique_vertices_end(); ++uvit) {
|
||||
++size;
|
||||
}
|
||||
uvit != t_const.unique_vertices_end(); ++uvit)
|
||||
{
|
||||
++size;
|
||||
}
|
||||
CGAL_assertion(size == t_const.number_of_vertices());
|
||||
size = 0;
|
||||
for (typename T::Vertex_iterator vit = t_const.all_vertices_begin();
|
||||
vit != t_const.all_vertices_end(); ++vit) {
|
||||
++size;
|
||||
}
|
||||
vit != t_const.all_vertices_end(); ++vit)
|
||||
{
|
||||
++size;
|
||||
}
|
||||
CGAL_assertion(size == t_const.number_of_stored_vertices());
|
||||
|
||||
// edges
|
||||
size = 0;
|
||||
for (typename T::Edge_iterator eit = t_const.edges_begin();
|
||||
eit != t_const.edges_end(); ++eit) {
|
||||
++size;
|
||||
}
|
||||
eit != t_const.edges_end(); ++eit)
|
||||
{
|
||||
++size;
|
||||
}
|
||||
CGAL_assertion(size == t_const.number_of_stored_edges());
|
||||
size = 0;
|
||||
for (typename T::Edge_iterator eit = t_const.all_edges_begin();
|
||||
eit != t_const.all_edges_end(); ++eit) {
|
||||
++size;
|
||||
}
|
||||
eit != t_const.all_edges_end(); ++eit)
|
||||
{
|
||||
++size;
|
||||
}
|
||||
CGAL_assertion(size == t_const.number_of_stored_edges());
|
||||
|
||||
// faces
|
||||
size = 0;
|
||||
for (typename T::Face_iterator fit = t_const.faces_begin();
|
||||
fit != t_const.faces_end(); ++fit) {
|
||||
++size;
|
||||
}
|
||||
fit != t_const.faces_end(); ++fit)
|
||||
{
|
||||
++size;
|
||||
}
|
||||
CGAL_assertion(size == t_const.number_of_stored_faces());
|
||||
size = 0;
|
||||
for (typename T::All_faces_iterator fit = t_const.all_faces_begin();
|
||||
fit != t_const.all_faces_end(); ++fit) {
|
||||
++size;
|
||||
}
|
||||
fit != t_const.all_faces_end(); ++fit)
|
||||
{
|
||||
++size;
|
||||
}
|
||||
CGAL_assertion(size == t_const.number_of_stored_faces());
|
||||
|
||||
/// Geometric iterators
|
||||
for (typename T::Periodic_point_iterator ppit = t_const.periodic_points_begin();
|
||||
ppit != t_const.periodic_points_end(); ++ppit) {
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
ppit != t_const.periodic_points_end(); ++ppit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
t_const.periodic_points_begin(T::STORED);
|
||||
ppit != t_const.periodic_points_end(T::STORED); ++ppit) {
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
ppit != t_const.periodic_points_end(T::STORED); ++ppit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
t_const.periodic_points_begin(T::UNIQUE);
|
||||
ppit != t_const.periodic_points_end(T::UNIQUE); ++ppit) {
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
ppit != t_const.periodic_points_end(T::UNIQUE); ++ppit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
t_const.periodic_points_begin(T::STORED_COVER_DOMAIN);
|
||||
ppit != t_const.periodic_points_end(T::STORED_COVER_DOMAIN); ++ppit) {
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
ppit != t_const.periodic_points_end(T::STORED_COVER_DOMAIN); ++ppit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_point_iterator ppit =
|
||||
t_const.periodic_points_begin(T::UNIQUE_COVER_DOMAIN);
|
||||
ppit != t_const.periodic_points_end(T::UNIQUE_COVER_DOMAIN); ++ppit) {
|
||||
}
|
||||
ppit != t_const.periodic_points_end(T::UNIQUE_COVER_DOMAIN); ++ppit)
|
||||
{
|
||||
}
|
||||
|
||||
for (typename T::Periodic_segment_iterator psit = t_const.periodic_segments_begin();
|
||||
psit != t_const.periodic_segments_end(); ++psit) {
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
psit != t_const.periodic_segments_end(); ++psit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
t_const.periodic_segments_begin(T::STORED);
|
||||
psit != t_const.periodic_segments_end(T::STORED); ++psit) {
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
psit != t_const.periodic_segments_end(T::STORED); ++psit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
t_const.periodic_segments_begin(T::UNIQUE);
|
||||
psit != t_const.periodic_segments_end(T::UNIQUE); ++psit) {
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
psit != t_const.periodic_segments_end(T::UNIQUE); ++psit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
t_const.periodic_segments_begin(T::STORED_COVER_DOMAIN);
|
||||
psit != t_const.periodic_segments_end(T::STORED_COVER_DOMAIN); ++psit) {
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
psit != t_const.periodic_segments_end(T::STORED_COVER_DOMAIN); ++psit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_segment_iterator psit =
|
||||
t_const.periodic_segments_begin(T::UNIQUE_COVER_DOMAIN);
|
||||
psit != t_const.periodic_segments_end(T::UNIQUE_COVER_DOMAIN); ++psit) {
|
||||
}
|
||||
psit != t_const.periodic_segments_end(T::UNIQUE_COVER_DOMAIN); ++psit)
|
||||
{
|
||||
}
|
||||
|
||||
for (typename T::Periodic_triangle_iterator ptit = t_const.periodic_triangles_begin();
|
||||
ptit != t_const.periodic_triangles_end(); ++ptit) {
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
ptit != t_const.periodic_triangles_end(); ++ptit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
t_const.periodic_triangles_begin(T::STORED);
|
||||
ptit != t_const.periodic_triangles_end(T::STORED); ++ptit) {
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
ptit != t_const.periodic_triangles_end(T::STORED); ++ptit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
t_const.periodic_triangles_begin(T::UNIQUE);
|
||||
ptit != t_const.periodic_triangles_end(T::UNIQUE); ++ptit) {
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
ptit != t_const.periodic_triangles_end(T::UNIQUE); ++ptit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
t_const.periodic_triangles_begin(T::STORED_COVER_DOMAIN);
|
||||
ptit != t_const.periodic_triangles_end(T::STORED_COVER_DOMAIN); ++ptit) {
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
ptit != t_const.periodic_triangles_end(T::STORED_COVER_DOMAIN); ++ptit)
|
||||
{
|
||||
}
|
||||
for (typename T::Periodic_triangle_iterator ptit =
|
||||
t_const.periodic_triangles_begin(T::UNIQUE_COVER_DOMAIN);
|
||||
ptit != t_const.periodic_triangles_end(T::UNIQUE_COVER_DOMAIN); ++ptit) {
|
||||
}
|
||||
ptit != t_const.periodic_triangles_end(T::UNIQUE_COVER_DOMAIN); ++ptit)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void test_circulators() {
|
||||
void test_circulators()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Face_handle Face_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
|
@ -323,7 +354,8 @@ void test_circulators() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_modifiers() {
|
||||
void test_modifiers()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Face_handle Face_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
|
@ -348,7 +380,8 @@ void test_modifiers() {
|
|||
vh1 = t.insert(p1);
|
||||
vh2 = t.insert(p2);
|
||||
|
||||
typename T::Locate_type lt; int li;
|
||||
typename T::Locate_type lt;
|
||||
int li;
|
||||
fh = t_const.locate(p0, lt, li);
|
||||
t.insert(p0, lt, fh, li);
|
||||
t.push_back(p0);
|
||||
|
|
@ -360,10 +393,11 @@ void test_modifiers() {
|
|||
t.clear();
|
||||
vh0 = t.insert_first(p0);
|
||||
vh1 = t.insert(p1);
|
||||
if (t.degree(vh1) == 3) {
|
||||
// The vertex has degree 6 in case we are testing the Delaunay triangulation
|
||||
t.remove_degree_3(vh1);
|
||||
}
|
||||
if (t.degree(vh1) == 3)
|
||||
{
|
||||
// The vertex has degree 6 in case we are testing the Delaunay triangulation
|
||||
t.remove_degree_3(vh1);
|
||||
}
|
||||
|
||||
t.clear();
|
||||
vh0 = t.insert_first(p0);
|
||||
|
|
@ -376,12 +410,14 @@ void test_modifiers() {
|
|||
t.insert_in_edge(p2, fh, li);
|
||||
|
||||
for (typename T::Vertex_iterator vit = t_const.vertices_begin();
|
||||
vit != t_const.vertices_end(); ++vit) {
|
||||
if (t_const.degree(vit) == 3) {
|
||||
t.remove_degree_3(vit);
|
||||
vit = t_const.vertices_begin();
|
||||
vit != t_const.vertices_end(); ++vit)
|
||||
{
|
||||
if (t_const.degree(vit) == 3)
|
||||
{
|
||||
t.remove_degree_3(vit);
|
||||
vit = t_const.vertices_begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.clear();
|
||||
vh0 = t.insert(p0);
|
||||
|
|
@ -391,7 +427,8 @@ void test_modifiers() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_miscellaneous() {
|
||||
void test_miscellaneous()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Face_handle Face_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
|
@ -406,10 +443,10 @@ void test_miscellaneous() {
|
|||
vh1 = t.insert(p1);
|
||||
vh2 = t.insert(p2);
|
||||
|
||||
t.set_domain(typename T::Iso_rectangle(0,0,2,2));
|
||||
t.set_domain(typename T::Iso_rectangle(0, 0, 2, 2));
|
||||
int i = t.ccw(0);
|
||||
int j = t.cw(0);
|
||||
CGAL_assertion(i+j == 3);
|
||||
CGAL_assertion(i + j == 3);
|
||||
|
||||
t = T();
|
||||
vh0 = t.insert(p0);
|
||||
|
|
@ -427,35 +464,40 @@ void test_miscellaneous() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_io(T &pt1, bool ex) {
|
||||
void test_io(T &pt1, bool ex)
|
||||
{
|
||||
// std::cout << "I/O" << std::endl;
|
||||
// std::cout << " ascii" << std::endl;
|
||||
|
||||
|
||||
std::stringstream ss1;
|
||||
ss1 << pt1;
|
||||
|
||||
T pt1r;
|
||||
ss1 >> pt1r;
|
||||
|
||||
|
||||
assert(CGAL::is_ascii(ss1));
|
||||
if (!ex) { assert(pt1 == pt1r); }
|
||||
if (!ex)
|
||||
{
|
||||
assert(pt1 == pt1r);
|
||||
}
|
||||
|
||||
// std::cout << " binary" << std::endl;
|
||||
pt1r.clear();
|
||||
// There are problems with the IO of exact number types in binary mode.
|
||||
if (!ex) {
|
||||
std::stringstream ss1b;
|
||||
CGAL::set_binary_mode(ss1b);
|
||||
ss1b << pt1;
|
||||
|
||||
ss1b >> pt1r;
|
||||
assert(CGAL::is_binary(ss1b));
|
||||
if (!ex)
|
||||
{
|
||||
std::stringstream ss1b;
|
||||
CGAL::set_binary_mode(ss1b);
|
||||
ss1b << pt1;
|
||||
|
||||
assert(pt1 == pt1r);
|
||||
}
|
||||
ss1b >> pt1r;
|
||||
assert(CGAL::is_binary(ss1b));
|
||||
|
||||
assert(pt1 == pt1r);
|
||||
}
|
||||
|
||||
// std::cout << " pretty" << std::endl;
|
||||
|
||||
|
||||
pt1r.clear();
|
||||
std::stringstream ss1p;
|
||||
CGAL::set_pretty_mode(ss1p);
|
||||
|
|
@ -465,7 +507,8 @@ void test_io(T &pt1, bool ex) {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_io(bool exact) {
|
||||
void test_io(bool exact)
|
||||
{
|
||||
typedef typename T::Point Point;
|
||||
|
||||
T t;
|
||||
|
|
@ -480,14 +523,15 @@ void test_io(bool exact) {
|
|||
|
||||
// One cover for the Delaunay triangulation
|
||||
t.clear();
|
||||
for (int x=0; x<5; ++x)
|
||||
for (int y=0; y<5; ++y)
|
||||
t.insert(Point(x/5.0, y/5.0));
|
||||
for (int x = 0; x < 5; ++x)
|
||||
for (int y = 0; y < 5; ++y)
|
||||
t.insert(Point(x / 5.0, y / 5.0));
|
||||
test_io(t, exact);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test(bool exact) {
|
||||
void test(bool exact)
|
||||
{
|
||||
test_constructor<T>();
|
||||
test_global_access<T>();
|
||||
test_geometric_access<T>();
|
||||
|
|
@ -503,7 +547,8 @@ void test(bool exact) {
|
|||
|
||||
|
||||
template <class T>
|
||||
void test_batch_insertion() {
|
||||
void test_batch_insertion()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
||||
|
|
@ -530,7 +575,8 @@ void test_batch_insertion() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_nearest() {
|
||||
void test_nearest()
|
||||
{
|
||||
typedef typename T::Vertex_handle Vertex_handle;
|
||||
typedef typename T::Point Point;
|
||||
|
||||
|
|
@ -555,13 +601,14 @@ void test_nearest() {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void test_locally_delaunay() {
|
||||
void test_locally_delaunay()
|
||||
{
|
||||
typedef typename T::Geom_traits Gt;
|
||||
typedef typename Gt::Vector_2 Vector;
|
||||
typedef typename T::Point Point;
|
||||
typedef typename T::Face_iterator Face_iterator;
|
||||
|
||||
typedef CGAL::Creator_uniform_2<typename Gt::FT,Point> Creator;
|
||||
typedef CGAL::Creator_uniform_2<typename Gt::FT, Point> Creator;
|
||||
typedef CGAL::Random_points_in_square_2<Point, Creator> Random_points_in_square;
|
||||
|
||||
T t;
|
||||
|
|
@ -573,26 +620,31 @@ void test_locally_delaunay() {
|
|||
for (int i = 0; i < 10; ++i)
|
||||
t.insert(*(++g) + midpoint);
|
||||
|
||||
for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit) {
|
||||
for (int i=0; i<3; ++i) {
|
||||
CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i)));
|
||||
for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (!t.is_1_cover())
|
||||
t.insert(*(++g) + midpoint);
|
||||
|
||||
for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit) {
|
||||
for (int i=0; i<3; ++i) {
|
||||
CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i)));
|
||||
for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit)
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test_delaunay() {
|
||||
void test_delaunay()
|
||||
{
|
||||
test_batch_insertion<T>();
|
||||
test_nearest<T>();
|
||||
test_locally_delaunay<T>();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ typedef Triangulation_data_structure_2<PTH_Vb, PTH_Fb> PTH_Tds;
|
|||
typedef Periodic_2_Delaunay_triangulation_2<Gt, PTH_Tds> PTH_Dt;
|
||||
typedef Periodic_2_triangulation_hierarchy_2<PTH_Dt> Delaunay_triangulation_hierarchy;
|
||||
|
||||
typedef Creator_uniform_2<double,Point> Creator;
|
||||
typedef Creator_uniform_2<double, Point> Creator;
|
||||
typedef Random_points_in_square_2<Point, Creator> Random_points_in_square;
|
||||
typedef Random_points_on_circle_2<Point, Creator> Random_points_on_circle;
|
||||
#endif // P2T2_UNIT_TEST_TYPES_H
|
||||
|
|
|
|||
|
|
@ -6,17 +6,19 @@
|
|||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
|
||||
void test_insertion() {
|
||||
void test_insertion()
|
||||
{
|
||||
// Create point sets
|
||||
typedef CGAL::Creator_uniform_2<double,Point> Creator;
|
||||
typedef CGAL::Creator_uniform_2<double, Point> Creator;
|
||||
CGAL::Random rnd(7);
|
||||
CGAL::Random_points_on_circle_2<Point, Creator> on_circle(0.5, rnd);
|
||||
|
||||
// Center of the circle at (0.5, 0.5)
|
||||
std::vector<Point> pts_rnd1000;
|
||||
for (int i=0 ; i<1000 ; i++) {
|
||||
pts_rnd1000.push_back(*on_circle++ + Vector(0.5, 0.5));
|
||||
}
|
||||
for (int i = 0 ; i < 1000 ; i++)
|
||||
{
|
||||
pts_rnd1000.push_back(*on_circle++ + Vector(0.5, 0.5));
|
||||
}
|
||||
|
||||
Triangulation pt(pts_rnd1000.begin(), pts_rnd1000.end());
|
||||
CGAL_assertion(pt.is_valid());
|
||||
|
|
@ -36,10 +38,11 @@ void test_insertion() {
|
|||
|
||||
// Center of the circle around the origin
|
||||
pts_rnd1000.clear();
|
||||
for (int i=0 ; i<1000 ; i++) {
|
||||
Point p = *on_circle++;
|
||||
pts_rnd1000.push_back(Point(p.x()<0 ? 1+p.x() : p.x(), p.y()<0 ? 1+p.y() :p.y()));
|
||||
}
|
||||
for (int i = 0 ; i < 1000 ; i++)
|
||||
{
|
||||
Point p = *on_circle++;
|
||||
pts_rnd1000.push_back(Point(p.x() < 0 ? 1 + p.x() : p.x(), p.y() < 0 ? 1 + p.y() : p.y()));
|
||||
}
|
||||
|
||||
pt.insert(pts_rnd1000.begin(), pts_rnd1000.end());
|
||||
CGAL_assertion(pt.is_valid());
|
||||
|
|
@ -50,7 +53,8 @@ void test_insertion() {
|
|||
CGAL_assertion(pt.number_of_vertices() == 0);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
test_insertion();
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -23,52 +23,60 @@ typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt> P2DT2;
|
|||
typedef CGAL::Delaunay_triangulation_2<Gt> DT2;
|
||||
|
||||
template <class Dt>
|
||||
class DT2_inserter {
|
||||
class DT2_inserter
|
||||
{
|
||||
Dt t;
|
||||
public:
|
||||
template <class Iterator>
|
||||
void insert(Iterator begin, Iterator end) {
|
||||
void insert(Iterator begin, Iterator end)
|
||||
{
|
||||
t.insert(begin, end);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class PT, bool large>
|
||||
class P2DT2_inserter {
|
||||
class P2DT2_inserter
|
||||
{
|
||||
PT t;
|
||||
public:
|
||||
template <class Iterator>
|
||||
void insert(Iterator begin, Iterator end) {
|
||||
void insert(Iterator begin, Iterator end)
|
||||
{
|
||||
t.insert(begin, end, large);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Inserter>
|
||||
void test_performance(const std::string &name, int maximum = 1e5) {
|
||||
void test_performance(const std::string &name, int maximum = 1e5)
|
||||
{
|
||||
// Create point sets
|
||||
typedef CGAL::Creator_uniform_2<double,Point> Creator;
|
||||
typedef CGAL::Creator_uniform_2<double, Point> Creator;
|
||||
CGAL::Random rnd(7);
|
||||
CGAL::Random_points_in_square_2<Point, Creator> in_square(0.5, rnd);
|
||||
|
||||
|
||||
for (int n = 0; n<=maximum; n+=5000) {
|
||||
CGAL::Timer timer;
|
||||
for (int n = 0; n <= maximum; n += 5000)
|
||||
{
|
||||
CGAL::Timer timer;
|
||||
|
||||
std::vector<Point> pts;
|
||||
for (int i=0 ; i<n ; i++) {
|
||||
pts.push_back(*in_square++ + Vector(0.5, 0.5));
|
||||
std::vector<Point> pts;
|
||||
for (int i = 0 ; i < n ; i++)
|
||||
{
|
||||
pts.push_back(*in_square++ + Vector(0.5, 0.5));
|
||||
}
|
||||
|
||||
Inserter inserter;
|
||||
|
||||
timer.start();
|
||||
inserter.insert(pts.begin(), pts.end());
|
||||
timer.stop();
|
||||
std::cout << name << "; " << pts.size() << "; " << timer.time() << std::endl;
|
||||
}
|
||||
|
||||
Inserter inserter;
|
||||
|
||||
timer.start();
|
||||
inserter.insert(pts.begin(), pts.end());
|
||||
timer.stop();
|
||||
std::cout << name << "; " << pts.size() << "; " << timer.time() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int maximum = 1e5;
|
||||
if (argc > 1) maximum = atoi(argv[1]);
|
||||
test_performance<DT2_inserter<DT2> >("Euclidean Delaunay", maximum);
|
||||
|
|
@ -101,7 +109,7 @@ int main(int argc, char *argv[]) {
|
|||
if (!(elem[0] in processed_data)) processed_data[elem[0]] = []
|
||||
return processed_data[elem[0]].push([ elem[1], elem[2] ]);
|
||||
});
|
||||
|
||||
|
||||
var processed_data2 = {};
|
||||
for (var key in processed_data) {
|
||||
var data0 = processed_data["Euclidean Delaunay"];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
const int N_PTS = 75;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Triangulation t;
|
||||
|
||||
Vector midpoint(0.5, 0.5);
|
||||
|
|
@ -14,52 +15,55 @@ int main() {
|
|||
Face_handle fh;
|
||||
Triangulation::Locate_type lt;
|
||||
int i;
|
||||
fh = t.locate(Point(0,0) + midpoint, lt, i);
|
||||
fh = t.locate(Point(0, 0) + midpoint, lt, i);
|
||||
CGAL_assertion(lt == Triangulation::EMPTY);
|
||||
|
||||
Vertex_handle vh_midpoint = t.insert(Point(0,0) + midpoint);
|
||||
fh = t.locate(Point(0,0) + midpoint, lt, i);
|
||||
Vertex_handle vh_midpoint = t.insert(Point(0, 0) + midpoint);
|
||||
fh = t.locate(Point(0, 0) + midpoint, lt, i);
|
||||
CGAL_assertion(lt == Triangulation::VERTEX && fh->vertex(i) == vh_midpoint);
|
||||
t.remove(vh_midpoint);
|
||||
CGAL_assertion(t.empty());
|
||||
|
||||
// High degree vertex
|
||||
for (int n=3; n<8; ++n) {
|
||||
vh_midpoint = t.insert(Point(0,0) + midpoint);
|
||||
for (int i=0; i<n; ++i) {
|
||||
t.insert(Point(0.3*sin(i*1.0/n*2*M_PI), 0.3*cos(i*1.0/n*2*M_PI)) + midpoint);
|
||||
}
|
||||
t.remove(vh_midpoint);
|
||||
CGAL_assertion(t.is_valid(true));
|
||||
while (!t.empty()) {
|
||||
t.remove(t.vertices_begin());
|
||||
for (int n = 3; n < 8; ++n)
|
||||
{
|
||||
vh_midpoint = t.insert(Point(0, 0) + midpoint);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
t.insert(Point(0.3 * sin(i * 1.0 / n * 2 * M_PI), 0.3 * cos(i * 1.0 / n * 2 * M_PI)) + midpoint);
|
||||
}
|
||||
t.remove(vh_midpoint);
|
||||
CGAL_assertion(t.is_valid(true));
|
||||
while (!t.empty())
|
||||
{
|
||||
t.remove(t.vertices_begin());
|
||||
CGAL_assertion(t.is_valid(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Random random(1284141159);
|
||||
std::cout << "Seed: " << random.get_seed () << std::endl;
|
||||
Random_points_in_square g(0.495, random);
|
||||
|
||||
|
||||
CGAL_assertion(t.is_valid());
|
||||
|
||||
|
||||
std::cout << "Removing first point" << std::endl;
|
||||
Vertex_handle vh0 = t.insert(Point(0.5, 0.5));
|
||||
CGAL_assertion(t.is_valid());
|
||||
t.remove(vh0);
|
||||
CGAL_assertion(t.is_valid());
|
||||
CGAL_assertion(t.empty());
|
||||
|
||||
|
||||
{
|
||||
Random random(1284141159);
|
||||
std::cout << "Seed: " << random.get_seed () << std::endl;
|
||||
|
||||
Random_points_in_square g(0.495, random);
|
||||
Vector midpoint(0.5, 0.5);
|
||||
|
||||
|
||||
Triangulation t;
|
||||
CGAL_assertion(t.is_valid());
|
||||
|
||||
|
||||
std::cout << "Removing first point" << std::endl;
|
||||
Vertex_handle vh0 = t.insert(Point(0.5, 0.5));
|
||||
CGAL_assertion(t.is_valid());
|
||||
|
|
@ -69,18 +73,20 @@ int main() {
|
|||
|
||||
std::cout << "Inserting random points and removing them." << std::endl;
|
||||
|
||||
for (int i = 0; i < N_PTS; ++i) {
|
||||
t.insert(*(++g) + midpoint);
|
||||
}
|
||||
for (int i = 0; i < N_PTS; ++i)
|
||||
{
|
||||
t.insert(*(++g) + midpoint);
|
||||
}
|
||||
CGAL_assertion(t.is_valid());
|
||||
|
||||
for (int i = 0; i < N_PTS; ++i) {
|
||||
// Find a random vertex
|
||||
Vertex_handle vh = t.locate(*(++g) + midpoint)->vertex(0);
|
||||
vh = t.get_original_vertex(vh);
|
||||
t.remove(vh);
|
||||
CGAL_assertion(t.is_valid());
|
||||
}
|
||||
for (int i = 0; i < N_PTS; ++i)
|
||||
{
|
||||
// Find a random vertex
|
||||
Vertex_handle vh = t.locate(*(++g) + midpoint)->vertex(0);
|
||||
vh = t.get_original_vertex(vh);
|
||||
t.remove(vh);
|
||||
CGAL_assertion(t.is_valid());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
//
|
||||
// $URL: svn+ssh://mcaroli@scm.gforge.inria.fr/svn/cgal/trunk/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_periodic_2_delaunay_2.cpp $
|
||||
// $Id: test_periodic_2_delaunay_2.cpp 48874 2009-04-22 12:54:28Z mcaroli $
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
// Manuel Caroli
|
||||
|
|
@ -34,8 +34,8 @@ typedef CGAL::Periodic_2_triangulation_traits_2<K1> PTT1;
|
|||
typedef CGAL::Periodic_2_triangulation_vertex_base_2<PTT1> PVB1;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<PTT1> PFB1;
|
||||
typedef CGAL::Triangulation_hierarchy_vertex_base_2<PVB1> PHVB1;
|
||||
typedef CGAL::Triangulation_data_structure_2<PHVB1,PFB1> Tds1;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<PTT1,Tds1> PDT1;
|
||||
typedef CGAL::Triangulation_data_structure_2<PHVB1, PFB1> Tds1;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<PTT1, Tds1> PDT1;
|
||||
// Explicit instantiation of the whole class :
|
||||
template class CGAL::Periodic_2_triangulation_hierarchy_2<PDT1>;
|
||||
|
||||
|
|
@ -44,11 +44,11 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel K2;
|
|||
typedef CGAL::Periodic_2_triangulation_traits_2<K2> PTT2;
|
||||
typedef CGAL::Periodic_2_triangulation_vertex_base_2<PTT2> DSVB2;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<PTT2> DSFB2;
|
||||
typedef CGAL::Triangulation_vertex_base_2<PTT2,DSVB2> VBB2;
|
||||
typedef CGAL::Triangulation_vertex_base_2<PTT2, DSVB2> VBB2;
|
||||
typedef CGAL::Triangulation_hierarchy_vertex_base_2<VBB2> VB2;
|
||||
typedef CGAL::Triangulation_face_base_2<PTT2,DSFB2> FB2;
|
||||
typedef CGAL::Triangulation_data_structure_2<VB2,FB2> Tds2;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<PTT2,Tds2> PDT2;
|
||||
typedef CGAL::Triangulation_face_base_2<PTT2, DSFB2> FB2;
|
||||
typedef CGAL::Triangulation_data_structure_2<VB2, FB2> Tds2;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<PTT2, Tds2> PDT2;
|
||||
// Explicit instantiation of the whole class :
|
||||
template class CGAL::Periodic_2_triangulation_hierarchy_2<PDT2>;
|
||||
|
||||
|
|
@ -58,11 +58,11 @@ typedef CGAL::Simple_homogeneous<CGAL::MP_Float> K3;
|
|||
typedef CGAL::Periodic_2_triangulation_traits_2<K3> PTT3;
|
||||
typedef CGAL::Periodic_2_triangulation_vertex_base_2<PTT3> DSVB3;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<PTT3> DSFB3;
|
||||
typedef CGAL::Triangulation_vertex_base_2<PTT3,DSVB3> VBB3;
|
||||
typedef CGAL::Triangulation_vertex_base_2<PTT3, DSVB3> VBB3;
|
||||
typedef CGAL::Triangulation_hierarchy_vertex_base_2<VBB3> VB3;
|
||||
typedef CGAL::Triangulation_face_base_2<PTT3,DSFB3> FB3;
|
||||
typedef CGAL::Triangulation_data_structure_2<VB3,FB3> Tds3;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<PTT3,Tds3> PDT3;
|
||||
typedef CGAL::Triangulation_face_base_2<PTT3, DSFB3> FB3;
|
||||
typedef CGAL::Triangulation_data_structure_2<VB3, FB3> Tds3;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<PTT3, Tds3> PDT3;
|
||||
// Explicit instantiation of the whole class :
|
||||
template class CGAL::Periodic_2_triangulation_hierarchy_2<PDT3>;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ typedef CGAL::Periodic_2_triangulation_traits_2<K3> PTT3;
|
|||
// Explicit instantiation of the whole class :
|
||||
template class CGAL::Periodic_2_Delaunay_triangulation_2<PTT3>;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
typedef Periodic_2_triangulation_2<Gt> P2T2;
|
||||
typedef Periodic_2_Delaunay_triangulation_2<Gt> DP2T2;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,86 +15,97 @@ const bool pre_run = false;
|
|||
const bool do_remove = true;
|
||||
const int n_runs = 2;
|
||||
|
||||
void load_data(const char *filename, Iso_rectangle &domain, std::vector<Point> &pts) {
|
||||
std::ifstream file (filename, std::ios::in|std::ios::binary);
|
||||
void load_data(const char *filename, Iso_rectangle &domain, std::vector<Point> &pts)
|
||||
{
|
||||
std::ifstream file (filename, std::ios::in | std::ios::binary);
|
||||
if (!file.is_open()) exit(1);
|
||||
|
||||
float dom[2];
|
||||
file.read((char *)&dom[0], 2 * sizeof(float));
|
||||
domain = Iso_rectangle(0,0,dom[0],dom[1]);
|
||||
domain = Iso_rectangle(0, 0, dom[0], dom[1]);
|
||||
|
||||
float coords[2];
|
||||
while (!file.eof()) {
|
||||
file.read((char *)&coords[0], 2 * sizeof(float));
|
||||
while (coords[0] < 0) coords[0] += dom[0];
|
||||
while (coords[1] < 0) coords[1] += dom[1];
|
||||
while (coords[0] >= dom[0]) coords[0] -= dom[0];
|
||||
while (coords[1] >= dom[1]) coords[1] -= dom[1];
|
||||
while (!file.eof())
|
||||
{
|
||||
file.read((char *)&coords[0], 2 * sizeof(float));
|
||||
while (coords[0] < 0) coords[0] += dom[0];
|
||||
while (coords[1] < 0) coords[1] += dom[1];
|
||||
while (coords[0] >= dom[0]) coords[0] -= dom[0];
|
||||
while (coords[1] >= dom[1]) coords[1] -= dom[1];
|
||||
|
||||
pts.push_back(Point(coords[0], coords[1]));
|
||||
}
|
||||
pts.push_back(Point(coords[0], coords[1]));
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void test(const std::vector<Point> &input, T &t) {
|
||||
void test(const std::vector<Point> &input, T &t)
|
||||
{
|
||||
t.insert(input.begin(), input.end(), true);
|
||||
|
||||
if (do_remove) {
|
||||
std::vector<typename T::Vertex_handle> vhs;
|
||||
for (typename T::Vertex_iterator it = t.vertices_begin(); it != t.vertices_end(); ++it) {
|
||||
vhs.push_back(it);
|
||||
if (do_remove)
|
||||
{
|
||||
std::vector<typename T::Vertex_handle> vhs;
|
||||
for (typename T::Vertex_iterator it = t.vertices_begin(); it != t.vertices_end(); ++it)
|
||||
{
|
||||
vhs.push_back(it);
|
||||
}
|
||||
|
||||
std::random_shuffle(vhs.begin(), vhs.end());
|
||||
vhs.resize(vhs.size() / 2);
|
||||
for (size_t i = 0; i < vhs.size(); ++i)
|
||||
t.remove(vhs[i]);
|
||||
}
|
||||
|
||||
std::random_shuffle(vhs.begin(), vhs.end());
|
||||
vhs.resize(vhs.size()/2);
|
||||
for (size_t i=0; i<vhs.size(); ++i)
|
||||
t.remove(vhs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
srand(42);
|
||||
const char *filename = "/home/nico/Code/periodic_data_sets/512000_000.dat";
|
||||
if (argc == 2) {
|
||||
filename = argv[1];
|
||||
}
|
||||
if (argc == 2)
|
||||
{
|
||||
filename = argv[1];
|
||||
}
|
||||
|
||||
Iso_rectangle domain;
|
||||
std::vector<Point> pts;
|
||||
load_data(filename, domain, pts);
|
||||
|
||||
for (int run=0; run<3; ++run) {
|
||||
// if (true) {
|
||||
// if (pre_run) {
|
||||
// Delaunay_triangulation_2<Gt> t;
|
||||
// test(pts, t);
|
||||
// }
|
||||
for (int run = 0; run < 3; ++run)
|
||||
{
|
||||
// if (true) {
|
||||
// if (pre_run) {
|
||||
// Delaunay_triangulation_2<Gt> t;
|
||||
// test(pts, t);
|
||||
// }
|
||||
|
||||
// std::clock_t total_start = std::clock();
|
||||
// for (int i=0; i<n_runs; ++i) {
|
||||
// Delaunay_triangulation_2<Gt> t;
|
||||
// test(pts, t);
|
||||
// }
|
||||
// double total_time = (std::clock()-total_start)/(double)CLOCKS_PER_SEC;
|
||||
// std::clock_t total_start = std::clock();
|
||||
// for (int i=0; i<n_runs; ++i) {
|
||||
// Delaunay_triangulation_2<Gt> t;
|
||||
// test(pts, t);
|
||||
// }
|
||||
// double total_time = (std::clock()-total_start)/(double)CLOCKS_PER_SEC;
|
||||
|
||||
// std::cout << "Euclidean space, " << filename << ", " << total_time << std::endl;
|
||||
// }
|
||||
// std::cout << "Euclidean space, " << filename << ", " << total_time << std::endl;
|
||||
// }
|
||||
|
||||
if (true) {
|
||||
if (pre_run) {
|
||||
Periodic_2_Delaunay_triangulation_2<Gt> t(domain);
|
||||
test(pts, t);
|
||||
}
|
||||
if (true)
|
||||
{
|
||||
if (pre_run)
|
||||
{
|
||||
Periodic_2_Delaunay_triangulation_2<Gt> t(domain);
|
||||
test(pts, t);
|
||||
}
|
||||
|
||||
std::clock_t total_start = std::clock();
|
||||
for (int i=0; i<n_runs; ++i) {
|
||||
Periodic_2_Delaunay_triangulation_2<Gt> t(domain);
|
||||
test(pts, t);
|
||||
}
|
||||
double total_time = (std::clock()-total_start)/(double)CLOCKS_PER_SEC;
|
||||
std::clock_t total_start = std::clock();
|
||||
for (int i = 0; i < n_runs; ++i)
|
||||
{
|
||||
Periodic_2_Delaunay_triangulation_2<Gt> t(domain);
|
||||
test(pts, t);
|
||||
}
|
||||
double total_time = (std::clock() - total_start) / (double)CLOCKS_PER_SEC;
|
||||
|
||||
std::cout << "Periodic space, " << filename << ", " << total_time << std::endl;
|
||||
std::cout << "Periodic space, " << filename << ", " << total_time << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ const int N_PTS = 50000;
|
|||
* r58618 : 154.491s
|
||||
*/
|
||||
|
||||
double total_time=0.0;
|
||||
double locate_time=0.0;
|
||||
double insert_time=0.0;
|
||||
double periodic_locate_time=0.0;
|
||||
double periodic_insert_time=0.0;
|
||||
double total_time = 0.0;
|
||||
double locate_time = 0.0;
|
||||
double insert_time = 0.0;
|
||||
double periodic_locate_time = 0.0;
|
||||
double periodic_insert_time = 0.0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Random random(1284141159);
|
||||
Random_points_in_square g(0.495, random);
|
||||
Vector midpoint(0.5, 0.5);
|
||||
|
|
@ -34,10 +35,10 @@ int main() {
|
|||
// Should take 5 seconds on the iMac
|
||||
std::vector<Point> pts;
|
||||
pts.resize(500000);
|
||||
for (size_t i=0; i<pts.size(); ++i) pts[i] = *(++g) + midpoint;
|
||||
for (size_t i = 0; i < pts.size(); ++i) pts[i] = *(++g) + midpoint;
|
||||
|
||||
Gt gt;
|
||||
for (size_t i=0; i<pts.size()-2; ++i) gt.orientation_2_object()(pts[i], pts[i+1], pts[i+2]);
|
||||
for (size_t i = 0; i < pts.size() - 2; ++i) gt.orientation_2_object()(pts[i], pts[i + 1], pts[i + 2]);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
|
|
@ -48,52 +49,59 @@ int main() {
|
|||
<< "locate_time" << ", \t" << "insert_time" << ", \t"
|
||||
<< "periodic_insert_time" << ", \t" << "periodic_insert_time" << std::endl;
|
||||
|
||||
|
||||
// First run is for heating up the CPU, don't output the stats
|
||||
for (int run=0; run<N_RUNS; ++run) {
|
||||
// Reset timings
|
||||
total_time=0.0;
|
||||
locate_time=0.0;
|
||||
insert_time=0.0;
|
||||
periodic_locate_time=0.0;
|
||||
periodic_insert_time=0.0;
|
||||
|
||||
#ifdef PERIODIC
|
||||
Triangulation t;
|
||||
const bool insert_periodic_copies = false;
|
||||
#else
|
||||
EuclideanTriangulation t;
|
||||
const bool insert_periodic_copies = false;
|
||||
#endif
|
||||
|
||||
std::clock_t start_time = std::clock();
|
||||
// Do one additional point to get the statistics right
|
||||
for (int i = 0; i <= N_PTS; ++i) {
|
||||
Point p = *(++g) + midpoint;
|
||||
t.insert(p);
|
||||
|
||||
if (insert_periodic_copies) {
|
||||
for (int x=0; x<3; ++x) {
|
||||
for (int y=0; y<3; ++y) {
|
||||
if (x+y > 0) {
|
||||
t.insert(p + Vector(x,y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i%500==0) {
|
||||
std::cout << i << ", \t"
|
||||
<< (std::clock()-start_time)/(double)CLOCKS_PER_SEC << ", \t"
|
||||
<< total_time << ", \t"
|
||||
<< locate_time << ", \t" << insert_time << ", \t"
|
||||
<< periodic_insert_time << ", \t" << periodic_insert_time << std::endl;
|
||||
}
|
||||
}
|
||||
CGAL_assertion(t.is_valid());
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
// First run is for heating up the CPU, don't output the stats
|
||||
for (int run = 0; run < N_RUNS; ++run)
|
||||
{
|
||||
// Reset timings
|
||||
total_time = 0.0;
|
||||
locate_time = 0.0;
|
||||
insert_time = 0.0;
|
||||
periodic_locate_time = 0.0;
|
||||
periodic_insert_time = 0.0;
|
||||
|
||||
#ifdef PERIODIC
|
||||
Triangulation t;
|
||||
const bool insert_periodic_copies = false;
|
||||
#else
|
||||
EuclideanTriangulation t;
|
||||
const bool insert_periodic_copies = false;
|
||||
#endif
|
||||
|
||||
std::clock_t start_time = std::clock();
|
||||
// Do one additional point to get the statistics right
|
||||
for (int i = 0; i <= N_PTS; ++i)
|
||||
{
|
||||
Point p = *(++g) + midpoint;
|
||||
t.insert(p);
|
||||
|
||||
if (insert_periodic_copies)
|
||||
{
|
||||
for (int x = 0; x < 3; ++x)
|
||||
{
|
||||
for (int y = 0; y < 3; ++y)
|
||||
{
|
||||
if (x + y > 0)
|
||||
{
|
||||
t.insert(p + Vector(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i % 500 == 0)
|
||||
{
|
||||
std::cout << i << ", \t"
|
||||
<< (std::clock() - start_time) / (double)CLOCKS_PER_SEC << ", \t"
|
||||
<< total_time << ", \t"
|
||||
<< locate_time << ", \t" << insert_time << ", \t"
|
||||
<< periodic_insert_time << ", \t" << periodic_insert_time << std::endl;
|
||||
}
|
||||
}
|
||||
CGAL_assertion(t.is_valid());
|
||||
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,20 @@
|
|||
#include "./types.h"
|
||||
#include <map>
|
||||
|
||||
const int N=10;
|
||||
const int N = 10;
|
||||
|
||||
void test_orientation() {
|
||||
void test_orientation()
|
||||
{
|
||||
Gt traits;
|
||||
traits.set_domain(Gt::Iso_rectangle_2(0,0,1,1));
|
||||
traits.set_domain(Gt::Iso_rectangle_2(0, 0, 1, 1));
|
||||
|
||||
Gt::Offset_2 o0(0, 0);
|
||||
Gt::Offset_2 o1(0, 1);
|
||||
|
||||
/// Near degenerate points, which cause the predicate to fail if not filtered
|
||||
Point p0(0.5 + (0.4999/N)*2, 0.5 + (0.4999/N)*-5);
|
||||
Point p1(0.5 + (0.4999/N)*4, 0.5 + (0.4999/N)*-4);
|
||||
Point p2(0.5 + (0.4999/N)*6, 0.5 + (0.4999/N)*-3);
|
||||
Point p0(0.5 + (0.4999 / N) * 2, 0.5 + (0.4999 / N) * -5);
|
||||
Point p1(0.5 + (0.4999 / N) * 4, 0.5 + (0.4999 / N) * -4);
|
||||
Point p2(0.5 + (0.4999 / N) * 6, 0.5 + (0.4999 / N) * -3);
|
||||
|
||||
CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == 1);
|
||||
CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == 1);
|
||||
|
|
@ -51,19 +52,20 @@ void test_orientation() {
|
|||
traits.orientation_2_object()(p2, p1, p0, o1, o1, o1));
|
||||
}
|
||||
|
||||
void test_in_circle() {
|
||||
void test_in_circle()
|
||||
{
|
||||
Gt traits;
|
||||
traits.set_domain(Gt::Iso_rectangle_2(0,0,1,1));
|
||||
traits.set_domain(Gt::Iso_rectangle_2(0, 0, 1, 1));
|
||||
|
||||
Gt::Offset_2 o0(0, 0);
|
||||
Gt::Offset_2 o1(0, 1);
|
||||
|
||||
/// Near degenerate points, which cause the predicate to fail if not filtered
|
||||
/// On the circle with center (0.4999, 0.4999) and radius 5
|
||||
Point p0( 5-0.4999, -0.4999);
|
||||
Point p1( 3-0.4999, 4-0.4999);
|
||||
Point p2(-4-0.4999, 3-0.4999);
|
||||
Point p3( 4-0.4999, -3-0.4999);
|
||||
Point p0( 5 - 0.4999, -0.4999);
|
||||
Point p1( 3 - 0.4999, 4 - 0.4999);
|
||||
Point p2(-4 - 0.4999, 3 - 0.4999);
|
||||
Point p3( 4 - 0.4999, -3 - 0.4999);
|
||||
|
||||
CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == 1);
|
||||
CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == 1);
|
||||
|
|
@ -99,9 +101,10 @@ void test_in_circle() {
|
|||
traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3, o1, o1, o1, o1));
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
test_orientation();
|
||||
test_in_circle();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,53 +3,65 @@
|
|||
#include "./types.h"
|
||||
#include <map>
|
||||
|
||||
void greedy_flip_long_edges(Triangulation &t) {
|
||||
void greedy_flip_long_edges(Triangulation &t)
|
||||
{
|
||||
typedef std::multimap<double, std::pair<Vertex_handle, Vertex_handle> > Edge_map;
|
||||
|
||||
Face_handle f; int i;
|
||||
Face_handle f;
|
||||
int i;
|
||||
|
||||
Edge_map edge_map;
|
||||
for (Triangulation::Edge_iterator eit = t.edges_begin(); eit != t.edges_end(); ++eit) {
|
||||
double sqr_length_orig = t.segment(eit).squared_length();
|
||||
if (sqr_length_orig > 0.166) {
|
||||
f = eit->first; i = eit->second;
|
||||
edge_map.insert(std::make_pair(sqr_length_orig,
|
||||
std::make_pair(f->vertex(t.ccw(i)),
|
||||
f->vertex(t.cw(i)))));
|
||||
}
|
||||
}
|
||||
|
||||
bool is_1_cover = t.is_1_cover();
|
||||
for (Edge_map::reverse_iterator it = edge_map.rbegin(); it != edge_map.rend(); ++it) {
|
||||
double sqr_length_orig = it->first;
|
||||
if (t.is_edge(it->second.first, it->second.second, f, i)) {
|
||||
if (t.flippable(f, i)) {
|
||||
t.flip(f, i);
|
||||
// We flipped enough long edges, when we go to the 1-cover all faces are invalidated
|
||||
if (is_1_cover != t.is_1_cover())
|
||||
return;
|
||||
double sqr_length_new = t.segment(f, t.ccw(i)).squared_length();
|
||||
if (sqr_length_orig < sqr_length_new) {
|
||||
std::cout << sqr_length_orig << std::endl;
|
||||
t.flip(f, t.ccw(i));
|
||||
for (Triangulation::Edge_iterator eit = t.edges_begin(); eit != t.edges_end(); ++eit)
|
||||
{
|
||||
double sqr_length_orig = t.segment(eit).squared_length();
|
||||
if (sqr_length_orig > 0.166)
|
||||
{
|
||||
f = eit->first;
|
||||
i = eit->second;
|
||||
edge_map.insert(std::make_pair(sqr_length_orig,
|
||||
std::make_pair(f->vertex(t.ccw(i)),
|
||||
f->vertex(t.cw(i)))));
|
||||
}
|
||||
}
|
||||
|
||||
bool is_1_cover = t.is_1_cover();
|
||||
for (Edge_map::reverse_iterator it = edge_map.rbegin(); it != edge_map.rend(); ++it)
|
||||
{
|
||||
double sqr_length_orig = it->first;
|
||||
if (t.is_edge(it->second.first, it->second.second, f, i))
|
||||
{
|
||||
if (t.flippable(f, i))
|
||||
{
|
||||
t.flip(f, i);
|
||||
// We flipped enough long edges, when we go to the 1-cover all faces are invalidated
|
||||
if (is_1_cover != t.is_1_cover())
|
||||
return;
|
||||
double sqr_length_new = t.segment(f, t.ccw(i)).squared_length();
|
||||
if (sqr_length_orig < sqr_length_new)
|
||||
{
|
||||
std::cout << sqr_length_orig << std::endl;
|
||||
t.flip(f, t.ccw(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Point p;
|
||||
Triangulation t;
|
||||
|
||||
const int N=4;
|
||||
const int N = 4;
|
||||
|
||||
// Insert the first point
|
||||
for (int y=0; y<N; y++) {
|
||||
for (int x=0; x<N; x++) {
|
||||
t.insert(Point((1.0/N)*x, (1.0/N)*y));
|
||||
for (int y = 0; y < N; y++)
|
||||
{
|
||||
for (int x = 0; x < N; x++)
|
||||
{
|
||||
t.insert(Point((1.0 / N)*x, (1.0 / N)*y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
greedy_flip_long_edges(t);
|
||||
greedy_flip_long_edges(t);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#include "./types.h"
|
||||
|
||||
void insert_in_edge(Triangulation &t, const Point &p) {
|
||||
void insert_in_edge(Triangulation &t, const Point &p)
|
||||
{
|
||||
Triangulation::Locate_type lt;
|
||||
int li;
|
||||
|
||||
|
|
@ -12,7 +13,8 @@ void insert_in_edge(Triangulation &t, const Point &p) {
|
|||
CGAL_assertion(t.is_valid());
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Point p;
|
||||
Triangulation t;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,39 +3,46 @@
|
|||
#include "./types.h"
|
||||
#include <map>
|
||||
|
||||
const int N=10;
|
||||
const int N = 10;
|
||||
|
||||
void test_insertion_xy(int x_order, int y_order) {
|
||||
void test_insertion_xy(int x_order, int y_order)
|
||||
{
|
||||
std::cout << "xy: " << x_order << " " << y_order << std::endl;
|
||||
Triangulation t;
|
||||
|
||||
Triangulation::Face_handle fh;
|
||||
|
||||
// Insert the first point
|
||||
for (int x=-N; x<N; x++) {
|
||||
for (int y=-N; y<N; y++) {
|
||||
Point p(0.5 + x_order * (0.4999/N)*x, 0.5 + y_order * (0.4999/N)*y);
|
||||
t.insert(p);
|
||||
for (int x = -N; x < N; x++)
|
||||
{
|
||||
for (int y = -N; y < N; y++)
|
||||
{
|
||||
Point p(0.5 + x_order * (0.4999 / N)*x, 0.5 + y_order * (0.4999 / N)*y);
|
||||
t.insert(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
CGAL_assertion(t.is_valid());
|
||||
}
|
||||
|
||||
void test_insertion_yx(int x_order, int y_order) {
|
||||
void test_insertion_yx(int x_order, int y_order)
|
||||
{
|
||||
std::cout << "yx: " << x_order << " " << y_order << std::endl;
|
||||
Triangulation t;
|
||||
|
||||
// Insert the first point
|
||||
for (int y=-N; y<N; y++) {
|
||||
for (int x=-N; x<N; x++) {
|
||||
Point p(0.5 + x_order * (0.4999/N)*x, 0.5 + y_order * (0.4999/N)*y);
|
||||
t.insert(p);
|
||||
for (int y = -N; y < N; y++)
|
||||
{
|
||||
for (int x = -N; x < N; x++)
|
||||
{
|
||||
Point p(0.5 + x_order * (0.4999 / N)*x, 0.5 + y_order * (0.4999 / N)*y);
|
||||
t.insert(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
CGAL_assertion(t.is_valid());
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
test_insertion_xy( 1, 1);
|
||||
test_insertion_xy( 1, -1);
|
||||
test_insertion_xy(-1, 1);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
#define N_PTS 10000
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Triangulation t;
|
||||
|
||||
Random random(1284141159);
|
||||
|
|
@ -16,14 +17,16 @@ int main() {
|
|||
Random_points_on_circle g(0.495, random);
|
||||
Vector midpoint(0.5, 0.5);
|
||||
|
||||
for (int i = 0; i < N_PTS; ++i) {
|
||||
t.insert(*(++g) + midpoint);
|
||||
}
|
||||
|
||||
if (!t.is_valid(true)) {
|
||||
std::cout << "l:" << __LINE__ << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
for (int i = 0; i < N_PTS; ++i)
|
||||
{
|
||||
t.insert(*(++g) + midpoint);
|
||||
}
|
||||
|
||||
if (!t.is_valid(true))
|
||||
{
|
||||
std::cout << "l:" << __LINE__ << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#include "./types.h"
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Point p;
|
||||
Triangulation t;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include "./types.h"
|
||||
|
||||
Face_handle test_point_location(const Triangulation &t,
|
||||
const Point &query,
|
||||
const Triangulation::Locate_type <_in) {
|
||||
const Point &query,
|
||||
const Triangulation::Locate_type <_in)
|
||||
{
|
||||
Triangulation::Locate_type lt, lt2;
|
||||
int li, li2;
|
||||
Face_handle fh;
|
||||
|
|
@ -13,17 +14,20 @@ Face_handle test_point_location(const Triangulation &t,
|
|||
|
||||
fh = t.locate(query, lt, li);
|
||||
CGAL_assertion(lt == lt_in);
|
||||
if (lt_in != Triangulation::EMPTY) {
|
||||
bs = t.side_of_face(query, fh, lt2, li2);
|
||||
os = t.oriented_side(fh, query);
|
||||
if (lt_in != Triangulation::EMPTY)
|
||||
{
|
||||
bs = t.side_of_face(query, fh, lt2, li2);
|
||||
os = t.oriented_side(fh, query);
|
||||
|
||||
CGAL_assertion(lt2 == lt_in);
|
||||
}
|
||||
CGAL_assertion(lt2 == lt_in);
|
||||
}
|
||||
|
||||
|
||||
switch (lt_in) {
|
||||
case Triangulation::VERTEX:
|
||||
case Triangulation::EDGE: {
|
||||
switch (lt_in)
|
||||
{
|
||||
case Triangulation::VERTEX:
|
||||
case Triangulation::EDGE:
|
||||
{
|
||||
CGAL_assertion(fh != Face_handle());
|
||||
CGAL_assertion(bs == CGAL::ON_BOUNDARY);
|
||||
CGAL_assertion(os == CGAL::ON_ORIENTED_BOUNDARY);
|
||||
|
|
@ -31,40 +35,43 @@ Face_handle test_point_location(const Triangulation &t,
|
|||
CGAL_assertion(li == li2);
|
||||
break;
|
||||
}
|
||||
case Triangulation::FACE: {
|
||||
CGAL_assertion(fh != Face_handle());
|
||||
CGAL_assertion(bs == CGAL::ON_BOUNDED_SIDE);
|
||||
CGAL_assertion(os == CGAL::ON_POSITIVE_SIDE);
|
||||
break;
|
||||
}
|
||||
case Triangulation::EMPTY: {
|
||||
CGAL_assertion(fh == Face_handle());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case Triangulation::FACE:
|
||||
{
|
||||
CGAL_assertion(fh != Face_handle());
|
||||
CGAL_assertion(bs == CGAL::ON_BOUNDED_SIDE);
|
||||
CGAL_assertion(os == CGAL::ON_POSITIVE_SIDE);
|
||||
break;
|
||||
}
|
||||
case Triangulation::EMPTY:
|
||||
{
|
||||
CGAL_assertion(fh == Face_handle());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fh;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Triangulation t;
|
||||
Face_handle fh;
|
||||
|
||||
// Check the empty triangulation
|
||||
fh = test_point_location(t, Point(0.5, 0.5), Triangulation::EMPTY);
|
||||
CGAL_assertion(fh == Face_handle());
|
||||
|
||||
|
||||
// Insert the first point
|
||||
Point p0(0.5, 0.5);
|
||||
Vertex_handle vh0 = t.insert(p0);
|
||||
CGAL_assertion(t.is_valid(true));
|
||||
|
||||
|
||||
fh = test_point_location(t, p0, Triangulation::VERTEX);
|
||||
CGAL_assertion(fh->has_vertex(vh0));
|
||||
|
||||
fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE);
|
||||
CGAL_assertion(fh->has_vertex(vh0));
|
||||
|
||||
|
||||
fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE);
|
||||
CGAL_assertion(fh->has_vertex(vh0));
|
||||
|
||||
|
|
@ -72,12 +79,12 @@ int main() {
|
|||
CGAL_assertion(fh->has_vertex(vh0));
|
||||
|
||||
CGAL_assertion(t.is_valid(true));
|
||||
|
||||
|
||||
// Insert the second point on an edge
|
||||
Point p1(0.7, 0.7);
|
||||
Vertex_handle vh1 = t.insert(p1);
|
||||
CGAL_assertion(t.is_valid(true));
|
||||
|
||||
|
||||
fh = test_point_location(t, p0, Triangulation::VERTEX);
|
||||
CGAL_assertion(fh->has_vertex(vh0));
|
||||
|
||||
|
|
@ -87,7 +94,7 @@ int main() {
|
|||
fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE);
|
||||
CGAL_assertion(fh->has_vertex(vh0));
|
||||
CGAL_assertion(fh->has_vertex(vh1));
|
||||
|
||||
|
||||
fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE);
|
||||
CGAL_assertion(fh->has_vertex(vh0));
|
||||
CGAL_assertion(!fh->has_vertex(vh1));
|
||||
|
|
|
|||
|
|
@ -19,177 +19,207 @@ typedef Triangulation::Periodic_point_iterator Periodic_point_iterator;
|
|||
typedef Triangulation::Periodic_segment_iterator Periodic_segment_iterator;
|
||||
typedef Triangulation::Periodic_triangle_iterator Periodic_triangle_iterator;
|
||||
|
||||
void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t) {
|
||||
void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t)
|
||||
{
|
||||
CGAL_assertion(t.number_of_vertices() == 1);
|
||||
|
||||
|
||||
Point &p = t.vertices_begin()->point();
|
||||
Triangulation::Locate_type lt;
|
||||
int li;
|
||||
|
||||
for (int offset_x = 0; offset_x<t.number_of_sheets()[0]; ++offset_x) {
|
||||
for (int offset_y = 0; offset_y<t.number_of_sheets()[1]; ++offset_y) {
|
||||
Triangulation::Offset offset(offset_x, offset_y);
|
||||
{ // Test the triangle iterator
|
||||
|
||||
Triangulation::Periodic_triangle_iterator triang_it;
|
||||
const Triangulation::Periodic_triangle_iterator triang_it_beyond = t.periodic_triangles_end();
|
||||
{ // Locate the point at the only vertex
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
triang_it = t.periodic_triangles_begin();
|
||||
while(triang_it != triang_it_beyond) {
|
||||
CGAL::Bounded_side side = t.side_of_face(p, offset, triang_it.get_face(), lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
CGAL_assertion(lt == Triangulation::VERTEX);
|
||||
|
||||
for (int offset_x = 0; offset_x < t.number_of_sheets()[0]; ++offset_x)
|
||||
{
|
||||
for (int offset_y = 0; offset_y < t.number_of_sheets()[1]; ++offset_y)
|
||||
{
|
||||
Triangulation::Offset offset(offset_x, offset_y);
|
||||
{
|
||||
// Test the triangle iterator
|
||||
|
||||
Triangulation::Periodic_triangle_iterator triang_it;
|
||||
const Triangulation::Periodic_triangle_iterator triang_it_beyond = t.periodic_triangles_end();
|
||||
{
|
||||
// Locate the point at the only vertex
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
triang_it = t.periodic_triangles_begin();
|
||||
while(triang_it != triang_it_beyond)
|
||||
{
|
||||
CGAL::Bounded_side side = t.side_of_face(p, offset, triang_it.get_face(), lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE)
|
||||
{
|
||||
CGAL_assertion(lt == Triangulation::VERTEX);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
Triangle triangle = t.triangle(*triang_it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++triang_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 6);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
Triangle triangle = t.triangle(*triang_it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++triang_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 6);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
{ // Locate point on an edge
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
triang_it = t.periodic_triangles_begin();
|
||||
while(triang_it != triang_it_beyond) {
|
||||
CGAL::Bounded_side side = t.side_of_face(p+Vector(0.0, 0.1), offset, triang_it.get_face(), lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
CGAL_assertion(lt == Triangulation::EDGE);
|
||||
{
|
||||
// Locate point on an edge
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
triang_it = t.periodic_triangles_begin();
|
||||
while(triang_it != triang_it_beyond)
|
||||
{
|
||||
CGAL::Bounded_side side = t.side_of_face(p + Vector(0.0, 0.1), offset, triang_it.get_face(), lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE)
|
||||
{
|
||||
CGAL_assertion(lt == Triangulation::EDGE);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
Triangle triangle = t.triangle(*triang_it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++triang_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 2);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
Triangle triangle = t.triangle(*triang_it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++triang_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 2);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
{ // Locate point inside a face
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
triang_it = t.periodic_triangles_begin();
|
||||
while(triang_it != triang_it_beyond) {
|
||||
CGAL::Bounded_side side = t.side_of_face(p+Vector(0.1, 0.2), offset, triang_it.get_face(), lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
CGAL_assertion(lt == Triangulation::FACE);
|
||||
{
|
||||
// Locate point inside a face
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
triang_it = t.periodic_triangles_begin();
|
||||
while(triang_it != triang_it_beyond)
|
||||
{
|
||||
CGAL::Bounded_side side = t.side_of_face(p + Vector(0.1, 0.2), offset, triang_it.get_face(), lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE)
|
||||
{
|
||||
CGAL_assertion(lt == Triangulation::FACE);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
Triangle triangle = t.triangle(*triang_it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++triang_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 0);
|
||||
CGAL_assertion(on_inside == 1);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
Triangle triangle = t.triangle(*triang_it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++triang_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 0);
|
||||
CGAL_assertion(on_inside == 1);
|
||||
}
|
||||
}
|
||||
{ // Test the face iterator
|
||||
Triangulation::Face_iterator face_it;
|
||||
const Triangulation::Face_iterator face_it_beyond = t.faces_end();
|
||||
|
||||
{ // Locate the point at the only vertex
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
face_it = t.faces_begin();
|
||||
while(face_it != face_it_beyond) {
|
||||
CGAL::Bounded_side side = t.side_of_face(p, offset, face_it, lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
CGAL_assertion(lt == Triangulation::VERTEX);
|
||||
{
|
||||
// Test the face iterator
|
||||
Triangulation::Face_iterator face_it;
|
||||
const Triangulation::Face_iterator face_it_beyond = t.faces_end();
|
||||
|
||||
{
|
||||
// Locate the point at the only vertex
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
face_it = t.faces_begin();
|
||||
while(face_it != face_it_beyond)
|
||||
{
|
||||
CGAL::Bounded_side side = t.side_of_face(p, offset, face_it, lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE)
|
||||
{
|
||||
CGAL_assertion(lt == Triangulation::VERTEX);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
++face_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 6);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
++face_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 6);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
{ // Locate point on an edge
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
face_it = t.faces_begin();
|
||||
while(face_it != face_it_beyond) {
|
||||
CGAL::Bounded_side side = t.side_of_face(p+Vector(0.1, 0.0), offset, face_it, lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
CGAL_assertion(lt == Triangulation::EDGE);
|
||||
{
|
||||
// Locate point on an edge
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
face_it = t.faces_begin();
|
||||
while(face_it != face_it_beyond)
|
||||
{
|
||||
CGAL::Bounded_side side = t.side_of_face(p + Vector(0.1, 0.0), offset, face_it, lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE)
|
||||
{
|
||||
CGAL_assertion(lt == Triangulation::EDGE);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
++face_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 2);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
++face_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 2);
|
||||
CGAL_assertion(on_inside == 0);
|
||||
}
|
||||
{ // Locate point inside a face
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
face_it = t.faces_begin();
|
||||
while(face_it != face_it_beyond) {
|
||||
CGAL::Bounded_side side = t.side_of_face(p+Vector(0.1, 0.2), offset, face_it, lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
CGAL_assertion(lt == Triangulation::FACE);
|
||||
{
|
||||
// Locate point inside a face
|
||||
int on_boundary = 0;
|
||||
int on_inside = 0;
|
||||
face_it = t.faces_begin();
|
||||
while(face_it != face_it_beyond)
|
||||
{
|
||||
CGAL::Bounded_side side = t.side_of_face(p + Vector(0.1, 0.2), offset, face_it, lt, li);
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE)
|
||||
{
|
||||
CGAL_assertion(lt == Triangulation::FACE);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
++face_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 0);
|
||||
CGAL_assertion(on_inside == 1);
|
||||
}
|
||||
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
|
||||
on_inside += (side == CGAL::ON_BOUNDED_SIDE ? 1 : 0);
|
||||
++face_it;
|
||||
}
|
||||
CGAL_assertion(on_boundary == 0);
|
||||
CGAL_assertion(on_inside == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
Triangulation t;
|
||||
|
||||
|
||||
// Insert the first point
|
||||
Point first_point(0.5, 0.5);
|
||||
t.insert(first_point);
|
||||
CGAL_assertion(t.is_valid(true));
|
||||
|
||||
{ // Testing the point iterator
|
||||
|
||||
{
|
||||
// Testing the point iterator
|
||||
Periodic_point_iterator it = t.periodic_points_begin();
|
||||
Periodic_point_iterator beyond = t.periodic_points_end();
|
||||
CGAL_assertion(std::distance(it, beyond) == 9);
|
||||
while(it != beyond) {
|
||||
Point p = t.point(*it);
|
||||
p.x(); // Avoid warning
|
||||
++it;
|
||||
}
|
||||
while(it != beyond)
|
||||
{
|
||||
Point p = t.point(*it);
|
||||
p.x(); // Avoid warning
|
||||
++it;
|
||||
}
|
||||
}
|
||||
{ // Testing the segment iterator
|
||||
{
|
||||
// Testing the segment iterator
|
||||
Periodic_segment_iterator it = t.periodic_segments_begin();
|
||||
Periodic_segment_iterator beyond = t.periodic_segments_end();
|
||||
CGAL_assertion(std::distance(it, beyond) == 27);
|
||||
while(it != beyond) {
|
||||
Segment s = t.segment(*it);
|
||||
s.point(0); // Avoid warning
|
||||
++it;
|
||||
}
|
||||
while(it != beyond)
|
||||
{
|
||||
Segment s = t.segment(*it);
|
||||
s.point(0); // Avoid warning
|
||||
++it;
|
||||
}
|
||||
}
|
||||
{ // Testing the triangle iterator
|
||||
{
|
||||
// Testing the triangle iterator
|
||||
Periodic_triangle_iterator it = t.periodic_triangles_begin();
|
||||
Periodic_triangle_iterator beyond = t.periodic_triangles_end();
|
||||
CGAL_assertion(std::distance(it, beyond) == 18);
|
||||
while(it != beyond) {
|
||||
Triangle triangle = t.triangle(*it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++it;
|
||||
}
|
||||
while(it != beyond)
|
||||
{
|
||||
Triangle triangle = t.triangle(*it);
|
||||
triangle.vertex(0); // Avoid warning
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
test_point_location_in_a_triangulation_with_a_single_point(t);
|
||||
|
||||
|
||||
// std::ifstream in("data/triangulation_prog1.cin");
|
||||
// std::istream_iterator<Point> begin(in);
|
||||
// std::istream_iterator<Point> end;
|
||||
// t.insert(begin, end);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue