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:
Nico Kruithof 2013-03-31 22:10:07 +02:00
parent a980dfc210
commit d69d0e303b
56 changed files with 10103 additions and 7493 deletions

View File

@ -1,5 +1,6 @@
namespace CGAL {
namespace CGAL
{
/*!
\ingroup PkgPeriodic2Triangulation2MainClasses
@ -46,39 +47,40 @@ 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
/// @{
/*!
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());
/// @}
@ -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
/// @{
/*!
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
/// @{
/*!
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,45 +191,45 @@ 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;
/// @}
@ -235,44 +237,44 @@ Face_handle start) const;
/// 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
/// @{
/*!
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;
/// @}
@ -280,28 +282,28 @@ Point& p, bool perturb ) const;
/// \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;
/// @}

View File

@ -1,5 +1,6 @@
namespace CGAL {
namespace CGAL
{
/*!
\ingroup PkgPeriodic2Triangulation2
@ -22,6 +23,7 @@ instantiation of `CGAL::Filtered_kernel`.
*/
template< typename Traits, typename Periodic_2Offset_2 >
class Periodic_2_Delaunay_triangulation_traits_2
: public Periodic_2_triangulation_traits_2<Traits,Periodic_2Offset_2> {
: public Periodic_2_triangulation_traits_2<Traits, Periodic_2Offset_2>
{
}; /* end Periodic_2_Delaunay_triangulation_traits_2 */
} /* end namespace CGAL */

View File

@ -1,4 +1,5 @@
namespace CGAL {
namespace CGAL
{
/*!
\ingroup PkgPeriodic2Triangulation2
@ -6,6 +7,7 @@ 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
{
}; /* end Periodic_2_offset_2 */
} /* end namespace CGAL */

View File

@ -1,5 +1,6 @@
namespace CGAL {
namespace CGAL
{
/*!
\ingroup PkgPeriodic2Triangulation2MainClasses
@ -34,7 +35,8 @@ whether all offsets are zero.
*/
template< >
class Periodic_2_triangulation_face_base_2 {
class Periodic_2_triangulation_face_base_2
{
public:
/// @}

View File

@ -1,5 +1,6 @@
namespace CGAL {
namespace CGAL
{
/*!
\ingroup PkgPeriodic2Triangulation2
@ -59,6 +60,7 @@ queries on real data.
*/
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 */

View File

@ -1,5 +1,6 @@
namespace CGAL {
namespace CGAL
{
/*!
\ingroup PkgPeriodic2Triangulation2TraitsClasses
@ -25,6 +26,7 @@ instantiation of `CGAL::Filtered_kernel`.
*/
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 */

View File

@ -1,5 +1,6 @@
namespace CGAL {
namespace CGAL
{
/*!
\ingroup PkgPeriodic2Triangulation2MainClasses
@ -24,7 +25,8 @@ added and should be a model of `TriangulationDSVertexBase_2`
*/
template< >
class Periodic_2_triangulation_vertex_base_2 {
class Periodic_2_triangulation_vertex_base_2
{
public:
/// @}

View File

@ -31,93 +31,94 @@ additional the Delaunay predicates as well if the template parameter Traits is a
\sa `DelaunayTriangulationTraits_2`
*/
class Periodic_2DelaunayTriangulationTraits_2 {
class Periodic_2DelaunayTriangulationTraits_2
{
public:
/// \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
/// @{
/*!
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();
/// @}

View File

@ -12,102 +12,103 @@ The concept `Periodic_2Offset_2` describes a two-/dimensional integer vector wit
*/
class Periodic_2Offset_2 {
class Periodic_2Offset_2
{
public:
/// \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
/// @{
/*!
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
/// @{
/*!
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;
/// @}

View File

@ -19,32 +19,33 @@ vertex \f$ i\f$.
*/
class Periodic_2TriangulationFaceBase_2 {
class Periodic_2TriangulationFaceBase_2
{
public:
/// \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
/// @{
/*!
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);
/// @}

View File

@ -29,137 +29,138 @@ requirements:
*/
class Periodic_2TriangulationTraits_2 {
class Periodic_2TriangulationTraits_2
{
public:
/// \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
/// @{
/*!
/*!
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;
/// @}
@ -168,47 +169,47 @@ typedef Hidden_type Orientation_2;
/// 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;
/// @}
@ -218,20 +219,20 @@ typedef Hidden_type Construct_triangle_2;
/// 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);
/// @}
@ -239,64 +240,64 @@ Periodic_2TriangulationTraits_2 operator=(Periodic_2TriangulationTraits_2 gtr);
/// 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
/// @{
/*!
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;
/// @}

View File

@ -24,42 +24,43 @@ The storage of the offset is only needed when a triangulation is copied.
*/
class Periodic_2TriangulationVertexBase_2 {
class Periodic_2TriangulationVertexBase_2
{
public:
/// \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
/// @{
/*!
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();
/// @}

View File

@ -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;

View File

@ -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;

View File

@ -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;
std::cout << "Current covering: " << cs[0] << ' ' << cs[1] << std::endl;
if ( T.is_triangulation_in_1_sheet() ) { // = true
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;
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;
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;
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 << "Current covering: " << cs[0] << ' ' << cs[1] << std::endl;
}
std::cout<<"It is (again) safe to modify the triangulation."<<std::endl;
std::cout << "It is (again) safe to modify the triangulation." << std::endl;
return 0;
}

View File

@ -16,16 +16,17 @@ 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) {
for (int i = 0; i != 100; ++i)
{
Point p = (*rnd++);
// Locate the point

View File

@ -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));
@ -26,9 +27,11 @@ int main() {
// 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) {
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()) ) {
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!

View File

@ -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

View File

@ -8,29 +8,30 @@ 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() ){
if( points[ vit->info() ].first != vit->point() )
{
std::cerr << "Error different info" << std::endl;
exit(EXIT_FAILURE);
}

View File

@ -8,33 +8,35 @@ 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
//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 );
@ -42,7 +44,8 @@ int main()
// 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() ){
if( points[ vit->info() ] != vit->point() )
{
std::cerr << "Error different info" << std::endl;
exit(EXIT_FAILURE);
}

View File

@ -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;
@ -24,16 +24,16 @@ int main()
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 );
@ -41,7 +41,8 @@ int main()
// 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() ){
if( points[ vit->info() ] != vit->point() )
{
std::cerr << "Error different info" << std::endl;
exit(EXIT_FAILURE);
}

View File

@ -29,33 +29,35 @@ int main()
PDT PT1, PT2, PT3;
// Generating n random points
for (int i=0 ; i < n ; i++) {
for (int i = 0 ; i < n ; i++)
{
Point p = *in_square;
in_square++;
pts.push_back(Point(p.x()+.5, p.y()+.5));
pts.push_back(Point(p.x() + .5, p.y() + .5));
}
// Standard insertion
t.start();
for (int i=0 ; i < n ; 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;
}

View File

@ -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,12 +61,12 @@ int main()
assert( nb->has_vertex( v, nli ) );
// nli is the index of v in nc
std::ofstream oFileT("output.tri",std::ios::out);
std::ofstream oFileT("output.tri", std::ios::out);
// writing file output;
oFileT << T;
PDT T1;
std::ifstream iFileT("output.tri",std::ios::in);
std::ifstream iFileT("output.tri", std::ios::in);
// reading file output;
iFileT >> T1;
assert( T1.is_valid() );

View File

@ -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>
{
};

View File

@ -24,10 +24,12 @@
#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,
// const Periodic_2_offset_2 &off);
@ -39,75 +41,100 @@ 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));
}
/// 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));
}
/// 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 {
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:
@ -115,33 +142,38 @@ private:
};
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) {
&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);
else
{
read(is, x);
read(is, y);
}
off = Periodic_2_offset_2(x,y);
off = Periodic_2_offset_2(x, y);
return is;
}

View File

@ -22,8 +22,9 @@
#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];
@ -31,107 +32,110 @@ Periodic_2_triangulation_2<GT,Tds>::insert_dummy_points() {
Face_handle faces[24];
// Initialise vertices:
for (int i=0; i<4; i++) {
for (int j=0; j<3; j++) {
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()),
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((_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);
vertices[3 * i + j]->set_point(p);
}
}
// Create faces:
for (int i=0; i<24; i++) {
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,10 +151,11 @@ 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++) {
for (int i = 0; i < 12; i++)
{
ret_vector[i] = vertices[i];
}

View File

@ -25,7 +25,8 @@
#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
@ -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;
};
@ -52,7 +54,7 @@ public:
Periodic_2_triangulation_face_base_2(Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2)
: Fb(v0,v1,v2) , _off(0){}
: Fb(v0, v1, v2) , _off(0) {}
Periodic_2_triangulation_face_base_2(Vertex_handle v0,
Vertex_handle v1,
@ -60,49 +62,54 @@ public:
Face_handle n0,
Face_handle n1,
Face_handle n2)
: Fb(v0,v1,v2,n0,n1,n2), _off(0) {}
: 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);
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]);
_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));
_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:

View File

@ -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).
@ -77,13 +78,13 @@ struct Offset_converter_2
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; */
/* 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; */
/* typedef typename Periodic_2_triangulation_traits_base_2<Target_kernel> */
/* ::Point_2 Target_pt; */
using Converter::operator();
@ -121,7 +122,8 @@ public:
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<
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<
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<
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<
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<
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,7 +198,8 @@ 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;
@ -195,8 +209,8 @@ 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

View File

@ -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,7 +72,7 @@ class Periodic_2_triangulation_hierarchy_2
public:
Periodic_2_triangulation_hierarchy_2(
const Iso_rectangle& domain = Iso_rectangle(0,0,1,1),
const Iso_rectangle& domain = Iso_rectangle(0, 0, 1, 1),
const Geom_traits& traits = Geom_traits());
Periodic_2_triangulation_hierarchy_2(
@ -79,13 +80,13 @@ public:
template < typename InputIterator >
Periodic_2_triangulation_hierarchy_2(InputIterator first, InputIterator last,
const Iso_rectangle& domain = Iso_rectangle(0,0,1,1),
const Iso_rectangle& domain = Iso_rectangle(0, 0, 1, 1),
const Geom_traits& traits = Geom_traits())
: PTr_Base(domain,traits), level_mult_cover(0)
: 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);
for(int i = 1; i < m_maxlevel; ++i)
hierarchy[i] = new PTr_Base(domain, traits);
insert(first, last);
}
@ -121,7 +122,8 @@ public:
// would give us.
Face_handle hints[m_maxlevel];
for (typename std::vector<Point>::const_iterator p = points.begin(), end = points.end();
p != end; ++p) {
p != end; ++p)
{
int vertex_level = random_level();
Vertex_handle v = hierarchy[0]->insert (*p, hints[0]);
@ -129,14 +131,16 @@ public:
Vertex_handle prev = v;
for (int level = 1; level <= vertex_level; ++level) {
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) {
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);
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(prev);
}
prev->set_up (v);
@ -189,7 +193,7 @@ Periodic_2_triangulation_hierarchy_2(const Iso_rectangle& domain, const Geom_tra
{
level_mult_cover = 0;
hierarchy[0] = this;
for(int i=1;i<m_maxlevel;++i)
for(int i = 1; i < m_maxlevel; ++i)
hierarchy[i] = new PTr_Base(domain, traits);
}
@ -202,7 +206,7 @@ Periodic_2_triangulation_hierarchy_2(const Periodic_2_triangulation_hierarchy_2<
{
// create an empty triangulation to be able to delete it !
hierarchy[0] = this;
for(int i=1;i<m_maxlevel;++i)
for(int i = 1; i < m_maxlevel; ++i)
hierarchy[i] = new PTr_Base(tr.domain(), tr.geom_traits());
copy_triangulation(tr);
}
@ -226,7 +230,7 @@ Periodic_2_triangulation_hierarchy_2<PTr>::
copy_triangulation(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
{
{
for(int i=0;i<m_maxlevel;++i)
for(int i = 0; i < m_maxlevel; ++i)
hierarchy[i]->copy_triangulation(*tr.hierarchy[i]);
}
@ -235,24 +239,28 @@ copy_triangulation(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
// 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) {
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)) {
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;
if (it->up() != Vertex_handle() ) V[ it->up()->down() ] = it;
}
}
}
@ -288,7 +296,7 @@ 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)
for(int i = 1; i < m_maxlevel; ++i)
std::swap(hierarchy[i], tr.hierarchy[i]);
}
@ -297,7 +305,8 @@ Periodic_2_triangulation_hierarchy_2<PTr>::
~Periodic_2_triangulation_hierarchy_2()
{
clear();
for(int i= 1; i<m_maxlevel; ++i){
for(int i = 1; i < m_maxlevel; ++i)
{
delete hierarchy[i];
}
}
@ -307,7 +316,7 @@ void
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();
}
@ -321,11 +330,12 @@ is_valid(bool verbose, int level) const
int i;
Finite_vertices_iterator it;
//verify correctness of triangulation at all levels
for(i=0;i<m_maxlevel;++i) {
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);
result = result && hierarchy[i]->is_valid(verbose, level);
}
//verify that lower level has no down pointers
for( it = hierarchy[0]->finite_vertices_begin();
@ -334,14 +344,14 @@ is_valid(bool verbose, int level) const
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(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(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))
@ -361,21 +371,23 @@ 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]);
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) {
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);
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(previous);
}
previous->set_up(vertex);
previous=vertex;
previous = vertex;
level++;
}
return first;
@ -391,27 +403,30 @@ insert(const Point& p,
{
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) {
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);
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]);
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) {
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);
for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(previous);
}
previous->set_up(vertex);
previous=vertex;
previous = vertex;
level++;
}
}
@ -432,13 +447,15 @@ 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){
while(1)
{
hierarchy[l++]->remove(v);
if (u == Vertex_handle()) break;
if (l >= m_maxlevel) break;
v=u; u=v->up();
v = u;
u = v->up();
}
}
@ -461,22 +478,28 @@ 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) {
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) {
if (l == 0)
{
ret = w;
} else {
}
else
{
old->set_up(w);
w->set_down(old);
if (hierarchy[l]->number_of_sheets()[0] != 1) {
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 (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(old);
}
}
if (u == Vertex_handle())
@ -491,22 +514,28 @@ 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) {
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) {
if (l == 0)
{
ret = w;
} else {
}
else
{
old->set_up(w);
w->set_down(old);
if (hierarchy[l]->number_of_sheets()[0] != 1) {
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 (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(old);
}
}
if (u == Vertex_handle())
@ -523,7 +552,7 @@ 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];
}
@ -556,38 +585,48 @@ locate_in_all(const Point& p,
// 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) ){
|| (hierarchy[level]->dimension() < 2) )
{
if ( ! level) break; // do not go below 0
}
if((level>0) && (hierarchy[level]->dimension()<2)){
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);
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))){
if (hierarchy[level]->is_infinite(position->vertex(0)))
{
nearest = position->vertex(1);
}
else if (hierarchy[level]->is_infinite(position->vertex(1))){
else if (hierarchy[level]->is_infinite(position->vertex(1)))
{
nearest = position->vertex(0);
} else if ( closer(p,
}
else if ( closer(p,
position->vertex(0)->point(),
position->vertex(1)->point()) == SMALLER){
position->vertex(1)->point()) == SMALLER)
{
nearest = position->vertex(0);
}
else{
}
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 ( (hierarchy[level]->dimension() == 2) && (! hierarchy[level]->is_infinite(position->vertex(2))))
{
if ( closer( p,
position->vertex(2)->point(),
nearest->point()) == SMALLER ){
nearest->point()) == SMALLER )
{
nearest = position->vertex(2);
}
}
@ -596,7 +635,7 @@ locate_in_all(const Point& p,
position = nearest->face(); // incident face
--level;
}
pos[0]=hierarchy[0]->locate(p,lt,li,loc == Face_handle() ? position : loc); // at level 0
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);
return (std::min)(die() - 1, level_mult_cover);
}
} //namespace CGAL

View File

@ -25,7 +25,8 @@
#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
@ -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;
};
@ -49,19 +51,31 @@ class 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
};

View File

@ -23,10 +23,12 @@
#include <CGAL/triangulation_assertions.h>
#include <CGAL/iterator.h>
namespace CGAL {
namespace CGAL
{
template < class T >
class Periodic_2_triangulation_triangle_iterator_2 {
class Periodic_2_triangulation_triangle_iterator_2
{
// Iterates over the primitives in a periodic triangulation.
// Options:
// - STORED: output each primitive from the Tds exactly once
@ -64,8 +66,10 @@ public:
Periodic_2_triangulation_triangle_iterator_2(const T * t,
Iterator_type it = T::STORED)
: _t(t), pos(_t->faces_begin()), _it(it), _off(0) {
if (_it == T::UNIQUE || _it == T::UNIQUE_COVER_DOMAIN) {
: _t(t), pos(_t->faces_begin()), _it(it), _off(0)
{
if (_it == T::UNIQUE || _it == T::UNIQUE_COVER_DOMAIN)
{
while (pos != _t->faces_end() && !is_canonical() )
++pos;
}
@ -76,13 +80,19 @@ public:
Iterator_type it = T::STORED)
: _t(t), pos(_t->faces_end()), _it(it), _off(0) {}
Periodic_triangle_iterator& operator++() {
switch (_it) {
Periodic_triangle_iterator& operator++()
{
switch (_it)
{
case T::STORED:
++pos;
break;
case T::UNIQUE:
do { ++pos; } while (pos != _t->faces_end() && !is_canonical());
do
{
++pos;
}
while (pos != _t->faces_end() && !is_canonical());
break;
case T::STORED_COVER_DOMAIN:
case T::UNIQUE_COVER_DOMAIN:
@ -94,13 +104,19 @@ public:
return *this;
}
Periodic_triangle_iterator& operator--() {
switch (_it) {
Periodic_triangle_iterator& operator--()
{
switch (_it)
{
case T::STORED:
--pos;
break;
case T::UNIQUE:
do { --pos; } while (pos != _t->faces_begin() && !is_canonical());
do
{
--pos;
}
while (pos != _t->faces_begin() && !is_canonical());
break;
case T::STORED_COVER_DOMAIN:
case T::UNIQUE_COVER_DOMAIN:
@ -163,12 +179,14 @@ private:
// check whether pos points onto a unique edge or not.
// If we are computing in 1-sheeted covering this should
// always be true.
bool is_canonical() {
bool is_canonical()
{
// fetch all offsets
Offset off0, off1, off2;
get_edge_offsets(off0, off1, off2);
if (_t->number_of_sheets() != make_array(1,1)) {
if (_t->number_of_sheets() != make_array(1, 1))
{
// If there is one offset with entries larger than 1 then we are
// talking about a vertex that is too far away from the original
// domain to belong to a canonical triangle.
@ -191,33 +209,53 @@ private:
// Artificial incrementation function that takes periodic
// copies into account.
void increment_domain() {
void increment_domain()
{
int off = get_drawing_offsets();
CGAL_triangulation_assertion(_off <= off);
if (_off == off) {
if (_off == off)
{
_off = 0;
do { ++pos; } while (_it == T::UNIQUE_COVER_DOMAIN
do
{
++pos;
}
while (_it == T::UNIQUE_COVER_DOMAIN
&& pos != _t->faces_end() && !is_canonical());
} else {
do {
}
else
{
do
{
++_off;
} while ((((~_off)|off)&3)!=3); // Increment until a valid
}
while ((((~_off) | off) & 3) != 3); // Increment until a valid
// offset has been found
}
}
// Artificial decrementation function that takes periodic
// copies into account.
void decrement_domain() {
if (_off == 0) {
void decrement_domain()
{
if (_off == 0)
{
if (pos == _t->faces_begin()) return;
do { --pos; } while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical());
do
{
--pos;
}
while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical());
_off = get_drawing_offsets();
} else {
}
else
{
int off = get_drawing_offsets();
do {
do
{
--_off;
} while ((((~_off)|off)&3)!=3); // Decrement until a valid
}
while ((((~_off) | off) & 3) != 3); // Decrement until a valid
// offset has been found
}
}
@ -225,24 +263,26 @@ private:
// Get the canonicalized offsets of an edge.
// This works in any cover that is encoded in _t->combine_offsets
void get_edge_offsets(Offset &off0, Offset &off1,
Offset &off2) const {
Offset &off2) const
{
Offset face_off0 = _t->int_to_off(pos->offset(0));
Offset face_off1 = _t->int_to_off(pos->offset(1));
Offset face_off2 = _t->int_to_off(pos->offset(2));
Offset diff_off((face_off0.x() == 1
&& face_off1.x() == 1
&& face_off2.x() == 1)?-1:0,
&& face_off2.x() == 1) ? -1 : 0,
(face_off0.y() == 1
&& face_off1.y() == 1
&& face_off2.y() == 1)?-1:0);
off0 = _t->combine_offsets(_t->get_offset(pos,0), diff_off);
off1 = _t->combine_offsets(_t->get_offset(pos,1), diff_off);
off2 = _t->combine_offsets(_t->get_offset(pos,2), diff_off);
&& face_off2.y() == 1) ? -1 : 0);
off0 = _t->combine_offsets(_t->get_offset(pos, 0), diff_off);
off1 = _t->combine_offsets(_t->get_offset(pos, 1), diff_off);
off2 = _t->combine_offsets(_t->get_offset(pos, 2), diff_off);
}
// return an integer that encodes the translations which have to be
// applied to the edge *pos
int get_drawing_offsets() {
int get_drawing_offsets()
{
Offset off0, off1, off2;
// Choose edges that are to be duplicated. These are edges that
// intersect the boundary of the periodic domain. In UNIQUE mode
@ -251,8 +291,9 @@ private:
// internally stored inside the cell telling us that this cell
// wraps around the domain.
if (_it == T::UNIQUE_COVER_DOMAIN)
get_edge_offsets(off0,off1,off2);
else {
get_edge_offsets(off0, off1, off2);
else
{
CGAL_triangulation_assertion(_it == T::STORED_COVER_DOMAIN);
off0 = _t->int_to_off(pos->offset(0));
off1 = _t->int_to_off(pos->offset(1));
@ -275,33 +316,37 @@ private:
|| (off0.y() == 1 && off1.y() == 1
&& off2.y() == 1)) ? 0 : 1);
return( 2*offx + offy );
return( 2 * offx + offy );
}
Periodic_triangle construct_periodic_triangle() const {
Periodic_triangle construct_periodic_triangle() const
{
CGAL_triangulation_assertion(pos != typename T::Face_handle());
Offset off0, off1, off2;
get_edge_offsets(off0, off1, off2);
Offset transl_off = Offset((((_off>>1)&1)==1 ? -1:0),
(((_off )&1)==1 ? -1:0));
if (_it == T::STORED_COVER_DOMAIN) {
off0 = _t->combine_offsets(off0,transl_off);
off1 = _t->combine_offsets(off1,transl_off);
off2 = _t->combine_offsets(off2,transl_off);
Offset transl_off = Offset((((_off >> 1) & 1) == 1 ? -1 : 0),
(((_off ) & 1) == 1 ? -1 : 0));
if (_it == T::STORED_COVER_DOMAIN)
{
off0 = _t->combine_offsets(off0, transl_off);
off1 = _t->combine_offsets(off1, transl_off);
off2 = _t->combine_offsets(off2, transl_off);
}
if (_it == T::UNIQUE_COVER_DOMAIN) {
if (_it == T::UNIQUE_COVER_DOMAIN)
{
off0 += transl_off;
off1 += transl_off;
off2 += transl_off;
}
return make_array(std::make_pair(pos->vertex(0)->point(),off0),
std::make_pair(pos->vertex(1)->point(),off1),
std::make_pair(pos->vertex(2)->point(),off2));
return make_array(std::make_pair(pos->vertex(0)->point(), off0),
std::make_pair(pos->vertex(1)->point(), off1),
std::make_pair(pos->vertex(2)->point(), off2));
}
};
template < class T >
class Periodic_2_triangulation_segment_iterator_2 {
class Periodic_2_triangulation_segment_iterator_2
{
// Iterates over the primitives in a periodic triangulation.
// Options:
// - STORED: output each primitive from the Tds exactly once
@ -340,8 +385,10 @@ public:
Periodic_2_triangulation_segment_iterator_2(const T * t,
Iterator_type it = T::STORED)
: _t(t), pos(_t->edges_begin()), _it(it), _off(0) {
if (_it == T::UNIQUE || _it == T::UNIQUE_COVER_DOMAIN) {
: _t(t), pos(_t->edges_begin()), _it(it), _off(0)
{
if (_it == T::UNIQUE || _it == T::UNIQUE_COVER_DOMAIN)
{
while (pos != _t->edges_end() && !is_canonical() )
++pos;
}
@ -352,13 +399,19 @@ public:
Iterator_type it = T::STORED)
: _t(t), pos(_t->edges_end()), _it(it), _off(0) {}
Periodic_segment_iterator& operator++() {
switch (_it) {
Periodic_segment_iterator& operator++()
{
switch (_it)
{
case T::STORED:
++pos;
break;
case T::UNIQUE:
do { ++pos; } while (pos != _t->edges_end() && !is_canonical());
do
{
++pos;
}
while (pos != _t->edges_end() && !is_canonical());
break;
case T::STORED_COVER_DOMAIN:
case T::UNIQUE_COVER_DOMAIN:
@ -370,13 +423,19 @@ public:
return *this;
}
Periodic_segment_iterator& operator--() {
switch (_it) {
Periodic_segment_iterator& operator--()
{
switch (_it)
{
case T::STORED:
--pos;
break;
case T::UNIQUE:
do { --pos; } while (pos != _t->edges_begin() && !is_canonical());
do
{
--pos;
}
while (pos != _t->edges_begin() && !is_canonical());
break;
case T::STORED_COVER_DOMAIN:
case T::UNIQUE_COVER_DOMAIN:
@ -438,12 +497,14 @@ private:
// check whether pos points onto a unique edge or not.
// If we are computing in 1-sheeted covering this should
// always be true.
bool is_canonical() {
bool is_canonical()
{
// fetch all offsets
Offset off0, off1;
get_edge_offsets(off0, off1);
if (_t->number_of_sheets() != make_array(1,1)) {
if (_t->number_of_sheets() != make_array(1, 1))
{
// If there is one offset with entries larger than 1 then we are
// talking about a vertex that is too far away from the original
// domain to belong to a canonical triangle.
@ -464,53 +525,75 @@ private:
// Artificial incrementation function that takes periodic
// copies into account.
void increment_domain() {
void increment_domain()
{
int off = get_drawing_offsets();
CGAL_triangulation_assertion(_off <= off);
if (_off == off) {
if (_off == off)
{
_off = 0;
do { ++pos; } while (_it == T::UNIQUE_COVER_DOMAIN
do
{
++pos;
}
while (_it == T::UNIQUE_COVER_DOMAIN
&& pos != _t->edges_end() && !is_canonical());
} else {
do {
}
else
{
do
{
++_off;
} while ((((~_off)|off)&3)!=3); // Increment until a valid
}
while ((((~_off) | off) & 3) != 3); // Increment until a valid
// offset has been found
}
}
// Artificial decrementation function that takes periodic
// copies into account.
void decrement_domain() {
if (_off == 0) {
void decrement_domain()
{
if (_off == 0)
{
if (pos == _t->edges_begin()) return;
do { --pos; } while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical());
do
{
--pos;
}
while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical());
_off = get_drawing_offsets();
} else {
}
else
{
int off = get_drawing_offsets();
do {
do
{
--_off;
} while ((((~_off)|off)&3)!=3); // Decrement until a valid
}
while ((((~_off) | off) & 3) != 3); // Decrement until a valid
// offset has been found
}
}
// Get the canonicalized offsets of an edge.
// This works in any cover that is encoded in _t->combine_offsets
void get_edge_offsets(Offset &off0, Offset &off1) const {
void get_edge_offsets(Offset &off0, Offset &off1) const
{
Offset cell_off0 = _t->int_to_off(pos->first->offset(_t->cw(pos->second)));
Offset cell_off1 = _t->int_to_off(pos->first->offset(_t->ccw(pos->second)));
Offset diff_off((cell_off0.x()==1 && cell_off1.x()==1)?-1:0,
(cell_off0.y()==1 && cell_off1.y()==1)?-1:0);
off0 = _t->combine_offsets(_t->get_offset(pos->first,_t->cw(pos->second)),
Offset diff_off((cell_off0.x() == 1 && cell_off1.x() == 1) ? -1 : 0,
(cell_off0.y() == 1 && cell_off1.y() == 1) ? -1 : 0);
off0 = _t->combine_offsets(_t->get_offset(pos->first, _t->cw(pos->second)),
diff_off);
off1 = _t->combine_offsets(_t->get_offset(pos->first,_t->ccw(pos->second)),
off1 = _t->combine_offsets(_t->get_offset(pos->first, _t->ccw(pos->second)),
diff_off);
}
// return an integer that encodes the translations which have to be
// applied to the edge *pos
int get_drawing_offsets() {
int get_drawing_offsets()
{
Offset off0, off1;
// Choose edges that are to be duplicated. These are edges that
// intersect the boundary of the periodic domain. In UNIQUE mode
@ -519,8 +602,9 @@ private:
// internally stored inside the cell telling us that this cell
// wraps around the domain.
if (_it == T::UNIQUE_COVER_DOMAIN)
get_edge_offsets(off0,off1);
else {
get_edge_offsets(off0, off1);
else
{
CGAL_triangulation_assertion(_it == T::STORED_COVER_DOMAIN);
off0 = _t->int_to_off(pos->first->offset(_t->cw(pos->second)));
off1 = _t->int_to_off(pos->first->offset(_t->ccw(pos->second)));
@ -530,32 +614,36 @@ private:
CGAL_triangulation_assertion(diff_off.x() >= -1 || diff_off.x() <= 1);
CGAL_triangulation_assertion(diff_off.y() >= -1 || diff_off.y() <= 1);
return( 2*(diff_off.x() == 0 ? 0:1)
+ (diff_off.y() == 0 ? 0:1));
return( 2 * (diff_off.x() == 0 ? 0 : 1)
+ (diff_off.y() == 0 ? 0 : 1));
}
Periodic_segment construct_periodic_segment() const {
Periodic_segment construct_periodic_segment() const
{
CGAL_triangulation_assertion(pos->first != typename T::Face_handle());
Offset off0, off1;
get_edge_offsets(off0, off1);
Offset transl_off = Offset((((_off>>1)&1)==1 ? -1:0),
(( _off &1)==1 ? -1:0));
if (_it == T::STORED_COVER_DOMAIN) {
off0 = _t->combine_offsets(off0,transl_off);
off1 = _t->combine_offsets(off1,transl_off);
Offset transl_off = Offset((((_off >> 1) & 1) == 1 ? -1 : 0),
(( _off & 1) == 1 ? -1 : 0));
if (_it == T::STORED_COVER_DOMAIN)
{
off0 = _t->combine_offsets(off0, transl_off);
off1 = _t->combine_offsets(off1, transl_off);
}
if (_it == T::UNIQUE_COVER_DOMAIN) {
if (_it == T::UNIQUE_COVER_DOMAIN)
{
off0 += transl_off;
off1 += transl_off;
}
return make_array(
std::make_pair(pos->first->vertex(_t->cw(pos->second))->point(),off0),
std::make_pair(pos->first->vertex(_t->ccw(pos->second))->point(),off1));
std::make_pair(pos->first->vertex(_t->cw(pos->second))->point(), off0),
std::make_pair(pos->first->vertex(_t->ccw(pos->second))->point(), off1));
}
};
template < class T >
class Periodic_2_triangulation_point_iterator_2 {
class Periodic_2_triangulation_point_iterator_2
{
// Iterates over the primitives in a periodic triangulation.
// Options:
// - STORED: output each primitive from the Tds exactly once
@ -593,8 +681,10 @@ public:
Periodic_2_triangulation_point_iterator_2(const T * t,
Iterator_type it = T::STORED)
: _t(t), pos(_t->vertices_begin()), _it(it) {
if (_it == T::UNIQUE || _it == T::UNIQUE_COVER_DOMAIN) {
: _t(t), pos(_t->vertices_begin()), _it(it)
{
if (_it == T::UNIQUE || _it == T::UNIQUE_COVER_DOMAIN)
{
while (pos != _t->vertices_end() && !is_canonical() )
++pos;
}
@ -605,15 +695,21 @@ public:
Iterator_type it = T::STORED)
: _t(t), pos(_t->vertices_end()), _it(it) {}
Periodic_point_iterator& operator++() {
switch (_it) {
Periodic_point_iterator& operator++()
{
switch (_it)
{
case T::STORED:
case T::STORED_COVER_DOMAIN:
++pos;
break;
case T::UNIQUE:
case T::UNIQUE_COVER_DOMAIN:
do { ++pos; } while (pos != _t->vertices_end() && !is_canonical());
do
{
++pos;
}
while (pos != _t->vertices_end() && !is_canonical());
break;
default:
CGAL_triangulation_assertion(false);
@ -621,15 +717,21 @@ public:
return *this;
}
Periodic_point_iterator& operator--() {
switch (_it) {
Periodic_point_iterator& operator--()
{
switch (_it)
{
case T::STORED:
case T::STORED_COVER_DOMAIN:
--pos;
break;
case T::UNIQUE:
case T::UNIQUE_COVER_DOMAIN:
do { --pos; } while (pos != _t->vertices_begin() && !is_canonical());
do
{
--pos;
}
while (pos != _t->vertices_begin() && !is_canonical());
break;
default:
CGAL_triangulation_assertion(false);
@ -690,27 +792,31 @@ private:
// check whether pos points onto a vertex inside the original
// domain. If we are computing in 1-sheeted covering this should
// always be true.
bool is_canonical() {
bool is_canonical()
{
return (_t->get_offset(pos).is_null());
}
Periodic_point construct_periodic_point() const {
Periodic_point construct_periodic_point() const
{
CGAL_triangulation_assertion(pos != typename T::Vertex_handle());
Offset off = _t->get_offset(pos);
return std::make_pair(pos->point(),off);
return std::make_pair(pos->point(), off);
}
};
template <class T>
class Domain_tester {
class Domain_tester
{
const T *t;
public:
Domain_tester() {}
Domain_tester(const T *tr) : t(tr) {}
bool operator()(const typename T::Vertex_iterator & v) const {
return (t->get_offset(v) != typename T::Offset(0,0));
bool operator()(const typename T::Vertex_iterator & v) const
{
return (t->get_offset(v) != typename T::Offset(0, 0));
}
};
@ -723,7 +829,8 @@ public:
// between a normal Vertex_iterator and this iterator
template <class T>
class Periodic_2_triangulation_unique_vertex_iterator_2
: public Filter_iterator<typename T::Vertex_iterator, Domain_tester<T> > {
: public Filter_iterator<typename T::Vertex_iterator, Domain_tester<T> >
{
typedef typename T::Vertex_handle Vertex_handle;
typedef typename T::Vertex_iterator Vertex_iterator;
@ -735,12 +842,33 @@ public:
Periodic_2_triangulation_unique_vertex_iterator_2() : Base() {}
Periodic_2_triangulation_unique_vertex_iterator_2(const Base &b) : Base(b) {}
Self & operator++() { Base::operator++(); return *this; }
Self & operator--() { Base::operator--(); return *this; }
Self operator++(int) { Self tmp(*this); ++(*this); return tmp; }
Self operator--(int) { Self tmp(*this); --(*this); return tmp; }
Self & operator++()
{
Base::operator++();
return *this;
}
Self & operator--()
{
Base::operator--();
return *this;
}
Self operator++(int)
{
Self tmp(*this);
++(*this);
return tmp;
}
Self operator--(int)
{
Self tmp(*this);
--(*this);
return tmp;
}
operator Vertex_handle() const { return Base::base(); }
operator Vertex_handle() const
{
return Base::base();
}
};
} //namespace CGAL

View File

@ -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 >
@ -56,10 +57,12 @@ public:
typedef internal::Static_filters_predicates::Periodic_2_side_of_oriented_circle_2<Traits>
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);

View File

@ -34,10 +34,12 @@
#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;
@ -55,38 +57,45 @@ public:
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 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,7 +125,8 @@ 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;
@ -155,19 +166,24 @@ public:
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,39 +191,60 @@ 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;
@ -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 >

View File

@ -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;
}
@ -102,7 +109,7 @@ inline
std::ostream&
operator<<(std::ostream &os,
const Periodic_2_triangulation_vertex_base_2<Tds> &)
// no combinatorial information.
// 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;
};
};

View File

@ -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,15 +97,16 @@ 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) {
const EX * dom_e, const AP * dom_f) : Base(dom_e, dom_f), _dom(dom)
{
}
#ifndef CGAL_CFG_MATCHING_BUG_6
@ -109,7 +115,7 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
result_type
operator()(const Vector_2& u, const Vector_2& v) const
{
return Base::operator()(u,v);
return Base::operator()(u, v);
}
result_type
@ -123,7 +129,8 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
const Point_2 &r,
const Offset_2 &o_p,
const Offset_2 &o_q,
const Offset_2 &o_r) const {
const Offset_2 &o_r) const
{
return Base::operator()(p, q, r, o_p, o_q, o_r);
}
#endif
@ -163,12 +170,14 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
std::swap(maxx, maxy);
// Protect against underflow in the computation of eps.
if (maxx < 1e-97) /* cbrt(min_double/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) */ {
else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */
{
if (det > eps) return POSITIVE;
if (det < -eps) return NEGATIVE;
}
@ -182,7 +191,8 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
/// 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");
@ -227,12 +237,14 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
std::swap(maxx, maxy);
// Protect against underflow in the computation of eps.
if (maxx < 1e-97) /* cbrt(min_double/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) */ {
else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */
{
if (det > eps) return POSITIVE;
if (det < -eps) return NEGATIVE;
}
@ -240,14 +252,14 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
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
@ -260,6 +272,8 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2
};
} } } // namespace CGAL::internal::Static_filters_predicates
}
}
} // namespace CGAL::internal::Static_filters_predicates
#endif // CGAL_INTERNAL_STATIC_FILTERS_PERIODIC_2_ORIENTATION_2_H

View File

@ -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
@ -49,7 +54,7 @@ public:
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) { }
: Base(dom_e, dom_f), _dom(dom) { }
Oriented_side
operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r,
@ -69,20 +74,20 @@ public:
{
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,12 +118,14 @@ public:
if (maxx > maxy) std::swap(maxx, maxy);
// Protect against underflow in the computation of eps.
if (maxx < 1e-73) {
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);
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;
}
@ -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");
@ -149,7 +157,8 @@ public:
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->ymin(), domymin))
{
CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static attempts");
@ -193,12 +202,14 @@ public:
rsx, rsy, rt2);
// Protect against underflow in the computation of eps.
if (maxx < 1e-58) /* sqrt^5(min_double/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]) */ {
else if (maxy < 1e61) /* sqrt^5(max_double/4 [hadamard]) */
{
if (det > eps) return ON_POSITIVE_SIDE;
if (det < -eps) return ON_NEGATIVE_SIDE;
}
@ -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,
@ -227,6 +238,8 @@ public:
}
};
} } } // 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

View File

@ -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,7 +132,8 @@ 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);
@ -136,7 +141,8 @@ void test_predicates() {
}
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,19 +191,22 @@ void test_iterators() {
// vertices
size_t size = 0;
for (typename T::Vertex_iterator vit = t_const.vertices_begin();
vit != t_const.vertices_end(); ++vit) {
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) {
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) {
vit != t_const.all_vertices_end(); ++vit)
{
++size;
}
CGAL_assertion(size == t_const.number_of_stored_vertices());
@ -203,13 +214,15 @@ void test_iterators() {
// edges
size = 0;
for (typename T::Edge_iterator eit = t_const.edges_begin();
eit != t_const.edges_end(); ++eit) {
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) {
eit != t_const.all_edges_end(); ++eit)
{
++size;
}
CGAL_assertion(size == t_const.number_of_stored_edges());
@ -217,82 +230,100 @@ void test_iterators() {
// faces
size = 0;
for (typename T::Face_iterator fit = t_const.faces_begin();
fit != t_const.faces_end(); ++fit) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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,7 +393,8 @@ void test_modifiers() {
t.clear();
vh0 = t.insert_first(p0);
vh1 = t.insert(p1);
if (t.degree(vh1) == 3) {
if (t.degree(vh1) == 3)
{
// The vertex has degree 6 in case we are testing the Delaunay triangulation
t.remove_degree_3(vh1);
}
@ -376,8 +410,10 @@ 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) {
vit != t_const.vertices_end(); ++vit)
{
if (t_const.degree(vit) == 3)
{
t.remove_degree_3(vit);
vit = t_const.vertices_begin();
}
@ -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,7 +464,8 @@ 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;
@ -438,12 +476,16 @@ void test_io(T &pt1, bool ex) {
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) {
if (!ex)
{
std::stringstream ss1b;
CGAL::set_binary_mode(ss1b);
ss1b << pt1;
@ -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,8 +620,10 @@ 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) {
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)));
}
}
@ -582,8 +631,10 @@ void test_locally_delaunay() {
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) {
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)));
}
}
@ -592,7 +643,8 @@ void test_locally_delaunay() {
}
template <class T>
void test_delaunay() {
void test_delaunay()
{
test_batch_insertion<T>();
test_nearest<T>();
test_locally_delaunay<T>();

View File

@ -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

View File

@ -6,15 +6,17 @@
#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++) {
for (int i = 0 ; i < 1000 ; i++)
{
pts_rnd1000.push_back(*on_circle++ + Vector(0.5, 0.5));
}
@ -36,9 +38,10 @@ void test_insertion() {
// Center of the circle around the origin
pts_rnd1000.clear();
for (int i=0 ; i<1000 ; i++) {
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()));
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());
@ -50,7 +53,8 @@ void test_insertion() {
CGAL_assertion(pt.number_of_vertices() == 0);
}
int main() {
int main()
{
test_insertion();
return 0;

View File

@ -23,39 +23,46 @@ 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) {
for (int n = 0; n <= maximum; n += 5000)
{
CGAL::Timer timer;
std::vector<Point> pts;
for (int i=0 ; i<n ; i++) {
for (int i = 0 ; i < n ; i++)
{
pts.push_back(*in_square++ + Vector(0.5, 0.5));
}
@ -68,7 +75,8 @@ void test_performance(const std::string &name, int maximum = 1e5) {
}
}
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);

View File

@ -6,7 +6,8 @@
const int N_PTS = 75;
int main() {
int main()
{
Triangulation t;
Vector midpoint(0.5, 0.5);
@ -14,24 +15,27 @@ 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);
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()) {
while (!t.empty())
{
t.remove(t.vertices_begin());
CGAL_assertion(t.is_valid(true));
}
@ -69,12 +73,14 @@ int main() {
std::cout << "Inserting random points and removing them." << std::endl;
for (int i = 0; i < N_PTS; ++i) {
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) {
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);

View File

@ -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>;

View File

@ -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;

View File

@ -15,16 +15,18 @@ 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()) {
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];
@ -36,26 +38,31 @@ void load_data(const char *filename, Iso_rectangle &domain, std::vector<Point> &
}
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) {
if (do_remove)
{
std::vector<typename T::Vertex_handle> vhs;
for (typename T::Vertex_iterator it = t.vertices_begin(); it != t.vertices_end(); ++it) {
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)
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) {
if (argc == 2)
{
filename = argv[1];
}
@ -63,7 +70,8 @@ int main(int argc, char * argv[]) {
std::vector<Point> pts;
load_data(filename, domain, pts);
for (int run=0; run<3; ++run) {
for (int run = 0; run < 3; ++run)
{
// if (true) {
// if (pre_run) {
// Delaunay_triangulation_2<Gt> t;
@ -80,18 +88,21 @@ int main(int argc, char * argv[]) {
// std::cout << "Euclidean space, " << filename << ", " << total_time << std::endl;
// }
if (true) {
if (pre_run) {
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) {
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;
double total_time = (std::clock() - total_start) / (double)CLOCKS_PER_SEC;
std::cout << "Periodic space, " << filename << ", " << total_time << std::endl;
}

View File

@ -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
@ -50,13 +51,14 @@ int main() {
// First run is for heating up the CPU, don't output the stats
for (int run=0; run<N_RUNS; ++run) {
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;
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;
@ -68,23 +70,29 @@ int main() {
std::clock_t start_time = std::clock();
// Do one additional point to get the statistics right
for (int i = 0; i <= N_PTS; ++i) {
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 (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) {
if (i % 500 == 0)
{
std::cout << i << ", \t"
<< (std::clock()-start_time)/(double)CLOCKS_PER_SEC << ", \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;

View File

@ -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,7 +101,8 @@ 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();

View File

@ -3,16 +3,21 @@
#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) {
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;
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)))));
@ -20,16 +25,20 @@ void greedy_flip_long_edges(Triangulation &t) {
}
bool is_1_cover = t.is_1_cover();
for (Edge_map::reverse_iterator it = edge_map.rbegin(); it != edge_map.rend(); ++it) {
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)) {
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) {
if (sqr_length_orig < sqr_length_new)
{
std::cout << sqr_length_orig << std::endl;
t.flip(f, t.ccw(i));
}
@ -38,16 +47,19 @@ void greedy_flip_long_edges(Triangulation &t) {
}
}
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));
}
}

View File

@ -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;

View File

@ -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);
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);
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);

View File

@ -6,7 +6,8 @@
#define N_PTS 10000
#endif
int main() {
int main()
{
Triangulation t;
Random random(1284141159);
@ -16,11 +17,13 @@ int main() {
Random_points_on_circle g(0.495, random);
Vector midpoint(0.5, 0.5);
for (int i = 0; i < N_PTS; ++i) {
for (int i = 0; i < N_PTS; ++i)
{
t.insert(*(++g) + midpoint);
}
if (!t.is_valid(true)) {
if (!t.is_valid(true))
{
std::cout << "l:" << __LINE__ << std::endl;
std::exit(1);
}

View File

@ -2,7 +2,8 @@
#include "./types.h"
int main() {
int main()
{
Point p;
Triangulation t;

View File

@ -4,7 +4,8 @@
Face_handle test_point_location(const Triangulation &t,
const Point &query,
const Triangulation::Locate_type &lt_in) {
const Triangulation::Locate_type &lt_in)
{
Triangulation::Locate_type lt, lt2;
int li, li2;
Face_handle fh;
@ -13,7 +14,8 @@ Face_handle test_point_location(const Triangulation &t,
fh = t.locate(query, lt, li);
CGAL_assertion(lt == lt_in);
if (lt_in != Triangulation::EMPTY) {
if (lt_in != Triangulation::EMPTY)
{
bs = t.side_of_face(query, fh, lt2, li2);
os = t.oriented_side(fh, query);
@ -21,9 +23,11 @@ Face_handle test_point_location(const Triangulation &t,
}
switch (lt_in) {
switch (lt_in)
{
case Triangulation::VERTEX:
case Triangulation::EDGE: {
case Triangulation::EDGE:
{
CGAL_assertion(fh != Face_handle());
CGAL_assertion(bs == CGAL::ON_BOUNDARY);
CGAL_assertion(os == CGAL::ON_ORIENTED_BOUNDARY);
@ -31,13 +35,15 @@ Face_handle test_point_location(const Triangulation &t,
CGAL_assertion(li == li2);
break;
}
case Triangulation::FACE: {
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: {
case Triangulation::EMPTY:
{
CGAL_assertion(fh == Face_handle());
break;
}
@ -46,7 +52,8 @@ Face_handle test_point_location(const Triangulation &t,
return fh;
}
int main() {
int main()
{
Triangulation t;
Face_handle fh;

View File

@ -19,27 +19,34 @@ 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) {
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
{
// 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
{
// 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) {
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) {
if (side != CGAL::ON_UNBOUNDED_SIDE)
{
CGAL_assertion(lt == Triangulation::VERTEX);
}
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
@ -51,13 +58,16 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t
CGAL_assertion(on_boundary == 6);
CGAL_assertion(on_inside == 0);
}
{ // Locate point on an 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) {
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);
@ -69,13 +79,16 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t
CGAL_assertion(on_boundary == 2);
CGAL_assertion(on_inside == 0);
}
{ // Locate point inside a 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) {
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);
@ -88,17 +101,21 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t
CGAL_assertion(on_inside == 1);
}
}
{ // Test the face iterator
{
// 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
{
// 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) {
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) {
if (side != CGAL::ON_UNBOUNDED_SIDE)
{
CGAL_assertion(lt == Triangulation::VERTEX);
}
on_boundary += (side == CGAL::ON_BOUNDARY ? 1 : 0);
@ -108,13 +125,16 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t
CGAL_assertion(on_boundary == 6);
CGAL_assertion(on_inside == 0);
}
{ // Locate point on an 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) {
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);
@ -124,13 +144,16 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t
CGAL_assertion(on_boundary == 2);
CGAL_assertion(on_inside == 0);
}
{ // Locate point inside a 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) {
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);
@ -145,7 +168,8 @@ void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t
}
}
int main() {
int main()
{
Triangulation t;
// Insert the first point
@ -153,31 +177,37 @@ int main() {
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) {
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) {
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) {
while(it != beyond)
{
Triangle triangle = t.triangle(*it);
triangle.vertex(0); // Avoid warning
++it;