diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_2.h index 44e5d570d05..8aa3b92f39a 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_2.h @@ -1,42 +1,43 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2MainClasses -The class `Periodic_2_Delaunay_triangulation_2` represents a -Delaunay triangulation in two-dimensional periodic space. +The class `Periodic_2_Delaunay_triangulation_2` represents a +Delaunay triangulation in two-dimensional periodic space. ### Parameters ### -The class `Periodic_2_Delaunay_triangulation_2` has two template parameters. The first one -`Traits` is the geometric traits, it is to be instantiated by a -model of the concept `Periodic_2DelaunayTriangulationTraits_2`. +The class `Periodic_2_Delaunay_triangulation_2` has two template parameters. The first one +`Traits` is the geometric traits, it is to be instantiated by a +model of the concept `Periodic_2DelaunayTriangulationTraits_2`. -The second parameter is the triangulation data structure, it has to be -instantiated by a model of the concept -`TriangulationDataStructure_2` with some additional functionality -in faces. By default, the triangulation data structure is instantiated -by -`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2, CGAL::Periodic_2_triangulation_face_base_2 > >`. +The second parameter is the triangulation data structure, it has to be +instantiated by a model of the concept +`TriangulationDataStructure_2` with some additional functionality +in faces. By default, the triangulation data structure is instantiated +by +`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2, CGAL::Periodic_2_triangulation_face_base_2 > >`. ### Implementation ### -Insertion is implemented by inserting in the triangulation, then -performing a sequence of Delaunay flips. The number of flips is \f$ O(d)\f$ -if the new vertex is of degree \f$ d\f$ in the new triangulation. For -points distributed uniformly at random, insertion takes time \f$ O(1)\f$ on -average. +Insertion is implemented by inserting in the triangulation, then +performing a sequence of Delaunay flips. The number of flips is \f$ O(d)\f$ +if the new vertex is of degree \f$ d\f$ in the new triangulation. For +points distributed uniformly at random, insertion takes time \f$ O(1)\f$ on +average. -Removal calls the removal in the triangulation and then -re-triangulates the hole in such a way that the Delaunay criterion is -satisfied. Removal of a vertex of degree \f$ d\f$ takes time \f$ O(d^2)\f$. The -expected degree \f$ d\f$ is \f$ O(1)\f$ for a random vertex in the -triangulation. +Removal calls the removal in the triangulation and then +re-triangulates the hole in such a way that the Delaunay criterion is +satisfied. Removal of a vertex of degree \f$ d\f$ takes time \f$ O(d^2)\f$. The +expected degree \f$ d\f$ is \f$ O(1)\f$ for a random vertex in the +triangulation. -After a point location step, the nearest neighbor is found in time -\f$ O(n)\f$ in the worst case, but in expected time \f$ O(1)\f$ on average for -vertices distributed uniformly at random and any query point. +After a point location step, the nearest neighbor is found in time +\f$ O(n)\f$ in the worst case, but in expected time \f$ O(1)\f$ on average for +vertices distributed uniformly at random and any query point. \sa `CGAL::Periodic_2_triangulation_2` \sa `CGAL::Delaunay_triangulation_2` @@ -46,43 +47,44 @@ vertices distributed uniformly at random and any query point. */ template< typename Traits, typename Tds > -class Periodic_2_Delaunay_triangulation_2 : public Periodic_2_triangulation_2 { +class Periodic_2_Delaunay_triangulation_2 : public Periodic_2_triangulation_2 +{ public: -/// \name Creation +/// \name Creation /// @{ -/*! -Creates an empty periodic Delaunay triangulation `dt`, with -`domain` as original domain and possibly specifying -a traits class `traits`. -\pre `domain` is a square. -*/ -Periodic_2_Delaunay_triangulation_2( -const Iso_rectangle & domain = Iso_rectangle(0,0,1,1), -const Geom_traits & traits = Geom_traits()); + /*! + Creates an empty periodic Delaunay triangulation `dt`, with + `domain` as original domain and possibly specifying + a traits class `traits`. + \pre `domain` is a square. + */ + Periodic_2_Delaunay_triangulation_2( + const Iso_rectangle & domain = Iso_rectangle(0, 0, 1, 1), + const Geom_traits & traits = Geom_traits()); -/*! -Copy constructor. -*/ -Periodic_2_Delaunay_triangulation_2 (const -Periodic_2_Delaunay_triangulation_2 & dt1); + /*! + Copy constructor. + */ + Periodic_2_Delaunay_triangulation_2 (const + Periodic_2_Delaunay_triangulation_2 & dt1); -/*! -Equivalent to constructing an empty triangulation with the optional -domain and traits class arguments and calling `insert(first,last)`. -\pre The `value_type` of `first` and `last` are `Point`s lying inside `domain` and `domain` is a square. -*/ -template < class InputIterator > -Periodic_2_Delaunay_triangulation_2 ( -InputIterator first, -InputIterator last, -const Iso_rectangle & domain = Iso_rectangle(0,0,1,1), -const Geom_traits & traits = Geom_traits()); + /*! + Equivalent to constructing an empty triangulation with the optional + domain and traits class arguments and calling `insert(first,last)`. + \pre The `value_type` of `first` and `last` are `Point`s lying inside `domain` and `domain` is a square. + */ + template < class InputIterator > + Periodic_2_Delaunay_triangulation_2 ( + InputIterator first, + InputIterator last, + const Iso_rectangle & domain = Iso_rectangle(0, 0, 1, 1), + const Geom_traits & traits = Geom_traits()); -/// @} +/// @} -/// \name Insertion and removal +/// \name Insertion and removal /// The following methods insert points in the triangulation ensuring /// the empty circle property of Delaunay triangulations. The inserted /// points need to lie in the original domain (see Section \ref @@ -96,89 +98,89 @@ const Geom_traits & traits = Geom_traits()); /// some `Vertex_handle`s and `Face_handle`s. /// @{ -/*! -Inserts point `p` in the triangulation and returns the -corresponding vertex. The optional argument `start` is used as a -starting place for the point location. \pre `p` lies in the original domain `domain`. -*/ -Vertex_handle insert(const Point & p, Face_handle start = -Face_handle() ); + /*! + Inserts point `p` in the triangulation and returns the + corresponding vertex. The optional argument `start` is used as a + starting place for the point location. \pre `p` lies in the original domain `domain`. + */ + Vertex_handle insert(const Point & p, Face_handle start = + Face_handle() ); -/*! -Inserts point `p` in the triangulation and returns the -corresponding vertex. Similar to the above `insert()` function, -but takes as additional parameter the return values of a previous -location query. See description of -`Periodic_2_triangulation_2::locate()`. \pre `p` lies in the original domain `domain`. -*/ -Vertex_handle insert(const Point & p, Locate_type lt, -Face_handle loc, int li, int lj); + /*! + Inserts point `p` in the triangulation and returns the + corresponding vertex. Similar to the above `insert()` function, + but takes as additional parameter the return values of a previous + location query. See description of + `Periodic_2_triangulation_2::locate()`. \pre `p` lies in the original domain `domain`. + */ + Vertex_handle insert(const Point & p, Locate_type lt, + Face_handle loc, int li, int lj); -/*! -Equivalent to `insert(p)`. -*/ -Vertex_handle push_back(const Point& p); + /*! + Equivalent to `insert(p)`. + */ + Vertex_handle push_back(const Point& p); -/*! -Inserts the points in the iterator range `[first, last)`. -Returns the number of inserted points. This function uses spatial -sorting (cf. chapter \ref secspatial_sorting) and therefore is -not guaranteed to insert the points following the order of -`InputIterator`. If the third argument `is_large_point_set` -is set to `true` a heuristic for optimizing the insertion of -large point sets is applied. \pre The `value_type` of `first` and `last` are `Point`s and all points in the range lie inside `domain`. -*/ -template < class InputIterator > std::ptrdiff_t -insert(InputIterator first, InputIterator last, bool -is_large_point_set = false); + /*! + Inserts the points in the iterator range `[first, last)`. + Returns the number of inserted points. This function uses spatial + sorting (cf. chapter \ref secspatial_sorting) and therefore is + not guaranteed to insert the points following the order of + `InputIterator`. If the third argument `is_large_point_set` + is set to `true` a heuristic for optimizing the insertion of + large point sets is applied. \pre The `value_type` of `first` and `last` are `Point`s and all points in the range lie inside `domain`. + */ + template < class InputIterator > std::ptrdiff_t + insert(InputIterator first, InputIterator last, bool + is_large_point_set = false); -/*! -Removes the vertex from the triangulation. -*/ -void remove(Vertex_handle v); + /*! + Removes the vertex from the triangulation. + */ + void remove(Vertex_handle v); -/// @} +/// @} -/// \name Point moving +/// \name Point moving /// @{ -/*! -if there is not already another vertex placed on `p`, the -triangulation is modified such that the new position of vertex -`v` is `p`, and `v` is returned. Otherwise, the -triangulation is not modified and the vertex at point `p` is -returned. \pre `p` lies in the original domain `domain`. -*/ -Vertex_handle move_if_no_collision(Vertex_handle v, const -Point & p); + /*! + if there is not already another vertex placed on `p`, the + triangulation is modified such that the new position of vertex + `v` is `p`, and `v` is returned. Otherwise, the + triangulation is not modified and the vertex at point `p` is + returned. \pre `p` lies in the original domain `domain`. + */ + Vertex_handle move_if_no_collision(Vertex_handle v, const + Point & p); -/*! -Moves the point stored in `v` to `p`, while preserving the -Delaunay property. This performs an action semantically equivalent -to `remove(v)` followed by `insert(p)`, but is supposedly -faster to performing these two operations separately when the point -has not moved much. Returns the handle to the new vertex. -\pre `p` lies in the original domain `domain`. -*/ -Vertex_handle move_point(Vertex_handle v, const Point & -p); + /*! + Moves the point stored in `v` to `p`, while preserving the + Delaunay property. This performs an action semantically equivalent + to `remove(v)` followed by `insert(p)`, but is supposedly + faster to performing these two operations separately when the point + has not moved much. Returns the handle to the new vertex. + \pre `p` lies in the original domain `domain`. + */ + Vertex_handle move_point(Vertex_handle v, const Point & + p); -/// @} +/// @} -/// \name Queries +/// \name Queries /// @{ -/*! -Returns any nearest vertex to the point `p`, or the default constructed -handle if the triangulation is empty. The optional argument `f` is a hint -specifying where to start the search. It always returns a vertex -corresponding to a point inside \f$ \ccc{domain}\f$ even if computing in a -multiply sheeted covering space. -\pre `f` is a face of `dt` and `p` lies in the original domain `domain`. + /*! + Returns any nearest vertex to the point `p`, or the default constructed + handle if the triangulation is empty. The optional argument `f` is a hint + specifying where to start the search. It always returns a vertex + corresponding to a point inside \f$ \ccc{domain}\f$ even if computing in a + multiply sheeted covering space. + \pre `f` is a face of `dt` and `p` lies in the original domain `domain`. -*/ -Vertex_handle nearest_vertex(Point p, -Face_handle f = Face_handle()); + */ + Vertex_handle nearest_vertex(Point p, + Face_handle f = Face_handle()); /// @} @@ -189,119 +191,119 @@ Face_handle f = Face_handle()); /// (`p`,`off`) is star-shaped. /// @{ -/*! -`OutputItFaces` is an output iterator with `Face_handle` as -value type. `OutputItBoundaryEdges` stands for an output -iterator with `Edge` as value type. This members function -outputs in the container pointed to by `fit` the faces which are -in conflict with point `p` i. e. the faces whose circumcircle -contains `p`. It outputs in the container pointed to by -`eit` the boundary of the zone in conflict with `p`. -The boundary edges of the conflict zone are output in -counter-clockwise order and each edge is described through its -incident face which is not in conflict with `p`. The function -returns in a std::pair the resulting output -iterators. \pre `start` is in conflict with `p` and `p` lies in the original domain `domain`. -*/ -template -std::pair -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 + std::pair + 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 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 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 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 OutputItBoundaryEdges + get_boundary_of_conflicts(const Point &p, OutputItBoundaryEdges eit, + Face_handle start) const; -/// @} +/// @} -/// \name Voronoi diagram +/// \name Voronoi diagram /// The following member functions provide the elements of the dual Voronoi diagram. /// @{ -/*! -Returns the center of the circle circumscribed to face `f`. -*/ -Point dual(const Face_handle &f) const; + /*! + Returns the center of the circle circumscribed to face `f`. + */ + Point dual(const Face_handle &f) const; -/*! -returns a segment whose endpoints are the duals of both incident -faces. -*/ -Segment dual(const Edge &e) const; + /*! + returns a segment whose endpoints are the duals of both incident + faces. + */ + Segment dual(const Edge &e) const; -/*! -Idem -*/ -Segment dual(const Edge_circulator& ec) const; + /*! + Idem + */ + Segment dual(const Edge_circulator& ec) const; -/*! -Idem -*/ -Segment dual(const Edge_iterator& ei) const; + /*! + Idem + */ + Segment dual(const Edge_iterator& ei) const; -/*! -output the dual Voronoi diagram to stream `ps`. -*/ -template < class Stream> Stream& draw_dual(Stream & ps); + /*! + output the dual Voronoi diagram to stream `ps`. + */ + template < class Stream> Stream& draw_dual(Stream & ps); -/// @} +/// @} -/// \name Predicates +/// \name Predicates /// @{ -/*! -Returns the side of `p` with respect to the circle circumscribing the -triangle associated with `f`. Periodic copies are checked if -necessary. -*/ -Oriented_side side_of_oriented_circle(Face_handle f, const -Point& p, bool perturb ) const; + /*! + Returns the side of `p` with respect to the circle circumscribing the + triangle associated with `f`. Periodic copies are checked if + necessary. + */ + Oriented_side side_of_oriented_circle(Face_handle f, const + Point& p, bool perturb ) const; -/// @} +/// @} -/// \name Checking +/// \name Checking /// \cgalAdvanced These methods are mainly a debugging help for the users of advanced features. /// @{ -/*! -Checks the combinatorial validity of the triangulation and the -validity of its geometric embedding (see -Section \ref P2Triangulation2secintro). Also checks that all the -circumscribing circles of cells are empty. + /*! + Checks the combinatorial validity of the triangulation and the + validity of its geometric embedding (see + Section \ref P2Triangulation2secintro). Also checks that all the + circumscribing circles of cells are empty. -When `verbose` is set to true, messages describing the first -invalidity encountered are printed. -*/ -bool -is_valid(bool verbose = false) const; + When `verbose` is set to true, messages describing the first + invalidity encountered are printed. + */ + bool + is_valid(bool verbose = false) const; -/*! -Checks the combinatorial and geometric validity of the cell (see -Section \ref P2Triangulation2secintro). Also checks that the -circumscribing circle of cells is empty. + /*! + Checks the combinatorial and geometric validity of the cell (see + Section \ref P2Triangulation2secintro). Also checks that the + circumscribing circle of cells is empty. -When `verbose` is set to true, messages are printed to give -a precise indication of the kind of invalidity encountered. -*/ -bool -is_valid(Face_handle f, bool verbose = false) const; + When `verbose` is set to true, messages are printed to give + a precise indication of the kind of invalidity encountered. + */ + bool + is_valid(Face_handle f, bool verbose = false) const; /// @} diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h index b0c42c7b723..3bdcbedd676 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h @@ -1,27 +1,29 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2 -The class `Periodic_2_Delaunay_triangulation_traits_2`is designed as a default traits class for the -class `Periodic_2_Delaunay_triangulation_2`. +The class `Periodic_2_Delaunay_triangulation_traits_2`is designed as a default traits class for the +class `Periodic_2_Delaunay_triangulation_2`. -The argument `Traits` must be a model of the -`DelaunayTriangulationTraits_2` concept. The argument -`Periodic_2Offset_2` must be a model of the concept -`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`. +The argument `Traits` must be a model of the +`DelaunayTriangulationTraits_2` concept. The argument +`Periodic_2Offset_2` must be a model of the concept +`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`. -Note that this template class is specialized for -`CGAL::Filtered_kernel`, so that it automatically provides filtered -predicates. This holds implicitly for -`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an -instantiation of `CGAL::Filtered_kernel`. +Note that this template class is specialized for +`CGAL::Filtered_kernel`, so that it automatically provides filtered +predicates. This holds implicitly for +`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an +instantiation of `CGAL::Filtered_kernel`. -\alModels ::Periodic_2DelaunayTriangulationTraits_2 +\alModels ::Periodic_2DelaunayTriangulationTraits_2 */ template< typename Traits, typename Periodic_2Offset_2 > -class Periodic_2_Delaunay_triangulation_traits_2 - : public Periodic_2_triangulation_traits_2 { +class Periodic_2_Delaunay_triangulation_traits_2 + : public Periodic_2_triangulation_traits_2 +{ }; /* end Periodic_2_Delaunay_triangulation_traits_2 */ } /* end namespace CGAL */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_offset_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_offset_2.h index 680f8f41f51..ef79c086cfa 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_offset_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_offset_2.h @@ -1,11 +1,13 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2 -The class `Periodic_2_offset_2` is a model of the concept `Periodic_2Offset_2`. +The class `Periodic_2_offset_2` is a model of the concept `Periodic_2Offset_2`. */ -class Periodic_2_offset_2 { +class Periodic_2_offset_2 +{ }; /* end Periodic_2_offset_2 */ } /* end namespace CGAL */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h index 86d01db2542..6b8de37a559 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h @@ -1,70 +1,71 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2MainClasses -The class `Periodic_2_triangulation_2` represents a 2-dimensional -triangulation of a point set in \f$ \mathbb T_c^2\f$. +The class `Periodic_2_triangulation_2` represents a 2-dimensional +triangulation of a point set in \f$ \mathbb T_c^2\f$. ### Parameters ### -The class `Periodic_2_triangulation_2` has two template parameters. The first one -`Traits` is the geometric traits, it is to be instantiated by -a model of the concept `Periodic_2TriangulationTraits_2`. +The class `Periodic_2_triangulation_2` has two template parameters. The first one +`Traits` is the geometric traits, it is to be instantiated by +a model of the concept `Periodic_2TriangulationTraits_2`. -The second parameter is the triangulation data structure, -it has to be instantiated by a model of the concept -`TriangulationDataStructure_2` with some additional -functionality in faces. -By default, the triangulation data structure is instantiated by -`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2, CGAL::Periodic_2_triangulation_face_base_2 > >`. +The second parameter is the triangulation data structure, +it has to be instantiated by a model of the concept +`TriangulationDataStructure_2` with some additional +functionality in faces. +By default, the triangulation data structure is instantiated by +`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2, CGAL::Periodic_2_triangulation_face_base_2 > >`. ### Traversal of the Triangulation ### -The periodic triangulation class provides several iterators and circulators that allow one to traverse it. +The periodic triangulation class provides several iterators and circulators that allow one to traverse it. ### I/O ### -The I/O operators are defined for `iostream`. The format for the -iostream is an internal format. +The I/O operators are defined for `iostream`. The format for the +iostream is an internal format. \code -`CGAL/IO/ostream_2.h` +`CGAL/IO/ostream_2.h` \endcode -The information in the `iostream` is: +The information in the `iostream` is: -- the original domain -- the number of sheets of the covering space as in `number_of_sheets()` -- the number of vertices -- the non-combinatorial information of vertices (point resp. point-offset pairs, etc.) -- the number of faces -- the indices of the vertices of each face -- the indices of the neighbors of each face, where the index - corresponds to the preceding list of faces -- the offsets corresponding to the vertices of the faces -- the non-combinatorial information of each face +- the original domain +- the number of sheets of the covering space as in `number_of_sheets()` +- the number of vertices +- the non-combinatorial information of vertices (point resp. point-offset pairs, etc.) +- the number of faces +- the indices of the vertices of each face +- the indices of the neighbors of each face, where the index + corresponds to the preceding list of faces +- the offsets corresponding to the vertices of the faces +- the non-combinatorial information of each face -CGAL also provides a stream operator `<<` to draw triangulations -for `CGAL::Qt_widget`, the Qt based graphic package. -These operators require the include statement: +CGAL also provides a stream operator `<<` to draw triangulations +for `CGAL::Qt_widget`, the Qt based graphic package. +These operators require the include statement: \code #include CGAL/IO/Qt_widget_Triangulation_2.h \endcode -See the `Qt_widget` class. +See the `Qt_widget` class. ### Implementation ### -Locate is implemented by a randomized walk from a vertex of the -face given as optional parameter (or from an arbitrary vertex of if no -optional parameter is given). +Locate is implemented by a randomized walk from a vertex of the +face given as optional parameter (or from an arbitrary vertex of if no +optional parameter is given). -Insertion of a point is done by locating a face that contains the -point, and then splitting this face. Apart from the location, -insertion takes a time \f$ O(1)\f$. +Insertion of a point is done by locating a face that contains the +point, and then splitting this face. Apart from the location, +insertion takes a time \f$ O(1)\f$. Removal of a vertex is more difficult than in the Euclidean space, since the star of a vertex may not be disjoint from the star of a @@ -73,480 +74,483 @@ not implemented. Several more constrained cases are implemented: the removal of the last vertex in the triangulation and the removal of a vertex of degree 3. -The face, edge, and vertex iterators on features are derived from -their counterparts visiting all (non-virtual and virtual) features -which are themselves derived from the corresponding iterators of the -triangulation data structure. +The face, edge, and vertex iterators on features are derived from +their counterparts visiting all (non-virtual and virtual) features +which are themselves derived from the corresponding iterators of the +triangulation data structure. -\sa `Triangulation_2` -\sa `Periodic_2TriangulationTraits_2` -\sa `TriangulationDataStructure_2` -\sa `TriangulationDataStructure_2::Face` -\sa `TriangulationDataStructure_2::Vertex` -\sa `CGAL::Triangulation_data_structure_2` -\sa `CGAL::Periodic_2_triangulation_face_base_2` +\sa `Triangulation_2` +\sa `Periodic_2TriangulationTraits_2` +\sa `TriangulationDataStructure_2` +\sa `TriangulationDataStructure_2::Face` +\sa `TriangulationDataStructure_2::Vertex` +\sa `CGAL::Triangulation_data_structure_2` +\sa `CGAL::Periodic_2_triangulation_face_base_2` */ template< typename Traits, typename Tds > -class Periodic_2_triangulation_2 : public Triangulation_cw_ccw_2 { +class Periodic_2_triangulation_2 : public Triangulation_cw_ccw_2 +{ public: /// The enum Iterator_type is defined by `Periodic_2_triangulation_2` to /// specify the behavior of geometric iterators. -enum Iterator_type { - /// Return all geometric primitives as they are - /// stored internally in `Triangulation_data_structure_2`. - STORED=0, - /// Return only one representative of each geometric - /// primitive even if the triangulation is computed in a multiply - /// sheeted covering space. Choose the representative whose maximum - /// offset is minimal but non-negative in each direction of space. - UNIQUE, - /// Same as `STORED` but return - /// additionally all primitives whose intersection with the original - /// domain of the current covering space is non-empty. - STORED_COVER_DOMAIN, - /// Same as `UNIQUE` but return - /// additionally all primitives whose intersection with the original - /// domain is non-empty. - UNIQUE_COVER_DOMAIN -}; + enum Iterator_type + { + /// Return all geometric primitives as they are + /// stored internally in `Triangulation_data_structure_2`. + STORED = 0, + /// Return only one representative of each geometric + /// primitive even if the triangulation is computed in a multiply + /// sheeted covering space. Choose the representative whose maximum + /// offset is minimal but non-negative in each direction of space. + UNIQUE, + /// Same as `STORED` but return + /// additionally all primitives whose intersection with the original + /// domain of the current covering space is non-empty. + STORED_COVER_DOMAIN, + /// Same as `UNIQUE` but return + /// additionally all primitives whose intersection with the original + /// domain is non-empty. + UNIQUE_COVER_DOMAIN + }; /// The enum `@` is defined by `Periodic_2_triangulation_2` to /// specify which case occurs when locating a point in the /// triangulation. If the triangulation does not contain any points /// `EMPTY` is returned. -enum Locate_type { - /// when the located point coincides with a vertex of the triangulation - VERTEX=0, - /// when the point is in the relative interior of an edge - EDGE, - /// when the point is in the interior of a facet - FACE, - /// when the triangulation is empty - EMPTY -}; + enum Locate_type + { + /// when the located point coincides with a vertex of the triangulation + VERTEX = 0, + /// when the point is in the relative interior of an edge + EDGE, + /// when the point is in the interior of a facet + FACE, + /// when the triangulation is empty + EMPTY + }; -/// \name Types +/// \name Types /// @{ -/*! -The traits class. -*/ -typedef Traits Geom_traits; + /*! + The traits class. + */ + typedef Traits Geom_traits; -/*! -The triangulation data structure type. -*/ -typedef Tds Triangulation_data_structure; + /*! + The triangulation data structure type. + */ + typedef Tds Triangulation_data_structure; -/*! -The offset type -*/ -typedef Geom_traits::Periodic_2_offset_2 Offset; + /*! + The offset type + */ + typedef Geom_traits::Periodic_2_offset_2 Offset; -/*! -the iso rectangle type -*/ -typedef Geom_traits::Iso_rectangle_2 Iso_rectangle; + /*! + the iso rectangle type + */ + typedef Geom_traits::Iso_rectangle_2 Iso_rectangle; -/*! -Integer tuple to -store the number of sheets in each direction of space. -*/ -typedef array Covering_sheets; + /*! + Integer tuple to + store the number of sheets in each direction of space. + */ + typedef array Covering_sheets; -/*! -the point type -*/ -typedef Geom_traits::Point_2 Point; + /*! + the point type + */ + typedef Geom_traits::Point_2 Point; -/*! -the segment type -*/ -typedef Geom_traits::Segment_2 Segment; + /*! + the segment type + */ + typedef Geom_traits::Segment_2 Segment; -/*! -the triangle type -*/ -typedef Geom_traits::Triangle_2 Triangle; + /*! + the triangle type + */ + typedef Geom_traits::Triangle_2 Triangle; -/*! -Represents a point-offset pair. The point in the -pair lies in the original domain. -*/ -typedef std::pair< Point, Offset > Periodic_point; + /*! + Represents a point-offset pair. The point in the + pair lies in the original domain. + */ + typedef std::pair< Point, Offset > Periodic_point; -/*! -A pair of periodic points representing a segment in the periodic -domain. -*/ -typedef array< Periodic_point, 2> Periodic_segment; + /*! + A pair of periodic points representing a segment in the periodic + domain. + */ + typedef array< Periodic_point, 2> Periodic_segment; -/*! -A triple of periodic points representing a triangle in the periodic -domain. -*/ -typedef array< Periodic_point, 3> -Periodic_triangle; + /*! + A triple of periodic points representing a triangle in the periodic + domain. + */ + typedef array< Periodic_point, 3> + Periodic_triangle; -/*! -the vertex type. -*/ -typedef Tds::Vertex Vertex; + /*! + the vertex type. + */ + typedef Tds::Vertex Vertex; -/*! -the face type. -*/ -typedef Tds::Face Face; + /*! + the face type. + */ + typedef Tds::Face Face; -/*! -the edge type. -*/ -typedef Tds::Edge Edge; + /*! + the edge type. + */ + typedef Tds::Edge Edge; -/*! -Size type (an unsigned integral type) -*/ -typedef Tds::size_type size_type; + /*! + Size type (an unsigned integral type) + */ + typedef Tds::size_type size_type; -/*! -Difference type (a signed integral type) -*/ -typedef Tds::difference_type difference_type; + /*! + Difference type (a signed integral type) + */ + typedef Tds::difference_type difference_type; -/*! -\name Handles, Iterators and Circulators + /*! + \name Handles, Iterators and Circulators -The vertices and faces of the triangulations are accessed through -`handles`, `iterators` and `circulators`. The handles are alModels of -the concept `Handle` which basically offers the two dereference -operators and `->`. The iterators and circulators are all -bidirectional and non-mutable. The circulators and iterators are -convertible to handles with the same value type, so that whenever a -handle appear in the parameter list of a function, an appropriate -iterator or circulator can be passed as well. + The vertices and faces of the triangulations are accessed through + `handles`, `iterators` and `circulators`. The handles are alModels of + the concept `Handle` which basically offers the two dereference + operators and `->`. The iterators and circulators are all + bidirectional and non-mutable. The circulators and iterators are + convertible to handles with the same value type, so that whenever a + handle appear in the parameter list of a function, an appropriate + iterator or circulator can be passed as well. -The edges of the triangulation can also be visited through iterators -and circulators, the edge circulators and iterators are also -bidirectional and non-mutable. -*/ + The edges of the triangulation can also be visited through iterators + and circulators, the edge circulators and iterators are also + bidirectional and non-mutable. + */ /// @{ -/*! -handle to a vertex -*/ -typedef Tds::Vertex_handle Vertex_handle; + /*! + handle to a vertex + */ + typedef Tds::Vertex_handle Vertex_handle; -/*! -handle to a face -*/ -typedef Tds::Face_handle Face_handle; + /*! + handle to a face + */ + typedef Tds::Face_handle Face_handle; -/*! -iterator over all faces. -*/ -typedef Tds::Face_iterator Face_iterator; + /*! + iterator over all faces. + */ + typedef Tds::Face_iterator Face_iterator; -/*! -iterator over all edges -*/ -typedef Tds::Edge_iterator Edge_iterator; + /*! + iterator over all edges + */ + typedef Tds::Edge_iterator Edge_iterator; -/*! -iterator over all vertices -*/ -typedef Tds::Vertex_iterator Vertex_iterator; + /*! + iterator over all vertices + */ + typedef Tds::Vertex_iterator Vertex_iterator; -/*! -iterator over the vertices whose -corresponding points lie in the original domain, i.e. for each set -of periodic copies the `Unique_vertex_iterator` iterates over -exactly one representative. -*/ -typedef Hidden_type Unique_vertex_iterator; + /*! + iterator over the vertices whose + corresponding points lie in the original domain, i.e. for each set + of periodic copies the `Unique_vertex_iterator` iterates over + exactly one representative. + */ + typedef Hidden_type Unique_vertex_iterator; -/*! -\cgalAdvanced For compatibility with `Triangulation_2`. -*/ -typedef Face_iterator Finite_faces_iterator; + /*! + \cgalAdvanced For compatibility with `Triangulation_2`. + */ + typedef Face_iterator Finite_faces_iterator; -/*! -\cgalAdvanced For compatibility with `Triangulation_2`. -*/ -typedef Edge_iterator Finite_edges_iterator; + /*! + \cgalAdvanced For compatibility with `Triangulation_2`. + */ + typedef Edge_iterator Finite_edges_iterator; -/*! -\cgalAdvanced For compatibility with `Triangulation_2`. -*/ -typedef Vertex_iterator Finite_vertices_iterator; + /*! + \cgalAdvanced For compatibility with `Triangulation_2`. + */ + typedef Vertex_iterator Finite_vertices_iterator; -/*! -\cgalAdvanced For compatibility with `Triangulation_2`. -*/ -typedef Face_iterator All_faces_iterator; + /*! + \cgalAdvanced For compatibility with `Triangulation_2`. + */ + typedef Face_iterator All_faces_iterator; -/*! -circulator over all faces incident to a given vertex. -*/ -typedef Hidden_type Face_circulator; + /*! + circulator over all faces incident to a given vertex. + */ + typedef Hidden_type Face_circulator; -/*! -circulator over all edges incident to a given vertex. -*/ -typedef Hidden_type Edge_circulator; + /*! + circulator over all edges incident to a given vertex. + */ + typedef Hidden_type Edge_circulator; -/*! -circulator over all vertices adjacent to a given vertex. -*/ -typedef Hidden_type Vertex_circulator; + /*! + circulator over all vertices adjacent to a given vertex. + */ + typedef Hidden_type Vertex_circulator; -/// @} +/// @} -/// \name Geometric iterators: +/// \name Geometric iterators: /// @{ -/*! -iterator over the triangles -corresponding to faces of the triangulation. -*/ -typedef Hidden_type Periodic_triangle_iterator; + /*! + iterator over the triangles + corresponding to faces of the triangulation. + */ + typedef Hidden_type Periodic_triangle_iterator; -/*! -iterator over the segments -corresponding to edges of the triangulation. -*/ -typedef Hidden_type Periodic_segment_iterator; + /*! + iterator over the segments + corresponding to edges of the triangulation. + */ + typedef Hidden_type Periodic_segment_iterator; -/*! -iterator over the points -corresponding to vertices of the triangulation. -*/ -typedef Hidden_type Periodic_point_iterator; + /*! + iterator over the points + corresponding to vertices of the triangulation. + */ + typedef Hidden_type Periodic_point_iterator; -/// @} +/// @} -/// \name Creation +/// \name Creation /// @{ -/*! -Introduces an empty triangulation `t` with -`domain` as original domain. \pre `domain` is a square. -*/ -Triangulation_2(const Iso_rectangle & domain = -Iso_rectangle(0,0,1,1), const Geom_traits & traits = -Geom_traits()); + /*! + Introduces an empty triangulation `t` with + `domain` as original domain. \pre `domain` is a square. + */ + Triangulation_2(const Iso_rectangle & domain = + Iso_rectangle(0, 0, 1, 1), const Geom_traits & traits = + Geom_traits()); -/*! -Copy constructor. All the vertices and faces are duplicated. -After the copy, `this` and `tr` -refer to different triangulations: -if `tr` is modified, `this` is not. -*/ -Triangulation_2(const Triangulation_2& tr); + /*! + Copy constructor. All the vertices and faces are duplicated. + After the copy, `this` and `tr` + refer to different triangulations: + if `tr` is modified, `this` is not. + */ + Triangulation_2(const Triangulation_2& tr); -/*! -Assignment. All the vertices and faces are duplicated. -After the assignment, `this` and `tr` -refer to different triangulations: -if `tr` is modified, `this` is not. -*/ -Triangulation_2 operator=(const Triangulation_2& tr); + /*! + Assignment. All the vertices and faces are duplicated. + After the assignment, `this` and `tr` + refer to different triangulations: + if `tr` is modified, `this` is not. + */ + Triangulation_2 operator=(const Triangulation_2& tr); -/*! -The triangulations `tr` and `this` are swapped. -`t.swap(tr)` should be preferred to `this` = `tr` or to -`t(tr)` if `tr` is deleted after that. -*/ -void swap(Triangulation_2& tr); + /*! + The triangulations `tr` and `this` are swapped. + `t.swap(tr)` should be preferred to `this` = `tr` or to + `t(tr)` if `tr` is deleted after that. + */ + void swap(Triangulation_2& tr); -/*! -Deletes all faces and vertices -resulting in an empty triangulation. -*/ -void clear(); + /*! + Deletes all faces and vertices + resulting in an empty triangulation. + */ + void clear(); -/// @} +/// @} -/// \name Access Functions +/// \name Access Functions /// The responsibility of keeping a valid triangulation belongs to the /// user when using advanced operations allowing a direct manipulation /// of the `tds`. /// @{ -/*! -Returns a const reference to the triangulation traits object. -*/ -const Geom_traits& geom_traits() const; + /*! + Returns a const reference to the triangulation traits object. + */ + const Geom_traits& geom_traits() const; -/*! -Returns a const reference to the triangulation data structure. -*/ -const Triangulation_data_structure_2 & tds() const; + /*! + Returns a const reference to the triangulation data structure. + */ + const Triangulation_data_structure_2 & tds() const; -/*! -Returns the original domain. -*/ -Iso_rectangle domain() const; + /*! + Returns the original domain. + */ + Iso_rectangle domain() const; -/*! -Returns the number of sheets of the covering space the triangulation is -currently computed in. -*/ -Covering_sheets number_of_sheets() const; + /*! + Returns the number of sheets of the covering space the triangulation is + currently computed in. + */ + Covering_sheets number_of_sheets() const; -/*! -Returns the dimension of the convex hull. The dimension is zero if -the triangulation is empty and two otherwise. -*/ -int dimension() const; + /*! + Returns the dimension of the convex hull. The dimension is zero if + the triangulation is empty and two otherwise. + */ + int dimension() const; -/*! -Returns the number of vertices. Counts all vertices that are -representatives of the same point in \f$ \mathbb T_c^2\f$ as one vertex. -*/ -size_type number_of_vertices() const; + /*! + Returns the number of vertices. Counts all vertices that are + representatives of the same point in \f$ \mathbb T_c^2\f$ as one vertex. + */ + size_type number_of_vertices() const; -/*! -Returns the number of faces. Counts all faces that are -representatives of the same triangle in \f$ \mathbb T_c^2\f$ as one face. -*/ -size_type number_of_faces() const; + /*! + Returns the number of faces. Counts all faces that are + representatives of the same triangle in \f$ \mathbb T_c^2\f$ as one face. + */ + size_type number_of_faces() const; -/*! -Returns the number of vertices in the data structure. This is the -same as the number of sheets times `number_of_vertices()`. -*/ -size_type number_of_stored_vertices() const; + /*! + Returns the number of vertices in the data structure. This is the + same as the number of sheets times `number_of_vertices()`. + */ + size_type number_of_stored_vertices() const; -/*! -Returns the number of faces in the data structure. This is the -same as the number of sheets times `number_of_faces()`. -*/ -size_type number_of_stored_faces() const; + /*! + Returns the number of faces in the data structure. This is the + same as the number of sheets times `number_of_faces()`. + */ + size_type number_of_stored_faces() const; -/// @} +/// @} -/// \name Non const access +/// \name Non const access /// \cgalAdvanced This method is mainly a help for users implementing /// their own triangulation algorithms. /// @{ -/*! -Returns a reference to the triangulation data structure. -*/ -Triangulation_data_structure_2 & tds(); + /*! + Returns a reference to the triangulation data structure. + */ + Triangulation_data_structure_2 & tds(); -/// @} +/// @} -/// \name Non-constant-time access functions +/// \name Non-constant-time access functions /// @{ -/*! -Returns the number of edges. Counts all edges that are -representatives of the same segment in \f$ \mathbb T_c^2\f$ as one edge. -*/ -size_type number_of_edges() const; + /*! + Returns the number of edges. Counts all edges that are + representatives of the same segment in \f$ \mathbb T_c^2\f$ as one edge. + */ + size_type number_of_edges() const; -/*! -Returns the number of edges in the data structure. This is the same -as the number of sheets times `number_of_edges()`. -*/ -size_type number_of_stored_edges() const; + /*! + Returns the number of edges in the data structure. This is the same + as the number of sheets times `number_of_edges()`. + */ + size_type number_of_stored_edges() const; -/// @} +/// @} -/// \name Non-constant-time queries and conversions +/// \name Non-constant-time queries and conversions /// \cgalAdvanced It is not recommended to interfere with the built-in /// covering management. Especially a premature conversion to the /// 1-sheeted covering space might lead to problems when modifying the /// triangulation later. /// @{ -/*! -The current triangulation remains a triangulation in the 1-sheeted -covering space even after adding points if this method returns -`true`. This test relies on a heuristic, i.e. if it answers -`false` nothing is known. This test runs in constant-time when -not computing in the 1-sheeted covering space. (This test uses the length -of the longest edge in the triangulation as a -criterion \cite cgal:ct-c3pt-09.) -*/ -bool is_extensible_triangulation_in_1_sheet_h1() const; + /*! + The current triangulation remains a triangulation in the 1-sheeted + covering space even after adding points if this method returns + `true`. This test relies on a heuristic, i.e. if it answers + `false` nothing is known. This test runs in constant-time when + not computing in the 1-sheeted covering space. (This test uses the length + of the longest edge in the triangulation as a + criterion \cite cgal:ct-c3pt-09.) + */ + bool is_extensible_triangulation_in_1_sheet_h1() const; -/*! -The same as `is_extensible_triangulation_in_1_sheet_h1()` but with -a more precise heuristic, i.e. it might answer `true` in cases in which -`is_extensible_triangulation_in_1_sheet_h1()` would not. However, it is -much less time efficient when not computing in the 1-sheeted covering -space. (This test uses the diameter of the largest empty circle in the -input point set as a criterion \cite cgal:ct-c3pt-09.) -*/ -bool is_extensible_triangulation_in_1_sheet_h2() const; + /*! + The same as `is_extensible_triangulation_in_1_sheet_h1()` but with + a more precise heuristic, i.e. it might answer `true` in cases in which + `is_extensible_triangulation_in_1_sheet_h1()` would not. However, it is + much less time efficient when not computing in the 1-sheeted covering + space. (This test uses the diameter of the largest empty circle in the + input point set as a criterion \cite cgal:ct-c3pt-09.) + */ + bool is_extensible_triangulation_in_1_sheet_h2() const; -/*! -Returns `true` if the current triangulation would still be a -triangulation in the 1-sheeted covering space, returns `false` otherwise. -*/ -bool is_triangulation_in_1_sheet() const; + /*! + Returns `true` if the current triangulation would still be a + triangulation in the 1-sheeted covering space, returns `false` otherwise. + */ + bool is_triangulation_in_1_sheet() const; -/*! -Converts the current triangulation into the same periodic -triangulation in the 1-sheeted covering space. -\pre `is_triangulation_in_1_sheet()` + /*! + Converts the current triangulation into the same periodic + triangulation in the 1-sheeted covering space. + \pre `is_triangulation_in_1_sheet()` -*/ -void convert_to_1_sheeted_covering(); + */ + void convert_to_1_sheeted_covering(); -/*! -Converts the current triangulation into the same periodic -triangulation in the 9-sheeted covering space. -*/ -void convert_to_9_sheeted_covering(); + /*! + Converts the current triangulation into the same periodic + triangulation in the 9-sheeted covering space. + */ + void convert_to_9_sheeted_covering(); -/// @} +/// @} -/// \name Geometric access functions +/// \name Geometric access functions /// @{ -/*! -Returns the periodic point given by vertex `v`. If `this` is -represented in the 1-sheeted covering space, the offset is always -zero. Otherwise `v` can correspond to a periodic copy outside the -`domain` of an input point. -*/ -Periodic_point periodic_point(const Vertex_handle v) const; + /*! + Returns the periodic point given by vertex `v`. If `this` is + represented in the 1-sheeted covering space, the offset is always + zero. Otherwise `v` can correspond to a periodic copy outside the + `domain` of an input point. + */ + Periodic_point periodic_point(const Vertex_handle v) const; -/*! -If `this` is represented in the 1-sheeted covering space, this -function returns the periodic point given by the \f$ i\f$-th vertex of -face `f`, that is the point in the original domain and the -offset of the vertex in `f`. If `this` is represented in the -9-sheeted covering space, this offset is possibly added to another -offset determining the periodic copy. \pre \f$ i \in\{0,1,2\}\f$ -*/ -Periodic_point periodic_point(const Face_handle f, int i) -const; + /*! + If `this` is represented in the 1-sheeted covering space, this + function returns the periodic point given by the \f$ i\f$-th vertex of + face `f`, that is the point in the original domain and the + offset of the vertex in `f`. If `this` is represented in the + 9-sheeted covering space, this offset is possibly added to another + offset determining the periodic copy. \pre \f$ i \in\{0,1,2\}\f$ + */ + Periodic_point periodic_point(const Face_handle f, int i) + const; -/*! -Returns the periodic segment formed by the two point-offset pairs -corresponding to the two vertices of edge `(f,i)`. -\pre \f$ i \in\{0,1,2\}\f$ -*/ -Periodic_segment periodic_segment(const Face_handle f, int -i) const; + /*! + Returns the periodic segment formed by the two point-offset pairs + corresponding to the two vertices of edge `(f,i)`. + \pre \f$ i \in\{0,1,2\}\f$ + */ + Periodic_segment periodic_segment(const Face_handle f, int + i) const; -/*! -Same as the previous method for edge `e`. -*/ -Periodic_segment periodic_segment(const Edge & e) const; + /*! + Same as the previous method for edge `e`. + */ + Periodic_segment periodic_segment(const Edge & e) const; -/*! -Returns the periodic triangle formed by the three point-offset pairs -corresponding to the three vertices of facet `f`. -*/ -Periodic_triangle periodic_triangle(const Face_handle f) const; + /*! + Returns the periodic triangle formed by the three point-offset pairs + corresponding to the three vertices of facet `f`. + */ + Periodic_triangle periodic_triangle(const Face_handle f) const; /// @} @@ -557,160 +561,160 @@ Periodic_triangle periodic_triangle(const Face_handle f) const; /// only exact predicates). /// @{ -/*! -Converts the `Periodic_point` `pp` (point-offset pair) to the -corresponding `Point` in \f$ \mathbb R^3\f$. -*/ -Point point(const Periodic_point & pp ) const; + /*! + Converts the `Periodic_point` `pp` (point-offset pair) to the + corresponding `Point` in \f$ \mathbb R^3\f$. + */ + Point point(const Periodic_point & pp ) const; -/*! -Converts the `Periodic_segment` `s` to a `Segment`. -*/ -Segment segment(const Periodic_segment & s) const; + /*! + Converts the `Periodic_segment` `s` to a `Segment`. + */ + Segment segment(const Periodic_segment & s) const; -/*! -Converts the `Periodic_triangle` `this` to a `Triangle`. -*/ -Triangle triangle(const Periodic_triangle & t) const; + /*! + Converts the `Periodic_triangle` `this` to a `Triangle`. + */ + Triangle triangle(const Periodic_triangle & t) const; -/*! -Compute the circumcenter of the face pointed to by f. This function -is available only if the corresponding function is provided in the -geometric traits. -*/ -Point circumcenter(Face_handle f) const; + /*! + Compute the circumcenter of the face pointed to by f. This function + is available only if the corresponding function is provided in the + geometric traits. + */ + Point circumcenter(Face_handle f) const; -/*! -Equivalent to -the call `t.segment(t.periodic_segment(f,i));` -*/ -Segment segment(Face_handle f, int i) const; + /*! + Equivalent to + the call `t.segment(t.periodic_segment(f,i));` + */ + Segment segment(Face_handle f, int i) const; -/*! -Equivalent to the -call `t.segment(t.periodic_segment(e));` -*/ -Segment segment(const Edge& e) const; + /*! + Equivalent to the + call `t.segment(t.periodic_segment(e));` + */ + Segment segment(const Edge& e) const; -/*! -Equivalent to the call `t.segment(t.periodic_segment(ec->first, ec->second));` -*/ -Segment segment(const Edge_circulator& ec) const; + /*! + Equivalent to the call `t.segment(t.periodic_segment(ec->first, ec->second));` + */ + Segment segment(const Edge_circulator& ec) const; -/*! -Equivalent to the call `t.segment(t.periodic_segment(ei->first, ei->second));` -*/ -Segment -segment(const Edge_iterator& ei) const; + /*! + Equivalent to the call `t.segment(t.periodic_segment(ei->first, ei->second));` + */ + Segment + segment(const Edge_iterator& ei) const; -/*! -Equivalent to the call `t.triangle(t.periodic_triangle(f));` -*/ -Triangle triangle(Face_handle f) const; + /*! + Equivalent to the call `t.triangle(t.periodic_triangle(f));` + */ + Triangle triangle(Face_handle f) const; -/// @} +/// @} -/// \name Predicates +/// \name Predicates /// The class `Periodic_2_triangulation_2` provides methods to test /// the presence in the triangulation of a particular feature (edge or /// face). /// @{ -/*! -`true` if there is an edge having `va` and `vb` as -vertices. -*/ -bool is_edge(Vertex_handle va, Vertex_handle vb); + /*! + `true` if there is an edge having `va` and `vb` as + vertices. + */ + bool is_edge(Vertex_handle va, Vertex_handle vb); -/*! -as above. In addition, if `true` is returned, the edge with -vertices `va` and `vb` is the edge `e=(fr,i)` where -`fr` is a handle to the face incident to `e` and -on the right side of `e` oriented from `va` to `vb`. -*/ -bool is_edge(Vertex_handle va, Vertex_handle vb, Face_handle& fr, -int & i); + /*! + as above. In addition, if `true` is returned, the edge with + vertices `va` and `vb` is the edge `e=(fr,i)` where + `fr` is a handle to the face incident to `e` and + on the right side of `e` oriented from `va` to `vb`. + */ + bool is_edge(Vertex_handle va, Vertex_handle vb, Face_handle& fr, + int & i); -/*! -`true` if there is a face having `v1`, `v2` and `v3` -as vertices. -*/ -bool is_face(Vertex_handle v1, Vertex_handle v2, -Vertex_handle v3); + /*! + `true` if there is a face having `v1`, `v2` and `v3` + as vertices. + */ + bool is_face(Vertex_handle v1, Vertex_handle v2, + Vertex_handle v3); -/*! -as above. In addition, if `true` is returned, `fr` is a -handle to the face with `v1`, `v2` and `v3` as -vertices. -*/ -bool is_face(Vertex_handle v1, Vertex_handle v2, -Vertex_handle v3, Face_handle &fr); + /*! + as above. In addition, if `true` is returned, `fr` is a + handle to the face with `v1`, `v2` and `v3` as + vertices. + */ + bool is_face(Vertex_handle v1, Vertex_handle v2, + Vertex_handle v3, Face_handle &fr); -/// @} +/// @} -/// \name Queries +/// \name Queries /// The class `Periodic_2_triangulation_2` provides methods to locate /// a given point with respect to a triangulation. It also provides /// methods to locate a point with respect to a given face of the /// triangulation. /// @{ -/*! -If the triangulation is not empty, a face -that contains the query in its interior or on its -boundary is returned. + /*! + If the triangulation is not empty, a face + that contains the query in its interior or on its + boundary is returned. -If the triangulation is empty, the default constructed `Face_handle` is returned. + If the triangulation is empty, the default constructed `Face_handle` is returned. -*/ -Face_handle -locate(const Point& query, -Face_handle f = Face_handle()) const; + */ + Face_handle + locate(const Point& query, + Face_handle f = Face_handle()) const; -/*! -Same as above. Additionally, the parameters `lt` -and `li` -describe where the query point is located. -The variable `lt` is set to the locate type of the query. -If `lt==VERTEX` -the variable `li` -is set to the index of the vertex, and if `lt==EDGE` -`li` -is set to the index -of the vertex opposite to the -edge. -Be careful that `li` -has no meaning when the query type is `FACE` or when the -triangulation is \f$ 0\f$-dimensional. -*/ -Face_handle -locate(const Point& query, -Locate_type& lt, -int& li, -Face_handle h =Face_handle() ) const; + /*! + Same as above. Additionally, the parameters `lt` + and `li` + describe where the query point is located. + The variable `lt` is set to the locate type of the query. + If `lt==VERTEX` + the variable `li` + is set to the index of the vertex, and if `lt==EDGE` + `li` + is set to the index + of the vertex opposite to the + edge. + Be careful that `li` + has no meaning when the query type is `FACE` or when the + triangulation is \f$ 0\f$-dimensional. + */ + Face_handle + locate(const Point& query, + Locate_type& lt, + int& li, + Face_handle h = Face_handle() ) const; -/*! -Returns on which side of the oriented boundary of `f` -the point `p` lies. -*/ -Oriented_side -oriented_side(Face_handle f, -const Point& p) const; + /*! + Returns on which side of the oriented boundary of `f` + the point `p` lies. + */ + Oriented_side + oriented_side(Face_handle f, + const Point& p) const; -/*! -Returns on which side of the circumcircle of face `f` lies -the point `p`. The circle is assumed to be counterclockwise -oriented, so its positive -side correspond to its bounded side. -This predicate is available only if the corresponding predicates on -points is provided in the geometric traits class. -*/ -Oriented_side -side_of_oriented_circle(Face_handle f, const Point & p); + /*! + Returns on which side of the circumcircle of face `f` lies + the point `p`. The circle is assumed to be counterclockwise + oriented, so its positive + side correspond to its bounded side. + This predicate is available only if the corresponding predicates on + points is provided in the geometric traits class. + */ + Oriented_side + side_of_oriented_circle(Face_handle f, const Point & p); -/// @} +/// @} -/// \name Face, Edge and Vertex Iterators +/// \name Face, Edge and Vertex Iterators /// The following iterators allow the user to visit faces, edges and /// vertices of the stored triangulation, i.e. in case of computing in /// a multiply sheeted covering space all stored periodic copies of @@ -720,40 +724,40 @@ side_of_oriented_circle(Face_handle f, const Point & p); /// triangulation. /// @{ -/*! -Starts at an arbitrary vertex -*/ -Vertices_iterator vertices_begin() const; + /*! + Starts at an arbitrary vertex + */ + Vertices_iterator vertices_begin() const; -/*! -Past-the-end iterator -*/ -Vertices_iterator vertices_end() const; + /*! + Past-the-end iterator + */ + Vertices_iterator vertices_end() const; -/*! -Starts at an arbitrary edge -*/ -Edges_iterator edges_begin() const; + /*! + Starts at an arbitrary edge + */ + Edges_iterator edges_begin() const; -/*! -Past-the-end iterator -*/ -Edges_iterator edges_end() const; + /*! + Past-the-end iterator + */ + Edges_iterator edges_end() const; -/*! -Starts at an arbitrary face -*/ -Faces_iterator faces_begin() const; + /*! + Starts at an arbitrary face + */ + Faces_iterator faces_begin() const; -/*! -Past-the-end iterator -*/ -Faces_iterator faces_end() -const; + /*! + Past-the-end iterator + */ + Faces_iterator faces_end() + const; -/// @} +/// @} -/// \name Geometric iterators +/// \name Geometric iterators /// The following iterators allow the user to obtain geometric /// primitives corresponding to faces, edges, and vertices of the /// triangulation. These iterators are non-mutable, bidirectional and @@ -778,57 +782,57 @@ const; /// result. /// @{ -/*! -Iterates over the points of the triangulation. Its behavior is -defined by the `Iterator_type` `it` as described on -\ref ::CGAL::Periodic_2_triangulation_2::Iterator_type. -*/ -Periodic_point_iterator periodic_points_begin(Iterator_type it = -STORED) const; + /*! + Iterates over the points of the triangulation. Its behavior is + defined by the `Iterator_type` `it` as described on + \ref ::CGAL::Periodic_2_triangulation_2::Iterator_type. + */ + Periodic_point_iterator periodic_points_begin(Iterator_type it = + STORED) const; -/*! -Past-the-end iterator. Note that to match another -`Periodic_point_iterator` both must have the same -`Iterator_type` `it`. -*/ -Periodic_point_iterator periodic_points_end(Iterator_type it = -STORED) const; + /*! + Past-the-end iterator. Note that to match another + `Periodic_point_iterator` both must have the same + `Iterator_type` `it`. + */ + Periodic_point_iterator periodic_points_end(Iterator_type it = + STORED) const; -/*! -Iterates over the segments of the triangulation. Its behavior is -defined by the `Iterator_type` `it` as described on -\ref ::CGAL::Periodic_2_triangulation_2::Iterator_type. -*/ -Periodic_segment_iterator periodic_segments_begin(Iterator_type it = -STORED) const; + /*! + Iterates over the segments of the triangulation. Its behavior is + defined by the `Iterator_type` `it` as described on + \ref ::CGAL::Periodic_2_triangulation_2::Iterator_type. + */ + Periodic_segment_iterator periodic_segments_begin(Iterator_type it = + STORED) const; -/*! -Past-the-end iterator. Note that to match another -`Periodic_segment_iterator` both must have the same -`Iterator_type` `it`. -*/ -Periodic_segment_iterator periodic_segments_end(Iterator_type it = -STORED) const; + /*! + Past-the-end iterator. Note that to match another + `Periodic_segment_iterator` both must have the same + `Iterator_type` `it`. + */ + Periodic_segment_iterator periodic_segments_end(Iterator_type it = + STORED) const; -/*! -Iterates over the triangles of the triangulation. Its behavior is -defined by the `Iterator_type` `it` as described on -\ref ::CGAL::Periodic_2_triangulation_2::Iterator_type. -*/ -Periodic_triangle_iterator periodic_triangles_begin(Iterator_type it = -STORED) const; + /*! + Iterates over the triangles of the triangulation. Its behavior is + defined by the `Iterator_type` `it` as described on + \ref ::CGAL::Periodic_2_triangulation_2::Iterator_type. + */ + Periodic_triangle_iterator periodic_triangles_begin(Iterator_type it = + STORED) const; -/*! -Past-the-end iterator. Note that to match another -`Periodic_triangle_iterator` both must have the same -`Iterator_type` `it`. -*/ -Periodic_triangle_iterator periodic_triangles_end(Iterator_type it = -STORED) const; + /*! + Past-the-end iterator. Note that to match another + `Periodic_triangle_iterator` both must have the same + `Iterator_type` `it`. + */ + Periodic_triangle_iterator periodic_triangles_end(Iterator_type it = + STORED) const; -/// @} +/// @} -/// \name Face, Edge and Vertex Circulators +/// \name Face, Edge and Vertex Circulators /// The triangulation also provides circulators that allows to visit /// respectively all faces or edges incident to a given vertex or all /// vertices adjacent to a given vertex. These circulators are @@ -840,130 +844,130 @@ STORED) const; /// faces incident to the edge pointed to. /// @{ -/*! -Starts at an arbitrary face incident -to `v`. -*/ -Face_circulator incident_faces(Vertex_handle v) const; + /*! + Starts at an arbitrary face incident + to `v`. + */ + Face_circulator incident_faces(Vertex_handle v) const; -/*! -Starts at face `f`. -\pre Face `f` is incident to vertex `v`. -*/ -Face_circulator incident_faces(Vertex_handle v, Face_handle f) const; + /*! + Starts at face `f`. + \pre Face `f` is incident to vertex `v`. + */ + Face_circulator incident_faces(Vertex_handle v, Face_handle f) const; -/*! -Starts at an arbitrary edge incident -to `v`. -*/ -Edge_circulator incident_edges(Vertex_handle v) const; + /*! + Starts at an arbitrary edge incident + to `v`. + */ + Edge_circulator incident_edges(Vertex_handle v) const; -/*! -Starts at the first edge of `f` incident to -`v`, in counterclockwise order around `v`. -\pre Face `f` is incident to vertex `v`. -*/ -Edge_circulator incident_edges(Vertex_handle v, Face_handle f) const; + /*! + Starts at the first edge of `f` incident to + `v`, in counterclockwise order around `v`. + \pre Face `f` is incident to vertex `v`. + */ + Edge_circulator incident_edges(Vertex_handle v, Face_handle f) const; -/*! -Starts at an arbitrary vertex adjacent to `v`. -*/ -Vertex_circulator adjacent_vertices(Vertex_handle v) const; + /*! + Starts at an arbitrary vertex adjacent to `v`. + */ + Vertex_circulator adjacent_vertices(Vertex_handle v) const; -/*! -Starts at the first vertex of `f` adjacent to `v` -in counterclockwise order around `v`. -\pre Face `f` is incident to vertex `v`. -*/ -Vertex_circulator adjacent_vertices(Vertex_handle v, Face_handle f) ; + /*! + Starts at the first vertex of `f` adjacent to `v` + in counterclockwise order around `v`. + \pre Face `f` is incident to vertex `v`. + */ + Vertex_circulator adjacent_vertices(Vertex_handle v, Face_handle f) ; -/// @} +/// @} -/// \name Traversal between adjacent faces +/// \name Traversal between adjacent faces /// @{ -/*! -returns the vertex of the \f$ i^{th}\f$ neighbor of `f` that is -opposite to `f`. -\pre $0 \\leqle i \\leqle 2$. -*/ -Vertex_handle mirror_vertex(Face_handle f, int i) const; + /*! + returns the vertex of the \f$ i^{th}\f$ neighbor of `f` that is + opposite to `f`. + \pre $0 \\leqle i \\leqle 2$. + */ + Vertex_handle mirror_vertex(Face_handle f, int i) const; -/*! -returns the index of `f` in its \f$ i^{th}\f$ neighbor. -\pre $0 \\leqle i \\leqle 2$. -*/ -int mirror_index(Face_handle f, int i) const; + /*! + returns the index of `f` in its \f$ i^{th}\f$ neighbor. + \pre $0 \\leqle i \\leqle 2$. + */ + int mirror_index(Face_handle f, int i) const; -/// @} +/// @} -/// \name Modifiers +/// \name Modifiers /// The following operations are guaranteed to lead to a valid /// triangulation when they are applied on a valid triangulation. /// @{ -/*! -Exchanges the edge -incident to `f` and `f->neighbor(i)` with the other diagonal -of the quadrilateral formed by `f` and -`f->neighbor(i)`. Flips all periodic copies of the edge when -the triangulation is on the 9-sheeted cover. -\pre The union of the faces `f` and `f->neighbor(i)` form a convex quadrilateral. -*/ -void flip(Face_handle f, int i); + /*! + Exchanges the edge + incident to `f` and `f->neighbor(i)` with the other diagonal + of the quadrilateral formed by `f` and + `f->neighbor(i)`. Flips all periodic copies of the edge when + the triangulation is on the 9-sheeted cover. + \pre The union of the faces `f` and `f->neighbor(i)` form a convex quadrilateral. + */ + void flip(Face_handle f, int i); -/*! -Inserts point `p` in the triangulation and returns the -corresponding vertex. -If point `p` coincides with an already -existing vertex, this vertex is returned and the triangulation -remains unchanged. -If point `p` is on an edge, the two -incident faces are split in two, see -Figure \ref Triangulation_ref_Fig_insert1. -If point `p` is -strictly inside a face of the triangulation, the face is split in -three, see Figure \ref Triangulation_ref_Fig_insert2. -If the -triangulation is empty, the triangulation with a single vertex at -point `p` is created. -The last argument `f` is an -indication to the underlying locate algorithm of where to start. -\pre `p` lies in the original domain. -*/ -Vertex_handle insert(const Point& p, Face_handle f = -Face_handle()); + /*! + Inserts point `p` in the triangulation and returns the + corresponding vertex. + If point `p` coincides with an already + existing vertex, this vertex is returned and the triangulation + remains unchanged. + If point `p` is on an edge, the two + incident faces are split in two, see + Figure \ref Triangulation_ref_Fig_insert1. + If point `p` is + strictly inside a face of the triangulation, the face is split in + three, see Figure \ref Triangulation_ref_Fig_insert2. + If the + triangulation is empty, the triangulation with a single vertex at + point `p` is created. + The last argument `f` is an + indication to the underlying locate algorithm of where to start. + \pre `p` lies in the original domain. + */ + Vertex_handle insert(const Point& p, Face_handle f = + Face_handle()); -/*! -Same as above except that the location -of the point `p` to be inserted is assumed to be given by -`(lt,loc,i)` (see the description of the `locate` method -above.) -*/ -Vertex_handle insert(const Point& p, Locate_type lt, -Face_handle loc, int li ); + /*! + Same as above except that the location + of the point `p` to be inserted is assumed to be given by + `(lt,loc,i)` (see the description of the `locate` method + above.) + */ + Vertex_handle insert(const Point& p, Locate_type lt, + Face_handle loc, int li ); -/*! -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 range -\f$ \left[\right.\f$`first`, `last`\f$ \left.\right)\f$. Returns the -number of inserted points. \pre The `value_type` of -`InputIterator` is `Point` and all points lie in the -original domain. -*/ -template < class InputIterator > int insert(InputIterator -first, InputIterator last); + /*! + Inserts the points in the range + \f$ \left[\right.\f$`first`, `last`\f$ \left.\right)\f$. Returns the + number of inserted points. \pre The `value_type` of + `InputIterator` is `Point` and all points lie in the + original domain. + */ + template < class InputIterator > int insert(InputIterator + first, InputIterator last); /// @} /// \name /// \anchor Triangulation_ref_Fig_insert1 -/// \image html insert1.gif "Insertion of a point on an edge." +/// \image html insert1.gif "Insertion of a point on an edge." /// \anchor Triangulation_ref_Fig_insert2 /// \image html insert2.gif "Insertion in a face." /// @{ @@ -972,7 +976,7 @@ first, InputIterator last); /// @} -/// \name +/// \name /// \cgalAdvanced The following member functions offer more specialized /// versions of the insertion or removal operations to be used when /// one knows to be in the corresponding case. The following functions @@ -981,102 +985,102 @@ first, InputIterator last); /// Delaunay triangulations to perform insertions. /// @{ -/*! -Inserts the first vertex. -*/ -Vertex_handle insert_first(const Point& p); + /*! + Inserts the first vertex. + */ + Vertex_handle insert_first(const Point& p); -/*! -Inserts vertex `v` in face -`f`. Face `f` is modified, -two new faces are created. If the triangulation contains periodic copies, a point is inserted in all periodic copies. -\pre The point in vertex `v` lies inside face `f`. -*/ -Vertex_handle insert_in_face(const Point& p, Face_handle f); + /*! + Inserts vertex `v` in face + `f`. Face `f` is modified, + two new faces are created. If the triangulation contains periodic copies, a point is inserted in all periodic copies. + \pre The point in vertex `v` lies inside face `f`. + */ + Vertex_handle insert_in_face(const Point& p, Face_handle f); -/*! -Inserts vertex v in edge `i` of `f`. If the triangulation contains periodic copies, a point is inserted in all periodic copies. -\pre The point in vertex `v` lies on the edge opposite to the vertex `i` of face `f`. -*/ -Vertex_handle insert_in_edge(const Point& p, const Offset &o, Face_handle f, int i); + /*! + Inserts vertex v in edge `i` of `f`. If the triangulation contains periodic copies, a point is inserted in all periodic copies. + \pre The point in vertex `v` lies on the edge opposite to the vertex `i` of face `f`. + */ + Vertex_handle insert_in_edge(const Point& p, const Offset &o, Face_handle f, int i); -/*! -Removes a vertex of degree three. Two of the incident faces are -destroyed, the third one is modified. \pre Vertex `v` is a vertex with degree three. -*/ -void remove_degree_3(Vertex_handle v); + /*! + Removes a vertex of degree three. Two of the incident faces are + destroyed, the third one is modified. \pre Vertex `v` is a vertex with degree three. + */ + void remove_degree_3(Vertex_handle v); -/*! -Removes the unique vertex in the -triangulation. -*/ -void -remove_first(Vertex_handle v); + /*! + Removes the unique vertex in the + triangulation. + */ + void + remove_first(Vertex_handle v); -/*! -creates a new vertex `v` and use it to star the hole -whose boundary is described by the sequence of edges `[edge_begin, edge_end]`. Returns a handle to the new vertex. + /*! + creates a new vertex `v` and use it to star the hole + whose boundary is described by the sequence of edges `[edge_begin, edge_end]`. Returns a handle to the new vertex. -\pre The triangulation is a triangulation of 1 sheet + \pre The triangulation is a triangulation of 1 sheet -*/ -template -Vertex_handle star_hole( Point p, -EdgeIt edge_begin, -EdgeIt edge_end); + */ + template + Vertex_handle star_hole( Point p, + EdgeIt edge_begin, + EdgeIt edge_end); -/*! -same as above, except that the algorithm -first recycles faces in the sequence `[face_begin, face_end]` -and create new ones only when the sequence is exhausted. + /*! + same as above, except that the algorithm + first recycles faces in the sequence `[face_begin, face_end]` + and create new ones only when the sequence is exhausted. -\pre The triangulation is a triangulation of 1 sheet -*/ -template -Vertex_handle star_hole( Point p, -EdgeIt edge_begin, -EdgeIt edge_end, -FaceIt face_begin, -FaceIt face_end); + \pre The triangulation is a triangulation of 1 sheet + */ + template + Vertex_handle star_hole( Point p, + EdgeIt edge_begin, + EdgeIt edge_end, + FaceIt face_begin, + FaceIt face_end); -/*! -\cgalAdvanced Changes the domain. Note that this function calls `clear()`, -i.e., it erases the existing triangulation. -*/ -void set_domain(const Iso_rectangle dom); + /*! + \cgalAdvanced Changes the domain. Note that this function calls `clear()`, + i.e., it erases the existing triangulation. + */ + void set_domain(const Iso_rectangle dom); -/// @} +/// @} -/// \name Miscellaneous +/// \name Miscellaneous /// @{ -/*! -Returns \f$ i+1\f$ modulo 3.\pre $0 \\leqle i \\leqle 2$. -*/ -int ccw(int i) const; + /*! + Returns \f$ i+1\f$ modulo 3.\pre $0 \\leqle i \\leqle 2$. + */ + int ccw(int i) const; -/*! -Returns \f$ i+2\f$ modulo 3.\pre $0 \\leqle i \\leqle 2$. -*/ -int cw(int i) const; + /*! + Returns \f$ i+2\f$ modulo 3.\pre $0 \\leqle i \\leqle 2$. + */ + int cw(int i) const; -/*! -Returns whether the -union of the faces `f` and `f->neighbor(i)` form a convex -quadrilateral. -*/ -void flippable(Face_handle f, int i); + /*! + Returns whether the + union of the faces `f` and `f->neighbor(i)` form a convex + quadrilateral. + */ + void flippable(Face_handle f, int i); -/*! -Returns the degree of the -vertex `v` -*/ -size_t degree(Vertex_handle v); + /*! + Returns the degree of the + vertex `v` + */ + size_t degree(Vertex_handle v); -/// @} +/// @} -/// \name Checking +/// \name Checking /// \cgalAdvanced The responsibility of keeping a valid triangulation /// belongs to the users if advanced operations are used. Obviously /// the advanced user, who implements higher levels operations may @@ -1084,34 +1088,34 @@ size_t degree(Vertex_handle v); /// method is provided to help the debugging. /// @{ -/*! -Checks the combinatorial validity of the triangulation and -also the validity of its geometric embedding. -This method is mainly a debugging help -for the users of advanced features. + /*! + Checks the combinatorial validity of the triangulation and + also the validity of its geometric embedding. + This method is mainly a debugging help + for the users of advanced features. -*/ -bool -is_valid(bool verbose = false, int level = 0) const; + */ + bool + is_valid(bool verbose = false, int level = 0) const; /// @} }; /* end Periodic_2_triangulation_2 */ -/*! -Writes the -triangulation `t` into the stream `os`. \pre The -output operator must be defined for `Point`. -\relates Periodic_2_triangulation_2 -*/ -ostream& operator<<(ostream& os, const Periodic_2_triangulation_2& t); +/*! +Writes the +triangulation `t` into the stream `os`. \pre The +output operator must be defined for `Point`. +\relates Periodic_2_triangulation_2 +*/ +ostream& operator<<(ostream& os, const Periodic_2_triangulation_2& t); -/*! -Reads a triangulation from stream -`is` and assigns it to `t`. \pre The input operator -must be defined for `Point`. -\relates Periodic_2_triangulation_2 -*/ -istream& operator>>(istream& is, Triangulation_2& t); +/*! +Reads a triangulation from stream +`is` and assigns it to `t`. \pre The input operator +must be defined for `Point`. +\relates Periodic_2_triangulation_2 +*/ +istream& operator>>(istream& is, Triangulation_2& t); } /* end namespace CGAL */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_face_base_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_face_base_2.h index c2a0bb9ea94..815ab7a89ff 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_face_base_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_face_base_2.h @@ -1,13 +1,14 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2MainClasses -The class `Periodic_2_triangulation_face_base_2` is a model of -the concept `Periodic_2TriangulationFaceBase_2` to be used by -`Triangulation_data_structure_2` to represent faces of a periodic -triangulation. +The class `Periodic_2_triangulation_face_base_2` is a model of +the concept `Periodic_2TriangulationFaceBase_2` to be used by +`Triangulation_data_structure_2` to represent faces of a periodic +triangulation. The first one `Traits` is the geometric traits, it is to be instantiated by a model of the concept @@ -15,26 +16,27 @@ instantiated by a model of the concept class to which the additional information for the periodic vertex is added and should be a model of `TriangulationDSFaceBase_2` -As faces cannot span more than one domain per direction of space in a -periodic Delaunay triangulation, it is enough to store offsets in the -range \f$ \{0,1\}^2\f$. For optimization purposes we encode all three -offsets in one integer. Each offset needs two bits (for the offset in -the \f$ x\f$- and \f$ y\f$-direction). If we number the bits from least -significant to most significant then bits \f$ 2*i\f$ and \f$ 2*i+1\f$ contain -the offset corresponding to vertex \f$ i\f$. +As faces cannot span more than one domain per direction of space in a +periodic Delaunay triangulation, it is enough to store offsets in the +range \f$ \{0,1\}^2\f$. For optimization purposes we encode all three +offsets in one integer. Each offset needs two bits (for the offset in +the \f$ x\f$- and \f$ y\f$-direction). If we number the bits from least +significant to most significant then bits \f$ 2*i\f$ and \f$ 2*i+1\f$ contain +the offset corresponding to vertex \f$ i\f$. -The implementation of `has_zero_offsets()` results in checking -whether all offsets are zero. +The implementation of `has_zero_offsets()` results in checking +whether all offsets are zero. -\cgalModels ::Periodic_2TriangulationFaceBase_2 +\cgalModels ::Periodic_2TriangulationFaceBase_2 -\sa `CGAL::Triangulation_face_base_2` -\sa `CGAL::Triangulation_face_base_with_info_2` -\sa `CGAL::Triangulation_face_base_with_circumcenter_2` +\sa `CGAL::Triangulation_face_base_2` +\sa `CGAL::Triangulation_face_base_with_info_2` +\sa `CGAL::Triangulation_face_base_with_circumcenter_2` */ template< > -class Periodic_2_triangulation_face_base_2 { +class Periodic_2_triangulation_face_base_2 +{ public: /// @} diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_hierarchy_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_hierarchy_2.h index 182e6131139..a9ad035646e 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_hierarchy_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_hierarchy_2.h @@ -1,64 +1,66 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2 -The class `Periodic_2_triangulation_hierarchy_2` implements a -triangulation augmented with a data structure which allows fast point -location queries. +The class `Periodic_2_triangulation_hierarchy_2` implements a +triangulation augmented with a data structure which allows fast point +location queries. ### Parameters ### -It is templated by a parameter which must be instantiated by one of the \cgal periodic triangulation classes. In the current -implementation, only `Periodic_2_Delaunay_triangulation_2` is -supported for `PTr`. +It is templated by a parameter which must be instantiated by one of the \cgal periodic triangulation classes. In the current +implementation, only `Periodic_2_Delaunay_triangulation_2` is +supported for `PTr`. -`PTr::Vertex` has to be a model of the concept -`Periodic_2TriangulationHierarchyVertexBase_2`. +`PTr::Vertex` has to be a model of the concept +`Periodic_2TriangulationHierarchyVertexBase_2`. -`PTr::Geom_traits` has to be a model of the concept -`Periodic_2DelaunayTriangulationTraits_2`. +`PTr::Geom_traits` has to be a model of the concept +`Periodic_2DelaunayTriangulationTraits_2`. ### Inherits From ### -`Periodic_2_triangulation_hierarchy_2` offers exactly the same functionalities as `PTr`. -Most of them (point location, insertion, removal \f$ \ldots\f$ ) are overloaded to -improve their efficiency by using the hierarchical structure. +`Periodic_2_triangulation_hierarchy_2` offers exactly the same functionalities as `PTr`. +Most of them (point location, insertion, removal \f$ \ldots\f$ ) are overloaded to +improve their efficiency by using the hierarchical structure. -Note that, since the algorithms that are provided are randomized, the -running time of constructing a triangulation with a hierarchy may be -improved when shuffling the data points. +Note that, since the algorithms that are provided are randomized, the +running time of constructing a triangulation with a hierarchy may be +improved when shuffling the data points. -However, the I/O operations are not overloaded. So, writing a -hierarchy into a file will lose the hierarchical structure and reading -it from the file will result in an ordinary triangulation whose -efficiency will be the same as `PTr`. +However, the I/O operations are not overloaded. So, writing a +hierarchy into a file will lose the hierarchical structure and reading +it from the file will result in an ordinary triangulation whose +efficiency will be the same as `PTr`. ### Implementation ### -The data structure is a hierarchy of triangulations. The triangulation -at the lowest level is the original triangulation where operations and -point location are to be performed. -Then at each succeeding level, the data structure -stores a triangulation of a small random sample of the vertices -of the triangulation at the preceding level. Point location -is done through a top-down nearest neighbor query. -The nearest neighbor query is first -performed naively in the top level triangulation. -Then, at each following level, the nearest neighbor at that level -is found through a randomized walk performed from -the nearest neighbor found at the preceding level. -Because the number of vertices in each triangulation is only a small -fraction of the number of vertices of the preceding triangulation -the data structure remains small and achieves fast point location -queries on real data. +The data structure is a hierarchy of triangulations. The triangulation +at the lowest level is the original triangulation where operations and +point location are to be performed. +Then at each succeeding level, the data structure +stores a triangulation of a small random sample of the vertices +of the triangulation at the preceding level. Point location +is done through a top-down nearest neighbor query. +The nearest neighbor query is first +performed naively in the top level triangulation. +Then, at each following level, the nearest neighbor at that level +is found through a randomized walk performed from +the nearest neighbor found at the preceding level. +Because the number of vertices in each triangulation is only a small +fraction of the number of vertices of the preceding triangulation +the data structure remains small and achieves fast point location +queries on real data. -\sa `CGAL::Periodic_2_triangulation_hierarchy_vertex_base_2` -\sa `CGAL::Periodic_2_Delaunay_triangulation_2` +\sa `CGAL::Periodic_2_triangulation_hierarchy_vertex_base_2` +\sa `CGAL::Periodic_2_Delaunay_triangulation_2` */ template< typename PTr > -class Periodic_2_triangulation_hierarchy_2 : public PTr { +class Periodic_2_triangulation_hierarchy_2 : public PTr +{ }; /* end Periodic_2_triangulation_hierarchy_2 */ } /* end namespace CGAL */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_traits_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_traits_2.h index 2a7d3f57446..92daf2ddf4e 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_traits_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_traits_2.h @@ -1,5 +1,6 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2TraitsClasses @@ -8,23 +9,24 @@ The class `Periodic_2_triangulation_traits_2` is designed as a default traits class for the class `Periodic_2_triangulation_2`. -The argument `Traits` must be a model of the -`TriangulationTraits_2` concept. The argument -`Periodic_2Offset_2` must be a model of the concept -`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`. +The argument `Traits` must be a model of the +`TriangulationTraits_2` concept. The argument +`Periodic_2Offset_2` must be a model of the concept +`Periodic_2Offset_2` and defaults to `Periodic_2_offset_2`. -Note that this template class is specialized for -`CGAL::Filtered_kernel`, so that it automatically provides filtered -predicates. This holds implicitly for -`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an -instantiation of `CGAL::Filtered_kernel`. +Note that this template class is specialized for +`CGAL::Filtered_kernel`, so that it automatically provides filtered +predicates. This holds implicitly for +`CGAL::Exact_predicates_inexact_constructions_kernel`, as it is an +instantiation of `CGAL::Filtered_kernel`. -\alModels `Periodic_2TriangulationTraits_2` and -\alModels `Periodic_2DelaunayTriangulationTraits_2` if the template parameter `Traits` is a model of the -`DelaunayTriangulationTraits_2` concept. +\alModels `Periodic_2TriangulationTraits_2` and +\alModels `Periodic_2DelaunayTriangulationTraits_2` if the template parameter `Traits` is a model of the +`DelaunayTriangulationTraits_2` concept. */ template< typename Traits, typename Periodic_2Offset_2 > -class Periodic_2_triangulation_traits_2 : public Traits { +class Periodic_2_triangulation_traits_2 : public Traits +{ }; /* end Periodic_2_triangulation_traits_2 */ } /* end namespace CGAL */ diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_vertex_base_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_vertex_base_2.h index d1f86a1fb67..825991a022e 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_vertex_base_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_vertex_base_2.h @@ -1,13 +1,14 @@ -namespace CGAL { +namespace CGAL +{ /*! \ingroup PkgPeriodic2Triangulation2MainClasses -The class `Periodic_2_triangulation_vertex_base_2` is a model -of the concept `Periodic_2TriangulationVertexBase_2` to be used by -`Triangulation_data_structure_2` to represent vertices of a -periodic triangulation. +The class `Periodic_2_triangulation_vertex_base_2` is a model +of the concept `Periodic_2TriangulationVertexBase_2` to be used by +`Triangulation_data_structure_2` to represent vertices of a +periodic triangulation. The first one `Traits` is the geometric traits, it is to be instantiated by a model of the concept @@ -18,13 +19,14 @@ added and should be a model of `TriangulationDSVertexBase_2` \cgalModels `Periodic_2TriangulationVertexBase_2` -\sa `CGAL::Periodic_2_triangulation_face_base_2` -\sa `CGAL::Triangulation_vertex_base_2` -\sa `CGAL::Triangulation_vertex_base_with_info_2` +\sa `CGAL::Periodic_2_triangulation_face_base_2` +\sa `CGAL::Triangulation_vertex_base_2` +\sa `CGAL::Triangulation_vertex_base_with_info_2` */ template< > -class Periodic_2_triangulation_vertex_base_2 { +class Periodic_2_triangulation_vertex_base_2 +{ public: /// @} diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2DelaunayTriangulationTraits_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2DelaunayTriangulationTraits_2.h index 20915935901..54271427402 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2DelaunayTriangulationTraits_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2DelaunayTriangulationTraits_2.h @@ -3,121 +3,122 @@ \ingroup PkgPeriodic2Triangulation2Concepts \cgalConcept -The concept `Periodic_2DelaunayTriangulationTraits_2` is the first template parameter of the class -`Periodic_2_Delaunay_triangulation_2`. It refines the concept -`Periodic_2TriangulationTraits_2` and -`DelaunayTriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the -geometric objects, predicates and constructions to work with -point-offset pairs. In most cases the offsets will be (0,0) and the -predicates from `DelaunayTriangulationTraits_2` can be used -directly. For efficiency reasons we maintain for each functor the -version without offsets. +The concept `Periodic_2DelaunayTriangulationTraits_2` is the first template parameter of the class +`Periodic_2_Delaunay_triangulation_2`. It refines the concept +`Periodic_2TriangulationTraits_2` and +`DelaunayTriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the +geometric objects, predicates and constructions to work with +point-offset pairs. In most cases the offsets will be (0,0) and the +predicates from `DelaunayTriangulationTraits_2` can be used +directly. For efficiency reasons we maintain for each functor the +version without offsets. -\cgalRefines ::DelaunayTriangulationTraits_2 and ::Periodic_2TriangulationTraits_2 +\cgalRefines ::DelaunayTriangulationTraits_2 and ::Periodic_2TriangulationTraits_2 -In addition to the requirements of the concept -::Periodic_2TriangulationTraits_2, the concept ::Periodic_2DelaunayTriangulationTraits_2 provides a predicate to check the empty circle property. The -corresponding predicate type is called type ::Periodic_2DelaunayTriangulationTraits_2::Side_of_oriented_circle_2. +In addition to the requirements of the concept +::Periodic_2TriangulationTraits_2, the concept ::Periodic_2DelaunayTriangulationTraits_2 provides a predicate to check the empty circle property. The +corresponding predicate type is called type ::Periodic_2DelaunayTriangulationTraits_2::Side_of_oriented_circle_2. -The additional constructor object ::Periodic_2DelaunayTriangulationTraits_2::Construct_circumcenter_2 is -used to build the dual Voronoi diagram and are required only if the -dual functions are called. The additional predicate type -::Periodic_2DelaunayTriangulationTraits_2::Compare_distance_2 is required if calls to -nearest_vertex(..) are issued. +The additional constructor object ::Periodic_2DelaunayTriangulationTraits_2::Construct_circumcenter_2 is +used to build the dual Voronoi diagram and are required only if the +dual functions are called. The additional predicate type +::Periodic_2DelaunayTriangulationTraits_2::Compare_distance_2 is required if calls to +nearest_vertex(..) are issued. \cgalHasModel `CGAL::Periodic_2_Delaunay_triangulation_traits_2` -\cgalHasModel `CGAL::Periodic_2_triangulation_traits_2`, which implements -additional the Delaunay predicates as well if the template parameter Traits is a model of `DelaunayTriangulationTraits_2`. +\cgalHasModel `CGAL::Periodic_2_triangulation_traits_2`, which implements +additional the Delaunay predicates as well if the template parameter Traits is a model of `DelaunayTriangulationTraits_2`. -\sa `DelaunayTriangulationTraits_2` +\sa `DelaunayTriangulationTraits_2` */ -class Periodic_2DelaunayTriangulationTraits_2 { +class Periodic_2DelaunayTriangulationTraits_2 +{ public: -/// \name Types +/// \name Types /// @{ -/*! -Predicate object. Must -provide the operators + /*! + Predicate object. Must + provide the operators -`Oriented_side operator()(Point p, Point q, Point r, Point s)` -which takes four points \f$ p, q, r, s\f$ as arguments and returns -`ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or, -`ON_ORIENTED_BOUNDARY` according to the position of points `s` -with respect to the oriented circle through through \f$ p,q\f$ -and \f$ r\f$ and + `Oriented_side operator()(Point p, Point q, Point r, Point s)` + which takes four points \f$ p, q, r, s\f$ as arguments and returns + `ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or, + `ON_ORIENTED_BOUNDARY` according to the position of points `s` + with respect to the oriented circle through through \f$ p,q\f$ + and \f$ r\f$ and -`Oriented_side operator()( Point p, Point q, Point r, Point s, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r, Periodic_2_offset_2 o_s)` -which takes four points \f$ (p, o_p), (q, o_q), (r, o_r), (s, o_s)\f$ as arguments and returns -`ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or, -`ON_ORIENTED_BOUNDARY` according to the position of points `(s, o_s)` -with respect to the oriented circle through through `(p, o_p), (q, o_q)` -and `(r, o_r)`. + `Oriented_side operator()( Point p, Point q, Point r, Point s, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r, Periodic_2_offset_2 o_s)` + which takes four points \f$ (p, o_p), (q, o_q), (r, o_r), (s, o_s)\f$ as arguments and returns + `ON_POSITIVE_SIDE`, `ON_NEGATIVE_SIDE` or, + `ON_ORIENTED_BOUNDARY` according to the position of points `(s, o_s)` + with respect to the oriented circle through through `(p, o_p), (q, o_q)` + and `(r, o_r)`. -This type is required only if the function -`side_of_oriented_circle(Face_handle f, Point p)` is called. -*/ -typedef Hidden_type Side_of_oriented_circle_2; + This type is required only if the function + `side_of_oriented_circle(Face_handle f, Point p)` is called. + */ + typedef Hidden_type Side_of_oriented_circle_2; -/*! -Constructor -object. Provides the operators: + /*! + Constructor + object. Provides the operators: -`Point operator()(Point p, Point q, Point r)` + `Point operator()(Point p, Point q, Point r)` -which returns -the circumcenter of the three points `p, q` and `r`. + which returns + the circumcenter of the three points `p, q` and `r`. -`Point operator()(Point p, Point q, Point r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)` + `Point operator()(Point p, Point q, Point r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)` -which returns the circumcenter of the three points `(p, o_p), (q, o_q)` and `(r, o_r)`. + which returns the circumcenter of the three points `(p, o_p), (q, o_q)` and `(r, o_r)`. -This type is required only if the function `Point circumcenter(Face_handle f)`is called. -*/ -typedef Hidden_type Construct_circumcenter_2; + This type is required only if the function `Point circumcenter(Face_handle f)`is called. + */ + typedef Hidden_type Construct_circumcenter_2; -/*! -Predicate type. Provides -the operators: + /*! + Predicate type. Provides + the operators: -`Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r)` -which returns `SMALLER`, `EQUAL` or `LARGER` according -to the distance between p and q being smaller, equal or larger than -the distance between p and r. + `Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r)` + which returns `SMALLER`, `EQUAL` or `LARGER` according + to the distance between p and q being smaller, equal or larger than + the distance between p and r. -`Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)` which returns `SMALLER`, `EQUAL` -or `LARGER` according to the distance between `(p, o_p)`, -and `(q, o_q)` being smaller, equal or larger than -the distance between `(p, o_p)` and `(r, o_r)`. + `Comparison_result operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q Periodic_2_offset_2 o_r)` which returns `SMALLER`, `EQUAL` + or `LARGER` according to the distance between `(p, o_p)`, + and `(q, o_q)` being smaller, equal or larger than + the distance between `(p, o_p)` and `(r, o_r)`. -This type is only require if -`nearest_vertex` queries are issued. -*/ -typedef Hidden_type Compare_distance_2; + This type is only require if + `nearest_vertex` queries are issued. + */ + typedef Hidden_type Compare_distance_2; -/// @} +/// @} -/// \name Predicate functions +/// \name Predicate functions /// @{ -/*! -Required only -if `side_of_oriented_circle` is called -called. -*/ -Side_of_oriented_circle_2 -side_of_oriented_circle_2_object(); + /*! + Required only + if `side_of_oriented_circle` is called + called. + */ + Side_of_oriented_circle_2 + side_of_oriented_circle_2_object(); -/*! -Required only if `circumcenter` is called. -*/ -Construct_circumcenter_2 construct_circumcenter_2_object(); + /*! + Required only if `circumcenter` is called. + */ + Construct_circumcenter_2 construct_circumcenter_2_object(); -/*! -Required only if `compare_distance` is called. -*/ -Compare_distance_2 compare_distance_2_object(); + /*! + Required only if `compare_distance` is called. + */ + Compare_distance_2 compare_distance_2_object(); /// @} diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2Offset_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2Offset_2.h index 46382cd91e8..bb1b75cdb9b 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2Offset_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2Offset_2.h @@ -3,125 +3,126 @@ \ingroup PkgPeriodic2Triangulation2Concepts \cgalConcept -The concept `Periodic_2Offset_2` describes a two-/dimensional integer vector with some specialized access functions and operations. +The concept `Periodic_2Offset_2` describes a two-/dimensional integer vector with some specialized access functions and operations. -\cgalHasModel CGAL::Periodic_2_offset_2 +\cgalHasModel CGAL::Periodic_2_offset_2 -\sa `Periodic_2TriangulationTraits_2` -\sa `Periodic_2DelaunayTriangulationTraits_2` +\sa `Periodic_2TriangulationTraits_2` +\sa `Periodic_2DelaunayTriangulationTraits_2` */ -class Periodic_2Offset_2 { +class Periodic_2Offset_2 +{ public: -/// \name Creation +/// \name Creation /// @{ -/*! -Default constructor. -*/ -Periodic_2Offset_2(); + /*! + Default constructor. + */ + Periodic_2Offset_2(); -/*! -Constructs the offset (x,y). -*/ -Periodic_2Offset_2(int x, int y); + /*! + Constructs the offset (x,y). + */ + Periodic_2Offset_2(int x, int y); -/// @} +/// @} -/// \name Operations +/// \name Operations /// @{ -/*! -Return the vector sum of `this` and `o`. -*/ -Periodic_2Offset_2 operator+(const Periodic_2Offset_2 & o) -const; + /*! + Return the vector sum of `this` and `o`. + */ + Periodic_2Offset_2 operator+(const Periodic_2Offset_2 & o) + const; -/*! -Return the vector difference of `this` and `o`. -*/ -Periodic_2Offset_2 operator-(const Periodic_2Offset_2 & o) -const; + /*! + Return the vector difference of `this` and `o`. + */ + Periodic_2Offset_2 operator-(const Periodic_2Offset_2 & o) + const; -/*! -Return the negative vector of `this`. -*/ -Periodic_2Offset_2 operator-() const; + /*! + Return the negative vector of `this`. + */ + Periodic_2Offset_2 operator-() const; -/*! -Add `o` to `this` using vector addition. -*/ -void operator+=(const Periodic_2Offset_2 & o) -const; + /*! + Add `o` to `this` using vector addition. + */ + void operator+=(const Periodic_2Offset_2 & o) + const; -/*! -Subtract `o` from `this` using vector subtraction. -*/ -void operator-=(const Periodic_2Offset_2 & o) -const; + /*! + Subtract `o` from `this` using vector subtraction. + */ + void operator-=(const Periodic_2Offset_2 & o) + const; -/*! -Return `true` if `o` and `this` represent the same vector. -*/ -bool operator==(const Periodic_2Offset_2 & o) const; + /*! + Return `true` if `o` and `this` represent the same vector. + */ + bool operator==(const Periodic_2Offset_2 & o) const; -/*! -Return `true` if `o` and `this` do not represent the same -vector. -*/ -bool operator!=(const Periodic_2Offset_2 & o) const; + /*! + Return `true` if `o` and `this` do not represent the same + vector. + */ + bool operator!=(const Periodic_2Offset_2 & o) const; -/*! -Compare `this` and `o` lexicographically. -*/ -bool operator<(const Periodic_2Offset_2 & o) const; + /*! + Compare `this` and `o` lexicographically. + */ + bool operator<(const Periodic_2Offset_2 & o) const; -/// @} +/// @} -/// \name Access Functions +/// \name Access Functions /// @{ -/*! -Return the \f$ i\f$-th entry of `this`. -\pre \f$ i\in\{0,1\}\f$ -*/ -int operator[](int i); + /*! + Return the \f$ i\f$-th entry of `this`. + \pre \f$ i\in\{0,1\}\f$ + */ + int operator[](int i); -/*! -Return the \f$ x\f$-entry of `this`. -*/ -int x() const; + /*! + Return the \f$ x\f$-entry of `this`. + */ + int x() const; -/*! -Return the \f$ y\f$-entry of `this`. -*/ -int y() const; + /*! + Return the \f$ y\f$-entry of `this`. + */ + int y() const; -/*! -Returns `true` if `this` is equal to (0,0). -*/ -bool is_null() const; + /*! + Returns `true` if `this` is equal to (0,0). + */ + bool is_null() const; -/*! -Returns `true` if `this` is equal to (0,0). -*/ -bool is_zero() const; + /*! + Returns `true` if `this` is equal to (0,0). + */ + bool is_zero() const; /// @} }; /* end Periodic_2Offset_2 */ -/*! -Inputs an offset from `is`. -\relates Periodic_2Offset_2 -*/ -istream& operator>>(istream & is, Periodic_2Offset_2 & off); +/*! +Inputs an offset from `is`. +\relates Periodic_2Offset_2 +*/ +istream& operator>>(istream & is, Periodic_2Offset_2 & off); -/*! -Outputs an offset from `os`. -\relates Periodic_2Offset_2 -*/ -ostream& operator<<(ostream & os, Periodic_2Offset_2 & off) const; +/*! +Outputs an offset from `os`. +\relates Periodic_2Offset_2 +*/ +ostream& operator<<(ostream & os, Periodic_2Offset_2 & off) const; diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationFaceBase_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationFaceBase_2.h index f70a509ab46..c08794702fc 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationFaceBase_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationFaceBase_2.h @@ -9,42 +9,43 @@ its four vertices and to its four neighbor faces. The vertices and neighbors are indexed 0, 1 and 2. Neighbor \f$ i\f$ lies opposite to vertex \f$ i\f$. -\cgalRefines ::TriangulationFaceBase_2 +\cgalRefines ::TriangulationFaceBase_2 -\cgalHasModel CGAL::Periodic_2_triangulation_face_base_2 +\cgalHasModel CGAL::Periodic_2_triangulation_face_base_2 -\sa `TriangulationDataStructure_2` -\sa `TriangulationFaceBase_2` -\sa `Periodic_2TriangulationVertexBase_2` +\sa `TriangulationDataStructure_2` +\sa `TriangulationFaceBase_2` +\sa `Periodic_2TriangulationVertexBase_2` */ -class Periodic_2TriangulationFaceBase_2 { +class Periodic_2TriangulationFaceBase_2 +{ public: -/// \name Access Functions +/// \name Access Functions /// @{ -/*! -Returns the offset of vertex `i`. -\pre \f$ i \in\{0, 1, 2\}\f$. -*/ -int offset(int i) const; + /*! + Returns the offset of vertex `i`. + \pre \f$ i \in\{0, 1, 2\}\f$. + */ + int offset(int i) const; -/*! -Returns true if the offset of vertex `i` is zero for \f$ i \in\{0, 1, 2\}\f$. -*/ -bool has_zero_offsets() const; + /*! + Returns true if the offset of vertex `i` is zero for \f$ i \in\{0, 1, 2\}\f$. + */ + bool has_zero_offsets() const; -/// @} +/// @} -/// \name Setting +/// \name Setting /// @{ -/*! -Sets the vertex offsets according to `off0` to `off2`. -*/ -void set_offsets(int off0, int off1, int off2); + /*! + Sets the vertex offsets according to `off0` to `off2`. + */ + void set_offsets(int off0, int off1, int off2); /// @} diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationTraits_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationTraits_2.h index f64e44dbb0a..28467e99709 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationTraits_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationTraits_2.h @@ -3,300 +3,301 @@ \ingroup PkgPeriodic2Triangulation2Concepts \cgalConcept -The concept `Periodic_2TriangulationTraits_2` is the first template parameter of the classes -`Periodic_2_triangulation_2`. This concept provides the types of -the geometric primitives used in the triangulation and some function -object types for the required predicates on those primitives. +The concept `Periodic_2TriangulationTraits_2` is the first template parameter of the classes +`Periodic_2_triangulation_2`. This concept provides the types of +the geometric primitives used in the triangulation and some function +object types for the required predicates on those primitives. -It refines the concept -`TriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the -geometric objects, predicates and constructions to work with -point-offset pairs. In most cases the offsets will be (0,0) and the -predicates from `TriangulationTraits_2` can be used -directly. For efficiency reasons we maintain for each functor the -version without offsets. +It refines the concept +`TriangulationTraits_2` from the \cgal \ref PkgTriangulation2 package. It redefines the +geometric objects, predicates and constructions to work with +point-offset pairs. In most cases the offsets will be (0,0) and the +predicates from `TriangulationTraits_2` can be used +directly. For efficiency reasons we maintain for each functor the +version without offsets. -\cgalRefines ::TriangulationTraits_2 -In addition to the requirements described for the traits class -::TriangulationTraits_2, the geometric traits class of a -Periodic triangulation must fulfill the following -requirements: +\cgalRefines ::TriangulationTraits_2 +In addition to the requirements described for the traits class +::TriangulationTraits_2, the geometric traits class of a +Periodic triangulation must fulfill the following +requirements: -\cgalHasModel CGAL::Periodic_2_triangulation_traits_2 +\cgalHasModel CGAL::Periodic_2_triangulation_traits_2 -\sa `TriangulationTraits_2` -\sa `CGAL::Periodic_2_triangulation_2` +\sa `TriangulationTraits_2` +\sa `CGAL::Periodic_2_triangulation_2` */ -class Periodic_2TriangulationTraits_2 { +class Periodic_2TriangulationTraits_2 +{ public: -/// \name Types +/// \name Types /// @{ -/*! -The point type. It must be a model of -`Kernel::Point_2`. -*/ -typedef Hidden_type Point_2; + /*! + The point type. It must be a model of + `Kernel::Point_2`. + */ + typedef Hidden_type Point_2; -/*! -The segment type. It must be a model -of `Kernel::Segment_2`. -*/ -typedef Hidden_type Segment_2; + /*! + The segment type. It must be a model + of `Kernel::Segment_2`. + */ + typedef Hidden_type Segment_2; -/*! -The vector type. It must be a model -of `Kernel::Vector_2`. -*/ -typedef Hidden_type Vector_2; + /*! + The vector type. It must be a model + of `Kernel::Vector_2`. + */ + typedef Hidden_type Vector_2; -/*! -The triangle type. It must be a -model of `Kernel::Triangle_2`. -*/ -typedef Hidden_type Triangle_2; + /*! + The triangle type. It must be a + model of `Kernel::Triangle_2`. + */ + typedef Hidden_type Triangle_2; -/*! -A type representing an -axis-aligned rectangle. It must be a model of -`Kernel::Iso_rectangle_2`. -*/ -typedef Hidden_type Iso_rectangle_2; + /*! + A type representing an + axis-aligned rectangle. It must be a model of + `Kernel::Iso_rectangle_2`. + */ + typedef Hidden_type Iso_rectangle_2; -/*! -The offset type. It must -be a model of the concept `Periodic_2Offset_2`. -*/ -typedef Hidden_type Periodic_2_offset_2; + /*! + The offset type. It must + be a model of the concept `Periodic_2Offset_2`. + */ + typedef Hidden_type Periodic_2_offset_2; -/// @} +/// @} -/// \name Predicate types +/// \name Predicate types /// @{ -/*! + /*! -A predicate object that must provide the function operators + A predicate object that must provide the function operators -`Comparison_result operator()(Point_2 p, Point_2 q)`, + `Comparison_result operator()(Point_2 p, Point_2 q)`, -which returns `EQUAL` if the \f$ x\f$-coordinates of the two points are equal and + which returns `EQUAL` if the \f$ x\f$-coordinates of the two points are equal and -`Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`, + `Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`, -which returns `EQUAL` if the \f$ x\f$-coordinates and \f$ x\f$-offsets of -the two point-offset pairs are equal. Otherwise it must return a -consistent order for any two points. \pre `p`, `q` lie inside the domain. -*/ -typedef Hidden_type Compare_x_2; + which returns `EQUAL` if the \f$ x\f$-coordinates and \f$ x\f$-offsets of + the two point-offset pairs are equal. Otherwise it must return a + consistent order for any two points. \pre `p`, `q` lie inside the domain. + */ + typedef Hidden_type Compare_x_2; -/*! + /*! -A predicate object that must provide the function operators + A predicate object that must provide the function operators -`Comparison_result operator()(Point_2 p, Point_2 q)`, + `Comparison_result operator()(Point_2 p, Point_2 q)`, -which returns `EQUAL` if the \f$ y\f$-coordinates of the two points are equal and + which returns `EQUAL` if the \f$ y\f$-coordinates of the two points are equal and -`Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`, + `Comparison_result operator()(Point_2 p, Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`, -which returns `EQUAL` if the \f$ y\f$-coordinates and \f$ y\f$-offsets of -the two point-offset pairs are equal. Otherwise it must return a -consistent order for any two points. \pre `p`, `q` lie inside the domain. -*/ -typedef Hidden_type Compare_y_2; + which returns `EQUAL` if the \f$ y\f$-coordinates and \f$ y\f$-offsets of + the two point-offset pairs are equal. Otherwise it must return a + consistent order for any two points. \pre `p`, `q` lie inside the domain. + */ + typedef Hidden_type Compare_y_2; -/*! + /*! -Predicate object. Provides the operators: + Predicate object. Provides the operators: -`bool operator()(Point p, Point q)` and + `bool operator()(Point p, Point q)` and -`bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)` + `bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)` -which returns `true` if `p` is before `q` -according to the \f$ x\f$-ordering of points. + which returns `true` if `p` is before `q` + according to the \f$ x\f$-ordering of points. -This predicate is only necessary if the insert function with a range -of points (using Hilbert sorting) is used. -*/ -typedef Hidden_type Less_x_2; + This predicate is only necessary if the insert function with a range + of points (using Hilbert sorting) is used. + */ + typedef Hidden_type Less_x_2; -/*! -Predicate object. Provides -the operators: + /*! + Predicate object. Provides + the operators: -`bool operator()(Point p, Point q)` and + `bool operator()(Point p, Point q)` and -`bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)` + `bool operator()(Point p, Point q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)` -which returns `true` if `p` is before `q` -according to the \f$ y\f$-ordering of points. + which returns `true` if `p` is before `q` + according to the \f$ y\f$-ordering of points. -This predicate is only necessary if the insert function with a range of -points (using Hilbert sorting) is used. + This predicate is only necessary if the insert function with a range of + points (using Hilbert sorting) is used. -*/ -typedef Hidden_type Less_y_2; + */ + typedef Hidden_type Less_y_2; -/*! -A predicate object that must provide the function operators + /*! + A predicate object that must provide the function operators -`Orientation operator()(Point_2 p, Point_2 q, Point_2 r)`, + `Orientation operator()(Point_2 p, Point_2 q, Point_2 r)`, -which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR` -depending on \f$ r\f$ being, with respect to the oriented line `pq`, -on the left side, on the right side or on the line. -and + which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR` + depending on \f$ r\f$ being, with respect to the oriented line `pq`, + on the left side, on the right side or on the line. + and -`Orientation operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`, + `Orientation operator()(Point_2 p, Point_2 q, Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`, -which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR` -depending on `(r,o_r)` being, with respect to the oriented line -defined by `(p,o_p)(q,o_q)` on the left side, on the right side -or on the line. -*/ -typedef Hidden_type Orientation_2; + which returns `LEFT_TURN`, `RIGHT_TURN` or `COLLINEAR` + depending on `(r,o_r)` being, with respect to the oriented line + defined by `(p,o_p)(q,o_q)` on the left side, on the right side + or on the line. + */ + typedef Hidden_type Orientation_2; -/// @} +/// @} -/// \name Constructor types: +/// \name Constructor types: /// Note that the traits must provide exact constructions in order to /// guarantee exactness of the following construction functors. /// @{ -/*! -A constructor object for -`Point_2`. Provides: + /*! + A constructor object for + `Point_2`. Provides: -`Point_2 operator()(Point_2 p,Periodic_2_offset_2 p_o)`, + `Point_2 operator()(Point_2 p,Periodic_2_offset_2 p_o)`, -which constructs a point from a point-offset pair. -\pre `p` lies inside the domain. + which constructs a point from a point-offset pair. + \pre `p` lies inside the domain. -*/ -typedef Hidden_type Construct_point_2; + */ + typedef Hidden_type Construct_point_2; -/*! -A constructor object for -`Segment_2`. Provides: + /*! + A constructor object for + `Segment_2`. Provides: -`Segment_2 operator()(Point_2 p,Point_2 q)`, + `Segment_2 operator()(Point_2 p,Point_2 q)`, -which constructs a segment from two points and + which constructs a segment from two points and -`Segment_2 operator()(Point_2 p,Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`, + `Segment_2 operator()(Point_2 p,Point_2 q, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q)`, -which constructs a segment from the points `(p,o_p)` and `(q,o_q)`. + which constructs a segment from the points `(p,o_p)` and `(q,o_q)`. -*/ -typedef Hidden_type Construct_segment_2; + */ + typedef Hidden_type Construct_segment_2; -/*! -A constructor object for -`Triangle_2`. Provides: + /*! + A constructor object for + `Triangle_2`. Provides: -`Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r )`, + `Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r )`, -which constructs a triangle from three points and + which constructs a triangle from three points and -`Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`, + `Triangle_2 operator()(Point_2 p,Point_2 q,Point_2 r, Periodic_2_offset_2 o_p, Periodic_2_offset_2 o_q, Periodic_2_offset_2 o_r)`, -which constructs a triangle from the three points `(p,o_p)`, -`(q,o_q)` and `(r,o_r)`. -*/ -typedef Hidden_type Construct_triangle_2; + which constructs a triangle from the three points `(p,o_p)`, + `(q,o_q)` and `(r,o_r)`. + */ + typedef Hidden_type Construct_triangle_2; -/// @} +/// @} -/// \name Creation +/// \name Creation /// Only a default constructor, copy constructor and an assignment /// operator are required. Note that further constructors can be /// provided. /// @{ -/*! -default constructor. -*/ -Periodic_2TriangulationTraits_2(); + /*! + default constructor. + */ + Periodic_2TriangulationTraits_2(); -/*! -Copy constructor -*/ -Periodic_2TriangulationTraits_2(Periodic_2TriangulationTraits_2 gtr); + /*! + Copy constructor + */ + Periodic_2TriangulationTraits_2(Periodic_2TriangulationTraits_2 gtr); -/*! -Assignment operator. -*/ -Periodic_2TriangulationTraits_2 operator=(Periodic_2TriangulationTraits_2 gtr); + /*! + Assignment operator. + */ + Periodic_2TriangulationTraits_2 operator=(Periodic_2TriangulationTraits_2 gtr); -/// @} +/// @} -/// \name Predicate functions +/// \name Predicate functions /// The following functions give access to the predicate and constructor objects. /// @{ -/*! + /*! -*/ -Compare_x_2 compare_x_2_object(); + */ + Compare_x_2 compare_x_2_object(); -/*! + /*! -*/ -Compare_y_2 compare_y_2_object(); + */ + Compare_y_2 compare_y_2_object(); -/*! + /*! -*/ -Less_x_2 less_x_2_object(); + */ + Less_x_2 less_x_2_object(); -/*! + /*! -*/ -Less_y_2 less_y_2_object(); + */ + Less_y_2 less_y_2_object(); -/*! + /*! -*/ -Orientation_2 orientation_2_object(); + */ + Orientation_2 orientation_2_object(); -/*! + /*! -*/ -Construct_point_2 construct_point_2_object(); + */ + Construct_point_2 construct_point_2_object(); -/*! + /*! -*/ -Construct_segment_2 construct_segment_2_object(); + */ + Construct_segment_2 construct_segment_2_object(); -/*! + /*! -*/ -Construct_triangle_2 construct_triangle_2_object(); + */ + Construct_triangle_2 construct_triangle_2_object(); -/// @} +/// @} -/// \name Access Functions +/// \name Access Functions /// @{ -/*! -Sets the -fundamental domain. This is necessary to evaluate predicates -correctly. -\pre `domain` represents a square. -*/ -void set_domain(Iso_rectangle_2 domain); + /*! + Sets the + fundamental domain. This is necessary to evaluate predicates + correctly. + \pre `domain` represents a square. + */ + void set_domain(Iso_rectangle_2 domain); -/*! -Returns the -fundamental domain. -*/ -Iso_rectangle_2 get_domain() const; + /*! + Returns the + fundamental domain. + */ + Iso_rectangle_2 get_domain() const; /// @} diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationVertexBase_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationVertexBase_2.h index 42c0ef46f92..253248b0f50 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationVertexBase_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/Concepts/Periodic_2TriangulationVertexBase_2.h @@ -3,7 +3,7 @@ \ingroup PkgPeriodic2Triangulation2Concepts \cgalConcept -A refinement of the concept `TriangulationVertexBase_2` +A refinement of the concept `TriangulationVertexBase_2` which adds an API for offset. At the base level of 2D-triangulations (see Section \ref @@ -12,54 +12,55 @@ to one of its incident faces through a handle. The storage of the offset is only needed when a triangulation is copied. -\cgalRefines `TriangulationVertexBase_2` +\cgalRefines `TriangulationVertexBase_2` - -\cgalHasModel CGAL::Periodic_2_triangulation_vertex_base_2 -\sa `TriangulationDataStructure_2` -\sa `TriangulationVertexBase_2` -\sa `Periodic_2TriangulationFaceBase_2` +\cgalHasModel CGAL::Periodic_2_triangulation_vertex_base_2 + +\sa `TriangulationDataStructure_2` +\sa `TriangulationVertexBase_2` +\sa `Periodic_2TriangulationFaceBase_2` */ -class Periodic_2TriangulationVertexBase_2 { +class Periodic_2TriangulationVertexBase_2 +{ public: -/// \name Types +/// \name Types /// @{ -/*! -A model of the concept -`Periodic_2Offset_2` -*/ -typedef Hidden_type Periodic_2_offset_2; + /*! + A model of the concept + `Periodic_2Offset_2` + */ + typedef Hidden_type Periodic_2_offset_2; -/// @} +/// @} -/// \name Access Functions +/// \name Access Functions /// @{ -/*! -Returns the offset stored in the vertex. -*/ -Periodic_2_offset_2 offset() const; + /*! + Returns the offset stored in the vertex. + */ + Periodic_2_offset_2 offset() const; -/*! -Returns `true` if the offset has been set, `false` otherwise. -*/ -bool get_offset_flag() const; + /*! + Returns `true` if the offset has been set, `false` otherwise. + */ + bool get_offset_flag() const; -/*! -Sets the offset and sets the offset flag to `true`. -*/ -void set_offset(Periodic_2_offset_2 o); + /*! + Sets the offset and sets the offset flag to `true`. + */ + void set_offset(Periodic_2_offset_2 o); -/*! -Sets the offset flag to `false` and clears the offset. -*/ -void clear_offset(); + /*! + Sets the offset flag to `false` and clears the offset. + */ + void clear_offset(); /// @} diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_adding_handles.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_adding_handles.cpp index 07ec4d7d576..308346bd9a0 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_adding_handles.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_adding_handles.cpp @@ -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::Other Vb2; typedef My_vertex_base Other; }; @@ -34,11 +35,11 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Periodic_2_triangulation_filtered_traits_2 GT; typedef CGAL::Periodic_2_triangulation_vertex_base_2 VbDS; -typedef My_vertex_base Vb; +typedef My_vertex_base Vb; typedef CGAL::Periodic_2_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; -typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT; +typedef CGAL::Periodic_2_Delaunay_triangulation_2 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; diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp index 7d9083537ac..13e9a7e0efc 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_colored_vertices.cpp @@ -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; diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_covering.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_covering.cpp index 96d82c91144..08b7ce64e60 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_covering.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_covering.cpp @@ -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: "< rnd(Point(0,0), Point(1,1)); + CGAL::Random_points_in_iso_rectangle_2 rnd(Point(0, 0), Point(1, 1)); // First, make sure the triangulation is 2D. - T.insert(Point(0,0)); - T.insert(Point(.1,0)); - T.insert(Point(0,.1)); + T.insert(Point(0, 0)); + T.insert(Point(.1, 0)); + T.insert(Point(0, .1)); // Gets the conflict region of 100 random points // in the Delaunay tetrahedralization - for (int i = 0; i != 100; ++i) { - Point p = (*rnd++); + for (int i = 0; i != 100; ++i) + { + Point p = (*rnd++); - // Locate the point - Delaunay::Locate_type lt; - int li; - Face_handle f = T.locate(p, lt, li); - if (lt == Delaunay::VERTEX) - continue; // Point already exists + // Locate the point + Delaunay::Locate_type lt; + int li; + Face_handle f = T.locate(p, lt, li); + if (lt == Delaunay::VERTEX) + continue; // Point already exists - // Get the cells that conflict with p in a vector V, - // and a facet on the boundary of this hole in f. - std::vector V; + // Get the cells that conflict with p in a vector V, + // and a facet on the boundary of this hole in f. + std::vector V; + + T.get_conflicts(p, + std::back_inserter(V), // Conflict cells in V + f); + } - T.get_conflicts(p, - std::back_inserter(V), // Conflict cells in V - f); - } - std::cout << "Final triangulation has " << T.number_of_vertices() << " vertices." << std::endl; diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_geometric_access.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_geometric_access.cpp index 5c23f4c9b5b..4baf8d9995a 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_geometric_access.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_geometric_access.cpp @@ -13,7 +13,8 @@ typedef P2DT2::Periodic_triangle Periodic_triangle; typedef P2DT2::Periodic_triangle_iterator Periodic_triangle_iterator; typedef P2DT2::Iterator_type Iterator_type; -int main() { +int main() +{ P2DT2 T; T.insert(Point(0, 0)); @@ -22,17 +23,19 @@ int main() { Periodic_triangle pt; Triangle t_bd; - + // Extracting the triangles that have a non-empty intersection with // the original domain of the 1-sheeted covering space for (Periodic_triangle_iterator ptit = T.periodic_triangles_begin(P2DT2::UNIQUE_COVER_DOMAIN); - ptit != T.periodic_triangles_end(P2DT2::UNIQUE_COVER_DOMAIN); ++ptit) { - pt = *ptit; - if (! (pt[0].second.is_null() && pt[1].second.is_null() && pt[2].second.is_null()) ) { - // Convert the current Periodic_triangle to a Triangle if it is - // not strictly contained inside the original domain. - // Note that this requires EXACT constructions to be exact! - t_bd = T.triangle(pt); + ptit != T.periodic_triangles_end(P2DT2::UNIQUE_COVER_DOMAIN); ++ptit) + { + pt = *ptit; + if (! (pt[0].second.is_null() && pt[1].second.is_null() && pt[2].second.is_null()) ) + { + // Convert the current Periodic_triangle to a Triangle if it is + // not strictly contained inside the original domain. + // Note that this requires EXACT constructions to be exact! + t_bd = T.triangle(pt); + } } - } } diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_hierarchy.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_hierarchy.cpp index 2d30581216c..32de30fed5b 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_hierarchy.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_hierarchy.cpp @@ -10,17 +10,17 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Triangulation_vertex_base_2 Vbb; typedef CGAL::Triangulation_hierarchy_vertex_base_2 Vb; typedef CGAL::Triangulation_face_base_2 Fb; -typedef CGAL::Triangulation_data_structure_2 Tds; -typedef CGAL::Delaunay_triangulation_2 Dt; +typedef CGAL::Triangulation_data_structure_2 Tds; +typedef CGAL::Delaunay_triangulation_2 Dt; typedef CGAL::Triangulation_hierarchy_2
Triangulation; typedef Triangulation::Point Point; -typedef CGAL::Creator_uniform_2 Creator; +typedef CGAL::Creator_uniform_2 Creator; int main( ) { std::cout << "insertion of 1000 random points" << std::endl; Triangulation t; - CGAL::Random_points_in_square_2 g(1.); + CGAL::Random_points_in_square_2 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 diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp index b46db689fb5..659ad936a58 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_pair_iterator_2.cpp @@ -8,32 +8,33 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Periodic_2_triangulation_traits_2 Gt; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Periodic_2_triangulation_face_base_2 Fb; -typedef CGAL::Triangulation_data_structure_2 Tds; +typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Periodic_2_Delaunay_triangulation_2 Delaunay; typedef Delaunay::Point Point; int main() { - std::vector< std::pair > 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 > points; + points.push_back( std::make_pair(Point(0.0, 0.0), 0) ); + points.push_back( std::make_pair(Point(0.1, 0.0), 1) ); + points.push_back( std::make_pair(Point(0.0, 0.1), 2) ); + points.push_back( std::make_pair(Point(0.1, 0.4), 3) ); + points.push_back( std::make_pair(Point(0.2, 0.2), 4) ); + points.push_back( std::make_pair(Point(0.4, 0.0), 5) ); Delaunay T; - T.insert( points.begin(),points.end() ); + T.insert( points.begin(), points.end() ); CGAL_assertion( T.number_of_vertices() == 6 ); // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ].first != vit->point() ){ - std::cerr << "Error different info" << std::endl; - exit(EXIT_FAILURE); - } + if( points[ vit->info() ].first != vit->point() ) + { + std::cerr << "Error different info" << std::endl; + exit(EXIT_FAILURE); + } std::cout << "OK" << std::endl; return 0; diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp index 2d4e3b02b53..ddedbfbf394 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_transform_iterator_2.cpp @@ -8,45 +8,48 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Periodic_2_triangulation_traits_2 Gt; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Periodic_2_triangulation_face_base_2 Fb; -typedef CGAL::Triangulation_data_structure_2 Tds; +typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Periodic_2_Delaunay_triangulation_2 Delaunay; typedef Delaunay::Point Point; //a functor that returns a std::pair. -//the unsigned integer is incremented at each call to +//the unsigned integer is incremented at each call to //operator() -struct Auto_count : public std::unary_function >{ +struct Auto_count : public std::unary_function > +{ mutable unsigned i; - Auto_count() : i(0){} - std::pair operator()(const Point& p) const { - return std::make_pair(p,i++); + Auto_count() : i(0) {} + std::pair operator()(const Point& p) const + { + return std::make_pair(p, i++); } }; int main() { std::vector points; - points.push_back( Point(0.0,0.0) ); - points.push_back( Point(0.1,0.0) ); - points.push_back( Point(0.0,0.1) ); - points.push_back( Point(0.1,0.4) ); - points.push_back( Point(0.2,0.2) ); - points.push_back( Point(0.4,0.0) ); + points.push_back( Point(0.0, 0.0) ); + points.push_back( Point(0.1, 0.0) ); + points.push_back( Point(0.0, 0.1) ); + points.push_back( Point(0.1, 0.4) ); + points.push_back( Point(0.2, 0.2) ); + points.push_back( Point(0.4, 0.0) ); Delaunay T; - T.insert( boost::make_transform_iterator(points.begin(),Auto_count()), + T.insert( boost::make_transform_iterator(points.begin(), Auto_count()), boost::make_transform_iterator(points.end(), Auto_count() ) ); CGAL_assertion( T.number_of_vertices() == 6 ); - + // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ] != vit->point() ){ - std::cerr << "Error different info" << std::endl; - exit(EXIT_FAILURE); - } + if( points[ vit->info() ] != vit->point() ) + { + std::cerr << "Error different info" << std::endl; + exit(EXIT_FAILURE); + } std::cout << "OK" << std::endl; - + return 0; } diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp index 3f51f0d4c49..2f1451c29bc 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_info_insert_with_zip_iterator_2.cpp @@ -8,7 +8,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Periodic_2_triangulation_traits_2 Gt; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Periodic_2_triangulation_face_base_2 Fb; -typedef CGAL::Triangulation_data_structure_2 Tds; +typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Periodic_2_Delaunay_triangulation_2 Delaunay; typedef Delaunay::Point Point; @@ -21,30 +21,31 @@ int main() indices.push_back(2); indices.push_back(3); indices.push_back(4); - indices.push_back(5); - + indices.push_back(5); + std::vector points; - points.push_back( Point(0.0,0.0) ); - points.push_back( Point(0.1,0.0) ); - points.push_back( Point(0.0,0.1) ); - points.push_back( Point(0.1,0.4) ); - points.push_back( Point(0.2,0.2) ); - points.push_back( Point(0.4,0.0) ); + points.push_back( Point(0.0, 0.0) ); + points.push_back( Point(0.1, 0.0) ); + points.push_back( Point(0.0, 0.1) ); + points.push_back( Point(0.1, 0.4) ); + points.push_back( Point(0.2, 0.2) ); + points.push_back( Point(0.4, 0.0) ); Delaunay T; - T.insert( boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), - boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) ); + T.insert( boost::make_zip_iterator(boost::make_tuple( points.begin(), indices.begin() )), + boost::make_zip_iterator(boost::make_tuple( points.end(), indices.end() ) ) ); CGAL_assertion( T.number_of_vertices() == 6 ); - - + + // check that the info was correctly set. Delaunay::Finite_vertices_iterator vit; for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit) - if( points[ vit->info() ] != vit->point() ){ - std::cerr << "Error different info" << std::endl; - exit(EXIT_FAILURE); - } + if( points[ vit->info() ] != vit->point() ) + { + std::cerr << "Error different info" << std::endl; + exit(EXIT_FAILURE); + } std::cout << "OK" << std::endl; return 0; diff --git a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_large_point_set.cpp b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_large_point_set.cpp index 5d3e44393e5..682a4c0dedf 100644 --- a/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_large_point_set.cpp +++ b/Periodic_2_triangulation_2/examples/Periodic_2_triangulation_2/p2t2_large_point_set.cpp @@ -29,33 +29,35 @@ int main() PDT PT1, PT2, PT3; // Generating n random points - for (int i=0 ; i < n ; i++) { - Point p = *in_square; - in_square++; - pts.push_back(Point(p.x()+.5, p.y()+.5)); - } + for (int i = 0 ; i < n ; i++) + { + Point p = *in_square; + in_square++; + pts.push_back(Point(p.x() + .5, p.y() + .5)); + } // Standard insertion t.start(); - for (int i=0 ; i < n ; i++) { - PT1.insert(pts[i]); - } + for (int i = 0 ; i < n ; i++) + { + PT1.insert(pts[i]); + } t.stop(); - std::cout<<" Time: "< 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 V(3); - V[0] = Point(0,0); - V[1] = Point(1,1); - V[2] = Point(-1,-1); + V[0] = Point(0, 0); + V[1] = Point(1, 1); + V[2] = Point(-1, -1); n = n + T.insert(V.begin(), V.end()); @@ -46,13 +46,13 @@ int main() Locate_type lt; int li; - Point p(0,0); + Point p(0, 0); Face_handle fh = T.locate(p, lt, li); // p is the vertex of c of index li : assert( lt == PDT::VERTEX ); assert( fh->vertex(li)->point() == p ); - Vertex_handle v = fh->vertex( (li+1)&3 ); + Vertex_handle v = fh->vertex( (li + 1) & 3 ); // v is another vertex of c Face_handle nb = fh->neighbor(li); // nb = neighbor of fh opposite to the vertex associated with p @@ -61,14 +61,14 @@ int main() assert( nb->has_vertex( v, nli ) ); // nli is the index of v in nc - std::ofstream oFileT("output.tri",std::ios::out); - // writing file output; - oFileT << T; + std::ofstream oFileT("output.tri", std::ios::out); + // writing file output; + oFileT << T; PDT T1; - std::ifstream iFileT("output.tri",std::ios::in); - // reading file output; - iFileT >> T1; + std::ifstream iFileT("output.tri", std::ios::in); + // reading file output; + iFileT >> T1; assert( T1.is_valid() ); assert( T1.number_of_vertices() == T.number_of_vertices() ); assert( T1.number_of_faces() == T.number_of_faces() ); diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_2.h index 5db4de269db..4be5d5486e5 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_2.h @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -32,37 +32,38 @@ #endif //CGAL_TRIANGULATION_2_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO -namespace CGAL { +namespace CGAL +{ template < - class Gt, - class Tds = Triangulation_data_structure_2< - Periodic_2_triangulation_vertex_base_2, - Periodic_2_triangulation_face_base_2 > > -class Periodic_2_Delaunay_triangulation_2 : public Periodic_2_triangulation_2 +class Gt, + class Tds = Triangulation_data_structure_2 < + Periodic_2_triangulation_vertex_base_2, + Periodic_2_triangulation_face_base_2 > > +class Periodic_2_Delaunay_triangulation_2 : public Periodic_2_triangulation_2 { - typedef Periodic_2_Delaunay_triangulation_2 Self; + typedef Periodic_2_Delaunay_triangulation_2 Self; public: - typedef Periodic_2_triangulation_2 Triangulation; - + typedef Periodic_2_triangulation_2 Triangulation; + public: typedef Tds Triangulation_data_structure; typedef Gt Geom_traits; - + typedef typename Gt::Periodic_2_offset_2 Offset; typedef typename Gt::Iso_rectangle_2 Iso_rectangle; typedef array Covering_sheets; - + typedef typename Gt::FT FT; typedef typename Gt::Point_2 Point; typedef typename Gt::Segment_2 Segment; typedef typename Gt::Triangle_2 Triangle; - - typedef std::pair Periodic_point; - typedef array< std::pair, 2> Periodic_segment; - typedef array< std::pair, 3> Periodic_triangle; - typedef array< std::pair, 4> Periodic_tetrahedron; - + + typedef std::pair Periodic_point; + typedef array< std::pair, 2> Periodic_segment; + typedef array< std::pair, 3> Periodic_triangle; + typedef array< std::pair, 4> Periodic_tetrahedron; + typedef typename Triangulation::size_type size_type; typedef typename Triangulation::Locate_type Locate_type; typedef typename Triangulation::Face_handle Face_handle; @@ -73,8 +74,8 @@ public: typedef typename Triangulation::Vertex_circulator Vertex_circulator; typedef typename Triangulation::Finite_edges_iterator Finite_edges_iterator; typedef typename Triangulation::Finite_faces_iterator Finite_faces_iterator; - typedef typename Triangulation::Finite_vertices_iterator - Finite_vertices_iterator; + typedef typename Triangulation::Finite_vertices_iterator + Finite_vertices_iterator; typedef typename Triangulation::All_faces_iterator All_faces_iterator; typedef typename Triangulation::Edge_iterator Edge_iterator; @@ -83,7 +84,7 @@ public: public: -#ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2 +#ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2 using Triangulation::empty; using Triangulation::cw; using Triangulation::ccw; @@ -114,35 +115,37 @@ public: /// \name Constructors // \{ /// Constructor - Periodic_2_Delaunay_triangulation_2(const Iso_rectangle & domain = Iso_rectangle(0,0,1,1), - const Gt& gt = Gt()) - : Periodic_2_triangulation_2(domain, gt) {} + Periodic_2_Delaunay_triangulation_2(const Iso_rectangle & domain = Iso_rectangle(0, 0, 1, 1), + const Gt& gt = Gt()) + : Periodic_2_triangulation_2(domain, gt) {} /// Copy constructor Periodic_2_Delaunay_triangulation_2( - const Periodic_2_Delaunay_triangulation_2 &tr) - : Periodic_2_triangulation_2(tr) { + const Periodic_2_Delaunay_triangulation_2 &tr) + : Periodic_2_triangulation_2(tr) + { CGAL_triangulation_postcondition( is_valid(true) ); } /// Constructor with insertion of points template < class InputIterator > Periodic_2_Delaunay_triangulation_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 Gt& gt = Gt()) - : Periodic_2_triangulation_2(domain, gt) { + : Periodic_2_triangulation_2(domain, gt) + { insert(first, last); } - + // \} /// \name Insertion-Removal // \{ - Vertex_handle insert(const Point &p, - Face_handle start = Face_handle() ); + Vertex_handle insert(const Point &p, + Face_handle start = Face_handle() ); Vertex_handle insert(const Point& p, - Locate_type lt, - Face_handle loc, int li ); + Locate_type lt, + Face_handle loc, int li ); /// Inserts a point in the triangulation. @@ -153,11 +156,11 @@ public: std::ptrdiff_t insert(InputIterator first, InputIterator last, bool is_large_point_set = true, - typename boost::enable_if< - boost::is_convertible< - typename std::iterator_traits::value_type, - Point - > >::type* = NULL) + typename boost::enable_if < + boost::is_convertible < + typename std::iterator_traits::value_type, + Point + > >::type* = NULL) #else template < class InputIterator > std::ptrdiff_t @@ -170,154 +173,191 @@ public: // The heuristic discards the existing triangulation so it can only be // applied to empty triangulations. - if (n!=0) is_large_point_set = false; + if (n != 0) is_large_point_set = false; std::set dummy_points; std::vector points(first, last); typename std::vector::iterator pbegin = points.begin(); - if (is_large_point_set) { - std::vector tmp_dummy_points = this->insert_dummy_points(); - std::copy(tmp_dummy_points.begin(), tmp_dummy_points.end(), - std::inserter(dummy_points, dummy_points.begin())); - } else { - std::random_shuffle (points.begin(), points.end()); - pbegin = points.begin(); + if (is_large_point_set) + { + std::vector tmp_dummy_points = this->insert_dummy_points(); + std::copy(tmp_dummy_points.begin(), tmp_dummy_points.end(), + std::inserter(dummy_points, dummy_points.begin())); + } + else + { + std::random_shuffle (points.begin(), points.end()); + pbegin = points.begin(); - // The empty triangulation is a 1-cover by definition, insert at least one point - insert(*pbegin); ++pbegin; - while (!is_1_cover()) { - if (pbegin == points.end()) - return number_of_vertices() - n; + // The empty triangulation is a 1-cover by definition, insert at least one point insert(*pbegin); ++pbegin; + while (!is_1_cover()) + { + if (pbegin == points.end()) + return number_of_vertices() - n; + insert(*pbegin); + ++pbegin; + } } - } CGAL_assertion(is_1_cover()); // Insert the points spatial_sort (pbegin, points.end(), geom_traits()); - Face_handle f; Locate_type lt; int li; + Face_handle f; + Locate_type lt; + int li; for (typename std::vector::const_iterator p = pbegin, end = points.end(); p != end; ++p) - { - f = locate(*p, lt, li, f); + { + f = locate(*p, lt, li, f); - if (lt == Triangulation::VERTEX) { - dummy_points.erase(f->vertex(li)); - } else { - insert(*p, lt, f, li); + if (lt == Triangulation::VERTEX) + { + dummy_points.erase(f->vertex(li)); + } + else + { + insert(*p, lt, f, li); + } } - } - if (is_large_point_set) { - for (typename std::set::const_iterator it = dummy_points.begin(); - it != dummy_points.end(); ++it) { - remove(*it); + if (is_large_point_set) + { + for (typename std::set::const_iterator it = dummy_points.begin(); + it != dummy_points.end(); ++it) + { + remove(*it); + } } - } return number_of_vertices() - n; } #ifndef CGAL_TRIANGULATION_2_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO -private: +private: //top stands for tuple-or-pair template - const Point& top_get_first(const std::pair& pair) const { return pair.first; } + const Point& top_get_first(const std::pair& pair) const + { + return pair.first; + } template - const Info& top_get_second(const std::pair& pair) const { return pair.second; } + const Info& top_get_second(const std::pair& pair) const + { + return pair.second; + } template - const Point& top_get_first(const boost::tuple& tuple) const { return boost::get<0>(tuple); } + const Point& top_get_first(const boost::tuple& tuple) const + { + return boost::get<0>(tuple); + } template - const Info& top_get_second(const boost::tuple& tuple) const { return boost::get<1>(tuple); } + const Info& top_get_second(const boost::tuple& tuple) const + { + return boost::get<1>(tuple); + } - template - std::ptrdiff_t insert_with_info(InputIterator first,InputIterator last, bool is_large_point_set) + template + std::ptrdiff_t insert_with_info(InputIterator first, InputIterator last, bool is_large_point_set) { if (first == last) return 0; std::vector indices; std::vector points; std::vector infos; - std::ptrdiff_t index=0; - for (InputIterator it=first;it!=last;++it){ - Tuple_or_pair value=*it; - points.push_back( top_get_first(value) ); - infos.push_back ( top_get_second(value) ); - indices.push_back(index++); - } + std::ptrdiff_t index = 0; + for (InputIterator it = first; it != last; ++it) + { + Tuple_or_pair value = *it; + points.push_back( top_get_first(value) ); + infos.push_back ( top_get_second(value) ); + indices.push_back(index++); + } + + typedef Spatial_sort_traits_adapter_2 Search_traits; - typedef Spatial_sort_traits_adapter_2 Search_traits; - size_type n = number_of_vertices(); // The heuristic discards the existing triangulation so it can only be // applied to empty triangulations. - if (n!=0) is_large_point_set = false; + if (n != 0) is_large_point_set = false; std::set dummy_points; typename std::vector::iterator pbegin = indices.begin(); - if (is_large_point_set) { - std::vector tmp_dummy_points = this->insert_dummy_points(); - std::copy(tmp_dummy_points.begin(), tmp_dummy_points.end(), - std::inserter(dummy_points, dummy_points.begin())); - } else { - std::random_shuffle(indices.begin(),indices.end()); - pbegin = indices.begin(); + if (is_large_point_set) + { + std::vector tmp_dummy_points = this->insert_dummy_points(); + std::copy(tmp_dummy_points.begin(), tmp_dummy_points.end(), + std::inserter(dummy_points, dummy_points.begin())); + } + else + { + std::random_shuffle(indices.begin(), indices.end()); + pbegin = indices.begin(); - Vertex_handle v_new; + Vertex_handle v_new; - // The empty triangulation is a 1-cover by definition, insert at least one point - v_new = insert(points[*pbegin]); - v_new->info() = infos[*pbegin]; - ++pbegin; - - while (!is_1_cover()) { - if (pbegin == indices.end()) - return number_of_vertices() - n; + // The empty triangulation is a 1-cover by definition, insert at least one point v_new = insert(points[*pbegin]); v_new->info() = infos[*pbegin]; ++pbegin; + + while (!is_1_cover()) + { + if (pbegin == indices.end()) + return number_of_vertices() - n; + v_new = insert(points[*pbegin]); + v_new->info() = infos[*pbegin]; + ++pbegin; + } } - } CGAL_assertion(is_1_cover()); // Insert the points - spatial_sort(indices.begin(),indices.end(),Search_traits(&(points[0]),geom_traits())); + spatial_sort(indices.begin(), indices.end(), Search_traits(&(points[0]), geom_traits())); - Face_handle f; Locate_type lt; int li; + Face_handle f; + Locate_type lt; + int li; Face_handle hint; for (typename std::vector::const_iterator it = pbegin, end = indices.end(); - it != end; ++it){ - f = locate(points[*it], lt, li, f); + it != end; ++it) + { + f = locate(points[*it], lt, li, f); - if (lt == Triangulation::VERTEX) { - // Always copy the info, it might be a dummy vertex - f->vertex(li)->info() = infos[*it]; - dummy_points.erase(f->vertex(li)); - } else { - Vertex_handle v_new = insert(points[*it], lt, f, li); - v_new->info() = infos[*it]; + if (lt == Triangulation::VERTEX) + { + // Always copy the info, it might be a dummy vertex + f->vertex(li)->info() = infos[*it]; + dummy_points.erase(f->vertex(li)); + } + else + { + Vertex_handle v_new = insert(points[*it], lt, f, li); + v_new->info() = infos[*it]; + } } - } - if (is_large_point_set) { - for (typename std::set::const_iterator it = dummy_points.begin(); - it != dummy_points.end(); ++it) { - remove(*it); + if (is_large_point_set) + { + for (typename std::set::const_iterator it = dummy_points.begin(); + it != dummy_points.end(); ++it) + { + remove(*it); + } } - } return number_of_vertices() - n; } - - + + public: template < class InputIterator > @@ -325,28 +365,28 @@ public: insert( InputIterator first, InputIterator last, bool is_large_point_set = true, - typename boost::enable_if< - boost::is_convertible< - typename std::iterator_traits::value_type, - std::pair::type> - > >::type* =NULL - ) + typename boost::enable_if < + boost::is_convertible < + typename std::iterator_traits::value_type, + std::pair::type> + > >::type* = NULL + ) { - return insert_with_info< std::pair::type> >(first,last, is_large_point_set); + return insert_with_info< std::pair::type> >(first, last, is_large_point_set); } - template + template std::ptrdiff_t - insert( boost::zip_iterator< boost::tuple > first, - boost::zip_iterator< boost::tuple > last, + insert( boost::zip_iterator< boost::tuple > first, + boost::zip_iterator< boost::tuple > last, bool is_large_point_set = true, - typename boost::enable_if< - boost::mpl::and_< - boost::is_convertible< typename std::iterator_traits::value_type, Point >, - boost::is_convertible< typename std::iterator_traits::value_type, typename internal::Info_check::type > - > >::type* =NULL) + typename boost::enable_if < + boost::mpl::and_ < + boost::is_convertible< typename std::iterator_traits::value_type, Point >, + boost::is_convertible< typename std::iterator_traits::value_type, typename internal::Info_check::type > + > >::type* = NULL) { - return insert_with_info< boost::tuple::type> >(first,last,is_large_point_set); + return insert_with_info< boost::tuple::type> >(first, last, is_large_point_set); } #endif //CGAL_TRIANGULATION_2_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO @@ -355,7 +395,7 @@ public: /// \name Displacement // \{ - + Vertex_handle move_if_no_collision(Vertex_handle v, const Point &p); Vertex_handle move_point(Vertex_handle v, const Point &p); // \} @@ -364,53 +404,57 @@ public: // \{ /// Returns the vertex closest to p, the point location will start from f Vertex_handle - nearest_vertex(const Point& p, Face_handle f= Face_handle()) const; + nearest_vertex(const Point& p, Face_handle f = Face_handle()) const; template - std::pair + std::pair get_conflicts_and_boundary(const Point &p, - OutputItFaces fit, - OutputItBoundaryEdges eit, - Face_handle start = Face_handle()) const { + OutputItFaces fit, + OutputItBoundaryEdges eit, + Face_handle start = Face_handle()) const + { CGAL_triangulation_precondition( dimension() == 2); int li; Locate_type lt; - Face_handle fh = locate(p,lt,li, start); - switch(lt) { - //case Triangulation::EMPTY: - case Triangulation::VERTEX: - return std::make_pair(fit,eit); - case Triangulation::FACE: - case Triangulation::EDGE: - case Triangulation::EMPTY: - *fit++ = fh; //put fh in OutputItFaces - std::pair pit = std::make_pair(fit,eit); - pit = propagate_conflicts(p,fh,0,pit); - pit = propagate_conflicts(p,fh,1,pit); - pit = propagate_conflicts(p,fh,2,pit); - return pit; - } + Face_handle fh = locate(p, lt, li, start); + switch(lt) + { + //case Triangulation::EMPTY: + case Triangulation::VERTEX: + return std::make_pair(fit, eit); + case Triangulation::FACE: + case Triangulation::EDGE: + case Triangulation::EMPTY: + *fit++ = fh; //put fh in OutputItFaces + std::pair pit = std::make_pair(fit, eit); + pit = propagate_conflicts(p, fh, 0, pit); + pit = propagate_conflicts(p, fh, 1, pit); + pit = propagate_conflicts(p, fh, 2, pit); + return pit; + } CGAL_triangulation_assertion(false); - return std::make_pair(fit,eit); + return std::make_pair(fit, eit); } template OutputItFaces get_conflicts (const Point &p, - OutputItFaces fit, - Face_handle start= Face_handle()) const { - std::pair pp = - get_conflicts_and_boundary(p,fit,Emptyset_iterator(),start); + OutputItFaces fit, + Face_handle start = Face_handle()) const + { + std::pair pp = + get_conflicts_and_boundary(p, fit, Emptyset_iterator(), start); return pp.first; } template OutputItBoundaryEdges get_boundary_of_conflicts(const Point &p, - OutputItBoundaryEdges eit, - Face_handle start= Face_handle()) const { + OutputItBoundaryEdges eit, + Face_handle start = Face_handle()) const + { std::pair pp = - get_conflicts_and_boundary(p,Emptyset_iterator(),eit,start); + get_conflicts_and_boundary(p, Emptyset_iterator(), eit, start); return pp.second; } // \} @@ -428,11 +472,13 @@ public: Segment dual(const Edge_iterator& ei) const; template < class Stream> - Stream& draw_dual(Stream & ps) { - Finite_edges_iterator eit= finite_edges_begin(); - for (; eit != finite_edges_end(); ++eit) { - ps << dual(eit); - } + Stream& draw_dual(Stream & ps) + { + Finite_edges_iterator eit = finite_edges_begin(); + for (; eit != finite_edges_end(); ++eit) + { + ps << dual(eit); + } return ps; } // \} @@ -452,10 +498,10 @@ private: inline void restore_Delaunay(Vertex_handle v); #ifndef CGAL_DT2_USE_RECURSIVE_PROPAGATING_FLIP - void non_recursive_propagating_flip(Face_handle f,int i); - void propagating_flip(const Face_handle& f,int i, int depth=0); + void non_recursive_propagating_flip(Face_handle f, int i); + void propagating_flip(const Face_handle& f, int i, int depth = 0); #else - void propagating_flip(const Face_handle& f,int i); + void propagating_flip(const Face_handle& f, int i); #endif void remove_2D(Vertex_handle v ); @@ -465,16 +511,16 @@ private: bool remove_single_vertex(Vertex_handle v, const Offset &v_o); void remove_degree_triangulate(Vertex_handle v, std::vector &f, std::vector &w, - std::vector &i,int d); + std::vector &i, int d); void remove_degree_triangulate(Vertex_handle v, std::vector &f, std::vector &w, std::vector &offset_w, - std::vector &i,int d); + std::vector &i, int d); void remove_degree_d(Vertex_handle v, std::vector &f, - std::vector &w, - std::vector &i,int d); + std::vector &w, + std::vector &i, int d); void remove_degree_d(Vertex_handle v, std::vector &f, std::vector &w, std::vector &offset_w, - std::vector &i,int d); + std::vector &i, int d); /// Assumes that all offsets are (0,0) void fill_hole_delaunay(std::list & hole); /// Fill hole over a periodic boundary @@ -488,10 +534,10 @@ private: std::vector &w, std::vector &o, std::vector &i); void remove_degree4(Vertex_handle v, std::vector &f, - std::vector &w, std::vector &o, + std::vector &w, std::vector &o, std::vector &i); void remove_degree4(Vertex_handle v, std::vector &f, - std::vector &w, + std::vector &w, std::vector &i); void remove_degree5(Vertex_handle v, std::vector &f, std::vector &w, @@ -500,133 +546,135 @@ private: std::vector &w, std::vector &o, std::vector &i); void remove_degree5_star (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&,Vertex_handle&,Vertex_handle&, - int ,int ,int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, Vertex_handle&, Vertex_handle&, + int , int , int , int , int ); void remove_degree5_star (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&,Vertex_handle&,Vertex_handle&, - Offset&,Offset&,Offset&,Offset&,Offset&, - int ,int ,int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, Vertex_handle&, Vertex_handle&, + Offset&, Offset&, Offset&, Offset&, Offset&, + int , int , int , int , int ); void remove_degree6(Vertex_handle v, std::vector &f, - std::vector &w, + std::vector &w, std::vector &i); void remove_degree6(Vertex_handle v, std::vector &f, - std::vector &w, std::vector &o, + std::vector &w, std::vector &o, std::vector &i); void remove_degree6_star (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - int ,int ,int , - int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + int , int , int , + int , int , int ); void remove_degree6_star (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Offset&,Offset&,Offset&, - Offset&,Offset&,Offset&, - int ,int ,int , - int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Offset&, Offset&, Offset&, + Offset&, Offset&, Offset&, + int , int , int , + int , int , int ); void remove_degree6_N (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - int ,int ,int , - int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + int , int , int , + int , int , int ); void remove_degree6_N (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Offset&,Offset&,Offset&, - Offset&,Offset&,Offset&, - int ,int ,int , - int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Offset&, Offset&, Offset&, + Offset&, Offset&, Offset&, + int , int , int , + int , int , int ); void remove_degree6_antiN (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - int ,int ,int , - int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + int , int , int , + int , int , int ); void remove_degree6_antiN (Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Offset&,Offset&,Offset&, - Offset&,Offset&,Offset&, - int ,int ,int , - int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Offset&, Offset&, Offset&, + Offset&, Offset&, Offset&, + int , int , int , + int , int , int ); void remove_degree6_diamond(Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - int ,int ,int , - int ,int ,int ); + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + int , int , int , + int , int , int ); void remove_degree6_diamond(Vertex_handle &v, - Face_handle & ,Face_handle & ,Face_handle & , - Face_handle & ,Face_handle & ,Face_handle & , - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Vertex_handle&,Vertex_handle&,Vertex_handle&, - Offset&,Offset&,Offset&, - Offset&,Offset&,Offset&, - int ,int ,int , - int ,int ,int ); - void remove_degree7(Vertex_handle v,std::vector &f, - std::vector &w, + Face_handle & , Face_handle & , Face_handle & , + Face_handle & , Face_handle & , Face_handle & , + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Vertex_handle&, Vertex_handle&, Vertex_handle&, + Offset&, Offset&, Offset&, + Offset&, Offset&, Offset&, + int , int , int , + int , int , int ); + void remove_degree7(Vertex_handle v, std::vector &f, + std::vector &w, std::vector &i); - void remove_degree7(Vertex_handle v,std::vector &f, - std::vector &w, std::vector &o, + void remove_degree7(Vertex_handle v, std::vector &f, + std::vector &w, std::vector &o, std::vector &i); void rotate7(int j, std::vector &w, - std::vector &f, + std::vector &f, std::vector &i); void rotate7(int j, std::vector &w, - std::vector &f, std::vector &o, + std::vector &f, std::vector &o, std::vector &i); /// Returns whether the simplicity criterion is satisfied void get_offset_degree7(std::vector &in_o, int out_o[]); - void remove_degree7_star (Vertex_handle&,int,std::vector &f, + void remove_degree7_star (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &i); - void remove_degree7_star (Vertex_handle&,int,std::vector &f, + void remove_degree7_star (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &o, std::vector &i); - void remove_degree7_zigzag (Vertex_handle&,int,std::vector &f, + void remove_degree7_zigzag (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &i); - void remove_degree7_zigzag (Vertex_handle&,int,std::vector &f, + void remove_degree7_zigzag (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &o, std::vector &i); - void remove_degree7_leftdelta (Vertex_handle&,int,std::vector &f, + void remove_degree7_leftdelta (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &i); - void remove_degree7_leftdelta (Vertex_handle&,int,std::vector &f, + void remove_degree7_leftdelta (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &o, std::vector &i); - void remove_degree7_rightdelta(Vertex_handle&,int,std::vector &f, + void remove_degree7_rightdelta(Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &i); - void remove_degree7_rightdelta(Vertex_handle&,int,std::vector &f, + void remove_degree7_rightdelta(Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &o, std::vector &i); - void remove_degree7_leftfan (Vertex_handle&,int,std::vector &f, + void remove_degree7_leftfan (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &i); - void remove_degree7_leftfan (Vertex_handle&,int,std::vector &f, + void remove_degree7_leftfan (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &o, std::vector &i); - void remove_degree7_rightfan (Vertex_handle&,int,std::vector &f, + void remove_degree7_rightfan (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &i); - void remove_degree7_rightfan (Vertex_handle&,int,std::vector &f, + void remove_degree7_rightfan (Vertex_handle&, int, std::vector &f, std::vector &w, std::vector &o, std::vector &i); bool incircle(int x, int j, int k, int l, std::vector &, - std::vector &w, std::vector &) { - + std::vector &w, std::vector &) + { + return side_of_oriented_circle(w[j]->point(), w[k]->point(), w[l]->point(), w[x]->point(), true) == ON_POSITIVE_SIDE; } bool incircle(int x, int j, int k, int l, std::vector &, - std::vector &w, std::vector &o, std::vector &) { - + std::vector &w, std::vector &o, std::vector &) + { + return side_of_oriented_circle(w[j]->point(), w[k]->point(), w[l]->point(), w[x]->point(), o[j], o[k], o[l], o[x], true) == ON_POSITIVE_SIDE; @@ -640,92 +688,103 @@ private: Vertex_handle nearest_vertex_2D(const Point& p, Face_handle f) const; void look_nearest_neighbor(const Point& p, - Face_handle f, - int i, - Vertex_handle& nn) const; + Face_handle f, + int i, + Vertex_handle& nn) const; template - std::pair + std::pair propagate_conflicts (const Point &p, - Face_handle fh, - int i, - std::pair - pit) const { + Face_handle fh, + int i, + std::pair + pit) const + { Face_handle fn = fh->neighbor(i); - if (! test_conflict(p,fn)) { - *(pit.second)++ = Edge(fn, fn->index(fh)); - } else { - *(pit.first)++ = fn; - int j = fn->index(fh); - pit = propagate_conflicts(p,fn,ccw(j),pit); - pit = propagate_conflicts(p,fn,cw(j), pit); - } + if (! test_conflict(p, fn)) + { + *(pit.second)++ = Edge(fn, fn->index(fh)); + } + else + { + *(pit.first)++ = fn; + int j = fn->index(fh); + pit = propagate_conflicts(p, fn, ccw(j), pit); + pit = propagate_conflicts(p, fn, cw(j), pit); + } return pit; } - bool test_conflict(const Point &p, Face_handle fh) const { + bool test_conflict(const Point &p, Face_handle fh) const + { return side_of_oriented_circle(fh, p, true) == ON_POSITIVE_SIDE; } }; template < class Gt, class Tds > bool -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: is_valid(bool verbose, int level) const { // Check the parent - bool result = Periodic_2_triangulation_2::is_valid(verbose, level); + bool result = Periodic_2_triangulation_2::is_valid(verbose, level); // Check in_sphere: - if (dimension()==2) { - const Point *p[4]; Offset off[4]; - for (Face_iterator fit = faces_begin(); - fit != this->faces_end(); ++fit) { - for (int i=0; i<3; i++) { - p[i] = &fit->vertex(i)->point(); - off[i] = get_offset(fit,i); - } + if (dimension() == 2) + { + const Point *p[4]; + Offset off[4]; + for (Face_iterator fit = faces_begin(); + fit != this->faces_end(); ++fit) + { + for (int i = 0; i < 3; i++) + { + p[i] = &fit->vertex(i)->point(); + off[i] = get_offset(fit, i); + } - /// Check whether the vertices of the neighbor lie outside the circumcircle of the face - for (int i=0; i<3; ++i) { - p[3] = &fit->vertex(i)->point(); - off[3] = combine_offsets(get_offset(fit,i), get_neighbor_offset(fit, i)); + /// Check whether the vertices of the neighbor lie outside the circumcircle of the face + for (int i = 0; i < 3; ++i) + { + p[3] = &fit->vertex(i)->point(); + off[3] = combine_offsets(get_offset(fit, i), get_neighbor_offset(fit, i)); - result &= ON_POSITIVE_SIDE != - side_of_oriented_circle(*p[0], *p[1], *p[2], *p[3], - off[0], off[1], off[2], off[3], - false); - CGAL_triangulation_assertion(result); - } + result &= ON_POSITIVE_SIDE != + side_of_oriented_circle(*p[0], *p[1], *p[2], *p[3], + off[0], off[1], off[2], off[3], + false); + CGAL_triangulation_assertion(result); + } + } } - } return result; } template < class Gt, class Tds > -typename Periodic_2_Delaunay_triangulation_2::Vertex_handle -Periodic_2_Delaunay_triangulation_2:: +typename Periodic_2_Delaunay_triangulation_2::Vertex_handle +Periodic_2_Delaunay_triangulation_2:: nearest_vertex(const Point &p, Face_handle f) const { - switch (dimension()) { - case 0: - return Vertex_handle(); - //break; - case 2: - return nearest_vertex_2D(p,f); - //break; - } + switch (dimension()) + { + case 0: + return Vertex_handle(); + //break; + case 2: + return nearest_vertex_2D(p, f); + //break; + } return Vertex_handle(); } template < class Gt, class Tds > -typename Periodic_2_Delaunay_triangulation_2::Vertex_handle -Periodic_2_Delaunay_triangulation_2:: +typename Periodic_2_Delaunay_triangulation_2::Vertex_handle +Periodic_2_Delaunay_triangulation_2:: nearest_vertex_2D(const Point& p, Face_handle f) const { CGAL_triangulation_precondition(dimension() == 2); - f = locate(p,f); + f = locate(p, f); typename Geom_traits::Compare_distance_2 compare_distance = geom_traits().compare_distance_2_object(); @@ -735,30 +794,30 @@ nearest_vertex_2D(const Point& p, Face_handle f) const if (compare_distance(p, f->vertex(2)->point(), nn->point()) == SMALLER) nn = f->vertex(2); - look_nearest_neighbor(p,f,0,nn); - look_nearest_neighbor(p,f,1,nn); - look_nearest_neighbor(p,f,2,nn); + look_nearest_neighbor(p, f, 0, nn); + look_nearest_neighbor(p, f, 1, nn); + look_nearest_neighbor(p, f, 2, nn); return nn; } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: look_nearest_neighbor(const Point& p, Face_handle f, - int i, - Vertex_handle& nn) const + int i, + Vertex_handle& nn) const { - Face_handle ni=f->neighbor(i); - if ( this->side_of_oriented_circle(ni,p,true) != ON_POSITIVE_SIDE ) + Face_handle ni = f->neighbor(i); + if ( this->side_of_oriented_circle(ni, p, true) != ON_POSITIVE_SIDE ) return; typename Geom_traits::Compare_distance_2 compare_distance = geom_traits().compare_distance_2_object(); i = ni->index(f); if (compare_distance(p, ni->vertex(i)->point(), nn->point()) == SMALLER) - nn=ni->vertex(i); + nn = ni->vertex(i); // recursive exploration of triangles whose circumcircle contains p look_nearest_neighbor(p, ni, ccw(i), nn); @@ -768,41 +827,42 @@ look_nearest_neighbor(const Point& p, //DUALITY template inline -typename Periodic_2_Delaunay_triangulation_2::Point -Periodic_2_Delaunay_triangulation_2:: +typename Periodic_2_Delaunay_triangulation_2::Point +Periodic_2_Delaunay_triangulation_2:: dual (Face_handle f) const { - CGAL_triangulation_precondition (dimension()==2); + CGAL_triangulation_precondition (dimension() == 2); return Triangulation::circumcenter(f); } template < class Gt, class Tds > inline typename Gt::Segment_2 -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: dual(const Edge &e) const { - // dimension==2 - Face_handle nb = e.first->neighbor(e.second); - Point p0 = dual(e.first); - Point p1 = dual(nb); - Offset o = combine_offsets( Offset(), get_neighbor_offset(e.first, e.second)); - Segment s = geom_traits().construct_segment_2_object()(p0, p1, o, Offset()); - - return s; + // dimension==2 + Face_handle nb = e.first->neighbor(e.second); + Point p0 = dual(e.first); + Point p1 = dual(nb); + Offset o = combine_offsets( Offset(), get_neighbor_offset(e.first, e.second)); + Segment s = geom_traits().construct_segment_2_object()(p0, p1, o, Offset()); + + return s; } template < class Gt, class Tds > inline typename Gt::Segment_2 -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: dual(const Edge_circulator& ec) const { return dual(*ec); } template < class Gt, class Tds > inline typename Gt::Segment_2 -Periodic_2_Delaunay_triangulation_2:: -dual(const Edge_iterator& ei) const { +Periodic_2_Delaunay_triangulation_2:: +dual(const Edge_iterator& ei) const +{ return dual(*ei); } @@ -811,8 +871,8 @@ dual(const Edge_iterator& ei) const { template < class Gt, class Tds > inline -typename Periodic_2_Delaunay_triangulation_2::Vertex_handle -Periodic_2_Delaunay_triangulation_2:: +typename Periodic_2_Delaunay_triangulation_2::Vertex_handle +Periodic_2_Delaunay_triangulation_2:: insert(const Point &p, Face_handle start) { CGAL_triangulation_assertion((this->domain().xmin() <= p.x()) && @@ -820,13 +880,15 @@ insert(const Point &p, Face_handle start) CGAL_triangulation_assertion((this->domain().ymin() <= p.y()) && (p.y() < this->domain().ymax())); - if (empty()) { - return this->insert_first(p); - } + if (empty()) + { + return this->insert_first(p); + } - if (start == Face_handle()) { - start = this->faces_begin(); - } + if (start == Face_handle()) + { + start = this->faces_begin(); + } Locate_type lt; int li; @@ -838,8 +900,8 @@ insert(const Point &p, Face_handle start) template < class Gt, class Tds > inline -typename Periodic_2_Delaunay_triangulation_2::Vertex_handle -Periodic_2_Delaunay_triangulation_2:: +typename Periodic_2_Delaunay_triangulation_2::Vertex_handle +Periodic_2_Delaunay_triangulation_2:: push_back(const Point &p) { return insert(p); @@ -847,107 +909,116 @@ push_back(const Point &p) template < class Gt, class Tds > inline -typename Periodic_2_Delaunay_triangulation_2::Vertex_handle -Periodic_2_Delaunay_triangulation_2:: +typename Periodic_2_Delaunay_triangulation_2::Vertex_handle +Periodic_2_Delaunay_triangulation_2:: insert(const Point &p, Locate_type lt, Face_handle loc, int li) { - Vertex_handle vh = Triangulation::insert(p,lt,loc,li); + Vertex_handle vh = Triangulation::insert(p, lt, loc, li); - if (lt != Triangulation::VERTEX) { - restore_Delaunay(vh); + if (lt != Triangulation::VERTEX) + { + restore_Delaunay(vh); - if (!is_1_cover()) { - typename Triangulation::Virtual_vertex_reverse_map_it vertices_it = - this->virtual_vertices_reverse().find(vh); - CGAL_triangulation_assertion(vertices_it != this->virtual_vertices_reverse().end()); - const std::vector &virtual_vertices = vertices_it->second; - for (size_t i=0; ivirtual_vertices_reverse().find(vh); + CGAL_triangulation_assertion(vertices_it != this->virtual_vertices_reverse().end()); + const std::vector &virtual_vertices = vertices_it->second; + for (size_t i = 0; i < virtual_vertices.size(); ++i) + { + restore_Delaunay(virtual_vertices[i]); + } - this->try_to_convert_to_one_cover(); - if (is_1_cover()) { - CGAL_triangulation_assertion(is_valid()); - } + this->try_to_convert_to_one_cover(); + if (is_1_cover()) + { + CGAL_triangulation_assertion(is_valid()); + } + } } - } return vh; } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: restore_Delaunay(Vertex_handle v) { - Face_handle f=v->face(); + Face_handle f = v->face(); Face_handle next; int i; Face_handle start(f); - do { - i = f->index(v); - next = f->neighbor(ccw(i)); // turn ccw around v - propagating_flip(f,i); - f=next; - } while(next != start); + do + { + i = f->index(v); + next = f->neighbor(ccw(i)); // turn ccw around v + propagating_flip(f, i); + f = next; + } + while(next != start); } #ifndef CGAL_DT2_USE_RECURSIVE_PROPAGATING_FLIP template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: non_recursive_propagating_flip(Face_handle f , int i) { std::stack edges; const Vertex_handle& vp = f->vertex(i); - edges.push(Edge(f,i)); + edges.push(Edge(f, i)); - while(! edges.empty()){ - const Edge& e = edges.top(); - f = e.first; - i = e.second; - const Face_handle& n = f->neighbor(i); - - if (locally_Delaunay(f, i, n)) { - edges.pop(); - continue; + while(! edges.empty()) + { + const Edge& e = edges.top(); + f = e.first; + i = e.second; + const Face_handle& n = f->neighbor(i); + + if (locally_Delaunay(f, i, n)) + { + edges.pop(); + continue; + } + this->flip_single_edge(f, i); + // As we haven't popped it, we don't have to push it + edges.push(Edge(n, n->index(vp))); } - this->flip_single_edge(f, i); - // As we haven't popped it, we don't have to push it - edges.push(Edge(n,n->index(vp))); - } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: -propagating_flip(const Face_handle& f,int i, int depth) +Periodic_2_Delaunay_triangulation_2:: +propagating_flip(const Face_handle& f, int i, int depth) { #ifdef CGAL_DT2_IMMEDIATELY_NON_RECURSIVE_PROPAGATING_FLIP - non_recursive_propagating_flip(f,i); + non_recursive_propagating_flip(f, i); #else int max_depth = 100; - if(depth==max_depth){ - non_recursive_propagating_flip(f,i); - return; - } + if(depth == max_depth) + { + non_recursive_propagating_flip(f, i); + return; + } Face_handle n = f->neighbor(i); - + if (locally_Delaunay(f, i, n)) return; this->flip_single_edge(f, i); - propagating_flip(f,i,depth+1); + propagating_flip(f, i, depth + 1); i = n->index(f->vertex(i)); - propagating_flip(n,i,depth+1); + propagating_flip(n, i, depth + 1); #endif } -#else +#else template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: -propagating_flip(Face_handle& f,int i) +Periodic_2_Delaunay_triangulation_2:: +propagating_flip(Face_handle& f, int i) { Face_handle nb = f->neighbor(i); @@ -955,43 +1026,49 @@ propagating_flip(Face_handle& f,int i) return; this->flip_single_edge(f, i); - propagating_flip(f,i); + propagating_flip(f, i); i = nb->index(f->vertex(i)); - propagating_flip(nb,i); + propagating_flip(nb, i); } #endif template < class Gt, class Tds > bool -Periodic_2_Delaunay_triangulation_2:: -locally_Delaunay(const Face_handle &f, int i, const Face_handle &nb) { +Periodic_2_Delaunay_triangulation_2:: +locally_Delaunay(const Face_handle &f, int i, const Face_handle &nb) +{ CGAL_BRANCH_PROFILER("locally_Delaunay(), simplicity check failures", tmp); bool simplicity_criterion = is_1_cover() && f->has_zero_offsets() && nb->has_zero_offsets(); const Point *p[4]; - for (int index=0; index<3; ++index) { - p[index] = &nb->vertex(index)->point(); - } + for (int index = 0; index < 3; ++index) + { + p[index] = &nb->vertex(index)->point(); + } p[3] = &f->vertex(i)->point(); Oriented_side os; - if (simplicity_criterion) { - // No periodic offsets - os = side_of_oriented_circle(*p[0], *p[1], *p[2], *p[3], true); - } else { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - - Offset off[4]; - - for (int index=0; index<3; ++index) { - off[index] = get_offset(nb,index); + if (simplicity_criterion) + { + // No periodic offsets + os = side_of_oriented_circle(*p[0], *p[1], *p[2], *p[3], true); } - off[3] = combine_offsets(get_offset(f,i), get_neighbor_offset(f, i)); + else + { + CGAL_BRANCH_PROFILER_BRANCH(tmp); - os = side_of_oriented_circle(*p[0], *p[1], *p[2], *p[3], - off[0], off[1], off[2], off[3], true); - } + Offset off[4]; + + for (int index = 0; index < 3; ++index) + { + off[index] = get_offset(nb, index); + } + off[3] = combine_offsets(get_offset(f, i), get_neighbor_offset(f, i)); + + os = side_of_oriented_circle(*p[0], *p[1], *p[2], *p[3], + off[0], off[1], off[2], off[3], true); + } return (ON_POSITIVE_SIDE != os); } @@ -1001,7 +1078,7 @@ locally_Delaunay(const Face_handle &f, int i, const Face_handle &nb) { template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove(Vertex_handle v) { // Make sure we have the original vertex @@ -1010,36 +1087,41 @@ remove(Vertex_handle v) CGAL_triangulation_precondition(v != Vertex_handle()); CGAL_triangulation_precondition(dimension() == 2); - if ( this->number_of_vertices() == 1) { - // Last vertex - Triangulation::remove_first(v); - return; - } - - if (!remove_single_vertex(v, Offset())) { - // The vertex was not removed as we need to revert to the 9-cover first - this->convert_to_9_sheeted_covering(); - - remove_single_vertex(v, Offset()); - } - - if (!is_1_cover()) { - CGAL_assertion(this->virtual_vertices_reverse().find(v) != this->virtual_vertices_reverse().end()); - - const std::vector &virtual_copies = this->virtual_vertices_reverse().find(v)->second; - for (size_t i=0; i<8; ++i) { - remove_single_vertex(virtual_copies[i], Offset((i+1)/3, (i+1)%3)); + if ( this->number_of_vertices() == 1) + { + // Last vertex + Triangulation::remove_first(v); + return; } - this->remove_from_virtual_copies(v); - } + if (!remove_single_vertex(v, Offset())) + { + // The vertex was not removed as we need to revert to the 9-cover first + this->convert_to_9_sheeted_covering(); + + remove_single_vertex(v, Offset()); + } + + if (!is_1_cover()) + { + CGAL_assertion(this->virtual_vertices_reverse().find(v) != this->virtual_vertices_reverse().end()); + + const std::vector &virtual_copies = this->virtual_vertices_reverse().find(v)->second; + for (size_t i = 0; i < 8; ++i) + { + remove_single_vertex(virtual_copies[i], Offset((i + 1) / 3, (i + 1) % 3)); + } + + this->remove_from_virtual_copies(v); + } } template < class Gt, class Tds > bool -Periodic_2_Delaunay_triangulation_2:: -remove_single_vertex(Vertex_handle v, const Offset &v_o) { - static int maxd=30; +Periodic_2_Delaunay_triangulation_2:: +remove_single_vertex(Vertex_handle v, const Offset &v_o) +{ + static int maxd = 30; static std::vector f(maxd); static std::vector i(maxd); static std::vector w(maxd); @@ -1047,17 +1129,19 @@ remove_single_vertex(Vertex_handle v, const Offset &v_o) { int d; bool simplicity_criterion; - if (remove_degree_init(v,v_o, f,w,offset_w,i,d,maxd, simplicity_criterion)) { - if (is_1_cover()) { - // Don't delete if the hole is too big and the triangulation is a 1-cover - return false; + if (remove_degree_init(v, v_o, f, w, offset_w, i, d, maxd, simplicity_criterion)) + { + if (is_1_cover()) + { + // Don't delete if the hole is too big and the triangulation is a 1-cover + return false; + } } - } if (simplicity_criterion) - remove_degree_triangulate(v,f,w,i,d); + remove_degree_triangulate(v, f, w, i, d); else - remove_degree_triangulate(v,f,w,offset_w,i,d); + remove_degree_triangulate(v, f, w, offset_w, i, d); this->delete_vertex(v); @@ -1067,38 +1151,45 @@ remove_single_vertex(Vertex_handle v, const Offset &v_o) { template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree_triangulate(Vertex_handle v, std::vector &f, std::vector &w, - std::vector &i,int d) + std::vector &i, int d) { // degree: 3: 1%, 4: 9%, 5: 23%, 6: 35%, 7: 19%, r: 10% - switch (d) { - case 3: - remove_degree3(v,f,w,i); break; - case 4: - remove_degree4(v,f,w,i); break; - case 5: - remove_degree5(v,f,w,i); break; - case 6: - remove_degree6(v,f,w,i); break; - case 7: - remove_degree7(v,f,w,i); break; - default: - remove_degree_d(v,f,w,i,d); break; - } + switch (d) + { + case 3: + remove_degree3(v, f, w, i); + break; + case 4: + remove_degree4(v, f, w, i); + break; + case 5: + remove_degree5(v, f, w, i); + break; + case 6: + remove_degree6(v, f, w, i); + break; + case 7: + remove_degree7(v, f, w, i); + break; + default: + remove_degree_d(v, f, w, i, d); + break; + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree_triangulate(Vertex_handle v, std::vector &f, std::vector &w, std::vector &offset_w, - std::vector &i,int d) + std::vector &i, int d) { // degree: 3: 1%, 4: 9%, 5: 23%, 6: 35%, 7: 19%, r: 10% @@ -1108,25 +1199,32 @@ remove_degree_triangulate(Vertex_handle v, // no too long edges. this->remove_too_long_edges_in_star(v); - switch (d) { - case 3: - remove_degree3(v,f,w,offset_w,i); break; - case 4: - remove_degree4(v,f,w,offset_w,i); break; - case 5: - remove_degree5(v,f,w,offset_w,i); break; - case 6: - remove_degree6(v,f,w,offset_w,i); break; - case 7: - remove_degree7(v,f,w,offset_w,i); break; - default: - remove_degree_d(v,f,w,offset_w,i,d); break; - } + switch (d) + { + case 3: + remove_degree3(v, f, w, offset_w, i); + break; + case 4: + remove_degree4(v, f, w, offset_w, i); + break; + case 5: + remove_degree5(v, f, w, offset_w, i); + break; + case 6: + remove_degree6(v, f, w, offset_w, i); + break; + case 7: + remove_degree7(v, f, w, offset_w, i); + break; + default: + remove_degree_d(v, f, w, offset_w, i, d); + break; + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree_d(Vertex_handle v, std::vector &, std::vector &, std::vector &, int) @@ -1140,18 +1238,19 @@ remove_degree_d(Vertex_handle v, std::vector &, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree_d(Vertex_handle v, std::vector &, std::vector &w, std::vector &offset_w, - std::vector &,int d) + std::vector &, int d) { std::list hole; this->make_hole(v, hole); std::map vertex_offsets; - for (int idx=0; idx &, template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree3(Vertex_handle, std::vector &f, std::vector &, std::vector &i) { // modify the triangulation - Face_handle nn= f[1]->neighbor( i[1] ); + Face_handle nn = f[1]->neighbor( i[1] ); tds().set_adjacency(f[0], ccw(i[0]) , nn , nn->index(f[1]) ); - nn= f[2]->neighbor( i[2] ); + nn = f[2]->neighbor( i[2] ); tds().set_adjacency(f[0], cw(i[0]) , nn , nn->index(f[2]) ); f[0]->set_vertex ( i[0] , f[1]->vertex( cw(i[1]) ) ); @@ -1176,21 +1275,21 @@ remove_degree3(Vertex_handle, std::vector &f, tds().delete_face(f[1]); tds().delete_face(f[2]); - this->set_offsets(f[0], 0,0,0); + this->set_offsets(f[0], 0, 0, 0); return; } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree3(Vertex_handle, std::vector &f, std::vector &, std::vector &o, std::vector &i) { // modify the triangulation - Face_handle nn= f[1]->neighbor( i[1] ); + Face_handle nn = f[1]->neighbor( i[1] ); tds().set_adjacency(f[0], ccw(i[0]) , nn , nn->index(f[1]) ); - nn= f[2]->neighbor( i[2] ); + nn = f[2]->neighbor( i[2] ); tds().set_adjacency(f[0], cw(i[0]) , nn , nn->index(f[2]) ); f[0]->set_vertex ( i[0] , f[1]->vertex( cw(i[1]) ) ); @@ -1203,15 +1302,21 @@ remove_degree3(Vertex_handle, std::vector &f, oo[ cw(i[0])] = o[1]; oo[ccw(i[0])] = o[0]; - if (oo[0].x() < 0 || oo[1].x() < 0 || oo[2].x() < 0) { - Offset o(number_of_sheets()[0], 0); - oo[0] += o; oo[1] += o; oo[2] += o; - } - if (oo[0].y() < 0 || oo[1].y() < 0 || oo[2].y() < 0) { - Offset o(0, number_of_sheets()[1]); - oo[0] += o; oo[1] += o; oo[2] += o; - } - this->set_offsets(f[0], + if (oo[0].x() < 0 || oo[1].x() < 0 || oo[2].x() < 0) + { + Offset o(number_of_sheets()[0], 0); + oo[0] += o; + oo[1] += o; + oo[2] += o; + } + if (oo[0].y() < 0 || oo[1].y() < 0 || oo[2].y() < 0) + { + Offset o(0, number_of_sheets()[1]); + oo[0] += o; + oo[1] += o; + oo[2] += o; + } + this->set_offsets(f[0], (oo[0].x() >= number_of_sheets()[0] ? 2 : 0) + (oo[0].y() >= number_of_sheets()[1] ? 1 : 0), (oo[1].x() >= number_of_sheets()[0] ? 2 : 0) + (oo[1].y() >= number_of_sheets()[1] ? 1 : 0), (oo[2].x() >= number_of_sheets()[0] ? 2 : 0) + (oo[2].y() >= number_of_sheets()[1] ? 1 : 0)); @@ -1221,53 +1326,56 @@ remove_degree3(Vertex_handle, std::vector &f, template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree4(Vertex_handle, std::vector &f, - std::vector &w, + std::vector &w, std::vector &i ) { // removing a degree 4 vertex Face_handle nn; - if ( !incircle(2,0,1,3,f,w,i) ) { - // diagonal 1 3 - f[0]->set_vertex( i[0], w[3] ); //w0 w1 w3 - f[1]->set_vertex( i[1], w[3] ); //w1 w2 w3 - nn = f[3]->neighbor( i[3] ); - tds().set_adjacency(f[0], cw(i[0]) , nn , nn->index(f[3]) ); - nn = f[2]->neighbor( i[2] ); - tds().set_adjacency(f[1], ccw(i[1]) , nn , nn->index(f[2]) ); - // clean container - tds().delete_face(f[2]); - tds().delete_face(f[3]); + if ( !incircle(2, 0, 1, 3, f, w, i) ) + { + // diagonal 1 3 + f[0]->set_vertex( i[0], w[3] ); //w0 w1 w3 + f[1]->set_vertex( i[1], w[3] ); //w1 w2 w3 + nn = f[3]->neighbor( i[3] ); + tds().set_adjacency(f[0], cw(i[0]) , nn , nn->index(f[3]) ); + nn = f[2]->neighbor( i[2] ); + tds().set_adjacency(f[1], ccw(i[1]) , nn , nn->index(f[2]) ); + // clean container + tds().delete_face(f[2]); + tds().delete_face(f[3]); - f[0]->set_offsets(0,0,0); - f[1]->set_offsets(0,0,0); + f[0]->set_offsets(0, 0, 0); + f[1]->set_offsets(0, 0, 0); - insert_too_long_edge(f[0], ccw(i[0])); - }else{ - // diagonal 0 2 - f[0]->set_vertex( i[0], w[2]); //w0 w1 w2 - f[3]->set_vertex( i[3], w[2]); //w3 w0 w2 - nn = f[1]->neighbor( i[1] ); - tds().set_adjacency(f[0], ccw(i[0]) , nn , nn->index(f[1]) ); - nn = f[2]->neighbor( i[2] ); - tds().set_adjacency(f[3], cw(i[3]) , nn , nn->index(f[2]) ); - // clean container - tds().delete_face(f[1]); - tds().delete_face(f[2]); + insert_too_long_edge(f[0], ccw(i[0])); + } + else + { + // diagonal 0 2 + f[0]->set_vertex( i[0], w[2]); //w0 w1 w2 + f[3]->set_vertex( i[3], w[2]); //w3 w0 w2 + nn = f[1]->neighbor( i[1] ); + tds().set_adjacency(f[0], ccw(i[0]) , nn , nn->index(f[1]) ); + nn = f[2]->neighbor( i[2] ); + tds().set_adjacency(f[3], cw(i[3]) , nn , nn->index(f[2]) ); + // clean container + tds().delete_face(f[1]); + tds().delete_face(f[2]); - f[0]->set_offsets(0,0,0); - f[3]->set_offsets(0,0,0); - } + f[0]->set_offsets(0, 0, 0); + f[3]->set_offsets(0, 0, 0); + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree4(Vertex_handle, std::vector &f, - std::vector &w, std::vector &o, + std::vector &w, std::vector &o, std::vector &i ) { // removing a degree 4 vertex @@ -1275,75 +1383,82 @@ remove_degree4(Vertex_handle, std::vector &f, Face_handle nn; int oo[4]; - if ((o[0] == o[1]) && (o[0] == o[2]) && (o[0] == o[3])) { - for (int i=0; i<4; ++i) oo[i] = 0; - } else { - Covering_sheets cover = number_of_sheets(); - if ((o[0].x() < 0) || (o[1].x() < 0) || (o[2].x() < 0) || (o[3].x() < 0)) - for (int i=0; i<4; ++i) - o[i] += Offset(cover[0], 0); - - if ((o[0].y() < 0) || (o[1].y() < 0) || (o[2].y() < 0) || (o[3].y() < 0)) - for (int i=0; i<4; ++i) - o[i] += Offset(0, cover[1]); - - for (int i=0; i<4; ++i) { - oo[i] = (o[i].x() >= cover[0] ? 2 : 0) + (o[i].y() >= cover[1] ? 1 : 0); + if ((o[0] == o[1]) && (o[0] == o[2]) && (o[0] == o[3])) + { + for (int i = 0; i < 4; ++i) oo[i] = 0; } - } + else + { + Covering_sheets cover = number_of_sheets(); + if ((o[0].x() < 0) || (o[1].x() < 0) || (o[2].x() < 0) || (o[3].x() < 0)) + for (int i = 0; i < 4; ++i) + o[i] += Offset(cover[0], 0); - if ( !incircle(2,0,1,3,f,w,o,i) ) { - // diagonal 1 3 - f[0]->set_vertex( i[0], w[3] ); //w0 w1 w3 - f[1]->set_vertex( i[1], w[3] ); //w1 w2 w3 - nn = f[3]->neighbor( i[3] ); - tds().set_adjacency(f[0], cw(i[0]) , nn , nn->index(f[3]) ); - nn = f[2]->neighbor( i[2] ); - tds().set_adjacency(f[1], ccw(i[1]) , nn , nn->index(f[2]) ); - // clean container - tds().delete_face(f[2]); - tds().delete_face(f[3]); + if ((o[0].y() < 0) || (o[1].y() < 0) || (o[2].y() < 0) || (o[3].y() < 0)) + for (int i = 0; i < 4; ++i) + o[i] += Offset(0, cover[1]); - int o_face[3]; - o_face[i[0]] = oo[3]; - o_face[ccw(i[0])] = oo[0]; - o_face[ cw(i[0])] = oo[1]; - this->set_offsets(f[0], o_face[0], o_face[1], o_face[2]); - o_face[i[1]] = oo[3]; - o_face[ccw(i[1])] = oo[1]; - o_face[ cw(i[1])] = oo[2]; - this->set_offsets(f[1], o_face[0], o_face[1], o_face[2]); + for (int i = 0; i < 4; ++i) + { + oo[i] = (o[i].x() >= cover[0] ? 2 : 0) + (o[i].y() >= cover[1] ? 1 : 0); + } + } - insert_too_long_edge(f[0], ccw(i[0])); - }else{ - // diagonal 0 2 - f[0]->set_vertex( i[0], w[2]); //w0 w1 w2 - f[3]->set_vertex( i[3], w[2]); //w3 w0 w2 - nn = f[1]->neighbor( i[1] ); - tds().set_adjacency(f[0], ccw(i[0]) , nn , nn->index(f[1]) ); - nn = f[2]->neighbor( i[2] ); - tds().set_adjacency(f[3], cw(i[3]) , nn , nn->index(f[2]) ); - // clean container - tds().delete_face(f[1]); - tds().delete_face(f[2]); + if ( !incircle(2, 0, 1, 3, f, w, o, i) ) + { + // diagonal 1 3 + f[0]->set_vertex( i[0], w[3] ); //w0 w1 w3 + f[1]->set_vertex( i[1], w[3] ); //w1 w2 w3 + nn = f[3]->neighbor( i[3] ); + tds().set_adjacency(f[0], cw(i[0]) , nn , nn->index(f[3]) ); + nn = f[2]->neighbor( i[2] ); + tds().set_adjacency(f[1], ccw(i[1]) , nn , nn->index(f[2]) ); + // clean container + tds().delete_face(f[2]); + tds().delete_face(f[3]); - int o_face[3]; - o_face[i[0]] = oo[2]; - o_face[ccw(i[0])] = oo[0]; - o_face[ cw(i[0])] = oo[1]; - this->set_offsets(f[0], o_face[0], o_face[1], o_face[2]); - o_face[i[3]] = oo[2]; - o_face[ccw(i[3])] = oo[3]; - o_face[ cw(i[3])] = oo[0]; - this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); + int o_face[3]; + o_face[i[0]] = oo[3]; + o_face[ccw(i[0])] = oo[0]; + o_face[ cw(i[0])] = oo[1]; + this->set_offsets(f[0], o_face[0], o_face[1], o_face[2]); + o_face[i[1]] = oo[3]; + o_face[ccw(i[1])] = oo[1]; + o_face[ cw(i[1])] = oo[2]; + this->set_offsets(f[1], o_face[0], o_face[1], o_face[2]); - insert_too_long_edge(f[3], ccw(i[3])); - } + insert_too_long_edge(f[0], ccw(i[0])); + } + else + { + // diagonal 0 2 + f[0]->set_vertex( i[0], w[2]); //w0 w1 w2 + f[3]->set_vertex( i[3], w[2]); //w3 w0 w2 + nn = f[1]->neighbor( i[1] ); + tds().set_adjacency(f[0], ccw(i[0]) , nn , nn->index(f[1]) ); + nn = f[2]->neighbor( i[2] ); + tds().set_adjacency(f[3], cw(i[3]) , nn , nn->index(f[2]) ); + // clean container + tds().delete_face(f[1]); + tds().delete_face(f[2]); + + int o_face[3]; + o_face[i[0]] = oo[2]; + o_face[ccw(i[0])] = oo[0]; + o_face[ cw(i[0])] = oo[1]; + this->set_offsets(f[0], o_face[0], o_face[1], o_face[2]); + o_face[i[3]] = oo[2]; + o_face[ccw(i[3])] = oo[3]; + o_face[ cw(i[3])] = oo[0]; + this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); + + insert_too_long_edge(f[3], ccw(i[3])); + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree5(Vertex_handle v, std::vector &f, std::vector &w, std::vector &i) @@ -1351,52 +1466,67 @@ remove_degree5(Vertex_handle v, std::vector &f, // removing a degree 5 vertex this->remove_too_long_edges_in_star(v); - if (incircle(3,0,1,2,f,w,i)) { - if (incircle(4,0,1,3,f,w,i)) { - if (incircle(4,1,2,3,f,w,i)) { - // star from 4 - remove_degree5_star(v,f[4],f[0],f[1],f[2],f[3], - w[4],w[0],w[1],w[2],w[3], - i[4],i[0],i[1],i[2],i[3]); - }else{ - //star from 1 - remove_degree5_star(v,f[1],f[2],f[3],f[4],f[0], - w[1],w[2],w[3],w[4],w[0], - i[1],i[2],i[3],i[4],i[0]); + if (incircle(3, 0, 1, 2, f, w, i)) + { + if (incircle(4, 0, 1, 3, f, w, i)) + { + if (incircle(4, 1, 2, 3, f, w, i)) + { + // star from 4 + remove_degree5_star(v, f[4], f[0], f[1], f[2], f[3], + w[4], w[0], w[1], w[2], w[3], + i[4], i[0], i[1], i[2], i[3]); + } + else + { + //star from 1 + remove_degree5_star(v, f[1], f[2], f[3], f[4], f[0], + w[1], w[2], w[3], w[4], w[0], + i[1], i[2], i[3], i[4], i[0]); - } - }else{ - // star from 3 - remove_degree5_star(v,f[3],f[4],f[0],f[1],f[2], - w[3],w[4],w[0],w[1],w[2], - i[3],i[4],i[0],i[1],i[2]); + } + } + else + { + // star from 3 + remove_degree5_star(v, f[3], f[4], f[0], f[1], f[2], + w[3], w[4], w[0], w[1], w[2], + i[3], i[4], i[0], i[1], i[2]); + } } - } else { - if (incircle(4,2,3,0,f,w,i)){ - if (incircle(4,0,1,2,f,w,i)){ - // star from 4 - remove_degree5_star(v,f[4],f[0],f[1],f[2],f[3], - w[4],w[0],w[1],w[2],w[3], - i[4],i[0],i[1],i[2],i[3]); - }else{ - //star from 2 - remove_degree5_star(v,f[2],f[3],f[4],f[0],f[1], - w[2],w[3],w[4],w[0],w[1], - i[2],i[3],i[4],i[0],i[1]); - } - }else{ - // star from 0 - remove_degree5_star(v,f[0],f[1],f[2],f[3],f[4], - w[0],w[1],w[2],w[3],w[4], - i[0],i[1],i[2],i[3],i[4]); + else + { + if (incircle(4, 2, 3, 0, f, w, i)) + { + if (incircle(4, 0, 1, 2, f, w, i)) + { + // star from 4 + remove_degree5_star(v, f[4], f[0], f[1], f[2], f[3], + w[4], w[0], w[1], w[2], w[3], + i[4], i[0], i[1], i[2], i[3]); + } + else + { + //star from 2 + remove_degree5_star(v, f[2], f[3], f[4], f[0], f[1], + w[2], w[3], w[4], w[0], w[1], + i[2], i[3], i[4], i[0], i[1]); + } + } + else + { + // star from 0 + remove_degree5_star(v, f[0], f[1], f[2], f[3], f[4], + w[0], w[1], w[2], w[3], w[4], + i[0], i[1], i[2], i[3], i[4]); + } } - } return; } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree5(Vertex_handle v, std::vector &f, std::vector &w, std::vector &o, std::vector &i) @@ -1404,64 +1534,80 @@ remove_degree5(Vertex_handle v, std::vector &f, // removing a degree 5 vertex this->remove_too_long_edges_in_star(v); - if (incircle(3,0,1,2,f,w,o,i)) { - if (incircle(4,0,1,3,f,w,o,i)) { - if (incircle(4,1,2,3,f,w,o,i)) { - // star from 4 - remove_degree5_star(v,f[4],f[0],f[1],f[2],f[3], - w[4],w[0],w[1],w[2],w[3], - o[4],o[0],o[1],o[2],o[3], - i[4],i[0],i[1],i[2],i[3]); - }else{ - //star from 1 - remove_degree5_star(v,f[1],f[2],f[3],f[4],f[0], - w[1],w[2],w[3],w[4],w[0], - o[1],o[2],o[3],o[4],o[0], - i[1],i[2],i[3],i[4],i[0]); + if (incircle(3, 0, 1, 2, f, w, o, i)) + { + if (incircle(4, 0, 1, 3, f, w, o, i)) + { + if (incircle(4, 1, 2, 3, f, w, o, i)) + { + // star from 4 + remove_degree5_star(v, f[4], f[0], f[1], f[2], f[3], + w[4], w[0], w[1], w[2], w[3], + o[4], o[0], o[1], o[2], o[3], + i[4], i[0], i[1], i[2], i[3]); + } + else + { + //star from 1 + remove_degree5_star(v, f[1], f[2], f[3], f[4], f[0], + w[1], w[2], w[3], w[4], w[0], + o[1], o[2], o[3], o[4], o[0], + i[1], i[2], i[3], i[4], i[0]); - } - }else{ - // star from 3 - remove_degree5_star(v,f[3],f[4],f[0],f[1],f[2], - w[3],w[4],w[0],w[1],w[2], - o[3],o[4],o[0],o[1],o[2], - i[3],i[4],i[0],i[1],i[2]); + } + } + else + { + // star from 3 + remove_degree5_star(v, f[3], f[4], f[0], f[1], f[2], + w[3], w[4], w[0], w[1], w[2], + o[3], o[4], o[0], o[1], o[2], + i[3], i[4], i[0], i[1], i[2]); + } } - } else { - if (incircle(4,2,3,0,f,w,o,i)){ - if (incircle(4,0,1,2,f,w,o,i)){ - // star from 4 - remove_degree5_star(v,f[4],f[0],f[1],f[2],f[3], - w[4],w[0],w[1],w[2],w[3], - o[4],o[0],o[1],o[2],o[3], - i[4],i[0],i[1],i[2],i[3]); - }else{ - //star from 2 - remove_degree5_star(v,f[2],f[3],f[4],f[0],f[1], - w[2],w[3],w[4],w[0],w[1], - o[2],o[3],o[4],o[0],o[1], - i[2],i[3],i[4],i[0],i[1]); - } - }else{ - // star from 0 - remove_degree5_star(v,f[0],f[1],f[2],f[3],f[4], - w[0],w[1],w[2],w[3],w[4], - o[0],o[1],o[2],o[3],o[4], - i[0],i[1],i[2],i[3],i[4]); + else + { + if (incircle(4, 2, 3, 0, f, w, o, i)) + { + if (incircle(4, 0, 1, 2, f, w, o, i)) + { + // star from 4 + remove_degree5_star(v, f[4], f[0], f[1], f[2], f[3], + w[4], w[0], w[1], w[2], w[3], + o[4], o[0], o[1], o[2], o[3], + i[4], i[0], i[1], i[2], i[3]); + } + else + { + //star from 2 + remove_degree5_star(v, f[2], f[3], f[4], f[0], f[1], + w[2], w[3], w[4], w[0], w[1], + o[2], o[3], o[4], o[0], o[1], + i[2], i[3], i[4], i[0], i[1]); + } + } + else + { + // star from 0 + remove_degree5_star(v, f[0], f[1], f[2], f[3], f[4], + w[0], w[1], w[2], w[3], w[4], + o[0], o[1], o[2], o[3], o[4], + i[0], i[1], i[2], i[3], i[4]); + } } - } return; } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree5_star +Periodic_2_Delaunay_triangulation_2::remove_degree5_star (Vertex_handle &, Face_handle &f0, Face_handle &f1, Face_handle &f2, Face_handle &f3, Face_handle &f4, Vertex_handle &v0, Vertex_handle &, Vertex_handle &, Vertex_handle &, Vertex_handle &, int i0, int i1, int i2, int i3, int i4 ) -{ // removing a degree 5 vertex, starring from v0 +{ + // removing a degree 5 vertex, starring from v0 Face_handle nn; f1->set_vertex( i1, v0) ; // f1 = v1v2v0 f2->set_vertex( i2, v0) ; // f2 = v2v3v0 @@ -1474,19 +1620,20 @@ Periodic_2_Delaunay_triangulation_2::remove_degree5_star tds().delete_face(f0); tds().delete_face(f4); - f1->set_offsets(0,0,0); - f2->set_offsets(0,0,0); - f3->set_offsets(0,0,0); + f1->set_offsets(0, 0, 0); + f2->set_offsets(0, 0, 0); + f3->set_offsets(0, 0, 0); } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree5_star +Periodic_2_Delaunay_triangulation_2::remove_degree5_star (Vertex_handle &, Face_handle &f0, Face_handle &f1, Face_handle &f2, Face_handle &f3, Face_handle &f4, Vertex_handle &v0, Vertex_handle &, Vertex_handle &, Vertex_handle &, Vertex_handle &, Offset &o0, Offset &o1, Offset &o2, Offset &o3, Offset &o4, int i0, int i1, int i2, int i3, int i4 ) -{ // removing a degree 5 vertex, starring from v0 +{ + // removing a degree 5 vertex, starring from v0 Face_handle nn; f1->set_vertex( i1, v0) ; // f1 = v1v2v0 f2->set_vertex( i2, v0) ; // f2 = v2v3v0 @@ -1499,20 +1646,22 @@ Periodic_2_Delaunay_triangulation_2::remove_degree5_star tds().delete_face(f0); tds().delete_face(f4); - if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0) { - o0 += Offset(number_of_sheets()[0], 0); - o1 += Offset(number_of_sheets()[0], 0); - o2 += Offset(number_of_sheets()[0], 0); - o3 += Offset(number_of_sheets()[0], 0); - o4 += Offset(number_of_sheets()[0], 0); - } - if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0) { - o0 += Offset(0, number_of_sheets()[1]); - o1 += Offset(0, number_of_sheets()[1]); - o2 += Offset(0, number_of_sheets()[1]); - o3 += Offset(0, number_of_sheets()[1]); - o4 += Offset(0, number_of_sheets()[1]); - } + if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0) + { + o0 += Offset(number_of_sheets()[0], 0); + o1 += Offset(number_of_sheets()[0], 0); + o2 += Offset(number_of_sheets()[0], 0); + o3 += Offset(number_of_sheets()[0], 0); + o4 += Offset(number_of_sheets()[0], 0); + } + if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0) + { + o0 += Offset(0, number_of_sheets()[1]); + o1 += Offset(0, number_of_sheets()[1]); + o2 += Offset(0, number_of_sheets()[1]); + o3 += Offset(0, number_of_sheets()[1]); + o4 += Offset(0, number_of_sheets()[1]); + } int oo0 = (o0.x() >= number_of_sheets()[0] ? 2 : 0) + (o0.y() >= number_of_sheets()[1] ? 1 : 0); int oo1 = (o1.x() >= number_of_sheets()[0] ? 2 : 0) + (o1.y() >= number_of_sheets()[1] ? 1 : 0); int oo2 = (o2.x() >= number_of_sheets()[0] ? 2 : 0) + (o2.y() >= number_of_sheets()[1] ? 1 : 0); @@ -1540,139 +1689,230 @@ Periodic_2_Delaunay_triangulation_2::remove_degree5_star template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree6(Vertex_handle v, std::vector &f, - std::vector &w, + std::vector &w, std::vector &i) { - if(incircle(1,2,3,0,f,w,i)){ - if(incircle(4,2,3,5,f,w,i)){ - if(incircle(1,2,3,4,f,w,i)){ - if(incircle(4,0,1,3,f,w,i)){ - if(incircle(5,0,1,4,f,w,i)){ - remove_degree6_star(v, - f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - remove_degree6_N(v, - f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }}else{ - remove_degree6_antiN(v, - f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}else{ - if(incircle(5,1,2,4,f,w,i)){ - remove_degree6_N(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }else{ - if(incircle(5,0,1,4,f,w,i)){ - remove_degree6_antiN(v, - f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - remove_degree6_star(v,f[4],f[5],f[0],f[1],f[2],f[3], - w[4],w[5],w[0],w[1],w[2],w[3], - i[4],i[5],i[0],i[1],i[2],i[3]); - }}}}else{ - if(incircle(1,2,3,5,f,w,i)){ - if(incircle(1,3,4,5,f,w,i)){ - if(incircle(4,0,1,3,f,w,i)){ - if(incircle(5,0,1,4,f,w,i)){ - remove_degree6_star(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - remove_degree6_N(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }}else{ - remove_degree6_antiN(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}else{ - if(incircle(5,0,1,3,f,w,i)){ - remove_degree6_diamond(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - if(incircle(4,5,0,3,f,w,i)){ - remove_degree6_antiN(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }else{ - remove_degree6_star(v,f[3],f[4],f[5],f[0],f[1],f[2], - w[3],w[4],w[5],w[0],w[1],w[2], - i[3],i[4],i[5],i[0],i[1],i[2]); - }}}}else{ - remove_degree6_star(v,f[5],f[0],f[1],f[2],f[3],f[4], - w[5],w[0],w[1],w[2],w[3],w[4], - i[5],i[0],i[1],i[2],i[3],i[4]); - }}}else{ - if(incircle(4,2,3,5,f,w,i)){ - if(incircle(4,2,3,0,f,w,i)){ - if(incircle(4,0,1,2,f,w,i)){ - if(incircle(4,1,2,5,f,w,i)){ - if(incircle(4,0,1,5,f,w,i)){ - remove_degree6_star(v,f[4],f[5],f[0],f[1],f[2],f[3], - w[4],w[5],w[0],w[1],w[2],w[3], - i[4],i[5],i[0],i[1],i[2],i[3]); - }else{ - remove_degree6_antiN(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }}else{ - remove_degree6_N(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }}else{ - if(incircle(4,5,0,2,f,w,i)){ - remove_degree6_diamond(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }else{ - if(incircle(5,0,1,2,f,w,i)){ - remove_degree6_N(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }else{ - remove_degree6_star(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }}}}else{ - remove_degree6_star(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}else{ - if(incircle(5,2,3,0,f,w,i)){ - if(incircle(5,0,1,2,f,w,i)){ - remove_degree6_star(v,f[5],f[0],f[1],f[2],f[3],f[4], - w[5],w[0],w[1],w[2],w[3],w[4], - i[5],i[0],i[1],i[2],i[3],i[4]); - }else{ - remove_degree6_antiN(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }}else{ - if(incircle(4,5,0,3,f,w,i)){ - remove_degree6_star(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }else{ - remove_degree6_N(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}}} + if(incircle(1, 2, 3, 0, f, w, i)) + { + if(incircle(4, 2, 3, 5, f, w, i)) + { + if(incircle(1, 2, 3, 4, f, w, i)) + { + if(incircle(4, 0, 1, 3, f, w, i)) + { + if(incircle(5, 0, 1, 4, f, w, i)) + { + remove_degree6_star(v, + f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + remove_degree6_N(v, + f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + } + else + { + remove_degree6_antiN(v, + f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + else + { + if(incircle(5, 1, 2, 4, f, w, i)) + { + remove_degree6_N(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + else + { + if(incircle(5, 0, 1, 4, f, w, i)) + { + remove_degree6_antiN(v, + f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + remove_degree6_star(v, f[4], f[5], f[0], f[1], f[2], f[3], + w[4], w[5], w[0], w[1], w[2], w[3], + i[4], i[5], i[0], i[1], i[2], i[3]); + } + } + } + } + else + { + if(incircle(1, 2, 3, 5, f, w, i)) + { + if(incircle(1, 3, 4, 5, f, w, i)) + { + if(incircle(4, 0, 1, 3, f, w, i)) + { + if(incircle(5, 0, 1, 4, f, w, i)) + { + remove_degree6_star(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + remove_degree6_N(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + } + else + { + remove_degree6_antiN(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + else + { + if(incircle(5, 0, 1, 3, f, w, i)) + { + remove_degree6_diamond(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + if(incircle(4, 5, 0, 3, f, w, i)) + { + remove_degree6_antiN(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + else + { + remove_degree6_star(v, f[3], f[4], f[5], f[0], f[1], f[2], + w[3], w[4], w[5], w[0], w[1], w[2], + i[3], i[4], i[5], i[0], i[1], i[2]); + } + } + } + } + else + { + remove_degree6_star(v, f[5], f[0], f[1], f[2], f[3], f[4], + w[5], w[0], w[1], w[2], w[3], w[4], + i[5], i[0], i[1], i[2], i[3], i[4]); + } + } + } + else + { + if(incircle(4, 2, 3, 5, f, w, i)) + { + if(incircle(4, 2, 3, 0, f, w, i)) + { + if(incircle(4, 0, 1, 2, f, w, i)) + { + if(incircle(4, 1, 2, 5, f, w, i)) + { + if(incircle(4, 0, 1, 5, f, w, i)) + { + remove_degree6_star(v, f[4], f[5], f[0], f[1], f[2], f[3], + w[4], w[5], w[0], w[1], w[2], w[3], + i[4], i[5], i[0], i[1], i[2], i[3]); + } + else + { + remove_degree6_antiN(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + } + else + { + remove_degree6_N(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + } + else + { + if(incircle(4, 5, 0, 2, f, w, i)) + { + remove_degree6_diamond(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + else + { + if(incircle(5, 0, 1, 2, f, w, i)) + { + remove_degree6_N(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + else + { + remove_degree6_star(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + } + } + } + else + { + remove_degree6_star(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + else + { + if(incircle(5, 2, 3, 0, f, w, i)) + { + if(incircle(5, 0, 1, 2, f, w, i)) + { + remove_degree6_star(v, f[5], f[0], f[1], f[2], f[3], f[4], + w[5], w[0], w[1], w[2], w[3], w[4], + i[5], i[0], i[1], i[2], i[3], i[4]); + } + else + { + remove_degree6_antiN(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + } + else + { + if(incircle(4, 5, 0, 3, f, w, i)) + { + remove_degree6_star(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + else + { + remove_degree6_N(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + } + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree6(Vertex_handle v, std::vector &f, std::vector &w, std::vector &o, std::vector &i) @@ -1680,165 +1920,257 @@ remove_degree6(Vertex_handle v, std::vector &f, // removing a degree 6 vertex this->remove_too_long_edges_in_star(v); - if(incircle(1,2,3,0,f,w,o,i)){ - if(incircle(4,2,3,5,f,w,o,i)){ - if(incircle(1,2,3,4,f,w,o,i)){ - if(incircle(4,0,1,3,f,w,o,i)){ - if(incircle(5,0,1,4,f,w,o,i)){ - remove_degree6_star(v, - f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - o[1],o[2],o[3],o[4],o[5],o[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - remove_degree6_N(v, - f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - o[1],o[2],o[3],o[4],o[5],o[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }}else{ - remove_degree6_antiN(v, - f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - o[0],o[1],o[2],o[3],o[4],o[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}else{ - if(incircle(5,1,2,4,f,w,o,i)){ - remove_degree6_N(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - o[2],o[3],o[4],o[5],o[0],o[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }else{ - if(incircle(5,0,1,4,f,w,o,i)){ - remove_degree6_antiN(v, - f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - o[1],o[2],o[3],o[4],o[5],o[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - remove_degree6_star(v,f[4],f[5],f[0],f[1],f[2],f[3], - w[4],w[5],w[0],w[1],w[2],w[3], - o[4],o[5],o[0],o[1],o[2],o[3], - i[4],i[5],i[0],i[1],i[2],i[3]); - }}}}else{ - if(incircle(1,2,3,5,f,w,o,i)){ - if(incircle(1,3,4,5,f,w,o,i)){ - if(incircle(4,0,1,3,f,w,o,i)){ - if(incircle(5,0,1,4,f,w,o,i)){ - remove_degree6_star(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - o[1],o[2],o[3],o[4],o[5],o[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - remove_degree6_N(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - o[1],o[2],o[3],o[4],o[5],o[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }}else{ - remove_degree6_antiN(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - o[0],o[1],o[2],o[3],o[4],o[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}else{ - if(incircle(5,0,1,3,f,w,o,i)){ - remove_degree6_diamond(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - o[1],o[2],o[3],o[4],o[5],o[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }else{ - if(incircle(4,5,0,3,f,w,o,i)){ - remove_degree6_antiN(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - o[0],o[1],o[2],o[3],o[4],o[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }else{ - remove_degree6_star(v,f[3],f[4],f[5],f[0],f[1],f[2], - w[3],w[4],w[5],w[0],w[1],w[2], - o[3],o[4],o[5],o[0],o[1],o[2], - i[3],i[4],i[5],i[0],i[1],i[2]); - }}}}else{ - remove_degree6_star(v,f[5],f[0],f[1],f[2],f[3],f[4], - w[5],w[0],w[1],w[2],w[3],w[4], - o[5],o[0],o[1],o[2],o[3],o[4], - i[5],i[0],i[1],i[2],i[3],i[4]); - }}}else{ - if(incircle(4,2,3,5,f,w,o,i)){ - if(incircle(4,2,3,0,f,w,o,i)){ - if(incircle(4,0,1,2,f,w,o,i)){ - if(incircle(4,1,2,5,f,w,o,i)){ - if(incircle(4,0,1,5,f,w,o,i)){ - remove_degree6_star(v,f[4],f[5],f[0],f[1],f[2],f[3], - w[4],w[5],w[0],w[1],w[2],w[3], - o[4],o[5],o[0],o[1],o[2],o[3], - i[4],i[5],i[0],i[1],i[2],i[3]); - }else{ - remove_degree6_antiN(v,f[1],f[2],f[3],f[4],f[5],f[0], - w[1],w[2],w[3],w[4],w[5],w[0], - o[1],o[2],o[3],o[4],o[5],o[0], - i[1],i[2],i[3],i[4],i[5],i[0]); - }}else{ - remove_degree6_N(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - o[2],o[3],o[4],o[5],o[0],o[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }}else{ - if(incircle(4,5,0,2,f,w,o,i)){ - remove_degree6_diamond(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - o[0],o[1],o[2],o[3],o[4],o[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }else{ - if(incircle(5,0,1,2,f,w,o,i)){ - remove_degree6_N(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - o[2],o[3],o[4],o[5],o[0],o[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }else{ - remove_degree6_star(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - o[2],o[3],o[4],o[5],o[0],o[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }}}}else{ - remove_degree6_star(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - o[0],o[1],o[2],o[3],o[4],o[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}else{ - if(incircle(5,2,3,0,f,w,o,i)){ - if(incircle(5,0,1,2,f,w,o,i)){ - remove_degree6_star(v,f[5],f[0],f[1],f[2],f[3],f[4], - w[5],w[0],w[1],w[2],w[3],w[4], - o[5],o[0],o[1],o[2],o[3],o[4], - i[5],i[0],i[1],i[2],i[3],i[4]); - }else{ - remove_degree6_antiN(v,f[2],f[3],f[4],f[5],f[0],f[1], - w[2],w[3],w[4],w[5],w[0],w[1], - o[2],o[3],o[4],o[5],o[0],o[1], - i[2],i[3],i[4],i[5],i[0],i[1]); - }}else{ - if(incircle(4,5,0,3,f,w,o,i)){ - remove_degree6_star(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - o[0],o[1],o[2],o[3],o[4],o[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }else{ - remove_degree6_N(v,f[0],f[1],f[2],f[3],f[4],f[5], - w[0],w[1],w[2],w[3],w[4],w[5], - o[0],o[1],o[2],o[3],o[4],o[5], - i[0],i[1],i[2],i[3],i[4],i[5]); - }}}} + if(incircle(1, 2, 3, 0, f, w, o, i)) + { + if(incircle(4, 2, 3, 5, f, w, o, i)) + { + if(incircle(1, 2, 3, 4, f, w, o, i)) + { + if(incircle(4, 0, 1, 3, f, w, o, i)) + { + if(incircle(5, 0, 1, 4, f, w, o, i)) + { + remove_degree6_star(v, + f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + o[1], o[2], o[3], o[4], o[5], o[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + remove_degree6_N(v, + f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + o[1], o[2], o[3], o[4], o[5], o[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + } + else + { + remove_degree6_antiN(v, + f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + o[0], o[1], o[2], o[3], o[4], o[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + else + { + if(incircle(5, 1, 2, 4, f, w, o, i)) + { + remove_degree6_N(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + o[2], o[3], o[4], o[5], o[0], o[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + else + { + if(incircle(5, 0, 1, 4, f, w, o, i)) + { + remove_degree6_antiN(v, + f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + o[1], o[2], o[3], o[4], o[5], o[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + remove_degree6_star(v, f[4], f[5], f[0], f[1], f[2], f[3], + w[4], w[5], w[0], w[1], w[2], w[3], + o[4], o[5], o[0], o[1], o[2], o[3], + i[4], i[5], i[0], i[1], i[2], i[3]); + } + } + } + } + else + { + if(incircle(1, 2, 3, 5, f, w, o, i)) + { + if(incircle(1, 3, 4, 5, f, w, o, i)) + { + if(incircle(4, 0, 1, 3, f, w, o, i)) + { + if(incircle(5, 0, 1, 4, f, w, o, i)) + { + remove_degree6_star(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + o[1], o[2], o[3], o[4], o[5], o[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + remove_degree6_N(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + o[1], o[2], o[3], o[4], o[5], o[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + } + else + { + remove_degree6_antiN(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + o[0], o[1], o[2], o[3], o[4], o[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + else + { + if(incircle(5, 0, 1, 3, f, w, o, i)) + { + remove_degree6_diamond(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + o[1], o[2], o[3], o[4], o[5], o[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + else + { + if(incircle(4, 5, 0, 3, f, w, o, i)) + { + remove_degree6_antiN(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + o[0], o[1], o[2], o[3], o[4], o[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + else + { + remove_degree6_star(v, f[3], f[4], f[5], f[0], f[1], f[2], + w[3], w[4], w[5], w[0], w[1], w[2], + o[3], o[4], o[5], o[0], o[1], o[2], + i[3], i[4], i[5], i[0], i[1], i[2]); + } + } + } + } + else + { + remove_degree6_star(v, f[5], f[0], f[1], f[2], f[3], f[4], + w[5], w[0], w[1], w[2], w[3], w[4], + o[5], o[0], o[1], o[2], o[3], o[4], + i[5], i[0], i[1], i[2], i[3], i[4]); + } + } + } + else + { + if(incircle(4, 2, 3, 5, f, w, o, i)) + { + if(incircle(4, 2, 3, 0, f, w, o, i)) + { + if(incircle(4, 0, 1, 2, f, w, o, i)) + { + if(incircle(4, 1, 2, 5, f, w, o, i)) + { + if(incircle(4, 0, 1, 5, f, w, o, i)) + { + remove_degree6_star(v, f[4], f[5], f[0], f[1], f[2], f[3], + w[4], w[5], w[0], w[1], w[2], w[3], + o[4], o[5], o[0], o[1], o[2], o[3], + i[4], i[5], i[0], i[1], i[2], i[3]); + } + else + { + remove_degree6_antiN(v, f[1], f[2], f[3], f[4], f[5], f[0], + w[1], w[2], w[3], w[4], w[5], w[0], + o[1], o[2], o[3], o[4], o[5], o[0], + i[1], i[2], i[3], i[4], i[5], i[0]); + } + } + else + { + remove_degree6_N(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + o[2], o[3], o[4], o[5], o[0], o[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + } + else + { + if(incircle(4, 5, 0, 2, f, w, o, i)) + { + remove_degree6_diamond(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + o[0], o[1], o[2], o[3], o[4], o[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + else + { + if(incircle(5, 0, 1, 2, f, w, o, i)) + { + remove_degree6_N(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + o[2], o[3], o[4], o[5], o[0], o[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + else + { + remove_degree6_star(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + o[2], o[3], o[4], o[5], o[0], o[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + } + } + } + else + { + remove_degree6_star(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + o[0], o[1], o[2], o[3], o[4], o[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + else + { + if(incircle(5, 2, 3, 0, f, w, o, i)) + { + if(incircle(5, 0, 1, 2, f, w, o, i)) + { + remove_degree6_star(v, f[5], f[0], f[1], f[2], f[3], f[4], + w[5], w[0], w[1], w[2], w[3], w[4], + o[5], o[0], o[1], o[2], o[3], o[4], + i[5], i[0], i[1], i[2], i[3], i[4]); + } + else + { + remove_degree6_antiN(v, f[2], f[3], f[4], f[5], f[0], f[1], + w[2], w[3], w[4], w[5], w[0], w[1], + o[2], o[3], o[4], o[5], o[0], o[1], + i[2], i[3], i[4], i[5], i[0], i[1]); + } + } + else + { + if(incircle(4, 5, 0, 3, f, w, o, i)) + { + remove_degree6_star(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + o[0], o[1], o[2], o[3], o[4], o[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + else + { + remove_degree6_N(v, f[0], f[1], f[2], f[3], f[4], f[5], + w[0], w[1], w[2], w[3], w[4], w[5], + o[0], o[1], o[2], o[3], o[4], o[5], + i[0], i[1], i[2], i[3], i[4], i[5]); + } + } + } + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_star +Periodic_2_Delaunay_triangulation_2::remove_degree6_star (Vertex_handle &, Face_handle & f0, Face_handle & f1, Face_handle & f2, Face_handle & f3, Face_handle & f4, Face_handle & f5, Vertex_handle &v0, Vertex_handle &, Vertex_handle &, Vertex_handle &, Vertex_handle &, Vertex_handle &, int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, staring from v0 +{ + // removing a degree 6 vertex, staring from v0 Face_handle nn; f1->set_vertex( i1, v0) ; // f1 = v1v2v0 f2->set_vertex( i2, v0) ; // f2 = v2v3v0 @@ -1851,15 +2183,15 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_star tds().delete_face(f0); tds().delete_face(f5); - f1->set_offsets(0,0,0); - f2->set_offsets(0,0,0); - f3->set_offsets(0,0,0); - f4->set_offsets(0,0,0); + f1->set_offsets(0, 0, 0); + f2->set_offsets(0, 0, 0); + f3->set_offsets(0, 0, 0); + f4->set_offsets(0, 0, 0); } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_star +Periodic_2_Delaunay_triangulation_2::remove_degree6_star (Vertex_handle &v, Face_handle & f0, Face_handle & f1, Face_handle & f2, Face_handle & f3, Face_handle & f4, Face_handle & f5, @@ -1868,28 +2200,31 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_star Offset &o0, Offset &o1, Offset &o2, Offset &o3, Offset &o4, Offset &o5, int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, staring from v0 +{ + // removing a degree 6 vertex, staring from v0 remove_degree6_star(v, f0, f1, f2, f3, f4, f5, v0, v1, v2, v3, v4, v5, i0, i1, i2, i3, i4, i5); - - if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) { - o0 += Offset(number_of_sheets()[0], 0); - o1 += Offset(number_of_sheets()[0], 0); - o2 += Offset(number_of_sheets()[0], 0); - o3 += Offset(number_of_sheets()[0], 0); - o4 += Offset(number_of_sheets()[0], 0); - o5 += Offset(number_of_sheets()[0], 0); - } - if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) { - o0 += Offset(0, number_of_sheets()[1]); - o1 += Offset(0, number_of_sheets()[1]); - o2 += Offset(0, number_of_sheets()[1]); - o3 += Offset(0, number_of_sheets()[1]); - o4 += Offset(0, number_of_sheets()[1]); - o5 += Offset(0, number_of_sheets()[1]); - } + + if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) + { + o0 += Offset(number_of_sheets()[0], 0); + o1 += Offset(number_of_sheets()[0], 0); + o2 += Offset(number_of_sheets()[0], 0); + o3 += Offset(number_of_sheets()[0], 0); + o4 += Offset(number_of_sheets()[0], 0); + o5 += Offset(number_of_sheets()[0], 0); + } + if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) + { + o0 += Offset(0, number_of_sheets()[1]); + o1 += Offset(0, number_of_sheets()[1]); + o2 += Offset(0, number_of_sheets()[1]); + o3 += Offset(0, number_of_sheets()[1]); + o4 += Offset(0, number_of_sheets()[1]); + o5 += Offset(0, number_of_sheets()[1]); + } int oo0 = (o0.x() >= number_of_sheets()[0] ? 2 : 0) + (o0.y() >= number_of_sheets()[1] ? 1 : 0); int oo1 = (o1.x() >= number_of_sheets()[0] ? 2 : 0) + (o1.y() >= number_of_sheets()[1] ? 1 : 0); int oo2 = (o2.x() >= number_of_sheets()[0] ? 2 : 0) + (o2.y() >= number_of_sheets()[1] ? 1 : 0); @@ -1922,15 +2257,16 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_star template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_N +Periodic_2_Delaunay_triangulation_2::remove_degree6_N ( - Vertex_handle &, - Face_handle & f0, Face_handle & f1, Face_handle & f2, - Face_handle & f3, Face_handle & f4, Face_handle & f5, - Vertex_handle &v0, Vertex_handle &, Vertex_handle &, - Vertex_handle &v3, Vertex_handle &, Vertex_handle &, - int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, N configuration with diagonal v0v3 + Vertex_handle &, + Face_handle & f0, Face_handle & f1, Face_handle & f2, + Face_handle & f3, Face_handle & f4, Face_handle & f5, + Vertex_handle &v0, Vertex_handle &, Vertex_handle &, + Vertex_handle &v3, Vertex_handle &, Vertex_handle &, + int i0, int i1, int i2, int i3, int i4, int i5 ) +{ + // removing a degree 6 vertex, N configuration with diagonal v0v3 Face_handle nn; f1->set_vertex( i1, v0) ; // f1 = v1v2v0 f2->set_vertex( i2, v0) ; // f2 = v2v3v0 @@ -1944,46 +2280,49 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_N tds().delete_face(f0); tds().delete_face(f3); - f1->set_offsets(0,0,0); - f2->set_offsets(0,0,0); - f4->set_offsets(0,0,0); - f5->set_offsets(0,0,0); + f1->set_offsets(0, 0, 0); + f2->set_offsets(0, 0, 0); + f4->set_offsets(0, 0, 0); + f5->set_offsets(0, 0, 0); } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_N +Periodic_2_Delaunay_triangulation_2::remove_degree6_N ( - Vertex_handle &v, - Face_handle & f0, Face_handle & f1, Face_handle & f2, - Face_handle & f3, Face_handle & f4, Face_handle & f5, - Vertex_handle &v0, Vertex_handle &v1, Vertex_handle &v2, - Vertex_handle &v3, Vertex_handle &v4, Vertex_handle &v5, - Offset &o0, Offset &o1, Offset &o2, - Offset &o3, Offset &o4, Offset &o5, - int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, N configuration with diagonal v0v3 + Vertex_handle &v, + Face_handle & f0, Face_handle & f1, Face_handle & f2, + Face_handle & f3, Face_handle & f4, Face_handle & f5, + Vertex_handle &v0, Vertex_handle &v1, Vertex_handle &v2, + Vertex_handle &v3, Vertex_handle &v4, Vertex_handle &v5, + Offset &o0, Offset &o1, Offset &o2, + Offset &o3, Offset &o4, Offset &o5, + int i0, int i1, int i2, int i3, int i4, int i5 ) +{ + // removing a degree 6 vertex, N configuration with diagonal v0v3 remove_degree6_N(v, - f0,f1,f2,f3,f4,f5, - v0,v1,v2,v3,v4,v5, - i0,i1,i2,i3,i4,i5); + f0, f1, f2, f3, f4, f5, + v0, v1, v2, v3, v4, v5, + i0, i1, i2, i3, i4, i5); - if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) { - o0 += Offset(number_of_sheets()[0], 0); - o1 += Offset(number_of_sheets()[0], 0); - o2 += Offset(number_of_sheets()[0], 0); - o3 += Offset(number_of_sheets()[0], 0); - o4 += Offset(number_of_sheets()[0], 0); - o5 += Offset(number_of_sheets()[0], 0); - } - if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) { - o0 += Offset(0, number_of_sheets()[1]); - o1 += Offset(0, number_of_sheets()[1]); - o2 += Offset(0, number_of_sheets()[1]); - o3 += Offset(0, number_of_sheets()[1]); - o4 += Offset(0, number_of_sheets()[1]); - o5 += Offset(0, number_of_sheets()[1]); - } + if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) + { + o0 += Offset(number_of_sheets()[0], 0); + o1 += Offset(number_of_sheets()[0], 0); + o2 += Offset(number_of_sheets()[0], 0); + o3 += Offset(number_of_sheets()[0], 0); + o4 += Offset(number_of_sheets()[0], 0); + o5 += Offset(number_of_sheets()[0], 0); + } + if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) + { + o0 += Offset(0, number_of_sheets()[1]); + o1 += Offset(0, number_of_sheets()[1]); + o2 += Offset(0, number_of_sheets()[1]); + o3 += Offset(0, number_of_sheets()[1]); + o4 += Offset(0, number_of_sheets()[1]); + o5 += Offset(0, number_of_sheets()[1]); + } int oo0 = (o0.x() >= number_of_sheets()[0] ? 2 : 0) + (o0.y() >= number_of_sheets()[1] ? 1 : 0); int oo1 = (o1.x() >= number_of_sheets()[0] ? 2 : 0) + (o1.y() >= number_of_sheets()[1] ? 1 : 0); int oo2 = (o2.x() >= number_of_sheets()[0] ? 2 : 0) + (o2.y() >= number_of_sheets()[1] ? 1 : 0); @@ -2018,15 +2357,16 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_N template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_antiN +Periodic_2_Delaunay_triangulation_2::remove_degree6_antiN ( - Vertex_handle &, - Face_handle & f0, Face_handle & f1, Face_handle & f2, - Face_handle & f3, Face_handle & f4, Face_handle & f5, - Vertex_handle &v0, Vertex_handle &, Vertex_handle &, - Vertex_handle &v3, Vertex_handle &, Vertex_handle &, - int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, antiN configuration with diagonal v0v3 + Vertex_handle &, + Face_handle & f0, Face_handle & f1, Face_handle & f2, + Face_handle & f3, Face_handle & f4, Face_handle & f5, + Vertex_handle &v0, Vertex_handle &, Vertex_handle &, + Vertex_handle &v3, Vertex_handle &, Vertex_handle &, + int i0, int i1, int i2, int i3, int i4, int i5 ) +{ + // removing a degree 6 vertex, antiN configuration with diagonal v0v3 Face_handle nn; f0->set_vertex( i0, v3) ; // f0 = v0v1v3 f1->set_vertex( i1, v3) ; // f1 = v1v2v3 @@ -2040,45 +2380,48 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_antiN tds().delete_face(f2); tds().delete_face(f5); - f0->set_offsets(0,0,0); - f1->set_offsets(0,0,0); - f3->set_offsets(0,0,0); - f4->set_offsets(0,0,0); + f0->set_offsets(0, 0, 0); + f1->set_offsets(0, 0, 0); + f3->set_offsets(0, 0, 0); + f4->set_offsets(0, 0, 0); } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_antiN +Periodic_2_Delaunay_triangulation_2::remove_degree6_antiN ( - Vertex_handle &v, - Face_handle & f0, Face_handle & f1, Face_handle & f2, - Face_handle & f3, Face_handle & f4, Face_handle & f5, - Vertex_handle &v0, Vertex_handle &v1, Vertex_handle &v2, - Vertex_handle &v3, Vertex_handle &v4, Vertex_handle &v5, - Offset &o0, Offset &o1, Offset &o2, - Offset &o3, Offset &o4, Offset &o5, - int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, antiN configuration with diagonal v0v3 + Vertex_handle &v, + Face_handle & f0, Face_handle & f1, Face_handle & f2, + Face_handle & f3, Face_handle & f4, Face_handle & f5, + Vertex_handle &v0, Vertex_handle &v1, Vertex_handle &v2, + Vertex_handle &v3, Vertex_handle &v4, Vertex_handle &v5, + Offset &o0, Offset &o1, Offset &o2, + Offset &o3, Offset &o4, Offset &o5, + int i0, int i1, int i2, int i3, int i4, int i5 ) +{ + // removing a degree 6 vertex, antiN configuration with diagonal v0v3 remove_degree6_antiN(v, - f0,f1,f2,f3,f4,f5, - v0,v1,v2,v3,v4,v5, - i0,i1,i2,i3,i4,i5); + f0, f1, f2, f3, f4, f5, + v0, v1, v2, v3, v4, v5, + i0, i1, i2, i3, i4, i5); - if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) { - o0 += Offset(number_of_sheets()[0], 0); - o1 += Offset(number_of_sheets()[0], 0); - o2 += Offset(number_of_sheets()[0], 0); - o3 += Offset(number_of_sheets()[0], 0); - o4 += Offset(number_of_sheets()[0], 0); - o5 += Offset(number_of_sheets()[0], 0); - } - if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) { - o0 += Offset(0, number_of_sheets()[1]); - o1 += Offset(0, number_of_sheets()[1]); - o2 += Offset(0, number_of_sheets()[1]); - o3 += Offset(0, number_of_sheets()[1]); - o4 += Offset(0, number_of_sheets()[1]); - o5 += Offset(0, number_of_sheets()[1]); - } + if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) + { + o0 += Offset(number_of_sheets()[0], 0); + o1 += Offset(number_of_sheets()[0], 0); + o2 += Offset(number_of_sheets()[0], 0); + o3 += Offset(number_of_sheets()[0], 0); + o4 += Offset(number_of_sheets()[0], 0); + o5 += Offset(number_of_sheets()[0], 0); + } + if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) + { + o0 += Offset(0, number_of_sheets()[1]); + o1 += Offset(0, number_of_sheets()[1]); + o2 += Offset(0, number_of_sheets()[1]); + o3 += Offset(0, number_of_sheets()[1]); + o4 += Offset(0, number_of_sheets()[1]); + o5 += Offset(0, number_of_sheets()[1]); + } int oo0 = (o0.x() >= number_of_sheets()[0] ? 2 : 0) + (o0.y() >= number_of_sheets()[1] ? 1 : 0); int oo1 = (o1.x() >= number_of_sheets()[0] ? 2 : 0) + (o1.y() >= number_of_sheets()[1] ? 1 : 0); int oo2 = (o2.x() >= number_of_sheets()[0] ? 2 : 0) + (o2.y() >= number_of_sheets()[1] ? 1 : 0); @@ -2111,15 +2454,16 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_antiN template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_diamond +Periodic_2_Delaunay_triangulation_2::remove_degree6_diamond ( - Vertex_handle &, - Face_handle & f0, Face_handle & f1, Face_handle & f2, - Face_handle & f3, Face_handle & f4, Face_handle & f5, - Vertex_handle &v0, Vertex_handle &, Vertex_handle &v2, - Vertex_handle &, Vertex_handle &v4, Vertex_handle &, - int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, with chords v0v2 v2v4 v4v0 + Vertex_handle &, + Face_handle & f0, Face_handle & f1, Face_handle & f2, + Face_handle & f3, Face_handle & f4, Face_handle & f5, + Vertex_handle &v0, Vertex_handle &, Vertex_handle &v2, + Vertex_handle &, Vertex_handle &v4, Vertex_handle &, + int i0, int i1, int i2, int i3, int i4, int i5 ) +{ + // removing a degree 6 vertex, with chords v0v2 v2v4 v4v0 Face_handle nn; f0->set_vertex( i0, v2) ; // f0 = v0v1v2 f2->set_vertex( i2, v4) ; // f2 = v2v3v4 @@ -2139,45 +2483,48 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_diamond tds().delete_face(f5); - f0->set_offsets(0,0,0); - f1->set_offsets(0,0,0); - f2->set_offsets(0,0,0); - f4->set_offsets(0,0,0); + f0->set_offsets(0, 0, 0); + f1->set_offsets(0, 0, 0); + f2->set_offsets(0, 0, 0); + f4->set_offsets(0, 0, 0); } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2::remove_degree6_diamond +Periodic_2_Delaunay_triangulation_2::remove_degree6_diamond ( - Vertex_handle &v, - Face_handle & f0, Face_handle & f1, Face_handle & f2, - Face_handle & f3, Face_handle & f4, Face_handle & f5, - Vertex_handle &v0, Vertex_handle &v1, Vertex_handle &v2, - Vertex_handle &v3, Vertex_handle &v4, Vertex_handle &v5, - Offset &o0, Offset &o1, Offset &o2, - Offset &o3, Offset &o4, Offset &o5, - int i0, int i1, int i2, int i3, int i4, int i5 ) -{ // removing a degree 6 vertex, with chords v0v2 v2v4 v4v0 + Vertex_handle &v, + Face_handle & f0, Face_handle & f1, Face_handle & f2, + Face_handle & f3, Face_handle & f4, Face_handle & f5, + Vertex_handle &v0, Vertex_handle &v1, Vertex_handle &v2, + Vertex_handle &v3, Vertex_handle &v4, Vertex_handle &v5, + Offset &o0, Offset &o1, Offset &o2, + Offset &o3, Offset &o4, Offset &o5, + int i0, int i1, int i2, int i3, int i4, int i5 ) +{ + // removing a degree 6 vertex, with chords v0v2 v2v4 v4v0 remove_degree6_diamond(v, - f0,f1,f2,f3,f4,f5, - v0,v1,v2,v3,v4,v5, - i0,i1,i2,i3,i4,i5); + f0, f1, f2, f3, f4, f5, + v0, v1, v2, v3, v4, v5, + i0, i1, i2, i3, i4, i5); - if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) { - o0 += Offset(number_of_sheets()[0], 0); - o1 += Offset(number_of_sheets()[0], 0); - o2 += Offset(number_of_sheets()[0], 0); - o3 += Offset(number_of_sheets()[0], 0); - o4 += Offset(number_of_sheets()[0], 0); - o5 += Offset(number_of_sheets()[0], 0); - } - if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) { - o0 += Offset(0, number_of_sheets()[1]); - o1 += Offset(0, number_of_sheets()[1]); - o2 += Offset(0, number_of_sheets()[1]); - o3 += Offset(0, number_of_sheets()[1]); - o4 += Offset(0, number_of_sheets()[1]); - o5 += Offset(0, number_of_sheets()[1]); - } + if (o0.x() < 0 || o1.x() < 0 || o2.x() < 0 || o3.x() < 0 || o4.x() < 0 || o5.x() < 0) + { + o0 += Offset(number_of_sheets()[0], 0); + o1 += Offset(number_of_sheets()[0], 0); + o2 += Offset(number_of_sheets()[0], 0); + o3 += Offset(number_of_sheets()[0], 0); + o4 += Offset(number_of_sheets()[0], 0); + o5 += Offset(number_of_sheets()[0], 0); + } + if (o0.y() < 0 || o1.y() < 0 || o2.y() < 0 || o3.y() < 0 || o4.y() < 0 || o5.y() < 0) + { + o0 += Offset(0, number_of_sheets()[1]); + o1 += Offset(0, number_of_sheets()[1]); + o2 += Offset(0, number_of_sheets()[1]); + o3 += Offset(0, number_of_sheets()[1]); + o4 += Offset(0, number_of_sheets()[1]); + o5 += Offset(0, number_of_sheets()[1]); + } int oo0 = (o0.x() >= number_of_sheets()[0] ? 2 : 0) + (o0.y() >= number_of_sheets()[1] ? 1 : 0); int oo1 = (o1.x() >= number_of_sheets()[0] ? 2 : 0) + (o1.y() >= number_of_sheets()[1] ? 1 : 0); int oo2 = (o2.x() >= number_of_sheets()[0] ? 2 : 0) + (o2.y() >= number_of_sheets()[1] ? 1 : 0); @@ -2211,870 +2558,1904 @@ Periodic_2_Delaunay_triangulation_2::remove_degree6_diamond template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: -remove_degree7(Vertex_handle v,std::vector &f, +Periodic_2_Delaunay_triangulation_2:: +remove_degree7(Vertex_handle v, std::vector &f, std::vector &w, std::vector &i) { // removing a degree 7 vertex - if (incircle(2,0,1,3,f,w,i)) { // sweeping from above - if (incircle(2,3,4,0,f,w,i)) { - if (incircle(5,3,4,6,f,w,i)) { - if (incircle(5,3,4,2,f,w,i)) { - if (incircle(6,2,3,5,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_leftfan(v, 6 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 6 ,f,w,i); - }}else{ - if (incircle(5,0,1,2,f,w,i)) { - if (incircle(6,1,2,5,f,w,i)) { - remove_degree7_zigzag(v, 2 ,f,w,i); - }else{ - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_rightfan(v, 5 ,f,w,i); - }else{ - remove_degree7_star(v, 5 ,f,w,i); - }}}else{ - if (incircle(2,5,6,0,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_zigzag(v, 2 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 2 ,f,w,i); - }}else{ - remove_degree7_rightdelta(v, 5 ,f,w,i); - }}}}else{ - if (incircle(4,0,1,2,f,w,i)) { - if (incircle(5,1,2,4,f,w,i)) { - if (incircle(6,1,2,5,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(5,0,1,4,f,w,i)) { - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 1 ,f,w,i); - }}else{ - remove_degree7_rightfan(v, 4 ,f,w,i); - }}}else{ - if (incircle(2,4,5,0,f,w,i)) { - if (incircle(5,0,1,2,f,w,i)) { - if (incircle(6,1,2,5,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(2,5,6,0,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - remove_degree7_star(v, 2 ,f,w,i); - }}else{ - remove_degree7_leftdelta(v, 2 ,f,w,i); - }}}else{ - remove_degree7_rightdelta(v, 0 ,f,w,i); - }}}}else{ - if (incircle(6,3,4,2,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_star(v, 6 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 6 ,f,w,i); - }}else{ - if (incircle(4,0,1,2,f,w,i)) { - if (incircle(2,4,5,6,f,w,i)) { - if (incircle(5,1,2,4,f,w,i)) { - if (incircle(6,1,2,5,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(5,0,1,4,f,w,i)) { - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 1 ,f,w,i); - }} else{ - remove_degree7_rightfan(v, 4 ,f,w,i); - }}} else { - if (incircle(6,1,2,4,f,w,i)) { - remove_degree7_leftdelta(v, 6 ,f,w,i); - }else{ - if (incircle(1,4,5,6,f,w,i)) { - if (incircle(1,4,5,0,f,w,i)) { - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 1 ,f,w,i); - }}else{ - remove_degree7_rightfan(v, 4 ,f,w,i); - }} else { - if (incircle(6,0,1,4,f,w,i)) { - remove_degree7_rightdelta(v, 4 ,f,w,i); - }else{ - if (incircle(6,4,5,0,f,w,i)) { - remove_degree7_star(v, 4 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 4 ,f,w,i); - }}}}}}else{ - if (incircle(2,4,5,6,f,w,i)) { - if (incircle(2,4,5,0,f,w,i)) { - if (incircle(5,0,1,2,f,w,i)) { - if (incircle(6,1,2,5,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(2,5,6,0,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - remove_degree7_star(v, 2 ,f,w,i); - }}else{ - remove_degree7_leftdelta(v, 2 ,f,w,i); - }}}else{ - remove_degree7_rightdelta(v, 0 ,f,w,i); - }}else{ - if (incircle(2,6,0,4,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_leftdelta(v, 6 ,f,w,i); - }else{ - remove_degree7_rightdelta(v, 2 ,f,w,i); - }}else{ - if (incircle(6,4,5,0,f,w,i)) { - remove_degree7_leftdelta(v, 4 ,f,w,i); - }else{ - remove_degree7_rightdelta(v, 0 ,f,w,i); - }}}}}}} else{ - if (incircle(5,3,4,6,f,w,i)) { - if (incircle(5,3,4,0,f,w,i)) { - if (incircle(5,2,3,0,f,w,i)) { - if (incircle(6,2,3,5,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_leftfan(v, 6 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 6 ,f,w,i); - }}else - if (incircle(5,0,1,2,f,w,i)) { - if (incircle(6,1,2,5,f,w,i)) { - remove_degree7_zigzag(v, 2 ,f,w,i); - }else{ - if (incircle(6,0,1,5,f,w,i)) { - remove_degree7_rightfan(v, 5 ,f,w,i); - }else{ - remove_degree7_star(v, 5 ,f,w,i); - }}}else{ - if (incircle(2,5,6,0,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_zigzag(v, 2 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 2 ,f,w,i); - }}else{ - remove_degree7_rightdelta(v, 5 ,f,w,i); - }}}else{ - if (incircle(3,5,6,0,f,w,i)) { - if (incircle(6,2,3,0,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_leftfan(v, 6 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 6 ,f,w,i); - }}else{ - remove_degree7_leftfan(v, 3 ,f,w,i); - }}else{ - remove_degree7_leftdelta(v, 0 ,f,w,i); - }}}else{ - remove_degree7_star(v, 0 ,f,w,i); - }}else{ - if (incircle(6,3,4,0,f,w,i)) { - if (incircle(6,2,3,0,f,w,i)) { - if (incircle(6,0,1,2,f,w,i)) { - remove_degree7_star(v, 6 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 6 ,f,w,i); - }}else{ - remove_degree7_zigzag(v, 3 ,f,w,i); - }}else{ - if (incircle(6,4,5,0,f,w,i)) { - remove_degree7_leftfan(v, 0 ,f,w,i); - }else{ - remove_degree7_star(v, 0 ,f,w,i); - }}}}}else{ //sweeping from below - if (incircle(1,6,0,3,f,w,i)) { - if (incircle(5,6,0,4,f,w,i)) { - if (incircle(5,6,0,1,f,w,i)) { - if (incircle(4,0,1,5,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_rightfan(v, 4 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 4 ,f,w,i); - }}else{ - if (incircle(5,2,3,1,f,w,i)) { - if (incircle(4,1,2,5,f,w,i)) { - remove_degree7_zigzag(v, 1 ,f,w,i); - }else{ - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_leftfan(v, 5 ,f,w,i); - }else{ - remove_degree7_star(v, 5 ,f,w,i); - }}}else{ - if (incircle(1,4,5,3,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_zigzag(v, 1 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 1 ,f,w,i); - }}else{ - remove_degree7_leftdelta(v, 5 ,f,w,i); - }}}}else{ - if (incircle(6,2,3,1,f,w,i)) { - if (incircle(5,1,2,6,f,w,i)) { - if (incircle(4,1,2,5,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(5,2,3,6,f,w,i)) { - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 2 ,f,w,i); - }}else{ - remove_degree7_leftfan(v, 6 ,f,w,i); - }}}else{ - if (incircle(1,5,6,3,f,w,i)) { - if (incircle(5,2,3,1,f,w,i)) { - if (incircle(4,1,2,5,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(1,4,5,3,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - remove_degree7_star(v, 1 ,f,w,i); - }}else{ - remove_degree7_rightdelta(v, 1 ,f,w,i); - }}}else{ - remove_degree7_leftdelta(v, 3 ,f,w,i); - }}}}else{ - if (incircle(4,6,0,1,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_star(v, 4 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 4 ,f,w,i); - }}else{ - if (incircle(6,2,3,1,f,w,i)) { - if (incircle(1,5,6,4,f,w,i)) { - if (incircle(5,1,2,6,f,w,i)) { - if (incircle(4,1,2,5,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(5,2,3,6,f,w,i)) { - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 2 ,f,w,i); - }} else{ - remove_degree7_leftfan(v, 6 ,f,w,i); - }}} else { - if (incircle(4,1,2,6,f,w,i)) { - remove_degree7_rightdelta(v, 4 ,f,w,i); - }else{ - if (incircle(2,5,6,4,f,w,i)) { - if (incircle(2,5,6,3,f,w,i)) { - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_leftfan(v, 2 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 2 ,f,w,i); - }}else{ - remove_degree7_leftfan(v, 6 ,f,w,i); - }} else { - if (incircle(4,2,3,6,f,w,i)) { - remove_degree7_leftdelta(v, 6 ,f,w,i); - }else{ - if (incircle(4,5,6,3,f,w,i)) { - remove_degree7_star(v, 6 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 6 ,f,w,i); - }}}}}}else{ - if (incircle(1,5,6,4,f,w,i)) { - if (incircle(1,5,6,3,f,w,i)) { - if (incircle(5,2,3,1,f,w,i)) { - if (incircle(4,1,2,5,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_zigzag(v, 5 ,f,w,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,i); - }}}else{ - if (incircle(1,4,5,3,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_rightfan(v, 1 ,f,w,i); - }else{ - remove_degree7_star(v, 1 ,f,w,i); - }}else{ - remove_degree7_rightdelta(v, 1 ,f,w,i); - }}}else{ - remove_degree7_leftdelta(v, 3 ,f,w,i); - }}else{ - if (incircle(1,3,4,6,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_rightdelta(v, 4 ,f,w,i); - }else{ - remove_degree7_leftdelta(v, 1 ,f,w,i); - }}else{ - if (incircle(4,5,6,3,f,w,i)) { - remove_degree7_rightdelta(v, 6 ,f,w,i); - }else{ - remove_degree7_leftdelta(v, 3 ,f,w,i); - }}}}}}} else{ - if (incircle(5,6,0,4,f,w,i)) { - if (incircle(5,6,0,3,f,w,i)) { - if (incircle(5,0,1,3,f,w,i)) { - if (incircle(4,0,1,5,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_rightfan(v, 4 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 4 ,f,w,i); - }}else - if (incircle(5,2,3,1,f,w,i)) { - if (incircle(4,1,2,5,f,w,i)) { - remove_degree7_zigzag(v, 1 ,f,w,i); - }else{ - if (incircle(4,2,3,5,f,w,i)) { - remove_degree7_leftfan(v, 5 ,f,w,i); - }else{ - remove_degree7_star(v, 5 ,f,w,i); - }}}else{ - if (incircle(1,4,5,3,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_zigzag(v, 1 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 1 ,f,w,i); - }}else{ - remove_degree7_leftdelta(v, 5 ,f,w,i); - }}}else{ - if (! incircle(3,4,5,0,f,w,i)) { - if (incircle(4,0,1,3,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_rightfan(v, 4 ,f,w,i); - }else{ - remove_degree7_zigzag(v, 4 ,f,w,i); - }}else{ - remove_degree7_rightfan(v, 0 ,f,w,i); - }}else{ - remove_degree7_rightdelta(v, 3 ,f,w,i); - }}}else{ - remove_degree7_star(v, 3 ,f,w,i); - }}else{ - if (incircle(4,6,0,3,f,w,i)) { - if (incircle(4,0,1,3,f,w,i)) { - if (incircle(4,2,3,1,f,w,i)) { - remove_degree7_star(v, 4 ,f,w,i); - }else{ - remove_degree7_leftfan(v, 4 ,f,w,i); - }}else{ - remove_degree7_zigzag(v, 0 ,f,w,i); - }}else{ - if (incircle(4,5,6,3,f,w,i)) { - remove_degree7_rightfan(v, 3 ,f,w,i); - }else{ - remove_degree7_star(v, 3 ,f,w,i); - }}}}} + if (incircle(2, 0, 1, 3, f, w, i)) // sweeping from above + { + if (incircle(2, 3, 4, 0, f, w, i)) + { + if (incircle(5, 3, 4, 6, f, w, i)) + { + if (incircle(5, 3, 4, 2, f, w, i)) + { + if (incircle(6, 2, 3, 5, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_leftfan(v, 6 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 6 , f, w, i); + } + } + else + { + if (incircle(5, 0, 1, 2, f, w, i)) + { + if (incircle(6, 1, 2, 5, f, w, i)) + { + remove_degree7_zigzag(v, 2 , f, w, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_rightfan(v, 5 , f, w, i); + } + else + { + remove_degree7_star(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_zigzag(v, 2 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 2 , f, w, i); + } + } + else + { + remove_degree7_rightdelta(v, 5 , f, w, i); + } + } + } + } + else + { + if (incircle(4, 0, 1, 2, f, w, i)) + { + if (incircle(5, 1, 2, 4, f, w, i)) + { + if (incircle(6, 1, 2, 5, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(5, 0, 1, 4, f, w, i)) + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 1 , f, w, i); + } + } + else + { + remove_degree7_rightfan(v, 4 , f, w, i); + } + } + } + else + { + if (incircle(2, 4, 5, 0, f, w, i)) + { + if (incircle(5, 0, 1, 2, f, w, i)) + { + if (incircle(6, 1, 2, 5, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + remove_degree7_star(v, 2 , f, w, i); + } + } + else + { + remove_degree7_leftdelta(v, 2 , f, w, i); + } + } + } + else + { + remove_degree7_rightdelta(v, 0 , f, w, i); + } + } + } + } + else + { + if (incircle(6, 3, 4, 2, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_star(v, 6 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 6 , f, w, i); + } + } + else + { + if (incircle(4, 0, 1, 2, f, w, i)) + { + if (incircle(2, 4, 5, 6, f, w, i)) + { + if (incircle(5, 1, 2, 4, f, w, i)) + { + if (incircle(6, 1, 2, 5, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(5, 0, 1, 4, f, w, i)) + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 1 , f, w, i); + } + } + else + { + remove_degree7_rightfan(v, 4 , f, w, i); + } + } + } + else + { + if (incircle(6, 1, 2, 4, f, w, i)) + { + remove_degree7_leftdelta(v, 6 , f, w, i); + } + else + { + if (incircle(1, 4, 5, 6, f, w, i)) + { + if (incircle(1, 4, 5, 0, f, w, i)) + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 1 , f, w, i); + } + } + else + { + remove_degree7_rightfan(v, 4 , f, w, i); + } + } + else + { + if (incircle(6, 0, 1, 4, f, w, i)) + { + remove_degree7_rightdelta(v, 4 , f, w, i); + } + else + { + if (incircle(6, 4, 5, 0, f, w, i)) + { + remove_degree7_star(v, 4 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 4 , f, w, i); + } + } + } + } + } + } + else + { + if (incircle(2, 4, 5, 6, f, w, i)) + { + if (incircle(2, 4, 5, 0, f, w, i)) + { + if (incircle(5, 0, 1, 2, f, w, i)) + { + if (incircle(6, 1, 2, 5, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + remove_degree7_star(v, 2 , f, w, i); + } + } + else + { + remove_degree7_leftdelta(v, 2 , f, w, i); + } + } + } + else + { + remove_degree7_rightdelta(v, 0 , f, w, i); + } + } + else + { + if (incircle(2, 6, 0, 4, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_leftdelta(v, 6 , f, w, i); + } + else + { + remove_degree7_rightdelta(v, 2 , f, w, i); + } + } + else + { + if (incircle(6, 4, 5, 0, f, w, i)) + { + remove_degree7_leftdelta(v, 4 , f, w, i); + } + else + { + remove_degree7_rightdelta(v, 0 , f, w, i); + } + } + } + } + } + } + } + else + { + if (incircle(5, 3, 4, 6, f, w, i)) + { + if (incircle(5, 3, 4, 0, f, w, i)) + { + if (incircle(5, 2, 3, 0, f, w, i)) + { + if (incircle(6, 2, 3, 5, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_leftfan(v, 6 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 6 , f, w, i); + } + } + else if (incircle(5, 0, 1, 2, f, w, i)) + { + if (incircle(6, 1, 2, 5, f, w, i)) + { + remove_degree7_zigzag(v, 2 , f, w, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, i)) + { + remove_degree7_rightfan(v, 5 , f, w, i); + } + else + { + remove_degree7_star(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_zigzag(v, 2 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 2 , f, w, i); + } + } + else + { + remove_degree7_rightdelta(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(3, 5, 6, 0, f, w, i)) + { + if (incircle(6, 2, 3, 0, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_leftfan(v, 6 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 6 , f, w, i); + } + } + else + { + remove_degree7_leftfan(v, 3 , f, w, i); + } + } + else + { + remove_degree7_leftdelta(v, 0 , f, w, i); + } + } + } + else + { + remove_degree7_star(v, 0 , f, w, i); + } + } + else + { + if (incircle(6, 3, 4, 0, f, w, i)) + { + if (incircle(6, 2, 3, 0, f, w, i)) + { + if (incircle(6, 0, 1, 2, f, w, i)) + { + remove_degree7_star(v, 6 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 6 , f, w, i); + } + } + else + { + remove_degree7_zigzag(v, 3 , f, w, i); + } + } + else + { + if (incircle(6, 4, 5, 0, f, w, i)) + { + remove_degree7_leftfan(v, 0 , f, w, i); + } + else + { + remove_degree7_star(v, 0 , f, w, i); + } + } + } + } + } + else //sweeping from below + { + if (incircle(1, 6, 0, 3, f, w, i)) + { + if (incircle(5, 6, 0, 4, f, w, i)) + { + if (incircle(5, 6, 0, 1, f, w, i)) + { + if (incircle(4, 0, 1, 5, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_rightfan(v, 4 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 4 , f, w, i); + } + } + else + { + if (incircle(5, 2, 3, 1, f, w, i)) + { + if (incircle(4, 1, 2, 5, f, w, i)) + { + remove_degree7_zigzag(v, 1 , f, w, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_leftfan(v, 5 , f, w, i); + } + else + { + remove_degree7_star(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_zigzag(v, 1 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 1 , f, w, i); + } + } + else + { + remove_degree7_leftdelta(v, 5 , f, w, i); + } + } + } + } + else + { + if (incircle(6, 2, 3, 1, f, w, i)) + { + if (incircle(5, 1, 2, 6, f, w, i)) + { + if (incircle(4, 1, 2, 5, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(5, 2, 3, 6, f, w, i)) + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 2 , f, w, i); + } + } + else + { + remove_degree7_leftfan(v, 6 , f, w, i); + } + } + } + else + { + if (incircle(1, 5, 6, 3, f, w, i)) + { + if (incircle(5, 2, 3, 1, f, w, i)) + { + if (incircle(4, 1, 2, 5, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + remove_degree7_star(v, 1 , f, w, i); + } + } + else + { + remove_degree7_rightdelta(v, 1 , f, w, i); + } + } + } + else + { + remove_degree7_leftdelta(v, 3 , f, w, i); + } + } + } + } + else + { + if (incircle(4, 6, 0, 1, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_star(v, 4 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 4 , f, w, i); + } + } + else + { + if (incircle(6, 2, 3, 1, f, w, i)) + { + if (incircle(1, 5, 6, 4, f, w, i)) + { + if (incircle(5, 1, 2, 6, f, w, i)) + { + if (incircle(4, 1, 2, 5, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(5, 2, 3, 6, f, w, i)) + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 2 , f, w, i); + } + } + else + { + remove_degree7_leftfan(v, 6 , f, w, i); + } + } + } + else + { + if (incircle(4, 1, 2, 6, f, w, i)) + { + remove_degree7_rightdelta(v, 4 , f, w, i); + } + else + { + if (incircle(2, 5, 6, 4, f, w, i)) + { + if (incircle(2, 5, 6, 3, f, w, i)) + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_leftfan(v, 2 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 2 , f, w, i); + } + } + else + { + remove_degree7_leftfan(v, 6 , f, w, i); + } + } + else + { + if (incircle(4, 2, 3, 6, f, w, i)) + { + remove_degree7_leftdelta(v, 6 , f, w, i); + } + else + { + if (incircle(4, 5, 6, 3, f, w, i)) + { + remove_degree7_star(v, 6 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 6 , f, w, i); + } + } + } + } + } + } + else + { + if (incircle(1, 5, 6, 4, f, w, i)) + { + if (incircle(1, 5, 6, 3, f, w, i)) + { + if (incircle(5, 2, 3, 1, f, w, i)) + { + if (incircle(4, 1, 2, 5, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_zigzag(v, 5 , f, w, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_rightfan(v, 1 , f, w, i); + } + else + { + remove_degree7_star(v, 1 , f, w, i); + } + } + else + { + remove_degree7_rightdelta(v, 1 , f, w, i); + } + } + } + else + { + remove_degree7_leftdelta(v, 3 , f, w, i); + } + } + else + { + if (incircle(1, 3, 4, 6, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_rightdelta(v, 4 , f, w, i); + } + else + { + remove_degree7_leftdelta(v, 1 , f, w, i); + } + } + else + { + if (incircle(4, 5, 6, 3, f, w, i)) + { + remove_degree7_rightdelta(v, 6 , f, w, i); + } + else + { + remove_degree7_leftdelta(v, 3 , f, w, i); + } + } + } + } + } + } + } + else + { + if (incircle(5, 6, 0, 4, f, w, i)) + { + if (incircle(5, 6, 0, 3, f, w, i)) + { + if (incircle(5, 0, 1, 3, f, w, i)) + { + if (incircle(4, 0, 1, 5, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_rightfan(v, 4 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 4 , f, w, i); + } + } + else if (incircle(5, 2, 3, 1, f, w, i)) + { + if (incircle(4, 1, 2, 5, f, w, i)) + { + remove_degree7_zigzag(v, 1 , f, w, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, i)) + { + remove_degree7_leftfan(v, 5 , f, w, i); + } + else + { + remove_degree7_star(v, 5 , f, w, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_zigzag(v, 1 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 1 , f, w, i); + } + } + else + { + remove_degree7_leftdelta(v, 5 , f, w, i); + } + } + } + else + { + if (! incircle(3, 4, 5, 0, f, w, i)) + { + if (incircle(4, 0, 1, 3, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_rightfan(v, 4 , f, w, i); + } + else + { + remove_degree7_zigzag(v, 4 , f, w, i); + } + } + else + { + remove_degree7_rightfan(v, 0 , f, w, i); + } + } + else + { + remove_degree7_rightdelta(v, 3 , f, w, i); + } + } + } + else + { + remove_degree7_star(v, 3 , f, w, i); + } + } + else + { + if (incircle(4, 6, 0, 3, f, w, i)) + { + if (incircle(4, 0, 1, 3, f, w, i)) + { + if (incircle(4, 2, 3, 1, f, w, i)) + { + remove_degree7_star(v, 4 , f, w, i); + } + else + { + remove_degree7_leftfan(v, 4 , f, w, i); + } + } + else + { + remove_degree7_zigzag(v, 0 , f, w, i); + } + } + else + { + if (incircle(4, 5, 6, 3, f, w, i)) + { + remove_degree7_rightfan(v, 3 , f, w, i); + } + else + { + remove_degree7_star(v, 3 , f, w, i); + } + } + } + } + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: -remove_degree7(Vertex_handle v,std::vector &f, +Periodic_2_Delaunay_triangulation_2:: +remove_degree7(Vertex_handle v, std::vector &f, std::vector &w, std::vector &o, std::vector &i) { // removing a degree 7 vertex - if (incircle(2,0,1,3,f,w,o,i)) { // sweeping from above - if (incircle(2,3,4,0,f,w,o,i)) { - if (incircle(5,3,4,6,f,w,o,i)) { - if (incircle(5,3,4,2,f,w,o,i)) { - if (incircle(6,2,3,5,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_leftfan(v, 6 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 6 ,f,w,o,i); - }}else{ - if (incircle(5,0,1,2,f,w,o,i)) { - if (incircle(6,1,2,5,f,w,o,i)) { - remove_degree7_zigzag(v, 2 ,f,w,o,i); - }else{ - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_rightfan(v, 5 ,f,w,o,i); - }else{ - remove_degree7_star(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(2,5,6,0,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_zigzag(v, 2 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 2 ,f,w,o,i); - }}else{ - remove_degree7_rightdelta(v, 5 ,f,w,o,i); - }}}}else{ - if (incircle(4,0,1,2,f,w,o,i)) { - if (incircle(5,1,2,4,f,w,o,i)) { - if (incircle(6,1,2,5,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(5,0,1,4,f,w,o,i)) { - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 1 ,f,w,o,i); - }}else{ - remove_degree7_rightfan(v, 4 ,f,w,o,i); - }}}else{ - if (incircle(2,4,5,0,f,w,o,i)) { - if (incircle(5,0,1,2,f,w,o,i)) { - if (incircle(6,1,2,5,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(2,5,6,0,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - remove_degree7_star(v, 2 ,f,w,o,i); - }}else{ - remove_degree7_leftdelta(v, 2 ,f,w,o,i); - }}}else{ - remove_degree7_rightdelta(v, 0 ,f,w,o,i); - }}}}else{ - if (incircle(6,3,4,2,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_star(v, 6 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 6 ,f,w,o,i); - }}else{ - if (incircle(4,0,1,2,f,w,o,i)) { - if (incircle(2,4,5,6,f,w,o,i)) { - if (incircle(5,1,2,4,f,w,o,i)) { - if (incircle(6,1,2,5,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(5,0,1,4,f,w,o,i)) { - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 1 ,f,w,o,i); - }} else{ - remove_degree7_rightfan(v, 4 ,f,w,o,i); - }}} else { - if (incircle(6,1,2,4,f,w,o,i)) { - remove_degree7_leftdelta(v, 6 ,f,w,o,i); - }else{ - if (incircle(1,4,5,6,f,w,o,i)) { - if (incircle(1,4,5,0,f,w,o,i)) { - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 1 ,f,w,o,i); - }}else{ - remove_degree7_rightfan(v, 4 ,f,w,o,i); - }} else { - if (incircle(6,0,1,4,f,w,o,i)) { - remove_degree7_rightdelta(v, 4 ,f,w,o,i); - }else{ - if (incircle(6,4,5,0,f,w,o,i)) { - remove_degree7_star(v, 4 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 4 ,f,w,o,i); - }}}}}}else{ - if (incircle(2,4,5,6,f,w,o,i)) { - if (incircle(2,4,5,0,f,w,o,i)) { - if (incircle(5,0,1,2,f,w,o,i)) { - if (incircle(6,1,2,5,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(2,5,6,0,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - remove_degree7_star(v, 2 ,f,w,o,i); - }}else{ - remove_degree7_leftdelta(v, 2 ,f,w,o,i); - }}}else{ - remove_degree7_rightdelta(v, 0 ,f,w,o,i); - }}else{ - if (incircle(2,6,0,4,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_leftdelta(v, 6 ,f,w,o,i); - }else{ - remove_degree7_rightdelta(v, 2 ,f,w,o,i); - }}else{ - if (incircle(6,4,5,0,f,w,o,i)) { - remove_degree7_leftdelta(v, 4 ,f,w,o,i); - }else{ - remove_degree7_rightdelta(v, 0 ,f,w,o,i); - }}}}}}} else{ - if (incircle(5,3,4,6,f,w,o,i)) { - if (incircle(5,3,4,0,f,w,o,i)) { - if (incircle(5,2,3,0,f,w,o,i)) { - if (incircle(6,2,3,5,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_leftfan(v, 6 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 6 ,f,w,o,i); - }}else - if (incircle(5,0,1,2,f,w,o,i)) { - if (incircle(6,1,2,5,f,w,o,i)) { - remove_degree7_zigzag(v, 2 ,f,w,o,i); - }else{ - if (incircle(6,0,1,5,f,w,o,i)) { - remove_degree7_rightfan(v, 5 ,f,w,o,i); - }else{ - remove_degree7_star(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(2,5,6,0,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_zigzag(v, 2 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 2 ,f,w,o,i); - }}else{ - remove_degree7_rightdelta(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(3,5,6,0,f,w,o,i)) { - if (incircle(6,2,3,0,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_leftfan(v, 6 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 6 ,f,w,o,i); - }}else{ - remove_degree7_leftfan(v, 3 ,f,w,o,i); - }}else{ - remove_degree7_leftdelta(v, 0 ,f,w,o,i); - }}}else{ - remove_degree7_star(v, 0 ,f,w,o,i); - }}else{ - if (incircle(6,3,4,0,f,w,o,i)) { - if (incircle(6,2,3,0,f,w,o,i)) { - if (incircle(6,0,1,2,f,w,o,i)) { - remove_degree7_star(v, 6 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 6 ,f,w,o,i); - }}else{ - remove_degree7_zigzag(v, 3 ,f,w,o,i); - }}else{ - if (incircle(6,4,5,0,f,w,o,i)) { - remove_degree7_leftfan(v, 0 ,f,w,o,i); - }else{ - remove_degree7_star(v, 0 ,f,w,o,i); - }}}}}else{ //sweeping from below - if (incircle(1,6,0,3,f,w,o,i)) { - if (incircle(5,6,0,4,f,w,o,i)) { - if (incircle(5,6,0,1,f,w,o,i)) { - if (incircle(4,0,1,5,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_rightfan(v, 4 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 4 ,f,w,o,i); - }}else{ - if (incircle(5,2,3,1,f,w,o,i)) { - if (incircle(4,1,2,5,f,w,o,i)) { - remove_degree7_zigzag(v, 1 ,f,w,o,i); - }else{ - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_leftfan(v, 5 ,f,w,o,i); - }else{ - remove_degree7_star(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(1,4,5,3,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_zigzag(v, 1 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 1 ,f,w,o,i); - }}else{ - remove_degree7_leftdelta(v, 5 ,f,w,o,i); - }}}}else{ - if (incircle(6,2,3,1,f,w,o,i)) { - if (incircle(5,1,2,6,f,w,o,i)) { - if (incircle(4,1,2,5,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(5,2,3,6,f,w,o,i)) { - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 2 ,f,w,o,i); - }}else{ - remove_degree7_leftfan(v, 6 ,f,w,o,i); - }}}else{ - if (incircle(1,5,6,3,f,w,o,i)) { - if (incircle(5,2,3,1,f,w,o,i)) { - if (incircle(4,1,2,5,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(1,4,5,3,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - remove_degree7_star(v, 1 ,f,w,o,i); - }}else{ - remove_degree7_rightdelta(v, 1 ,f,w,o,i); - }}}else{ - remove_degree7_leftdelta(v, 3 ,f,w,o,i); - }}}}else{ - if (incircle(4,6,0,1,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_star(v, 4 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 4 ,f,w,o,i); - }}else{ - if (incircle(6,2,3,1,f,w,o,i)) { - if (incircle(1,5,6,4,f,w,o,i)) { - if (incircle(5,1,2,6,f,w,o,i)) { - if (incircle(4,1,2,5,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(5,2,3,6,f,w,o,i)) { - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 2 ,f,w,o,i); - }} else{ - remove_degree7_leftfan(v, 6 ,f,w,o,i); - }}} else { - if (incircle(4,1,2,6,f,w,o,i)) { - remove_degree7_rightdelta(v, 4 ,f,w,o,i); - }else{ - if (incircle(2,5,6,4,f,w,o,i)) { - if (incircle(2,5,6,3,f,w,o,i)) { - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_leftfan(v, 2 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 2 ,f,w,o,i); - }}else{ - remove_degree7_leftfan(v, 6 ,f,w,o,i); - }} else { - if (incircle(4,2,3,6,f,w,o,i)) { - remove_degree7_leftdelta(v, 6 ,f,w,o,i); - }else{ - if (incircle(4,5,6,3,f,w,o,i)) { - remove_degree7_star(v, 6 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 6 ,f,w,o,i); - }}}}}}else{ - if (incircle(1,5,6,4,f,w,o,i)) { - if (incircle(1,5,6,3,f,w,o,i)) { - if (incircle(5,2,3,1,f,w,o,i)) { - if (incircle(4,1,2,5,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_zigzag(v, 5 ,f,w,o,i); - }else{ - remove_degree7_rightfan(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(1,4,5,3,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_rightfan(v, 1 ,f,w,o,i); - }else{ - remove_degree7_star(v, 1 ,f,w,o,i); - }}else{ - remove_degree7_rightdelta(v, 1 ,f,w,o,i); - }}}else{ - remove_degree7_leftdelta(v, 3 ,f,w,o,i); - }}else{ - if (incircle(1,3,4,6,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_rightdelta(v, 4 ,f,w,o,i); - }else{ - remove_degree7_leftdelta(v, 1 ,f,w,o,i); - }}else{ - if (incircle(4,5,6,3,f,w,o,i)) { - remove_degree7_rightdelta(v, 6 ,f,w,o,i); - }else{ - remove_degree7_leftdelta(v, 3 ,f,w,o,i); - }}}}}}} else{ - if (incircle(5,6,0,4,f,w,o,i)) { - if (incircle(5,6,0,3,f,w,o,i)) { - if (incircle(5,0,1,3,f,w,o,i)) { - if (incircle(4,0,1,5,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_rightfan(v, 4 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 4 ,f,w,o,i); - }}else - if (incircle(5,2,3,1,f,w,o,i)) { - if (incircle(4,1,2,5,f,w,o,i)) { - remove_degree7_zigzag(v, 1 ,f,w,o,i); - }else{ - if (incircle(4,2,3,5,f,w,o,i)) { - remove_degree7_leftfan(v, 5 ,f,w,o,i); - }else{ - remove_degree7_star(v, 5 ,f,w,o,i); - }}}else{ - if (incircle(1,4,5,3,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_zigzag(v, 1 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 1 ,f,w,o,i); - }}else{ - remove_degree7_leftdelta(v, 5 ,f,w,o,i); - }}}else{ - if (! incircle(3,4,5,0,f,w,o,i)) { - if (incircle(4,0,1,3,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_rightfan(v, 4 ,f,w,o,i); - }else{ - remove_degree7_zigzag(v, 4 ,f,w,o,i); - }}else{ - remove_degree7_rightfan(v, 0 ,f,w,o,i); - }}else{ - remove_degree7_rightdelta(v, 3 ,f,w,o,i); - }}}else{ - remove_degree7_star(v, 3 ,f,w,o,i); - }}else{ - if (incircle(4,6,0,3,f,w,o,i)) { - if (incircle(4,0,1,3,f,w,o,i)) { - if (incircle(4,2,3,1,f,w,o,i)) { - remove_degree7_star(v, 4 ,f,w,o,i); - }else{ - remove_degree7_leftfan(v, 4 ,f,w,o,i); - }}else{ - remove_degree7_zigzag(v, 0 ,f,w,o,i); - }}else{ - if (incircle(4,5,6,3,f,w,o,i)) { - remove_degree7_rightfan(v, 3 ,f,w,o,i); - }else{ - remove_degree7_star(v, 3 ,f,w,o,i); - }}}}} + if (incircle(2, 0, 1, 3, f, w, o, i)) // sweeping from above + { + if (incircle(2, 3, 4, 0, f, w, o, i)) + { + if (incircle(5, 3, 4, 6, f, w, o, i)) + { + if (incircle(5, 3, 4, 2, f, w, o, i)) + { + if (incircle(6, 2, 3, 5, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_leftfan(v, 6 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 6 , f, w, o, i); + } + } + else + { + if (incircle(5, 0, 1, 2, f, w, o, i)) + { + if (incircle(6, 1, 2, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 2 , f, w, o, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 5 , f, w, o, i); + } + else + { + remove_degree7_star(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_zigzag(v, 2 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 2 , f, w, o, i); + } + } + else + { + remove_degree7_rightdelta(v, 5 , f, w, o, i); + } + } + } + } + else + { + if (incircle(4, 0, 1, 2, f, w, o, i)) + { + if (incircle(5, 1, 2, 4, f, w, o, i)) + { + if (incircle(6, 1, 2, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(5, 0, 1, 4, f, w, o, i)) + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 1 , f, w, o, i); + } + } + else + { + remove_degree7_rightfan(v, 4 , f, w, o, i); + } + } + } + else + { + if (incircle(2, 4, 5, 0, f, w, o, i)) + { + if (incircle(5, 0, 1, 2, f, w, o, i)) + { + if (incircle(6, 1, 2, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + remove_degree7_star(v, 2 , f, w, o, i); + } + } + else + { + remove_degree7_leftdelta(v, 2 , f, w, o, i); + } + } + } + else + { + remove_degree7_rightdelta(v, 0 , f, w, o, i); + } + } + } + } + else + { + if (incircle(6, 3, 4, 2, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_star(v, 6 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 6 , f, w, o, i); + } + } + else + { + if (incircle(4, 0, 1, 2, f, w, o, i)) + { + if (incircle(2, 4, 5, 6, f, w, o, i)) + { + if (incircle(5, 1, 2, 4, f, w, o, i)) + { + if (incircle(6, 1, 2, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(5, 0, 1, 4, f, w, o, i)) + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 1 , f, w, o, i); + } + } + else + { + remove_degree7_rightfan(v, 4 , f, w, o, i); + } + } + } + else + { + if (incircle(6, 1, 2, 4, f, w, o, i)) + { + remove_degree7_leftdelta(v, 6 , f, w, o, i); + } + else + { + if (incircle(1, 4, 5, 6, f, w, o, i)) + { + if (incircle(1, 4, 5, 0, f, w, o, i)) + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 1 , f, w, o, i); + } + } + else + { + remove_degree7_rightfan(v, 4 , f, w, o, i); + } + } + else + { + if (incircle(6, 0, 1, 4, f, w, o, i)) + { + remove_degree7_rightdelta(v, 4 , f, w, o, i); + } + else + { + if (incircle(6, 4, 5, 0, f, w, o, i)) + { + remove_degree7_star(v, 4 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 4 , f, w, o, i); + } + } + } + } + } + } + else + { + if (incircle(2, 4, 5, 6, f, w, o, i)) + { + if (incircle(2, 4, 5, 0, f, w, o, i)) + { + if (incircle(5, 0, 1, 2, f, w, o, i)) + { + if (incircle(6, 1, 2, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + remove_degree7_star(v, 2 , f, w, o, i); + } + } + else + { + remove_degree7_leftdelta(v, 2 , f, w, o, i); + } + } + } + else + { + remove_degree7_rightdelta(v, 0 , f, w, o, i); + } + } + else + { + if (incircle(2, 6, 0, 4, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_leftdelta(v, 6 , f, w, o, i); + } + else + { + remove_degree7_rightdelta(v, 2 , f, w, o, i); + } + } + else + { + if (incircle(6, 4, 5, 0, f, w, o, i)) + { + remove_degree7_leftdelta(v, 4 , f, w, o, i); + } + else + { + remove_degree7_rightdelta(v, 0 , f, w, o, i); + } + } + } + } + } + } + } + else + { + if (incircle(5, 3, 4, 6, f, w, o, i)) + { + if (incircle(5, 3, 4, 0, f, w, o, i)) + { + if (incircle(5, 2, 3, 0, f, w, o, i)) + { + if (incircle(6, 2, 3, 5, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_leftfan(v, 6 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 6 , f, w, o, i); + } + } + else if (incircle(5, 0, 1, 2, f, w, o, i)) + { + if (incircle(6, 1, 2, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 2 , f, w, o, i); + } + else + { + if (incircle(6, 0, 1, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 5 , f, w, o, i); + } + else + { + remove_degree7_star(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(2, 5, 6, 0, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_zigzag(v, 2 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 2 , f, w, o, i); + } + } + else + { + remove_degree7_rightdelta(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(3, 5, 6, 0, f, w, o, i)) + { + if (incircle(6, 2, 3, 0, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_leftfan(v, 6 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 6 , f, w, o, i); + } + } + else + { + remove_degree7_leftfan(v, 3 , f, w, o, i); + } + } + else + { + remove_degree7_leftdelta(v, 0 , f, w, o, i); + } + } + } + else + { + remove_degree7_star(v, 0 , f, w, o, i); + } + } + else + { + if (incircle(6, 3, 4, 0, f, w, o, i)) + { + if (incircle(6, 2, 3, 0, f, w, o, i)) + { + if (incircle(6, 0, 1, 2, f, w, o, i)) + { + remove_degree7_star(v, 6 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 6 , f, w, o, i); + } + } + else + { + remove_degree7_zigzag(v, 3 , f, w, o, i); + } + } + else + { + if (incircle(6, 4, 5, 0, f, w, o, i)) + { + remove_degree7_leftfan(v, 0 , f, w, o, i); + } + else + { + remove_degree7_star(v, 0 , f, w, o, i); + } + } + } + } + } + else //sweeping from below + { + if (incircle(1, 6, 0, 3, f, w, o, i)) + { + if (incircle(5, 6, 0, 4, f, w, o, i)) + { + if (incircle(5, 6, 0, 1, f, w, o, i)) + { + if (incircle(4, 0, 1, 5, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_rightfan(v, 4 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 4 , f, w, o, i); + } + } + else + { + if (incircle(5, 2, 3, 1, f, w, o, i)) + { + if (incircle(4, 1, 2, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 1 , f, w, o, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 5 , f, w, o, i); + } + else + { + remove_degree7_star(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_zigzag(v, 1 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 1 , f, w, o, i); + } + } + else + { + remove_degree7_leftdelta(v, 5 , f, w, o, i); + } + } + } + } + else + { + if (incircle(6, 2, 3, 1, f, w, o, i)) + { + if (incircle(5, 1, 2, 6, f, w, o, i)) + { + if (incircle(4, 1, 2, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(5, 2, 3, 6, f, w, o, i)) + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 2 , f, w, o, i); + } + } + else + { + remove_degree7_leftfan(v, 6 , f, w, o, i); + } + } + } + else + { + if (incircle(1, 5, 6, 3, f, w, o, i)) + { + if (incircle(5, 2, 3, 1, f, w, o, i)) + { + if (incircle(4, 1, 2, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + remove_degree7_star(v, 1 , f, w, o, i); + } + } + else + { + remove_degree7_rightdelta(v, 1 , f, w, o, i); + } + } + } + else + { + remove_degree7_leftdelta(v, 3 , f, w, o, i); + } + } + } + } + else + { + if (incircle(4, 6, 0, 1, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_star(v, 4 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 4 , f, w, o, i); + } + } + else + { + if (incircle(6, 2, 3, 1, f, w, o, i)) + { + if (incircle(1, 5, 6, 4, f, w, o, i)) + { + if (incircle(5, 1, 2, 6, f, w, o, i)) + { + if (incircle(4, 1, 2, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(5, 2, 3, 6, f, w, o, i)) + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 2 , f, w, o, i); + } + } + else + { + remove_degree7_leftfan(v, 6 , f, w, o, i); + } + } + } + else + { + if (incircle(4, 1, 2, 6, f, w, o, i)) + { + remove_degree7_rightdelta(v, 4 , f, w, o, i); + } + else + { + if (incircle(2, 5, 6, 4, f, w, o, i)) + { + if (incircle(2, 5, 6, 3, f, w, o, i)) + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 2 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 2 , f, w, o, i); + } + } + else + { + remove_degree7_leftfan(v, 6 , f, w, o, i); + } + } + else + { + if (incircle(4, 2, 3, 6, f, w, o, i)) + { + remove_degree7_leftdelta(v, 6 , f, w, o, i); + } + else + { + if (incircle(4, 5, 6, 3, f, w, o, i)) + { + remove_degree7_star(v, 6 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 6 , f, w, o, i); + } + } + } + } + } + } + else + { + if (incircle(1, 5, 6, 4, f, w, o, i)) + { + if (incircle(1, 5, 6, 3, f, w, o, i)) + { + if (incircle(5, 2, 3, 1, f, w, o, i)) + { + if (incircle(4, 1, 2, 5, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 5 , f, w, o, i); + } + else + { + remove_degree7_rightfan(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_rightfan(v, 1 , f, w, o, i); + } + else + { + remove_degree7_star(v, 1 , f, w, o, i); + } + } + else + { + remove_degree7_rightdelta(v, 1 , f, w, o, i); + } + } + } + else + { + remove_degree7_leftdelta(v, 3 , f, w, o, i); + } + } + else + { + if (incircle(1, 3, 4, 6, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_rightdelta(v, 4 , f, w, o, i); + } + else + { + remove_degree7_leftdelta(v, 1 , f, w, o, i); + } + } + else + { + if (incircle(4, 5, 6, 3, f, w, o, i)) + { + remove_degree7_rightdelta(v, 6 , f, w, o, i); + } + else + { + remove_degree7_leftdelta(v, 3 , f, w, o, i); + } + } + } + } + } + } + } + else + { + if (incircle(5, 6, 0, 4, f, w, o, i)) + { + if (incircle(5, 6, 0, 3, f, w, o, i)) + { + if (incircle(5, 0, 1, 3, f, w, o, i)) + { + if (incircle(4, 0, 1, 5, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_rightfan(v, 4 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 4 , f, w, o, i); + } + } + else if (incircle(5, 2, 3, 1, f, w, o, i)) + { + if (incircle(4, 1, 2, 5, f, w, o, i)) + { + remove_degree7_zigzag(v, 1 , f, w, o, i); + } + else + { + if (incircle(4, 2, 3, 5, f, w, o, i)) + { + remove_degree7_leftfan(v, 5 , f, w, o, i); + } + else + { + remove_degree7_star(v, 5 , f, w, o, i); + } + } + } + else + { + if (incircle(1, 4, 5, 3, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_zigzag(v, 1 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 1 , f, w, o, i); + } + } + else + { + remove_degree7_leftdelta(v, 5 , f, w, o, i); + } + } + } + else + { + if (! incircle(3, 4, 5, 0, f, w, o, i)) + { + if (incircle(4, 0, 1, 3, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_rightfan(v, 4 , f, w, o, i); + } + else + { + remove_degree7_zigzag(v, 4 , f, w, o, i); + } + } + else + { + remove_degree7_rightfan(v, 0 , f, w, o, i); + } + } + else + { + remove_degree7_rightdelta(v, 3 , f, w, o, i); + } + } + } + else + { + remove_degree7_star(v, 3 , f, w, o, i); + } + } + else + { + if (incircle(4, 6, 0, 3, f, w, o, i)) + { + if (incircle(4, 0, 1, 3, f, w, o, i)) + { + if (incircle(4, 2, 3, 1, f, w, o, i)) + { + remove_degree7_star(v, 4 , f, w, o, i); + } + else + { + remove_degree7_leftfan(v, 4 , f, w, o, i); + } + } + else + { + remove_degree7_zigzag(v, 0 , f, w, o, i); + } + } + else + { + if (incircle(4, 5, 6, 3, f, w, o, i)) + { + remove_degree7_rightfan(v, 3 , f, w, o, i); + } + else + { + remove_degree7_star(v, 3 , f, w, o, i); + } + } + } + } + } } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: rotate7(int j, std::vector &w, std::vector &f, std::vector &i) { - if (j==0) return; - Face_handle ff=f[0]; - int ii=i[0],k=0,kk=(6*j)%7; - Vertex_handle ww=w[0]; - for (int jj=0; k!=kk; jj=k) { // 7 is prime - k=(jj+j)%7; - w[jj]=w[k]; f[jj]=f[k]; i[jj]=i[k]; - } - w[kk]=ww;f[kk]=ff;i[kk]=ii; + if (j == 0) return; + Face_handle ff = f[0]; + int ii = i[0], k = 0, kk = (6 * j) % 7; + Vertex_handle ww = w[0]; + for (int jj = 0; k != kk; jj = k) // 7 is prime + { + k = (jj + j) % 7; + w[jj] = w[k]; + f[jj] = f[k]; + i[jj] = i[k]; + } + w[kk] = ww; + f[kk] = ff; + i[kk] = ii; } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: rotate7(int j, std::vector &w, std::vector &f, std::vector &o, std::vector &i) { - if (j==0) return; - Face_handle ff=f[0]; - int ii=i[0],k=0,kk=(6*j)%7; - Vertex_handle ww=w[0]; - Offset oo=o[0]; - for (int jj=0; k!=kk; jj=k) { // 7 is prime - k=(jj+j)%7; - w[jj]=w[k]; f[jj]=f[k]; o[jj] = o[k]; i[jj]=i[k]; - } - w[kk]=ww;f[kk]=ff;o[kk]=oo;i[kk]=ii; + if (j == 0) return; + Face_handle ff = f[0]; + int ii = i[0], k = 0, kk = (6 * j) % 7; + Vertex_handle ww = w[0]; + Offset oo = o[0]; + for (int jj = 0; k != kk; jj = k) // 7 is prime + { + k = (jj + j) % 7; + w[jj] = w[k]; + f[jj] = f[k]; + o[jj] = o[k]; + i[jj] = i[k]; + } + w[kk] = ww; + f[kk] = ff; + o[kk] = oo; + i[kk] = ii; } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: -get_offset_degree7(std::vector &in_o, int out_o[]) { +Periodic_2_Delaunay_triangulation_2:: +get_offset_degree7(std::vector &in_o, int out_o[]) +{ bool add[2]; - + add[0] = add[1] = false; - for (int cnt=0; cnt<7; ++cnt) { - add[0] |= in_o[cnt].x() < 0; - add[1] |= in_o[cnt].y() < 0; - } + for (int cnt = 0; cnt < 7; ++cnt) + { + add[0] |= in_o[cnt].x() < 0; + add[1] |= in_o[cnt].y() < 0; + } Covering_sheets c = number_of_sheets(); - if (add[0] || add[1]) { - const Offset oo = Offset(add[0]?c[0]:0, add[1]?c[1]:0); - for (int i=0; i<7; ++i) in_o[i] += oo; - } + if (add[0] || add[1]) + { + const Offset oo = Offset(add[0] ? c[0] : 0, add[1] ? c[1] : 0); + for (int i = 0; i < 7; ++i) in_o[i] += oo; + } - for (int cnt=0; cnt<7; ++cnt) + for (int cnt = 0; cnt < 7; ++cnt) out_o[cnt] = (in_o[cnt].x() >= c[0] ? 2 : 0) + (in_o[cnt].y() >= c[1] ? 1 : 0); } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_star (Vertex_handle &, int j, -std::vector &f, std::vector &w, std::vector &i) -{ // removing a degree 7 vertex, staring from w[j] - rotate7(j,w,f,i); - + std::vector &f, std::vector &w, std::vector &i) +{ + // removing a degree 7 vertex, staring from w[j] + rotate7(j, w, f, i); + Face_handle nn; f[1]->set_vertex( i[1], w[0]) ; // f1 = w1w2w0 f[2]->set_vertex( i[2], w[0]) ; // f2 = w2w3w0 @@ -3088,7 +4469,7 @@ std::vector &f, std::vector &w, std::vector &i) tds().set_adjacency(f[5], ccw(i[5]) , nn , nn->index(f[6]) ); tds().delete_face(f[0]); tds().delete_face(f[6]); - + f[1]->set_offsets(0, 0, 0); f[2]->set_offsets(0, 0, 0); @@ -3098,29 +4479,46 @@ std::vector &f, std::vector &w, std::vector &i) } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_star (Vertex_handle &v, int j, -std::vector &f, std::vector &w, std::vector &o, std::vector &i) -{ // removing a degree 7 vertex, staring from w[j] + std::vector &f, std::vector &w, std::vector &o, std::vector &i) +{ + // removing a degree 7 vertex, staring from w[j] // Rotate the offset as well - rotate7(j,w,f,o,i); + rotate7(j, w, f, o, i); remove_degree7_star(v, /* !! */ 0, f, w, i); - + int oo[7]; get_offset_degree7(o, oo); - int o_face[3]; int ii; - ii = i[1]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[1]; o_face[ cw(ii)] = oo[2]; + int o_face[3]; + int ii; + ii = i[1]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[1]; + o_face[ cw(ii)] = oo[2]; this->set_offsets(f[1], o_face[0], o_face[1], o_face[2]); - ii = i[2]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[2]; o_face[ cw(ii)] = oo[3]; + ii = i[2]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[2]; + o_face[ cw(ii)] = oo[3]; this->set_offsets(f[2], o_face[0], o_face[1], o_face[2]); - ii = i[3]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[3]; o_face[ cw(ii)] = oo[4]; + ii = i[3]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[3]; + o_face[ cw(ii)] = oo[4]; this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); - ii = i[4]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[4]; o_face[ cw(ii)] = oo[5]; + ii = i[4]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[4]; + o_face[ cw(ii)] = oo[5]; this->set_offsets(f[4], o_face[0], o_face[1], o_face[2]); - ii = i[5]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[5]; o_face[ cw(ii)] = oo[6]; + ii = i[5]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[5]; + o_face[ cw(ii)] = oo[6]; this->set_offsets(f[5], o_face[0], o_face[1], o_face[2]); - + insert_too_long_edge(f[1], ccw(i[1])); insert_too_long_edge(f[2], ccw(i[2])); insert_too_long_edge(f[3], ccw(i[3])); @@ -3128,11 +4526,12 @@ std::vector &f, std::vector &w, std::vector } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_zigzag (Vertex_handle &, int j, - std::vector &f,std::vector &w, std::vector &i) -{ // removing a degree 7 vertex, zigzag, w[j] = middle point - rotate7(j,w,f,i); + std::vector &f, std::vector &w, std::vector &i) +{ + // removing a degree 7 vertex, zigzag, w[j] = middle point + rotate7(j, w, f, i); Face_handle nn; f[1]->set_vertex( i[1] , w[3]) ; // f1 = w1w2w3 @@ -3166,29 +4565,46 @@ remove_degree7_zigzag (Vertex_handle &, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_zigzag (Vertex_handle &v, int j, - std::vector &f,std::vector &w, std::vector &o, std::vector &i) -{ // removing a degree 7 vertex, zigzag, w[j] = middle point + std::vector &f, std::vector &w, std::vector &o, std::vector &i) +{ + // removing a degree 7 vertex, zigzag, w[j] = middle point // Rotate the offset as well - rotate7(j,w,f,o,i); + rotate7(j, w, f, o, i); remove_degree7_zigzag(v, /* !! */ 0, f, w, i); int oo[7]; get_offset_degree7(o, oo); - int o_face[3]; int ii; - ii = i[1]; o_face[ii] = oo[3]; o_face[ccw(ii)] = oo[1]; o_face[ cw(ii)] = oo[2]; + int o_face[3]; + int ii; + ii = i[1]; + o_face[ii] = oo[3]; + o_face[ccw(ii)] = oo[1]; + o_face[ cw(ii)] = oo[2]; this->set_offsets(f[1], o_face[0], o_face[1], o_face[2]); - ii = i[2]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[1]; o_face[ cw(ii)] = oo[3]; + ii = i[2]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[1]; + o_face[ cw(ii)] = oo[3]; this->set_offsets(f[2], o_face[0], o_face[1], o_face[2]); - ii = i[3]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[3]; o_face[ cw(ii)] = oo[4]; + ii = i[3]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[3]; + o_face[ cw(ii)] = oo[4]; this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); - ii = i[4]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[4]; o_face[ cw(ii)] = oo[6]; + ii = i[4]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[4]; + o_face[ cw(ii)] = oo[6]; this->set_offsets(f[4], o_face[0], o_face[1], o_face[2]); - ii = i[5]; o_face[ii] = oo[4]; o_face[ccw(ii)] = oo[5]; o_face[ cw(ii)] = oo[6]; + ii = i[5]; + o_face[ii] = oo[4]; + o_face[ccw(ii)] = oo[5]; + o_face[ cw(ii)] = oo[6]; this->set_offsets(f[5], o_face[0], o_face[1], o_face[2]); - + insert_too_long_edge(f[1], cw(i[1])); insert_too_long_edge(f[2], ccw(i[2])); insert_too_long_edge(f[3], ccw(i[3])); @@ -3196,11 +4612,12 @@ remove_degree7_zigzag (Vertex_handle &v, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_leftdelta(Vertex_handle &, int j, - std::vector &f,std::vector &w, std::vector &i) -{ // removing a degree 7 vertex, left delta from w[j] - rotate7(j,w,f,i); + std::vector &f, std::vector &w, std::vector &i) +{ + // removing a degree 7 vertex, left delta from w[j] + rotate7(j, w, f, i); Face_handle nn; f[1]->set_vertex( i[1] , w[0]) ; // f1 = w1w2w0 @@ -3230,30 +4647,47 @@ remove_degree7_leftdelta(Vertex_handle &, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_leftdelta(Vertex_handle &v, int j, - std::vector &f,std::vector &w, std::vector &o, std::vector &i) -{ // removing a degree 7 vertex, left delta from w[j] + std::vector &f, std::vector &w, std::vector &o, std::vector &i) +{ + // removing a degree 7 vertex, left delta from w[j] // Rotate the offset as well - rotate7(j,w,f,o,i); + rotate7(j, w, f, o, i); remove_degree7_leftdelta(v, /* !! */ 0, f, w, i); int oo[7]; get_offset_degree7(o, oo); - int o_face[3]; int ii; - ii = i[1]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[1]; o_face[ cw(ii)] = oo[2]; + int o_face[3]; + int ii; + ii = i[1]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[1]; + o_face[ cw(ii)] = oo[2]; this->set_offsets(f[1], o_face[0], o_face[1], o_face[2]); - ii = i[2]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[2]; o_face[ cw(ii)] = oo[3]; + ii = i[2]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[2]; + o_face[ cw(ii)] = oo[3]; this->set_offsets(f[2], o_face[0], o_face[1], o_face[2]); - ii = i[3]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[3]; o_face[ cw(ii)] = oo[5]; + ii = i[3]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[3]; + o_face[ cw(ii)] = oo[5]; this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); - ii = i[4]; o_face[ii] = oo[3]; o_face[ccw(ii)] = oo[4]; o_face[ cw(ii)] = oo[5]; + ii = i[4]; + o_face[ii] = oo[3]; + o_face[ccw(ii)] = oo[4]; + o_face[ cw(ii)] = oo[5]; this->set_offsets(f[4], o_face[0], o_face[1], o_face[2]); - ii = i[5]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[5]; o_face[ cw(ii)] = oo[6]; + ii = i[5]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[5]; + o_face[ cw(ii)] = oo[6]; this->set_offsets(f[5], o_face[0], o_face[1], o_face[2]); - + insert_too_long_edge(f[1], ccw(i[1])); insert_too_long_edge(f[2], ccw(i[2])); insert_too_long_edge(f[3], i[3]); @@ -3261,11 +4695,12 @@ remove_degree7_leftdelta(Vertex_handle &v, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_rightdelta(Vertex_handle &, int j, - std::vector &f,std::vector &w, std::vector &i) -{ // removing a degree 7 vertex, right delta from w[j] - rotate7(j,w,f,i); + std::vector &f, std::vector &w, std::vector &i) +{ + // removing a degree 7 vertex, right delta from w[j] + rotate7(j, w, f, i); Face_handle nn; f[1]->set_vertex( i[1] , w[0]) ; // f1 = w1w2w0 @@ -3295,29 +4730,46 @@ remove_degree7_rightdelta(Vertex_handle &, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_rightdelta(Vertex_handle &v, int j, - std::vector &f,std::vector &w, std::vector &o, std::vector &i) -{ // removing a degree 7 vertex, right delta from w[j] + std::vector &f, std::vector &w, std::vector &o, std::vector &i) +{ + // removing a degree 7 vertex, right delta from w[j] // Rotate the offset as well - rotate7(j,w,f,o,i); + rotate7(j, w, f, o, i); remove_degree7_rightdelta(v, /* !! */ 0, f, w, i); int oo[7]; get_offset_degree7(o, oo); - int o_face[3]; int ii; - ii = i[1]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[1]; o_face[ cw(ii)] = oo[2]; + int o_face[3]; + int ii; + ii = i[1]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[1]; + o_face[ cw(ii)] = oo[2]; this->set_offsets(f[1], o_face[0], o_face[1], o_face[2]); - ii = i[2]; o_face[ii] = oo[4]; o_face[ccw(ii)] = oo[2]; o_face[ cw(ii)] = oo[3]; + ii = i[2]; + o_face[ii] = oo[4]; + o_face[ccw(ii)] = oo[2]; + o_face[ cw(ii)] = oo[3]; this->set_offsets(f[2], o_face[0], o_face[1], o_face[2]); - ii = i[3]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[2]; o_face[ cw(ii)] = oo[4]; + ii = i[3]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[2]; + o_face[ cw(ii)] = oo[4]; this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); - ii = i[4]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[4]; o_face[ cw(ii)] = oo[5]; + ii = i[4]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[4]; + o_face[ cw(ii)] = oo[5]; this->set_offsets(f[4], o_face[0], o_face[1], o_face[2]); - ii = i[5]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[5]; o_face[ cw(ii)] = oo[6]; + ii = i[5]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[5]; + o_face[ cw(ii)] = oo[6]; this->set_offsets(f[5], o_face[0], o_face[1], o_face[2]); - + insert_too_long_edge(f[1], ccw(i[1])); insert_too_long_edge(f[2], cw(i[2])); insert_too_long_edge(f[3], ccw(i[3])); @@ -3325,11 +4777,12 @@ remove_degree7_rightdelta(Vertex_handle &v, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_leftfan(Vertex_handle &, int j, - std::vector &f,std::vector &w, std::vector &i) -{ // removing a degree 7 vertex, left fan from w[j] - rotate7(j,w,f,i); + std::vector &f, std::vector &w, std::vector &i) +{ + // removing a degree 7 vertex, left fan from w[j] + rotate7(j, w, f, i); Face_handle nn; f[1]->set_vertex( i[1] , w[0]) ; // f1 = w1w2w0 @@ -3356,30 +4809,47 @@ remove_degree7_leftfan(Vertex_handle &, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_leftfan(Vertex_handle &v, int j, - std::vector &f,std::vector &w, std::vector &o, std::vector &i) -{ // removing a degree 7 vertex, left fan from w[j] + std::vector &f, std::vector &w, std::vector &o, std::vector &i) +{ + // removing a degree 7 vertex, left fan from w[j] // Rotate the offset as well - rotate7(j,w,f,o,i); + rotate7(j, w, f, o, i); remove_degree7_leftfan(v, /* !! */ 0, f, w, i); int oo[7]; get_offset_degree7(o, oo); - int o_face[3]; int ii; - ii = i[1]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[1]; o_face[ cw(ii)] = oo[2]; + int o_face[3]; + int ii; + ii = i[1]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[1]; + o_face[ cw(ii)] = oo[2]; this->set_offsets(f[1], o_face[0], o_face[1], o_face[2]); - ii = i[2]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[2]; o_face[ cw(ii)] = oo[3]; + ii = i[2]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[2]; + o_face[ cw(ii)] = oo[3]; this->set_offsets(f[2], o_face[0], o_face[1], o_face[2]); - ii = i[3]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[3]; o_face[ cw(ii)] = oo[4]; + ii = i[3]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[3]; + o_face[ cw(ii)] = oo[4]; this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); - ii = i[4]; o_face[ii] = oo[6]; o_face[ccw(ii)] = oo[4]; o_face[ cw(ii)] = oo[5]; + ii = i[4]; + o_face[ii] = oo[6]; + o_face[ccw(ii)] = oo[4]; + o_face[ cw(ii)] = oo[5]; this->set_offsets(f[4], o_face[0], o_face[1], o_face[2]); - ii = i[6]; o_face[ii] = oo[4]; o_face[ccw(ii)] = oo[6]; o_face[ cw(ii)] = oo[0]; + ii = i[6]; + o_face[ii] = oo[4]; + o_face[ccw(ii)] = oo[6]; + o_face[ cw(ii)] = oo[0]; this->set_offsets(f[6], o_face[0], o_face[1], o_face[2]); - + insert_too_long_edge(f[1], ccw(i[1])); insert_too_long_edge(f[2], ccw(i[2])); insert_too_long_edge(f[3], ccw(i[3])); @@ -3387,11 +4857,12 @@ remove_degree7_leftfan(Vertex_handle &v, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_rightfan(Vertex_handle &, int j, - std::vector &f,std::vector &w, std::vector &i) -{ // removing a degree 7 vertex, right fan from w[j] - rotate7(j,w,f,i); + std::vector &f, std::vector &w, std::vector &i) +{ + // removing a degree 7 vertex, right fan from w[j] + rotate7(j, w, f, i); Face_handle nn; f[0]->set_vertex( i[0] , w[3]) ; // f0 = w0w1w3 @@ -3418,29 +4889,46 @@ remove_degree7_rightfan(Vertex_handle &, int j, } template < class Gt, class Tds > void -Periodic_2_Delaunay_triangulation_2:: +Periodic_2_Delaunay_triangulation_2:: remove_degree7_rightfan(Vertex_handle &v, int j, - std::vector &f,std::vector &w, std::vector &o, std::vector &i) -{ // removing a degree 7 vertex, right fan from w[j] + std::vector &f, std::vector &w, std::vector &o, std::vector &i) +{ + // removing a degree 7 vertex, right fan from w[j] // Rotate the offset as well - rotate7(j,w,f,o,i); + rotate7(j, w, f, o, i); remove_degree7_rightfan(v, /* !! */ 0, f, w, i); int oo[7]; get_offset_degree7(o, oo); - int o_face[3]; int ii; - ii = i[0]; o_face[ii] = oo[3]; o_face[ccw(ii)] = oo[0]; o_face[ cw(ii)] = oo[1]; + int o_face[3]; + int ii; + ii = i[0]; + o_face[ii] = oo[3]; + o_face[ccw(ii)] = oo[0]; + o_face[ cw(ii)] = oo[1]; this->set_offsets(f[0], o_face[0], o_face[1], o_face[2]); - ii = i[2]; o_face[ii] = oo[1]; o_face[ccw(ii)] = oo[2]; o_face[ cw(ii)] = oo[3]; + ii = i[2]; + o_face[ii] = oo[1]; + o_face[ccw(ii)] = oo[2]; + o_face[ cw(ii)] = oo[3]; this->set_offsets(f[2], o_face[0], o_face[1], o_face[2]); - ii = i[3]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[3]; o_face[ cw(ii)] = oo[4]; + ii = i[3]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[3]; + o_face[ cw(ii)] = oo[4]; this->set_offsets(f[3], o_face[0], o_face[1], o_face[2]); - ii = i[4]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[4]; o_face[ cw(ii)] = oo[5]; + ii = i[4]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[4]; + o_face[ cw(ii)] = oo[5]; this->set_offsets(f[4], o_face[0], o_face[1], o_face[2]); - ii = i[5]; o_face[ii] = oo[0]; o_face[ccw(ii)] = oo[5]; o_face[ cw(ii)] = oo[6]; + ii = i[5]; + o_face[ii] = oo[0]; + o_face[ccw(ii)] = oo[5]; + o_face[ cw(ii)] = oo[6]; this->set_offsets(f[5], o_face[0], o_face[1], o_face[2]); - + insert_too_long_edge(f[0], ccw(i[0])); insert_too_long_edge(f[0], cw(i[0])); insert_too_long_edge(f[3], ccw(i[3])); @@ -3454,9 +4942,10 @@ remove_degree7_rightfan(Vertex_handle &v, int j, // DISPLACEMENT template -typename Periodic_2_Delaunay_triangulation_2::Vertex_handle -Periodic_2_Delaunay_triangulation_2:: -move_if_no_collision(Vertex_handle v, const Point &p) { +typename Periodic_2_Delaunay_triangulation_2::Vertex_handle +Periodic_2_Delaunay_triangulation_2:: +move_if_no_collision(Vertex_handle v, const Point &p) +{ Locate_type lt; int li; Vertex_handle inserted; @@ -3464,26 +4953,29 @@ move_if_no_collision(Vertex_handle v, const Point &p) { if (lt == Triangulation::VERTEX) return v; - else + else /// This can be optimized by checking whether we can move v->point() to p return insert(p, lt, loc, li); } template -typename Periodic_2_Delaunay_triangulation_2::Vertex_handle -Periodic_2_Delaunay_triangulation_2:: -move_point(Vertex_handle v, const Point &p) { +typename Periodic_2_Delaunay_triangulation_2::Vertex_handle +Periodic_2_Delaunay_triangulation_2:: +move_point(Vertex_handle v, const Point &p) +{ if(v->point() == p) return v; - Vertex_handle w = move_if_no_collision(v,p); - if(w != v) { - remove(v); - return w; - } + Vertex_handle w = move_if_no_collision(v, p); + if(w != v) + { + remove(v); + return w; + } return v; } template -void Periodic_2_Delaunay_triangulation_2::fill_hole_delaunay(std::list & first_hole) { +void Periodic_2_Delaunay_triangulation_2::fill_hole_delaunay(std::list & first_hole) +{ typedef std::list Hole; typedef std::list Hole_list; @@ -3495,130 +4987,146 @@ void Periodic_2_Delaunay_triangulation_2::fill_hole_delaunay(std::list< hole_list.push_front(first_hole); while( ! hole_list.empty()) - { - hole = hole_list.front(); - hole_list.pop_front(); - typename Hole::iterator hit = hole.begin(); + { + hole = hole_list.front(); + hole_list.pop_front(); + typename Hole::iterator hit = hole.begin(); - // if the hole has only three edges, create the triangle - if (hole.size() == 3) { - hit = hole.begin(); - f = (*hit).first; i = (*hit).second; - ff = (* ++hit).first; ii = (*hit).second; - fn = (* ++hit).first; in = (*hit).second; - Face_handle newf = create_face(f,i,ff,ii,fn,in); - newf->set_offsets(0,0,0); - - continue; - } - - // else find an edge with two finite vertices - // on the hole boundary - // and the new triangle adjacent to that edge - // cut the hole and push it back - - // take the first neighboring face and pop it; - ff = (hole.front()).first; - ii =(hole.front()).second; - hole.pop_front(); - - Vertex_handle v0 = ff->vertex(cw(ii)); - Vertex_handle v1 = ff->vertex(ccw(ii)); - Vertex_handle v2 = Vertex_handle(); - Vertex_handle v3 = Vertex_handle(); - const Point& p0 = v0->point(); - const Point& p1 = v1->point(); - - typename Hole::iterator hdone = hole.end(); - hit = hole.begin(); - typename Hole::iterator cut_after(hit); - - // if tested vertex is c with respect to the vertex opposite - // to NULL neighbor, - // stop at the before last face; - hdone--; - while( hit != hdone) { - fn = (*hit).first; - in = (*hit).second; - Vertex_handle vv = fn->vertex(ccw(in)); - - const Point &p = vv->point(); - Orientation orient = orientation(p0,p1,p); - - if (orient == COUNTERCLOCKWISE) { - if (v2 == Vertex_handle()) { - v2=vv; - v3=vv; - cut_after=hit; - } else { - Oriented_side side = side_of_oriented_circle(p0,p1,v3->point(),p,true); - if (side == ON_POSITIVE_SIDE) { - v2=vv; - v3=vv; - cut_after=hit; - } - } - } - - ++hit; - } - - // create new triangle and update adjacency relations - Face_handle newf; - - //update the hole and push back in the Hole_List stack - // if v2 belongs to the neighbor following or preceding *f - // the hole remain a single hole - // otherwise it is split in two holes - - fn = (hole.front()).first; - in = (hole.front()).second; - if (fn->has_vertex(v2, i) && i == fn->ccw(in)) { - newf = create_face(ff,ii,fn,in); - - newf->set_offsets(0,0,0); - - hole.pop_front(); - hole.push_front(Edge(newf,1)); - hole_list.push_front(hole); - } - else{ - fn = (hole.back()).first; - in = (hole.back()).second; - if (fn->has_vertex(v2, i) && i== fn->cw(in)) { - newf = create_face(fn,in,ff,ii); - newf->set_offsets(0,0,0); - - hole.pop_back(); - hole.push_back(Edge(newf,1)); - hole_list.push_front(hole); - } else { - // split the hole in two holes - CGAL_assertion(v2 != Vertex_handle()); - newf = create_face(ff,ii,v2); - newf->set_offsets(0,0,0); - - Hole new_hole; - ++cut_after; - while( hole.begin() != cut_after ) + // if the hole has only three edges, create the triangle + if (hole.size() == 3) { - new_hole.push_back(hole.front()); - hole.pop_front(); + hit = hole.begin(); + f = (*hit).first; + i = (*hit).second; + ff = (* ++hit).first; + ii = (*hit).second; + fn = (* ++hit).first; + in = (*hit).second; + Face_handle newf = create_face(f, i, ff, ii, fn, in); + newf->set_offsets(0, 0, 0); + + continue; } - hole.push_front(Edge( newf,1)); - new_hole.push_front(Edge( newf,0)); - hole_list.push_front(hole); - hole_list.push_front(new_hole); - } + // else find an edge with two finite vertices + // on the hole boundary + // and the new triangle adjacent to that edge + // cut the hole and push it back + + // take the first neighboring face and pop it; + ff = (hole.front()).first; + ii = (hole.front()).second; + hole.pop_front(); + + Vertex_handle v0 = ff->vertex(cw(ii)); + Vertex_handle v1 = ff->vertex(ccw(ii)); + Vertex_handle v2 = Vertex_handle(); + Vertex_handle v3 = Vertex_handle(); + const Point& p0 = v0->point(); + const Point& p1 = v1->point(); + + typename Hole::iterator hdone = hole.end(); + hit = hole.begin(); + typename Hole::iterator cut_after(hit); + + // if tested vertex is c with respect to the vertex opposite + // to NULL neighbor, + // stop at the before last face; + hdone--; + while( hit != hdone) + { + fn = (*hit).first; + in = (*hit).second; + Vertex_handle vv = fn->vertex(ccw(in)); + + const Point &p = vv->point(); + Orientation orient = orientation(p0, p1, p); + + if (orient == COUNTERCLOCKWISE) + { + if (v2 == Vertex_handle()) + { + v2 = vv; + v3 = vv; + cut_after = hit; + } + else + { + Oriented_side side = side_of_oriented_circle(p0, p1, v3->point(), p, true); + if (side == ON_POSITIVE_SIDE) + { + v2 = vv; + v3 = vv; + cut_after = hit; + } + } + } + + ++hit; + } + + // create new triangle and update adjacency relations + Face_handle newf; + + //update the hole and push back in the Hole_List stack + // if v2 belongs to the neighbor following or preceding *f + // the hole remain a single hole + // otherwise it is split in two holes + + fn = (hole.front()).first; + in = (hole.front()).second; + if (fn->has_vertex(v2, i) && i == fn->ccw(in)) + { + newf = create_face(ff, ii, fn, in); + + newf->set_offsets(0, 0, 0); + + hole.pop_front(); + hole.push_front(Edge(newf, 1)); + hole_list.push_front(hole); + } + else + { + fn = (hole.back()).first; + in = (hole.back()).second; + if (fn->has_vertex(v2, i) && i == fn->cw(in)) + { + newf = create_face(fn, in, ff, ii); + newf->set_offsets(0, 0, 0); + + hole.pop_back(); + hole.push_back(Edge(newf, 1)); + hole_list.push_front(hole); + } + else + { + // split the hole in two holes + CGAL_assertion(v2 != Vertex_handle()); + newf = create_face(ff, ii, v2); + newf->set_offsets(0, 0, 0); + + Hole new_hole; + ++cut_after; + while( hole.begin() != cut_after ) + { + new_hole.push_back(hole.front()); + hole.pop_front(); + } + + hole.push_front(Edge( newf, 1)); + new_hole.push_front(Edge( newf, 0)); + hole_list.push_front(hole); + hole_list.push_front(new_hole); + } + } } - } } template void Periodic_2_Delaunay_triangulation_2::fill_hole_delaunay( - std::list & first_hole, - std::map &vertex_offsets) { + std::list & first_hole, + std::map &vertex_offsets) +{ typedef std::list Hole; typedef std::list Hole_list; @@ -3630,203 +5138,242 @@ void Periodic_2_Delaunay_triangulation_2::fill_hole_delaunay( hole_list.push_front(first_hole); while( ! hole_list.empty()) - { - hole = hole_list.front(); - hole_list.pop_front(); - typename Hole::iterator hit = hole.begin(); + { + hole = hole_list.front(); + hole_list.pop_front(); + typename Hole::iterator hit = hole.begin(); - // if the hole has only three edges, create the triangle - if (hole.size() == 3) { - hit = hole.begin(); - f = (*hit).first; i = (*hit).second; - ff = (* ++hit).first; ii = (*hit).second; - fn = (* ++hit).first; in = (*hit).second; - Face_handle newf = create_face(f,i,ff,ii,fn,in); - Offset oo0(vertex_offsets[newf->vertex(0)]); - Offset oo1(vertex_offsets[newf->vertex(1)]); - Offset oo2(vertex_offsets[newf->vertex(2)]); - if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) { - oo0 += Offset(number_of_sheets()[0], 0); oo1 += Offset(number_of_sheets()[0], 0); oo2 += Offset(number_of_sheets()[0], 0); - } - if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) { - oo0 += Offset(0, number_of_sheets()[1]); oo1 += Offset(0, number_of_sheets()[1]); oo2 += Offset(0, number_of_sheets()[1]); - } - set_offsets(newf, - (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), - (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0), - (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0)); - - insert_too_long_edge(newf, 0); - insert_too_long_edge(newf, 1); - insert_too_long_edge(newf, 2); - - continue; - } - - // else find an edge with two finite vertices - // on the hole boundary - // and the new triangle adjacent to that edge - // cut the hole and push it back - - // take the first neighboring face and pop it; - ff = (hole.front()).first; - ii =(hole.front()).second; - hole.pop_front(); - - Vertex_handle v0 = ff->vertex(cw(ii)); - Vertex_handle v1 = ff->vertex(ccw(ii)); - Vertex_handle v2 = Vertex_handle(); - Vertex_handle v3 = Vertex_handle(); - const Point& p0 = v0->point(); - const Point& p1 = v1->point(); - const Offset o0 = vertex_offsets[v0]; - const Offset o1 = vertex_offsets[v1]; - bool simplicity_criterion = (o0 == o1); - - typename Hole::iterator hdone = hole.end(); - hit = hole.begin(); - typename Hole::iterator cut_after(hit); - - // if tested vertex is c with respect to the vertex opposite - // to NULL neighbor, - // stop at the before last face; - hdone--; - while( hit != hdone) { - fn = (*hit).first; - in = (*hit).second; - Vertex_handle vv = fn->vertex(ccw(in)); - - const Point &p = vv->point(); - CGAL_assertion(vertex_offsets.find(vv) != vertex_offsets.end()); - const Offset o = vertex_offsets[vv]; - Orientation orient; - simplicity_criterion &= (o == o0); - if (simplicity_criterion) - orient = orientation(p0,p1,p); - else - orient = orientation(p0,p1,p, o0,o1,o); - - if (orient == COUNTERCLOCKWISE) { - if (v2 == Vertex_handle()) { - v2=vv; - v3=vv; - cut_after=hit; - } else { - Offset o3 = vertex_offsets[v3]; - Oriented_side side; - if (simplicity_criterion && (o3 == o0)) - side = side_of_oriented_circle(p0,p1,v3->point(),p, - true); - else - side = side_of_oriented_circle(p0,p1,v3->point(),p, - o0,o1,o3,o, - true); - if (side == ON_POSITIVE_SIDE) { - v2=vv; - v3=vv; - cut_after=hit; - } - } - } - - ++hit; - } - - // create new triangle and update adjacency relations - Face_handle newf; - - //update the hole and push back in the Hole_List stack - // if v2 belongs to the neighbor following or preceding *f - // the hole remain a single hole - // otherwise it is split in two holes - - fn = (hole.front()).first; - in = (hole.front()).second; - if (fn->has_vertex(v2, i) && i == fn->ccw(in)) { - newf = create_face(ff,ii,fn,in); - - Offset oo0 = o0; - Offset oo1 = o1; - Offset oo2 = vertex_offsets[v2]; - if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) { - oo0 += Offset(number_of_sheets()[0], 0); oo1 += Offset(number_of_sheets()[0], 0); oo2 += Offset(number_of_sheets()[0], 0); - } - if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) { - oo0 += Offset(0, number_of_sheets()[1]); oo1 += Offset(0, number_of_sheets()[1]); oo2 += Offset(0, number_of_sheets()[1]); - } - set_offsets(newf, - (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), - (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0), - (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0)); - // set_offsets(newf, o0, o1, o2); - insert_too_long_edge(newf, 0); - insert_too_long_edge(newf, 1); - - hole.pop_front(); - hole.push_front(Edge(newf,1)); - hole_list.push_front(hole); - } - else{ - fn = (hole.back()).first; - in = (hole.back()).second; - if (fn->has_vertex(v2, i) && i== fn->cw(in)) { - newf = create_face(fn,in,ff,ii); - Offset oo0 = o0; - Offset oo1 = o1; - Offset oo2 = vertex_offsets[v2]; - if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) { - oo0 += Offset(number_of_sheets()[0], 0); oo1 += Offset(number_of_sheets()[0], 0); oo2 += Offset(number_of_sheets()[0], 0); - } - if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) { - oo0 += Offset(0, number_of_sheets()[1]); oo1 += Offset(0, number_of_sheets()[1]); oo2 += Offset(0, number_of_sheets()[1]); - } - set_offsets(newf, - (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0), - (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), - (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0)); - insert_too_long_edge(newf, 1); - insert_too_long_edge(newf, 2); - hole.pop_back(); - hole.push_back(Edge(newf,1)); - hole_list.push_front(hole); - } else { - // split the hole in two holes - CGAL_assertion(v2 != Vertex_handle()); - newf = create_face(ff,ii,v2); - Offset oo0 = o0; - Offset oo1 = o1; - Offset oo2 = vertex_offsets[v2]; - if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) { - oo0 += Offset(number_of_sheets()[0], 0); oo1 += Offset(number_of_sheets()[0], 0); oo2 += Offset(number_of_sheets()[0], 0); - } - if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) { - oo0 += Offset(0, number_of_sheets()[1]); oo1 += Offset(0, number_of_sheets()[1]); oo2 += Offset(0, number_of_sheets()[1]); - } - set_offsets(newf, - (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), - (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0), - (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0)); - - - // set_offsets(newf, o0, o1, o2); - insert_too_long_edge(newf, 0); - insert_too_long_edge(newf, 1); - - Hole new_hole; - ++cut_after; - while( hole.begin() != cut_after ) + // if the hole has only three edges, create the triangle + if (hole.size() == 3) { - new_hole.push_back(hole.front()); - hole.pop_front(); + hit = hole.begin(); + f = (*hit).first; + i = (*hit).second; + ff = (* ++hit).first; + ii = (*hit).second; + fn = (* ++hit).first; + in = (*hit).second; + Face_handle newf = create_face(f, i, ff, ii, fn, in); + Offset oo0(vertex_offsets[newf->vertex(0)]); + Offset oo1(vertex_offsets[newf->vertex(1)]); + Offset oo2(vertex_offsets[newf->vertex(2)]); + if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) + { + oo0 += Offset(number_of_sheets()[0], 0); + oo1 += Offset(number_of_sheets()[0], 0); + oo2 += Offset(number_of_sheets()[0], 0); + } + if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) + { + oo0 += Offset(0, number_of_sheets()[1]); + oo1 += Offset(0, number_of_sheets()[1]); + oo2 += Offset(0, number_of_sheets()[1]); + } + set_offsets(newf, + (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), + (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0), + (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0)); + + insert_too_long_edge(newf, 0); + insert_too_long_edge(newf, 1); + insert_too_long_edge(newf, 2); + + continue; } - hole.push_front(Edge( newf,1)); - new_hole.push_front(Edge( newf,0)); - hole_list.push_front(hole); - hole_list.push_front(new_hole); - } + // else find an edge with two finite vertices + // on the hole boundary + // and the new triangle adjacent to that edge + // cut the hole and push it back + + // take the first neighboring face and pop it; + ff = (hole.front()).first; + ii = (hole.front()).second; + hole.pop_front(); + + Vertex_handle v0 = ff->vertex(cw(ii)); + Vertex_handle v1 = ff->vertex(ccw(ii)); + Vertex_handle v2 = Vertex_handle(); + Vertex_handle v3 = Vertex_handle(); + const Point& p0 = v0->point(); + const Point& p1 = v1->point(); + const Offset o0 = vertex_offsets[v0]; + const Offset o1 = vertex_offsets[v1]; + bool simplicity_criterion = (o0 == o1); + + typename Hole::iterator hdone = hole.end(); + hit = hole.begin(); + typename Hole::iterator cut_after(hit); + + // if tested vertex is c with respect to the vertex opposite + // to NULL neighbor, + // stop at the before last face; + hdone--; + while( hit != hdone) + { + fn = (*hit).first; + in = (*hit).second; + Vertex_handle vv = fn->vertex(ccw(in)); + + const Point &p = vv->point(); + CGAL_assertion(vertex_offsets.find(vv) != vertex_offsets.end()); + const Offset o = vertex_offsets[vv]; + Orientation orient; + simplicity_criterion &= (o == o0); + if (simplicity_criterion) + orient = orientation(p0, p1, p); + else + orient = orientation(p0, p1, p, o0, o1, o); + + if (orient == COUNTERCLOCKWISE) + { + if (v2 == Vertex_handle()) + { + v2 = vv; + v3 = vv; + cut_after = hit; + } + else + { + Offset o3 = vertex_offsets[v3]; + Oriented_side side; + if (simplicity_criterion && (o3 == o0)) + side = side_of_oriented_circle(p0, p1, v3->point(), p, + true); + else + side = side_of_oriented_circle(p0, p1, v3->point(), p, + o0, o1, o3, o, + true); + if (side == ON_POSITIVE_SIDE) + { + v2 = vv; + v3 = vv; + cut_after = hit; + } + } + } + + ++hit; + } + + // create new triangle and update adjacency relations + Face_handle newf; + + //update the hole and push back in the Hole_List stack + // if v2 belongs to the neighbor following or preceding *f + // the hole remain a single hole + // otherwise it is split in two holes + + fn = (hole.front()).first; + in = (hole.front()).second; + if (fn->has_vertex(v2, i) && i == fn->ccw(in)) + { + newf = create_face(ff, ii, fn, in); + + Offset oo0 = o0; + Offset oo1 = o1; + Offset oo2 = vertex_offsets[v2]; + if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) + { + oo0 += Offset(number_of_sheets()[0], 0); + oo1 += Offset(number_of_sheets()[0], 0); + oo2 += Offset(number_of_sheets()[0], 0); + } + if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) + { + oo0 += Offset(0, number_of_sheets()[1]); + oo1 += Offset(0, number_of_sheets()[1]); + oo2 += Offset(0, number_of_sheets()[1]); + } + set_offsets(newf, + (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), + (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0), + (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0)); + // set_offsets(newf, o0, o1, o2); + insert_too_long_edge(newf, 0); + insert_too_long_edge(newf, 1); + + hole.pop_front(); + hole.push_front(Edge(newf, 1)); + hole_list.push_front(hole); + } + else + { + fn = (hole.back()).first; + in = (hole.back()).second; + if (fn->has_vertex(v2, i) && i == fn->cw(in)) + { + newf = create_face(fn, in, ff, ii); + Offset oo0 = o0; + Offset oo1 = o1; + Offset oo2 = vertex_offsets[v2]; + if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) + { + oo0 += Offset(number_of_sheets()[0], 0); + oo1 += Offset(number_of_sheets()[0], 0); + oo2 += Offset(number_of_sheets()[0], 0); + } + if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) + { + oo0 += Offset(0, number_of_sheets()[1]); + oo1 += Offset(0, number_of_sheets()[1]); + oo2 += Offset(0, number_of_sheets()[1]); + } + set_offsets(newf, + (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0), + (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), + (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0)); + insert_too_long_edge(newf, 1); + insert_too_long_edge(newf, 2); + hole.pop_back(); + hole.push_back(Edge(newf, 1)); + hole_list.push_front(hole); + } + else + { + // split the hole in two holes + CGAL_assertion(v2 != Vertex_handle()); + newf = create_face(ff, ii, v2); + Offset oo0 = o0; + Offset oo1 = o1; + Offset oo2 = vertex_offsets[v2]; + if (oo0.x() < 0 || oo1.x() < 0 || oo2.x() < 0) + { + oo0 += Offset(number_of_sheets()[0], 0); + oo1 += Offset(number_of_sheets()[0], 0); + oo2 += Offset(number_of_sheets()[0], 0); + } + if (oo0.y() < 0 || oo1.y() < 0 || oo2.y() < 0) + { + oo0 += Offset(0, number_of_sheets()[1]); + oo1 += Offset(0, number_of_sheets()[1]); + oo2 += Offset(0, number_of_sheets()[1]); + } + set_offsets(newf, + (oo0.x() >= number_of_sheets()[0] ? 2 : 0) + (oo0.y() >= number_of_sheets()[1] ? 1 : 0), + (oo1.x() >= number_of_sheets()[0] ? 2 : 0) + (oo1.y() >= number_of_sheets()[1] ? 1 : 0), + (oo2.x() >= number_of_sheets()[0] ? 2 : 0) + (oo2.y() >= number_of_sheets()[1] ? 1 : 0)); + + + // set_offsets(newf, o0, o1, o2); + insert_too_long_edge(newf, 0); + insert_too_long_edge(newf, 1); + + Hole new_hole; + ++cut_after; + while( hole.begin() != cut_after ) + { + new_hole.push_back(hole.front()); + hole.pop_front(); + } + + hole.push_front(Edge( newf, 1)); + new_hole.push_front(Edge( newf, 0)); + hole_list.push_front(hole); + hole_list.push_front(new_hole); + } + } } - } } } //namespace CGAL diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h index 5cd51355646..9799866ba5a 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_Delaunay_triangulation_traits_2.h @@ -13,7 +13,7 @@ // // $URL: svn+ssh://cgal/svn/cgal/branches/experimental-packages/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_traits_2.h $ // $Id: Periodic_2_triangulation_traits_2.h 60448 2010-12-21 15:40:31Z nicokruithof $ -// +// // // Author(s) : Nico Kruithof @@ -22,13 +22,15 @@ #include -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 { + public Periodic_2_triangulation_traits_2 +{ }; diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_offset_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_offset_2.h index 61b8c795fb4..cafbc6ed5c2 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_offset_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_offset_2.h @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -24,14 +24,16 @@ #include #include -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 - // friend std::ostream & operator<<(std::ostream &os, + // friend std::ostream & operator<<(std::ostream &os, // const Periodic_2_offset_2 &off); - + public: /// Default constructor. Periodic_2_offset_2() : _offx(0), _offy(0) {} @@ -39,109 +41,139 @@ public: Periodic_2_offset_2(int x, int y) : _offx(x), _offy(y) {} /// Returns true if o is equal to (0,0). - inline bool is_null() const { + inline bool is_null() const + { return is_zero(); } /// Returns true if o is equal to (0,0). - inline bool is_zero() const { + inline bool is_zero() const + { return ((_offx | _offy) == 0); } /// Return the x-entry of o. - int& x() { return _offx; } + int& x() + { + return _offx; + } /// Return the x-entry of o. - int x() const { return _offx; } + int x() const + { + return _offx; + } /// Return the y-entry of o. - int& y() { return _offy; } + int& y() + { + return _offy; + } /// Return the y-entry of o. - int y() const { return _offy; } + int y() const + { + return _offy; + } /// Return the i-th entry of o. - int &operator[](int i) { - if (i==0) return _offx; - CGAL_triangulation_assertion(i==1); + int &operator[](int i) + { + if (i == 0) return _offx; + CGAL_triangulation_assertion(i == 1); return _offy; } /// Return the i-th entry of o. - int operator[](int i) const { - if (i==0) return _offx; - CGAL_triangulation_assertion(i==1); + int operator[](int i) const + { + if (i == 0) return _offx; + CGAL_triangulation_assertion(i == 1); return _offy; } /// Add o' to o using vector addition. - void operator+=(const Periodic_2_offset_2 &other) { + void operator+=(const Periodic_2_offset_2 &other) + { _offx += other._offx; _offy += other._offy; } /// Subtract o' from o using vector subtraction. - void operator-=(const Periodic_2_offset_2 &other) { + void operator-=(const Periodic_2_offset_2 &other) + { _offx -= other._offx; _offy -= other._offy; } /// Return the negative vector of o. - Periodic_2_offset_2 operator-() const { - return Periodic_2_offset_2(-_offx,-_offy); + Periodic_2_offset_2 operator-() const + { + return Periodic_2_offset_2(-_offx, -_offy); } /// Return true if o' and o represent the same vector. - bool operator==(const Periodic_2_offset_2 &other) const { + bool operator==(const Periodic_2_offset_2 &other) const + { return ((_offx == other._offx) && - (_offy == other._offy)); + (_offy == other._offy)); } /// Return true if o' and o do not represent the same vector. - bool operator!=(const Periodic_2_offset_2 &other) const { + bool operator!=(const Periodic_2_offset_2 &other) const + { return ((_offx != other._offx) || - (_offy != other._offy)); + (_offy != other._offy)); } /// Compare o and o' lexicographically. - bool operator<(const Periodic_2_offset_2 &other) const { + bool operator<(const Periodic_2_offset_2 &other) const + { if (_offx != other._offx) return (_offx < other._offx); - else { - return (_offy < other._offy); - } + else + { + return (_offy < other._offy); + } } /// Return the vector sum of o and o'. - Periodic_2_offset_2 operator+(const Periodic_2_offset_2 &off2) const { - return Periodic_2_offset_2(_offx+off2.x(), _offy+off2.y()); + Periodic_2_offset_2 operator+(const Periodic_2_offset_2 &off2) const + { + return Periodic_2_offset_2(_offx + off2.x(), _offy + off2.y()); } /// Return the vector difference of o and o'. - Periodic_2_offset_2 operator-(const Periodic_2_offset_2 &off2) const { - return Periodic_2_offset_2(_offx-off2.x(), _offy-off2.y()); + Periodic_2_offset_2 operator-(const Periodic_2_offset_2 &off2) const + { + return Periodic_2_offset_2(_offx - off2.x(), _offy - off2.y()); } - -private: + +private: int _offx, _offy; }; template -inline Point_3 operator+(const Point_3 &p, const Periodic_2_offset_2 &off) { - return (off.is_null() ? p : Point_3(p.x()+off.x(), p.y()+off.y())); +inline Point_3 operator+(const Point_3 &p, const Periodic_2_offset_2 &off) +{ + return (off.is_null() ? p : Point_3(p.x() + off.x(), p.y() + off.y())); } /// Inputs an Periodic_2_offset_2 from is. -inline std::ostream -&operator<<(std::ostream &os, const Periodic_2_offset_2 &off) { +inline std::ostream +&operator<<(std::ostream &os, const Periodic_2_offset_2 &off) +{ if (is_ascii(os)) os << off.x() << " " << off.y(); - else { - write(os,off.x()); - write(os,off.y()); - } + else + { + write(os, off.x()); + write(os, off.y()); + } return os; } /// Outputs an Periodic_2_offset_2 to os. inline std::istream -&operator>>(std::istream &is, Periodic_2_offset_2 &off) { - int x=0,y=0; +&operator>>(std::istream &is, Periodic_2_offset_2 &off) +{ + int x = 0, y = 0; if (is_ascii(is)) is >> x >> y; - else { - read(is,x); - read(is,y); - } - off = Periodic_2_offset_2(x,y); + else + { + read(is, x); + read(is, y); + } + off = Periodic_2_offset_2(x, y); return is; } diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h index 322e26cdf3f..f7706b0e93c 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h @@ -11,7 +11,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -48,18 +48,20 @@ #include -namespace CGAL { +namespace CGAL +{ /// Periodic triangulation class. /// Its main functionality is: /// - Insertion of points /// - Deletion of points /// - Point location -template, - Periodic_2_triangulation_face_base_2 > > -class Periodic_2_triangulation_2: public Triangulation_cw_ccw_2 { +template < class Gt, + class Tds = Triangulation_data_structure_2 < + Periodic_2_triangulation_vertex_base_2, + Periodic_2_triangulation_face_base_2 > > +class Periodic_2_triangulation_2: public Triangulation_cw_ccw_2 +{ typedef Periodic_2_triangulation_2 Self; public: @@ -117,7 +119,7 @@ public: /// original domain, i.e. for each set of periodic copies the /// Unique_vertex_iterator iterates over exactly one representative. typedef Periodic_2_triangulation_unique_vertex_iterator_2 - Unique_vertex_iterator; + Unique_vertex_iterator; /// \name For compatibility with the Triangulation_2 class // \{ @@ -138,20 +140,21 @@ public: //\{ /// Iterator over all periodic triangles typedef Periodic_2_triangulation_triangle_iterator_2 - Periodic_triangle_iterator; + Periodic_triangle_iterator; /// Iterator over all periodic segments typedef Periodic_2_triangulation_segment_iterator_2 - Periodic_segment_iterator; + Periodic_segment_iterator; /// Iterator over all periodic points typedef Periodic_2_triangulation_point_iterator_2 - Periodic_point_iterator; + Periodic_point_iterator; //\} /// \name Enumeration types //\{ /// Type determining how to iterate over the stored simplices in the triangulation - enum Iterator_type { + enum Iterator_type + { STORED = 0, UNIQUE, // 1 STORED_COVER_DOMAIN, // 2 @@ -159,14 +162,15 @@ public: };//3 /// Return type of a point location query - enum Locate_type { + enum Locate_type + { /// The query point lies on a vertex VERTEX = 0, /// The query point lies on an edge EDGE, /// The query point lies on a face FACE, - /// The query point lies outside the affine hull of the triangulation, + /// The query point lies outside the affine hull of the triangulation, /// which is the case when the triangulation is empty. EMPTY }; @@ -206,28 +210,32 @@ protected: /// Vector is contains virtual copies with offset off: /// virtual copy with offset off is stored at position: i=3*off[0]+off[1]-1 typedef std::map > - Virtual_vertex_reverse_map; + Virtual_vertex_reverse_map; typedef typename Virtual_vertex_reverse_map::const_iterator - Virtual_vertex_reverse_map_it; + Virtual_vertex_reverse_map_it; typedef std::map > Too_long_edges_map; typedef typename Too_long_edges_map::const_iterator Too_long_edges_map_it; /// \name Functors // \{ /// Functor for symbolically perturbing points - class Perturbation_order { + class Perturbation_order + { const Self *t; public: // Perturbation_order, public interface Perturbation_order(const Self *tr) : - t(tr) { + t(tr) + { } - bool operator()(const Point *p, const Point *q) const { + bool operator()(const Point *p, const Point *q) const + { return t->compare_xy(*p, *q) == SMALLER; } - bool operator()(const Periodic_point *p, const Periodic_point *q) const { + bool operator()(const Periodic_point *p, const Periodic_point *q) const + { return t->compare_xy(p->first, q->first, p->second, q->second) == SMALLER; } }; @@ -245,8 +253,8 @@ public: //\{ /// Constructor Periodic_2_triangulation_2( - const Iso_rectangle &domain = Iso_rectangle(0,0,1,1), - const Geom_traits &geom_traits = Geom_traits()); + const Iso_rectangle &domain = Iso_rectangle(0, 0, 1, 1), + const Geom_traits &geom_traits = Geom_traits()); /// Copy constructor Periodic_2_triangulation_2(const Periodic_2_triangulation_2 &tr); @@ -272,28 +280,34 @@ public: //\{ /// Returns the geometric traits used for the predicates and constructions. - const Geom_traits& geom_traits() const { + const Geom_traits& geom_traits() const + { return _gt; } /// Returns the datastructure storing the triangulation. - const Triangulation_data_structure & tds() const { + const Triangulation_data_structure & tds() const + { return _tds; } /// Returns the datastructure storing the triangulation. - Triangulation_data_structure & tds() { + Triangulation_data_structure & tds() + { return _tds; } /// Returns the domain of the 1-sheeted cover. - const Iso_rectangle & domain() const { + const Iso_rectangle & domain() const + { return _domain; } - /// Returns the number of copies of the 1-sheeted cover stored in each of + /// Returns the number of copies of the 1-sheeted cover stored in each of /// the principal directions. - Covering_sheets number_of_sheets() const { + Covering_sheets number_of_sheets() const + { return _cover; } /// Returns the dimension of the triangulation. - int dimension() const { + int dimension() const + { return _tds.dimension() == 2 ? 2 : 0; } @@ -302,13 +316,15 @@ public: /// \name Number of simplices //\{ /// Returns whether the triangulation is empty. - bool empty() const { + bool empty() const + { return _tds.dimension() < 2; } /// Returns the number of vertices. Counts all vertices that are /// representatives of the same point in the 1-cover as one vertex. - size_type number_of_vertices() const { + size_type number_of_vertices() const + { if (is_1_cover()) return _tds.number_of_vertices(); else @@ -317,7 +333,8 @@ public: /// Returns the number of edges. Counts all edges that are /// representatives of the same segment in the 1-cover as one edge. - size_type number_of_edges() const { + size_type number_of_edges() const + { if (is_1_cover()) return _tds.number_of_edges(); else @@ -325,22 +342,26 @@ public: } /// Returns the number of faces. Counts all faces that are /// representatives of the same triangle in the 1-cover as one face. - size_type number_of_faces() const { + size_type number_of_faces() const + { if (is_1_cover()) return _tds.number_of_faces(); else return _tds.number_of_faces() / 9; } /// Returns the number of vertices stored in the datastructure. - size_type number_of_stored_vertices() const { + size_type number_of_stored_vertices() const + { return _tds.number_of_vertices(); } /// Returns the number of edges stored in the datastructure. - size_type number_of_stored_edges() const { + size_type number_of_stored_edges() const + { return _tds.number_of_edges(); } /// Returns the number of faces stored in the datastructure. - size_type number_of_stored_faces() const { + size_type number_of_stored_faces() const + { return _tds.number_of_faces(); } //\} @@ -375,7 +396,8 @@ public: /// represented in the 1-sheeted covering space, the offset is /// always zero. Otherwise v can correspond to a periodic copy /// outside domain of an input point. - Periodic_point periodic_point(const Vertex_handle &v) const { + Periodic_point periodic_point(const Vertex_handle &v) const + { return Periodic_point(v->point(), get_offset(v)); } @@ -384,16 +406,18 @@ public: /// face f, that is the point in the original domain and the offset /// of the vertex in f. If t is represented in the 9-sheeted /// covering space, this offset is possibly added to another offset - /// determining the periodic copy. + /// determining the periodic copy. /// \pre i == {0,1,2} - Periodic_point periodic_point(const Face_handle &f, int i) const { + Periodic_point periodic_point(const Face_handle &f, int i) const + { return Periodic_point(f->vertex(i)->point(), get_offset(f, i)); } /// Returns the periodic segment formed by the two point-offset /// pairs corresponding to the two vertices of edge (f,i). /// \pre i == {0,1,2} - Periodic_segment periodic_segment(const Face_handle &f, int i) const { + Periodic_segment periodic_segment(const Face_handle &f, int i) const + { CGAL_triangulation_precondition( number_of_vertices() != 0 ); CGAL_triangulation_precondition( i >= 0 && i <= 2); return make_array(periodic_point(f, ccw(i)), @@ -401,89 +425,106 @@ public: } /// Same as the previous method for edge e. - Periodic_segment periodic_segment(const Edge &e) const { + Periodic_segment periodic_segment(const Edge &e) const + { return periodic_segment(e.first, e.second); } /// Returns the periodic triangle formed by the three point-offset /// pairs corresponding to the three vertices of facet f. - Periodic_triangle periodic_triangle(const Face_handle &f) const { - return make_array(periodic_point(f, 0), - periodic_point(f, 1), + Periodic_triangle periodic_triangle(const Face_handle &f) const + { + return make_array(periodic_point(f, 0), + periodic_point(f, 1), periodic_point(f, 2)); } - /// Converts the Periodic_point pp (point-offset pair) to the corresponding + /// Converts the Periodic_point pp (point-offset pair) to the corresponding /// Point in \f$R^2\f$. - Point point(const Periodic_point & pp) const { + Point point(const Periodic_point & pp) const + { return construct_point(pp.first, pp.second); } - Point point(const Vertex_handle &v) const { + Point point(const Vertex_handle &v) const + { return point(periodic_point(v)); } - Point point(const Face_handle &fh, int i) const { + Point point(const Face_handle &fh, int i) const + { return point(periodic_point(fh, i)); } /// Converts the Periodic_segment ps to a Segment in \f$R^2\f$. - Segment segment(const Periodic_segment &ps) const { + Segment segment(const Periodic_segment &ps) const + { return construct_segment(ps[0].first, ps[1].first, ps[0].second, ps[1].second); } /// Converts the Periodic_triangle pt to a Triagle in \f$R^2\f$. - Triangle triangle(const Periodic_triangle &pt) const { + Triangle triangle(const Periodic_triangle &pt) const + { Triangle triang = construct_triangle(pt[0].first, pt[1].first, pt[2].first, - pt[0].second, pt[1].second, pt[2].second); + pt[0].second, pt[1].second, pt[2].second); return triang; } /// Constructs the segment associated with the edge (f,i), respects the offset - Segment segment(Face_handle f, int i) const { + Segment segment(Face_handle f, int i) const + { return segment(periodic_segment(f, i)); } /// Constructs the segment associated with the edge e, respects the offset - Segment segment(const Edge& e) const { + Segment segment(const Edge& e) const + { return segment(periodic_segment(e)); } /// Constructs the segment associated with the edge ec, respects the offset - Segment segment(const Edge_circulator& ec) const { + Segment segment(const Edge_circulator& ec) const + { return segment(periodic_segment(ec->first, ec->second)); } /// Constructs the segment associated with the edge ei, respects the offset - Segment segment(const Edge_iterator& ei) const { + Segment segment(const Edge_iterator& ei) const + { return segment(periodic_segment(ei->first, ei->second)); } /// Constructs the triangle associated with the face f, respects the offset - Triangle triangle(Face_handle f) const { + Triangle triangle(Face_handle f) const + { return triangle(periodic_triangle(f)); } //\} - Point move_in_domain(const Point &p) { + Point move_in_domain(const Point &p) + { typename Gt::FT x = p.x(); typename Gt::FT y = p.y(); - - while (x < _domain.xmin()) x += _domain.xmax()-_domain.xmin(); - while (x >= _domain.xmax()) x -= _domain.xmax()-_domain.xmin(); - while (y < _domain.ymin()) y += _domain.ymax()-_domain.ymin(); - while (y >= _domain.ymax()) y -= _domain.ymax()-_domain.ymin(); + while (x < _domain.xmin()) x += _domain.xmax() - _domain.xmin(); + while (x >= _domain.xmax()) x -= _domain.xmax() - _domain.xmin(); - return Point(x,y); + while (y < _domain.ymin()) y += _domain.ymax() - _domain.ymin(); + while (y >= _domain.ymax()) y -= _domain.ymax() - _domain.ymin(); + + return Point(x, y); } /// \name Queries on simplices // \{ - bool is_edge(Vertex_handle va, Vertex_handle vb) const { + bool is_edge(Vertex_handle va, Vertex_handle vb) const + { return _tds.is_edge(va, vb); } - bool is_edge(Vertex_handle va, Vertex_handle vb, Face_handle& fr, int & i) const { + bool is_edge(Vertex_handle va, Vertex_handle vb, Face_handle& fr, int & i) const + { return _tds.is_edge(va, vb, fr, i); } - bool is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) const { + bool is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) const + { return _tds.is_face(v1, v2, v3); } bool is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, - Face_handle &fr) const { + Face_handle &fr) const + { return _tds.is_face(v1, v2, v3, fr); } // \} @@ -492,7 +533,8 @@ public: // \{ /// Wrapper function for locate if only the requested point is given. - Face_handle locate(const Point &p, Face_handle start = Face_handle()) const { + Face_handle locate(const Point &p, Face_handle start = Face_handle()) const + { Locate_type lt; int li; return locate(p, Offset(), lt, li, start); @@ -500,13 +542,15 @@ public: /// Wrapper function for locate if the offset is omitted. Face_handle locate(const Point& p, Locate_type& lt, int& li, - Face_handle start = Face_handle()) const { + Face_handle start = Face_handle()) const + { return locate(p, Offset(), lt, li, start); } /// Returns the oriented side of the point p with respect to the /// triangle defined by the face f - Oriented_side oriented_side(Face_handle f, const Point& p) const { + Oriented_side oriented_side(Face_handle f, const Point& p) const + { return oriented_side(f, p, Offset()); } @@ -515,97 +559,117 @@ public: /// \name Traversal of the Triangulation // \{ - /// Iterator over all stored vertices. Starts at an arbitrary vertex. + /// Iterator over all stored vertices. Starts at an arbitrary vertex. /// Returns vertices_end() if t.number_of_vertices()=0. - Vertex_iterator vertices_begin() const { + Vertex_iterator vertices_begin() const + { return _tds.vertices_begin(); } /// Past the end Vertex_iterator. - Vertex_iterator vertices_end() const { + Vertex_iterator vertices_end() const + { return _tds.vertices_end(); } - /// Iterator over all stored edges. Starts at an arbitrary edge. + /// Iterator over all stored edges. Starts at an arbitrary edge. /// Returns edges_end() if t.number_of_vertices()=0. - Edge_iterator edges_begin() const { + Edge_iterator edges_begin() const + { return _tds.edges_begin(); } /// Past the end Edge_iterator. - Edge_iterator edges_end() const { + Edge_iterator edges_end() const + { return _tds.edges_end(); } - /// Iterator over all stored faces. Starts at an arbitrary face. + /// Iterator over all stored faces. Starts at an arbitrary face. /// Returns faces_end() if t.number_of_vertices()=0. - Face_iterator faces_begin() const { + Face_iterator faces_begin() const + { return _tds.faces_begin(); } /// Past the end Face_iterator. - Face_iterator faces_end() const { + Face_iterator faces_end() const + { return _tds.faces_end(); } - /// Iterator over all stored vertices. Starts at an arbitrary vertex. + /// Iterator over all stored vertices. Starts at an arbitrary vertex. /// Returns vertices_end() if t.number_of_vertices()=0. - Vertex_iterator finite_vertices_begin() const { + Vertex_iterator finite_vertices_begin() const + { return _tds.vertices_begin(); } /// Past the end Vertex_iterator. - Vertex_iterator finite_vertices_end() const { + Vertex_iterator finite_vertices_end() const + { return _tds.vertices_end(); } - /// Iterator over all stored edges. Starts at an arbitrary edge. + /// Iterator over all stored edges. Starts at an arbitrary edge. /// Returns edges_end() if t.number_of_vertices()=0. - Edge_iterator finite_edges_begin() const { + Edge_iterator finite_edges_begin() const + { return _tds.edges_begin(); } /// Past the end Edge_iterator. - Edge_iterator finite_edges_end() const { + Edge_iterator finite_edges_end() const + { return _tds.edges_end(); } - /// Iterator over all stored faces. Starts at an arbitrary face. + /// Iterator over all stored faces. Starts at an arbitrary face. /// Returns faces_end() if t.number_of_vertices()=0. - Face_iterator finite_faces_begin() const { + Face_iterator finite_faces_begin() const + { return _tds.faces_begin(); } /// Past the end Face_iterator. - Face_iterator finite_faces_end() const { + Face_iterator finite_faces_end() const + { return _tds.faces_end(); } - /// Iterator over all stored vertices. Starts at an arbitrary vertex. + /// Iterator over all stored vertices. Starts at an arbitrary vertex. /// Returns vertices_end() if t.number_of_vertices()=0. - Vertex_iterator all_vertices_begin() const { + Vertex_iterator all_vertices_begin() const + { return _tds.vertices_begin(); } /// Past the end Vertex_iterator. - Vertex_iterator all_vertices_end() const { + Vertex_iterator all_vertices_end() const + { return _tds.vertices_end(); } - /// Iterator over all stored edges. Starts at an arbitrary edge. + /// Iterator over all stored edges. Starts at an arbitrary edge. /// Returns edges_end() if t.number_of_vertices()=0. - Edge_iterator all_edges_begin() const { + Edge_iterator all_edges_begin() const + { return _tds.edges_begin(); } /// Past the end Edge_iterator. - Edge_iterator all_edges_end() const { + Edge_iterator all_edges_end() const + { return _tds.edges_end(); } - /// Iterator over all stored faces. Starts at an arbitrary face. + /// Iterator over all stored faces. Starts at an arbitrary face. /// Returns faces_end() if t.number_of_vertices()=0. - Face_iterator all_faces_begin() const { + Face_iterator all_faces_begin() const + { return _tds.faces_begin(); } /// Past the end Face_iterator. - Face_iterator all_faces_end() const { + Face_iterator all_faces_end() const + { return _tds.faces_end(); } /// begin iterator over the non-virtual vertices - Unique_vertex_iterator unique_vertices_begin() const { + Unique_vertex_iterator unique_vertices_begin() const + { return CGAL::filter_iterator(vertices_end(), Domain_tester(this), - vertices_begin()); + vertices_begin()); } /// past-the-end iterator over the non-virtual vertices - Unique_vertex_iterator unique_vertices_end() const { + Unique_vertex_iterator unique_vertices_end() const + { return CGAL::filter_iterator(vertices_end(), Domain_tester(this)); } @@ -614,29 +678,35 @@ public: //\{ /// Start iterator over the points - Periodic_point_iterator periodic_points_begin(Iterator_type it = STORED) const { + Periodic_point_iterator periodic_points_begin(Iterator_type it = STORED) const + { return Periodic_point_iterator(this, it); } /// Past-the-end iterator over the points - Periodic_point_iterator periodic_points_end(Iterator_type it = STORED) const { + Periodic_point_iterator periodic_points_end(Iterator_type it = STORED) const + { return Periodic_point_iterator(this, 1, it); } /// Start iterator over the segments - Periodic_segment_iterator periodic_segments_begin(Iterator_type it = STORED) const { + Periodic_segment_iterator periodic_segments_begin(Iterator_type it = STORED) const + { return Periodic_segment_iterator(this, it); } /// Past-the-end iterator over the segments - Periodic_segment_iterator periodic_segments_end(Iterator_type it = STORED) const { + Periodic_segment_iterator periodic_segments_end(Iterator_type it = STORED) const + { return Periodic_segment_iterator(this, 1, it); } /// Start iterator over the triangles - Periodic_triangle_iterator periodic_triangles_begin(Iterator_type it = STORED) const { + Periodic_triangle_iterator periodic_triangles_begin(Iterator_type it = STORED) const + { return Periodic_triangle_iterator(this, it); } /// Past-the-end iterator over the triangles - Periodic_triangle_iterator periodic_triangles_end(Iterator_type it = STORED) const { + Periodic_triangle_iterator periodic_triangles_end(Iterator_type it = STORED) const + { return Periodic_triangle_iterator(this, 1, it); } //\} @@ -644,19 +714,23 @@ public: /// \name Incident simplices // \{ - Face_circulator incident_faces(Vertex_handle v, Face_handle f = Face_handle()) const { + Face_circulator incident_faces(Vertex_handle v, Face_handle f = Face_handle()) const + { return _tds.incident_faces(v, f); } - Edge_circulator incident_edges(Vertex_handle v, Face_handle f = Face_handle()) const { + Edge_circulator incident_edges(Vertex_handle v, Face_handle f = Face_handle()) const + { return _tds.incident_edges(v, f); } Vertex_circulator incident_vertices(Vertex_handle v, Face_handle f = - Face_handle()) const { - bool DEPRECATED_USE_ADJACENT_VERTICES; - return adjacent_vertices(v,f); + Face_handle()) const + { + bool DEPRECATED_USE_ADJACENT_VERTICES; + return adjacent_vertices(v, f); } Vertex_circulator adjacent_vertices(Vertex_handle v, Face_handle f = - Face_handle()) const { + Face_handle()) const + { return _tds.incident_vertices(v, f); } // \} @@ -664,10 +738,12 @@ public: /// \name Traversal between adjacent faces // \{ - Vertex_handle mirror_vertex(Face_handle f, int i) const { + Vertex_handle mirror_vertex(Face_handle f, int i) const + { return _tds.mirror_vertex(f, i); } - int mirror_index(Face_handle f, int i) const { + int mirror_index(Face_handle f, int i) const + { return _tds.mirror_index(f, i); } //\} @@ -690,7 +766,8 @@ public: Vertex_handle insert(const Point& p, Locate_type lt, Face_handle loc, int li); /// Insert a point in the triangulation - Vertex_handle push_back(const Point& p) { + Vertex_handle push_back(const Point& p) + { return insert(p); } @@ -721,12 +798,13 @@ public: /// Changes the domain. Note that this function calls clear(), i.e., /// it erases the existing triangulation. - void set_domain(const Iso_rectangle &domain) { + void set_domain(const Iso_rectangle &domain) + { clear(); _domain = domain; _gt.set_domain(_domain); - _edge_length_threshold = - FT(0.166) * (_domain.xmax()-_domain.xmin()) * (_domain.xmax()-_domain.xmin()); + _edge_length_threshold = + FT(0.166) * (_domain.xmax() - _domain.xmin()) * (_domain.xmax() - _domain.xmin()); } //\} @@ -736,19 +814,20 @@ public: /// Do a remembering heuristic walk to locate point (p,o) Face_handle march_locate_2D(Face_handle f, const Point& p, const Offset& o, - Locate_type& lt, int& li) const; + Locate_type& lt, int& li) const; /// Checks whether the result of two point location queries are equivalent. bool compare_walks(const Point& p, Face_handle c1, Face_handle c2, - Locate_type& lt1, Locate_type& lt2, int li1, int li2) const; + Locate_type& lt1, Locate_type& lt2, int li1, int li2) const; /// Testing where the point (p,off) lies w.r.t. the face f Bounded_side side_of_face(const Point &p, const Offset &off, Face_handle f, - Locate_type <, int &li) const; + Locate_type <, int &li) const; /// Testing where the point (p,off) lies w.r.t. the face f Bounded_side side_of_face(const Point &p, Face_handle f, Locate_type <, - int &li) const { + int &li) const + { return side_of_face(p, Offset(), f, lt, li); } //\} @@ -775,24 +854,24 @@ public: /// (q,o_q), (p,o_p) and (r,o_r) are supposed to be collinear points bool collinear_between(const Point& p, const Point& q, const Point& r, - const Offset& o_p, const Offset& o_q, const Offset& o_r) const; + const Offset& o_p, const Offset& o_q, const Offset& o_r) const; /// Compares the x-coordinates of p and q Comparison_result compare_x(const Point& p, const Point& q) const; /// Compares the x-coordinates of (p,o_p) and (q,o_q) Comparison_result compare_x(const Point& p, const Point& q, - const Offset &o_p, const Offset &o_q) const; + const Offset &o_p, const Offset &o_q) const; /// Compares p and q lexicographically Comparison_result compare_xy(const Point& p, const Point& q, - const Offset &o_p, const Offset &o_q) const; + const Offset &o_p, const Offset &o_q) const; /// Compares (p,o_p) and (q,o_q) lexicographically Comparison_result compare_xy(const Point& p, const Point& q) const; /// Compares the x-coordinates of p and q Comparison_result compare_y(const Point& p, const Point& q) const; /// Compares the x-coordinates of (p,o_p) and (q,o_q) Comparison_result compare_y(const Point& p, const Point& q, - const Offset &o_p, const Offset &o_q) const; + const Offset &o_p, const Offset &o_q) const; /// Checks for equality of p and q bool xy_equal(const Point& p, const Point& q) const; /// Returns the orientation of p1,p2,p3 @@ -810,27 +889,29 @@ public: /// the circle through the points p0, p1 and p2 Oriented_side side_of_oriented_circle(const Point &p0, const Point &p1, const Point &p2, - const Point &p, bool perturb) const; + const Point &p, bool perturb) const; /// Determines whether the point (p,o) lies on the (un-)bounded side of /// the circle through the points (p0,o0), (p1,o1) and (p2,o2) Oriented_side side_of_oriented_circle(const Point &p0, const Point &p1, const Point &p2, - const Point &p, const Offset &o0, const Offset &o1, const Offset &o2, - const Offset &o, bool perturb) const; + const Point &p, const Offset &o0, const Offset &o1, const Offset &o2, + const Offset &o, bool perturb) const; /// Constructs the circumcenter of the face f, respects the offset - Point circumcenter(Face_handle f) const { - return construct_circumcenter(f->vertex(0)->point(), - f->vertex(1)->point(), - f->vertex(2)->point(), - get_offset(f, 0), - get_offset(f, 1), - get_offset(f, 2)); + Point circumcenter(Face_handle f) const + { + return construct_circumcenter(f->vertex(0)->point(), + f->vertex(1)->point(), + f->vertex(2)->point(), + get_offset(f, 0), + get_offset(f, 1), + get_offset(f, 2)); } - Point construct_circumcenter(const Point &p1, const Point &p2, const Point &p3, - const Offset &o1, const Offset &o2, const Offset &o3) const { + Point construct_circumcenter(const Point &p1, const Point &p2, const Point &p3, + const Offset &o1, const Offset &o2, const Offset &o3) const + { return geom_traits().construct_circumcenter_2_object()(p1, p2, p3, o1, o2, o3); } //\} @@ -843,7 +924,8 @@ public: /// a convex quadrilateral. bool flippable(Face_handle f, int i); - size_type degree(Vertex_handle v) const { + size_type degree(Vertex_handle v) const + { return _tds.degree(v); } @@ -858,13 +940,15 @@ public: /// \name Undocumented functions, needed by the geometric iterators // \{ /// [Undoc] Returns whether the stored triangulation covers a 1-cover. - bool is_1_cover() const { + bool is_1_cover() const + { return (_cover[0] == 1) && (_cover[1] == 1); } /// [Undoc] Combines two offsets, where the first offset is defined by the /// virtual vertex and the second by the face. - Offset combine_offsets(const Offset& o_c, const Offset& o_t) const { + Offset combine_offsets(const Offset& o_c, const Offset& o_t) const + { Offset o_ct(_cover[0] * o_t.x(), _cover[1] * o_t.y()); return o_c + o_ct; } @@ -875,7 +959,8 @@ public: /// - Find two corresponding vertices from each face /// - Return the difference of their offsets. /// - Offset get_neighbor_offset(Face_handle fh, int i) const { + Offset get_neighbor_offset(Face_handle fh, int i) const + { Face_handle nb = fh->neighbor(i); return get_neighbor_offset(fh, i, nb, nb->index(fh)); } @@ -886,7 +971,8 @@ public: /// - Find two corresponding vertices from each face /// - Return the difference of their offsets. /// - Offset get_neighbor_offset(Face_handle fh, int i, Face_handle nb, int j) const { + Offset get_neighbor_offset(Face_handle fh, int i, Face_handle nb, int j) const + { // Redundance in the signature CGAL_triangulation_precondition(fh->neighbor(i) == nb); CGAL_triangulation_precondition(nb->neighbor(j) == fh); @@ -896,7 +982,8 @@ public: } /// [Undoc] returns the combined offset of the vertex /// (if we are not on the 1-cover) and the offset defined by the face. - Offset get_offset(Face_handle f, int i) const { + Offset get_offset(Face_handle f, int i) const + { if (is_1_cover()) return int_to_off(f->offset(i)); @@ -907,7 +994,8 @@ public: return combine_offsets(Offset(), int_to_off(f->offset(i))); } /// [Undoc] Returns the offset of the vertex if we are not on the 1-cover. - Offset get_offset(Vertex_handle vh) const { + Offset get_offset(Vertex_handle vh) const + { if (is_1_cover()) return Offset(); Virtual_vertex_map_it it = _virtual_vertices.find(vh); @@ -918,27 +1006,31 @@ public: } /// Converts an offset to a bit pattern where bit1==offx and bit0==offy. - int off_to_int(const Offset & off) const { - CGAL_triangulation_assertion( off.x()==0 || off.x() ==1 ); - CGAL_triangulation_assertion( off.y()==0 || off.y() ==1 ); + int off_to_int(const Offset & off) const + { + CGAL_triangulation_assertion( off.x() == 0 || off.x() == 1 ); + CGAL_triangulation_assertion( off.y() == 0 || off.y() == 1 ); int i = ((off.x() & 1) << 1) + (off.y() & 1); return i; } /// Creates an offset from a bit pattern. - Offset int_to_off(int i) const { + Offset int_to_off(int i) const + { return Offset((i >> 1) & 1, i & 1); } // \} // Protected functions of Periodic_2_triangulation_2 - /// Const accessor to the virtual vertices reverse map, + /// Const accessor to the virtual vertices reverse map, /// used to optimize point location for periodic copies. - const Virtual_vertex_reverse_map &virtual_vertices_reverse() const { + const Virtual_vertex_reverse_map &virtual_vertices_reverse() const + { return _virtual_vertices_reverse; } /// [Undoc] Returns the non-virtual copy of the vertex. - Vertex_handle get_original_vertex(Vertex_handle vh) const { + Vertex_handle get_original_vertex(Vertex_handle vh) const + { if (is_1_cover()) return vh; Virtual_vertex_map_it it = _virtual_vertices.find(vh); @@ -950,39 +1042,45 @@ public: /// Tests whether a vertex is a periodic copy of a vertex in the 3-cover. - bool is_virtual(Vertex_handle v) { + bool is_virtual(Vertex_handle v) + { if (is_1_cover()) return false; return (_virtual_vertices.find(v) != _virtual_vertices.end()); } - const std::vector& periodic_copies(const Vertex_handle v) const { - CGAL_triangulation_precondition(number_of_sheets() != make_array(1,1) ); + const std::vector& periodic_copies(const Vertex_handle v) const + { + CGAL_triangulation_precondition(number_of_sheets() != make_array(1, 1) ); CGAL_triangulation_precondition(_virtual_vertices.find(v) == _virtual_vertices.end()); CGAL_triangulation_assertion(_virtual_vertices_reverse.find(v) != _virtual_vertices_reverse.end()); return _virtual_vertices_reverse.find(v)->second; } template - Stream& draw_triangulation(Stream& os) const { + Stream& draw_triangulation(Stream& os) const + { Edge_iterator it = edges_begin(); - for (; it != edges_end(); ++it) { - os << segment(it); - } + for (; it != edges_end(); ++it) + { + os << segment(it); + } return os; } protected: std::vector insert_dummy_points(); - inline void try_to_convert_to_one_cover() { + inline void try_to_convert_to_one_cover() + { // Fall back to 1-cover if the criterion that the longest edge is shorter // than sqrt(0.166) is fulfilled. - if (_too_long_edge_counter == 0 && !is_1_cover()) { - CGAL_triangulation_expensive_assertion( is_valid() ); - this->convert_to_1_sheeted_covering(); - CGAL_triangulation_expensive_assertion( is_valid() ); - } + if (_too_long_edge_counter == 0 && !is_1_cover()) + { + CGAL_triangulation_expensive_assertion( is_valid() ); + this->convert_to_1_sheeted_covering(); + CGAL_triangulation_expensive_assertion( is_valid() ); + } } protected: @@ -991,7 +1089,7 @@ protected: /// Inserts a point with an offset in the triangulation /// \pre The point has been located in the triangulation Vertex_handle insert(const Point& p, const Offset& o, Locate_type lt, - Face_handle loc, int li, Vertex_handle vh); + Face_handle loc, int li, Vertex_handle vh); /// \name Helper functions for queries // \{ @@ -1003,7 +1101,7 @@ protected: /// The Face_handle start is the start point of the heuristic walk. Face_handle locate(const Point& p, const Offset &o, Locate_type& lt, int& li, - Face_handle start = Face_handle()) const; + Face_handle start = Face_handle()) const; /// Returns the oriented side of the point (p,o) with respect to the /// triangle defined by the face f Oriented_side @@ -1037,32 +1135,39 @@ protected: /// \name Wrapping the traits //\{ - Point construct_point(const Point& p, const Offset &o) const { + Point construct_point(const Point& p, const Offset &o) const + { return geom_traits().construct_point_2_object()(p, o); } - Point construct_point(const Periodic_point& pp) const { + Point construct_point(const Periodic_point& pp) const + { return construct_point(pp.first, pp.second); } Triangle construct_triangle(const Point &p1, const Point &p2, - const Point &p3, const Offset &o1, const Offset &o2, const Offset &o3) const { + const Point &p3, const Offset &o1, const Offset &o2, const Offset &o3) const + { return geom_traits().construct_triangle_2_object()(p1, p2, p3, o1, o2, o3); } - Triangle construct_triangle(const Periodic_triangle& tri) const { + Triangle construct_triangle(const Periodic_triangle& tri) const + { return construct_triangle(tri[0].first, tri[1].first, tri[2].first, - tri[0].second, tri[1].second, tri[2].second); + tri[0].second, tri[1].second, tri[2].second); } Segment construct_segment(const Point &p1, const Point &p2, const Offset &o1, - const Offset &o2) const { + const Offset &o2) const + { return geom_traits().construct_segment_2_object()(p1, p2, o1, o2); } - Segment construct_segment(const Periodic_segment& seg) const { + Segment construct_segment(const Periodic_segment& seg) const + { return construct_segment(seg[0].first, seg[1].first, seg[0].second, - seg[1].second); + seg[1].second); } //\} /// Test whether removing vertex v decreases the dimension of the triangulation. - bool test_dim_down(Vertex_handle /*v*/) const { + bool test_dim_down(Vertex_handle /*v*/) const + { //test the dimensionality of the resulting triangulation //upon removing of vertex v return number_of_vertices() == 1; @@ -1082,44 +1187,52 @@ protected: // template members - bool well_oriented(Vertex_handle v) const { + bool well_oriented(Vertex_handle v) const + { typedef typename Geom_traits::Orientation_2 Orientation_2; Face_circulator fc = incident_faces(v), done(fc); - do { - Orientation o; - - Vertex_handle v0 = fc->vertex(0); - Vertex_handle v1 = fc->vertex(1); - Vertex_handle v2 = fc->vertex(2); - if (fc->has_zero_offsets()) { - o = orientation(v0->point(), v1->point(), v2->point()); - } else { - Offset off0 = get_offset(fc, 0); - Offset off1 = get_offset(fc, 1); - Offset off2 = get_offset(fc, 2); - o = orientation(v0->point(), v1->point(), v2->point(), off0, off1, off2); + do + { + Orientation o; + + Vertex_handle v0 = fc->vertex(0); + Vertex_handle v1 = fc->vertex(1); + Vertex_handle v2 = fc->vertex(2); + if (fc->has_zero_offsets()) + { + o = orientation(v0->point(), v1->point(), v2->point()); + } + else + { + Offset off0 = get_offset(fc, 0); + Offset off1 = get_offset(fc, 1); + Offset off2 = get_offset(fc, 2); + o = orientation(v0->point(), v1->point(), v2->point(), off0, off1, off2); + } + if (o != COUNTERCLOCKWISE) return false; } - if (o != COUNTERCLOCKWISE) return false; - } while (++fc != done); + while (++fc != done); return true; } template - Vertex_handle star_hole(const Point& p, EdgeIt edge_begin, EdgeIt edge_end) { + Vertex_handle star_hole(const Point& p, EdgeIt edge_begin, EdgeIt edge_end) + { std::list empty_list; return star_hole(p, edge_begin, edge_end, empty_list.begin(), - empty_list.end()); + empty_list.end()); } template Vertex_handle star_hole(const Point& p, EdgeIt edge_begin, EdgeIt edge_end, - FaceIt face_begin, FaceIt face_end) { + FaceIt face_begin, FaceIt face_end) + { CGAL_assertion(is_1_cover()); typedef typename Triangulation_data_structure::Edge Tds_Edge; typedef typename Triangulation_data_structure::Face Tds_Face; Vertex_handle v = - _tds.star_hole(edge_begin, edge_end, face_begin, face_end); + _tds.star_hole(edge_begin, edge_end, face_begin, face_end); v->set_point(p); return v; } @@ -1137,54 +1250,65 @@ protected: inline Face_handle get_face(const Vertex_handle* vh) const; /// Constructs a list of too long edges in the triangulation. int find_too_long_edges( - std::map >& edges) const; + std::map >& edges) const; /// Returns the offset such that (p, o) lies on the bounded side of the face f. - Offset get_location_offset(Face_handle f, const Point &p, const Offset &o) const { + Offset get_location_offset(Face_handle f, const Point &p, const Offset &o) const + { CGAL_triangulation_precondition( number_of_vertices() != 0 ); - if (is_1_cover() && f->has_zero_offsets()) { - // default case: - return Offset(); - } else { - int cumm_off = f->offset(0) | f->offset(1) | f->offset(2); - // Special case for the periodic space. - // Fetch vertices and respective offsets of c from _virtual_vertices - const Point *pts[3]; - Offset off[3]; - for (int i = 0; i < 3; i++) { - pts[i] = &(f->vertex(i)->point()); - off[i] = get_offset(f, i); + if (is_1_cover() && f->has_zero_offsets()) + { + // default case: + return Offset(); } - - // Main idea seems to just test all possibilities. - for (int i = 0; i < 4; i++) { - if (((cumm_off | (~i)) & 3) == 3) { - if (bounded_side(*pts[0], *pts[1], *pts[2], p, off[0], off[1], - off[2], combine_offsets(o, int_to_off(i))) != ON_UNBOUNDED_SIDE) { - return int_to_off(i); + else + { + int cumm_off = f->offset(0) | f->offset(1) | f->offset(2); + // Special case for the periodic space. + // Fetch vertices and respective offsets of c from _virtual_vertices + const Point *pts[3]; + Offset off[3]; + for (int i = 0; i < 3; i++) + { + pts[i] = &(f->vertex(i)->point()); + off[i] = get_offset(f, i); + } + + // Main idea seems to just test all possibilities. + for (int i = 0; i < 4; i++) + { + if (((cumm_off | (~i)) & 3) == 3) + { + if (bounded_side(*pts[0], *pts[1], *pts[2], p, off[0], off[1], + off[2], combine_offsets(o, int_to_off(i))) != ON_UNBOUNDED_SIDE) + { + return int_to_off(i); + } + } } - } } - } CGAL_assertion(false); return Offset(); } /// Assigns the offsets to the vertices of the face f, and makes the offset minimal in each direction. - void set_offsets(Face_handle f, int o0, int o1, int o2) { + void set_offsets(Face_handle f, int o0, int o1, int o2) + { int off0[2] = { (o0 >> 1) & 1, (o0 & 1) }; int off1[2] = { (o1 >> 1) & 1, (o1 & 1) }; int off2[2] = { (o2 >> 1) & 1, (o2 & 1) }; // Make sure that there is at least one zero offset in every direction - for (int i = 0; i < 2; i++) { - int min_off = (std::min)((std::min)(off0[i], off1[i]), off2[i]); - if (min_off != 0) { - off0[i] -= min_off; - off1[i] -= min_off; - off2[i] -= min_off; + for (int i = 0; i < 2; i++) + { + int min_off = (std::min)((std::min)(off0[i], off1[i]), off2[i]); + if (min_off != 0) + { + off0[i] -= min_off; + off1[i] -= min_off; + off2[i] -= min_off; + } } - } o0 = ((off0[0] & 1) << 1) + (off0[1] & 1); o1 = ((off1[0] & 1) << 1) + (off1[1] & 1); o2 = ((off2[0] & 1) << 1) + (off2[1] & 1); @@ -1193,21 +1317,24 @@ protected: /// Assigns the offsets to the vertices of the face f, and makes the offset minimal in each direction. template - void set_offsets(Face_handle f, const Offset &o0, const Offset &o1, const Offset &o2) { + void set_offsets(Face_handle f, const Offset &o0, const Offset &o1, const Offset &o2) + { int off0[2] = { o0.x(), o0.y() }; int off1[2] = { o1.x(), o1.y() }; int off2[2] = { o2.x(), o2.y() }; - for (int i = 0; i < 2; i++) { - int min_off = (std::min)((std::min)(off0[i], off1[i]), off2[i]); - if (min_off != 0) { - off0[i] -= min_off; - off1[i] -= min_off; - off2[i] -= min_off; + for (int i = 0; i < 2; i++) + { + int min_off = (std::min)((std::min)(off0[i], off1[i]), off2[i]); + if (min_off != 0) + { + off0[i] -= min_off; + off1[i] -= min_off; + off2[i] -= min_off; + } } - } - CGAL_triangulation_assertion((std::min)((std::min)(off0[0],off1[0]),off2[0]) == 0); - CGAL_triangulation_assertion((std::min)((std::min)(off0[1],off1[1]),off2[1]) == 0); + CGAL_triangulation_assertion((std::min)((std::min)(off0[0], off1[0]), off2[0]) == 0); + CGAL_triangulation_assertion((std::min)((std::min)(off0[1], off1[1]), off2[1]) == 0); CGAL_triangulation_assertion((0 <= off0[0]) && (off0[0] < 2)); CGAL_triangulation_assertion((0 <= off1[0]) && (off1[0] < 2)); CGAL_triangulation_assertion((0 <= off2[0]) && (off2[0] < 2)); @@ -1227,18 +1354,20 @@ protected: /** @name Checking helpers */ //@{ /// calls has_self_edges for every face of the triangulation - bool has_self_edges() const { + bool has_self_edges() const + { Face_iterator it; for ( it = all_faces_begin(); it != all_faces_end(); ++it ) if (has_self_edges(it)) return true; return false; } - bool has_self_edges(Face_handle fh) const { - CGAL_triangulation_assertion((fh->vertex(0) != fh->vertex(1)) || + bool has_self_edges(Face_handle fh) const + { + CGAL_triangulation_assertion((fh->vertex(0) != fh->vertex(1)) || (fh->offset(0) != fh->offset(1))); - CGAL_triangulation_assertion((fh->vertex(0) != fh->vertex(2)) || + CGAL_triangulation_assertion((fh->vertex(0) != fh->vertex(2)) || (fh->offset(0) != fh->offset(2))); - CGAL_triangulation_assertion((fh->vertex(1) != fh->vertex(2)) || + CGAL_triangulation_assertion((fh->vertex(1) != fh->vertex(2)) || (fh->offset(1) != fh->offset(2))); return ((fh->vertex(0) == fh->vertex(1)) || (fh->vertex(0) == fh->vertex(2)) || @@ -1246,7 +1375,7 @@ protected: } //@} - + protected: // Protected data of Periodic_2_triangulation_2 @@ -1261,7 +1390,10 @@ protected: /// Returns false, no infinite simplices in the periodic triangulation template - inline bool is_infinite(T) const { return false; } + inline bool is_infinite(T) const + { + return false; + } private: /// Inserts (p,o) in the face f and sets the offsets of the newly created faces @@ -1309,19 +1441,21 @@ private: // CONSTRUCTORS template Periodic_2_triangulation_2::Periodic_2_triangulation_2( - const Iso_rectangle & domain, const Geom_traits& geom_traits) + const Iso_rectangle & domain, const Geom_traits& geom_traits) : _gt(geom_traits), _tds() , _cover(make_array(1, 1)) , _domain(domain) - , _too_long_edge_counter(0) { + , _too_long_edge_counter(0) +{ CGAL_triangulation_precondition(_domain.xmax() - _domain.xmin() == - _domain.ymax() - _domain.ymin()); + _domain.ymax() - _domain.ymin()); set_domain(_domain); } // copy constructor duplicates vertices and faces template -Periodic_2_triangulation_2::Periodic_2_triangulation_2(const Periodic_2_triangulation_2 &tr) { +Periodic_2_triangulation_2::Periodic_2_triangulation_2(const Periodic_2_triangulation_2 &tr) +{ copy_triangulation(tr); } @@ -1329,33 +1463,38 @@ Periodic_2_triangulation_2::Periodic_2_triangulation_2(const Periodic_2 template Periodic_2_triangulation_2 & Periodic_2_triangulation_2::operator=( - const Periodic_2_triangulation_2 &tr) { + const Periodic_2_triangulation_2 &tr) +{ copy_triangulation(tr); return *this; } // Helping functions template < class GT, class Tds > -class Periodic_2_triangulation_2::Finder { +class Periodic_2_triangulation_2::Finder +{ const Self* _t; const Point & _p; public: Finder(const Self* t, const Point &p) : _t(t), _p(p) {} - bool operator()(const Vertex_handle v) { + bool operator()(const Vertex_handle v) + { return _t->xy_equal(v->point(), _p); } }; template < class GT, class Tds > inline void -Periodic_2_triangulation_2:: -copy_multiple_covering(const Periodic_2_triangulation_2 & tr) { +Periodic_2_triangulation_2:: +copy_multiple_covering(const Periodic_2_triangulation_2 & tr) +{ // Write the respective offsets in the vertices to make them // automatically copy with the tds. for (Vertex_iterator vit = tr.vertices_begin() ; - vit != tr.vertices_end() ; ++vit) { - vit->set_offset(tr.get_offset(vit)); - } + vit != tr.vertices_end() ; ++vit) + { + vit->set_offset(tr.get_offset(vit)); + } // copy the tds _tds = tr.tds(); // make a list of all vertices that belong to the original @@ -1363,33 +1502,37 @@ copy_multiple_covering(const Periodic_2_triangulation_2 & tr) { // virtual_vertices_reverse std::list vlist; for (Vertex_iterator vit = vertices_begin() ; - vit != vertices_end() ; ++vit) { - if (vit->offset() == Offset()) { - vlist.push_back(vit); - _virtual_vertices_reverse.insert( - std::make_pair(vit,std::vector(8))); - CGAL_triangulation_assertion(_virtual_vertices_reverse.find(vit) - ->second.size() == 8); + vit != vertices_end() ; ++vit) + { + if (vit->offset() == Offset()) + { + vlist.push_back(vit); + _virtual_vertices_reverse.insert( + std::make_pair(vit, std::vector(8))); + CGAL_triangulation_assertion(_virtual_vertices_reverse.find(vit) + ->second.size() == 8); + } } - } // Iterate over all vertices that are not in the original domain // and construct the respective entries to virtual_vertices and // virtual_vertices_reverse for (Vertex_iterator vit2 = vertices_begin() ; - vit2 != vertices_end() ; ++vit2) { - if (vit2->offset() != Offset()) { - //TODO: use some binding, maybe boost instead of the Finder. - typename std::list::iterator vlist_it - = std::find_if(vlist.begin(), vlist.end(), - Finder(this,vit2->point())); - Offset off = vit2->offset(); - _virtual_vertices.insert(std::make_pair(vit2, - std::make_pair(*vlist_it,off))); - _virtual_vertices_reverse.find(*vlist_it) - ->second[3*off[0]+off[1]-1]=vit2; - CGAL_triangulation_assertion(get_offset(vit2) == off); + vit2 != vertices_end() ; ++vit2) + { + if (vit2->offset() != Offset()) + { + //TODO: use some binding, maybe boost instead of the Finder. + typename std::list::iterator vlist_it + = std::find_if(vlist.begin(), vlist.end(), + Finder(this, vit2->point())); + Offset off = vit2->offset(); + _virtual_vertices.insert(std::make_pair(vit2, + std::make_pair(*vlist_it, off))); + _virtual_vertices_reverse.find(*vlist_it) + ->second[3 * off[0] + off[1] - 1] = vit2; + CGAL_triangulation_assertion(get_offset(vit2) == off); + } } - } // Cleanup vertex offsets for (Vertex_iterator vit = vertices_begin() ; vit != vertices_end() ; ++vit) @@ -1401,76 +1544,89 @@ copy_multiple_covering(const Periodic_2_triangulation_2 & tr) { _too_long_edge_counter = 0; _too_long_edges.clear(); for (Vertex_iterator vit = vertices_begin() ; - vit != vertices_end() ; ++vit) + vit != vertices_end() ; ++vit) _too_long_edges[vit] = std::list(); std::pair edge_to_add; - Point p1,p2; - int i,j; + Point p1, p2; + int i, j; for (Edge_iterator eit = edges_begin() ; - eit != edges_end() ; ++eit) { - if (&*(eit->first->vertex(cw(eit->second))) - < &*(eit->first->vertex(ccw(eit->second)))) { - i = cw(eit->second); j = ccw(eit->second); - } else { - i = ccw(eit->second); j = cw(eit->second); + eit != edges_end() ; ++eit) + { + if (&*(eit->first->vertex(cw(eit->second))) + < &*(eit->first->vertex(ccw(eit->second)))) + { + i = cw(eit->second); + j = ccw(eit->second); + } + else + { + i = ccw(eit->second); + j = cw(eit->second); + } + edge_to_add = std::make_pair(eit->first->vertex(i), + eit->first->vertex(j)); + p1 = construct_point(eit->first->vertex(i)->point(), + get_offset(eit->first, i)); + p2 = construct_point(eit->first->vertex(j)->point(), + get_offset(eit->first, j)); + Vertex_handle v_no = eit->first->vertex(i); + if (squared_distance(p1, p2) > _edge_length_threshold) + { + CGAL_triangulation_assertion( + find(_too_long_edges[v_no].begin(), + _too_long_edges[v_no].end(), + edge_to_add.second) == _too_long_edges[v_no].end()); + _too_long_edges[v_no].push_back(edge_to_add.second); + _too_long_edge_counter++; + } } - edge_to_add = std::make_pair(eit->first->vertex(i), - eit->first->vertex(j)); - p1 = construct_point(eit->first->vertex(i)->point(), - get_offset(eit->first, i)); - p2 = construct_point(eit->first->vertex(j)->point(), - get_offset(eit->first, j)); - Vertex_handle v_no = eit->first->vertex(i); - if (squared_distance(p1,p2) > _edge_length_threshold) { - CGAL_triangulation_assertion( - find(_too_long_edges[v_no].begin(), - _too_long_edges[v_no].end(), - edge_to_add.second) == _too_long_edges[v_no].end()); - _too_long_edges[v_no].push_back(edge_to_add.second); - _too_long_edge_counter++; - } - } } template void Periodic_2_triangulation_2::copy_triangulation( - const Periodic_2_triangulation_2 &tr) { + const Periodic_2_triangulation_2 &tr) +{ _tds.clear(); _gt = tr._gt; _cover = tr._cover; _domain = tr._domain; _edge_length_threshold = tr._edge_length_threshold; _too_long_edge_counter = tr._too_long_edge_counter; - if (tr.is_1_cover()) { - _tds = tr.tds(); - } else { - copy_multiple_covering(tr); - } + if (tr.is_1_cover()) + { + _tds = tr.tds(); + } + else + { + copy_multiple_covering(tr); + } CGAL_assertion(_too_long_edge_counter == tr._too_long_edge_counter); CGAL_triangulation_expensive_postcondition(*this == tr); } template -void Periodic_2_triangulation_2::swap(Periodic_2_triangulation_2 &tr) { +void Periodic_2_triangulation_2::swap(Periodic_2_triangulation_2 &tr) +{ _tds.swap(tr._tds); Geom_traits t = geom_traits(); _gt = tr.geom_traits(); tr._gt = t; - std::swap(tr._cover,_cover); - std::swap(tr._domain,_domain); + std::swap(tr._cover, _cover); + std::swap(tr._domain, _domain); - std::swap(tr._edge_length_threshold,_edge_length_threshold); - std::swap(tr._too_long_edges,_too_long_edges); - std::swap(tr._too_long_edge_counter,_too_long_edge_counter); + std::swap(tr._edge_length_threshold, _edge_length_threshold); + std::swap(tr._too_long_edges, _too_long_edges); + std::swap(tr._too_long_edge_counter, _too_long_edge_counter); std::swap(tr._virtual_vertices, _virtual_vertices); std::swap(tr._virtual_vertices_reverse, _virtual_vertices_reverse); } template -void Periodic_2_triangulation_2::clear() { +void Periodic_2_triangulation_2::clear() +{ _tds.clear(); _tds.set_dimension(-2); @@ -1484,62 +1640,72 @@ void Periodic_2_triangulation_2::clear() { } template -bool Periodic_2_triangulation_2::is_valid(Face_handle fh, bool /*verbose*/, int /*level*/) const { +bool Periodic_2_triangulation_2::is_valid(Face_handle fh, bool /*verbose*/, int /*level*/) const +{ bool result = true; int xmin, xmax, ymin, ymax; xmin = ymin = 3; xmax = ymax = 0; - for (int i = 0; i < 3; ++i) { - Offset o = get_offset(fh, i); - xmin = (std::min)(xmin, o[0]); - xmax = (std::max)(xmax, o[0]); - ymin = (std::min)(ymin, o[1]); - ymax = (std::max)(ymax, o[1]); - } + for (int i = 0; i < 3; ++i) + { + Offset o = get_offset(fh, i); + xmin = (std::min)(xmin, o[0]); + xmax = (std::max)(xmax, o[0]); + ymin = (std::min)(ymin, o[1]); + ymax = (std::max)(ymax, o[1]); + } // Should at most cross 1 border in each direction result &= (xmax - xmin <= 1); result &= (ymax - ymin <= 1); - if (!result) { - std::cerr << "min/max: " << xmin << "," << xmax << " " << ymin << "," << ymax << std::endl; - for (int i = 0; i < 3; ++i) { - Offset o = get_offset(fh, i); - std::cerr << "Offset: " << o << std::endl; + if (!result) + { + std::cerr << "min/max: " << xmin << "," << xmax << " " << ymin << "," << ymax << std::endl; + for (int i = 0; i < 3; ++i) + { + Offset o = get_offset(fh, i); + std::cerr << "Offset: " << o << std::endl; + } + std::cerr << std::endl; + CGAL_triangulation_assertion(false); } - std::cerr << std::endl; - CGAL_triangulation_assertion(false); - } return result; } template -bool Periodic_2_triangulation_2::is_valid(bool verbose, int level) const { +bool Periodic_2_triangulation_2::is_valid(bool verbose, int level) const +{ bool result = _tds.is_valid(verbose, level); CGAL_triangulation_assertion(result); - if (dimension() == 2) { - // Check positive orientation: - const Point *p[3]; - Offset off[3]; - for (Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) { - for (int i = 0; i < 3; i++) { - p[i] = &fit->vertex(i)->point(); - off[i] = get_offset(fit, i); - } + if (dimension() == 2) + { + // Check positive orientation: + const Point *p[3]; + Offset off[3]; + for (Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) + { + for (int i = 0; i < 3; i++) + { + p[i] = &fit->vertex(i)->point(); + off[i] = get_offset(fit, i); + } - if (orientation(*p[0], *p[1], *p[2], off[0], off[1], off[2]) != POSITIVE) { - if (verbose) { - std::cerr - << "Periodic_2_triangulation_2: wrong orientation:" << "\n" - << *p[0] << " \t" << off[0] << "\n" - << *p[1] << " \t" << off[1] << "\n" - << *p[2] << " \t" << off[2] << std::endl; + if (orientation(*p[0], *p[1], *p[2], off[0], off[1], off[2]) != POSITIVE) + { + if (verbose) + { + std::cerr + << "Periodic_2_triangulation_2: wrong orientation:" << "\n" + << *p[0] << " \t" << off[0] << "\n" + << *p[1] << " \t" << off[1] << "\n" + << *p[2] << " \t" << off[2] << std::endl; + } + result = false; + } } - result = false; - } } - } CGAL_triangulation_assertion(result); // Check for the right number of simplices @@ -1559,49 +1725,62 @@ bool Periodic_2_triangulation_2::is_valid(bool verbose, int level) cons CGAL_triangulation_assertion(result); // Edges should not be longer than 1 periodicity - for (Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) { - result &= is_valid(fit, verbose, level); - } + for (Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) + { + result &= is_valid(fit, verbose, level); + } CGAL_triangulation_assertion(result); result &= is_1_cover() == _virtual_vertices.empty(); result &= is_1_cover() == _virtual_vertices_reverse.empty(); result &= (_virtual_vertices.size() == (number_of_sheets()[0] - * number_of_sheets()[1] - 1) * _virtual_vertices_reverse.size()); + * number_of_sheets()[1] - 1) * _virtual_vertices_reverse.size()); CGAL_triangulation_assertion(result); for (Virtual_vertex_map_it it = _virtual_vertices.begin(); it - != _virtual_vertices.end(); ++it) { - const Vertex_handle © = it->first; - const Vertex_handle &orig = it->second.first; - const Offset &off = it->second.second; - size_t index = number_of_sheets()[0] * off[0] + off[1] - 1; - Virtual_vertex_reverse_map_it rev_it = _virtual_vertices_reverse.find(orig); - if (rev_it != _virtual_vertices_reverse.end()) { - if (index < rev_it->second.size()) { - result &= (rev_it->second[index] == copy); - } else { - result &= false; - } - } else { - result &= false; + != _virtual_vertices.end(); ++it) + { + const Vertex_handle © = it->first; + const Vertex_handle &orig = it->second.first; + const Offset &off = it->second.second; + size_t index = number_of_sheets()[0] * off[0] + off[1] - 1; + Virtual_vertex_reverse_map_it rev_it = _virtual_vertices_reverse.find(orig); + if (rev_it != _virtual_vertices_reverse.end()) + { + if (index < rev_it->second.size()) + { + result &= (rev_it->second[index] == copy); + } + else + { + result &= false; + } + } + else + { + result &= false; + } } - } CGAL_triangulation_assertion(result); for (Virtual_vertex_reverse_map_it it = _virtual_vertices_reverse.begin(); it - != _virtual_vertices_reverse.end(); ++it) { - const std::vector &copies = it->second; - result &= copies.size() == 8; - for (size_t i = 0; i < copies.size(); ++i) { - Virtual_vertex_map_it copy_it = _virtual_vertices.find(copies[i]); - if (copy_it != _virtual_vertices.end()) { - result &= copy_it->second.first == it->first; - } else { - result &= false; - } + != _virtual_vertices_reverse.end(); ++it) + { + const std::vector &copies = it->second; + result &= copies.size() == 8; + for (size_t i = 0; i < copies.size(); ++i) + { + Virtual_vertex_map_it copy_it = _virtual_vertices.find(copies[i]); + if (copy_it != _virtual_vertices.end()) + { + result &= copy_it->second.first == it->first; + } + else + { + result &= false; + } + } } - } // Check the too_long_edges administration result &= is_valid_too_long_edges(verbose, level); @@ -1610,94 +1789,114 @@ bool Periodic_2_triangulation_2::is_valid(bool verbose, int level) cons } template -bool Periodic_2_triangulation_2::is_valid_too_long_edges(bool verbose, int /*level*/) const { +bool Periodic_2_triangulation_2::is_valid_too_long_edges(bool verbose, int /*level*/) const +{ bool result = true; result &= is_1_cover() == _too_long_edges.empty(); CGAL_triangulation_assertion(result); unsigned int too_long_edges = 0; for (Too_long_edges_map_it it = _too_long_edges.begin(); it - != _too_long_edges.end(); ++it) { - too_long_edges += it->second.size(); - } + != _too_long_edges.end(); ++it) + { + too_long_edges += it->second.size(); + } CGAL_triangulation_assertion(result); - if (_too_long_edge_counter != too_long_edges) { - if (verbose) std::cout << "Too long edge counter is incorrect: " << _too_long_edge_counter << " != " << too_long_edges << std::endl; - result = false; - } + if (_too_long_edge_counter != too_long_edges) + { + if (verbose) std::cout << "Too long edge counter is incorrect: " << _too_long_edge_counter << " != " << too_long_edges << std::endl; + result = false; + } CGAL_triangulation_assertion(result); /// Expensive check whether the right too long edges are in the list - if (is_1_cover()) { - for (Edge_iterator eit = edges_begin(); eit != edges_end(); ++eit) { - Vertex_handle vh1 = eit->first->vertex(ccw(eit->second)); - Vertex_handle vh2 = eit->first->vertex(cw(eit->second)); - Point p1 = construct_point(vh1->point(), get_offset(eit->first, ccw(eit->second))); - Point p2 = construct_point(vh2->point(), get_offset(eit->first, cw(eit->second))); - result &= (!edge_is_too_long(p1, p2)); - } - CGAL_triangulation_assertion(result); - } else { - too_long_edges = 0; - for (Edge_iterator eit = edges_begin(); eit != edges_end(); ++eit) { - Vertex_handle vh1 = eit->first->vertex(ccw(eit->second)); - Vertex_handle vh2 = eit->first->vertex(cw(eit->second)); - Point p1 = construct_point(vh1->point(), - get_offset(eit->first, ccw(eit->second))); - Point p2 = construct_point(vh2->point(), - get_offset(eit->first, cw(eit->second))); - - if (&*vh2 < &*vh1) - std::swap(vh1, vh2); - CGAL_triangulation_assertion(&*vh1 < &*vh2); - - bool too_long = edge_is_too_long(p1, p2); - if (too_long != edge_is_too_long(p2, p1)) { - if (verbose) std::cout << "Long edge criterion not symmetric c(v1,v2) != c(v2,v1)" << std::endl; - result = false; - } - CGAL_triangulation_assertion(result); - - Too_long_edges_map_it it = _too_long_edges.find(vh1); - if (it == _too_long_edges.end()) { - if (too_long) { - if (verbose) std::cout << "1. Too long edge not in the datastructure" << std::endl; - result = false; - } - result &= !too_long; - CGAL_triangulation_assertion(result); - } else { - typename std::list::const_iterator it2 = find(it->second.begin(), it->second.end(), vh2); - if (too_long) { - too_long_edges++; - if (it2 == it->second.end()) { - if (verbose) std::cout << "2. Too long edge not in the datastructure" << std::endl; - result = false; - } - CGAL_triangulation_assertion(result); - } else { - if (it2 != it->second.end()) { - if (verbose) std::cout << "Edge is not too long, but contained in the datastructure" << std::endl; - result = false; - } - CGAL_triangulation_assertion(result); + if (is_1_cover()) + { + for (Edge_iterator eit = edges_begin(); eit != edges_end(); ++eit) + { + Vertex_handle vh1 = eit->first->vertex(ccw(eit->second)); + Vertex_handle vh2 = eit->first->vertex(cw(eit->second)); + Point p1 = construct_point(vh1->point(), get_offset(eit->first, ccw(eit->second))); + Point p2 = construct_point(vh2->point(), get_offset(eit->first, cw(eit->second))); + result &= (!edge_is_too_long(p1, p2)); } - } + CGAL_triangulation_assertion(result); } + else + { + too_long_edges = 0; + for (Edge_iterator eit = edges_begin(); eit != edges_end(); ++eit) + { + Vertex_handle vh1 = eit->first->vertex(ccw(eit->second)); + Vertex_handle vh2 = eit->first->vertex(cw(eit->second)); + Point p1 = construct_point(vh1->point(), + get_offset(eit->first, ccw(eit->second))); + Point p2 = construct_point(vh2->point(), + get_offset(eit->first, cw(eit->second))); - if (_too_long_edge_counter != too_long_edges) { - if (verbose) - std::cout << "Counts do not match: " << _too_long_edge_counter << " != " << too_long_edges << std::endl; - result = false; + if (&*vh2 < &*vh1) + std::swap(vh1, vh2); + CGAL_triangulation_assertion(&*vh1 < &*vh2); + + bool too_long = edge_is_too_long(p1, p2); + if (too_long != edge_is_too_long(p2, p1)) + { + if (verbose) std::cout << "Long edge criterion not symmetric c(v1,v2) != c(v2,v1)" << std::endl; + result = false; + } + CGAL_triangulation_assertion(result); + + Too_long_edges_map_it it = _too_long_edges.find(vh1); + if (it == _too_long_edges.end()) + { + if (too_long) + { + if (verbose) std::cout << "1. Too long edge not in the datastructure" << std::endl; + result = false; + } + result &= !too_long; + CGAL_triangulation_assertion(result); + } + else + { + typename std::list::const_iterator it2 = find(it->second.begin(), it->second.end(), vh2); + if (too_long) + { + too_long_edges++; + if (it2 == it->second.end()) + { + if (verbose) std::cout << "2. Too long edge not in the datastructure" << std::endl; + result = false; + } + CGAL_triangulation_assertion(result); + } + else + { + if (it2 != it->second.end()) + { + if (verbose) std::cout << "Edge is not too long, but contained in the datastructure" << std::endl; + result = false; + } + CGAL_triangulation_assertion(result); + } + } + } + + if (_too_long_edge_counter != too_long_edges) + { + if (verbose) + std::cout << "Counts do not match: " << _too_long_edge_counter << " != " << too_long_edges << std::endl; + result = false; + } + CGAL_triangulation_assertion(result); } - CGAL_triangulation_assertion(result); - } return result; } template -bool Periodic_2_triangulation_2::flippable(Face_handle f, int i) { +bool Periodic_2_triangulation_2::flippable(Face_handle f, int i) +{ Face_handle nb = f->neighbor(i); int j = nb->index(f); @@ -1708,41 +1907,46 @@ bool Periodic_2_triangulation_2::flippable(Face_handle f, int i) { p[2] = &f->vertex(ccw(i))->point(); // ccw p[3] = &f->vertex(cw(i))->point(); // cw - if (is_1_cover() && f->has_zero_offsets() && nb->has_zero_offsets()) { - // if (orientation(*p[0], *p[1], *p[2]) != RIGHT_TURN) - // return false; - // if (orientation(*p[0], *p[1], *p[3]) != LEFT_TURN) - // return false; - if (orientation(*p[0], *p[1], *p[2]) == LEFT_TURN) - return false; - if (orientation(*p[0], *p[1], *p[3]) == RIGHT_TURN) - return false; - } else { - Offset off[4]; - off[0] = get_offset(f, i); - off[1] = combine_offsets(get_offset(nb, j), get_neighbor_offset(nb, j, f, i)); - off[2] = get_offset(f, ccw(i)); - off[3] = get_offset(f, cw(i)); - - // if (orientation(*p[0], *p[1], *p[2], off[0], off[1], off[2]) != RIGHT_TURN) - // return false; - // if (orientation(*p[0], *p[1], *p[3], off[0], off[1], off[3]) != LEFT_TURN) - // return false; - if (orientation(*p[0], *p[1], *p[2], off[0], off[1], off[2]) == LEFT_TURN) - return false; - if (orientation(*p[0], *p[1], *p[3], off[0], off[1], off[3]) == RIGHT_TURN) - return false; - } + if (is_1_cover() && f->has_zero_offsets() && nb->has_zero_offsets()) + { + // if (orientation(*p[0], *p[1], *p[2]) != RIGHT_TURN) + // return false; + // if (orientation(*p[0], *p[1], *p[3]) != LEFT_TURN) + // return false; + if (orientation(*p[0], *p[1], *p[2]) == LEFT_TURN) + return false; + if (orientation(*p[0], *p[1], *p[3]) == RIGHT_TURN) + return false; + } + else + { + Offset off[4]; + off[0] = get_offset(f, i); + off[1] = combine_offsets(get_offset(nb, j), get_neighbor_offset(nb, j, f, i)); + off[2] = get_offset(f, ccw(i)); + off[3] = get_offset(f, cw(i)); + + // if (orientation(*p[0], *p[1], *p[2], off[0], off[1], off[2]) != RIGHT_TURN) + // return false; + // if (orientation(*p[0], *p[1], *p[3], off[0], off[1], off[3]) != LEFT_TURN) + // return false; + if (orientation(*p[0], *p[1], *p[2], off[0], off[1], off[2]) == LEFT_TURN) + return false; + if (orientation(*p[0], *p[1], *p[3], off[0], off[1], off[3]) == RIGHT_TURN) + return false; + } return true; } template -void Periodic_2_triangulation_2::flip(Face_handle f, int i) { - if (is_1_cover()) { - flip_single_edge(f, i); - return; - } +void Periodic_2_triangulation_2::flip(Face_handle f, int i) +{ + if (is_1_cover()) + { + flip_single_edge(f, i); + return; + } Vertex_handle vh1 = f->vertex( cw(i)); Vertex_handle vh2 = f->vertex(ccw(i)); @@ -1750,57 +1954,63 @@ void Periodic_2_triangulation_2::flip(Face_handle f, int i) { Virtual_vertex_map_it it_vh2 = _virtual_vertices.find(vh2); Offset vh1_offset, vh2_offset; - if (it_vh1 != _virtual_vertices.end()) { - vh1 = it_vh1->second.first; - vh1_offset = it_vh1->second.second; - } - if (it_vh2 != _virtual_vertices.end()) { - vh2 = it_vh2->second.first; - vh2_offset = it_vh2->second.second; - } + if (it_vh1 != _virtual_vertices.end()) + { + vh1 = it_vh1->second.first; + vh1_offset = it_vh1->second.second; + } + if (it_vh2 != _virtual_vertices.end()) + { + vh2 = it_vh2->second.first; + vh2_offset = it_vh2->second.second; + } CGAL_triangulation_assertion( virtual_vertices_reverse().find(vh1) != virtual_vertices_reverse().end()); CGAL_triangulation_assertion( virtual_vertices_reverse().find(vh2) != virtual_vertices_reverse().end()); - const std::vector &v1s = + const std::vector &v1s = virtual_vertices_reverse().find(vh1)->second; - const std::vector &v2s = + const std::vector &v2s = virtual_vertices_reverse().find(vh2)->second; - + CGAL_assertion(v1s.size() == 8); CGAL_assertion(v1s.size() == v2s.size()); - + bool found; - Face_handle fh; int index; + Face_handle fh; + int index; Vertex_handle vh1_copy, vh2_copy; // Virtual copies - for (int x=0; x<3; ++x) { - for (int y=0; y<3; ++y) { - int i1 = 3*((x+vh1_offset.x())%3) + ((y+vh1_offset.y())%3); - int i2 = 3*((x+vh2_offset.x())%3) + ((y+vh2_offset.y())%3); + for (int x = 0; x < 3; ++x) + { + for (int y = 0; y < 3; ++y) + { + int i1 = 3 * ((x + vh1_offset.x()) % 3) + ((y + vh1_offset.y()) % 3); + int i2 = 3 * ((x + vh2_offset.x()) % 3) + ((y + vh2_offset.y()) % 3); - if (i1 == 0) - vh1_copy = vh1; - else - vh1_copy = v1s[i1-1]; - if (i2 == 0) - vh2_copy = vh2; - else - vh2_copy = v2s[i2-1]; + if (i1 == 0) + vh1_copy = vh1; + else + vh1_copy = v1s[i1 - 1]; + if (i2 == 0) + vh2_copy = vh2; + else + vh2_copy = v2s[i2 - 1]; - found = is_edge(vh1_copy, vh2_copy, fh, index); - CGAL_assertion(found); + found = is_edge(vh1_copy, vh2_copy, fh, index); + CGAL_assertion(found); - flip_single_edge(fh, index); + flip_single_edge(fh, index); + } } - } try_to_convert_to_one_cover(); } template -void Periodic_2_triangulation_2::flip_single_edge(Face_handle f, int i) { +void Periodic_2_triangulation_2::flip_single_edge(Face_handle f, int i) +{ CGAL_triangulation_precondition(f != Face_handle()); CGAL_triangulation_precondition(i == 0 || i == 1 || i == 2); CGAL_triangulation_precondition(dimension() == 2); @@ -1811,14 +2021,15 @@ void Periodic_2_triangulation_2::flip_single_edge(Face_handle f, int i) remove_too_long_edge(f, i); Face_handle nb = f->neighbor(i); - if (f->has_zero_offsets() && nb->has_zero_offsets()) { - _tds.flip(f, i); + if (f->has_zero_offsets() && nb->has_zero_offsets()) + { + _tds.flip(f, i); - if (!is_1_cover()) - insert_too_long_edge(f, ccw(i)); + if (!is_1_cover()) + insert_too_long_edge(f, ccw(i)); - return; - } + return; + } int nb_index = nb->index(f); int offsets[4]; @@ -1829,30 +2040,38 @@ void Periodic_2_triangulation_2::flip_single_edge(Face_handle f, int i) // Move the offsets of f and nb in the same space by correcting for nb_offset Offset nb_offset = get_neighbor_offset(f, i, nb, nb_index); - if (nb_offset.x() != 0) { - if (nb_offset.x() == 1) { - CGAL_assertion(((offsets[0] & 2) | (offsets[1] & 2) | (offsets[2] & 2)) == 0); - offsets[0] |= 2; - offsets[1] |= 2; - offsets[2] |= 2; - } else { - CGAL_triangulation_assertion(nb_offset.x() == -1); - CGAL_assertion((offsets[3] & 2) == 0); - offsets[3] |= 2; + if (nb_offset.x() != 0) + { + if (nb_offset.x() == 1) + { + CGAL_assertion(((offsets[0] & 2) | (offsets[1] & 2) | (offsets[2] & 2)) == 0); + offsets[0] |= 2; + offsets[1] |= 2; + offsets[2] |= 2; + } + else + { + CGAL_triangulation_assertion(nb_offset.x() == -1); + CGAL_assertion((offsets[3] & 2) == 0); + offsets[3] |= 2; + } } - } - if (nb_offset.y() != 0) { - if (nb_offset.y() == 1) { - CGAL_assertion(((offsets[0] & 1) | (offsets[1] & 1) | (offsets[2] & 1)) == 0); - offsets[0] |= 1; - offsets[1] |= 1; - offsets[2] |= 1; - } else { - CGAL_triangulation_assertion(nb_offset.y() == -1); - CGAL_assertion((offsets[3] & 1) == 0); - offsets[3] |= 1; + if (nb_offset.y() != 0) + { + if (nb_offset.y() == 1) + { + CGAL_assertion(((offsets[0] & 1) | (offsets[1] & 1) | (offsets[2] & 1)) == 0); + offsets[0] |= 1; + offsets[1] |= 1; + offsets[2] |= 1; + } + else + { + CGAL_triangulation_assertion(nb_offset.y() == -1); + CGAL_assertion((offsets[3] & 1) == 0); + offsets[3] |= 1; + } } - } CGAL_assertion((offsets[0] & offsets[1] & offsets[2] & offsets[3]) == 0); CGAL_triangulation_assertion_code(Vertex_handle vh = f->vertex(i)); CGAL_triangulation_assertion_code(Vertex_handle vh_ccw = f->vertex(ccw(i))); @@ -1882,20 +2101,23 @@ void Periodic_2_triangulation_2::flip_single_edge(Face_handle f, int i) template void -Periodic_2_triangulation_2::remove_from_virtual_copies(Vertex_handle v) { +Periodic_2_triangulation_2::remove_from_virtual_copies(Vertex_handle v) +{ typename Virtual_vertex_reverse_map::iterator rev_it = _virtual_vertices_reverse.find(v); CGAL_triangulation_assertion(rev_it != _virtual_vertices_reverse.end()); const std::vector &virtual_copies = rev_it->second; - for (size_t i=0; i -typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangulation_2< - Gt, Tds>::insert_first(const Point& p) { +typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangulation_2 < +Gt, Tds >::insert_first(const Point& p) +{ CGAL_assertion(empty()); // The empty triangulation has a single sheeted cover _cover = make_array(3, 3); @@ -1909,69 +2131,86 @@ typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangula vir_vertices[0][0] = _tds.create_vertex(); vir_vertices[0][0]->set_point(p); _virtual_vertices_reverse[vir_vertices[0][0]] = std::vector(); - for (int i = 0; i < _cover[0]; i++) { - for (int j = 0; j < _cover[1]; j++) { - if ((i != 0) || (j != 0)) { - // Initialise virtual vertices out of the domain for debugging - vir_vertices[i][j] = _tds.create_vertex(); - vir_vertices[i][j]->set_point(p); //+Offset(i,j)); - _virtual_vertices[vir_vertices[i][j]] = Virtual_vertex( - vir_vertices[0][0], Offset(i, j)); - _virtual_vertices_reverse[vir_vertices[0][0]].push_back( - vir_vertices[i][j]); - } + for (int i = 0; i < _cover[0]; i++) + { + for (int j = 0; j < _cover[1]; j++) + { + if ((i != 0) || (j != 0)) + { + // Initialise virtual vertices out of the domain for debugging + vir_vertices[i][j] = _tds.create_vertex(); + vir_vertices[i][j]->set_point(p); //+Offset(i,j)); + _virtual_vertices[vir_vertices[i][j]] = Virtual_vertex( + vir_vertices[0][0], Offset(i, j)); + _virtual_vertices_reverse[vir_vertices[0][0]].push_back( + vir_vertices[i][j]); + } + } } - } // Create faces: - for (int i = 0; i < _cover[0]; i++) { - for (int j = 0; j < _cover[1]; j++) { - for (int f = 0; f < 2; f++) { - // f faces per 'rectangle' - faces[i][j][f] = _tds.create_face(); - } + for (int i = 0; i < _cover[0]; i++) + { + for (int j = 0; j < _cover[1]; j++) + { + for (int f = 0; f < 2; f++) + { + // f faces per 'rectangle' + faces[i][j][f] = _tds.create_face(); + } + } } - } // table containing the vertex information // index to the right vertex: [number of faces][vertex][offset] int vertex_ind[2][3][2] = { { { 0, 0 }, { 1, 1 }, { 0, 1 } }, { { 0, 0 }, { - 1, 0 }, { 1, 1 } } }; + 1, 0 + }, { 1, 1 } + } + }; // Table containing the neighbor information // [number of faces][neighbor][offset,face] int neighb_ind[2][3][3] = { { { 0, 1, 1 }, { -1, 0, 1 }, { 0, 0, 1 } }, { { - 1, 0, 0 }, { 0, 0, 0 }, { 0, -1, 0 } } }; - for (int i = 0; i < _cover[0]; i++) { - for (int j = 0; j < _cover[1]; j++) { - int offset = - ((i == _cover[0] - 1 ? 2 : 0) | (j == _cover[1] - 1 ? 1 : 0)); - for (int f = 0; f < 2; f++) { - faces[i][j][f]->set_vertices(vir_vertices[(i + vertex_ind[f][0][0]) - % _cover[0]][(j + vertex_ind[f][0][1]) % _cover[1]], - vir_vertices[(i + vertex_ind[f][1][0]) % _cover[0]][(j - + vertex_ind[f][1][1]) % _cover[1]], vir_vertices[(i - + vertex_ind[f][2][0]) % _cover[0]][(j + vertex_ind[f][2][1]) - % _cover[1]]); - set_offsets(faces[i][j][f], offset & (vertex_ind[f][0][0] * 2 - + vertex_ind[f][0][1] * 1), offset & (vertex_ind[f][1][0] * 2 - + vertex_ind[f][1][1] * 1), offset & (vertex_ind[f][2][0] * 2 - + vertex_ind[f][2][1] * 1)); - faces[i][j][f]->set_neighbors(faces[(i + _cover[0] - + neighb_ind[f][0][0]) % _cover[0]][(j + _cover[1] - + neighb_ind[f][0][1]) % _cover[1]][neighb_ind[f][0][2]], faces[(i - + _cover[0] + neighb_ind[f][1][0]) % _cover[0]][(j + _cover[1] - + neighb_ind[f][1][1]) % _cover[1]][neighb_ind[f][1][2]], faces[(i - + _cover[0] + neighb_ind[f][2][0]) % _cover[0]][(j + _cover[1] - + neighb_ind[f][2][1]) % _cover[1]][neighb_ind[f][2][2]]); - } + 1, 0, 0 + }, { 0, 0, 0 }, { 0, -1, 0 } + } + }; + for (int i = 0; i < _cover[0]; i++) + { + for (int j = 0; j < _cover[1]; j++) + { + int offset = + ((i == _cover[0] - 1 ? 2 : 0) | (j == _cover[1] - 1 ? 1 : 0)); + for (int f = 0; f < 2; f++) + { + faces[i][j][f]->set_vertices(vir_vertices[(i + vertex_ind[f][0][0]) + % _cover[0]][(j + vertex_ind[f][0][1]) % _cover[1]], + vir_vertices[(i + vertex_ind[f][1][0]) % _cover[0]][(j + + vertex_ind[f][1][1]) % _cover[1]], vir_vertices[(i + + vertex_ind[f][2][0]) % _cover[0]][(j + vertex_ind[f][2][1]) + % _cover[1]]); + set_offsets(faces[i][j][f], offset & (vertex_ind[f][0][0] * 2 + + vertex_ind[f][0][1] * 1), offset & (vertex_ind[f][1][0] * 2 + + vertex_ind[f][1][1] * 1), offset & (vertex_ind[f][2][0] * 2 + + vertex_ind[f][2][1] * 1)); + faces[i][j][f]->set_neighbors(faces[(i + _cover[0] + + neighb_ind[f][0][0]) % _cover[0]][(j + _cover[1] + + neighb_ind[f][0][1]) % _cover[1]][neighb_ind[f][0][2]], faces[(i + + _cover[0] + neighb_ind[f][1][0]) % _cover[0]][(j + _cover[1] + + neighb_ind[f][1][1]) % _cover[1]][neighb_ind[f][1][2]], faces[(i + + _cover[0] + neighb_ind[f][2][0]) % _cover[0]][(j + _cover[1] + + neighb_ind[f][2][1]) % _cover[1]][neighb_ind[f][2][2]]); + } + } } - } // set pointers from the vertices to incident faces. - for (int i = 0; i < _cover[0]; i++) { - for (int j = 0; j < _cover[1]; j++) { - vir_vertices[i][j]->set_face(faces[i][j][0]); + for (int i = 0; i < _cover[0]; i++) + { + for (int j = 0; j < _cover[1]; j++) + { + vir_vertices[i][j]->set_face(faces[i][j][0]); + } } - } _tds.set_dimension(2); @@ -1982,23 +2221,28 @@ typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangula // Insert all vertices as the first vertex in the _too_long_edges list int k = 0; std::list empty_list; - for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) { - _too_long_edges[vit] = empty_list; - k++; - } + for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) + { + _too_long_edges[vit] = empty_list; + k++; + } // Insert all edges as all edges are too long _too_long_edge_counter = 0; - for (Edge_iterator eit = edges_begin(); eit != edges_end(); eit++) { - Vertex_handle vh1 = eit->first->vertex(ccw(eit->second)); - Vertex_handle vh2 = eit->first->vertex(cw(eit->second)); - if (&*vh1 < &*vh2) { - _too_long_edges[vh1].push_back(vh2); - } else { - _too_long_edges[vh2].push_back(vh1); + for (Edge_iterator eit = edges_begin(); eit != edges_end(); eit++) + { + Vertex_handle vh1 = eit->first->vertex(ccw(eit->second)); + Vertex_handle vh2 = eit->first->vertex(cw(eit->second)); + if (&*vh1 < &*vh2) + { + _too_long_edges[vh1].push_back(vh2); + } + else + { + _too_long_edges[vh2].push_back(vh1); + } + _too_long_edge_counter++; } - _too_long_edge_counter++; - } return vir_vertices[0][0]; } @@ -2006,14 +2250,16 @@ typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangula template typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangulation_2::insert_in_edge(const Point& p, - Face_handle f, int i) { + Face_handle f, int i) +{ return insert(p, EDGE, f, i); } template typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangulation_2::insert_in_edge(const Point& p, const Offset &o, - Face_handle f, int i, - Vertex_handle vh) { + Face_handle f, int i, + Vertex_handle vh) +{ // Insert in edge calls an insert_in_face and a flip. // Therefore there is no need to update the too_long_edges bookkeeping directly. @@ -2025,11 +2271,11 @@ Periodic_2_triangulation_2::insert_in_edge(const Point& p, const Offset int j = nb->index(f); CGAL_triangulation_assertion_code(Offset current_offset = get_location_offset(f, p, o)); CGAL_triangulation_assertion - (orientation(f->vertex(cw(i))->point(), p, f->vertex(ccw(i))->point(), - get_offset(f,cw(i)), combine_offsets(o, current_offset), get_offset(f, ccw(i))) == COLLINEAR && - collinear_between(f->vertex(cw(i))->point(), p, f->vertex(ccw(i))->point(), - get_offset(f,cw(i)), combine_offsets(o, current_offset), get_offset(f, ccw(i))) ); - + (orientation(f->vertex(cw(i))->point(), p, f->vertex(ccw(i))->point(), + get_offset(f, cw(i)), combine_offsets(o, current_offset), get_offset(f, ccw(i))) == COLLINEAR && + collinear_between(f->vertex(cw(i))->point(), p, f->vertex(ccw(i))->point(), + get_offset(f, cw(i)), combine_offsets(o, current_offset), get_offset(f, ccw(i))) ); + /// Insert in the face and flip an edge Vertex_handle v = insert_in_face(p, o, f, vh); flip_single_edge(nb, j); @@ -2039,14 +2285,16 @@ Periodic_2_triangulation_2::insert_in_edge(const Point& p, const Offset template typename Periodic_2_triangulation_2::Vertex_handle -Periodic_2_triangulation_2::insert_in_face(const Point& p, Face_handle f) { +Periodic_2_triangulation_2::insert_in_face(const Point& p, Face_handle f) +{ return insert(p, FACE, f, 0); } template typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangulation_2::insert_in_face(const Point& p, const Offset &o, - Face_handle f, - Vertex_handle vh) { + Face_handle f, + Vertex_handle vh) +{ CGAL_triangulation_assertion(f != Face_handle()); CGAL_triangulation_assertion(number_of_vertices() != 0); CGAL_triangulation_assertion((!is_1_cover()) || (o == Offset())); @@ -2062,107 +2310,123 @@ Periodic_2_triangulation_2::insert_in_face(const Point& p, const Offset int offsets[3]; CGAL_triangulation_assertion_code( Vertex_handle vertices[3]; ) - if (!simplicity_criterion) { - // Choose the periodic copy of tester.point() that is inside c. - current_off = get_location_offset(f, p, o); + if (!simplicity_criterion) + { + // Choose the periodic copy of tester.point() that is inside c. + current_off = get_location_offset(f, p, o); - CGAL_triangulation_assertion(oriented_side(f, p, combine_offsets(o,current_off)) != ON_NEGATIVE_SIDE); + CGAL_triangulation_assertion(oriented_side(f, p, combine_offsets(o, current_off)) != ON_NEGATIVE_SIDE); - for (int i = 0; i < 3; ++i) { - nb[i] = f->neighbor(i); - nb_index[i] = nb[i]->index(f); - offsets[i] = f->offset(i); - CGAL_triangulation_assertion_code( vertices[i] = f->vertex(i); ); + for (int i = 0; i < 3; ++i) + { + nb[i] = f->neighbor(i); + nb_index[i] = nb[i]->index(f); + offsets[i] = f->offset(i); + CGAL_triangulation_assertion_code( vertices[i] = f->vertex(i); ); + } } - } // Insert the new vertex Vertex_handle v = _tds.insert_in_face(f); v->set_point(p); - if (!simplicity_criterion) { - // Update the offsets - int v_offset = off_to_int(current_off); - int new_offsets[3]; - for (int i = 0; i < 3; ++i) { - Face_handle new_face = nb[i]->neighbor(nb_index[i]); - int v_index = new_face->index(v); + if (!simplicity_criterion) + { + // Update the offsets + int v_offset = off_to_int(current_off); + int new_offsets[3]; + for (int i = 0; i < 3; ++i) + { + Face_handle new_face = nb[i]->neighbor(nb_index[i]); + int v_index = new_face->index(v); - CGAL_triangulation_assertion(new_face->vertex(ccw(v_index)) == vertices[ccw(i)]); - CGAL_triangulation_assertion(new_face->vertex(cw(v_index)) == vertices[cw(i)]); + CGAL_triangulation_assertion(new_face->vertex(ccw(v_index)) == vertices[ccw(i)]); + CGAL_triangulation_assertion(new_face->vertex(cw(v_index)) == vertices[cw(i)]); - new_offsets[v_index] = v_offset; - new_offsets[ccw(v_index)] = offsets[ccw(i)]; - new_offsets[cw(v_index)] = offsets[cw(i)]; - set_offsets(new_face, new_offsets[0], new_offsets[1], new_offsets[2]); - } - } - - if (!is_1_cover()) { - // update the book-keeping in case of a periodic copy - if (vh != Vertex_handle()) { - _virtual_vertices[v] = Virtual_vertex(vh, o); - _virtual_vertices_reverse[vh].push_back(v); + new_offsets[v_index] = v_offset; + new_offsets[ccw(v_index)] = offsets[ccw(i)]; + new_offsets[cw(v_index)] = offsets[cw(i)]; + set_offsets(new_face, new_offsets[0], new_offsets[1], new_offsets[2]); + } } - insert_too_long_edges_in_star(v); - } + if (!is_1_cover()) + { + // update the book-keeping in case of a periodic copy + if (vh != Vertex_handle()) + { + _virtual_vertices[v] = Virtual_vertex(vh, o); + _virtual_vertices_reverse[vh].push_back(v); + } + + insert_too_long_edges_in_star(v); + } return v; } template typename Periodic_2_triangulation_2::Vertex_handle -Periodic_2_triangulation_2::insert(const Point &p, Face_handle start) { +Periodic_2_triangulation_2::insert(const Point &p, Face_handle start) +{ CGAL_triangulation_assertion((_domain.xmin() <= p.x()) && - (p.x() < _domain.xmax())); + (p.x() < _domain.xmax())); CGAL_triangulation_assertion((_domain.ymin() <= p.y()) && - (p.y() < _domain.ymax())); + (p.y() < _domain.ymax())); - if (number_of_stored_vertices() == 0) { - return insert_first(p); - } + if (number_of_stored_vertices() == 0) + { + return insert_first(p); + } - if (start == Face_handle()) { - start = faces_begin(); - } + if (start == Face_handle()) + { + start = faces_begin(); + } Locate_type lt; int li; Face_handle loc = locate(p, lt, li, start); - if (start != Face_handle()) { - CGAL_assertion(start->vertex(0) != Vertex_handle()); - } + if (start != Face_handle()) + { + CGAL_assertion(start->vertex(0) != Vertex_handle()); + } return insert(p, lt, loc, li); } template typename Periodic_2_triangulation_2::Vertex_handle -Periodic_2_triangulation_2::insert(const Point& p, - Locate_type lt, Face_handle loc, int li) { - if (number_of_stored_vertices() == 0) { - return insert_first(p); - } +Periodic_2_triangulation_2::insert(const Point& p, + Locate_type lt, Face_handle loc, int li) +{ + if (number_of_stored_vertices() == 0) + { + return insert_first(p); + } // vstart is a vertex incident to the Face_handle start that will be used as // for creating a start point for the virtual vertices. // We use the virtual copies of a vertex incident to loc. Vertex_handle vstart; - if (!is_1_cover()) { - Virtual_vertex_map_it vvmit = _virtual_vertices.find(loc->vertex(0)); - if (vvmit == _virtual_vertices.end()) { - vstart = loc->vertex(0); - } else { - vstart = vvmit->second.first; - } + if (!is_1_cover()) + { + Virtual_vertex_map_it vvmit = _virtual_vertices.find(loc->vertex(0)); + if (vvmit == _virtual_vertices.end()) + { + vstart = loc->vertex(0); + } + else + { + vstart = vvmit->second.first; + } - // vstart should be non-virtual, but should have virtual copies - CGAL_triangulation_assertion(_virtual_vertices.find(vstart) - == _virtual_vertices.end()); - CGAL_triangulation_assertion(_virtual_vertices_reverse.find(vstart) - != _virtual_vertices_reverse.end()); - } + // vstart should be non-virtual, but should have virtual copies + CGAL_triangulation_assertion(_virtual_vertices.find(vstart) + == _virtual_vertices.end()); + CGAL_triangulation_assertion(_virtual_vertices_reverse.find(vstart) + != _virtual_vertices_reverse.end()); + } Vertex_handle vh = insert(p, Offset(), lt, loc, li, Vertex_handle()); @@ -2176,59 +2440,69 @@ Periodic_2_triangulation_2::insert(const Point& p, return vh; const std::vector &start_vertices = - _virtual_vertices_reverse.find(vstart)->second; + _virtual_vertices_reverse.find(vstart)->second; CGAL_assertion(start_vertices.size() == size_t(number_of_sheets()[0] * number_of_sheets()[1] - 1)); - for (int i = 0; i < number_of_sheets()[0]; i++) { - for (int j = 0; j < number_of_sheets()[1]; j++) { - if ((i != 0) || (j != 0)) { - loc = start_vertices[i * 3 + j - 1]->face(); - Offset offset(i, j); + for (int i = 0; i < number_of_sheets()[0]; i++) + { + for (int j = 0; j < number_of_sheets()[1]; j++) + { + if ((i != 0) || (j != 0)) + { + loc = start_vertices[i * 3 + j - 1]->face(); + Offset offset(i, j); - loc = locate(p, offset, lt, li, loc); + loc = locate(p, offset, lt, li, loc); - insert(p, offset, lt, loc, li, vh); - } + insert(p, offset, lt, loc, li, vh); + } + } } - } return vh; } template -typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangulation_2< - Gt, Tds>::insert(const Point& p, const Offset &o, Locate_type lt, - Face_handle loc, int li, Vertex_handle vh) +typename Periodic_2_triangulation_2::Vertex_handle Periodic_2_triangulation_2 < +Gt, Tds >::insert(const Point& p, const Offset &o, Locate_type lt, + Face_handle loc, int li, Vertex_handle vh) // insert a point p, whose localization is known (lt, f, i) { Vertex_handle result; - switch (lt) { - case FACE: { - result = insert_in_face(p, o, loc, vh); - break; - } - case EDGE: { - result = insert_in_edge(p, o, loc, li, vh); - break; - } - case VERTEX: { - // The vertex is a special case, we can return immediately - CGAL_assertion(vh == Vertex_handle()); - return loc->vertex(li); - } - case EMPTY: { - result = insert_first(p); - break; - } - default: { - CGAL_triangulation_assertion(false); // locate step failed - return Vertex_handle(); - } - } + switch (lt) + { + case FACE: + { + result = insert_in_face(p, o, loc, vh); + break; + } + case EDGE: + { + result = insert_in_edge(p, o, loc, li, vh); + break; + } + case VERTEX: + { + // The vertex is a special case, we can return immediately + CGAL_assertion(vh == Vertex_handle()); + return loc->vertex(li); + } + case EMPTY: + { + result = insert_first(p); + break; + } + default: + { + CGAL_triangulation_assertion(false); // locate step failed + return Vertex_handle(); + } + } - if (!is_1_cover() && (vh == Vertex_handle())) { - _virtual_vertices_reverse[result] = std::vector(); - } + if (!is_1_cover() && (vh == Vertex_handle())) + { + _virtual_vertices_reverse[result] = std::vector(); + } return result; } @@ -2240,31 +2514,32 @@ inline void Periodic_2_triangulation_2::remove_degree_3(Vertex_handle v CGAL_assertion(degree(v) == 3); if (is_1_cover()) - { - remove_degree_3_single_copy(v); - return; - } + { + remove_degree_3_single_copy(v); + return; + } { Virtual_vertex_map_it it = _virtual_vertices.find(v); if (it != _virtual_vertices.end()) - { - v = it->second.first; - } + { + v = it->second.first; + } } remove_too_long_edges_in_star(v); - typename Virtual_vertex_reverse_map::iterator reverse_it = + typename Virtual_vertex_reverse_map::iterator reverse_it = _virtual_vertices_reverse.find(v); CGAL_assertion(reverse_it != _virtual_vertices_reverse.end()); - + const std::vector &virtual_copies = reverse_it->second; for (typename std::vector::const_iterator it = virtual_copies.begin(); - it != virtual_copies.end(); ++it) { - _virtual_vertices.erase(*it); - remove_degree_3_single_copy(*it); - } + it != virtual_copies.end(); ++it) + { + _virtual_vertices.erase(*it); + remove_degree_3_single_copy(*it); + } _virtual_vertices_reverse.erase(reverse_it); remove_degree_3_single_copy(v); @@ -2283,14 +2558,20 @@ inline void Periodic_2_triangulation_2::remove_degree_3_single_copy(Ver off[i] = get_offset(f, i); off[ccw(i)] = get_offset(f, ccw(i)); off[cw(i)] = combine_offsets(get_offset(f2, j), get_neighbor_offset(f2, j, f, i)); - if (off[0].x() < 0 || off[1].x() < 0 || off[2].x() < 0) { - Offset o(number_of_sheets()[0], 0); - off[0] += o; off[1] += o; off[2] += o; - } - if (off[0].y() < 0 || off[1].y() < 0 || off[2].y() < 0) { - Offset o(0, number_of_sheets()[1]); - off[0] += o; off[1] += o; off[2] += o; - } + if (off[0].x() < 0 || off[1].x() < 0 || off[2].x() < 0) + { + Offset o(number_of_sheets()[0], 0); + off[0] += o; + off[1] += o; + off[2] += o; + } + if (off[0].y() < 0 || off[1].y() < 0 || off[2].y() < 0) + { + Offset o(0, number_of_sheets()[1]); + off[0] += o; + off[1] += o; + off[2] += o; + } // Remove the vertex, keep face f _tds.remove_degree_3(vh, f); @@ -2303,7 +2584,8 @@ inline void Periodic_2_triangulation_2::remove_degree_3_single_copy(Ver } template -inline void Periodic_2_triangulation_2::remove_first(Vertex_handle) { +inline void Periodic_2_triangulation_2::remove_first(Vertex_handle) +{ CGAL_assertion(number_of_vertices() == 1); clear(); return; @@ -2312,48 +2594,53 @@ inline void Periodic_2_triangulation_2::remove_first(Vertex_handle) { template < class Gt, class Tds > bool -Periodic_2_triangulation_2:: +Periodic_2_triangulation_2:: remove_degree_init(Vertex_handle v, const Offset &v_o, std::vector &f, - std::vector &w, - std::vector &offset_w, + std::vector &w, + std::vector &offset_w, std::vector &i, - int &d, int &maxd, + int &d, int &maxd, bool &simplicity_criterion) { Bbox_2 bbox = v->point().bbox(); simplicity_criterion = is_1_cover(); - f[0] = v->face();d=0; + f[0] = v->face(); + d = 0; - do{ - i[d] = f[d]->index(v); - w[d] = f[d]->vertex( ccw(i[d]) ); - offset_w[d] = get_offset(f[d], ccw(i[d])) - get_offset(f[d], i[d]) + v_o; - w[d]->set_face( f[d]->neighbor(i[d])); // do no longer bother about set_face - simplicity_criterion &= (offset_w[d] == offset_w[0]); + do + { + i[d] = f[d]->index(v); + w[d] = f[d]->vertex( ccw(i[d]) ); + offset_w[d] = get_offset(f[d], ccw(i[d])) - get_offset(f[d], i[d]) + v_o; + w[d]->set_face( f[d]->neighbor(i[d])); // do no longer bother about set_face + simplicity_criterion &= (offset_w[d] == offset_w[0]); - bbox = bbox + this->construct_point(w[d]->point(), offset_w[d]).bbox(); + bbox = bbox + this->construct_point(w[d]->point(), offset_w[d]).bbox(); + + ++d; + if ( d == maxd) + { + maxd *= 2; + f.resize(maxd); + w.resize(maxd); + offset_w.resize(maxd); + i.resize(maxd); + } + + f[d] = f[d - 1]->neighbor( ccw(i[d - 1]) ); - ++d; - if ( d==maxd) { - maxd *=2; - f.resize(maxd); - w.resize(maxd); - offset_w.resize(maxd); - i.resize(maxd); } - - f[d] = f[d-1]->neighbor( ccw(i[d-1]) ); - - } while(f[d]!=f[0]); + while(f[d] != f[0]); return is_1_cover() && - this->edge_is_too_long(Point(bbox.xmin(), bbox.ymin()), Point(bbox.xmax(), bbox.ymax())); + this->edge_is_too_long(Point(bbox.xmin(), bbox.ymin()), Point(bbox.xmax(), bbox.ymax())); } template -void Periodic_2_triangulation_2::make_hole(Vertex_handle v, std::list & hole) { +void Periodic_2_triangulation_2::make_hole(Vertex_handle v, std::list & hole) +{ remove_too_long_edges_in_star(v); std::list to_delete; @@ -2364,116 +2651,137 @@ void Periodic_2_triangulation_2::make_hole(Vertex_handle v, std::listindex(v); - fn = f->neighbor(i); - in = fn->index(f); - vv = f->vertex(cw(i)); - if (vv->face() == f) - vv->set_face(fn); - vv = f->vertex(ccw(i)); - if (vv->face() == f) - vv->set_face(fn); - fn->set_neighbor(in, Face_handle()); - hole.push_back(Edge(fn, in)); - to_delete.push_back(f); - } while (fc != done); + do + { + f = fc; + fc++; + i = f->index(v); + fn = f->neighbor(i); + in = fn->index(f); + vv = f->vertex(cw(i)); + if (vv->face() == f) + vv->set_face(fn); + vv = f->vertex(ccw(i)); + if (vv->face() == f) + vv->set_face(fn); + fn->set_neighbor(in, Face_handle()); + hole.push_back(Edge(fn, in)); + to_delete.push_back(f); + } + while (fc != done); - while (!to_delete.empty()) { - delete_face(to_delete.front()); - to_delete.pop_front(); - } + while (!to_delete.empty()) + { + delete_face(to_delete.front()); + to_delete.pop_front(); + } return; } template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::create_face(Face_handle f1, int i1, Face_handle f2, int i2, - Face_handle f3, int i3) { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::create_face(Face_handle f1, int i1, Face_handle f2, int i2, + Face_handle f3, int i3) +{ return _tds.create_face(f1, i1, f2, i2, f3, i3); } template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::create_face(Face_handle f1, int i1, Face_handle f2, int i2) { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::create_face(Face_handle f1, int i1, Face_handle f2, int i2) +{ return _tds.create_face(f1, i1, f2, i2); } template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::create_face(Face_handle f, int i, Vertex_handle v) { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::create_face(Face_handle f, int i, Vertex_handle v) +{ return _tds.create_face(f, i, v); } template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) +{ return _tds.create_face(v1, v2, v3); } template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, - Face_handle f1, Face_handle f2, Face_handle f3) { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, + Face_handle f1, Face_handle f2, Face_handle f3) +{ return _tds.create_face(v1, v2, v3, f1, f2, f3); } template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::create_face(Face_handle fh) { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::create_face(Face_handle fh) +{ return _tds.create_face(fh); } template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::create_face() { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::create_face() +{ return _tds.create_face(); } template inline -void Periodic_2_triangulation_2::delete_face(Face_handle f) { +void Periodic_2_triangulation_2::delete_face(Face_handle f) +{ _tds.delete_face(f); } template inline -void Periodic_2_triangulation_2::delete_vertex(Vertex_handle v) { +void Periodic_2_triangulation_2::delete_vertex(Vertex_handle v) +{ _tds.delete_vertex(v); } template bool Periodic_2_triangulation_2::compare_walks(const Point& p, Face_handle c1, Face_handle c2, Locate_type& lt1, Locate_type& lt2, - int li1, int li2) const { + int li1, int li2) const +{ bool b = true; b &= (lt1 == lt2); - if ((lt1 == lt2) && (lt1 == VERTEX)) { - b &= (c1->vertex(li1) == c2->vertex(li2)); - } else if ((lt1 == lt2) && (lt1 == EDGE)) { - b &= ((c1 == c2) - || ((c1->neighbor(li1) == c2) && (c2->neighbor(li2) == c1))); - } else if ((lt1 == lt2) && (lt1 == EMPTY)) { - // Skip - } else { - b &= (lt1 == lt2); - b &= (lt1 == FACE); - b &= (c1 == c2); - } + if ((lt1 == lt2) && (lt1 == VERTEX)) + { + b &= (c1->vertex(li1) == c2->vertex(li2)); + } + else if ((lt1 == lt2) && (lt1 == EDGE)) + { + b &= ((c1 == c2) + || ((c1->neighbor(li1) == c2) && (c2->neighbor(li2) == c1))); + } + else if ((lt1 == lt2) && (lt1 == EMPTY)) + { + // Skip + } + else + { + b &= (lt1 == lt2); + b &= (lt1 == FACE); + b &= (c1 == c2); + } - if (!b) { - std::cerr << "from compare_walks " << std::endl; - std::cerr << "point " << p << std::endl; - std::cerr << "locate 1 " << &*c1 << "\t" << lt1 << "\t" << li1 << std::endl; - std::cerr << "locate 2 " << &*c2 << "\t" << lt2 << "\t" << li2 << std::endl; - std::cerr << std::endl; - show_face(c1); - std::cerr << std::endl; - show_face(c2); - std::cerr << std::endl; - } + if (!b) + { + std::cerr << "from compare_walks " << std::endl; + std::cerr << "point " << p << std::endl; + std::cerr << "locate 1 " << &*c1 << "\t" << lt1 << "\t" << li1 << std::endl; + std::cerr << "locate 2 " << &*c2 << "\t" << lt2 << "\t" << li2 << std::endl; + std::cerr << std::endl; + show_face(c1); + std::cerr << std::endl; + show_face(c2); + std::cerr << std::endl; + } CGAL_triangulation_assertion(b); return b; @@ -2483,7 +2791,8 @@ template typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2:: march_locate_2D(Face_handle f, const Point& query, - const Offset& o_p, Locate_type& lt, int& li) const { + const Offset& o_p, Locate_type& lt, int& li) const +{ CGAL_assertion(!empty()); Offset off_query = o_p; @@ -2494,187 +2803,225 @@ march_locate_2D(Face_handle f, const Point& query, boost::variate_generator > coin(rng, two); // Give the point the best start-offset possible - if (is_1_cover() && !f->has_zero_offsets()) { - int cumm_off = f->offset(0) | f->offset(1) | f->offset(2); - if (((cumm_off & 2) == 2) && - (FT(2) * query.x() < (_domain.xmax() + _domain.xmin()))) - off_query += Offset(1, 0); - if (((cumm_off & 1) == 1) && - (FT(2) * query.y() < (_domain.ymax() + _domain.ymin()))) - off_query += Offset(0, 1); - } + if (is_1_cover() && !f->has_zero_offsets()) + { + int cumm_off = f->offset(0) | f->offset(1) | f->offset(2); + if (((cumm_off & 2) == 2) && + (FT(2) * query.x() < (_domain.xmax() + _domain.xmin()))) + off_query += Offset(1, 0); + if (((cumm_off & 1) == 1) && + (FT(2) * query.y() < (_domain.ymax() + _domain.ymin()))) + off_query += Offset(0, 1); + } Face_handle prev = Face_handle(); int prev_index = 0; Offset off[3]; Orientation o[3]; - while (1) { - // Instead of testing its edges in a random order we do the following - // until we find a neighbor to go further: - // As we come from prev we do not have to check the edge leading to prev - // Now we flip a coin in order to decide if we start checking the - // edge before or the edge after the edge leading to prev - int left_first = coin() % 2; + while (1) + { + // Instead of testing its edges in a random order we do the following + // until we find a neighbor to go further: + // As we come from prev we do not have to check the edge leading to prev + // Now we flip a coin in order to decide if we start checking the + // edge before or the edge after the edge leading to prev + int left_first = coin() % 2; - bool simplicity_criterion = - f->has_zero_offsets() && off_query.is_null() && is_1_cover(); + bool simplicity_criterion = + f->has_zero_offsets() && off_query.is_null() && is_1_cover(); - const Point *p[3] = { - &f->vertex(0)->point(), - &f->vertex(1)->point(), - &f->vertex(2)->point() - }; + const Point *p[3] = + { + &f->vertex(0)->point(), + &f->vertex(1)->point(), + &f->vertex(2)->point() + }; - // Get the offsets - if (!simplicity_criterion) { - if (!is_1_cover()) { - // Just fetch the vertices of c as points with offsets - for (int i = 0; i < 3; i++) { - off[i] = get_offset(f, i); + // Get the offsets + if (!simplicity_criterion) + { + if (!is_1_cover()) + { + // Just fetch the vertices of c as points with offsets + for (int i = 0; i < 3; i++) + { + off[i] = get_offset(f, i); + } + } + else + { + // We are on the one cover and on the boundary between domains + // Hence, we need to check predicates with offsets + for (int i = 0; i < 3; i++) + { + off[i] = int_to_off(f->offset(i)); + } + } } - } else { - // We are on the one cover and on the boundary between domains - // Hence, we need to check predicates with offsets - for (int i = 0; i < 3; i++) { - off[i] = int_to_off(f->offset(i)); + + if (prev == Face_handle()) + { + prev = f; + // First step, also check the prev_index + if (simplicity_criterion) + { + o[ccw(prev_index)] = + orientation(*p[ccw(prev_index)], *p[cw(prev_index)], query); + } + else + { + o[ccw(prev_index)] = + orientation(*p[ccw(prev_index)], *p[cw(prev_index)], query, + off[ccw(prev_index)], off[cw(prev_index)], off_query); + } + if (o[ccw(prev_index)] == NEGATIVE) + { + // This assignment is already done: prev = f + f = f->neighbor(prev_index); + int new_index = f->index(prev); + if (!(simplicity_criterion && f->has_zero_offsets())) + off_query = combine_offsets(off_query, + get_neighbor_offset(prev, prev_index, + f, new_index)); + prev_index = new_index; + continue; + } + } + else + { + o[ccw(prev_index)] = POSITIVE; } - } - } - if (prev == Face_handle()) { - prev = f; - // First step, also check the prev_index - if (simplicity_criterion) { - o[ccw(prev_index)] = - orientation(*p[ccw(prev_index)], *p[cw(prev_index)], query); - } else { - o[ccw(prev_index)] = - orientation(*p[ccw(prev_index)], *p[cw(prev_index)], query, - off[ccw(prev_index)], off[cw(prev_index)], off_query); + if (left_first) + { + if (simplicity_criterion) + { + o[prev_index] = + orientation(*p[prev_index], *p[ccw(prev_index)], query); + } + else + { + o[prev_index] = + orientation(*p[prev_index], *p[ccw(prev_index)], query, + off[prev_index], off[ccw(prev_index)], off_query); + } + if (o[prev_index] == NEGATIVE) + { + prev = f; + f = f->neighbor(cw(prev_index)); + int new_index = f->index(prev); + if (!(simplicity_criterion && f->has_zero_offsets())) + off_query = combine_offsets(off_query, + get_neighbor_offset(prev, cw(prev_index), f, new_index)); + prev_index = new_index; + continue; + } + } + { + // Do right side + if (simplicity_criterion) + { + o[cw(prev_index)] = + orientation(*p[cw(prev_index)], *p[prev_index], query); + } + else + { + o[cw(prev_index)] = + orientation(*p[cw(prev_index)], *p[prev_index], query, + off[cw(prev_index)], off[prev_index], off_query); + } + if (o[cw(prev_index)] == NEGATIVE) + { + prev = f; + f = f->neighbor(ccw(prev_index)); + int new_index = f->index(prev); + if (!(simplicity_criterion && f->has_zero_offsets())) + off_query = combine_offsets(off_query, + get_neighbor_offset(prev, ccw(prev_index), f, new_index)); + prev_index = new_index; + continue; + } } - if (o[ccw(prev_index)] == NEGATIVE) { - // This assignment is already done: prev = f - f = f->neighbor(prev_index); - int new_index = f->index(prev); - if (!(simplicity_criterion && f->has_zero_offsets())) - off_query = combine_offsets(off_query, - get_neighbor_offset(prev, prev_index, - f, new_index)); - prev_index = new_index; - continue; - } - } else { - o[ccw(prev_index)] = POSITIVE; - } + if (!left_first) + { + if (simplicity_criterion) + { + o[prev_index] = orientation(*p[prev_index], *p[ccw(prev_index)], query); + } + else + { + o[prev_index] = orientation(*p[prev_index], *p[ccw(prev_index)], query, + off[prev_index], off[ccw(prev_index)], off_query); + } + if (o[prev_index] == NEGATIVE) + { + prev = f; + f = f->neighbor(cw(prev_index)); + int new_index = f->index(prev); + if (!(simplicity_criterion && f->has_zero_offsets())) + off_query = combine_offsets(off_query, + get_neighbor_offset(prev, cw(prev_index), f, new_index)); + prev_index = new_index; + continue; + } + } - if (left_first) { - if (simplicity_criterion) { - o[prev_index] = - orientation(*p[prev_index], *p[ccw(prev_index)], query); - } else { - o[prev_index] = - orientation(*p[prev_index], *p[ccw(prev_index)], query, - off[prev_index], off[ccw(prev_index)], off_query); - } - if (o[prev_index] == NEGATIVE) { - prev = f; - f = f->neighbor(cw(prev_index)); - int new_index = f->index(prev); - if (!(simplicity_criterion && f->has_zero_offsets())) - off_query = combine_offsets(off_query, - get_neighbor_offset(prev, cw(prev_index), f, new_index)); - prev_index = new_index; - continue; - } + // now p is in c or on its boundary + int sum = (o[0] == COLLINEAR) + (o[1] == COLLINEAR) + (o[2] == COLLINEAR); + switch (sum) + { + case 0: + { + lt = FACE; + li = 4; + break; + } + case 1: + { + lt = EDGE; + li = (o[0] == COLLINEAR) ? 2 : (o[1] == COLLINEAR) ? 0 : 1; + break; + } + case 2: + { + lt = VERTEX; + li = (o[0] != COLLINEAR) ? 2 : (o[1] != COLLINEAR) ? 0 : 1; + break; + } + } + return f; } - { // Do right side - if (simplicity_criterion) { - o[cw(prev_index)] = - orientation(*p[cw(prev_index)], *p[prev_index], query); - } else { - o[cw(prev_index)] = - orientation(*p[cw(prev_index)], *p[prev_index], query, - off[cw(prev_index)], off[prev_index], off_query); - } - if (o[cw(prev_index)] == NEGATIVE) { - prev = f; - f = f->neighbor(ccw(prev_index)); - int new_index = f->index(prev); - if (!(simplicity_criterion && f->has_zero_offsets())) - off_query = combine_offsets(off_query, - get_neighbor_offset(prev, ccw(prev_index), f, new_index)); - prev_index = new_index; - continue; - } - } - if (!left_first) { - if (simplicity_criterion) { - o[prev_index] = orientation(*p[prev_index], *p[ccw(prev_index)], query); - } else { - o[prev_index] = orientation(*p[prev_index], *p[ccw(prev_index)], query, - off[prev_index], off[ccw(prev_index)], off_query); - } - if (o[prev_index] == NEGATIVE) { - prev = f; - f = f->neighbor(cw(prev_index)); - int new_index = f->index(prev); - if (!(simplicity_criterion && f->has_zero_offsets())) - off_query = combine_offsets(off_query, - get_neighbor_offset(prev, cw(prev_index), f, new_index)); - prev_index = new_index; - continue; - } - } - - // now p is in c or on its boundary - int sum = (o[0] == COLLINEAR) + (o[1] == COLLINEAR) + (o[2] == COLLINEAR); - switch (sum) { - case 0: { - lt = FACE; - li = 4; - break; - } - case 1: { - lt = EDGE; - li = (o[0] == COLLINEAR) ? 2 : (o[1] == COLLINEAR) ? 0 : 1; - break; - } - case 2: { - lt = VERTEX; - li = (o[0] != COLLINEAR) ? 2 : (o[1] != COLLINEAR) ? 0 : 1; - break; - } - } - return f; - } } template -typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - Gt, Tds>::locate(const Point& p, const Offset &o, Locate_type& lt, int& li, - Face_handle start) const { +typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +Gt, Tds >::locate(const Point& p, const Offset &o, Locate_type& lt, int& li, + Face_handle start) const +{ CGAL_triangulation_assertion((_domain.xmin() <= p.x()) && - (p.x() < _domain.xmax())); + (p.x() < _domain.xmax())); CGAL_triangulation_assertion((_domain.ymin() <= p.y()) && - (p.y() < _domain.ymax())); + (p.y() < _domain.ymax())); - if (dimension() <= 0) { - lt = EMPTY; - li = 4; - return Face_handle(); - } + if (dimension() <= 0) + { + lt = EMPTY; + li = 4; + return Face_handle(); + } // Triangulation is not empty - if (start == Face_handle()) { - start = faces_begin(); - } + if (start == Face_handle()) + { + start = faces_begin(); + } return march_locate_2D(start, p, o, lt, li); } /** Delete each redundant face and the not anymore needed data * structures. - * + * * This function consists of four iterations over all faces and one * iteration over all vertices: * -# Face iteration: mark all faces that are to delete @@ -2684,7 +3031,8 @@ typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulati * -# Vertex iteration: delete all vertices outside the original domain. */ template -void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() { +void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() +{ // ################################################################### // ### First face iteration ########################################## // ################################################################### @@ -2698,40 +3046,46 @@ void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() { // First iteration over all faces: Mark the faces that are to delete. // Faces are to delete if they cannot be translated anymore in the // direction of one of the axes without yielding negative offsets. - for (Face_iterator it = all_faces_begin(); it != all_faces_end(); ++it) { - to_delete = false; - // for all directions in 2D Space - for (int j = 0; j < 2; j++) { - has_simplifiable_offset = true; - // for all vertices of face it - for (int i = 0; i < 3; i++) { - vvmit = _virtual_vertices.find(it->vertex(i)); - if (vvmit == _virtual_vertices.end()) { - // if it->vertex(i) lies inside the original domain: + for (Face_iterator it = all_faces_begin(); it != all_faces_end(); ++it) + { + to_delete = false; + // for all directions in 2D Space + for (int j = 0; j < 2; j++) + { + has_simplifiable_offset = true; + // for all vertices of face it + for (int i = 0; i < 3; i++) + { + vvmit = _virtual_vertices.find(it->vertex(i)); + if (vvmit == _virtual_vertices.end()) + { + // if it->vertex(i) lies inside the original domain: - // the face cannot be moved any more because if we did, then - // it->vertex(i) will get at least one negative offset. - has_simplifiable_offset = false; - } else { - // if it->vertex(i) lies outside the original domain: + // the face cannot be moved any more because if we did, then + // it->vertex(i) will get at least one negative offset. + has_simplifiable_offset = false; + } + else + { + // if it->vertex(i) lies outside the original domain: - // The face can certainly be deleted if the offset contains a 2 - to_delete |= (vvmit->second.second[j] == 2); - // The face can be moved into one direction only if the offset of - // all for vertices is >=1 for this direction. Since we already - // tested for 2 it is sufficient to test here for 1. - has_simplifiable_offset &= (vvmit->second.second[j] == 1); + // The face can certainly be deleted if the offset contains a 2 + to_delete |= (vvmit->second.second[j] == 2); + // The face can be moved into one direction only if the offset of + // all for vertices is >=1 for this direction. Since we already + // tested for 2 it is sufficient to test here for 1. + has_simplifiable_offset &= (vvmit->second.second[j] == 1); + } + } + // if the offset can be simplified, i.e. the face can be moved, then + // it can be deleted. + if (has_simplifiable_offset) + to_delete = true; } - } - // if the offset can be simplified, i.e. the face can be moved, then - // it can be deleted. - if (has_simplifiable_offset) - to_delete = true; + // Mark all faces that are to delete. They cannot be deleted yet, + // because neighboring information still needs to be extracted. + it->set_additional_flag(to_delete ? 1 : 0); } - // Mark all faces that are to delete. They cannot be deleted yet, - // because neighboring information still needs to be extracted. - it->set_additional_flag(to_delete ? 1 : 0); - } } // ################################################################### @@ -2744,69 +3098,77 @@ void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() { std::vector > new_neighbor_relations; // Second iteration over all faces: redirect neighbors where necessary - for (Face_iterator it = all_faces_begin(); it != all_faces_end(); ++it) { - // Skip all faces that are to delete. - if (it->get_additional_flag() == 1) - continue; - - // Redirect neighbors: Only neighbors that are marked by the - // additional_flag have to be substituted by one of their periodic - // copies. The unmarked neighbors stay the same. - for (int i = 0; i < 3; i++) { - if (it->neighbor(i)->get_additional_flag() != 1) + for (Face_iterator it = all_faces_begin(); it != all_faces_end(); ++it) + { + // Skip all faces that are to delete. + if (it->get_additional_flag() == 1) continue; - nb = it->neighbor(i); + // Redirect neighbors: Only neighbors that are marked by the + // additional_flag have to be substituted by one of their periodic + // copies. The unmarked neighbors stay the same. + for (int i = 0; i < 3; i++) + { + if (it->neighbor(i)->get_additional_flag() != 1) + continue; - for (int j = 0; j < 3; j++) { - off[j] = Offset(); - get_vertex(nb, j, vert[j], off[j]); - } - int x, y; - x = (std::min)((std::min)(off[0][0], off[1][0]), off[2][0]); - y = (std::min)((std::min)(off[0][1], off[1][1]), off[2][1]); + nb = it->neighbor(i); - // The vector from nb to the "original" periodic copy of nb, that is - // the copy that will not be deleted. - Offset difference_offset(x, y); - CGAL_triangulation_assertion( !difference_offset.is_null() ); + for (int j = 0; j < 3; j++) + { + off[j] = Offset(); + get_vertex(nb, j, vert[j], off[j]); + } + int x, y; + x = (std::min)((std::min)(off[0][0], off[1][0]), off[2][0]); + y = (std::min)((std::min)(off[0][1], off[1][1]), off[2][1]); - // We now have to find the "original" periodic copy of nb from - // its vertices. Therefore, we first have to find the vertices. - for (int j = 0; j < 3; j++) { - CGAL_triangulation_assertion( (off[j]-difference_offset)[0] >= 0); - CGAL_triangulation_assertion( (off[j]-difference_offset)[1] >= 0); - CGAL_triangulation_assertion( (off[j]-difference_offset)[0] < 3); - CGAL_triangulation_assertion( (off[j]-difference_offset)[1] < 3); + // The vector from nb to the "original" periodic copy of nb, that is + // the copy that will not be deleted. + Offset difference_offset(x, y); + CGAL_triangulation_assertion( !difference_offset.is_null() ); - // find the Vertex_handles of the vertices of the "original" - // periodic copy of nb. If the vertex is inside the original - // domain, there is nothing to do - if ((off[j] - difference_offset).is_null()) { - nbv[j] = vert[j]; - // If the vertex is outside the original domain, we have to search - // in _virtual_vertices in the "wrong" direction. That means, we - // cannot use _virtual_vertices.find but have to use - // _virtual_vertices_reverse. - } else { - Offset nbo = off[j] - difference_offset; - nbv[j] = _virtual_vertices_reverse.find(vert[j]) ->second[nbo[0] - * 3 + nbo[1] - 1]; + // We now have to find the "original" periodic copy of nb from + // its vertices. Therefore, we first have to find the vertices. + for (int j = 0; j < 3; j++) + { + CGAL_triangulation_assertion( (off[j] - difference_offset)[0] >= 0); + CGAL_triangulation_assertion( (off[j] - difference_offset)[1] >= 0); + CGAL_triangulation_assertion( (off[j] - difference_offset)[0] < 3); + CGAL_triangulation_assertion( (off[j] - difference_offset)[1] < 3); + + // find the Vertex_handles of the vertices of the "original" + // periodic copy of nb. If the vertex is inside the original + // domain, there is nothing to do + if ((off[j] - difference_offset).is_null()) + { + nbv[j] = vert[j]; + // If the vertex is outside the original domain, we have to search + // in _virtual_vertices in the "wrong" direction. That means, we + // cannot use _virtual_vertices.find but have to use + // _virtual_vertices_reverse. + } + else + { + Offset nbo = off[j] - difference_offset; + nbv[j] = _virtual_vertices_reverse.find(vert[j]) ->second[nbo[0] + * 3 + nbo[1] - 1]; + } + } + // Find the new neighbor by its 4 vertices + new_neighbor = get_face(nbv); + + // Store the new neighbor relation. This cannot be applied yet because + // it would disturb the functioning of get_face( ... ) + new_neighbor_relations.push_back(make_triple(it, i, new_neighbor)); } - } - // Find the new neighbor by its 4 vertices - new_neighbor = get_face(nbv); - - // Store the new neighbor relation. This cannot be applied yet because - // it would disturb the functioning of get_face( ... ) - new_neighbor_relations.push_back(make_triple(it, i, new_neighbor)); } - } // Apply the new neighbor relations now. - for (unsigned int i = 0; i < new_neighbor_relations.size(); i++) { - new_neighbor_relations[i].first->set_neighbor( + for (unsigned int i = 0; i < new_neighbor_relations.size(); i++) + { + new_neighbor_relations[i].first->set_neighbor( new_neighbor_relations[i].second, new_neighbor_relations[i].third); - } + } } // ################################################################### @@ -2816,30 +3178,32 @@ void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() { Vertex_handle vert[3]; Offset off[3]; // Third iteration over all faces: redirect vertices where necessary - for (Face_iterator it = all_faces_begin(); it != all_faces_end(); ++it) { - // Skip all faces that are marked to delete - if (it->get_additional_flag() == 1) - continue; - // Find the corresponding vertices of it in the original domain - // and set them as new vertices of it. - for (int i = 0; i < 3; i++) { - off[i] = Offset(); - get_vertex(it, i, vert[i], off[i]); - it->set_vertex(i, vert[i]); - CGAL_triangulation_assertion(vert[i]->point()[0] < _domain.xmax()); - CGAL_triangulation_assertion(vert[i]->point()[1] < _domain.ymax()); - CGAL_triangulation_assertion(vert[i]->point()[0] >= _domain.xmin()); - CGAL_triangulation_assertion(vert[i]->point()[1] >= _domain.ymin()); + for (Face_iterator it = all_faces_begin(); it != all_faces_end(); ++it) + { + // Skip all faces that are marked to delete + if (it->get_additional_flag() == 1) + continue; + // Find the corresponding vertices of it in the original domain + // and set them as new vertices of it. + for (int i = 0; i < 3; i++) + { + off[i] = Offset(); + get_vertex(it, i, vert[i], off[i]); + it->set_vertex(i, vert[i]); + CGAL_triangulation_assertion(vert[i]->point()[0] < _domain.xmax()); + CGAL_triangulation_assertion(vert[i]->point()[1] < _domain.ymax()); + CGAL_triangulation_assertion(vert[i]->point()[0] >= _domain.xmin()); + CGAL_triangulation_assertion(vert[i]->point()[1] >= _domain.ymin()); - // redirect also the face pointer of the vertex. - it->vertex(i)->set_face(it); + // redirect also the face pointer of the vertex. + it->vertex(i)->set_face(it); + } + // Set the offsets. + set_offsets(it, off[0], off[1], off[2]); + CGAL_triangulation_assertion( int_to_off(it->offset(0)) == off[0] ); + CGAL_triangulation_assertion( int_to_off(it->offset(1)) == off[1] ); + CGAL_triangulation_assertion( int_to_off(it->offset(2)) == off[2] ); } - // Set the offsets. - set_offsets(it, off[0], off[1], off[2]); - CGAL_triangulation_assertion( int_to_off(it->offset(0)) == off[0] ); - CGAL_triangulation_assertion( int_to_off(it->offset(1)) == off[1] ); - CGAL_triangulation_assertion( int_to_off(it->offset(2)) == off[2] ); - } } // ################################################################### @@ -2848,14 +3212,16 @@ void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() { { // Delete the marked faces. std::vector faces_to_delete; - for (Face_iterator fit = all_faces_begin(); fit != all_faces_end(); ++fit) { - if (fit->get_additional_flag() == 1) - faces_to_delete.push_back(fit); - } + for (Face_iterator fit = all_faces_begin(); fit != all_faces_end(); ++fit) + { + if (fit->get_additional_flag() == 1) + faces_to_delete.push_back(fit); + } for (typename std::vector::iterator it = - faces_to_delete.begin(); it != faces_to_delete.end(); ++it) { - _tds.delete_face(*it); - } + faces_to_delete.begin(); it != faces_to_delete.end(); ++it) + { + _tds.delete_face(*it); + } } // ################################################################### @@ -2865,16 +3231,19 @@ void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() { // Delete all the vertices in _virtual_vertices, that is all vertices // outside the original domain. std::vector vertices_to_delete; - for (Vertex_iterator vit = all_vertices_begin(); vit != all_vertices_end(); ++vit) { - if (_virtual_vertices.count(vit) != 0) { - CGAL_triangulation_assertion( _virtual_vertices.count( vit ) == 1 ); - vertices_to_delete.push_back(vit); + for (Vertex_iterator vit = all_vertices_begin(); vit != all_vertices_end(); ++vit) + { + if (_virtual_vertices.count(vit) != 0) + { + CGAL_triangulation_assertion( _virtual_vertices.count( vit ) == 1 ); + vertices_to_delete.push_back(vit); + } } - } for (typename std::vector::iterator it = - vertices_to_delete.begin(); it != vertices_to_delete.end(); ++it) { - _tds.delete_vertex(*it); - } + vertices_to_delete.begin(); it != vertices_to_delete.end(); ++it) + { + _tds.delete_vertex(*it); + } } _cover = make_array(1, 1); @@ -2887,7 +3256,8 @@ void Periodic_2_triangulation_2::convert_to_1_sheeted_covering() { } template -void Periodic_2_triangulation_2::convert_to_9_sheeted_covering() { +void Periodic_2_triangulation_2::convert_to_9_sheeted_covering() +{ if (_cover == make_array(3, 3)) return; CGAL_triangulation_precondition(is_1_cover()); @@ -2899,27 +3269,29 @@ void Periodic_2_triangulation_2::convert_to_9_sheeted_covering() { for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) original_vertices.push_back(vit); for (typename std::list::iterator vit = - original_vertices.begin(); vit != original_vertices.end(); ++vit) { - Vertex_handle v_cp; - std::vector copies; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) { - if (i == 0 && j == 0) - continue; - v_cp = _tds.create_vertex(*vit); - copies.push_back(v_cp); - _virtual_vertices.insert(std::make_pair(v_cp, std::make_pair(*vit, - Offset(i, j)))); - } - _virtual_vertices_reverse.insert(std::make_pair(*vit, copies)); - } + original_vertices.begin(); vit != original_vertices.end(); ++vit) + { + Vertex_handle v_cp; + std::vector copies; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + { + if (i == 0 && j == 0) + continue; + v_cp = _tds.create_vertex(*vit); + copies.push_back(v_cp); + _virtual_vertices.insert(std::make_pair(v_cp, std::make_pair(*vit, + Offset(i, j)))); + } + _virtual_vertices_reverse.insert(std::make_pair(*vit, copies)); + } // Create 9 copies of each face from the respective copies of the // vertices and write virtual_faces and virtual_faces_reverse. typedef std::map > - Virtual_face_map; + Virtual_face_map; typedef std::map > - Virtual_face_reverse_map; + Virtual_face_reverse_map; typedef typename Virtual_face_map::const_iterator VCMIT; typedef typename Virtual_face_reverse_map::const_iterator VCRMIT; @@ -2933,186 +3305,213 @@ void Periodic_2_triangulation_2::convert_to_9_sheeted_covering() { // Store vertex offsets in a separate data structure std::list off_v; for (typename std::list::iterator vit = - original_vertices.begin(); vit != original_vertices.end(); ++vit) { - Face_handle ccc = (*vit)->face(); - int v_index = ccc->index(*vit); - off_v.push_back(int_to_off(ccc->offset(v_index))); - } + original_vertices.begin(); vit != original_vertices.end(); ++vit) + { + Face_handle ccc = (*vit)->face(); + int v_index = ccc->index(*vit); + off_v.push_back(int_to_off(ccc->offset(v_index))); + } // Store neighboring offsets in a separate data structure std::list > off_nb; for (typename std::list::iterator fit = original_faces.begin(); fit - != original_faces.end(); ++fit) { - array off_nb_f; - for (int i = 0; i < 3; i++) { - Face_handle fff = *fit; - Face_handle nnn = fff->neighbor(i); - off_nb_f[i] = get_neighbor_offset(fff, i, nnn, nnn->index(fff)); + != original_faces.end(); ++fit) + { + array off_nb_f; + for (int i = 0; i < 3; i++) + { + Face_handle fff = *fit; + Face_handle nnn = fff->neighbor(i); + off_nb_f[i] = get_neighbor_offset(fff, i, nnn, nnn->index(fff)); + } + off_nb.push_back(off_nb_f); } - off_nb.push_back(off_nb_f); - } // Create copies of faces for (typename std::list::iterator fit = original_faces.begin(); fit - != original_faces.end(); ++fit) { - Face_handle c_cp; - Vertex_handle v0, v1, v2; - std::vector copies; - Virtual_vertex_reverse_map_it vvrmit[3]; - Offset vvoff[3]; - for (int i = 0; i < 3; i++) { - vvrmit[i] = _virtual_vertices_reverse.find((*fit)->vertex(i)); - CGAL_triangulation_assertion( - vvrmit[i] != _virtual_vertices_reverse.end()); - vvoff[i] = int_to_off((*fit)->offset(i)); + != original_faces.end(); ++fit) + { + Face_handle c_cp; + Vertex_handle v0, v1, v2; + std::vector copies; + Virtual_vertex_reverse_map_it vvrmit[3]; + Offset vvoff[3]; + for (int i = 0; i < 3; i++) + { + vvrmit[i] = _virtual_vertices_reverse.find((*fit)->vertex(i)); + CGAL_triangulation_assertion( + vvrmit[i] != _virtual_vertices_reverse.end()); + vvoff[i] = int_to_off((*fit)->offset(i)); + } + Vertex_handle vvh[3]; + for (int n = 0; n < 8; n++) // iterate over faces + { + for (int i = 0; i < 3; i++) // iterate over vertices of the face + { + // Decomposition of n into an offset (nx,ny): + // nx = ((n+1)/3)%3, ny = (n+1)%3 + int o_i = ((n + 1) / 3 + vvoff[i].x() + 3) % 3; + int o_j = ((n + 1) + vvoff[i].y() + 3) % 3; + int n_c = 3 * o_i + o_j - 1; + CGAL_triangulation_assertion(n_c >= -1); + if (n_c == -1) + vvh[i] = (*fit)->vertex(i); + else + vvh[i] = vvrmit[i]->second[n_c]; + } + c_cp = _tds.create_face(vvh[0], vvh[1], vvh[2]); + copies.push_back(c_cp); + } + virtual_faces_reverse.insert(std::make_pair(*fit, copies)); } - Vertex_handle vvh[3]; - for (int n = 0; n < 8; n++) { // iterate over faces - for (int i = 0; i < 3; i++) { // iterate over vertices of the face - // Decomposition of n into an offset (nx,ny): - // nx = ((n+1)/3)%3, ny = (n+1)%3 - int o_i = ((n + 1) / 3 + vvoff[i].x() + 3) % 3; - int o_j = ((n + 1) + vvoff[i].y() + 3) % 3; - int n_c = 3 * o_i + o_j - 1; - CGAL_triangulation_assertion(n_c >= -1); - if (n_c == -1) - vvh[i] = (*fit)->vertex(i); - else - vvh[i] = vvrmit[i]->second[n_c]; - } - c_cp = _tds.create_face(vvh[0], vvh[1], vvh[2]); - copies.push_back(c_cp); - } - virtual_faces_reverse.insert(std::make_pair(*fit, copies)); - } // Set new vertices of boundary faces of the original domain. for (typename std::list::iterator fit = original_faces.begin(); fit - != original_faces.end(); ++fit) { - for (int i = 0; i < 3; i++) { - Virtual_vertex_reverse_map_it vvrmit = _virtual_vertices_reverse.find( - (*fit)->vertex(i)); - CGAL_triangulation_assertion(vvrmit != _virtual_vertices_reverse.end()); - Offset vvoff = int_to_off((*fit)->offset(i)); - if (!vvoff.is_null()) { - int n_f = 3 * vvoff.x() + vvoff.y() - 1; - CGAL_triangulation_assertion(n_f >= 0); - CGAL_triangulation_assertion(static_cast(n_f) < vvrmit->second.size()); - (*fit)->set_vertex(i, vvrmit->second[n_f]); - } + != original_faces.end(); ++fit) + { + for (int i = 0; i < 3; i++) + { + Virtual_vertex_reverse_map_it vvrmit = _virtual_vertices_reverse.find( + (*fit)->vertex(i)); + CGAL_triangulation_assertion(vvrmit != _virtual_vertices_reverse.end()); + Offset vvoff = int_to_off((*fit)->offset(i)); + if (!vvoff.is_null()) + { + int n_f = 3 * vvoff.x() + vvoff.y() - 1; + CGAL_triangulation_assertion(n_f >= 0); + CGAL_triangulation_assertion(static_cast(n_f) < vvrmit->second.size()); + (*fit)->set_vertex(i, vvrmit->second[n_f]); + } + } } - } // Set neighboring relations of face copies typename std::list >::iterator oit = off_nb.begin(); for (typename std::list::iterator fit = original_faces.begin(); fit - != original_faces.end(); ++fit, ++oit) { - CGAL_triangulation_assertion( oit != off_nb.end() ); - VCRMIT c_cp = virtual_faces_reverse.find(*fit); - CGAL_triangulation_assertion(c_cp != virtual_faces_reverse.end()); - for (int i = 0; i < 3; i++) { - Face_handle fit_nb = (*fit)->neighbor(i); - VCRMIT c_cp_nb = virtual_faces_reverse.find(fit_nb); - CGAL_triangulation_assertion(c_cp_nb != virtual_faces_reverse.end()); - Offset nboff = (*oit)[i]; - for (int n = 0; n < 8; n++) { - int n_nb; - if (nboff.is_null()) - n_nb = n; - else { - int o_i = ((n + 1) / 3 - nboff.x() + 3) % 3; - int o_j = (n + 1 - nboff.y() + 3) % 3; - n_nb = 3 * o_i + o_j - 1; + != original_faces.end(); ++fit, ++oit) + { + CGAL_triangulation_assertion( oit != off_nb.end() ); + VCRMIT c_cp = virtual_faces_reverse.find(*fit); + CGAL_triangulation_assertion(c_cp != virtual_faces_reverse.end()); + for (int i = 0; i < 3; i++) + { + Face_handle fit_nb = (*fit)->neighbor(i); + VCRMIT c_cp_nb = virtual_faces_reverse.find(fit_nb); + CGAL_triangulation_assertion(c_cp_nb != virtual_faces_reverse.end()); + Offset nboff = (*oit)[i]; + for (int n = 0; n < 8; n++) + { + int n_nb; + if (nboff.is_null()) + n_nb = n; + else + { + int o_i = ((n + 1) / 3 - nboff.x() + 3) % 3; + int o_j = (n + 1 - nboff.y() + 3) % 3; + n_nb = 3 * o_i + o_j - 1; + } + if (n_nb == -1) + { + CGAL_triangulation_assertion(fit_nb->has_vertex(c_cp->second[n]->vertex(ccw(i))) ); + CGAL_triangulation_assertion(fit_nb->has_vertex(c_cp->second[n]->vertex( cw(i))) ); + c_cp->second[n]->set_neighbor(i, fit_nb); + } + else + { + CGAL_triangulation_assertion(n_nb >= 0); + CGAL_triangulation_assertion(static_cast(n_nb) <= c_cp_nb->second.size()); + CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex(c_cp->second[n]->vertex(ccw(i))) ); + CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex(c_cp->second[n]->vertex( cw(i))) ); + c_cp->second[n]->set_neighbor(i, c_cp_nb->second[n_nb]); + } + } } - if (n_nb == -1) { - CGAL_triangulation_assertion(fit_nb->has_vertex(c_cp->second[n]->vertex(ccw(i))) ); - CGAL_triangulation_assertion(fit_nb->has_vertex(c_cp->second[n]->vertex( cw(i))) ); - c_cp->second[n]->set_neighbor(i, fit_nb); - } else { - CGAL_triangulation_assertion(n_nb >= 0); - CGAL_triangulation_assertion(static_cast(n_nb) <= c_cp_nb->second.size()); - CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex(c_cp->second[n]->vertex(ccw(i))) ); - CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex(c_cp->second[n]->vertex( cw(i))) ); - c_cp->second[n]->set_neighbor(i, c_cp_nb->second[n_nb]); - } - } } - } // Set neighboring relations of original faces oit = off_nb.begin(); for (typename std::list::iterator fit = original_faces.begin(); fit - != original_faces.end(); ++fit, ++oit) { - CGAL_triangulation_assertion( oit != off_nb.end() ); - for (int i = 0; i < 3; i++) { - Offset nboff = (*oit)[i]; - if (!nboff.is_null()) { - Face_handle fit_nb = (*fit)->neighbor(i); - VCRMIT c_cp_nb = virtual_faces_reverse.find(fit_nb); - CGAL_triangulation_assertion(c_cp_nb != virtual_faces_reverse.end()); - int o_i = (3 - nboff.x()) % 3; - int o_j = (3 - nboff.y()) % 3; - int n_nb = 3 * o_i + o_j - 1; - CGAL_triangulation_assertion(n_nb >= 0); - CGAL_triangulation_assertion(static_cast(n_nb) <= c_cp_nb->second.size()); - CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex((*fit)->vertex(ccw(i))) ); - CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex((*fit)->vertex( cw(i))) ); - (*fit)->set_neighbor(i, c_cp_nb->second[n_nb]); - } + != original_faces.end(); ++fit, ++oit) + { + CGAL_triangulation_assertion( oit != off_nb.end() ); + for (int i = 0; i < 3; i++) + { + Offset nboff = (*oit)[i]; + if (!nboff.is_null()) + { + Face_handle fit_nb = (*fit)->neighbor(i); + VCRMIT c_cp_nb = virtual_faces_reverse.find(fit_nb); + CGAL_triangulation_assertion(c_cp_nb != virtual_faces_reverse.end()); + int o_i = (3 - nboff.x()) % 3; + int o_j = (3 - nboff.y()) % 3; + int n_nb = 3 * o_i + o_j - 1; + CGAL_triangulation_assertion(n_nb >= 0); + CGAL_triangulation_assertion(static_cast(n_nb) <= c_cp_nb->second.size()); + CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex((*fit)->vertex(ccw(i))) ); + CGAL_triangulation_assertion(c_cp_nb->second[n_nb]->has_vertex((*fit)->vertex( cw(i))) ); + (*fit)->set_neighbor(i, c_cp_nb->second[n_nb]); + } + } } - } - // Set incident faces - for (Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) { - for (int i = 0; i < 3; i++) { - fit->vertex(i)->set_face(fit); + // Set incident faces + for (Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) + { + for (int i = 0; i < 3; i++) + { + fit->vertex(i)->set_face(fit); + } } - } // Set offsets where necessary for (typename std::list::iterator fit = original_faces.begin(); fit - != original_faces.end(); ++fit) { - VCRMIT c_cp = virtual_faces_reverse.find(*fit); - CGAL_triangulation_assertion( c_cp != virtual_faces_reverse.end()); - Offset off[3]; - for (int i = 0; i < 3; i++) - off[i] = int_to_off((*fit)->offset(i)); - if (off[0].is_null() && off[1].is_null() && off[2].is_null()) - continue; - for (int n = 0; n < 8; n++) { - Offset off_cp[4]; - int o_i = ((n + 1) / 3) % 3; - int o_j = (n + 1) % 3; - if (o_i != 2 && o_j != 2) + != original_faces.end(); ++fit) + { + VCRMIT c_cp = virtual_faces_reverse.find(*fit); + CGAL_triangulation_assertion( c_cp != virtual_faces_reverse.end()); + Offset off[3]; + for (int i = 0; i < 3; i++) + off[i] = int_to_off((*fit)->offset(i)); + if (off[0].is_null() && off[1].is_null() && off[2].is_null()) continue; - for (int i = 0; i < 3; i++) { - off_cp[i] = Offset((o_i == 2) ? off[i].x() : 0, (o_j == 2) ? off[i].y() - : 0); - CGAL_triangulation_assertion(off_cp[i].x() == 0 || off_cp[i].x() == 1); - CGAL_triangulation_assertion(off_cp[i].y() == 0 || off_cp[i].y() == 1); - } - set_offsets(c_cp->second[n], off_cp[0], off_cp[1], off_cp[2]); + for (int n = 0; n < 8; n++) + { + Offset off_cp[4]; + int o_i = ((n + 1) / 3) % 3; + int o_j = (n + 1) % 3; + if (o_i != 2 && o_j != 2) + continue; + for (int i = 0; i < 3; i++) + { + off_cp[i] = Offset((o_i == 2) ? off[i].x() : 0, (o_j == 2) ? off[i].y() + : 0); + CGAL_triangulation_assertion(off_cp[i].x() == 0 || off_cp[i].x() == 1); + CGAL_triangulation_assertion(off_cp[i].y() == 0 || off_cp[i].y() == 1); + } + set_offsets(c_cp->second[n], off_cp[0], off_cp[1], off_cp[2]); + } } - } // Iterate over all original faces and reset offsets. for (typename std::list::iterator fit = original_faces.begin(); fit - != original_faces.end(); ++fit) { - //This statement does not seem to have any effect - set_offsets(*fit, 0, 0, 0); - CGAL_triangulation_assertion((*fit)->offset(0) == 0); - CGAL_triangulation_assertion((*fit)->offset(1) == 0); - CGAL_triangulation_assertion((*fit)->offset(2) == 0); - } + != original_faces.end(); ++fit) + { + //This statement does not seem to have any effect + set_offsets(*fit, 0, 0, 0); + CGAL_triangulation_assertion((*fit)->offset(0) == 0); + CGAL_triangulation_assertion((*fit)->offset(1) == 0); + CGAL_triangulation_assertion((*fit)->offset(2) == 0); + } _cover = make_array(3, 3); // Set up too long edges data structure int i = 0; - for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) { - _too_long_edges[vit] = std::list(); - ++i; - } + for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) + { + _too_long_edges[vit] = std::list(); + ++i; + } _too_long_edge_counter = find_too_long_edges(_too_long_edges); CGAL_triangulation_expensive_assertion(is_valid()); @@ -3123,29 +3522,35 @@ void Periodic_2_triangulation_2::convert_to_9_sheeted_covering() { // iterate over all edges and store the ones that are longer than // edge_length_threshold in edges. Return the number of too long edges. template -inline int Periodic_2_triangulation_2::find_too_long_edges(std::map< - Vertex_handle, std::list >& edges) const { +inline int Periodic_2_triangulation_2::find_too_long_edges(std::map < + Vertex_handle, std::list > & edges) const +{ Point p1, p2; int counter = 0; Vertex_handle v_no, vh; - for (Edge_iterator eit = edges_begin(); eit != edges_end(); eit++) { - p1 = construct_point(eit->first->vertex(ccw(eit->second))->point(), - get_offset(eit->first, ccw(eit->second))); - p2 = construct_point(eit->first->vertex(cw(eit->second))->point(), - get_offset(eit->first, cw(eit->second))); - if (edge_is_too_long(p1, p2)) { - if (&*(eit->first->vertex(ccw(eit->second))) < &*(eit->first->vertex(cw( - eit->second)))) { - v_no = eit->first->vertex(ccw(eit->second)); - vh = eit->first->vertex(cw(eit->second)); - } else { - v_no = eit->first->vertex(cw(eit->second)); - vh = eit->first->vertex(ccw(eit->second)); - } - edges[v_no].push_back(vh); - counter++; + for (Edge_iterator eit = edges_begin(); eit != edges_end(); eit++) + { + p1 = construct_point(eit->first->vertex(ccw(eit->second))->point(), + get_offset(eit->first, ccw(eit->second))); + p2 = construct_point(eit->first->vertex(cw(eit->second))->point(), + get_offset(eit->first, cw(eit->second))); + if (edge_is_too_long(p1, p2)) + { + if (&*(eit->first->vertex(ccw(eit->second))) < &*(eit->first->vertex(cw( + eit->second)))) + { + v_no = eit->first->vertex(ccw(eit->second)); + vh = eit->first->vertex(cw(eit->second)); + } + else + { + v_no = eit->first->vertex(cw(eit->second)); + vh = eit->first->vertex(ccw(eit->second)); + } + edges[v_no].push_back(vh); + counter++; + } } - } return counter; } @@ -3159,7 +3564,8 @@ inline int Periodic_2_triangulation_2::find_too_long_edges(std::map< */ template inline void Periodic_2_triangulation_2::get_vertex(Face_handle fh, - int i, Vertex_handle &vh, Offset &off) const { + int i, Vertex_handle &vh, Offset &off) const +{ off = combine_offsets(Offset(), int_to_off(fh->offset(i))); vh = fh->vertex(i); @@ -3172,23 +3578,27 @@ inline void Periodic_2_triangulation_2::get_vertex(Face_handle fh, template inline void Periodic_2_triangulation_2::get_vertex(Vertex_handle vh_i, - Vertex_handle &vh, Offset &off) const { + Vertex_handle &vh, Offset &off) const +{ Virtual_vertex_map_it it = _virtual_vertices.find(vh_i); - if (it == _virtual_vertices.end()) { - // if vh_i is not contained in virtual_vertices, then it is in the - // original domain. - vh = vh_i; - CGAL_triangulation_assertion(vh != Vertex_handle()); - } else { - // otherwise it has to be looked up as well as its offset. - vh = it->second.first; - off += it->second.second; - CGAL_triangulation_assertion(vh->point().x() < _domain.xmax()); - CGAL_triangulation_assertion(vh->point().y() < _domain.ymax()); - CGAL_triangulation_assertion(vh->point().x() >= _domain.xmin()); - CGAL_triangulation_assertion(vh->point().y() >= _domain.ymin()); - } + if (it == _virtual_vertices.end()) + { + // if vh_i is not contained in virtual_vertices, then it is in the + // original domain. + vh = vh_i; + CGAL_triangulation_assertion(vh != Vertex_handle()); + } + else + { + // otherwise it has to be looked up as well as its offset. + vh = it->second.first; + off += it->second.second; + CGAL_triangulation_assertion(vh->point().x() < _domain.xmax()); + CGAL_triangulation_assertion(vh->point().y() < _domain.ymax()); + CGAL_triangulation_assertion(vh->point().x() >= _domain.xmin()); + CGAL_triangulation_assertion(vh->point().y() >= _domain.ymin()); + } } /** Find the Face that consists of the three given vertices @@ -3197,24 +3607,29 @@ inline void Periodic_2_triangulation_2::get_vertex(Vertex_handle vh_i, * with the three vertices in vh. */ template -inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2< - GT, Tds>::get_face(const Vertex_handle* vh) const { +inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_triangulation_2 < +GT, Tds >::get_face(const Vertex_handle* vh) const +{ bool contains_v[2]; Face_circulator fc = incident_faces(vh[2]); Face_circulator done(fc); - do { - CGAL_triangulation_assertion( + do + { + CGAL_triangulation_assertion( fc->vertex(0) == vh[2] || fc->vertex(1) == vh[2] || fc->vertex(2) == vh[2]); - for (int j = 0; j < 2; j++) { - contains_v[j] = (fc->vertex(0) == vh[j]) || (fc->vertex(1) == vh[j]) - || (fc->vertex(2) == vh[j]); + for (int j = 0; j < 2; j++) + { + contains_v[j] = (fc->vertex(0) == vh[j]) || (fc->vertex(1) == vh[j]) + || (fc->vertex(2) == vh[j]); + } + if (contains_v[0] && contains_v[1]) + { + return fc; + } } - if (contains_v[0] && contains_v[1]) { - return fc; - } - } while (++fc != done); + while (++fc != done); CGAL_triangulation_assertion(false); return Face_handle(); @@ -3222,137 +3637,160 @@ inline typename Periodic_2_triangulation_2::Face_handle Periodic_2_tria template Bounded_side Periodic_2_triangulation_2::side_of_face(const Point &q, - const Offset &off, Face_handle f, Locate_type <, int &li) const { + const Offset &off, Face_handle f, Locate_type <, int &li) const +{ CGAL_triangulation_precondition(number_of_vertices() != 0); Orientation o0, o1, o2; o0 = o1 = o2 = ZERO; int cumm_off = f->offset(0) | f->offset(1) | f->offset(2); - if ((cumm_off == 0) && is_1_cover()) { - CGAL_triangulation_assertion(off == Offset()); + if ((cumm_off == 0) && is_1_cover()) + { + CGAL_triangulation_assertion(off == Offset()); - const Point &p0 = f->vertex(0)->point(); - const Point &p1 = f->vertex(1)->point(); - const Point &p2 = f->vertex(2)->point(); + const Point &p0 = f->vertex(0)->point(); + const Point &p1 = f->vertex(1)->point(); + const Point &p2 = f->vertex(2)->point(); - if (((o0 = orientation(q, p1, p2)) == NEGATIVE) || ((o1 = orientation(p0, - q, p2)) == NEGATIVE) || ((o2 = orientation(p0, p1, q)) == NEGATIVE)) { - return ON_UNBOUNDED_SIDE; - } - } else { // Special case for the periodic space. - Offset off_q; - Offset offs[3]; - const Point *p[3]; - for (int i = 0; i < 3; i++) { - p[i] = &(f->vertex(i)->point()); - offs[i] = get_offset(f, i); - } - CGAL_triangulation_assertion(orientation(*p[0], *p[1], *p[2], - offs[0], offs[1], offs[2]) == POSITIVE); - bool found = false; - for (int i = 0; (i < 4) && (!found); i++) { - if ((cumm_off | ((~i) & 3)) == 3) { - o0 = o1 = o2 = NEGATIVE; - off_q = combine_offsets(off, int_to_off(i)); - - if (((o0 = orientation(q, *p[1], *p[2], off_q, offs[1], offs[2])) - != NEGATIVE) && ((o1 = orientation(*p[0], q, *p[2], offs[0], off_q, - offs[2])) != NEGATIVE) && ((o2 = orientation(*p[0], *p[1], q, - offs[0], offs[1], off_q)) != NEGATIVE)) { - found = true; + if (((o0 = orientation(q, p1, p2)) == NEGATIVE) || ((o1 = orientation(p0, + q, p2)) == NEGATIVE) || ((o2 = orientation(p0, p1, q)) == NEGATIVE)) + { + return ON_UNBOUNDED_SIDE; } - } } - if (!found) - return ON_UNBOUNDED_SIDE; - } + else // Special case for the periodic space. + { + Offset off_q; + Offset offs[3]; + const Point *p[3]; + for (int i = 0; i < 3; i++) + { + p[i] = &(f->vertex(i)->point()); + offs[i] = get_offset(f, i); + } + CGAL_triangulation_assertion(orientation(*p[0], *p[1], *p[2], + offs[0], offs[1], offs[2]) == POSITIVE); + bool found = false; + for (int i = 0; (i < 4) && (!found); i++) + { + if ((cumm_off | ((~i) & 3)) == 3) + { + o0 = o1 = o2 = NEGATIVE; + off_q = combine_offsets(off, int_to_off(i)); + + if (((o0 = orientation(q, *p[1], *p[2], off_q, offs[1], offs[2])) + != NEGATIVE) && ((o1 = orientation(*p[0], q, *p[2], offs[0], off_q, + offs[2])) != NEGATIVE) && ((o2 = orientation(*p[0], *p[1], q, + offs[0], offs[1], off_q)) != NEGATIVE)) + { + found = true; + } + } + } + if (!found) + return ON_UNBOUNDED_SIDE; + } // now all the oi's are >=0 // sum gives the number of facets p lies on int sum = ((o0 == ZERO) ? 1 : 0) + ((o1 == ZERO) ? 1 : 0) + ((o2 == ZERO) ? 1 - : 0); + : 0); - switch (sum) { - case 0: { - lt = FACE; - return ON_BOUNDED_SIDE; - } - case 1: { - lt = EDGE; - // i = index such that q lies on edge (f,li) - li = (o0 == ZERO) ? 0 : (o1 == ZERO) ? 1 : 2; - return ON_BOUNDARY; - } - case 2: { - lt = VERTEX; - // i = index such that q lies on vertex li - li = (o0 != ZERO) ? 0 : (o1 != ZERO) ? 1 : 2; - return ON_BOUNDARY; - } - default: { - // impossible : cannot be on 3 edges for a real triangle - CGAL_triangulation_assertion(false); - return ON_BOUNDARY; - } - } + switch (sum) + { + case 0: + { + lt = FACE; + return ON_BOUNDED_SIDE; + } + case 1: + { + lt = EDGE; + // i = index such that q lies on edge (f,li) + li = (o0 == ZERO) ? 0 : (o1 == ZERO) ? 1 : 2; + return ON_BOUNDARY; + } + case 2: + { + lt = VERTEX; + // i = index such that q lies on vertex li + li = (o0 != ZERO) ? 0 : (o1 != ZERO) ? 1 : 2; + return ON_BOUNDARY; + } + default: + { + // impossible : cannot be on 3 edges for a real triangle + CGAL_triangulation_assertion(false); + return ON_BOUNDARY; + } + } } template Oriented_side Periodic_2_triangulation_2::oriented_side(Face_handle f, - const Point& p, const Offset &o) const { + const Point& p, const Offset &o) const +{ Point &p0 = f->vertex(0)->point(); Point &p1 = f->vertex(1)->point(); Point &p2 = f->vertex(2)->point(); int cumm_off = f->offset(0) | f->offset(1) | f->offset(2); - if ((cumm_off == 0) && is_1_cover()) { - CGAL_precondition(o == Offset()); + if ((cumm_off == 0) && is_1_cover()) + { + CGAL_precondition(o == Offset()); - // return position of point p with respect to the oriented triangle p0p1p2 - // the orientation of the vertices is assumed to be counter clockwise - CGAL_assertion(orientation(p0,p1,p2) == LEFT_TURN); + // return position of point p with respect to the oriented triangle p0p1p2 + // the orientation of the vertices is assumed to be counter clockwise + CGAL_assertion(orientation(p0, p1, p2) == LEFT_TURN); + + Bounded_side bs = bounded_side(p0, p1, p2, p); + switch (bs) + { + case ON_BOUNDARY: + return ON_ORIENTED_BOUNDARY; + case ON_BOUNDED_SIDE: + return ON_POSITIVE_SIDE; + case ON_UNBOUNDED_SIDE: + return ON_NEGATIVE_SIDE; + } + } + else // Special case for the periodic space. + { + Offset off_q; + Offset off0 = get_offset(f, 0); + Offset off1 = get_offset(f, 1); + Offset off2 = get_offset(f, 2); + + // return position of point p with respect to the oriented triangle p0p1p2 + // the orientation of the vertices is assumed to be counter clockwise + CGAL_assertion(orientation(p0, p1, p2, off0, off1, off2) == LEFT_TURN); + + Bounded_side bs; + for (int i = 0; (i <= 7); i++) + { + if ((cumm_off | ((~i) & 3)) == 3) + { + off_q = combine_offsets(o, int_to_off(i)); + bs = bounded_side(p0, p1, p2, p, off0, off1, off2, off_q); + if (bs != ON_UNBOUNDED_SIDE) + { + return (bs == ON_BOUNDARY ? ON_ORIENTED_BOUNDARY : ON_POSITIVE_SIDE); + } + } + } - Bounded_side bs = bounded_side(p0, p1, p2, p); - switch (bs) { - case ON_BOUNDARY: - return ON_ORIENTED_BOUNDARY; - case ON_BOUNDED_SIDE: - return ON_POSITIVE_SIDE; - case ON_UNBOUNDED_SIDE: return ON_NEGATIVE_SIDE; } - } else { // Special case for the periodic space. - Offset off_q; - Offset off0 = get_offset(f, 0); - Offset off1 = get_offset(f, 1); - Offset off2 = get_offset(f, 2); - - // return position of point p with respect to the oriented triangle p0p1p2 - // the orientation of the vertices is assumed to be counter clockwise - CGAL_assertion(orientation(p0,p1,p2, off0,off1,off2) == LEFT_TURN); - - Bounded_side bs; - for (int i = 0; (i <= 7); i++) { - if ((cumm_off | ((~i) & 3)) == 3) { - off_q = combine_offsets(o, int_to_off(i)); - bs = bounded_side(p0, p1, p2, p, off0, off1, off2, off_q); - if (bs != ON_UNBOUNDED_SIDE) { - return (bs == ON_BOUNDARY ? ON_ORIENTED_BOUNDARY : ON_POSITIVE_SIDE); - } - } - } - - return ON_NEGATIVE_SIDE; - } CGAL_assertion(false); return ON_NEGATIVE_SIDE; } template -Bounded_side Periodic_2_triangulation_2::bounded_side(const Point &p0, const Point &p1, const Point &p2, const Point &p) const { +Bounded_side Periodic_2_triangulation_2::bounded_side(const Point &p0, const Point &p1, const Point &p2, const Point &p) const +{ // return position of point p with respect to triangle p0p1p2 CGAL_triangulation_precondition( orientation(p0, p1, p2) != COLLINEAR); @@ -3361,27 +3799,30 @@ Bounded_side Periodic_2_triangulation_2::bounded_side(const Point &p0, Orientation o2 = orientation(p1, p2, p); Orientation o3 = orientation(p2, p0, p); - if (o1 == COLLINEAR) { - if (o2 == COLLINEAR || o3 == COLLINEAR) - return ON_BOUNDARY; - if (collinear_between(p0, p, p1)) - return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } + if (o1 == COLLINEAR) + { + if (o2 == COLLINEAR || o3 == COLLINEAR) + return ON_BOUNDARY; + if (collinear_between(p0, p, p1)) + return ON_BOUNDARY; + return ON_UNBOUNDED_SIDE; + } - if (o2 == COLLINEAR) { - if (o3 == COLLINEAR) - return ON_BOUNDARY; - if (collinear_between(p1, p, p2)) - return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } + if (o2 == COLLINEAR) + { + if (o3 == COLLINEAR) + return ON_BOUNDARY; + if (collinear_between(p1, p, p2)) + return ON_BOUNDARY; + return ON_UNBOUNDED_SIDE; + } - if (o3 == COLLINEAR) { - if (collinear_between(p2, p, p0)) - return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } + if (o3 == COLLINEAR) + { + if (collinear_between(p2, p, p0)) + return ON_BOUNDARY; + return ON_UNBOUNDED_SIDE; + } // from here none ot, o1, o2 and o3 are known to be non null if (o1 == o2 && o2 == o3) @@ -3392,34 +3833,38 @@ Bounded_side Periodic_2_triangulation_2::bounded_side(const Point &p0, template Bounded_side Periodic_2_triangulation_2::bounded_side(const Point &p0, const Point &p1, const Point &p2, const Point &p, const Offset &o0, - const Offset &o1, const Offset &o2, const Offset &o) const { + const Offset &o1, const Offset &o2, const Offset &o) const +{ // return position of point p with respect to triangle p0p1p2 - CGAL_triangulation_precondition( orientation(p0,p1,p2, o0,o1,o2) != COLLINEAR); + CGAL_triangulation_precondition( orientation(p0, p1, p2, o0, o1, o2) != COLLINEAR); Orientation orient1 = orientation(p0, p1, p, o0, o1, o); Orientation orient2 = orientation(p1, p2, p, o1, o2, o); Orientation orient3 = orientation(p2, p0, p, o2, o0, o); - if (orient1 == COLLINEAR) { - if (orient2 == COLLINEAR || orient3 == COLLINEAR) - return ON_BOUNDARY; - if (collinear_between(p0, p, p1, o0, o, o1)) - return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } + if (orient1 == COLLINEAR) + { + if (orient2 == COLLINEAR || orient3 == COLLINEAR) + return ON_BOUNDARY; + if (collinear_between(p0, p, p1, o0, o, o1)) + return ON_BOUNDARY; + return ON_UNBOUNDED_SIDE; + } - if (orient2 == COLLINEAR) { - if (orient3 == COLLINEAR) - return ON_BOUNDARY; - if (collinear_between(p1, p, p2, o1, o, o2)) - return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } + if (orient2 == COLLINEAR) + { + if (orient3 == COLLINEAR) + return ON_BOUNDARY; + if (collinear_between(p1, p, p2, o1, o, o2)) + return ON_BOUNDARY; + return ON_UNBOUNDED_SIDE; + } - if (orient3 == COLLINEAR) { - if (collinear_between(p2, p, p0, o2, o, o0)) - return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } + if (orient3 == COLLINEAR) + { + if (collinear_between(p2, p, p0, o2, o, o0)) + return ON_BOUNDARY; + return ON_UNBOUNDED_SIDE; + } // from here none ot, o1, o2 and o3 are known to be non null if (orient1 == orient2 && orient2 == orient3) @@ -3430,19 +3875,23 @@ Bounded_side Periodic_2_triangulation_2::bounded_side(const Point &p0, template bool Periodic_2_triangulation_2::collinear_between(const Point& p, - const Point& q, const Point& r) const { + const Point& q, const Point& r) const +{ // return true if point q is strictly between p and r // p,q and r are supposed to be collinear points Comparison_result c_pr = compare_x(p, r); Comparison_result c_pq; Comparison_result c_qr; - if(c_pr == EQUAL) { - c_pq = compare_y(p, q); - c_qr = compare_y(q, r); - } else { - c_pq = compare_x(p, q); - c_qr = compare_x(q, r); - } + if(c_pr == EQUAL) + { + c_pq = compare_y(p, q); + c_qr = compare_y(q, r); + } + else + { + c_pq = compare_x(p, q); + c_qr = compare_x(q, r); + } return ( (c_pq == SMALLER) && (c_qr == SMALLER) ) || ( (c_pq == LARGER) && (c_qr == LARGER) ); @@ -3451,91 +3900,107 @@ bool Periodic_2_triangulation_2::collinear_between(const Point& p, template bool Periodic_2_triangulation_2::collinear_between(const Point& p, const Point& q, const Point& r, const Offset& o_p, const Offset& o_q, - const Offset& o_r) const { + const Offset& o_r) const +{ // return true if point q is strictly between p and r // p,q and r are supposed to be collinear points Comparison_result c_pr = compare_x(p, r, o_p, o_r); Comparison_result c_pq; Comparison_result c_qr; - if (c_pr == EQUAL) { - c_pq = compare_y(p, q, o_p, o_q); - c_qr = compare_y(q, r, o_q, o_r); - } else { - c_pq = compare_x(p, q, o_p, o_q); - c_qr = compare_x(q, r, o_q, o_r); - } + if (c_pr == EQUAL) + { + c_pq = compare_y(p, q, o_p, o_q); + c_qr = compare_y(q, r, o_q, o_r); + } + else + { + c_pq = compare_x(p, q, o_p, o_q); + c_qr = compare_x(q, r, o_q, o_r); + } return (((c_pq == SMALLER) && (c_qr == SMALLER)) || ((c_pq == LARGER) && (c_qr == LARGER))); } template inline Comparison_result Periodic_2_triangulation_2::compare_x( - const Point& p, const Point& q) const { + const Point& p, const Point& q) const +{ return geom_traits().compare_x_2_object()(p, q); } template inline Comparison_result Periodic_2_triangulation_2::compare_x( - const Point& p, const Point& q, const Offset &o_p, const Offset &o_q) const { + const Point& p, const Point& q, const Offset &o_p, const Offset &o_q) const +{ return geom_traits().compare_x_2_object()(p, q, o_p, o_q); } template inline Comparison_result Periodic_2_triangulation_2::compare_xy( - const Point& p, const Point& q) const { + const Point& p, const Point& q) const +{ Comparison_result res = geom_traits().compare_x_2_object()(p, q); - if (res == EQUAL) { - return geom_traits().compare_y_2_object()(p, q); - } + if (res == EQUAL) + { + return geom_traits().compare_y_2_object()(p, q); + } return res; } template inline Comparison_result Periodic_2_triangulation_2::compare_xy( - const Point& p, const Point& q, const Offset &o_p, const Offset &o_q) const { + const Point& p, const Point& q, const Offset &o_p, const Offset &o_q) const +{ Comparison_result res = geom_traits().compare_x_2_object()(p, q, o_p, o_q); - if (res == EQUAL) { - return geom_traits().compare_y_2_object()(p, q, o_p, o_q); - } + if (res == EQUAL) + { + return geom_traits().compare_y_2_object()(p, q, o_p, o_q); + } return res; } template inline Comparison_result Periodic_2_triangulation_2::compare_y( - const Point& p, const Point& q) const { + const Point& p, const Point& q) const +{ return geom_traits().compare_y_2_object()(p, q); } template inline Comparison_result Periodic_2_triangulation_2::compare_y( - const Point& p, const Point& q, const Offset &o_p, const Offset &o_q) const { + const Point& p, const Point& q, const Offset &o_p, const Offset &o_q) const +{ return geom_traits().compare_y_2_object()(p, q, o_p, o_q); } template inline bool Periodic_2_triangulation_2::xy_equal(const Point& p, - const Point& q) const { + const Point& q) const +{ return compare_xy(p, q) == EQUAL; } template inline Orientation Periodic_2_triangulation_2::orientation( - const Point& p0, const Point& p1, const Point& p2) const { + const Point& p0, const Point& p1, const Point& p2) const +{ return geom_traits().orientation_2_object()(p0, p1, p2); } template inline Orientation Periodic_2_triangulation_2::orientation( - const Point& p0, const Point& p1, const Point& p2, const Offset& o0, - const Offset& o1, const Offset& o2) const { + const Point& p0, const Point& p1, const Point& p2, const Offset& o0, + const Offset& o1, const Offset& o2) const +{ return geom_traits().orientation_2_object()(p0, p1, p2, o0, o1, o2); } template Oriented_side Periodic_2_triangulation_2::side_of_oriented_circle( - const Point &p0, const Point &p1, const Point &p2, const Point &p, - bool perturb) const { + const Point &p0, const Point &p1, const Point &p2, const Point &p, + bool perturb) const +{ Oriented_side os = geom_traits().side_of_oriented_circle_2_object()(p0, p1, p2, p); if ((os != ON_ORIENTED_BOUNDARY) || (!perturb)) return os; @@ -3549,27 +4014,29 @@ Oriented_side Periodic_2_triangulation_2::side_of_oriented_circle( // We successively look whether the leading monomial, then 2nd monomial // of the determinant has non null coefficient. // 2 iterations are enough (cf paper) - for (int i = 3; i > 0; --i) { - if (points[i] == &p) - return ON_NEGATIVE_SIDE; // since p0 p1 p2 are non collinear - // and positively oriented - Orientation o; - if (points[i] == &p2 && (o = orientation(p0, p1, p)) != COLLINEAR) - return Oriented_side(o); - if (points[i] == &p1 && (o = orientation(p0, p, p2)) != COLLINEAR) - return Oriented_side(o); - if (points[i] == &p0 && (o = orientation(p, p1, p2)) != COLLINEAR) - return Oriented_side(o); - } + for (int i = 3; i > 0; --i) + { + if (points[i] == &p) + return ON_NEGATIVE_SIDE; // since p0 p1 p2 are non collinear + // and positively oriented + Orientation o; + if (points[i] == &p2 && (o = orientation(p0, p1, p)) != COLLINEAR) + return Oriented_side(o); + if (points[i] == &p1 && (o = orientation(p0, p, p2)) != COLLINEAR) + return Oriented_side(o); + if (points[i] == &p0 && (o = orientation(p, p1, p2)) != COLLINEAR) + return Oriented_side(o); + } CGAL_triangulation_assertion(false); return ON_NEGATIVE_SIDE; } template Oriented_side Periodic_2_triangulation_2::side_of_oriented_circle( - const Point &p0, const Point &p1, const Point &p2, const Point &p, - const Offset &o0, const Offset &o1, const Offset &o2, const Offset &o, - bool perturb) const { + const Point &p0, const Point &p1, const Point &p2, const Point &p, + const Offset &o0, const Offset &o1, const Offset &o2, const Offset &o, + bool perturb) const +{ Oriented_side os = geom_traits().side_of_oriented_circle_2_object()(p0, p1, p2, p, o0, o1, o2, o); if ((os != ON_ORIENTED_BOUNDARY) || (!perturb)) return os; @@ -3577,7 +4044,8 @@ Oriented_side Periodic_2_triangulation_2::side_of_oriented_circle( // We are now in a degenerate case => we do a symbolic perturbation. // We sort the points lexicographically. Periodic_point pts[4] = { std::make_pair(p0, o0), std::make_pair(p1, o1), - std::make_pair(p2, o2), std::make_pair(p, o) }; + std::make_pair(p2, o2), std::make_pair(p, o) + }; const Periodic_point *points[4] = { &pts[0], &pts[1], &pts[2], &pts[3] }; std::sort(points, points + 4, Perturbation_order(this)); @@ -3585,62 +4053,69 @@ Oriented_side Periodic_2_triangulation_2::side_of_oriented_circle( // We successively look whether the leading monomial, then 2nd monomial // of the determinant has non null coefficient. // 2 iterations are enough (cf paper) - for (int i = 3; i > 0; --i) { - if (points[i] == &pts[3]) - return ON_NEGATIVE_SIDE; // since p0 p1 p2 are non collinear - // and positively oriented - Orientation orient; - if ((points[i] == &pts[2]) && ((orient = orientation(p0, p1, p, o0, o1, o)) - != COLLINEAR)) - return Oriented_side(orient); - if ((points[i] == &pts[1]) && ((orient = orientation(p0, p, p2, o0, o, o2)) - != COLLINEAR)) - return Oriented_side(orient); - if ((points[i] == &pts[0]) && ((orient = orientation(p, p1, p2, o, o1, o2)) - != COLLINEAR)) - return Oriented_side(orient); - } + for (int i = 3; i > 0; --i) + { + if (points[i] == &pts[3]) + return ON_NEGATIVE_SIDE; // since p0 p1 p2 are non collinear + // and positively oriented + Orientation orient; + if ((points[i] == &pts[2]) && ((orient = orientation(p0, p1, p, o0, o1, o)) + != COLLINEAR)) + return Oriented_side(orient); + if ((points[i] == &pts[1]) && ((orient = orientation(p0, p, p2, o0, o, o2)) + != COLLINEAR)) + return Oriented_side(orient); + if ((points[i] == &pts[0]) && ((orient = orientation(p, p1, p2, o, o1, o2)) + != COLLINEAR)) + return Oriented_side(orient); + } CGAL_triangulation_assertion(false); return ON_NEGATIVE_SIDE; } template Oriented_side Periodic_2_triangulation_2::side_of_oriented_circle( - Face_handle f, const Point & p, bool perturb) const { + Face_handle f, const Point & p, bool perturb) const +{ Oriented_side os = ON_NEGATIVE_SIDE; int i = 0; // TODO: optimize which copies to check depending on the offsets in // the face. - while (os == ON_NEGATIVE_SIDE && i < 4) { - os = side_of_oriented_circle(f->vertex(0)->point(), f->vertex(1)->point(), f->vertex(2)->point(), p, - get_offset(f, 0), get_offset(f, 1), get_offset(f, 2), combine_offsets(Offset(), int_to_off(i)), - perturb); - i++; - } + while (os == ON_NEGATIVE_SIDE && i < 4) + { + os = side_of_oriented_circle(f->vertex(0)->point(), f->vertex(1)->point(), f->vertex(2)->point(), p, + get_offset(f, 0), get_offset(f, 1), get_offset(f, 2), combine_offsets(Offset(), int_to_off(i)), + perturb); + i++; + } return os; } template -void Periodic_2_triangulation_2::insert_too_long_edges_in_star(Vertex_handle vh) { +void Periodic_2_triangulation_2::insert_too_long_edges_in_star(Vertex_handle vh) +{ // Insert the too long edges in the star of vh Face_handle f = vh->face(); Face_handle f_start = f; - do { - int i = ccw(f->index(vh)); + do + { + int i = ccw(f->index(vh)); - insert_too_long_edge(f, i); + insert_too_long_edge(f, i); - // Proceed to the next face - f = f->neighbor(i); - } while (f != f_start); + // Proceed to the next face + f = f->neighbor(i); + } + while (f != f_start); } template -void Periodic_2_triangulation_2::insert_too_long_edge(Face_handle f, int i) { +void Periodic_2_triangulation_2::insert_too_long_edge(Face_handle f, int i) +{ Vertex_handle vh1 = f->vertex(ccw(i)); Vertex_handle vh2 = f->vertex(cw(i)); CGAL_assertion(vh1 != Vertex_handle()); @@ -3648,25 +4123,31 @@ void Periodic_2_triangulation_2::insert_too_long_edge(Face_handle f, in Point p1 = construct_point(vh1->point(), get_offset(f, ccw(i))); Point p2 = construct_point(vh2->point(), get_offset(f, cw(i))); - if (&*vh1 < &*vh2) { - if (edge_is_too_long(p1, p2) && - (find(_too_long_edges[vh1].begin(), _too_long_edges[vh1].end(), vh2) == _too_long_edges[vh1].end())) { - _too_long_edges[vh1].push_back(vh2); - _too_long_edge_counter++; + if (&*vh1 < &*vh2) + { + if (edge_is_too_long(p1, p2) && + (find(_too_long_edges[vh1].begin(), _too_long_edges[vh1].end(), vh2) == _too_long_edges[vh1].end())) + { + _too_long_edges[vh1].push_back(vh2); + _too_long_edge_counter++; + } } - } else { - CGAL_triangulation_precondition(&*vh2 < &*vh1); - if (edge_is_too_long(p2, p1) && - (find(_too_long_edges[vh2].begin(), _too_long_edges[vh2].end(), vh1) == _too_long_edges[vh2].end())) { - _too_long_edges[vh2].push_back(vh1); - _too_long_edge_counter++; + else + { + CGAL_triangulation_precondition(&*vh2 < &*vh1); + if (edge_is_too_long(p2, p1) && + (find(_too_long_edges[vh2].begin(), _too_long_edges[vh2].end(), vh1) == _too_long_edges[vh2].end())) + { + _too_long_edges[vh2].push_back(vh1); + _too_long_edge_counter++; + } } - } } template void Periodic_2_triangulation_2::remove_too_long_edges_in_star( - Vertex_handle vh) { + Vertex_handle vh) +{ if (is_1_cover()) return; @@ -3674,136 +4155,163 @@ void Periodic_2_triangulation_2::remove_too_long_edges_in_star( Face_handle f = vh->face(); Face_handle f_start = f; - do { - int i = f->index(vh); - int i2 = ccw(i); - Vertex_handle vh2 = f->vertex(i2); + do + { + int i = f->index(vh); + int i2 = ccw(i); + Vertex_handle vh2 = f->vertex(i2); - // Point corresponding to v - Point p1 = construct_point(vh->point(), get_offset(f, f->index(vh))); - // Point corresponding to the other vertex - Point p2 = construct_point(vh2->point(), get_offset(f, i2)); + // Point corresponding to v + Point p1 = construct_point(vh->point(), get_offset(f, f->index(vh))); + // Point corresponding to the other vertex + Point p2 = construct_point(vh2->point(), get_offset(f, i2)); - if (&*vh < &*vh2) { - if (edge_is_too_long(p1, p2) && - (find(_too_long_edges[vh].begin(), _too_long_edges[vh].end(), vh2) != - _too_long_edges[vh].end())) { - _too_long_edges[vh].remove(vh2); - _too_long_edge_counter--; - } - } else { - CGAL_triangulation_precondition(&*vh2 < &*vh); - if (edge_is_too_long(p1, p2) && - (find(_too_long_edges[vh2].begin(), _too_long_edges[vh2].end(), vh) != - _too_long_edges[vh2].end())) { - _too_long_edges[vh2].remove(vh); - _too_long_edge_counter--; - } + if (&*vh < &*vh2) + { + if (edge_is_too_long(p1, p2) && + (find(_too_long_edges[vh].begin(), _too_long_edges[vh].end(), vh2) != + _too_long_edges[vh].end())) + { + _too_long_edges[vh].remove(vh2); + _too_long_edge_counter--; + } + } + else + { + CGAL_triangulation_precondition(&*vh2 < &*vh); + if (edge_is_too_long(p1, p2) && + (find(_too_long_edges[vh2].begin(), _too_long_edges[vh2].end(), vh) != + _too_long_edges[vh2].end())) + { + _too_long_edges[vh2].remove(vh); + _too_long_edge_counter--; + } + } + + // Proceed to the next face + f = f->neighbor(i2); } - - // Proceed to the next face - f = f->neighbor(i2); - } while (f != f_start); + while (f != f_start); } template void Periodic_2_triangulation_2::remove_too_long_edge(Face_handle f, - int i) { + int i) +{ Vertex_handle vh1 = f->vertex(cw(i)); Vertex_handle vh2 = f->vertex(ccw(i)); Point p1 = construct_point(vh1->point(), get_offset(f, cw(i))); Point p2 = construct_point(vh2->point(), get_offset(f, ccw(i))); - if (edge_is_too_long(p1, p2)) { - if (&*vh1 < &*vh2) { - typename std::list::iterator it = find( - _too_long_edges[vh1].begin(), _too_long_edges[vh1].end(), vh2); - if (it != _too_long_edges[vh1].end()) { - _too_long_edges[vh1].erase(it); - _too_long_edge_counter--; - } - } else { - typename std::list::iterator it = find( - _too_long_edges[vh2].begin(), _too_long_edges[vh2].end(), vh1); - if (it != _too_long_edges[vh2].end()) { - _too_long_edges[vh2].erase(it); - _too_long_edge_counter--; - } + if (edge_is_too_long(p1, p2)) + { + if (&*vh1 < &*vh2) + { + typename std::list::iterator it = find( + _too_long_edges[vh1].begin(), _too_long_edges[vh1].end(), vh2); + if (it != _too_long_edges[vh1].end()) + { + _too_long_edges[vh1].erase(it); + _too_long_edge_counter--; + } + } + else + { + typename std::list::iterator it = find( + _too_long_edges[vh2].begin(), _too_long_edges[vh2].end(), vh1); + if (it != _too_long_edges[vh2].end()) + { + _too_long_edges[vh2].erase(it); + _too_long_edge_counter--; + } + } } - } } template bool Periodic_2_triangulation_2::edge_is_too_long(const Point &p1, - const Point &p2) const { + const Point &p2) const +{ return squared_distance(p1, p2) > _edge_length_threshold; } template -inline bool Periodic_2_triangulation_2::is_extensible_triangulation_in_1_sheet_h1() const { - if (!is_1_cover()) { - if (_too_long_edge_counter == 0) - return true; - else - return false; - } else { - typename Geom_traits::FT longest_edge_squared_length(0); - Segment s; - for (Periodic_segment_iterator psit = periodic_segments_begin(UNIQUE); psit - != periodic_segments_end(UNIQUE); ++psit) { - s = construct_segment(*psit); - longest_edge_squared_length = (std::max)(longest_edge_squared_length, - s.squared_length()); +inline bool Periodic_2_triangulation_2::is_extensible_triangulation_in_1_sheet_h1() const +{ + if (!is_1_cover()) + { + if (_too_long_edge_counter == 0) + return true; + else + return false; + } + else + { + typename Geom_traits::FT longest_edge_squared_length(0); + Segment s; + for (Periodic_segment_iterator psit = periodic_segments_begin(UNIQUE); psit + != periodic_segments_end(UNIQUE); ++psit) + { + s = construct_segment(*psit); + longest_edge_squared_length = (std::max)(longest_edge_squared_length, + s.squared_length()); + } + return (longest_edge_squared_length < _edge_length_threshold); } - return (longest_edge_squared_length < _edge_length_threshold); - } } template -inline bool Periodic_2_triangulation_2::is_extensible_triangulation_in_1_sheet_h2() const { +inline bool Periodic_2_triangulation_2::is_extensible_triangulation_in_1_sheet_h2() const +{ typedef typename Geom_traits::Construct_circumcenter_2 Construct_circumcenter; typedef typename Geom_traits::FT FT; Construct_circumcenter construct_circumcenter = - _gt.construct_circumcenter_2_object(); + _gt.construct_circumcenter_2_object(); for (Periodic_triangle_iterator tit = periodic_triangles_begin(UNIQUE); tit - != periodic_triangles_end(UNIQUE); ++tit) { - Point cc = construct_circumcenter(tit->at(0).first, tit->at(1).first, - tit->at(2).first, tit->at(0).second, tit->at(1).second, - tit->at(2).second); + != periodic_triangles_end(UNIQUE); ++tit) + { + Point cc = construct_circumcenter(tit->at(0).first, tit->at(1).first, + tit->at(2).first, tit->at(0).second, tit->at(1).second, + tit->at(2).second); - if (!(FT(16) * squared_distance(cc, point(tit->at(0))) < (_domain.xmax() - - _domain.xmin()) * (_domain.xmax() - _domain.xmin()))) - return false; - } + if (!(FT(16) * squared_distance(cc, point(tit->at(0))) < (_domain.xmax() + - _domain.xmin()) * (_domain.xmax() - _domain.xmin()))) + return false; + } return true; } template -inline bool Periodic_2_triangulation_2::is_triangulation_in_1_sheet() const { +inline bool Periodic_2_triangulation_2::is_triangulation_in_1_sheet() const +{ if (is_1_cover()) return true; - for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) { - if (_virtual_vertices.find(vit) == _virtual_vertices.end()) - continue; - std::set nb_v_odom; - Vertex_handle vh; - Offset off; - Vertex_circulator vcir = adjacent_vertices(vit); - Vertex_circulator vstart = vcir; - size_t degree = 0; - do { - get_vertex(vcir, vh, off); - nb_v_odom.insert(vh); - degree++; - } while (++vcir != vstart); - if (degree != nb_v_odom.size()) - return false; - } + for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) + { + if (_virtual_vertices.find(vit) == _virtual_vertices.end()) + continue; + std::set nb_v_odom; + Vertex_handle vh; + Offset off; + Vertex_circulator vcir = adjacent_vertices(vit); + Vertex_circulator vstart = vcir; + size_t degree = 0; + do + { + get_vertex(vcir, vh, off); + nb_v_odom.insert(vh); + degree++; + } + while (++vcir != vstart); + if (degree != nb_v_odom.size()) + return false; + } return true; } template std::ostream& -Periodic_2_triangulation_2::save(std::ostream& os) const { +Periodic_2_triangulation_2::save(std::ostream& os) const +{ // writes : // the number of vertices // the domain as four coordinates: xmin ymin ymax zmax @@ -3825,57 +4333,64 @@ Periodic_2_triangulation_2::save(std::ostream& os) const { if (is_ascii(os)) os << domain() << std::endl << cover[0] << " " << cover[1] << std::endl - << n*cover[0]*cover[1] << std::endl; - else { - os << domain(); - write(os,cover[0]); - write(os,cover[1]); - write(os,n*cover[0]*cover[1]); - } + << n*cover[0]*cover[1] << std::endl; + else + { + os << domain(); + write(os, cover[0]); + write(os, cover[1]); + write(os, n * cover[0]*cover[1]); + } if (n == 0) return os; - + // write the vertices Unique_hash_map V; - std::size_t i=0; - if (is_1_cover()) { - for (Vertex_iterator it=vertices_begin(); it!=vertices_end(); ++it) { - V[it] = i++; - os << it->point(); - if (is_ascii(os)) - os << std::endl; + std::size_t i = 0; + if (is_1_cover()) + { + for (Vertex_iterator it = vertices_begin(); it != vertices_end(); ++it) + { + V[it] = i++; + os << it->point(); + if (is_ascii(os)) + os << std::endl; + } } - } else { - Virtual_vertex_map_it vit, vvit; - std::vector vv; - for (Vertex_iterator it=vertices_begin(); it!=vertices_end(); ++it) { - vit = _virtual_vertices.find(it); - if (vit != _virtual_vertices.end()) continue; - V[it]=i++; - if (is_ascii(os)) - os << it->point() << std::endl - << Offset(0,0) << std::endl; - else - os << it->point() << Offset(0,0); - CGAL_triangulation_assertion(_virtual_vertices_reverse.find(it) - != _virtual_vertices_reverse.end()); - vv = _virtual_vertices_reverse.find(it)->second; - CGAL_triangulation_assertion(vv.size() == 8); - for (std::size_t j=0; jpoint() << std::endl - << vvit->second.second << std::endl; - else os << vv[j]->point() << vvit->second.second; - } + else + { + Virtual_vertex_map_it vit, vvit; + std::vector vv; + for (Vertex_iterator it = vertices_begin(); it != vertices_end(); ++it) + { + vit = _virtual_vertices.find(it); + if (vit != _virtual_vertices.end()) continue; + V[it] = i++; + if (is_ascii(os)) + os << it->point() << std::endl + << Offset(0, 0) << std::endl; + else + os << it->point() << Offset(0, 0); + CGAL_triangulation_assertion(_virtual_vertices_reverse.find(it) + != _virtual_vertices_reverse.end()); + vv = _virtual_vertices_reverse.find(it)->second; + CGAL_triangulation_assertion(vv.size() == 8); + for (std::size_t j = 0; j < vv.size(); j++) + { + vvit = _virtual_vertices.find(vv[j]); + CGAL_triangulation_assertion(vvit != _virtual_vertices.end()); + V[vv[j]] = i++; + if (is_ascii(os)) + os << vv[j]->point() << std::endl + << vvit->second.second << std::endl; + else os << vv[j]->point() << vvit->second.second; + } + } } - } - CGAL_triangulation_postcondition(i==_cover[0]*_cover[1]*n); + CGAL_triangulation_postcondition(i == _cover[0]*_cover[1]*n); - Unique_hash_map F; + Unique_hash_map F; int inum = 0; // asks the tds for the combinatorial information // vertices of the faces @@ -3884,62 +4399,72 @@ Periodic_2_triangulation_2::save(std::ostream& os) const { else write(os, m); for( Face_iterator ib = faces_begin(); - ib != faces_end(); ++ib) { - F[ib] = inum++; - for(int j = 0; j < 3 ; ++j) { - if(is_ascii(os)) os << V[ib->vertex(j)] << " "; - else write(os, V[ib->vertex(j)]); + ib != faces_end(); ++ib) + { + F[ib] = inum++; + for(int j = 0; j < 3 ; ++j) + { + if(is_ascii(os)) os << V[ib->vertex(j)] << " "; + else write(os, V[ib->vertex(j)]); + } + os << *ib ; + if(is_ascii(os)) os << "\n"; } - os << *ib ; - if(is_ascii(os)) os << "\n"; - } if(is_ascii(os)) os << "\n"; - + // neighbor pointers of the faces for( Face_iterator it = faces_begin(); - it != faces_end(); ++it) { - for(int j = 0; j < 3; ++j){ - if(is_ascii(os)) os << F[it->neighbor(j)] << " "; - else write(os, F[it->neighbor(j)]); + it != faces_end(); ++it) + { + for(int j = 0; j < 3; ++j) + { + if(is_ascii(os)) os << F[it->neighbor(j)] << " "; + else write(os, F[it->neighbor(j)]); + } + if(is_ascii(os)) os << "\n"; } - if(is_ascii(os)) os << "\n"; - } - + // write offsets //for (unsigned int i=0 ; ioffset(j); - if ( j==3 ) - os << std::endl; - else - os << ' '; - } - else write(os,ch->offset(j)); + for (Face_iterator it = faces_begin(); it != faces_end(); ++it) + { + //Face_handle ch = std::find(faces_begin(), faces_end(), i); + Face_handle ch(it); + for (int j = 0; j < 3; j++) + { + if(is_ascii(os)) + { + os << ch->offset(j); + if ( j == 3 ) + os << std::endl; + else + os << ' '; + } + else write(os, ch->offset(j)); + } } - } - + // write the non combinatorial information on the faces // using the << operator of Face // works because the iterator of the tds traverses the faces in the // same order as the iterator of the triangulation - if(number_of_vertices() != 0) { - for(Face_iterator it=faces_begin(); it != faces_end(); ++it) { - os << *it; // other information - if(is_ascii(os)) - os << std::endl; + if(number_of_vertices() != 0) + { + for(Face_iterator it = faces_begin(); it != faces_end(); ++it) + { + os << *it; // other information + if(is_ascii(os)) + os << std::endl; + } } - } return os; } template std::istream& -Periodic_2_triangulation_2::load(std::istream& is) { +Periodic_2_triangulation_2::load(std::istream& is) +{ // reads // the current covering that guarantees the triangulation to be a // simplicial complex @@ -3955,120 +4480,138 @@ Periodic_2_triangulation_2::load(std::istream& is) { clear(); - Iso_rectangle domain(0,0,1,1); - int cx=0, cy=0; - size_type n=0; + Iso_rectangle domain(0, 0, 1, 1); + int cx = 0, cy = 0; + size_type n = 0; - if (is_ascii(is)) { - is >> domain; - is >> cx >> cy >> n; - } else { - is >> domain; - read(is,cx); read(is,cy); read(is,n); - } - - CGAL_triangulation_assertion((n/(cx*cy))*cx*cy == n); + if (is_ascii(is)) + { + is >> domain; + is >> cx >> cy >> n; + } + else + { + is >> domain; + read(is, cx); + read(is, cy); + read(is, n); + } - tds().set_dimension((n==0?-2:2)); + CGAL_triangulation_assertion((n / (cx * cy))*cx*cy == n); + + tds().set_dimension((n == 0 ? -2 : 2)); _domain = domain; _gt.set_domain(domain); - _cover = make_array(cx,cy); + _cover = make_array(cx, cy); - if ( n==0 ) return is; + if ( n == 0 ) return is; std::map< std::size_t, Vertex_handle > V; - if (cx==1 && cy==1) { - for (std::size_t i=0; i < n; i++) { - V[i] = tds().create_vertex(); - is >> *V[i]; + if (cx == 1 && cy == 1) + { + for (std::size_t i = 0; i < n; i++) + { + V[i] = tds().create_vertex(); + is >> *V[i]; + } } - } else { - Vertex_handle v,w; - std::vector vv; - Offset off; - Point p; - for (std::size_t i=0; i < n; i++) { - v = tds().create_vertex(); - V[i] = v; - is >> p >> off; - V[i]->set_point(p); - vv.clear(); - for (int j=1; j> p >> off; - V[i]->set_point(p); - vv.push_back(w); - _virtual_vertices[w]=std::make_pair(v,off); - } - _virtual_vertices_reverse[v]=vv; + else + { + Vertex_handle v, w; + std::vector vv; + Offset off; + Point p; + for (std::size_t i = 0; i < n; i++) + { + v = tds().create_vertex(); + V[i] = v; + is >> p >> off; + V[i]->set_point(p); + vv.clear(); + for (int j = 1; j < cx * cy; j++) + { + i++; + w = tds().create_vertex(); + V[i] = w; + is >> p >> off; + V[i]->set_point(p); + vv.push_back(w); + _virtual_vertices[w] = std::make_pair(v, off); + } + _virtual_vertices_reverse[v] = vv; + } } - } - + // Creation of the faces std::size_t index; - size_type m; + size_type m; if (is_ascii(is)) is >> m; else read(is, m); std::vector F(m); { - for(size_t i = 0; i < m; ++i) { - F[i] = _tds.create_face() ; - for(int j = 0; j < 3 ; ++j){ - if (is_ascii(is)) is >> index; - else read(is, index); - CGAL_assertion(index < V.size()); - F[i]->set_vertex(j, V[index]); - // The face pointer of vertices is set too often, - // but otherwise we had to use one more map - V[index]->set_face(F[i]); + for(size_t i = 0; i < m; ++i) + { + F[i] = _tds.create_face() ; + for(int j = 0; j < 3 ; ++j) + { + if (is_ascii(is)) is >> index; + else read(is, index); + CGAL_assertion(index < V.size()); + F[i]->set_vertex(j, V[index]); + // The face pointer of vertices is set too often, + // but otherwise we had to use one more map + V[index]->set_face(F[i]); + } + // read in non combinatorial info of the face + is >> *(F[i]) ; } - // read in non combinatorial info of the face - is >> *(F[i]) ; - } } - // Setting the neighbor pointers + // Setting the neighbor pointers { - for(size_t i = 0; i < m; ++i) { - for(int j = 0; j < 3; ++j){ - if (is_ascii(is)) is >> index; - else read(is, index); - CGAL_assertion(i < F.size()); - CGAL_assertion(index < F.size()); - F[i]->set_neighbor(j, F[index]); + for(size_t i = 0; i < m; ++i) + { + for(int j = 0; j < 3; ++j) + { + if (is_ascii(is)) is >> index; + else read(is, index); + CGAL_assertion(i < F.size()); + CGAL_assertion(index < F.size()); + F[i]->set_neighbor(j, F[index]); + } } - } } // read offsets - int off[3] = {0,0,0}; - for (std::size_t j=0 ; j < m; j++) { - if (is_ascii(is)) - is >> off[0] >> off[1] >> off[2]; - else { - read(is,off[0]); - read(is,off[1]); - read(is,off[2]); + int off[3] = {0, 0, 0}; + for (std::size_t j = 0 ; j < m; j++) + { + if (is_ascii(is)) + is >> off[0] >> off[1] >> off[2]; + else + { + read(is, off[0]); + read(is, off[1]); + read(is, off[2]); + } + set_offsets(F[j], off[0], off[1], off[2]); } - set_offsets(F[j],off[0],off[1],off[2]); - } - + // read potential other information - for (std::size_t j=0 ; j < m; j++) + for (std::size_t j = 0 ; j < m; j++) is >> *(F[j]); - int i=0; + int i = 0; for (Vertex_iterator vi = vertices_begin(); - vi != vertices_end(); ++vi) { - _too_long_edges[vi]=std::list(); - ++i; - } + vi != vertices_end(); ++vi) + { + _too_long_edges[vi] = std::list(); + ++i; + } - _edge_length_threshold = FT(0.166) * (_domain.xmax()-_domain.xmin()) - * (_domain.xmax()-_domain.xmin()); + _edge_length_threshold = FT(0.166) * (_domain.xmax() - _domain.xmin()) + * (_domain.xmax() - _domain.xmin()); _too_long_edge_counter = find_too_long_edges(_too_long_edges); CGAL_triangulation_expensive_assertion( is_valid() ); @@ -4076,128 +4619,135 @@ Periodic_2_triangulation_2::load(std::istream& is) { } -namespace internal { +namespace internal +{ - /// Internal function used by operator==. - //TODO: introduce offsets - template - bool - test_next(const Periodic_2_triangulation_2 &t1, - const Periodic_2_triangulation_2 &t2, - typename Periodic_2_triangulation_2::Face_handle c1, - typename Periodic_2_triangulation_2::Face_handle c2, - std::map::Face_handle, - typename Periodic_2_triangulation_2::Face_handle> &Cmap, - std::map::Vertex_handle, - typename Periodic_2_triangulation_2::Vertex_handle> &Vmap) - { - // This function tests and registers the 4 neighbors of c1/c2, - // and recursively calls itself over them. - // Returns false if an inequality has been found. +/// Internal function used by operator==. +//TODO: introduce offsets +template +bool +test_next(const Periodic_2_triangulation_2 &t1, + const Periodic_2_triangulation_2 &t2, + typename Periodic_2_triangulation_2::Face_handle c1, + typename Periodic_2_triangulation_2::Face_handle c2, + std::map < typename Periodic_2_triangulation_2::Face_handle, + typename Periodic_2_triangulation_2::Face_handle > &Cmap, + std::map < typename Periodic_2_triangulation_2::Vertex_handle, + typename Periodic_2_triangulation_2::Vertex_handle > &Vmap) +{ + // This function tests and registers the 4 neighbors of c1/c2, + // and recursively calls itself over them. + // Returns false if an inequality has been found. - // Precondition: c1, c2 have been registered as well as their 4 vertices. - CGAL_triangulation_precondition(t1.number_of_vertices() != 0); - CGAL_triangulation_precondition(Cmap[c1] == c2); - CGAL_triangulation_precondition(Vmap.find(c1->vertex(0)) != Vmap.end()); - CGAL_triangulation_precondition(Vmap.find(c1->vertex(1)) != Vmap.end()); - CGAL_triangulation_precondition(Vmap.find(c1->vertex(2)) != Vmap.end()); + // Precondition: c1, c2 have been registered as well as their 4 vertices. + CGAL_triangulation_precondition(t1.number_of_vertices() != 0); + CGAL_triangulation_precondition(Cmap[c1] == c2); + CGAL_triangulation_precondition(Vmap.find(c1->vertex(0)) != Vmap.end()); + CGAL_triangulation_precondition(Vmap.find(c1->vertex(1)) != Vmap.end()); + CGAL_triangulation_precondition(Vmap.find(c1->vertex(2)) != Vmap.end()); - typedef Periodic_2_triangulation_2 Tr1; - typedef Periodic_2_triangulation_2 Tr2; - typedef typename Tr1::Vertex_handle Vertex_handle1; - typedef typename Tr1::Face_handle Face_handle1; - typedef typename Tr2::Vertex_handle Vertex_handle2; - typedef typename Tr2::Face_handle Face_handle2; - typedef typename std::map::const_iterator Cit; - typedef typename std::map::const_iterator Vit; + typedef Periodic_2_triangulation_2 Tr1; + typedef Periodic_2_triangulation_2 Tr2; + typedef typename Tr1::Vertex_handle Vertex_handle1; + typedef typename Tr1::Face_handle Face_handle1; + typedef typename Tr2::Vertex_handle Vertex_handle2; + typedef typename Tr2::Face_handle Face_handle2; + typedef typename std::map::const_iterator Cit; + typedef typename std::map < Vertex_handle1, + Vertex_handle2 >::const_iterator Vit; - for (int i=0; i <= 2; ++i) { + for (int i = 0; i <= 2; ++i) + { Face_handle1 n1 = c1->neighbor(i); Cit cit = Cmap.find(n1); Vertex_handle1 v1 = c1->vertex(i); Vertex_handle2 v2 = Vmap[v1]; Face_handle2 n2 = c2->neighbor(c2->index(v2)); - if (cit != Cmap.end()) { - // n1 was already registered. - if (cit->second != n2) - return false; - continue; - } + if (cit != Cmap.end()) + { + // n1 was already registered. + if (cit->second != n2) + return false; + continue; + } // n1 has not yet been registered. // We check that the new vertices match geometrically. // And we register them. Vertex_handle1 vn1 = n1->vertex(n1->index(c1)); Vertex_handle2 vn2 = n2->vertex(n2->index(c2)); Vit vit = Vmap.find(vn1); - if (vit != Vmap.end()) { - // vn1 already registered - if (vit->second != vn2) - return false; - } - else { - if (t1.geom_traits().compare_xy_2_object()(vn1->point(), - vn2->point()) != 0) - return false; + if (vit != Vmap.end()) + { + // vn1 already registered + if (vit->second != vn2) + return false; + } + else + { + if (t1.geom_traits().compare_xy_2_object()(vn1->point(), + vn2->point()) != 0) + return false; - // We register vn1/vn2. - Vmap.insert(std::make_pair(vn1, vn2)); - } + // We register vn1/vn2. + Vmap.insert(std::make_pair(vn1, vn2)); + } // We register n1/n2. Cmap.insert(std::make_pair(n1, n2)); // We recurse on n1/n2. if (!test_next(t1, t2, n1, n2, Cmap, Vmap)) - return false; + return false; } - return true; - } + return true; +} } // namespace internal template std::istream& -operator>>(std::istream& is, Periodic_2_triangulation_2 &tr) { +operator>>(std::istream& is, Periodic_2_triangulation_2 &tr) +{ return tr.load(is); } template std::ostream& -operator<<(std::ostream& os, Periodic_2_triangulation_2 &tr) { +operator<<(std::ostream& os, Periodic_2_triangulation_2 &tr) +{ return tr.save(os); } template < class GT, class Tds1, class Tds2 > bool -operator==(const Periodic_2_triangulation_2 &t1, - const Periodic_2_triangulation_2 &t2) +operator==(const Periodic_2_triangulation_2 &t1, + const Periodic_2_triangulation_2 &t2) { - typedef typename Periodic_2_triangulation_2::Vertex_handle - Vertex_handle1; - typedef typename Periodic_2_triangulation_2::Face_handle - Face_handle1; - typedef typename Periodic_2_triangulation_2::Vertex_handle - Vertex_handle2; - typedef typename Periodic_2_triangulation_2::Vertex_handle - Vertex_iterator2; - typedef typename Periodic_2_triangulation_2::Face_handle - Face_handle2; - typedef typename Periodic_2_triangulation_2::Face_circulator - Face_circulator2; - - typedef typename Periodic_2_triangulation_2::Point Point; - typedef typename Periodic_2_triangulation_2::Offset Offset; - typedef typename Periodic_2_triangulation_2 - ::Geom_traits::Compare_xy_2 Compare_xy_2; - + typedef typename Periodic_2_triangulation_2::Vertex_handle + Vertex_handle1; + typedef typename Periodic_2_triangulation_2::Face_handle + Face_handle1; + typedef typename Periodic_2_triangulation_2::Vertex_handle + Vertex_handle2; + typedef typename Periodic_2_triangulation_2::Vertex_handle + Vertex_iterator2; + typedef typename Periodic_2_triangulation_2::Face_handle + Face_handle2; + typedef typename Periodic_2_triangulation_2::Face_circulator + Face_circulator2; + + typedef typename Periodic_2_triangulation_2::Point Point; + typedef typename Periodic_2_triangulation_2::Offset Offset; + typedef typename Periodic_2_triangulation_2 + ::Geom_traits::Compare_xy_2 Compare_xy_2; + // Some quick checks. if ( t1.domain() != t2.domain() - || t1.number_of_sheets() != t2.number_of_sheets()) + || t1.number_of_sheets() != t2.number_of_sheets()) return false; if ( t1.number_of_vertices() != t2.number_of_vertices() - || t1.number_of_faces() != t2.number_of_faces()) + || t1.number_of_faces() != t2.number_of_faces()) return false; // Special case for empty triangulations @@ -4213,13 +4763,14 @@ operator==(const Periodic_2_triangulation_2 &t1, Vertex_handle1 v1 = static_cast(t1.vertices_begin()); Vertex_handle2 iv2; for (Vertex_iterator2 vit2 = t2.vertices_begin() ; - vit2 != t2.vertices_end(); ++vit2) { - if (t1.compare_xy(vit2->point(), v1->point(), - t2.get_offset(vit2), t1.get_offset(v1)) != EQUAL) - continue; - iv2 = static_cast(vit2); - break; - } + vit2 != t2.vertices_end(); ++vit2) + { + if (t1.compare_xy(vit2->point(), v1->point(), + t2.get_offset(vit2), t1.get_offset(v1)) != EQUAL) + continue; + iv2 = static_cast(vit2); + break; + } if (iv2 == Vertex_handle2()) return false; Vmap.insert(std::make_pair(v1, iv2)); @@ -4235,45 +4786,47 @@ operator==(const Periodic_2_triangulation_2 &t1, Offset o3 = t1.get_offset(v3); Face_circulator2 fc = t2.incident_faces(iv2), done(fc); - do { - int inf = fc->index(iv2); + do + { + int inf = fc->index(iv2); - if (t1.compare_xy(p2, fc->vertex((inf+1)%3)->point(), - o2, t2.get_offset(fc->vertex((inf+1)%3))) == EQUAL) - Vmap.insert(std::make_pair(v2, fc->vertex((inf+1)%3))); - else if (t1.compare_xy(p2, fc->vertex((inf+2)%3)->point(), - o2, t2.get_offset(fc->vertex((inf+2)%3))) == EQUAL) - Vmap.insert(std::make_pair(v2, fc->vertex((inf+2)%3))); - else - continue; // None matched v2. + if (t1.compare_xy(p2, fc->vertex((inf + 1) % 3)->point(), + o2, t2.get_offset(fc->vertex((inf + 1) % 3))) == EQUAL) + Vmap.insert(std::make_pair(v2, fc->vertex((inf + 1) % 3))); + else if (t1.compare_xy(p2, fc->vertex((inf + 2) % 3)->point(), + o2, t2.get_offset(fc->vertex((inf + 2) % 3))) == EQUAL) + Vmap.insert(std::make_pair(v2, fc->vertex((inf + 2) % 3))); + else + continue; // None matched v2. - if (t1.compare_xy(p3, fc->vertex((inf+1)%3)->point(), - o3, t2.get_offset(fc->vertex((inf+1)%3))) == EQUAL) - Vmap.insert(std::make_pair(v3, fc->vertex((inf+1)%3))); - else if (t1.compare_xy(p3, fc->vertex((inf+2)%3)->point(), - o3, t2.get_offset(fc->vertex((inf+2)%3))) == EQUAL) - Vmap.insert(std::make_pair(v3, fc->vertex((inf+2)%3))); - else - continue; // None matched v3. + if (t1.compare_xy(p3, fc->vertex((inf + 1) % 3)->point(), + o3, t2.get_offset(fc->vertex((inf + 1) % 3))) == EQUAL) + Vmap.insert(std::make_pair(v3, fc->vertex((inf + 1) % 3))); + else if (t1.compare_xy(p3, fc->vertex((inf + 2) % 3)->point(), + o3, t2.get_offset(fc->vertex((inf + 2) % 3))) == EQUAL) + Vmap.insert(std::make_pair(v3, fc->vertex((inf + 2) % 3))); + else + continue; // None matched v3. - // Found it ! - Cmap.insert(std::make_pair(c, fc)); - break; - } while (++fc != done); + // Found it ! + Cmap.insert(std::make_pair(c, fc)); + break; + } + while (++fc != done); if (Cmap.size() == 0) return false; // We now have one face, we need to propagate recursively. return internal::test_next(t1, t2, - Cmap.begin()->first, Cmap.begin()->second, Cmap, Vmap); + Cmap.begin()->first, Cmap.begin()->second, Cmap, Vmap); } template < class GT, class Tds1, class Tds2 > inline bool -operator!=(const Periodic_2_triangulation_2 &t1, - const Periodic_2_triangulation_2 &t2) +operator!=(const Periodic_2_triangulation_2 &t1, + const Periodic_2_triangulation_2 &t2) { return ! (t1 == t2); } diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h index 7ea0a539658..ad6ea027035 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -22,116 +22,120 @@ #define CGAL_PERIODIC_2_TRIANGULATION_DUMMY_12_H template < class GT, class Tds > -inline std::vector::Vertex_handle > -Periodic_2_triangulation_2::insert_dummy_points() { +inline std::vector::Vertex_handle > +Periodic_2_triangulation_2::insert_dummy_points() +{ clear(); Vertex_handle vertices[12]; // 6 faces per row, 4 rows Face_handle faces[24]; - + // Initialise vertices: - for (int i=0; i<4; i++) { - for (int j=0; j<3; j++) { - // Initialise virtual vertices out of the domain for debugging - vertices[3*i+j] = _tds.create_vertex(); - Point p(j*(1.0/3.0) + i*(1.0/6.0), i*(1.0/4.0) ); - p = Point((p.x() > FT(0.9375) ? (std::max)( p.x()-1, FT(0) ) : p.x()), - p.y()); - p = Point((_domain.xmax()-_domain.xmin())*p.x(), - (_domain.xmax()-_domain.xmin())*p.y()); - p = Point(p.x() + _domain.xmin(), - p.y() + _domain.ymin()); - vertices[3*i+j]->set_point(p); + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < 3; j++) + { + // Initialise virtual vertices out of the domain for debugging + vertices[3 * i + j] = _tds.create_vertex(); + Point p(j * (1.0 / 3.0) + i * (1.0 / 6.0), i * (1.0 / 4.0) ); + p = Point((p.x() > FT(0.9375) ? (std::max)( p.x() - 1, FT(0) ) : p.x()), + p.y()); + p = Point((_domain.xmax() - _domain.xmin()) * p.x(), + (_domain.xmax() - _domain.xmin()) * p.y()); + p = Point(p.x() + _domain.xmin(), + p.y() + _domain.ymin()); + vertices[3 * i + j]->set_point(p); + } } - } // Create faces: - for (int i=0; i<24; i++) { - faces[i] = _tds.create_face(); - } + for (int i = 0; i < 24; i++) + { + faces[i] = _tds.create_face(); + } // bottom row - faces[0]->set_vertices(vertices[0],vertices[1],vertices[3]); - faces[1]->set_vertices(vertices[1],vertices[2],vertices[4]); - faces[2]->set_vertices(vertices[2],vertices[0],vertices[5]); - faces[3]->set_vertices(vertices[0],vertices[3],vertices[5]); - faces[4]->set_vertices(vertices[1],vertices[4],vertices[3]); - faces[5]->set_vertices(vertices[2],vertices[5],vertices[4]); + faces[0]->set_vertices(vertices[0], vertices[1], vertices[3]); + faces[1]->set_vertices(vertices[1], vertices[2], vertices[4]); + faces[2]->set_vertices(vertices[2], vertices[0], vertices[5]); + faces[3]->set_vertices(vertices[0], vertices[3], vertices[5]); + faces[4]->set_vertices(vertices[1], vertices[4], vertices[3]); + faces[5]->set_vertices(vertices[2], vertices[5], vertices[4]); // second row - faces[6]->set_vertices(vertices[3],vertices[4],vertices[6]); - faces[7]->set_vertices(vertices[4],vertices[5],vertices[7]); - faces[8]->set_vertices(vertices[5],vertices[3],vertices[8]); - faces[9]->set_vertices(vertices[3],vertices[6],vertices[8]); - faces[10]->set_vertices(vertices[4],vertices[7],vertices[6]); - faces[11]->set_vertices(vertices[5],vertices[8],vertices[7]); + faces[6]->set_vertices(vertices[3], vertices[4], vertices[6]); + faces[7]->set_vertices(vertices[4], vertices[5], vertices[7]); + faces[8]->set_vertices(vertices[5], vertices[3], vertices[8]); + faces[9]->set_vertices(vertices[3], vertices[6], vertices[8]); + faces[10]->set_vertices(vertices[4], vertices[7], vertices[6]); + faces[11]->set_vertices(vertices[5], vertices[8], vertices[7]); // third row - faces[12]->set_vertices(vertices[6],vertices[7],vertices[9]); - faces[13]->set_vertices(vertices[7],vertices[8],vertices[10]); - faces[14]->set_vertices(vertices[8],vertices[6],vertices[11]); - faces[15]->set_vertices(vertices[6],vertices[9],vertices[11]); - faces[16]->set_vertices(vertices[7],vertices[10],vertices[9]); - faces[17]->set_vertices(vertices[8],vertices[11],vertices[10]); + faces[12]->set_vertices(vertices[6], vertices[7], vertices[9]); + faces[13]->set_vertices(vertices[7], vertices[8], vertices[10]); + faces[14]->set_vertices(vertices[8], vertices[6], vertices[11]); + faces[15]->set_vertices(vertices[6], vertices[9], vertices[11]); + faces[16]->set_vertices(vertices[7], vertices[10], vertices[9]); + faces[17]->set_vertices(vertices[8], vertices[11], vertices[10]); // fourth row - faces[18]->set_vertices(vertices[9],vertices[10],vertices[2]); - faces[19]->set_vertices(vertices[10],vertices[11],vertices[0]); - faces[20]->set_vertices(vertices[11],vertices[9],vertices[1]); - faces[21]->set_vertices(vertices[9],vertices[2],vertices[1]); - faces[22]->set_vertices(vertices[10],vertices[0],vertices[2]); - faces[23]->set_vertices(vertices[11],vertices[1],vertices[0]); + faces[18]->set_vertices(vertices[9], vertices[10], vertices[2]); + faces[19]->set_vertices(vertices[10], vertices[11], vertices[0]); + faces[20]->set_vertices(vertices[11], vertices[9], vertices[1]); + faces[21]->set_vertices(vertices[9], vertices[2], vertices[1]); + faces[22]->set_vertices(vertices[10], vertices[0], vertices[2]); + faces[23]->set_vertices(vertices[11], vertices[1], vertices[0]); - faces[0]->set_neighbors(faces[4],faces[3],faces[23]); - faces[1]->set_neighbors(faces[5],faces[4],faces[21]); - faces[2]->set_neighbors(faces[3],faces[5],faces[22]); - faces[3]->set_neighbors(faces[8],faces[2],faces[0]); - faces[4]->set_neighbors(faces[6],faces[0],faces[1]); - faces[5]->set_neighbors(faces[7],faces[1],faces[2]); + faces[0]->set_neighbors(faces[4], faces[3], faces[23]); + faces[1]->set_neighbors(faces[5], faces[4], faces[21]); + faces[2]->set_neighbors(faces[3], faces[5], faces[22]); + faces[3]->set_neighbors(faces[8], faces[2], faces[0]); + faces[4]->set_neighbors(faces[6], faces[0], faces[1]); + faces[5]->set_neighbors(faces[7], faces[1], faces[2]); - faces[6]->set_neighbors(faces[10],faces[9],faces[4]); - faces[7]->set_neighbors(faces[11],faces[10],faces[5]); - faces[8]->set_neighbors(faces[9],faces[11],faces[3]); - faces[9]->set_neighbors(faces[14],faces[8],faces[6]); - faces[10]->set_neighbors(faces[12],faces[6],faces[7]); - faces[11]->set_neighbors(faces[13],faces[7],faces[8]); + faces[6]->set_neighbors(faces[10], faces[9], faces[4]); + faces[7]->set_neighbors(faces[11], faces[10], faces[5]); + faces[8]->set_neighbors(faces[9], faces[11], faces[3]); + faces[9]->set_neighbors(faces[14], faces[8], faces[6]); + faces[10]->set_neighbors(faces[12], faces[6], faces[7]); + faces[11]->set_neighbors(faces[13], faces[7], faces[8]); - faces[12]->set_neighbors(faces[16],faces[15],faces[10]); - faces[13]->set_neighbors(faces[17],faces[16],faces[11]); - faces[14]->set_neighbors(faces[15],faces[17],faces[9]); - faces[15]->set_neighbors(faces[20],faces[14],faces[12]); - faces[16]->set_neighbors(faces[18],faces[12],faces[13]); - faces[17]->set_neighbors(faces[19],faces[13],faces[14]); + faces[12]->set_neighbors(faces[16], faces[15], faces[10]); + faces[13]->set_neighbors(faces[17], faces[16], faces[11]); + faces[14]->set_neighbors(faces[15], faces[17], faces[9]); + faces[15]->set_neighbors(faces[20], faces[14], faces[12]); + faces[16]->set_neighbors(faces[18], faces[12], faces[13]); + faces[17]->set_neighbors(faces[19], faces[13], faces[14]); - faces[18]->set_neighbors(faces[22],faces[21],faces[16]); - faces[19]->set_neighbors(faces[23],faces[22],faces[17]); - faces[20]->set_neighbors(faces[21],faces[23],faces[15]); - faces[21]->set_neighbors(faces[1],faces[20],faces[18]); - faces[22]->set_neighbors(faces[2],faces[18],faces[19]); - faces[23]->set_neighbors(faces[0],faces[19],faces[20]); + faces[18]->set_neighbors(faces[22], faces[21], faces[16]); + faces[19]->set_neighbors(faces[23], faces[22], faces[17]); + faces[20]->set_neighbors(faces[21], faces[23], faces[15]); + faces[21]->set_neighbors(faces[1], faces[20], faces[18]); + faces[22]->set_neighbors(faces[2], faces[18], faces[19]); + faces[23]->set_neighbors(faces[0], faces[19], faces[20]); - set_offsets(faces[0],0,0,0); - set_offsets(faces[1],0,0,0); - set_offsets(faces[2],0,2,0); - set_offsets(faces[3],2,2,0); - set_offsets(faces[4],0,0,0); - set_offsets(faces[5],0,0,0); - set_offsets(faces[6],0,0,0); - set_offsets(faces[7],0,0,0); - set_offsets(faces[8],0,2,2); - set_offsets(faces[9],0,0,0); - set_offsets(faces[10],0,0,0); - set_offsets(faces[11],0,2,0); - set_offsets(faces[12],0,0,0); - set_offsets(faces[13],0,2,0); - set_offsets(faces[14],0,0,0); - set_offsets(faces[15],0,0,0); - set_offsets(faces[16],0,0,0); - set_offsets(faces[17],2,2,0); - set_offsets(faces[18],0,0,1); - set_offsets(faces[19],0,2,3); - set_offsets(faces[20],0,0,1); - set_offsets(faces[21],0,1,1); - set_offsets(faces[22],0,3,1); - set_offsets(faces[23],0,1,1); + set_offsets(faces[0], 0, 0, 0); + set_offsets(faces[1], 0, 0, 0); + set_offsets(faces[2], 0, 2, 0); + set_offsets(faces[3], 2, 2, 0); + set_offsets(faces[4], 0, 0, 0); + set_offsets(faces[5], 0, 0, 0); + set_offsets(faces[6], 0, 0, 0); + set_offsets(faces[7], 0, 0, 0); + set_offsets(faces[8], 0, 2, 2); + set_offsets(faces[9], 0, 0, 0); + set_offsets(faces[10], 0, 0, 0); + set_offsets(faces[11], 0, 2, 0); + set_offsets(faces[12], 0, 0, 0); + set_offsets(faces[13], 0, 2, 0); + set_offsets(faces[14], 0, 0, 0); + set_offsets(faces[15], 0, 0, 0); + set_offsets(faces[16], 0, 0, 0); + set_offsets(faces[17], 2, 2, 0); + set_offsets(faces[18], 0, 0, 1); + set_offsets(faces[19], 0, 2, 3); + set_offsets(faces[20], 0, 0, 1); + set_offsets(faces[21], 0, 1, 1); + set_offsets(faces[22], 0, 3, 1); + set_offsets(faces[23], 0, 1, 1); vertices[0]->set_face(faces[0]); vertices[1]->set_face(faces[1]); @@ -147,12 +151,13 @@ Periodic_2_triangulation_2::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 ret_vector(12); - for (int i=0; i<12; i++) { - ret_vector[i] = vertices[i]; - } + for (int i = 0; i < 12; i++) + { + ret_vector[i] = vertices[i]; + } CGAL_assertion(is_valid()); diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_face_base_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_face_base_2.h index badd86615ca..c2632922b0b 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_face_base_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_face_base_2.h @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -25,10 +25,11 @@ #include #include -namespace CGAL { +namespace CGAL +{ template < typename Gt, typename Fb = Triangulation_face_base_2 > -class Periodic_2_triangulation_face_base_2 +class Periodic_2_triangulation_face_base_2 : public Fb { typedef Fb Base; @@ -40,7 +41,8 @@ public: typedef typename Tds::Face_handle Face_handle; template < typename TDS2 > - struct Rebind_TDS { + struct Rebind_TDS + { typedef typename Fb::template Rebind_TDS::Other Fb2; typedef Periodic_2_triangulation_face_base_2 Other; }; @@ -49,67 +51,72 @@ public: Periodic_2_triangulation_face_base_2() : Fb(), _off(0) {} - Periodic_2_triangulation_face_base_2(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2) - : Fb(v0,v1,v2) , _off(0){} + Periodic_2_triangulation_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2) + : Fb(v0, v1, v2) , _off(0) {} - Periodic_2_triangulation_face_base_2(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Face_handle n0, - Face_handle n1, - Face_handle n2) - : Fb(v0,v1,v2,n0,n1,n2), _off(0) {} + Periodic_2_triangulation_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2) + : Fb(v0, v1, v2, n0, n1, n2), _off(0) {} /// Periodic functions int offset(int i) const { CGAL_triangulation_precondition( i >= 0 && i < 3 ); - return ((_off>>2*i)&3); + return ((_off >> 2 * i) & 3); } - bool has_zero_offsets() const { - return (_off&63) == 0; + bool has_zero_offsets() const + { + return (_off & 63) == 0; } - void set_offsets(unsigned int o0, unsigned int o1, unsigned int o2) { + void set_offsets(unsigned int o0, unsigned int o1, unsigned int o2) + { // 192=11000000 _off = _off | 192; - unsigned int off0[2] = {(o0>>1)&1, (o0&1)}; - unsigned int off1[2] = {(o1>>1)&1, (o1&1)}; - unsigned int off2[2] = {(o2>>1)&1, (o2&1)}; - for (int i=0; i<2; i++) { - unsigned int _off0 = ( _off &3); - unsigned int _off1 = ((_off>>2)&3); - unsigned int _off2 = ((_off>>4)&3); - - _off0 = ( (_off0<<1) + off0[i]); - _off1 = ( (_off1<<1) + off1[i]); - _off2 = ( (_off2<<1) + off2[i]); - - // 252=11111100 - // 243=11110011 - // 207=11001111 - _off = ((_off&252) | (_off0 )); - _off = ((_off&243) | (_off1<<2)); - _off = ((_off&207) | (_off2<<4)); - } + unsigned int off0[2] = {(o0 >> 1) & 1, (o0 & 1)}; + unsigned int off1[2] = {(o1 >> 1) & 1, (o1 & 1)}; + unsigned int off2[2] = {(o2 >> 1) & 1, (o2 & 1)}; + for (int i = 0; i < 2; i++) + { + unsigned int _off0 = ( _off & 3); + unsigned int _off1 = ((_off >> 2) & 3); + unsigned int _off2 = ((_off >> 4) & 3); + + _off0 = ( (_off0 << 1) + off0[i]); + _off1 = ( (_off1 << 1) + off1[i]); + _off2 = ( (_off2 << 1) + off2[i]); + + // 252=11111100 + // 243=11110011 + // 207=11001111 + _off = ((_off & 252) | (_off0 )); + _off = ((_off & 243) | (_off1 << 2)); + _off = ((_off & 207) | (_off2 << 4)); + } } - - void set_additional_flag(unsigned char b) { + + void set_additional_flag(unsigned char b) + { CGAL_assertion(b < 4); // 63=00111111 - _off = ((_off & 63) | (b<<6)); + _off = ((_off & 63) | (b << 6)); } - unsigned char get_additional_flag() { - return (_off>>6); + unsigned char get_additional_flag() + { + return (_off >> 6); } private: // 2 respective bits are the _offset in x and y - // right to left: + // right to left: // bit[0]-bit[1]: vertex(0), - // bit[2]-bit[3]: vertex(1) and + // bit[2]-bit[3]: vertex(1) and // bit[4]-bit[5]: vertex(2) // Thus the underlying data type needs to have at least 6 bit, // which is true for an unsigned char. @@ -135,6 +142,6 @@ operator<<(std::ostream &os, const Periodic_2_triangulation_face_base_2 &) return os; } -} //namespace CGAL +} //namespace CGAL #endif //CGAL_PERIODIC_2_TRIANGULATION_FACE_BASE_2_H diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_filtered_traits_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_filtered_traits_2.h index 2fd86cfcee5..bfea7dfb25e 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_filtered_traits_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_filtered_traits_2.h @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -31,7 +31,8 @@ #include #include -namespace CGAL { +namespace CGAL +{ // This template class is a wrapper that implements the filtering for any // predicate (dynamic filters with IA). @@ -60,7 +61,7 @@ public: // These constructors are used for constructive predicates. // You should try to avoid constructive predicates, as they will construct // the exact values systematically (in the ctor), rather than lazily. - template + template Filtered_periodic_predicate_2(const OE * oe, const OA * oa) : Base(EP(oe), AP(oa)) {} @@ -76,14 +77,14 @@ struct Offset_converter_2 typedef typename Converter::Target_kernel Target_kernel; typedef typename Periodic_2_triangulation_traits_base_2 - ::Offset_2 Source_off; -/* typedef typename Periodic_2_triangulation_traits_base_2 */ -/* ::Point_2 Source_pt; */ + ::Offset_2 Source_off; + /* typedef typename Periodic_2_triangulation_traits_base_2 */ + /* ::Point_2 Source_pt; */ typedef typename Periodic_2_triangulation_traits_base_2 - ::Offset_2 Target_off; -/* typedef typename Periodic_2_triangulation_traits_base_2 */ -/* ::Point_2 Target_pt; */ + ::Offset_2 Target_off; + /* typedef typename Periodic_2_triangulation_traits_base_2 */ + /* ::Point_2 Target_pt; */ using Converter::operator(); @@ -104,24 +105,25 @@ class Periodic_2_triangulation_filtered_traits_base_2 // Exact traits is based on the exact kernel. typedef Periodic_2_triangulation_traits_2 - Exact_traits; + Exact_traits; // Filtering traits is based on the filtering kernel. typedef Periodic_2_triangulation_traits_2 - Filtering_traits; + Filtering_traits; private: typedef typename K::C2E C2E; typedef typename K::C2F C2F; typedef typename C2E::Target_kernel::Iso_rectangle_2 Exact_iso_rectangle_2; typedef typename C2F::Target_kernel::Iso_rectangle_2 Approximate_iso_rectangle_2; - + public: typedef typename K::Iso_rectangle_2 Iso_rectangle_2; Periodic_2_triangulation_filtered_traits_base_2() {} - void set_domain(const Iso_rectangle_2& domain) { + void set_domain(const Iso_rectangle_2& domain) + { C2E c2e; C2F c2f; this->_domain = domain; @@ -129,40 +131,51 @@ public: this->_domain_f = c2f(this->_domain); } - typedef Filtered_periodic_predicate_2< - typename Exact_traits::Less_x_2, - typename Filtering_traits::Less_x_2, - Offset_converter_2, - Offset_converter_2 > Less_x_2; - typedef Filtered_periodic_predicate_2< - typename Exact_traits::Less_y_2, - typename Filtering_traits::Less_y_2, - Offset_converter_2, - Offset_converter_2 > Less_y_2; - typedef Filtered_periodic_predicate_2< - typename Exact_traits::Orientation_2, - typename Filtering_traits::Orientation_2, - Offset_converter_2, - Offset_converter_2 > Orientation_2; - typedef Filtered_periodic_predicate_2< - typename Exact_traits::Side_of_oriented_circle_2, - typename Filtering_traits::Side_of_oriented_circle_2, - Offset_converter_2, - Offset_converter_2 > Side_of_oriented_circle_2; - typedef Filtered_periodic_predicate_2< - typename Exact_traits::Compare_distance_2, - typename Filtering_traits::Compare_distance_2, - Offset_converter_2, - Offset_converter_2 > Compare_distance_2; + typedef Filtered_periodic_predicate_2 < + typename Exact_traits::Less_x_2, + typename Filtering_traits::Less_x_2, + Offset_converter_2, + Offset_converter_2 > Less_x_2; + typedef Filtered_periodic_predicate_2 < + typename Exact_traits::Less_y_2, + typename Filtering_traits::Less_y_2, + Offset_converter_2, + Offset_converter_2 > Less_y_2; + typedef Filtered_periodic_predicate_2 < + typename Exact_traits::Orientation_2, + typename Filtering_traits::Orientation_2, + Offset_converter_2, + Offset_converter_2 > Orientation_2; + typedef Filtered_periodic_predicate_2 < + typename Exact_traits::Side_of_oriented_circle_2, + typename Filtering_traits::Side_of_oriented_circle_2, + Offset_converter_2, + Offset_converter_2 > Side_of_oriented_circle_2; + typedef Filtered_periodic_predicate_2 < + typename Exact_traits::Compare_distance_2, + typename Filtering_traits::Compare_distance_2, + Offset_converter_2, + Offset_converter_2 > Compare_distance_2; - Less_x_2 less_x_2_object() const { return Less_x_2(&_domain_e,&_domain_f); } - Less_y_2 less_y_2_object() const { return Less_y_2(&_domain_e,&_domain_f); } - Orientation_2 orientation_2_object() const { return Orientation_2(&_domain_e,&_domain_f); } - Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const { - return Side_of_oriented_circle_2(&_domain_e,&_domain_f); + Less_x_2 less_x_2_object() const + { + return Less_x_2(&_domain_e, &_domain_f); } - Compare_distance_2 compare_distance_2_object() const { - return Compare_distance_2(&_domain_e,&_domain_f); + Less_y_2 less_y_2_object() const + { + return Less_y_2(&_domain_e, &_domain_f); + } + Orientation_2 orientation_2_object() const + { + return Orientation_2(&_domain_e, &_domain_f); + } + Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const + { + return Side_of_oriented_circle_2(&_domain_e, &_domain_f); + } + Compare_distance_2 compare_distance_2_object() const + { + return Compare_distance_2(&_domain_e, &_domain_f); } // The following are inherited since they are constructions : @@ -185,18 +198,19 @@ protected: #include -namespace CGAL { +namespace CGAL +{ template < typename K, typename Off = typename CGAL::Periodic_2_offset_2, bool Has_static_filters = K::Has_static_filters > class Periodic_2_triangulation_filtered_traits_2; -template < typename K, typename Off, bool Has_static_filters > +template < typename K, typename Off, bool Has_static_filters > class Periodic_2_triangulation_filtered_traits_2 : public Periodic_2_triangulation_filtered_traits_base_2 {}; - + template < typename K, typename Off > -class Periodic_2_triangulation_filtered_traits_2 - : public Periodic_2_triangulation_statically_filtered_traits_2< +class Periodic_2_triangulation_filtered_traits_2 + : public Periodic_2_triangulation_statically_filtered_traits_2 < Periodic_2_triangulation_filtered_traits_base_2 > {}; } //namespace CGAL diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_2.h index 97cf93fb5f0..2d0655785d0 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_2.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Olivier Devillers // Mariette Yvinec @@ -31,7 +31,8 @@ #include #include -namespace CGAL { +namespace CGAL +{ template < class PTr> class Periodic_2_triangulation_hierarchy_2 @@ -44,7 +45,7 @@ class Periodic_2_triangulation_hierarchy_2 // maximal number of points is 30^5 = 24 millions ! - public: +public: typedef PTr PTr_Base; typedef typename PTr::Geom_traits Geom_traits; typedef typename PTr::Point Point; @@ -63,7 +64,7 @@ class Periodic_2_triangulation_hierarchy_2 using PTr_Base::geom_traits; #endif - private: +private: // here is the stack of triangulations which form the hierarchy PTr_Base* hierarchy[m_maxlevel]; boost::rand48 random; @@ -71,21 +72,21 @@ class Periodic_2_triangulation_hierarchy_2 public: Periodic_2_triangulation_hierarchy_2( - const Iso_rectangle& domain = Iso_rectangle(0,0,1,1), - const Geom_traits& traits = Geom_traits()); + const Iso_rectangle& domain = Iso_rectangle(0, 0, 1, 1), + const Geom_traits& traits = Geom_traits()); Periodic_2_triangulation_hierarchy_2( - const Periodic_2_triangulation_hierarchy_2& tr); + const Periodic_2_triangulation_hierarchy_2& tr); template < typename InputIterator > Periodic_2_triangulation_hierarchy_2(InputIterator first, InputIterator last, - const Iso_rectangle& domain = Iso_rectangle(0,0,1,1), - const Geom_traits& traits = Geom_traits()) - : PTr_Base(domain,traits), level_mult_cover(0) + const Iso_rectangle& domain = Iso_rectangle(0, 0, 1, 1), + const Geom_traits& traits = Geom_traits()) + : PTr_Base(domain, traits), level_mult_cover(0) { - hierarchy[0] = this; - for(int i=1; i std::ptrdiff_t insert(InputIterator first, InputIterator last, bool /* is_large_point_set */ = false) { @@ -115,34 +116,37 @@ public: std::vector points (first, last); CGAL::spatial_sort (points.begin(), points.end(), geom_traits()); - + // hints[i] is the face of the previously inserted point in level i. // Thanks to spatial sort, they are better hints than what the hierarchy // would give us. Face_handle hints[m_maxlevel]; for (typename std::vector::const_iterator p = points.begin(), end = points.end(); - p != end; ++p) { - int vertex_level = random_level(); - - Vertex_handle v = hierarchy[0]->insert (*p, hints[0]); - hints[0] = v->face(); - - Vertex_handle prev = v; - - for (int level = 1; level <= vertex_level; ++level) { - v = hierarchy[level]->insert (*p, hints[level]); - hints[level] = v->face(); - - v->set_down (prev); - if (hierarchy[level]->number_of_sheets()[0] != 1) { - std::vector vtc = hierarchy[level]->periodic_copies(v); - for (unsigned int i=0 ; iset_down(prev); - } - - prev->set_up (v); - prev = v; + p != end; ++p) + { + int vertex_level = random_level(); + + Vertex_handle v = hierarchy[0]->insert (*p, hints[0]); + hints[0] = v->face(); + + Vertex_handle prev = v; + + for (int level = 1; level <= vertex_level; ++level) + { + v = hierarchy[level]->insert (*p, hints[level]); + hints[level] = v->face(); + + v->set_down (prev); + if (hierarchy[level]->number_of_sheets()[0] != 1) + { + std::vector vtc = hierarchy[level]->periodic_copies(v); + for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(prev); + } + + prev->set_up (v); + prev = v; + } } - } std::ptrdiff_t m = this->number_of_vertices(); return m - n; } @@ -157,13 +161,13 @@ public: //LOCATE Face_handle locate(const Point& p, - Locate_type& lt, - int& li, - Face_handle start = Face_handle()) const; + Locate_type& lt, + int& li, + Face_handle start = Face_handle()) const; Face_handle locate(const Point &p, - Face_handle start = Face_handle()) const; + Face_handle start = Face_handle()) const; Vertex_handle nearest_vertex(const Point& p, Face_handle start = Face_handle()) const @@ -173,10 +177,10 @@ public: private: void locate_in_all(const Point& p, - Locate_type& lt, - int& li, - Face_handle loc, - Face_handle pos[m_maxlevel]) const; + Locate_type& lt, + int& li, + Face_handle loc, + Face_handle pos[m_maxlevel]) const; int random_level(); }; @@ -186,10 +190,10 @@ template Periodic_2_triangulation_hierarchy_2:: Periodic_2_triangulation_hierarchy_2(const Iso_rectangle& domain, const Geom_traits& traits) : PTr_Base(domain, traits) -{ +{ level_mult_cover = 0; - hierarchy[0] = this; - for(int i=1;i Periodic_2_triangulation_hierarchy_2:: Periodic_2_triangulation_hierarchy_2(const Periodic_2_triangulation_hierarchy_2 &tr) - : PTr_Base() -{ + : PTr_Base() +{ // create an empty triangulation to be able to delete it ! - hierarchy[0] = this; - for(int i=1;i @@ -222,40 +226,44 @@ operator=(const Periodic_2_triangulation_hierarchy_2 &tr) template void -Periodic_2_triangulation_hierarchy_2:: +Periodic_2_triangulation_hierarchy_2:: copy_triangulation(const Periodic_2_triangulation_hierarchy_2 &tr) { { - for(int i=0;icopy_triangulation(*tr.hierarchy[i]); + for(int i = 0; i < m_maxlevel; ++i) + hierarchy[i]->copy_triangulation(*tr.hierarchy[i]); } - + //up and down have been copied in straightforward way // compute a map at lower level std::map V; { - for(Finite_vertices_iterator it=hierarchy[0]->finite_vertices_begin(); - it != hierarchy[0]->finite_vertices_end(); ++it) { - if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it; - } + for(Finite_vertices_iterator it = hierarchy[0]->finite_vertices_begin(); + it != hierarchy[0]->finite_vertices_end(); ++it) + { + if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it; + } } { - for(int i=1;ifinite_vertices_begin(); - it != hierarchy[i]->finite_vertices_end(); ++it) { - if (hierarchy[i]->is_virtual(it)) { - // down pointer goes in original instead in copied triangulation - it->set_down(V[it->down()]); - // make reverse link - it->down()->set_up(it); - // I think the next line is unnecessary (my) - // make map for next level - if (it->up()!= Vertex_handle() ) V[ it->up()->down() ] = it; - } + for(int i = 1; i < m_maxlevel; ++i) + { + for( Finite_vertices_iterator it = hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) + { + if (hierarchy[i]->is_virtual(it)) + { + // down pointer goes in original instead in copied triangulation + it->set_down(V[it->down()]); + // make reverse link + it->down()->set_up(it); + // I think the next line is unnecessary (my) + // make map for next level + if (it->up() != Vertex_handle() ) V[ it->up()->down() ] = it; + } + } } - } } } @@ -284,73 +292,75 @@ copy_triangulation(const Periodic_2_triangulation_hierarchy_2 &tr) template void -Periodic_2_triangulation_hierarchy_2:: +Periodic_2_triangulation_hierarchy_2:: swap(Periodic_2_triangulation_hierarchy_2 &tr) { PTr_Base::swap(tr); - for(int i=1; i -Periodic_2_triangulation_hierarchy_2:: +Periodic_2_triangulation_hierarchy_2:: ~Periodic_2_triangulation_hierarchy_2() { clear(); - for(int i= 1; i void -Periodic_2_triangulation_hierarchy_2:: +Periodic_2_triangulation_hierarchy_2:: clear() { - for(int i=0;iclear(); } template bool -Periodic_2_triangulation_hierarchy_2:: +Periodic_2_triangulation_hierarchy_2:: is_valid(bool verbose, int level) const { bool result = true; int i; Finite_vertices_iterator it; //verify correctness of triangulation at all levels - for(i=0;inumber_of_vertices() << std::endl; - result = result && hierarchy[i]->is_valid(verbose,level); - } - //verify that lower level has no down pointers - for( it = hierarchy[0]->finite_vertices_begin(); - it != hierarchy[0]->finite_vertices_end(); ++it) + for(i = 0; i < m_maxlevel; ++i) + { + if(verbose) // print number of vertices at each level + std::cout << "number_of_vertices " + << hierarchy[i]->number_of_vertices() << std::endl; + result = result && hierarchy[i]->is_valid(verbose, level); + } + //verify that lower level has no down pointers + for( it = hierarchy[0]->finite_vertices_begin(); + it != hierarchy[0]->finite_vertices_end(); ++it) if (!hierarchy[0]->is_virtual(it)) result = result && (it->down() == Vertex_handle()); //verify that other levels have down pointer and reciprocal link is fine - for(i=1;ifinite_vertices_begin(); - it != hierarchy[i]->finite_vertices_end(); ++it) + for(i = 1; i < m_maxlevel; ++i) + for( it = hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) if (!hierarchy[i]->is_virtual(it)) result = result && (&*(it->down()->up()) == &*(it)); //verify that levels have up pointer and reciprocal link is fine - for(i=0;ifinite_vertices_begin(); - it != hierarchy[i]->finite_vertices_end(); ++it) + for(i = 0; i < m_maxlevel - 1; ++i) + for( it = hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) if (!hierarchy[i]->is_virtual(it)) result = result && ( it->up() == Vertex_handle() || &*it == &*(it->up())->down() ); return result; } - + template typename Periodic_2_triangulation_hierarchy_2::Vertex_handle Periodic_2_triangulation_hierarchy_2:: @@ -361,23 +371,25 @@ insert(const Point &p, Face_handle loc) int i; // locate using hierarchy Face_handle positions[m_maxlevel]; - locate_in_all(p,lt,i,loc,positions); - Vertex_handle vertex=hierarchy[0]->PTr_Base::insert(p,lt,positions[0],i); - Vertex_handle previous=vertex; + locate_in_all(p, lt, i, loc, positions); + Vertex_handle vertex = hierarchy[0]->PTr_Base::insert(p, lt, positions[0], i); + Vertex_handle previous = vertex; Vertex_handle first = vertex; - + int level = 1; - while (level <= vertex_level ){ - vertex=hierarchy[level]->PTr_Base::insert(p,positions[level]); - vertex->set_down(previous);// link with level above - if (hierarchy[level]->number_of_sheets()[0] != 1) { - std::vector vtc = hierarchy[level]->periodic_copies(vertex); - for (unsigned int i=0 ; iset_down(previous); + while (level <= vertex_level ) + { + vertex = hierarchy[level]->PTr_Base::insert(p, positions[level]); + vertex->set_down(previous);// link with level above + if (hierarchy[level]->number_of_sheets()[0] != 1) + { + std::vector vtc = hierarchy[level]->periodic_copies(vertex); + for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(previous); + } + previous->set_up(vertex); + previous = vertex; + level++; } - previous->set_up(vertex); - previous=vertex; - level++; - } return first; } @@ -386,35 +398,38 @@ typename Periodic_2_triangulation_hierarchy_2::Vertex_handle Periodic_2_triangulation_hierarchy_2:: insert(const Point& p, Locate_type lt, - Face_handle loc, + Face_handle loc, int li ) { int vertex_level = random_level(); //insert at level 0 - Vertex_handle vertex=hierarchy[0]->PTr_Base::insert(p,lt,loc,li); - Vertex_handle previous=vertex; + Vertex_handle vertex = hierarchy[0]->PTr_Base::insert(p, lt, loc, li); + Vertex_handle previous = vertex; Vertex_handle first = vertex; - if (vertex_level > 0) { - // locate using hierarchy - Locate_type ltt; - int lii; - Face_handle positions[m_maxlevel]; - locate_in_all(p,ltt,lii,loc,positions); - //insert in higher levels - int level = 1; - while (level <= vertex_level ){ - vertex=hierarchy[level]->PTr_Base::insert(p,positions[level]); - vertex->set_down(previous);// link with level above - if (hierarchy[level]->number_of_sheets()[0] != 1) { - std::vector vtc = hierarchy[level]->periodic_copies(vertex); - for (unsigned int i=0 ; iset_down(previous); - } - previous->set_up(vertex); - previous=vertex; - level++; + if (vertex_level > 0) + { + // locate using hierarchy + Locate_type ltt; + int lii; + Face_handle positions[m_maxlevel]; + locate_in_all(p, ltt, lii, loc, positions); + //insert in higher levels + int level = 1; + while (level <= vertex_level ) + { + vertex = hierarchy[level]->PTr_Base::insert(p, positions[level]); + vertex->set_down(previous);// link with level above + if (hierarchy[level]->number_of_sheets()[0] != 1) + { + std::vector vtc = hierarchy[level]->periodic_copies(vertex); + for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(previous); + } + previous->set_up(vertex); + previous = vertex; + level++; + } } - } return first; } @@ -428,22 +443,24 @@ push_back(const Point &p) } template -void +void Periodic_2_triangulation_hierarchy_2:: remove(Vertex_handle v ) { - Vertex_handle u=v->up(); + Vertex_handle u = v->up(); int l = 0 ; - while(1){ - hierarchy[l++]->remove(v); - if (u == Vertex_handle()) break; - if (l >= m_maxlevel) break; - v=u; u=v->up(); - } + while(1) + { + hierarchy[l++]->remove(v); + if (u == Vertex_handle()) break; + if (l >= m_maxlevel) break; + v = u; + u = v->up(); + } } template -inline void +inline void Periodic_2_triangulation_hierarchy_2:: remove_degree_3(Vertex_handle v ) { @@ -451,7 +468,7 @@ remove_degree_3(Vertex_handle v ) } template -inline void +inline void Periodic_2_triangulation_hierarchy_2:: remove_first(Vertex_handle v ) { @@ -461,29 +478,35 @@ remove_first(Vertex_handle v ) template typename Periodic_2_triangulation_hierarchy_2::Vertex_handle Periodic_2_triangulation_hierarchy_2:: -move_if_no_collision(Vertex_handle v, const Point &p) { +move_if_no_collision(Vertex_handle v, const Point &p) +{ CGAL_triangulation_precondition(v != Vertex_handle()); Vertex_handle old, ret; - for (int l = 0; l < m_maxlevel; ++l) { - Vertex_handle u = v->up(); - CGAL_triangulation_assertion(hierarchy[l]->is_valid()); - Vertex_handle w = hierarchy[l]->move_if_no_collision(v, p); - if (l == 0) { - ret = w; - } else { - old->set_up(w); - w->set_down(old); - if (hierarchy[l]->number_of_sheets()[0] != 1) { - std::vector vtc = hierarchy[l]->periodic_copies(w); - for (unsigned int i=0 ; iset_down(old); - } + for (int l = 0; l < m_maxlevel; ++l) + { + Vertex_handle u = v->up(); + CGAL_triangulation_assertion(hierarchy[l]->is_valid()); + Vertex_handle w = hierarchy[l]->move_if_no_collision(v, p); + if (l == 0) + { + ret = w; + } + else + { + old->set_up(w); + w->set_down(old); + if (hierarchy[l]->number_of_sheets()[0] != 1) + { + std::vector vtc = hierarchy[l]->periodic_copies(w); + for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(old); + } + } + if (u == Vertex_handle()) + break; + old = w; + v = u; } - if (u == Vertex_handle()) - break; - old = w; - v = u; - } return ret; } @@ -491,44 +514,50 @@ move_if_no_collision(Vertex_handle v, const Point &p) { template typename Periodic_2_triangulation_hierarchy_2::Vertex_handle Periodic_2_triangulation_hierarchy_2:: -move_point(Vertex_handle v, const Point &p) { +move_point(Vertex_handle v, const Point &p) +{ CGAL_triangulation_precondition(v != Vertex_handle()); Vertex_handle old, ret; - for (int l = 0; l < m_maxlevel; ++l) { - Vertex_handle u = v->up(); - CGAL_triangulation_assertion(hierarchy[l]->is_valid()); - Vertex_handle w = hierarchy[l]->move_point(v, p); - if (l == 0) { - ret = w; - } else { - old->set_up(w); - w->set_down(old); - if (hierarchy[l]->number_of_sheets()[0] != 1) { - std::vector vtc = hierarchy[l]->periodic_copies(w); - for (unsigned int i=0 ; iset_down(old); - } + for (int l = 0; l < m_maxlevel; ++l) + { + Vertex_handle u = v->up(); + CGAL_triangulation_assertion(hierarchy[l]->is_valid()); + Vertex_handle w = hierarchy[l]->move_point(v, p); + if (l == 0) + { + ret = w; + } + else + { + old->set_up(w); + w->set_down(old); + if (hierarchy[l]->number_of_sheets()[0] != 1) + { + std::vector vtc = hierarchy[l]->periodic_copies(w); + for (unsigned int i = 0 ; i < vtc.size() ; i++) vtc[i]->set_down(old); + } + } + if (u == Vertex_handle()) + break; + old = w; + v = u; } - if (u == Vertex_handle()) - break; - old = w; - v = u; - } return ret; } template -typename Periodic_2_triangulation_hierarchy_2::Face_handle +typename Periodic_2_triangulation_hierarchy_2::Face_handle Periodic_2_triangulation_hierarchy_2:: locate(const Point& p, Locate_type& lt, int& li, Face_handle loc) const { Face_handle positions[m_maxlevel]; - locate_in_all(p,lt,li,loc,positions); + locate_in_all(p, lt, li, loc, positions); return positions[0]; } template -typename Periodic_2_triangulation_hierarchy_2::Face_handle +typename Periodic_2_triangulation_hierarchy_2::Face_handle Periodic_2_triangulation_hierarchy_2:: locate(const Point& p, Face_handle loc ) const { @@ -542,61 +571,71 @@ template void Periodic_2_triangulation_hierarchy_2:: locate_in_all(const Point& p, - Locate_type& lt, - int& li, - Face_handle loc, - Face_handle pos[m_maxlevel]) const + Locate_type& lt, + int& li, + Face_handle loc, + Face_handle pos[m_maxlevel]) const { Face_handle position; Vertex_handle nearest; int level = m_maxlevel; - typename Geom_traits::Compare_distance_2 - closer = this->geom_traits().compare_distance_2_object(); + typename Geom_traits::Compare_distance_2 + closer = this->geom_traits().compare_distance_2_object(); // find the highest level with enough vertices that is at the same time 2D - while ( (hierarchy[--level]->number_of_vertices() - < static_cast (m_minsize )) - || (hierarchy[level]->dimension()<2) ){ - if ( ! level) break; // do not go below 0 - } - if((level>0) && (hierarchy[level]->dimension()<2)){ - level--; - } - - for (int i=level+1; i 0) { - pos[level]=position=hierarchy[level]->locate(p,position); - // locate at that level from "position" - // result is stored in "position" for the next level - // find the nearest between vertices 0 and 1 - if (hierarchy[level]->is_infinite(position->vertex(0))){ - - nearest = position->vertex(1); + while ( (hierarchy[--level]->number_of_vertices() + < static_cast (m_minsize )) + || (hierarchy[level]->dimension() < 2) ) + { + if ( ! level) break; // do not go below 0 } - else if (hierarchy[level]->is_infinite(position->vertex(1))){ - nearest = position->vertex(0); -} else if ( closer(p, - position->vertex(0)->point(), - position->vertex(1)->point()) == SMALLER){ - nearest = position->vertex(0); -} - else{ - nearest = position->vertex(1); -} - // compare to vertex 2, but only if the triangulation is 2D, because otherwise vertex(2) is NULL - if ( (hierarchy[level]->dimension()==2) && (! hierarchy[level]->is_infinite(position->vertex(2)))){ - if ( closer( p, - position->vertex(2)->point(), - nearest->point()) == SMALLER ){ - nearest = position->vertex(2); - } + if((level > 0) && (hierarchy[level]->dimension() < 2)) + { + level--; } - // go at the same vertex on level below - nearest = nearest->down(); - position = nearest->face(); // incident face - --level; - } - pos[0]=hierarchy[0]->locate(p,lt,li,loc == Face_handle() ? position : loc); // at level 0 + + for (int i = level + 1; i < m_maxlevel; ++i) pos[i] = 0; + while(level > 0) + { + pos[level] = position = hierarchy[level]->locate(p, position); + // locate at that level from "position" + // result is stored in "position" for the next level + // find the nearest between vertices 0 and 1 + if (hierarchy[level]->is_infinite(position->vertex(0))) + { + + nearest = position->vertex(1); + } + else if (hierarchy[level]->is_infinite(position->vertex(1))) + { + nearest = position->vertex(0); + } + else if ( closer(p, + position->vertex(0)->point(), + position->vertex(1)->point()) == SMALLER) + { + nearest = position->vertex(0); + } + else + { + nearest = position->vertex(1); + } + // compare to vertex 2, but only if the triangulation is 2D, because otherwise vertex(2) is NULL + if ( (hierarchy[level]->dimension() == 2) && (! hierarchy[level]->is_infinite(position->vertex(2)))) + { + if ( closer( p, + position->vertex(2)->point(), + nearest->point()) == SMALLER ) + { + nearest = position->vertex(2); + } + } + // go at the same vertex on level below + nearest = nearest->down(); + position = nearest->face(); // incident face + --level; + } + pos[0] = hierarchy[0]->locate(p, lt, li, loc == Face_handle() ? position : loc); // at level 0 } template @@ -605,13 +644,13 @@ Periodic_2_triangulation_hierarchy_2:: 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 > - die(random, proba); - return (std::min)(die()-1, level_mult_cover); + die(random, proba); + return (std::min)(die() - 1, level_mult_cover); } } //namespace CGAL diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_vertex_base_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_vertex_base_2.h index 2debfa096dc..54ee5fa3a3a 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_vertex_base_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_hierarchy_vertex_base_2.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Olivier Devillers // Mariette Yvinec @@ -25,11 +25,12 @@ #include -namespace CGAL { +namespace CGAL +{ template < class Gt, class Vb = CGAL::Periodic_2_triangulation_vertex_base_2 > class Periodic_2_triangulation_hierarchy_vertex_base_2 - : public Vb + : public Vb { typedef typename Vb::Triangulation_data_structure Tds; typedef Gt Geom_traits; @@ -39,7 +40,8 @@ class Periodic_2_triangulation_hierarchy_vertex_base_2 typedef typename Tds::Vertex_handle Vertex_handle; template < typename Tds2 > - struct Rebind_Tds { + struct Rebind_Tds + { typedef typename Vb::template Rebind_Tds::Other Vb2; typedef Triangulation_vertex_base_2 Other; }; @@ -47,21 +49,33 @@ class Periodic_2_triangulation_hierarchy_vertex_base_2 Periodic_2_triangulation_hierarchy_vertex_base_2() : Base(), _up(0), _down(0) - {} + {} Periodic_2_triangulation_hierarchy_vertex_base_2(const Point & p, Face_handle f) - : Base(p,f), _up(0), _down(0) - {} + : Base(p, f), _up(0), _down(0) + {} Periodic_2_triangulation_hierarchy_vertex_base_2(const Point & p) : Base(p), _up(0), _down(0) - {} + {} - Vertex_handle up() {return _up;} - Vertex_handle down() {return _down;} - void set_up(Vertex_handle u) {_up=u;} - void set_down(Vertex_handle d) { _down=d;} + Vertex_handle up() + { + return _up; + } + Vertex_handle down() + { + return _down; + } + void set_up(Vertex_handle u) + { + _up = u; + } + void set_down(Vertex_handle d) + { + _down = d; + } - private: +private: Vertex_handle _up; // same vertex one level above Vertex_handle _down; // same vertex one level below }; diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_iterators_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_iterators_2.h index b6b79ecd951..9cd422b2608 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_iterators_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_iterators_2.h @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -23,10 +23,12 @@ #include #include -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 @@ -41,48 +43,56 @@ class Periodic_2_triangulation_triangle_iterator_2 { // When computing in 1-sheeted covering, there will be no difference in the // result of STORED and UNIQUE as well as STORED_COVER_DOMAIN and // UNIQUE_COVER_DOMAIN. - + public: - + typedef typename T::Periodic_triangle value_type; typedef const typename T::Periodic_triangle * pointer; typedef const typename T::Periodic_triangle & reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef std::bidirectional_iterator_tag iterator_category; - + typedef typename T::Periodic_triangle Periodic_triangle; typedef Periodic_2_triangulation_triangle_iterator_2 Periodic_triangle_iterator; typedef typename T::Face Face; typedef typename T::Face_iterator Face_iterator; - + typedef typename T::Offset Offset; typedef typename T::Iterator_type Iterator_type; - + Periodic_2_triangulation_triangle_iterator_2(Iterator_type it = T::STORED) - : _t(NULL), _it(it), _off(0) {} - + : _t(NULL), _it(it), _off(0) {} + 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) { - while (pos != _t->faces_end() && !is_canonical() ) - ++pos; - } + Iterator_type it = T::STORED) + : _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; + } } - + // used to initialize the past-the-end iterator Periodic_2_triangulation_triangle_iterator_2(const T* t, int, - Iterator_type it = T::STORED) - : _t(t), pos(_t->faces_end()), _it(it), _off(0) {} - - Periodic_triangle_iterator& operator++() { - switch (_it) { + Iterator_type it = T::STORED) + : _t(t), pos(_t->faces_end()), _it(it), _off(0) {} + + 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: @@ -90,159 +100,189 @@ public: break; default: CGAL_triangulation_assertion(false); - }; + }; 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: decrement_domain(); - }; + }; return *this; } - + Periodic_triangle_iterator operator++(int) { Periodic_triangle_iterator tmp(*this); ++(*this); return tmp; } - + Periodic_triangle_iterator operator--(int) { Periodic_triangle_iterator tmp(*this); --(*this); return tmp; } - + bool operator==(const Periodic_triangle_iterator& ti) const { // We are only allowed to compare iterators of the same type. CGAL_triangulation_assertion(_it == ti._it); return _t == ti._t && pos == ti.pos && _off == ti._off; } - + bool operator!=(const Periodic_triangle_iterator& ti) const { return !(*this == ti); } - + reference operator*() const { periodic_triangle = construct_periodic_triangle(); return periodic_triangle; } - + pointer operator->() const { periodic_triangle = construct_periodic_triangle(); return &periodic_triangle; } - + Face_iterator get_face() const { return pos; } - + private: const T* _t; Face_iterator pos; // current face. Iterator_type _it; int _off; // current offset mutable Periodic_triangle periodic_triangle; // current triangle. - + 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 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. - if (off0.x() > 1) return false; - if (off0.y() > 1) return false; - if (off1.x() > 1) return false; - if (off1.y() > 1) return false; - if (off2.x() > 1) return false; - if (off2.y() > 1) return false; - } - + + 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. + if (off0.x() > 1) return false; + if (off0.y() > 1) return false; + if (off1.x() > 1) return false; + if (off1.y() > 1) return false; + if (off2.x() > 1) return false; + if (off2.y() > 1) return false; + } + // If there is one direction of space for which all offsets are // non-zero then the edge is not canonical because we can // take the copy closer towards the origin in that direction. int offx = off0.x() & off1.x() & off2.x(); int offy = off0.y() & off1.y() & off2.y(); - + return (offx == 0 && offy == 0); } - + // 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) { - _off = 0; - do { ++pos; } while (_it == T::UNIQUE_COVER_DOMAIN - && pos != _t->faces_end() && !is_canonical()); - } else { - do { - ++_off; - } while ((((~_off)|off)&3)!=3); // Increment until a valid - // offset has been found - } + if (_off == off) + { + _off = 0; + do + { + ++pos; + } + while (_it == T::UNIQUE_COVER_DOMAIN + && pos != _t->faces_end() && !is_canonical()); + } + else + { + do + { + ++_off; + } + 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) { - if (pos == _t->faces_begin()) return; - do { --pos; } while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical()); - _off = get_drawing_offsets(); - } else { - int off = get_drawing_offsets(); - do { - --_off; - } while ((((~_off)|off)&3)!=3); // Decrement until a valid - // offset has been found - } + void decrement_domain() + { + if (_off == 0) + { + if (pos == _t->faces_begin()) return; + do + { + --pos; + } + while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical()); + _off = get_drawing_offsets(); + } + else + { + int off = get_drawing_offsets(); + do + { + --_off; + } + 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, - 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_off0.y() == 1 + Offset diff_off((face_off0.x() == 1 + && face_off1.x() == 1 + && 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,57 +291,62 @@ 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 { - CGAL_triangulation_assertion(_it == T::STORED_COVER_DOMAIN); - off0 = _t->int_to_off(pos->offset(0)); - off1 = _t->int_to_off(pos->offset(1)); - off2 = _t->int_to_off(pos->offset(2)); - } - + 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)); + off2 = _t->int_to_off(pos->offset(2)); + } + CGAL_triangulation_assertion(off0.x() == 0 || off0.x() == 1); CGAL_triangulation_assertion(off0.y() == 0 || off0.y() == 1); CGAL_triangulation_assertion(off1.x() == 0 || off1.x() == 1); CGAL_triangulation_assertion(off1.y() == 0 || off1.y() == 1); CGAL_triangulation_assertion(off2.x() == 0 || off2.x() == 1); CGAL_triangulation_assertion(off2.y() == 0 || off2.y() == 1); - - int offx = ( ((off0.x() == 0 && off1.x() == 0 + + int offx = ( ((off0.x() == 0 && off1.x() == 0 && off2.x() == 0) - || (off0.x() == 1 && off1.x() == 1 + || (off0.x() == 1 && off1.x() == 1 && off2.x() == 1)) ? 0 : 1); - int offy = ( ((off0.y() == 0 && off1.y() == 0 + int offy = ( ((off0.y() == 0 && off1.y() == 0 && off2.y() == 0) - || (off0.y() == 1 && off1.y() == 1 + || (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); - } - 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)); + 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) + { + 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)); } }; 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 @@ -316,49 +361,57 @@ class Periodic_2_triangulation_segment_iterator_2 { // When computing in 1-sheeted covering, there will be no difference in the // result of STORED and UNIQUE as well as STORED_COVER_DOMAIN and // UNIQUE_COVER_DOMAIN. - + public: - + typedef typename T::Periodic_segment value_type; typedef const typename T::Periodic_segment * pointer; typedef const typename T::Periodic_segment & reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef std::bidirectional_iterator_tag iterator_category; - + typedef typename T::Periodic_segment Periodic_segment; typedef Periodic_2_triangulation_segment_iterator_2 Periodic_segment_iterator; typedef typename T::Edge Edge; typedef typename T::Edge_iterator Edge_iterator; - + typedef typename T::Offset Offset; typedef typename T::Iterator_type Iterator_type; - + Periodic_2_triangulation_segment_iterator_2(Iterator_type it = T::STORED) - : _t(NULL), _it(it), _off(0) {} - + : _t(NULL), _it(it), _off(0) {} + 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) { - while (pos != _t->edges_end() && !is_canonical() ) - ++pos; - } + Iterator_type it = T::STORED) + : _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; + } } - + // used to initialize the past-the-end iterator Periodic_2_triangulation_segment_iterator_2(const T* t, int, - Iterator_type it = T::STORED) - : _t(t), pos(_t->edges_end()), _it(it), _off(0) {} - - Periodic_segment_iterator& operator++() { - switch (_it) { + Iterator_type it = T::STORED) + : _t(t), pos(_t->edges_end()), _it(it), _off(0) {} + + 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: @@ -366,63 +419,69 @@ public: break; default: CGAL_triangulation_assertion(false); - }; + }; 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: decrement_domain(); - }; + }; return *this; } - + Periodic_segment_iterator operator++(int) { Periodic_segment_iterator tmp(*this); ++(*this); return tmp; } - + Periodic_segment_iterator operator--(int) { Periodic_segment_iterator tmp(*this); --(*this); return tmp; } - + bool operator==(const Periodic_segment_iterator& ti) const { // We are only allowed to compare iterators of the same type. CGAL_triangulation_assertion(_it == ti._it); return _t == ti._t && pos == ti.pos && _off == ti._off; } - + bool operator!=(const Periodic_segment_iterator& ti) const { return !(*this == ti); } - + reference operator*() const { periodic_segment = construct_periodic_segment(); return periodic_segment; } - + pointer operator->() const { periodic_segment = construct_periodic_segment(); return &periodic_segment; } - + Edge_iterator get_edge() const { return pos; @@ -433,84 +492,108 @@ private: Iterator_type _it; int _off; // current offset mutable Periodic_segment periodic_segment; // current segment. - + 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 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. - if (off0.x() > 1) return false; - if (off0.y() > 1) return false; - if (off1.x() > 1) return false; - if (off1.y() > 1) return false; - } - + + 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. + if (off0.x() > 1) return false; + if (off0.y() > 1) return false; + if (off1.x() > 1) return false; + if (off1.y() > 1) return false; + } + // If there is one direction of space for which all offsets are // non-zero then the edge is not canonical because we can // take the copy closer towards the origin in that direction. int offx = off0.x() & off1.x(); int offy = off0.y() & off1.y(); - + return (offx == 0 && offy == 0); } - + // 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) { - _off = 0; - do { ++pos; } while (_it == T::UNIQUE_COVER_DOMAIN - && pos != _t->edges_end() && !is_canonical()); - } else { - do { - ++_off; - } while ((((~_off)|off)&3)!=3); // Increment until a valid - // offset has been found - } + if (_off == off) + { + _off = 0; + do + { + ++pos; + } + while (_it == T::UNIQUE_COVER_DOMAIN + && pos != _t->edges_end() && !is_canonical()); + } + else + { + do + { + ++_off; + } + 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) { - if (pos == _t->edges_begin()) return; - do { --pos; } while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical()); - _off = get_drawing_offsets(); - } else { - int off = get_drawing_offsets(); - do { - --_off; - } while ((((~_off)|off)&3)!=3); // Decrement until a valid - // offset has been found - } + void decrement_domain() + { + if (_off == 0) + { + if (pos == _t->edges_begin()) return; + do + { + --pos; + } + while (_it == T::UNIQUE_COVER_DOMAIN && !is_canonical()); + _off = get_drawing_offsets(); + } + else + { + int off = get_drawing_offsets(); + do + { + --_off; + } + 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,43 +602,48 @@ 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 { - 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))); - } + 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))); + } Offset diff_off = off0 - off1; - + 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); - } - if (_it == T::UNIQUE_COVER_DOMAIN) { - off0 += transl_off; - 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) + { + 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 @@ -570,7 +658,7 @@ class Periodic_2_triangulation_point_iterator_2 { // When computing in 1-sheeted covering, there will be no difference in the // result of STORED and UNIQUE as well as STORED_COVER_DOMAIN and // UNIQUE_COVER_DOMAIN. - + public: typedef typename T::Periodic_point value_type; typedef const typename T::Periodic_point * pointer; @@ -578,103 +666,117 @@ public: typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef std::bidirectional_iterator_tag iterator_category; - + typedef typename T::Periodic_point Periodic_point; typedef Periodic_2_triangulation_point_iterator_2 Periodic_point_iterator; - + typedef typename T::Vertex Vertex; typedef typename T::Vertex_iterator Vertex_iterator; - + typedef typename T::Offset Offset; typedef typename T::Iterator_type Iterator_type; - + Periodic_2_triangulation_point_iterator_2(Iterator_type it = T::STORED) - : _t(NULL), _it(it) {} - + : _t(NULL), _it(it) {} + 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) { - while (pos != _t->vertices_end() && !is_canonical() ) - ++pos; - } + Iterator_type it = T::STORED) + : _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; + } } - + // used to initialize the past-the-end iterator Periodic_2_triangulation_point_iterator_2(const T* t, int, - Iterator_type it = T::STORED) - : _t(t), pos(_t->vertices_end()), _it(it) {} - - Periodic_point_iterator& operator++() { - switch (_it) { + Iterator_type it = T::STORED) + : _t(t), pos(_t->vertices_end()), _it(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); - }; + }; 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); - }; + }; return *this; } - + Periodic_point_iterator operator++(int) { Periodic_point_iterator tmp(*this); ++(*this); return tmp; } - + Periodic_point_iterator operator--(int) { Periodic_point_iterator tmp(*this); --(*this); return tmp; } - + bool operator==(const Periodic_point_iterator& pi) const { // We are only allowed to compare iterators of the same type. CGAL_triangulation_assertion(_it == pi._it); return _t == pi._t && pos == pi.pos; } - + bool operator!=(const Periodic_point_iterator& pi) const { return !(*this == pi); } - + reference operator*() const { periodic_point = construct_periodic_point(); return periodic_point; } - + pointer operator->() const { periodic_point = construct_periodic_point(); return &periodic_point; } - + Vertex_iterator get_vertex() const { return pos; @@ -685,32 +787,36 @@ private: Iterator_type _it; int _off; // current offset mutable Periodic_point periodic_point; // current point. - + 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 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,24 +829,46 @@ public: // between a normal Vertex_iterator and this iterator template class Periodic_2_triangulation_unique_vertex_iterator_2 -: public Filter_iterator > { - + : public Filter_iterator > +{ + typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Vertex_iterator Vertex_iterator; - + typedef Filter_iterator > Base; typedef Periodic_2_triangulation_unique_vertex_iterator_2 Self; 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; } - - operator Vertex_handle() const { return Base::base(); } + + 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(); + } }; } //namespace CGAL diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_statically_filtered_traits_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_statically_filtered_traits_2.h index ba55c2c65cc..59863e9d259 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_statically_filtered_traits_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_statically_filtered_traits_2.h @@ -13,10 +13,10 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof - + #ifndef CGAL_PERIODIC_2_TRIANGULATION_STATICALLY_FILTERED_TRAITS_2_H #define CGAL_PERIODIC_2_TRIANGULATION_STATICALLY_FILTERED_TRAITS_2_H @@ -40,7 +40,8 @@ // TODO : // - add more predicates : -namespace CGAL { +namespace CGAL +{ // The K_base argument is supposed to provide exact primitives. template < typename Traits > @@ -52,14 +53,16 @@ public: Periodic_2_triangulation_statically_filtered_traits_2() {} typedef internal::Static_filters_predicates::Periodic_2_orientation_2 - Orientation_2; + Orientation_2; typedef internal::Static_filters_predicates::Periodic_2_side_of_oriented_circle_2 - Side_of_oriented_circle_2; + Side_of_oriented_circle_2; - Orientation_2 orientation_2_object() const { - return Orientation_2(&this->_domain,&this->_domain_e,&this->_domain_f); + Orientation_2 orientation_2_object() const + { + return Orientation_2(&this->_domain, &this->_domain_e, &this->_domain_f); } - Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const { + Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const + { return Side_of_oriented_circle_2(&this->_domain, &this->_domain_e, &this->_domain_f); diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_traits_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_traits_2.h index cbba59f5c86..293311b3338 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_traits_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_traits_2.h @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -34,13 +34,15 @@ #include -namespace CGAL { +namespace CGAL +{ template < class K, class Predicate_ > -class Traits_with_offsets_2_adaptor { +class Traits_with_offsets_2_adaptor +{ typedef K Kernel; typedef Predicate_ Predicate; - + typedef typename Kernel::Point_2 Point; typedef typename Kernel::Offset_2 Offset; @@ -48,45 +50,52 @@ class Traits_with_offsets_2_adaptor { typedef typename Kernel::Construct_point_2 Construct_point_2; public: typedef typename Kernel::Iso_rectangle_2 Iso_rectangle_2; - + public: typedef typename Predicate::result_type result_type; - + Traits_with_offsets_2_adaptor(const Iso_rectangle_2 * dom) : _domain(dom) { } - + result_type operator()(const Point& p0, const Point& p1, - const Offset& o0, const Offset& o1) const { - return Predicate()(pp(p0,o0),pp(p1,o1)); + const Offset& o0, const Offset& o1) const + { + return Predicate()(pp(p0, o0), pp(p1, o1)); } result_type operator()(const Point& p0, const Point& p1, const Point& p2, - const Offset& o0, const Offset& o1, const Offset& o2) const { - return Predicate()(pp(p0,o0),pp(p1,o1),pp(p2,o2)); + const Offset& o0, const Offset& o1, const Offset& o2) const + { + return Predicate()(pp(p0, o0), pp(p1, o1), pp(p2, o2)); } result_type operator()(const Point& p0, const Point& p1, - const Point& p2, const Point& p3, - const Offset& o0, const Offset& o1, - const Offset& o2, const Offset& o3) const { - return Predicate()(pp(p0,o0),pp(p1,o1),pp(p2,o2),pp(p3,o3)); + const Point& p2, const Point& p3, + const Offset& o0, const Offset& o1, + const Offset& o2, const Offset& o3) const + { + return Predicate()(pp(p0, o0), pp(p1, o1), pp(p2, o2), pp(p3, o3)); } - result_type operator()(const Point& p0, const Point& p1) const { + result_type operator()(const Point& p0, const Point& p1) const + { return Predicate()(p0, p1); } result_type operator()(const Point& p0, const Point& p1, - const Point& p2) const { + const Point& p2) const + { return Predicate()(p0, p1, p2); } result_type operator()(const Point& p0, const Point& p1, - const Point& p2, const Point& p3) const { + const Point& p2, const Point& p3) const + { return Predicate()(p0, p1, p2, p3); } - + private: - Point pp(const Point &p, const Offset &o) const { - return Point(p.x()+(_domain->xmax()-_domain->xmin())*o.x(), - p.y()+(_domain->ymax()-_domain->ymin())*o.y()); + Point pp(const Point &p, const Offset &o) const + { + return Point(p.x() + (_domain->xmax() - _domain->xmin()) * o.x(), + p.y() + (_domain->ymax() - _domain->ymin()) * o.y()); } - public: +public: const Iso_rectangle_2* _domain; }; @@ -104,9 +113,10 @@ public: Periodic_2_construct_point_2(const Iso_rectangle_2 & dom) : _dom(dom) { } - Point operator() ( const Point& p, const Offset& o ) const { - return Point(p.x()+(_dom.xmax()-_dom.xmin())*o.x(), - p.y()+(_dom.ymax()-_dom.ymin())*o.y()); + Point operator() ( const Point& p, const Offset& o ) const + { + return Point(p.x() + (_dom.xmax() - _dom.xmin()) * o.x(), + p.y() + (_dom.ymax() - _dom.ymin()) * o.y()); } private: @@ -115,12 +125,13 @@ private: template < class Kernel, class Off = typename CGAL::Periodic_2_offset_2 > -class Periodic_2_triangulation_traits_base_2 : public Kernel { +class Periodic_2_triangulation_traits_base_2 : public Kernel +{ public: // Undocumented typedef Kernel K; typedef Kernel Kernel_base; typedef Off Offset_2; - typedef Periodic_2_triangulation_traits_base_2 Self; + typedef Periodic_2_triangulation_traits_base_2 Self; typedef typename K::FT FT; typedef typename K::RT RT; @@ -154,20 +165,25 @@ public: typedef Traits_with_offsets_2_adaptor Construct_triangle_2; typedef Traits_with_offsets_2_adaptor Construct_direction_2; typedef Traits_with_offsets_2_adaptor Construct_ray_2; - - Periodic_2_triangulation_traits_base_2() : _domain(Iso_rectangle_2(0,0,1,1)) { + + Periodic_2_triangulation_traits_base_2() : _domain(Iso_rectangle_2(0, 0, 1, 1)) + { } Periodic_2_triangulation_traits_base_2(const Periodic_2_triangulation_traits_base_2 &) {} Periodic_2_triangulation_traits_base_2 &operator= (const Periodic_2_triangulation_traits_base_2 &) - {return *this;} - + { + return *this; + } + // Access - void set_domain(const Iso_rectangle_2& domain) { + void set_domain(const Iso_rectangle_2& domain) + { _domain = domain; } - - Iso_rectangle_2 get_domain() const { + + Iso_rectangle_2 get_domain() const + { return _domain; } @@ -175,40 +191,61 @@ public: Compare_x_2 compare_x_2_object() const - { return Compare_x_2(&_domain);} - + { + return Compare_x_2(&_domain); + } + Compare_y_2 compare_y_2_object() const - { return Compare_y_2(&_domain);} - + { + return Compare_y_2(&_domain); + } + Compare_xy_2 compare_xy_2_object() const - { return Compare_xy_2(&_domain);} - + { + return Compare_xy_2(&_domain); + } + Orientation_2 - orientation_2_object() const { return Orientation_2(&_domain); } - + orientation_2_object() const + { + return Orientation_2(&_domain); + } + Side_of_oriented_circle_2 side_of_oriented_circle_2_object() const - {return Side_of_oriented_circle_2(&_domain);} - + { + return Side_of_oriented_circle_2(&_domain); + } + Construct_circumcenter_2 construct_circumcenter_2_object() const - { return Construct_circumcenter_2(&_domain);} - + { + return Construct_circumcenter_2(&_domain); + } + Compare_distance_2 compare_distance_2_object() const - {return Compare_distance_2(&_domain);} - + { + return Compare_distance_2(&_domain); + } + Construct_point_2 construct_point_2_object() const - {return Construct_point_2(_domain);} + { + return Construct_point_2(_domain); + } Construct_segment_2 construct_segment_2_object() const - {return Construct_segment_2(&_domain);} + { + return Construct_segment_2(&_domain); + } Construct_triangle_2 construct_triangle_2_object() const - {return Construct_triangle_2(&_domain);} - + { + return Construct_triangle_2(&_domain); + } + protected: Iso_rectangle_2 _domain; }; @@ -218,7 +255,7 @@ protected: template < typename K, typename Off = CGAL::Periodic_2_offset_2, bool Has_filtered_predicates = K::Has_filtered_predicates > class Periodic_2_triangulation_traits_2; -} //namespace CGAL +} //namespace CGAL // Partial specialization for Filtered_kernel. @@ -227,7 +264,8 @@ class Periodic_2_triangulation_traits_2; #include #include -namespace CGAL { +namespace CGAL +{ // This declaration is needed to break the cyclic dependency. template < typename K, typename Off > diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_vertex_base_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_vertex_base_2.h index 9ae377c70d7..7eaec7dc5c2 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_vertex_base_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_vertex_base_2.h @@ -13,7 +13,7 @@ // // $URL: svn+ssh://nicokruithof@scm.gforge.inria.fr/svnroot/cgal/trunk/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_vertex_base_2.h $ // $Id: Periodic_2_triangulation_vertex_base_2.h 56667 2010-06-09 07:37:13Z sloriot $ -// +// // // Author(s) : Monique Teillaud // Manuel Caroli @@ -26,7 +26,8 @@ #include #include -namespace CGAL { +namespace CGAL +{ template < class Gt, class Vb = CGAL::Triangulation_vertex_base_2 > @@ -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::Other Vb2; - typedef Periodic_2_triangulation_vertex_base_2 Other; + typedef Periodic_2_triangulation_vertex_base_2 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 &) - // no combinatorial information. +// no combinatorial information. { return is; } @@ -101,8 +108,8 @@ template < class Tds > inline std::ostream& operator<<(std::ostream &os, - const Periodic_2_triangulation_vertex_base_2 &) - // no combinatorial information. + const Periodic_2_triangulation_vertex_base_2 &) +// 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 - struct Rebind_Tds { + struct Rebind_Tds + { typedef Periodic_2_triangulation_vertex_base_2 Other; }; }; diff --git a/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_orientation_2.h b/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_orientation_2.h index 61fb29d5154..1908de21a39 100644 --- a/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_orientation_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_orientation_2.h @@ -14,7 +14,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Nico Kruithof @@ -79,7 +79,12 @@ } */ -namespace CGAL { namespace internal { namespace Static_filters_predicates { +namespace CGAL +{ +namespace internal +{ +namespace Static_filters_predicates +{ template < typename K_base > class Periodic_2_orientation_2 : public K_base::Orientation_2 @@ -92,174 +97,183 @@ class Periodic_2_orientation_2 : public K_base::Orientation_2 typedef typename K_base::Orientation_2 Base; - public: +public: const Iso_rectangle_2 * const _dom; - - public: + +public: typedef typename Base::result_type result_type; template - Periodic_2_orientation_2(const Iso_rectangle_2 * const dom, - const EX * dom_e, const AP * dom_f) : Base(dom_e,dom_f), _dom(dom) { + Periodic_2_orientation_2(const Iso_rectangle_2 * const dom, + const EX * dom_e, const AP * dom_f) : Base(dom_e, dom_f), _dom(dom) + { } #ifndef CGAL_CFG_MATCHING_BUG_6 using Base::operator(); -#else +#else result_type - operator()(const Vector_2& u, const Vector_2& v) const - { - return Base::operator()(u,v); + operator()(const Vector_2& u, const Vector_2& v) const + { + return Base::operator()(u, v); } - + result_type - operator()(const Circle_2& c) const + operator()(const Circle_2& c) const { return Base::operator()(c); } - result_type operator()(const Point_2 &p, - const Point_2 &q, + result_type operator()(const Point_2 &p, + const Point_2 &q, const Point_2 &r, const Offset_2 &o_p, - const Offset_2 &o_q, - const Offset_2 &o_r) const { + const Offset_2 &o_q, + const Offset_2 &o_r) const + { return Base::operator()(p, q, r, o_p, o_q, o_r); } #endif /// Normal static orientation test, copied from Orientation_2 result_type operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r) const - { - CGAL_PROFILER("Periodic_2_orientation_2 calls"); + { + CGAL_PROFILER("Periodic_2_orientation_2 calls"); - double px, py, qx, qy, rx, ry; + double px, py, qx, qy, rx, ry; - if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && - fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && - fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry)) + if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && + fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && + fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry)) { - CGAL_PROFILER("Periodic_2_orientation_2 semi-static attempts"); + CGAL_PROFILER("Periodic_2_orientation_2 semi-static attempts"); - double pqx = qx - px; - double pqy = qy - py; - double prx = rx - px; - double pry = ry - py; + double pqx = qx - px; + double pqy = qy - py; + double prx = rx - px; + double pry = ry - py; - // Then semi-static filter. - double maxx = CGAL::abs(pqx); - double maxy = CGAL::abs(pqy); + // Then semi-static filter. + double maxx = CGAL::abs(pqx); + double maxy = CGAL::abs(pqy); - double aprx = CGAL::abs(prx); - double apry = CGAL::abs(pry); + double aprx = CGAL::abs(prx); + double apry = CGAL::abs(pry); - if (maxx < aprx) maxx = aprx; - if (maxy < apry) maxy = apry; - double eps = 5.1107127829973299e-15 * maxx * maxy; - double det = CGAL::determinant(pqx, pqy, - prx, pry); + if (maxx < aprx) maxx = aprx; + if (maxy < apry) maxy = apry; + double eps = 5.1107127829973299e-15 * maxx * maxy; + double det = CGAL::determinant(pqx, pqy, + prx, pry); - // Sort maxx < maxy - if (maxx > maxy) - std::swap(maxx, maxy); + // Sort maxx < maxy + if (maxx > maxy) + std::swap(maxx, maxy); - // Protect against underflow in the computation of eps. - if (maxx < 1e-97) /* cbrt(min_double/eps) */ { + // Protect against underflow in the computation of eps. + if (maxx < 1e-97) /* cbrt(min_double/eps) */ + { if (maxx == 0) return ZERO; } - // Protect against overflow in the computation of det. - else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */ { + // Protect against overflow in the computation of det. + else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */ + { if (det > eps) return POSITIVE; if (det < -eps) return NEGATIVE; } - CGAL_PROFILER("Periodic_2_orientation_2 semi-static failures"); + CGAL_PROFILER("Periodic_2_orientation_2 semi-static failures"); } - return Base::operator()(p, q, r); + return Base::operator()(p, q, r); } - + /// Static orientation test with offsets result_type operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r, - const Offset_2 &o_p, const Offset_2 &o_q, const Offset_2 &o_r) const { + const Offset_2 &o_p, const Offset_2 &o_q, const Offset_2 &o_r) const + { - CGAL_PROFILER("Periodic_2_orientation_2 with offset calls"); + CGAL_PROFILER("Periodic_2_orientation_2 with offset calls"); - double px, py, qx, qy, rx, ry; - double domxmax, domxmin, domymax, domymin; - int opx = o_p.x(); - int opy = o_p.y(); + double px, py, qx, qy, rx, ry; + double domxmax, domxmin, domymax, domymin; + int opx = o_p.x(); + int opy = o_p.y(); - if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && - fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && - fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) && - fit_in_double(_dom->xmax(), domxmax) && - fit_in_double(_dom->xmin(), domxmin) && - fit_in_double(_dom->ymax(), domymax) && - fit_in_double(_dom->ymin(), domymin)) + if (fit_in_double(p.x(), px) && fit_in_double(p.y(), py) && + fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && + fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) && + fit_in_double(_dom->xmax(), domxmax) && + fit_in_double(_dom->xmin(), domxmin) && + fit_in_double(_dom->ymax(), domymax) && + fit_in_double(_dom->ymin(), domymin)) { - CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static attempts"); + CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static attempts"); - double domx = domxmax - domxmin; - double domy = domymax - domymin; + double domx = domxmax - domxmin; + double domy = domymax - domymin; - double pqx = qx - px + domx * ( o_q.x() - opx ); - double pqy = qy - py + domy * ( o_q.y() - opy ); - double prx = rx - px + domx * ( o_r.x() - opx ); - double pry = ry - py + domy * ( o_r.y() - opy ); + double pqx = qx - px + domx * ( o_q.x() - opx ); + double pqy = qy - py + domy * ( o_q.y() - opy ); + double prx = rx - px + domx * ( o_r.x() - opx ); + double pry = ry - py + domy * ( o_r.y() - opy ); - // Then semi-static filter. - double maxx = CGAL::abs(pqx); - double maxy = CGAL::abs(pqy); + // Then semi-static filter. + double maxx = CGAL::abs(pqx); + double maxy = CGAL::abs(pqy); - double aprx = CGAL::abs(prx); - double apry = CGAL::abs(pry); + double aprx = CGAL::abs(prx); + double apry = CGAL::abs(pry); - if (maxx < aprx) maxx = aprx; - if (maxy < apry) maxy = apry; - double eps = 4.111024169857068197e-15 * maxx * maxy; - double det = CGAL::determinant(pqx, pqy, - prx, pry); + if (maxx < aprx) maxx = aprx; + if (maxy < apry) maxy = apry; + double eps = 4.111024169857068197e-15 * maxx * maxy; + double det = CGAL::determinant(pqx, pqy, + prx, pry); - // Sort maxx < maxy. - if (maxx > maxy) - std::swap(maxx, maxy); + // Sort maxx < maxy. + if (maxx > maxy) + std::swap(maxx, maxy); - // Protect against underflow in the computation of eps. - if (maxx < 1e-97) /* cbrt(min_double/eps) */ { + // Protect against underflow in the computation of eps. + if (maxx < 1e-97) /* cbrt(min_double/eps) */ + { if (maxx == 0) return ZERO; } - // Protect against overflow in the computation of det. - else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */ { + // Protect against overflow in the computation of det. + else if (maxy < 1e102) /* cbrt(max_double [hadamard]/4) */ + { if (det > eps) return POSITIVE; if (det < -eps) return NEGATIVE; } - CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static failures"); + CGAL_PROFILER("Periodic_2_orientation_2 with offset semi-static failures"); } - return Base::operator()(p,q,r,o_p,o_q,o_r); + return Base::operator()(p, q, r, o_p, o_q, o_r); } // Computes the epsilon for Periodic_2_orientation_2. static double compute_epsilon() { typedef Static_filter_error F; - F t1 = F(1, F::ulp()/4); // First translation + F t1 = F(1, F::ulp() / 4); // First translation F det = CGAL::determinant(t1, t1, t1, t1, t1, t1, t1, t1, t1); // Full det double err = det.error(); err += err * 2 * F::ulp(); // Correction due to "eps * maxx * maxy...". - std::cerr << "*** epsilon for Periodic_2_orientation_2 = " << err - << std::endl; + std::cerr << "*** epsilon for Periodic_2_orientation_2 = " << err + << std::endl; return err; } }; -} } } // namespace CGAL::internal::Static_filters_predicates +} +} +} // namespace CGAL::internal::Static_filters_predicates #endif // CGAL_INTERNAL_STATIC_FILTERS_PERIODIC_2_ORIENTATION_2_H diff --git a/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_side_of_oriented_circle_2.h b/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_side_of_oriented_circle_2.h index 24b3f454ecf..b7aa72e705c 100644 --- a/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_side_of_oriented_circle_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/internal/Static_filters/Periodic_2_side_of_oriented_circle_2.h @@ -13,7 +13,7 @@ // // $URL: svn+ssh://nicokruithof@scm.gforge.inria.fr/svnroot/cgal/trunk/Periodic_3_triangulation_3/include/CGAL/internal/Static_filters/Periodic_3_side_of_oriented_sphere_3.h $ // $Id: Periodic_3_side_of_oriented_sphere_3.h 63134 2011-04-26 17:01:34Z sloriot $ -// +// // // Author(s) : Sylvain Pion // Manuel Caroli @@ -27,7 +27,12 @@ #include -namespace CGAL { namespace internal { namespace Static_filters_predicates { +namespace CGAL +{ +namespace internal +{ +namespace Static_filters_predicates +{ template < typename K_base > class Periodic_2_side_of_oriented_circle_2 @@ -47,9 +52,9 @@ public: template Periodic_2_side_of_oriented_circle_2(const Iso_rectangle_2 * dom, - const EX * dom_e, - const AP * dom_f) - : Base(dom_e,dom_f), _dom(dom) { } + const EX * dom_e, + const AP * dom_f) + : Base(dom_e, dom_f), _dom(dom) { } Oriented_side operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r, @@ -58,7 +63,7 @@ public: CGAL_BRANCH_PROFILER_3("semi-static failures/attempts/calls to : Periodic_2_side_of_oriented_circle_2", tmp); Get_approx get_approx; // Identity functor for all points - // but lazy points. + // but lazy points. double px, py, qx, qy, rx, ry, tx, ty; @@ -66,23 +71,23 @@ public: fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) && fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry) && fit_in_double(get_approx(t).x(), tx) && fit_in_double(get_approx(t).y(), ty)) - { + { CGAL_BRANCH_PROFILER_BRANCH_1(tmp); - double qpx = qx-px; - double qpy = qy-py; - double rpx = rx-px; - double rpy = ry-py; - double tpx = tx-px; - double tpy = ty-py; + double qpx = qx - px; + double qpy = qy - py; + double rpx = rx - px; + double rpy = ry - py; + double tpx = tx - px; + double tpy = ty - py; - double tqx = tx-qx; - double tqy = ty-qy; - double rqx = rx-qx; - double rqy = ry-qy; + double tqx = tx - qx; + double tqy = ty - qy; + double rqx = rx - qx; + double rqy = ry - qy; - double det = CGAL::determinant(qpx*tpy - qpy*tpx, tpx*tqx + tpy*tqy, - qpx*rpy - qpy*rpx, rpx*rqx + rpy*rqy); + double det = CGAL::determinant(qpx * tpy - qpy * tpx, tpx * tqx + tpy * tqy, + qpx * rpy - qpy * rpx, rpx * rqx + rpy * rqy); // We compute the semi-static bound. double maxx = CGAL::abs(qpx); @@ -113,18 +118,20 @@ public: if (maxx > maxy) std::swap(maxx, maxy); // Protect against underflow in the computation of eps. - if (maxx < 1e-73) { - if (maxx == 0) - return ON_ORIENTED_BOUNDARY; - } - else if (maxy < 1e76) /* sqrt(sqrt(max_double/16 [hadamard])) */ { - double eps = 8.8878565762001373e-15 * maxx * maxy * (maxy*maxy); - if (det > eps) return ON_POSITIVE_SIDE; - if (det < -eps) return ON_NEGATIVE_SIDE; - } + if (maxx < 1e-73) + { + if (maxx == 0) + return ON_ORIENTED_BOUNDARY; + } + else if (maxy < 1e76) /* sqrt(sqrt(max_double/16 [hadamard])) */ + { + double eps = 8.8878565762001373e-15 * maxx * maxy * (maxy * maxy); + if (det > eps) return ON_POSITIVE_SIDE; + if (det < -eps) return ON_NEGATIVE_SIDE; + } CGAL_BRANCH_PROFILER_BRANCH_2(tmp); - } + } return Base::operator()(p, q, r, t); } @@ -133,7 +140,8 @@ public: operator()(const Point_2 &p, const Point_2 &q, const Point_2 &r, const Point_2 &s, const Offset &o_p, const Offset &o_q, - const Offset &o_r, const Offset &o_s) const { + const Offset &o_r, const Offset &o_s) const + { CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 calls"); @@ -146,65 +154,68 @@ public: fit_in_double(q.x(), qx) && fit_in_double(q.y(), qy) && fit_in_double(r.x(), rx) && fit_in_double(r.y(), ry) && fit_in_double(s.x(), sx) && fit_in_double(s.y(), sy) && - fit_in_double(_dom->xmax(), domxmax) && - fit_in_double(_dom->xmin(), domxmin) && - fit_in_double(_dom->ymax(), domymax) && - fit_in_double(_dom->ymin(), domymin)) { + fit_in_double(_dom->xmax(), domxmax) && + fit_in_double(_dom->xmin(), domxmin) && + fit_in_double(_dom->ymax(), domymax) && + fit_in_double(_dom->ymin(), domymin)) + { - CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static attempts"); + CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static attempts"); - double domx = domxmax - domxmin; - double domy = domymax - domymin; + double domx = domxmax - domxmin; + double domy = domymax - domymin; - double psx = px - sx + domx * (o_p.x() - osx); - double psy = py - sy + domy * (o_p.y() - osy); - double pt2 = CGAL_NTS square(psx) + CGAL_NTS square(psy); - double qsx = qx - sx + domx * (o_q.x() - osx); - double qsy = qy - sy + domy * (o_q.y() - osy); - double qt2 = CGAL_NTS square(qsx) + CGAL_NTS square(qsy); - double rsx = rx - sx + domx * (o_r.x() - osx); - double rsy = ry - sy + domy * (o_r.y() - osy); - double rt2 = CGAL_NTS square(rsx) + CGAL_NTS square(rsy); + double psx = px - sx + domx * (o_p.x() - osx); + double psy = py - sy + domy * (o_p.y() - osy); + double pt2 = CGAL_NTS square(psx) + CGAL_NTS square(psy); + double qsx = qx - sx + domx * (o_q.x() - osx); + double qsy = qy - sy + domy * (o_q.y() - osy); + double qt2 = CGAL_NTS square(qsx) + CGAL_NTS square(qsy); + double rsx = rx - sx + domx * (o_r.x() - osx); + double rsy = ry - sy + domy * (o_r.y() - osy); + double rt2 = CGAL_NTS square(rsx) + CGAL_NTS square(rsy); - // Compute the semi-static bound. - double maxx = CGAL::abs(psx); - double maxy = CGAL::abs(psy); - - double aqsx = CGAL::abs(qsx); - double aqsy = CGAL::abs(qsy); + // Compute the semi-static bound. + double maxx = CGAL::abs(psx); + double maxy = CGAL::abs(psy); - double arsx = CGAL::abs(rsx); - double arsy = CGAL::abs(rsy); - - if (maxx < aqsx) maxx = aqsx; - if (maxx < arsx) maxx = arsx; + double aqsx = CGAL::abs(qsx); + double aqsy = CGAL::abs(qsy); - if (maxy < aqsy) maxy = aqsy; - if (maxy < arsy) maxy = arsy; + double arsx = CGAL::abs(rsx); + double arsy = CGAL::abs(rsy); - // Sort maxx < maxy. - if (maxx > maxy) + if (maxx < aqsx) maxx = aqsx; + if (maxx < arsx) maxx = arsx; + + if (maxy < aqsy) maxy = aqsy; + if (maxy < arsy) maxy = arsy; + + // Sort maxx < maxy. + if (maxx > maxy) std::swap(maxx, maxy); - double eps = 1.0466759304746772485e-13 * maxx * maxy * (maxy * maxy); - - double det = CGAL::determinant(psx, psy, pt2, - qsx, qsy, qt2, - rsx, rsy, rt2); + double eps = 1.0466759304746772485e-13 * maxx * maxy * (maxy * maxy); - // Protect against underflow in the computation of eps. - if (maxx < 1e-58) /* sqrt^5(min_double/eps) */ { - if (maxx == 0) - return ON_ORIENTED_BOUNDARY; - } - // Protect against overflow in the computation of det. - else if (maxy < 1e61) /* sqrt^5(max_double/4 [hadamard]) */ { - if (det > eps) return ON_POSITIVE_SIDE; - if (det < -eps) return ON_NEGATIVE_SIDE; - } + double det = CGAL::determinant(psx, psy, pt2, + qsx, qsy, qt2, + rsx, rsy, rt2); - CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static failures"); - } + // Protect against underflow in the computation of eps. + if (maxx < 1e-58) /* sqrt^5(min_double/eps) */ + { + if (maxx == 0) + return ON_ORIENTED_BOUNDARY; + } + // Protect against overflow in the computation of det. + else if (maxy < 1e61) /* sqrt^5(max_double/4 [hadamard]) */ + { + if (det > eps) return ON_POSITIVE_SIDE; + if (det < -eps) return ON_NEGATIVE_SIDE; + } + + CGAL_PROFILER("Periodic_2_side_of_oriented_circle_2 with offset semi-static failures"); + } return Base::operator()(p, q, r, s, o_p, o_q, o_r, o_s); } @@ -212,8 +223,8 @@ public: static double compute_epsilon() { typedef Static_filter_error F; - F t1 = F(1,F::ulp()/4); // First translations - F sq = t1*t1+t1*t1+t1*t1; // squares + F t1 = F(1, F::ulp() / 4); // First translations + F sq = t1 * t1 + t1 * t1 + t1 * t1; // squares F det = CGAL::determinant(t1, t1, t1, sq, t1, t1, t1, sq, t1, t1, t1, sq, @@ -222,11 +233,13 @@ public: err += err * 3 * F::ulp(); // Correction due to "eps * maxx * ...". std::cerr << "*** epsilon for Periodic_2_side_of_oriented_circle_2 = " - << err << std::endl; + << err << std::endl; return err; } }; -} } } // namespace CGAL::internal::Static_filters_predicates +} +} +} // namespace CGAL::internal::Static_filters_predicates #endif // CGAL_INTERNAL_STATIC_FILTERS_PERIODIC_2_SIDE_OF_ORIENTED_CIRCLE_2_H diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h index 72faf7fb5ab..61c77998ff8 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/interface_test.h @@ -4,7 +4,8 @@ #include template -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 -void test_global_access() { +void test_global_access() +{ T t; const T &t_const = t; @@ -76,7 +78,8 @@ void test_global_access() { } template -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 -void test_predicates() { +void test_predicates() +{ typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Face_handle Face_handle; typedef typename T::Point Point; @@ -128,15 +132,17 @@ void test_predicates() { Vertex_handle vh2 = t.insert(Point(0.7, 0.7)); t.is_edge(vh0, vh1); - Face_handle fh; int i; + Face_handle fh; + int i; t.is_edge(vh0, vh1, fh, i); - + t.is_face(vh0, vh1, vh2); t.is_face(vh0, vh1, vh2, fh); } template -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 -void test_iterators() { +void test_iterators() +{ typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Face_handle Face_handle; typedef typename T::Point Point; @@ -183,116 +191,139 @@ void test_iterators() { // vertices size_t size = 0; for (typename T::Vertex_iterator vit = t_const.vertices_begin(); - vit != t_const.vertices_end(); ++vit) { - ++size; - } + vit != t_const.vertices_end(); ++vit) + { + ++size; + } CGAL_assertion(size == t_const.number_of_stored_vertices()); size = 0; for (typename T::Unique_vertex_iterator uvit = t_const.unique_vertices_begin(); - uvit != t_const.unique_vertices_end(); ++uvit) { - ++size; - } + uvit != t_const.unique_vertices_end(); ++uvit) + { + ++size; + } CGAL_assertion(size == t_const.number_of_vertices()); size = 0; for (typename T::Vertex_iterator vit = t_const.all_vertices_begin(); - vit != t_const.all_vertices_end(); ++vit) { - ++size; - } + vit != t_const.all_vertices_end(); ++vit) + { + ++size; + } CGAL_assertion(size == t_const.number_of_stored_vertices()); // edges size = 0; for (typename T::Edge_iterator eit = t_const.edges_begin(); - eit != t_const.edges_end(); ++eit) { - ++size; - } + eit != t_const.edges_end(); ++eit) + { + ++size; + } CGAL_assertion(size == t_const.number_of_stored_edges()); size = 0; for (typename T::Edge_iterator eit = t_const.all_edges_begin(); - eit != t_const.all_edges_end(); ++eit) { - ++size; - } + eit != t_const.all_edges_end(); ++eit) + { + ++size; + } CGAL_assertion(size == t_const.number_of_stored_edges()); // faces size = 0; for (typename T::Face_iterator fit = t_const.faces_begin(); - fit != t_const.faces_end(); ++fit) { - ++size; - } + fit != t_const.faces_end(); ++fit) + { + ++size; + } CGAL_assertion(size == t_const.number_of_stored_faces()); size = 0; for (typename T::All_faces_iterator fit = t_const.all_faces_begin(); - fit != t_const.all_faces_end(); ++fit) { - ++size; - } + fit != t_const.all_faces_end(); ++fit) + { + ++size; + } CGAL_assertion(size == t_const.number_of_stored_faces()); /// Geometric iterators for (typename T::Periodic_point_iterator ppit = t_const.periodic_points_begin(); - ppit != t_const.periodic_points_end(); ++ppit) { - } - for (typename T::Periodic_point_iterator ppit = + ppit != t_const.periodic_points_end(); ++ppit) + { + } + for (typename T::Periodic_point_iterator ppit = t_const.periodic_points_begin(T::STORED); - ppit != t_const.periodic_points_end(T::STORED); ++ppit) { - } - for (typename T::Periodic_point_iterator ppit = + ppit != t_const.periodic_points_end(T::STORED); ++ppit) + { + } + for (typename T::Periodic_point_iterator ppit = t_const.periodic_points_begin(T::UNIQUE); - ppit != t_const.periodic_points_end(T::UNIQUE); ++ppit) { - } - for (typename T::Periodic_point_iterator ppit = + ppit != t_const.periodic_points_end(T::UNIQUE); ++ppit) + { + } + for (typename T::Periodic_point_iterator ppit = t_const.periodic_points_begin(T::STORED_COVER_DOMAIN); - ppit != t_const.periodic_points_end(T::STORED_COVER_DOMAIN); ++ppit) { - } - for (typename T::Periodic_point_iterator ppit = + ppit != t_const.periodic_points_end(T::STORED_COVER_DOMAIN); ++ppit) + { + } + for (typename T::Periodic_point_iterator ppit = t_const.periodic_points_begin(T::UNIQUE_COVER_DOMAIN); - ppit != t_const.periodic_points_end(T::UNIQUE_COVER_DOMAIN); ++ppit) { - } + ppit != t_const.periodic_points_end(T::UNIQUE_COVER_DOMAIN); ++ppit) + { + } for (typename T::Periodic_segment_iterator psit = t_const.periodic_segments_begin(); - psit != t_const.periodic_segments_end(); ++psit) { - } - for (typename T::Periodic_segment_iterator psit = + psit != t_const.periodic_segments_end(); ++psit) + { + } + for (typename T::Periodic_segment_iterator psit = t_const.periodic_segments_begin(T::STORED); - psit != t_const.periodic_segments_end(T::STORED); ++psit) { - } - for (typename T::Periodic_segment_iterator psit = + psit != t_const.periodic_segments_end(T::STORED); ++psit) + { + } + for (typename T::Periodic_segment_iterator psit = t_const.periodic_segments_begin(T::UNIQUE); - psit != t_const.periodic_segments_end(T::UNIQUE); ++psit) { - } - for (typename T::Periodic_segment_iterator psit = + psit != t_const.periodic_segments_end(T::UNIQUE); ++psit) + { + } + for (typename T::Periodic_segment_iterator psit = t_const.periodic_segments_begin(T::STORED_COVER_DOMAIN); - psit != t_const.periodic_segments_end(T::STORED_COVER_DOMAIN); ++psit) { - } - for (typename T::Periodic_segment_iterator psit = + psit != t_const.periodic_segments_end(T::STORED_COVER_DOMAIN); ++psit) + { + } + for (typename T::Periodic_segment_iterator psit = t_const.periodic_segments_begin(T::UNIQUE_COVER_DOMAIN); - psit != t_const.periodic_segments_end(T::UNIQUE_COVER_DOMAIN); ++psit) { - } + psit != t_const.periodic_segments_end(T::UNIQUE_COVER_DOMAIN); ++psit) + { + } for (typename T::Periodic_triangle_iterator ptit = t_const.periodic_triangles_begin(); - ptit != t_const.periodic_triangles_end(); ++ptit) { - } - for (typename T::Periodic_triangle_iterator ptit = + ptit != t_const.periodic_triangles_end(); ++ptit) + { + } + for (typename T::Periodic_triangle_iterator ptit = t_const.periodic_triangles_begin(T::STORED); - ptit != t_const.periodic_triangles_end(T::STORED); ++ptit) { - } - for (typename T::Periodic_triangle_iterator ptit = + ptit != t_const.periodic_triangles_end(T::STORED); ++ptit) + { + } + for (typename T::Periodic_triangle_iterator ptit = t_const.periodic_triangles_begin(T::UNIQUE); - ptit != t_const.periodic_triangles_end(T::UNIQUE); ++ptit) { - } - for (typename T::Periodic_triangle_iterator ptit = + ptit != t_const.periodic_triangles_end(T::UNIQUE); ++ptit) + { + } + for (typename T::Periodic_triangle_iterator ptit = t_const.periodic_triangles_begin(T::STORED_COVER_DOMAIN); - ptit != t_const.periodic_triangles_end(T::STORED_COVER_DOMAIN); ++ptit) { - } - for (typename T::Periodic_triangle_iterator ptit = + ptit != t_const.periodic_triangles_end(T::STORED_COVER_DOMAIN); ++ptit) + { + } + for (typename T::Periodic_triangle_iterator ptit = t_const.periodic_triangles_begin(T::UNIQUE_COVER_DOMAIN); - ptit != t_const.periodic_triangles_end(T::UNIQUE_COVER_DOMAIN); ++ptit) { - } + ptit != t_const.periodic_triangles_end(T::UNIQUE_COVER_DOMAIN); ++ptit) + { + } } template -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 -void test_modifiers() { +void test_modifiers() +{ typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Face_handle Face_handle; typedef typename T::Point Point; @@ -348,7 +380,8 @@ void test_modifiers() { vh1 = t.insert(p1); vh2 = t.insert(p2); - typename T::Locate_type lt; int li; + typename T::Locate_type lt; + int li; fh = t_const.locate(p0, lt, li); t.insert(p0, lt, fh, li); t.push_back(p0); @@ -360,10 +393,11 @@ void test_modifiers() { t.clear(); vh0 = t.insert_first(p0); vh1 = t.insert(p1); - if (t.degree(vh1) == 3) { - // The vertex has degree 6 in case we are testing the Delaunay triangulation - t.remove_degree_3(vh1); - } + if (t.degree(vh1) == 3) + { + // The vertex has degree 6 in case we are testing the Delaunay triangulation + t.remove_degree_3(vh1); + } t.clear(); vh0 = t.insert_first(p0); @@ -376,12 +410,14 @@ void test_modifiers() { t.insert_in_edge(p2, fh, li); for (typename T::Vertex_iterator vit = t_const.vertices_begin(); - vit != t_const.vertices_end(); ++vit) { - if (t_const.degree(vit) == 3) { - t.remove_degree_3(vit); - vit = t_const.vertices_begin(); + vit != t_const.vertices_end(); ++vit) + { + if (t_const.degree(vit) == 3) + { + t.remove_degree_3(vit); + vit = t_const.vertices_begin(); + } } - } t.clear(); vh0 = t.insert(p0); @@ -391,7 +427,8 @@ void test_modifiers() { } template -void test_miscellaneous() { +void test_miscellaneous() +{ typedef typename T::Vertex_handle Vertex_handle; typedef typename T::Face_handle Face_handle; typedef typename T::Point Point; @@ -406,10 +443,10 @@ void test_miscellaneous() { vh1 = t.insert(p1); vh2 = t.insert(p2); - t.set_domain(typename T::Iso_rectangle(0,0,2,2)); + t.set_domain(typename T::Iso_rectangle(0, 0, 2, 2)); int i = t.ccw(0); int j = t.cw(0); - CGAL_assertion(i+j == 3); + CGAL_assertion(i + j == 3); t = T(); vh0 = t.insert(p0); @@ -427,35 +464,40 @@ void test_miscellaneous() { } template -void test_io(T &pt1, bool ex) { +void test_io(T &pt1, bool ex) +{ // std::cout << "I/O" << std::endl; // std::cout << " ascii" << std::endl; - + std::stringstream ss1; ss1 << pt1; T pt1r; ss1 >> pt1r; - + assert(CGAL::is_ascii(ss1)); - if (!ex) { assert(pt1 == pt1r); } + if (!ex) + { + assert(pt1 == pt1r); + } // std::cout << " binary" << std::endl; pt1r.clear(); // There are problems with the IO of exact number types in binary mode. - if (!ex) { - std::stringstream ss1b; - CGAL::set_binary_mode(ss1b); - ss1b << pt1; - - ss1b >> pt1r; - assert(CGAL::is_binary(ss1b)); + if (!ex) + { + std::stringstream ss1b; + CGAL::set_binary_mode(ss1b); + ss1b << pt1; - assert(pt1 == pt1r); - } + ss1b >> pt1r; + assert(CGAL::is_binary(ss1b)); + + assert(pt1 == pt1r); + } // std::cout << " pretty" << std::endl; - + pt1r.clear(); std::stringstream ss1p; CGAL::set_pretty_mode(ss1p); @@ -465,7 +507,8 @@ void test_io(T &pt1, bool ex) { } template -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 -void test(bool exact) { +void test(bool exact) +{ test_constructor(); test_global_access(); test_geometric_access(); @@ -503,7 +547,8 @@ void test(bool exact) { template -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 -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 -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 Creator; + typedef CGAL::Creator_uniform_2 Creator; typedef CGAL::Random_points_in_square_2 Random_points_in_square; T t; @@ -573,26 +620,31 @@ void test_locally_delaunay() { for (int i = 0; i < 10; ++i) t.insert(*(++g) + midpoint); - for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit) { - for (int i=0; i<3; ++i) { - CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i))); + for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit) + { + for (int i = 0; i < 3; ++i) + { + CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i))); + } } - } while (!t.is_1_cover()) t.insert(*(++g) + midpoint); - for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit) { - for (int i=0; i<3; ++i) { - CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i))); + for (Face_iterator fit = t.faces_begin(); fit != t.faces_end(); ++fit) + { + for (int i = 0; i < 3; ++i) + { + CGAL_assertion(t.locally_Delaunay(fit, i, fit->neighbor(i))); + } } - } - + } template -void test_delaunay() { +void test_delaunay() +{ test_batch_insertion(); test_nearest(); test_locally_delaunay(); diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/types.h b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/types.h index 127c4beff3f..33b7d2074ae 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/types.h +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/include/types.h @@ -50,7 +50,7 @@ typedef Triangulation_data_structure_2 PTH_Tds; typedef Periodic_2_Delaunay_triangulation_2 PTH_Dt; typedef Periodic_2_triangulation_hierarchy_2 Delaunay_triangulation_hierarchy; -typedef Creator_uniform_2 Creator; +typedef Creator_uniform_2 Creator; typedef Random_points_in_square_2 Random_points_in_square; typedef Random_points_on_circle_2 Random_points_on_circle; #endif // P2T2_UNIT_TEST_TYPES_H diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp index 22653bdb077..857a4a8939e 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_insert_degenerate.cpp @@ -6,17 +6,19 @@ #include -void test_insertion() { +void test_insertion() +{ // Create point sets - typedef CGAL::Creator_uniform_2 Creator; + typedef CGAL::Creator_uniform_2 Creator; CGAL::Random rnd(7); CGAL::Random_points_on_circle_2 on_circle(0.5, rnd); // Center of the circle at (0.5, 0.5) std::vector pts_rnd1000; - for (int i=0 ; i<1000 ; i++) { - pts_rnd1000.push_back(*on_circle++ + Vector(0.5, 0.5)); - } + for (int i = 0 ; i < 1000 ; i++) + { + pts_rnd1000.push_back(*on_circle++ + Vector(0.5, 0.5)); + } Triangulation pt(pts_rnd1000.begin(), pts_rnd1000.end()); CGAL_assertion(pt.is_valid()); @@ -36,10 +38,11 @@ void test_insertion() { // Center of the circle around the origin pts_rnd1000.clear(); - for (int i=0 ; i<1000 ; i++) { - Point p = *on_circle++; - pts_rnd1000.push_back(Point(p.x()<0 ? 1+p.x() : p.x(), p.y()<0 ? 1+p.y() :p.y())); - } + for (int i = 0 ; i < 1000 ; i++) + { + Point p = *on_circle++; + pts_rnd1000.push_back(Point(p.x() < 0 ? 1 + p.x() : p.x(), p.y() < 0 ? 1 + p.y() : p.y())); + } pt.insert(pts_rnd1000.begin(), pts_rnd1000.end()); CGAL_assertion(pt.is_valid()); @@ -50,7 +53,8 @@ void test_insertion() { CGAL_assertion(pt.number_of_vertices() == 0); } -int main() { +int main() +{ test_insertion(); return 0; diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_performance.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_performance.cpp index 452993ace46..964a6f4c7f6 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_performance.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_performance.cpp @@ -23,52 +23,60 @@ typedef CGAL::Periodic_2_Delaunay_triangulation_2 P2DT2; typedef CGAL::Delaunay_triangulation_2 DT2; template -class DT2_inserter { +class DT2_inserter +{ Dt t; public: template - void insert(Iterator begin, Iterator end) { + void insert(Iterator begin, Iterator end) + { t.insert(begin, end); } }; template -class P2DT2_inserter { +class P2DT2_inserter +{ PT t; public: template - void insert(Iterator begin, Iterator end) { + void insert(Iterator begin, Iterator end) + { t.insert(begin, end, large); } }; template -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 Creator; + typedef CGAL::Creator_uniform_2 Creator; CGAL::Random rnd(7); CGAL::Random_points_in_square_2 in_square(0.5, rnd); - for (int n = 0; n<=maximum; n+=5000) { - CGAL::Timer timer; + for (int n = 0; n <= maximum; n += 5000) + { + CGAL::Timer timer; - std::vector pts; - for (int i=0 ; i pts; + for (int i = 0 ; i < n ; i++) + { + pts.push_back(*in_square++ + Vector(0.5, 0.5)); + } + + Inserter inserter; + + timer.start(); + inserter.insert(pts.begin(), pts.end()); + timer.stop(); + std::cout << name << "; " << pts.size() << "; " << timer.time() << std::endl; } - - Inserter inserter; - - timer.start(); - inserter.insert(pts.begin(), pts.end()); - timer.stop(); - std::cout << name << "; " << pts.size() << "; " << timer.time() << std::endl; - } } -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ int maximum = 1e5; if (argc > 1) maximum = atoi(argv[1]); test_performance >("Euclidean Delaunay", maximum); @@ -101,7 +109,7 @@ int main(int argc, char *argv[]) { if (!(elem[0] in processed_data)) processed_data[elem[0]] = [] return processed_data[elem[0]].push([ elem[1], elem[2] ]); }); - + var processed_data2 = {}; for (var key in processed_data) { var data0 = processed_data["Euclidean Delaunay"]; diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp index 095193c03e0..2d4af155d5f 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_delaunay_remove.cpp @@ -6,7 +6,8 @@ const int N_PTS = 75; -int main() { +int main() +{ Triangulation t; Vector midpoint(0.5, 0.5); @@ -14,52 +15,55 @@ int main() { Face_handle fh; Triangulation::Locate_type lt; int i; - fh = t.locate(Point(0,0) + midpoint, lt, i); + fh = t.locate(Point(0, 0) + midpoint, lt, i); CGAL_assertion(lt == Triangulation::EMPTY); - Vertex_handle vh_midpoint = t.insert(Point(0,0) + midpoint); - fh = t.locate(Point(0,0) + midpoint, lt, i); + Vertex_handle vh_midpoint = t.insert(Point(0, 0) + midpoint); + fh = t.locate(Point(0, 0) + midpoint, lt, i); CGAL_assertion(lt == Triangulation::VERTEX && fh->vertex(i) == vh_midpoint); t.remove(vh_midpoint); CGAL_assertion(t.empty()); // High degree vertex - for (int n=3; n<8; ++n) { - vh_midpoint = t.insert(Point(0,0) + midpoint); - for (int i=0; ivertex(0); - vh = t.get_original_vertex(vh); - t.remove(vh); - CGAL_assertion(t.is_valid()); - } + for (int i = 0; i < N_PTS; ++i) + { + // Find a random vertex + Vertex_handle vh = t.locate(*(++g) + midpoint)->vertex(0); + vh = t.get_original_vertex(vh); + t.remove(vh); + CGAL_assertion(t.is_valid()); + } } return 0; } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_hierarchy.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_hierarchy.cpp index 2f37dfdff23..5e7deb15d84 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_hierarchy.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_hierarchy.cpp @@ -14,7 +14,7 @@ // // $URL: svn+ssh://mcaroli@scm.gforge.inria.fr/svn/cgal/trunk/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_periodic_2_delaunay_2.cpp $ // $Id: test_periodic_2_delaunay_2.cpp 48874 2009-04-22 12:54:28Z mcaroli $ -// +// // // Author(s) : Nico Kruithof // Manuel Caroli @@ -34,8 +34,8 @@ typedef CGAL::Periodic_2_triangulation_traits_2 PTT1; typedef CGAL::Periodic_2_triangulation_vertex_base_2 PVB1; typedef CGAL::Periodic_2_triangulation_face_base_2 PFB1; typedef CGAL::Triangulation_hierarchy_vertex_base_2 PHVB1; -typedef CGAL::Triangulation_data_structure_2 Tds1; -typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT1; +typedef CGAL::Triangulation_data_structure_2 Tds1; +typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT1; // Explicit instantiation of the whole class : template class CGAL::Periodic_2_triangulation_hierarchy_2; @@ -44,11 +44,11 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel K2; typedef CGAL::Periodic_2_triangulation_traits_2 PTT2; typedef CGAL::Periodic_2_triangulation_vertex_base_2 DSVB2; typedef CGAL::Periodic_2_triangulation_face_base_2 DSFB2; -typedef CGAL::Triangulation_vertex_base_2 VBB2; +typedef CGAL::Triangulation_vertex_base_2 VBB2; typedef CGAL::Triangulation_hierarchy_vertex_base_2 VB2; -typedef CGAL::Triangulation_face_base_2 FB2; -typedef CGAL::Triangulation_data_structure_2 Tds2; -typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT2; +typedef CGAL::Triangulation_face_base_2 FB2; +typedef CGAL::Triangulation_data_structure_2 Tds2; +typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT2; // Explicit instantiation of the whole class : template class CGAL::Periodic_2_triangulation_hierarchy_2; @@ -58,11 +58,11 @@ typedef CGAL::Simple_homogeneous K3; typedef CGAL::Periodic_2_triangulation_traits_2 PTT3; typedef CGAL::Periodic_2_triangulation_vertex_base_2 DSVB3; typedef CGAL::Periodic_2_triangulation_face_base_2 DSFB3; -typedef CGAL::Triangulation_vertex_base_2 VBB3; +typedef CGAL::Triangulation_vertex_base_2 VBB3; typedef CGAL::Triangulation_hierarchy_vertex_base_2 VB3; -typedef CGAL::Triangulation_face_base_2 FB3; -typedef CGAL::Triangulation_data_structure_2 Tds3; -typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT3; +typedef CGAL::Triangulation_face_base_2 FB3; +typedef CGAL::Triangulation_data_structure_2 Tds3; +typedef CGAL::Periodic_2_Delaunay_triangulation_2 PDT3; // Explicit instantiation of the whole class : template class CGAL::Periodic_2_triangulation_hierarchy_2; diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_interface_triang_2.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_interface_triang_2.cpp index 9628127614e..52beb24d672 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_interface_triang_2.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_interface_triang_2.cpp @@ -18,7 +18,8 @@ typedef CGAL::Periodic_2_triangulation_traits_2 PTT3; // Explicit instantiation of the whole class : template class CGAL::Periodic_2_Delaunay_triangulation_2; -int main() { +int main() +{ typedef Periodic_2_triangulation_2 P2T2; typedef Periodic_2_Delaunay_triangulation_2 DP2T2; diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_gredner.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_gredner.cpp index 6dd8fb7ff66..e3026f85713 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_gredner.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_gredner.cpp @@ -15,86 +15,97 @@ const bool pre_run = false; const bool do_remove = true; const int n_runs = 2; -void load_data(const char *filename, Iso_rectangle &domain, std::vector &pts) { - std::ifstream file (filename, std::ios::in|std::ios::binary); +void load_data(const char *filename, Iso_rectangle &domain, std::vector &pts) +{ + std::ifstream file (filename, std::ios::in | std::ios::binary); if (!file.is_open()) exit(1); float dom[2]; file.read((char *)&dom[0], 2 * sizeof(float)); - domain = Iso_rectangle(0,0,dom[0],dom[1]); + domain = Iso_rectangle(0, 0, dom[0], dom[1]); float coords[2]; - while (!file.eof()) { - file.read((char *)&coords[0], 2 * sizeof(float)); - while (coords[0] < 0) coords[0] += dom[0]; - while (coords[1] < 0) coords[1] += dom[1]; - while (coords[0] >= dom[0]) coords[0] -= dom[0]; - while (coords[1] >= dom[1]) coords[1] -= dom[1]; + while (!file.eof()) + { + file.read((char *)&coords[0], 2 * sizeof(float)); + while (coords[0] < 0) coords[0] += dom[0]; + while (coords[1] < 0) coords[1] += dom[1]; + while (coords[0] >= dom[0]) coords[0] -= dom[0]; + while (coords[1] >= dom[1]) coords[1] -= dom[1]; - pts.push_back(Point(coords[0], coords[1])); - } + pts.push_back(Point(coords[0], coords[1])); + } } template -void test(const std::vector &input, T &t) { +void test(const std::vector &input, T &t) +{ t.insert(input.begin(), input.end(), true); - if (do_remove) { - std::vector vhs; - for (typename T::Vertex_iterator it = t.vertices_begin(); it != t.vertices_end(); ++it) { - vhs.push_back(it); + if (do_remove) + { + std::vector vhs; + for (typename T::Vertex_iterator it = t.vertices_begin(); it != t.vertices_end(); ++it) + { + vhs.push_back(it); + } + + std::random_shuffle(vhs.begin(), vhs.end()); + vhs.resize(vhs.size() / 2); + for (size_t i = 0; i < vhs.size(); ++i) + t.remove(vhs[i]); } - - std::random_shuffle(vhs.begin(), vhs.end()); - vhs.resize(vhs.size()/2); - for (size_t i=0; i pts; load_data(filename, domain, pts); - for (int run=0; run<3; ++run) { - // if (true) { - // if (pre_run) { - // Delaunay_triangulation_2 t; - // test(pts, t); - // } + for (int run = 0; run < 3; ++run) + { + // if (true) { + // if (pre_run) { + // Delaunay_triangulation_2 t; + // test(pts, t); + // } - // std::clock_t total_start = std::clock(); - // for (int i=0; i t; - // test(pts, t); - // } - // double total_time = (std::clock()-total_start)/(double)CLOCKS_PER_SEC; + // std::clock_t total_start = std::clock(); + // for (int i=0; i t; + // test(pts, t); + // } + // double total_time = (std::clock()-total_start)/(double)CLOCKS_PER_SEC; - // std::cout << "Euclidean space, " << filename << ", " << total_time << std::endl; - // } + // std::cout << "Euclidean space, " << filename << ", " << total_time << std::endl; + // } - if (true) { - if (pre_run) { - Periodic_2_Delaunay_triangulation_2 t(domain); - test(pts, t); - } + if (true) + { + if (pre_run) + { + Periodic_2_Delaunay_triangulation_2 t(domain); + test(pts, t); + } - std::clock_t total_start = std::clock(); - for (int i=0; i t(domain); - test(pts, t); - } - double total_time = (std::clock()-total_start)/(double)CLOCKS_PER_SEC; + std::clock_t total_start = std::clock(); + for (int i = 0; i < n_runs; ++i) + { + Periodic_2_Delaunay_triangulation_2 t(domain); + test(pts, t); + } + double total_time = (std::clock() - total_start) / (double)CLOCKS_PER_SEC; - std::cout << "Periodic space, " << filename << ", " << total_time << std::endl; + std::cout << "Periodic space, " << filename << ", " << total_time << std::endl; + } } - } return 0; } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp index c5953077dd8..5b38e6237ce 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_performance_test.cpp @@ -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 pts; pts.resize(500000); - for (size_t i=0; i 0) { - t.insert(p + Vector(x,y)); - } - } - } - } - - if (i%500==0) { - std::cout << i << ", \t" - << (std::clock()-start_time)/(double)CLOCKS_PER_SEC << ", \t" - << total_time << ", \t" - << locate_time << ", \t" << insert_time << ", \t" - << periodic_insert_time << ", \t" << periodic_insert_time << std::endl; - } - } - CGAL_assertion(t.is_valid()); - std::cout << std::endl; - } + // First run is for heating up the CPU, don't output the stats + for (int run = 0; run < N_RUNS; ++run) + { + // Reset timings + total_time = 0.0; + locate_time = 0.0; + insert_time = 0.0; + periodic_locate_time = 0.0; + periodic_insert_time = 0.0; + +#ifdef PERIODIC + Triangulation t; + const bool insert_periodic_copies = false; +#else + EuclideanTriangulation t; + const bool insert_periodic_copies = false; +#endif + + std::clock_t start_time = std::clock(); + // Do one additional point to get the statistics right + for (int i = 0; i <= N_PTS; ++i) + { + Point p = *(++g) + midpoint; + t.insert(p); + + if (insert_periodic_copies) + { + for (int x = 0; x < 3; ++x) + { + for (int y = 0; y < 3; ++y) + { + if (x + y > 0) + { + t.insert(p + Vector(x, y)); + } + } + } + } + + if (i % 500 == 0) + { + std::cout << i << ", \t" + << (std::clock() - start_time) / (double)CLOCKS_PER_SEC << ", \t" + << total_time << ", \t" + << locate_time << ", \t" << insert_time << ", \t" + << periodic_insert_time << ", \t" << periodic_insert_time << std::endl; + } + } + CGAL_assertion(t.is_valid()); + + std::cout << std::endl; + } return 0; } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp index e142830dcb2..ba18d70deb2 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_test_semi_static_predicates.cpp @@ -3,19 +3,20 @@ #include "./types.h" #include -const int N=10; +const int N = 10; -void test_orientation() { +void test_orientation() +{ Gt traits; - traits.set_domain(Gt::Iso_rectangle_2(0,0,1,1)); + traits.set_domain(Gt::Iso_rectangle_2(0, 0, 1, 1)); Gt::Offset_2 o0(0, 0); Gt::Offset_2 o1(0, 1); /// Near degenerate points, which cause the predicate to fail if not filtered - Point p0(0.5 + (0.4999/N)*2, 0.5 + (0.4999/N)*-5); - Point p1(0.5 + (0.4999/N)*4, 0.5 + (0.4999/N)*-4); - Point p2(0.5 + (0.4999/N)*6, 0.5 + (0.4999/N)*-3); + Point p0(0.5 + (0.4999 / N) * 2, 0.5 + (0.4999 / N) * -5); + Point p1(0.5 + (0.4999 / N) * 4, 0.5 + (0.4999 / N) * -4); + Point p2(0.5 + (0.4999 / N) * 6, 0.5 + (0.4999 / N) * -3); CGAL_assertion(traits.orientation_2_object()(p0, p1, p2) == 1); CGAL_assertion(traits.orientation_2_object()(p2, p0, p1) == 1); @@ -51,19 +52,20 @@ void test_orientation() { traits.orientation_2_object()(p2, p1, p0, o1, o1, o1)); } -void test_in_circle() { +void test_in_circle() +{ Gt traits; - traits.set_domain(Gt::Iso_rectangle_2(0,0,1,1)); + traits.set_domain(Gt::Iso_rectangle_2(0, 0, 1, 1)); Gt::Offset_2 o0(0, 0); Gt::Offset_2 o1(0, 1); /// Near degenerate points, which cause the predicate to fail if not filtered /// On the circle with center (0.4999, 0.4999) and radius 5 - Point p0( 5-0.4999, -0.4999); - Point p1( 3-0.4999, 4-0.4999); - Point p2(-4-0.4999, 3-0.4999); - Point p3( 4-0.4999, -3-0.4999); + Point p0( 5 - 0.4999, -0.4999); + Point p1( 3 - 0.4999, 4 - 0.4999); + Point p2(-4 - 0.4999, 3 - 0.4999); + Point p3( 4 - 0.4999, -3 - 0.4999); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p0, p1, p2, p3) == 1); CGAL_assertion(traits.side_of_oriented_circle_2_object()(p2, p0, p1, p3) == 1); @@ -99,9 +101,10 @@ void test_in_circle() { traits.side_of_oriented_circle_2_object()(p2, p1, p0, p3, o1, o1, o1, o1)); } -int main() { +int main() +{ test_orientation(); test_in_circle(); - + return 0; } diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp index 95a65f6395a..37b70b993af 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_flip.cpp @@ -3,53 +3,65 @@ #include "./types.h" #include -void greedy_flip_long_edges(Triangulation &t) { +void greedy_flip_long_edges(Triangulation &t) +{ typedef std::multimap > Edge_map; - Face_handle f; int i; + Face_handle f; + int i; Edge_map edge_map; - for (Triangulation::Edge_iterator eit = t.edges_begin(); eit != t.edges_end(); ++eit) { - double sqr_length_orig = t.segment(eit).squared_length(); - if (sqr_length_orig > 0.166) { - f = eit->first; i = eit->second; - edge_map.insert(std::make_pair(sqr_length_orig, - std::make_pair(f->vertex(t.ccw(i)), - f->vertex(t.cw(i))))); - } - } - - bool is_1_cover = t.is_1_cover(); - for (Edge_map::reverse_iterator it = edge_map.rbegin(); it != edge_map.rend(); ++it) { - double sqr_length_orig = it->first; - if (t.is_edge(it->second.first, it->second.second, f, i)) { - if (t.flippable(f, i)) { - t.flip(f, i); - // We flipped enough long edges, when we go to the 1-cover all faces are invalidated - if (is_1_cover != t.is_1_cover()) - return; - double sqr_length_new = t.segment(f, t.ccw(i)).squared_length(); - if (sqr_length_orig < sqr_length_new) { - std::cout << sqr_length_orig << std::endl; - t.flip(f, t.ccw(i)); + for (Triangulation::Edge_iterator eit = t.edges_begin(); eit != t.edges_end(); ++eit) + { + double sqr_length_orig = t.segment(eit).squared_length(); + if (sqr_length_orig > 0.166) + { + f = eit->first; + i = eit->second; + edge_map.insert(std::make_pair(sqr_length_orig, + std::make_pair(f->vertex(t.ccw(i)), + f->vertex(t.cw(i))))); + } + } + + bool is_1_cover = t.is_1_cover(); + for (Edge_map::reverse_iterator it = edge_map.rbegin(); it != edge_map.rend(); ++it) + { + double sqr_length_orig = it->first; + if (t.is_edge(it->second.first, it->second.second, f, i)) + { + if (t.flippable(f, i)) + { + t.flip(f, i); + // We flipped enough long edges, when we go to the 1-cover all faces are invalidated + if (is_1_cover != t.is_1_cover()) + return; + double sqr_length_new = t.segment(f, t.ccw(i)).squared_length(); + if (sqr_length_orig < sqr_length_new) + { + std::cout << sqr_length_orig << std::endl; + t.flip(f, t.ccw(i)); + } + } } - } } - } } -int main() { +int main() +{ Point p; Triangulation t; - const int N=4; + const int N = 4; // Insert the first point - for (int y=0; y -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; xhas_vertex(vh0)); fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE); CGAL_assertion(fh->has_vertex(vh0)); - + fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE); CGAL_assertion(fh->has_vertex(vh0)); @@ -72,12 +79,12 @@ int main() { CGAL_assertion(fh->has_vertex(vh0)); CGAL_assertion(t.is_valid(true)); - + // Insert the second point on an edge Point p1(0.7, 0.7); Vertex_handle vh1 = t.insert(p1); CGAL_assertion(t.is_valid(true)); - + fh = test_point_location(t, p0, Triangulation::VERTEX); CGAL_assertion(fh->has_vertex(vh0)); @@ -87,7 +94,7 @@ int main() { fh = test_point_location(t, p0 + Vector(0.1, 0.1), Triangulation::EDGE); CGAL_assertion(fh->has_vertex(vh0)); CGAL_assertion(fh->has_vertex(vh1)); - + fh = test_point_location(t, p0 + Vector(-0.1, -0.1), Triangulation::EDGE); CGAL_assertion(fh->has_vertex(vh0)); CGAL_assertion(!fh->has_vertex(vh1)); diff --git a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp index 68fc09a0a43..e93c7063f1d 100644 --- a/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp +++ b/Periodic_2_triangulation_2/test/Periodic_2_triangulation_2/test_p2t2_triangulation_prog1.cpp @@ -19,177 +19,207 @@ typedef Triangulation::Periodic_point_iterator Periodic_point_iterator; typedef Triangulation::Periodic_segment_iterator Periodic_segment_iterator; typedef Triangulation::Periodic_triangle_iterator Periodic_triangle_iterator; -void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t) { +void test_point_location_in_a_triangulation_with_a_single_point(Triangulation &t) +{ CGAL_assertion(t.number_of_vertices() == 1); - + Point &p = t.vertices_begin()->point(); Triangulation::Locate_type lt; int li; - - for (int offset_x = 0; offset_x begin(in); // std::istream_iterator end; // t.insert(begin, end); - + return 0; }