mirror of https://github.com/CGAL/cgal
Working on the vertex/face structs, renaming.
Working on the hierarchy
This commit is contained in:
parent
55f561b0dc
commit
f05ca0bb23
|
|
@ -18,7 +18,7 @@ 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_ds_vertex_base_2<Gt>, CGAL::Periodic_2_triangulation_ds_face_base_2<Gt> > >`.
|
||||
`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2<Gt>, CGAL::Periodic_2_triangulation_face_base_2<Gt> > >`.
|
||||
|
||||
### Implementation ###
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ vertices distributed uniformly at random and any query point.
|
|||
\sa `CGAL::Delaunay_triangulation_2<Traits,Tds>`
|
||||
\sa `TriangulationDataStructure_2`
|
||||
\sa `Periodic_2DelaunayTriangulationTraits_2`
|
||||
\sa `CGAL::Triangulation_hierarchy_2<Tr>`
|
||||
\sa `CGAL::Periodic_2_triangulation_hierarchy_2<Tr>`
|
||||
|
||||
*/
|
||||
template< typename Traits, typename Tds >
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ 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_ds_vertex_base_2<Gt>, CGAL::Periodic_2_triangulation_ds_face_base_2<Gt> > >`.
|
||||
`CGAL::Triangulation_data_structure_2 < CGAL::Triangulation_vertex_base_2<Gt>, CGAL::Periodic_2_triangulation_face_base_2<Gt> > >`.
|
||||
|
||||
### Traversal of the Triangulation ###
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2MainClasses
|
||||
|
||||
The class `Periodic_2_triangulation_ds_vertex_base_2` is a model
|
||||
of the concept `Periodic_2TriangulationDSVertexBase_2` to be used by
|
||||
`Triangulation_data_structure_2` to represent vertices of a
|
||||
periodic triangulation.
|
||||
|
||||
\cgalModels `Periodic_2TriangulationDSVertexBase_2`
|
||||
|
||||
\sa `CGAL::Periodic_2_triangulation_ds_face_base_2`
|
||||
\sa `CGAL::Triangulation_vertex_base_2`
|
||||
\sa `CGAL::Triangulation_vertex_base_with_info_2`
|
||||
|
||||
*/
|
||||
template< >
|
||||
class Periodic_2_triangulation_ds_vertex_base_2 {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Periodic_2_triangulation_ds_vertex_base_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -4,8 +4,8 @@ namespace CGAL {
|
|||
/*!
|
||||
\ingroup PkgPeriodic2Triangulation2
|
||||
|
||||
The class `Periodic_2_triangulation_ds_face_base_2` is a model of
|
||||
the concept `Periodic_2TriangulationDSFaceBase_2` to be used by
|
||||
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.
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ the offset corresponding to vertex \f$ i\f$.
|
|||
The implementation of `has_zero_offsets()` results in checking
|
||||
whether all offsets are zero.
|
||||
|
||||
\cgalModels ::Periodic_2TriangulationDSFaceBase_2
|
||||
\cgalModels ::Periodic_2TriangulationFaceBase_2
|
||||
|
||||
\sa `CGAL::Triangulation_face_base_2`
|
||||
\sa `CGAL::Triangulation_face_base_with_info_2`
|
||||
|
|
@ -28,10 +28,10 @@ whether all offsets are zero.
|
|||
|
||||
*/
|
||||
template< >
|
||||
class Periodic_2_triangulation_ds_face_base_2 {
|
||||
class Periodic_2_triangulation_face_base_2 {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Periodic_2_triangulation_ds_face_base_2 */
|
||||
}; /* end Periodic_2_triangulation_face_base_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
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.
|
||||
|
||||
\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`
|
||||
|
||||
*/
|
||||
template< >
|
||||
class Periodic_2_triangulation_vertex_base_2 {
|
||||
public:
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Periodic_2_triangulation_vertex_base_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -14,9 +14,9 @@ functions in the triangulation classes.
|
|||
|
||||
The package uses the `Triangulation_data_structure_2` to represent
|
||||
the triangulation. The faces need to be a model of the concept
|
||||
`Periodic_2TriangulationDSFaceBase_2` and the vertices can be a
|
||||
`Periodic_2TriangulationFaceBase_2` and the vertices can be a
|
||||
model of the Euclidean vertex concept
|
||||
`TriangulationDSVertexBase_2`. A triangulation is stored as a
|
||||
`TriangulationVertexBase_2`. A triangulation is stored as a
|
||||
collection of vertices and faces that are linked together through
|
||||
incidence and adjacency relations. Each face gives access to its three
|
||||
incident vertices and to its three adjacent faces. Each vertex gives
|
||||
|
|
@ -44,7 +44,7 @@ concept `Periodic_2Offset_2`.
|
|||
|
||||
`TriangulationDataStructure_2`
|
||||
|
||||
`Periodic_2TriangulationDSFaceBase_2`
|
||||
`Periodic_2TriangulationFaceBase_2`
|
||||
|
||||
`TriangulationVertexBase_2`
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ concept `Periodic_2Offset_2`.
|
|||
|
||||
\ref ::CGAL::Periodic_2_triangulation_hierarchy_2<PTr>
|
||||
|
||||
\ref ::CGAL::Periodic_2_triangulation_ds_face_base_2<>
|
||||
\ref ::CGAL::Periodic_2_triangulation_face_base_2<>
|
||||
|
||||
\ref ::CGAL::Periodic_2_offset_2
|
||||
|
||||
|
|
|
|||
|
|
@ -9,17 +9,17 @@ 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 ::TriangulationDSFaceBase_2
|
||||
\cgalRefines ::TriangulationFaceBase_2
|
||||
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_ds_face_base_2
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_face_base_2
|
||||
|
||||
\sa `TriangulationDataStructure_2`
|
||||
\sa `TriangulationDSFaceBase_2`
|
||||
\sa `Periodic_2TriangulationDSVertexBase_2`
|
||||
\sa `TriangulationFaceBase_2`
|
||||
\sa `Periodic_2TriangulationVertexBase_2`
|
||||
|
||||
*/
|
||||
|
||||
class Periodic_2TriangulationDSFaceBase_2 {
|
||||
class Periodic_2TriangulationFaceBase_2 {
|
||||
public:
|
||||
|
||||
/// \name Access Functions
|
||||
|
|
@ -48,5 +48,5 @@ void set_offsets(int off0, int off1, int off2);
|
|||
|
||||
/// @}
|
||||
|
||||
}; /* end Periodic_2TriangulationDSFaceBase_2 */
|
||||
}; /* end Periodic_2TriangulationFaceBase_2 */
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\ingroup PkgPeriodic2Triangulation2Concepts
|
||||
\cgalConcept
|
||||
|
||||
A refinement of the concept `TriangulationDSVertexBase_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,19 +12,19 @@ to one of its incident faces through a handle.
|
|||
|
||||
The storage of the offset is only needed when a triangulation is copied.
|
||||
|
||||
\cgalRefines `TriangulationDSVertexBase_2`
|
||||
\cgalRefines `TriangulationVertexBase_2`
|
||||
|
||||
|
||||
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_ds_vertex_base_2
|
||||
\cgalHasModel CGAL::Periodic_2_triangulation_vertex_base_2
|
||||
|
||||
\sa `TriangulationDataStructure_2`
|
||||
\sa `TriangulationDSVertexBase_2`
|
||||
\sa `Periodic_2TriangulationDSFaceBase_2`
|
||||
\sa `TriangulationVertexBase_2`
|
||||
\sa `Periodic_2TriangulationFaceBase_2`
|
||||
|
||||
*/
|
||||
|
||||
class Periodic_2TriangulationDSVertexBase_2 {
|
||||
class Periodic_2TriangulationVertexBase_2 {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
|
|
@ -63,5 +63,5 @@ void clear_offset();
|
|||
|
||||
/// @}
|
||||
|
||||
}; /* end Periodic_2TriangulationDSVertexBase_2 */
|
||||
}; /* end Periodic_2TriangulationVertexBase_2 */
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ triangulation classes.
|
|||
|
||||
The package uses `Triangulation_data_structure_2` to represent the
|
||||
triangulation. The faces and vertices need to be alModels of the
|
||||
concepts `Periodic_2TriangulationDSFaceBase_2` and
|
||||
`TriangulationDSVertexBase_2`, respectively.
|
||||
concepts `Periodic_2TriangulationFaceBase_2` and
|
||||
`TriangulationVertexBase_2`, respectively.
|
||||
A triangulation is stored as a collection of vertices and faces that
|
||||
are linked together through incidence and adjacency relations. Each
|
||||
face gives access to its three incident vertices and to its three
|
||||
|
|
|
|||
|
|
@ -155,14 +155,14 @@ The class `Periodic_2_triangulation_hierarchy_2` is the adaptation
|
|||
of the hierarchical structure described in
|
||||
Chapter \ref Chapter_2D_Triangulations,
|
||||
Section \ref Section_2D_Triangulations_Hierarchy to the periodic
|
||||
case. (NGHK: TODO, hierarchy is not implemented yet)
|
||||
case.
|
||||
|
||||
The class `Triangulation_hierarchy_2<Tr>` inherits from the
|
||||
triangulation type passed as template parameter `Tr`.
|
||||
The `insert`, `move`, and `remove` member functions
|
||||
are overwritten to update the data structure at each operation.
|
||||
The locate queries are also overwritten to take advantage of the data
|
||||
structure for a fast processing.
|
||||
The class `Periodic_2_triangulation_hierarchy_2<Tr>` inherits from the
|
||||
triangulation type passed as template parameter `Tr`. The `insert`,
|
||||
`move`, and `remove` member functions are overwritten to update the
|
||||
data structure at each operation. The locate queries are also
|
||||
overwritten to take advantage of the data structure for a fast
|
||||
processing.
|
||||
|
||||
\section P2Triangulation2secdesign Software Design
|
||||
|
||||
|
|
@ -201,9 +201,9 @@ parameters:
|
|||
combinatorial structure, described in Section \ref
|
||||
P2Triangulation2sectds and in more detail in Chapter \ref
|
||||
Chapter_2D_Triangulation_Data_Structure. The triangulation data
|
||||
structure needs alModels of the concepts
|
||||
`Periodic_2TriangulationDSFaceBase_2` and
|
||||
`Periodic_2TriangulationDSVertexBase_2` as template parameters.
|
||||
structure needs Models of the concepts
|
||||
`Periodic_2TriangulationFaceBase_2` and
|
||||
`Periodic_2TriangulationVertexBase_2` as template parameters.
|
||||
|
||||
\subsection P2Triangulation2secTraits The Geometric Traits Parameter
|
||||
|
||||
|
|
@ -263,8 +263,8 @@ possibility to customize the vertices and cells used by the triangulation data
|
|||
structure, and hence by the geometric triangulation using it.
|
||||
To represent periodic triangulations the cell base and vertex base
|
||||
classes need to meet the concepts
|
||||
`Periodic_2TriangulationDSFaceBase_2` and
|
||||
`Periodic_2TriangulationDSVertexBase_2`.
|
||||
`Periodic_2TriangulationFaceBase_2` and
|
||||
`Periodic_2TriangulationVertexBase_2`.
|
||||
|
||||
A default value for the triangulation data structure parameter is provided in
|
||||
all the triangulation classes, so it does not need to be specified by
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ public:
|
|||
typedef typename Vb::Face_handle Face_handle;
|
||||
typedef typename Vb::Point Point;
|
||||
|
||||
template < class TDS2 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2;
|
||||
template < class Tds2 >
|
||||
struct Rebind_Tds {
|
||||
typedef typename Vb::template Rebind_Tds<Tds2>::Other Vb2;
|
||||
typedef My_vertex_base<GT, Vb2> Other;
|
||||
};
|
||||
|
||||
|
|
@ -35,12 +35,12 @@ public:
|
|||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Periodic_2_triangulation_filtered_traits_2<K> GT;
|
||||
|
||||
typedef CGAL::Triangulation_ds_vertex_base_2<> VbDS;
|
||||
typedef CGAL::Periodic_2_triangulation_ds_face_base_2<> FbDS;
|
||||
typedef CGAL::Triangulation_vertex_base_2<> VbDS;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<> FbDS;
|
||||
typedef CGAL::Triangulation_face_base_2<GT,FbDS> Fb;
|
||||
|
||||
typedef CGAL::Triangulation_data_structure_2<My_vertex_base<GT,VbDS>, Fb> TDS;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<GT,TDS> PDT;
|
||||
typedef CGAL::Triangulation_data_structure_2<My_vertex_base<GT,VbDS>, Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<GT,Tds> PDT;
|
||||
|
||||
typedef PDT::Vertex_handle Vertex_handle;
|
||||
typedef PDT::Point Point;
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ typedef CGAL::Periodic_2_triangulation_filtered_traits_2<K> GT;
|
|||
|
||||
typedef CGAL::Triangulation_vertex_base_2<GT> Vb;
|
||||
|
||||
typedef CGAL::Periodic_2_triangulation_ds_face_base_2<> FbDS;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<> FbDS;
|
||||
typedef CGAL::Triangulation_face_base_2<GT,FbDS> Fb;
|
||||
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<CGAL::Color, GT, Vb> VbInfo;
|
||||
typedef CGAL::Triangulation_data_structure_2<VbInfo, Fb> TDS;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<GT, TDS> PDT;
|
||||
typedef CGAL::Triangulation_data_structure_2<VbInfo, Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<GT, Tds> PDT;
|
||||
|
||||
typedef PDT::Point Point;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Periodic_2_triangulation_traits_2<K> Gt;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, Gt> Vb;
|
||||
typedef CGAL::Periodic_2_triangulation_ds_face_base_2<> FbDS;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<> FbDS;
|
||||
typedef CGAL::Triangulation_face_base_2<Gt,FbDS> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt, Tds> Delaunay;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Periodic_2_triangulation_traits_2<K> Gt;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, Gt> Vb;
|
||||
typedef CGAL::Periodic_2_triangulation_ds_face_base_2<> FbDS;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<> FbDS;
|
||||
typedef CGAL::Triangulation_face_base_2<Gt,FbDS> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt, Tds> Delaunay;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Periodic_2_triangulation_traits_2<K> Gt;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, Gt> Vb;
|
||||
typedef CGAL::Periodic_2_triangulation_ds_face_base_2<> FbDS;
|
||||
typedef CGAL::Periodic_2_triangulation_face_base_2<> FbDS;
|
||||
typedef CGAL::Triangulation_face_base_2<Gt,FbDS> Fb;
|
||||
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
|
||||
typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt, Tds> Delaunay;
|
||||
|
|
|
|||
|
|
@ -37,9 +37,8 @@ namespace CGAL {
|
|||
template <
|
||||
class Gt,
|
||||
class Tds = Triangulation_data_structure_2<
|
||||
Periodic_2_triangulation_ds_vertex_base_2<Gt>,
|
||||
Triangulation_face_base_2<Gt,
|
||||
Periodic_2_triangulation_ds_face_base_2<> > > >
|
||||
Periodic_2_triangulation_vertex_base_2<Gt>,
|
||||
Periodic_2_triangulation_face_base_2<Gt> > >
|
||||
class Periodic_2_Delaunay_triangulation_2 : public Periodic_2_triangulation_2<Gt,Tds>
|
||||
{
|
||||
typedef Periodic_2_Delaunay_triangulation_2<Gt,Tds> Self;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@
|
|||
#include <CGAL/Triangulation_data_structure_2.h>
|
||||
#include <CGAL/Triangulation_vertex_base_2.h>
|
||||
#include <CGAL/Triangulation_face_base_2.h>
|
||||
#include <CGAL/Periodic_2_triangulation_ds_face_base_2.h>
|
||||
#include <CGAL/Periodic_2_triangulation_ds_vertex_base_2.h>
|
||||
#include <CGAL/Periodic_2_triangulation_face_base_2.h>
|
||||
#include <CGAL/Periodic_2_triangulation_vertex_base_2.h>
|
||||
#include <CGAL/Periodic_2_triangulation_iterators_2.h>
|
||||
#include <CGAL/spatial_sort.h>
|
||||
|
||||
|
|
@ -57,10 +57,10 @@ namespace CGAL {
|
|||
/// - Insertion of points
|
||||
/// - Deletion of points
|
||||
/// - Point location
|
||||
template<class Gt, class Tds = Triangulation_data_structure_2<
|
||||
Periodic_2_triangulation_ds_vertex_base_2<Gt>,
|
||||
Triangulation_face_base_2<Gt,
|
||||
Periodic_2_triangulation_ds_face_base_2<> > > >
|
||||
template<class Gt,
|
||||
class Tds = Triangulation_data_structure_2<
|
||||
Periodic_2_triangulation_vertex_base_2<Gt>,
|
||||
Periodic_2_triangulation_face_base_2<Gt> > >
|
||||
class Periodic_2_triangulation_2: public Triangulation_cw_ccw_2 {
|
||||
typedef Periodic_2_triangulation_2<Gt, Tds> Self;
|
||||
|
||||
|
|
@ -1539,8 +1539,8 @@ Periodic_2_triangulation_2<Gt, Tds>::operator=(
|
|||
}
|
||||
|
||||
// Helping functions
|
||||
template < class GT, class TDS >
|
||||
class Periodic_2_triangulation_2<GT,TDS>::Finder {
|
||||
template < class GT, class Tds >
|
||||
class Periodic_2_triangulation_2<GT,Tds>::Finder {
|
||||
const Self* _t;
|
||||
const Point & _p;
|
||||
public:
|
||||
|
|
@ -1550,10 +1550,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template < class GT, class TDS >
|
||||
template < class GT, class Tds >
|
||||
inline void
|
||||
Periodic_2_triangulation_2<GT,TDS>::
|
||||
copy_multiple_covering(const Periodic_2_triangulation_2<GT,TDS> & tr) {
|
||||
Periodic_2_triangulation_2<GT,Tds>::
|
||||
copy_multiple_covering(const Periodic_2_triangulation_2<GT,Tds> & tr) {
|
||||
// Write the respective offsets in the vertices to make them
|
||||
// automatically copy with the tds.
|
||||
for (Vertex_iterator vit = tr.vertices_begin() ;
|
||||
|
|
@ -3308,8 +3308,8 @@ void Periodic_2_triangulation_2<Gt, Tds>::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<class GT, class TDS>
|
||||
inline int Periodic_2_triangulation_2<GT, TDS>::find_too_long_edges(std::map<
|
||||
template<class GT, class Tds>
|
||||
inline int Periodic_2_triangulation_2<GT, Tds>::find_too_long_edges(std::map<
|
||||
Vertex_handle, std::list<Vertex_handle> >& edges) const {
|
||||
Point p1, p2;
|
||||
int counter = 0;
|
||||
|
|
@ -3343,8 +3343,8 @@ inline int Periodic_2_triangulation_2<GT, TDS>::find_too_long_edges(std::map<
|
|||
* So if we are working in 3-cover we translate it to the neighboring
|
||||
* 3-cover and not only to the neighboring domain.
|
||||
*/
|
||||
template<class GT, class TDS>
|
||||
inline void Periodic_2_triangulation_2<GT, TDS>::get_vertex(Face_handle fh,
|
||||
template<class GT, class Tds>
|
||||
inline void Periodic_2_triangulation_2<GT, Tds>::get_vertex(Face_handle fh,
|
||||
int i, Vertex_handle &vh, Offset &off) const {
|
||||
off = combine_offsets(Offset(), int_to_off(fh->offset(i)));
|
||||
vh = fh->vertex(i);
|
||||
|
|
@ -3356,8 +3356,8 @@ inline void Periodic_2_triangulation_2<GT, TDS>::get_vertex(Face_handle fh,
|
|||
return;
|
||||
}
|
||||
|
||||
template<class GT, class TDS>
|
||||
inline void Periodic_2_triangulation_2<GT, TDS>::get_vertex(Vertex_handle vh_i,
|
||||
template<class GT, class Tds>
|
||||
inline void Periodic_2_triangulation_2<GT, Tds>::get_vertex(Vertex_handle vh_i,
|
||||
Vertex_handle &vh, Offset &off) const {
|
||||
Virtual_vertex_map_it it = _virtual_vertices.find(vh_i);
|
||||
|
||||
|
|
@ -3382,9 +3382,9 @@ inline void Periodic_2_triangulation_2<GT, TDS>::get_vertex(Vertex_handle vh_i,
|
|||
* Iterates over all faces and compare the three vertices of each face
|
||||
* with the three vertices in vh.
|
||||
*/
|
||||
template<class GT, class TDS>
|
||||
inline typename Periodic_2_triangulation_2<GT, TDS>::Face_handle Periodic_2_triangulation_2<
|
||||
GT, TDS>::get_face(const Vertex_handle* vh) const {
|
||||
template<class GT, class Tds>
|
||||
inline typename Periodic_2_triangulation_2<GT, Tds>::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);
|
||||
|
|
@ -3970,8 +3970,8 @@ bool Periodic_2_triangulation_2<Gt, Tds>::edge_is_too_long(const Point &p1,
|
|||
return squared_distance(p1, p2) > _edge_length_threshold;
|
||||
}
|
||||
|
||||
template<class GT, class TDS>
|
||||
inline bool Periodic_2_triangulation_2<GT, TDS>::is_extensible_triangulation_in_1_sheet_h1() const {
|
||||
template<class GT, class Tds>
|
||||
inline bool Periodic_2_triangulation_2<GT, Tds>::is_extensible_triangulation_in_1_sheet_h1() const {
|
||||
if (!is_1_cover()) {
|
||||
if (_too_long_edge_counter == 0)
|
||||
return true;
|
||||
|
|
@ -3990,8 +3990,8 @@ inline bool Periodic_2_triangulation_2<GT, TDS>::is_extensible_triangulation_in_
|
|||
}
|
||||
}
|
||||
|
||||
template<class GT, class TDS>
|
||||
inline bool Periodic_2_triangulation_2<GT, TDS>::is_extensible_triangulation_in_1_sheet_h2() const {
|
||||
template<class GT, class Tds>
|
||||
inline bool Periodic_2_triangulation_2<GT, Tds>::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 =
|
||||
|
|
@ -4009,8 +4009,8 @@ inline bool Periodic_2_triangulation_2<GT, TDS>::is_extensible_triangulation_in_
|
|||
return true;
|
||||
}
|
||||
|
||||
template<class GT, class TDS>
|
||||
inline bool Periodic_2_triangulation_2<GT, TDS>::is_triangulation_in_1_sheet() const {
|
||||
template<class GT, class Tds>
|
||||
inline bool Periodic_2_triangulation_2<GT, Tds>::is_triangulation_in_1_sheet() const {
|
||||
if (is_1_cover())
|
||||
return true;
|
||||
for (Vertex_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) {
|
||||
|
|
@ -4326,16 +4326,16 @@ namespace internal {
|
|||
|
||||
/// Internal function used by operator==.
|
||||
//TODO: introduce offsets
|
||||
template <class GT, class TDS1, class TDS2>
|
||||
template <class GT, class Tds1, class Tds2>
|
||||
bool
|
||||
test_next(const Periodic_2_triangulation_2<GT, TDS1> &t1,
|
||||
const Periodic_2_triangulation_2<GT, TDS2> &t2,
|
||||
typename Periodic_2_triangulation_2<GT, TDS1>::Face_handle c1,
|
||||
typename Periodic_2_triangulation_2<GT, TDS2>::Face_handle c2,
|
||||
std::map<typename Periodic_2_triangulation_2<GT, TDS1>::Face_handle,
|
||||
typename Periodic_2_triangulation_2<GT, TDS2>::Face_handle> &Cmap,
|
||||
std::map<typename Periodic_2_triangulation_2<GT, TDS1>::Vertex_handle,
|
||||
typename Periodic_2_triangulation_2<GT, TDS2>::Vertex_handle> &Vmap)
|
||||
test_next(const Periodic_2_triangulation_2<GT, Tds1> &t1,
|
||||
const Periodic_2_triangulation_2<GT, Tds2> &t2,
|
||||
typename Periodic_2_triangulation_2<GT, Tds1>::Face_handle c1,
|
||||
typename Periodic_2_triangulation_2<GT, Tds2>::Face_handle c2,
|
||||
std::map<typename Periodic_2_triangulation_2<GT, Tds1>::Face_handle,
|
||||
typename Periodic_2_triangulation_2<GT, Tds2>::Face_handle> &Cmap,
|
||||
std::map<typename Periodic_2_triangulation_2<GT, Tds1>::Vertex_handle,
|
||||
typename Periodic_2_triangulation_2<GT, Tds2>::Vertex_handle> &Vmap)
|
||||
{
|
||||
// This function tests and registers the 4 neighbors of c1/c2,
|
||||
// and recursively calls itself over them.
|
||||
|
|
@ -4348,8 +4348,8 @@ namespace internal {
|
|||
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<GT, TDS1> Tr1;
|
||||
typedef Periodic_2_triangulation_2<GT, TDS2> Tr2;
|
||||
typedef Periodic_2_triangulation_2<GT, Tds1> Tr1;
|
||||
typedef Periodic_2_triangulation_2<GT, Tds2> Tr2;
|
||||
typedef typename Tr1::Vertex_handle Vertex_handle1;
|
||||
typedef typename Tr1::Face_handle Face_handle1;
|
||||
typedef typename Tr2::Vertex_handle Vertex_handle2;
|
||||
|
|
@ -4414,27 +4414,27 @@ operator<<(std::ostream& os, Periodic_2_triangulation_2<Gt, Tds> &tr) {
|
|||
return tr.save(os);
|
||||
}
|
||||
|
||||
template < class GT, class TDS1, class TDS2 >
|
||||
template < class GT, class Tds1, class Tds2 >
|
||||
bool
|
||||
operator==(const Periodic_2_triangulation_2<GT,TDS1> &t1,
|
||||
const Periodic_2_triangulation_2<GT,TDS2> &t2)
|
||||
operator==(const Periodic_2_triangulation_2<GT,Tds1> &t1,
|
||||
const Periodic_2_triangulation_2<GT,Tds2> &t2)
|
||||
{
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS1>::Vertex_handle
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds1>::Vertex_handle
|
||||
Vertex_handle1;
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS1>::Face_handle
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds1>::Face_handle
|
||||
Face_handle1;
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS2>::Vertex_handle
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds2>::Vertex_handle
|
||||
Vertex_handle2;
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS2>::Vertex_handle
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds2>::Vertex_handle
|
||||
Vertex_iterator2;
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS2>::Face_handle
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds2>::Face_handle
|
||||
Face_handle2;
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS2>::Face_circulator
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds2>::Face_circulator
|
||||
Face_circulator2;
|
||||
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS1>::Point Point;
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS1>::Offset Offset;
|
||||
typedef typename Periodic_2_triangulation_2<GT,TDS1>
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds1>::Point Point;
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds1>::Offset Offset;
|
||||
typedef typename Periodic_2_triangulation_2<GT,Tds1>
|
||||
::Geom_traits::Compare_xy_2 Compare_xy_2;
|
||||
|
||||
// Some quick checks.
|
||||
|
|
@ -4515,11 +4515,11 @@ operator==(const Periodic_2_triangulation_2<GT,TDS1> &t1,
|
|||
Cmap.begin()->first, Cmap.begin()->second, Cmap, Vmap);
|
||||
}
|
||||
|
||||
template < class GT, class TDS1, class TDS2 >
|
||||
template < class GT, class Tds1, class Tds2 >
|
||||
inline
|
||||
bool
|
||||
operator!=(const Periodic_2_triangulation_2<GT,TDS1> &t1,
|
||||
const Periodic_2_triangulation_2<GT,TDS2> &t2)
|
||||
operator!=(const Periodic_2_triangulation_2<GT,Tds1> &t1,
|
||||
const Periodic_2_triangulation_2<GT,Tds2> &t2)
|
||||
{
|
||||
return ! (t1 == t2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,427 +0,0 @@
|
|||
// Copyright (c) 1997 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
// the terms of the Q Public License version 1.0.
|
||||
// See the file LICENSE.QPL distributed with CGAL.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
#ifndef CGAL_PERIODIC_2_TRIANGULATION_DS_FACE_BASE_2_H
|
||||
#define CGAL_PERIODIC_2_TRIANGULATION_DS_FACE_BASE_2_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/triangulation_assertions.h>
|
||||
#include <CGAL/Triangulation_utils_2.h>
|
||||
#include <CGAL/Dummy_tds_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template < typename TDS = void>
|
||||
class Periodic_2_triangulation_ds_face_base_2
|
||||
{
|
||||
public:
|
||||
typedef TDS Triangulation_data_structure;
|
||||
typedef typename TDS::Vertex_handle Vertex_handle;
|
||||
typedef typename TDS::Face_handle Face_handle;
|
||||
#ifdef CGAL_TDS2_DATA
|
||||
typedef typename TDS::Face_data TDS_data;
|
||||
#endif
|
||||
|
||||
template <typename TDS2>
|
||||
struct Rebind_TDS { typedef Periodic_2_triangulation_ds_face_base_2<TDS2> Other; };
|
||||
|
||||
private:
|
||||
Vertex_handle V[3];
|
||||
Face_handle N[3];
|
||||
#ifdef CGAL_TDS2_DATA
|
||||
TDS_data _tds_data;
|
||||
#endif
|
||||
|
||||
// 2 respective bits are the _offset in x and y
|
||||
// right to left:
|
||||
// bit[0]-bit[1]: vertex(0),
|
||||
// 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.
|
||||
// bit[6]: Used to convert 9 sheeted covering to a 1 sheeted covering
|
||||
unsigned char _off;
|
||||
|
||||
public:
|
||||
Periodic_2_triangulation_ds_face_base_2();
|
||||
Periodic_2_triangulation_ds_face_base_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2);
|
||||
Periodic_2_triangulation_ds_face_base_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Face_handle n0,
|
||||
Face_handle n1,
|
||||
Face_handle n2);
|
||||
|
||||
Vertex_handle vertex(int i) const;
|
||||
bool has_vertex(Vertex_handle v) const;
|
||||
bool has_vertex(Vertex_handle v, int& i) const ;
|
||||
int index(Vertex_handle v) const ;
|
||||
|
||||
Face_handle neighbor(int i) const ;
|
||||
bool has_neighbor(Face_handle n) const;
|
||||
bool has_neighbor(Face_handle n, int& i) const;
|
||||
int index(Face_handle n) const;
|
||||
|
||||
void set_vertex(int i, Vertex_handle v);
|
||||
void set_vertices();
|
||||
void set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2);
|
||||
void set_neighbor(int i, Face_handle n) ;
|
||||
void set_neighbors();
|
||||
void set_neighbors(Face_handle n0, Face_handle n1, Face_handle n2);
|
||||
void reorient();
|
||||
void ccw_permute();
|
||||
void cw_permute();
|
||||
|
||||
int dimension() const;
|
||||
//the following trivial is_valid to allow
|
||||
// the user of derived face base classes
|
||||
// to add their own purpose checking
|
||||
bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const
|
||||
{return true;}
|
||||
|
||||
// For use by Compact_container.
|
||||
void * for_compact_container() const {return N[0].for_compact_container(); }
|
||||
void * & for_compact_container() { return N[0].for_compact_container();}
|
||||
|
||||
|
||||
static int ccw(int i) {return Triangulation_cw_ccw_2::ccw(i);}
|
||||
static int cw(int i) {return Triangulation_cw_ccw_2::cw(i);}
|
||||
|
||||
#ifdef CGAL_TDS2_DATA
|
||||
// TDS internal data access functions.
|
||||
TDS_data& tds_data() { return _tds_data; }
|
||||
const TDS_data& tds_data() const { return _tds_data; }
|
||||
#endif
|
||||
|
||||
/// Periodic functions
|
||||
int offset(int i) const
|
||||
{
|
||||
CGAL_triangulation_precondition( i >= 0 && i < 3 );
|
||||
return ((_off>>2*i)&3);
|
||||
}
|
||||
bool has_zero_offsets() const {
|
||||
return (_off&63) == 0;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
void set_additional_flag(unsigned char b) {
|
||||
CGAL_assertion(b < 4);
|
||||
// 63=00111111
|
||||
_off = ((_off & 63) | (b<<6));
|
||||
}
|
||||
unsigned char get_additional_flag() {
|
||||
return (_off>>6);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <class TDS>
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
Periodic_2_triangulation_ds_face_base_2()
|
||||
: _off(0)
|
||||
{
|
||||
set_vertices();
|
||||
set_neighbors();
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
Periodic_2_triangulation_ds_face_base_2( Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2)
|
||||
: _off(0)
|
||||
{
|
||||
set_vertices(v0, v1, v2);
|
||||
set_neighbors();
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
Periodic_2_triangulation_ds_face_base_2(Vertex_handle v0,
|
||||
Vertex_handle v1,
|
||||
Vertex_handle v2,
|
||||
Face_handle n0,
|
||||
Face_handle n1,
|
||||
Face_handle n2)
|
||||
: _off(0)
|
||||
{
|
||||
set_vertices(v0, v1, v2);
|
||||
set_neighbors(n0, n1, n2);
|
||||
}
|
||||
|
||||
|
||||
template <class TDS>
|
||||
inline
|
||||
typename Periodic_2_triangulation_ds_face_base_2<TDS>::Vertex_handle
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS>::
|
||||
vertex(int i) const
|
||||
{
|
||||
CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2);
|
||||
return V[i];
|
||||
}
|
||||
|
||||
|
||||
template <class TDS>
|
||||
inline bool
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
has_vertex(Vertex_handle v) const
|
||||
{
|
||||
return (V[0] == v) || (V[1] == v) || (V[2]== v);
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline bool
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
has_vertex(Vertex_handle v, int& i) const
|
||||
{
|
||||
if (v == V[0]) {
|
||||
i = 0;
|
||||
return true;
|
||||
}
|
||||
if (v == V[1]) {
|
||||
i = 1;
|
||||
return true;
|
||||
}
|
||||
if (v == V[2]) {
|
||||
i = 2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline int
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
index(Vertex_handle v) const
|
||||
{
|
||||
if (v == V[0]) return 0;
|
||||
if (v == V[1]) return 1;
|
||||
CGAL_triangulation_assertion( v == V[2] );
|
||||
return 2;
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline
|
||||
typename Periodic_2_triangulation_ds_face_base_2<TDS>::Face_handle
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS>::
|
||||
neighbor(int i) const
|
||||
{
|
||||
CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2);
|
||||
return N[i];
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline bool
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
has_neighbor(Face_handle n) const
|
||||
{
|
||||
return (N[0] == n) || (N[1] == n) || (N[2] == n);
|
||||
}
|
||||
|
||||
|
||||
template <class TDS>
|
||||
inline bool
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
has_neighbor(Face_handle n, int& i) const
|
||||
{
|
||||
if(n == N[0]){
|
||||
i = 0;
|
||||
return true;
|
||||
}
|
||||
if(n == N[1]){
|
||||
i = 1;
|
||||
return true;
|
||||
}
|
||||
if(n == N[2]){
|
||||
i = 2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class TDS>
|
||||
inline int
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
index(Face_handle n) const
|
||||
{
|
||||
if (n == N[0]) return 0;
|
||||
if (n == N[1]) return 1;
|
||||
CGAL_triangulation_assertion( n == N[2] );
|
||||
return 2;
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
set_vertex(int i, Vertex_handle v)
|
||||
{
|
||||
CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2);
|
||||
V[i] = v;
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
set_neighbor(int i, Face_handle n)
|
||||
{
|
||||
CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2);
|
||||
CGAL_triangulation_precondition( this != &*n );
|
||||
N[i] = n;
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
set_vertices()
|
||||
{
|
||||
V[0] = V[1] = V[2] = Vertex_handle();
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2)
|
||||
{
|
||||
V[0] = v0;
|
||||
V[1] = v1;
|
||||
V[2] = v2;
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
set_neighbors()
|
||||
{
|
||||
N[0] = N[1] = N[2] = Face_handle();
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
set_neighbors(Face_handle n0,Face_handle n1, Face_handle n2)
|
||||
{
|
||||
CGAL_triangulation_precondition( this != &*n0 );
|
||||
CGAL_triangulation_precondition( this != &*n1 );
|
||||
CGAL_triangulation_precondition( this != &*n2 );
|
||||
N[0] = n0;
|
||||
N[1] = n1;
|
||||
N[2] = n2;
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
reorient()
|
||||
{
|
||||
//exchange the vertices 0 and 1
|
||||
set_vertices (V[1],V[0],V[2]);
|
||||
set_neighbors(N[1],N[0],N[2]);
|
||||
}
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
ccw_permute()
|
||||
{
|
||||
set_vertices (V[2],V[0],V[1]);
|
||||
set_neighbors(N[2],N[0],N[1]);
|
||||
}
|
||||
|
||||
|
||||
template <class TDS>
|
||||
inline void
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
cw_permute()
|
||||
{
|
||||
set_vertices (V[1],V[2],V[0]);
|
||||
set_neighbors(N[1],N[2],N[0]);
|
||||
}
|
||||
|
||||
|
||||
template < class TDS>
|
||||
inline int
|
||||
Periodic_2_triangulation_ds_face_base_2<TDS> ::
|
||||
dimension() const
|
||||
{
|
||||
if (V[2] != Vertex_handle()) {return 2;}
|
||||
else return( V[1] != Vertex_handle() ? 1 : 0);
|
||||
}
|
||||
|
||||
template < class TDS >
|
||||
inline
|
||||
std::istream&
|
||||
operator>>(std::istream &is, Periodic_2_triangulation_ds_face_base_2<TDS> &)
|
||||
// non combinatorial information. Default = nothing
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
template < class TDS >
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream &os, const Periodic_2_triangulation_ds_face_base_2<TDS> &)
|
||||
// non combinatorial information. Default = nothing
|
||||
{
|
||||
return os;
|
||||
}
|
||||
|
||||
// Specialisation for void.
|
||||
template <>
|
||||
class Periodic_2_triangulation_ds_face_base_2<void>
|
||||
{
|
||||
public:
|
||||
typedef Dummy_tds_2 Triangulation_data_structure;
|
||||
typedef Triangulation_data_structure::Vertex_handle Vertex_handle;
|
||||
typedef Triangulation_data_structure::Face_handle Face_handle;
|
||||
template <typename TDS2>
|
||||
struct Rebind_TDS { typedef Periodic_2_triangulation_ds_face_base_2<TDS2> Other; };
|
||||
};
|
||||
|
||||
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif //CGAL_PERIODIC_2_TRIANGULATION_DS_FACE_BASE_2_H
|
||||
|
|
@ -21,9 +21,9 @@
|
|||
#ifndef CGAL_PERIODIC_2_TRIANGULATION_DUMMY_12_H
|
||||
#define CGAL_PERIODIC_2_TRIANGULATION_DUMMY_12_H
|
||||
|
||||
template < class GT, class TDS >
|
||||
inline std::vector<typename Periodic_2_triangulation_2<GT,TDS>::Vertex_handle >
|
||||
Periodic_2_triangulation_2<GT,TDS>::insert_dummy_points() {
|
||||
template < class GT, class Tds >
|
||||
inline std::vector<typename Periodic_2_triangulation_2<GT,Tds>::Vertex_handle >
|
||||
Periodic_2_triangulation_2<GT,Tds>::insert_dummy_points() {
|
||||
clear();
|
||||
|
||||
Vertex_handle vertices[12];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
// Copyright (c) 1997 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
// the terms of the Q Public License version 1.0.
|
||||
// See the file LICENSE.QPL distributed with CGAL.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
#ifndef CGAL_PERIODIC_2_TRIANGULATION_FACE_BASE_2_H
|
||||
#define CGAL_PERIODIC_2_TRIANGULATION_FACE_BASE_2_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/triangulation_assertions.h>
|
||||
#include <CGAL/Triangulation_utils_2.h>
|
||||
#include <CGAL/Dummy_tds_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template < typename Gt, typename Fb = Triangulation_face_base_2<Gt> >
|
||||
class Periodic_2_triangulation_face_base_2
|
||||
: public Fb
|
||||
{
|
||||
typedef Fb Base;
|
||||
typedef typename Base::Triangulation_data_structure Tds;
|
||||
public:
|
||||
typedef Gt Geom_traits;
|
||||
typedef Tds Triangulation_data_structure;
|
||||
typedef typename Tds::Vertex_handle Vertex_handle;
|
||||
typedef typename Tds::Face_handle Face_handle;
|
||||
|
||||
template < typename TDS2 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
|
||||
typedef Periodic_2_triangulation_face_base_2<Gt, Fb2> Other;
|
||||
};
|
||||
|
||||
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,
|
||||
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);
|
||||
}
|
||||
bool has_zero_offsets() const {
|
||||
return (_off&63) == 0;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
void set_additional_flag(unsigned char b) {
|
||||
CGAL_assertion(b < 4);
|
||||
// 63=00111111
|
||||
_off = ((_off & 63) | (b<<6));
|
||||
}
|
||||
unsigned char get_additional_flag() {
|
||||
return (_off>>6);
|
||||
}
|
||||
|
||||
private:
|
||||
// 2 respective bits are the _offset in x and y
|
||||
// right to left:
|
||||
// bit[0]-bit[1]: vertex(0),
|
||||
// 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.
|
||||
// bit[6]: Used to convert 9 sheeted covering to a 1 sheeted covering
|
||||
unsigned char _off;
|
||||
};
|
||||
|
||||
template < class Tds >
|
||||
inline
|
||||
std::istream&
|
||||
operator>>(std::istream &is, Periodic_2_triangulation_face_base_2<Tds> &)
|
||||
// non combinatorial information. Default = nothing
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
template < class Tds >
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream &os, const Periodic_2_triangulation_face_base_2<Tds> &)
|
||||
// non combinatorial information. Default = nothing
|
||||
{
|
||||
return os;
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif //CGAL_PERIODIC_2_TRIANGULATION_FACE_BASE_2_H
|
||||
|
|
@ -0,0 +1,595 @@
|
|||
// Copyright (c) 1998-2010 INRIA Sophia-Antipolis (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Olivier Devillers <Olivivier.Devillers@sophia.inria.fr>
|
||||
// Mariette Yvinec <Mariette.Yvinec@sophia.inria.fr>
|
||||
|
||||
#ifndef CGAL_PERIODIC_2_TRIANGULATION_HIERARCHY_2_H
|
||||
#define CGAL_PERIODIC_2_TRIANGULATION_HIERARCHY_2_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Triangulation_hierarchy_vertex_base_2.h>
|
||||
#include <map>
|
||||
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <boost/random/geometric_distribution.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template < class PTr>
|
||||
class Periodic_2_triangulation_hierarchy_2
|
||||
: public PTr
|
||||
{
|
||||
// parameterization of the hierarchy
|
||||
static const int ratio = 30;
|
||||
static const int minsize = 20;
|
||||
static const int maxlevel = 5;
|
||||
// maximal number of points is 30^5 = 24 millions !
|
||||
|
||||
|
||||
public:
|
||||
typedef PTr PTr_Base;
|
||||
typedef typename PTr::Geom_traits Geom_traits;
|
||||
typedef typename PTr::Point Point;
|
||||
typedef typename PTr::Iso_rectangle Iso_rectangle;
|
||||
typedef typename PTr::size_type size_type;
|
||||
typedef typename PTr::Vertex_handle Vertex_handle;
|
||||
typedef typename PTr::Face_handle Face_handle;
|
||||
typedef typename PTr::Vertex Vertex;
|
||||
typedef typename PTr::Locate_type Locate_type;
|
||||
typedef typename PTr::Finite_vertices_iterator Finite_vertices_iterator;
|
||||
//typedef typename PTr::Finite_faces_iterator Finite_faces_iterator;
|
||||
|
||||
typedef typename PTr::Weighted_tag Weighted_tag;
|
||||
|
||||
#ifndef CGAL_CFG_USING_BASE_MEMBER_BUG_2
|
||||
using PTr_Base::geom_traits;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// here is the stack of triangulations which form the hierarchy
|
||||
PTr_Base* hierarchy[maxlevel];
|
||||
boost::rand48 random;
|
||||
int level_mult_cover;
|
||||
|
||||
public:
|
||||
Periodic_2_triangulation_hierarchy_2(
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
NGHK_NYI;
|
||||
hierarchy[0] = this;
|
||||
for(int i=1; i<maxlevel; ++i)
|
||||
hierarchy[i] = new PTr_Base(domain,traits);
|
||||
insert(first, last);
|
||||
}
|
||||
|
||||
Periodic_2_triangulation_hierarchy_2 &operator=(const Periodic_2_triangulation_hierarchy_2& tr);
|
||||
~Periodic_2_triangulation_hierarchy_2();
|
||||
|
||||
//Helping
|
||||
void copy_triangulation(const Periodic_2_triangulation_hierarchy_2 &tr);
|
||||
void swap(Periodic_2_triangulation_hierarchy_2 &tr);
|
||||
void clear();
|
||||
|
||||
// CHECKING
|
||||
bool is_valid(bool verbose = false, int level = 0) const;
|
||||
|
||||
// INSERT REMOVE MOVE
|
||||
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 );
|
||||
Vertex_handle push_back(const Point &p);
|
||||
|
||||
template < class InputIterator >
|
||||
std::ptrdiff_t insert(InputIterator first, InputIterator last, bool /* is_large_point_set */ = false)
|
||||
{
|
||||
NGHK_NYI;
|
||||
std::ptrdiff_t n = this->number_of_vertices();
|
||||
|
||||
std::vector<Point> points (first, last);
|
||||
CGAL::spatial_sort (points.begin(), points.end(), geom_traits());
|
||||
|
||||
// hints[i] is the face of the previously inserted point in level i.
|
||||
// Thanks to spatial sort, they are better hints than what the hierarchy
|
||||
// would give us.
|
||||
Face_handle hints[maxlevel];
|
||||
for (typename std::vector<Point>::const_iterator p = points.begin(), end = points.end();
|
||||
p != end; ++p)
|
||||
{
|
||||
int vertex_level = random_level();
|
||||
|
||||
Vertex_handle v = hierarchy[0]->insert (*p, hints[0]);
|
||||
hints[0] = v->face();
|
||||
|
||||
Vertex_handle prev = v;
|
||||
|
||||
for (int level = 1; level <= vertex_level; ++level) {
|
||||
v = hierarchy[level]->insert (*p, hints[level]);
|
||||
hints[level] = v->face();
|
||||
|
||||
v->set_down (prev);
|
||||
prev->set_up (v);
|
||||
prev = v;
|
||||
}
|
||||
}
|
||||
std::ptrdiff_t m = this->number_of_vertices();
|
||||
return m - n;
|
||||
}
|
||||
|
||||
void remove(Vertex_handle v);
|
||||
void remove_first(Vertex_handle v);
|
||||
void remove_degree_3(Vertex_handle v);
|
||||
|
||||
Vertex_handle move(Vertex_handle v, const Point &p);
|
||||
Vertex_handle move_if_no_collision(Vertex_handle v, const Point &p);
|
||||
|
||||
//LOCATE
|
||||
Face_handle
|
||||
locate(const Point& p,
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle start = Face_handle()) const;
|
||||
|
||||
Face_handle
|
||||
locate(const Point &p,
|
||||
Face_handle start = Face_handle()) const;
|
||||
|
||||
Vertex_handle
|
||||
nearest_vertex(const Point& p, Face_handle start = Face_handle()) const
|
||||
{
|
||||
NGHK_NYI; // TODO
|
||||
return Vertex_handle();
|
||||
// return nearest_vertex_dispatch<Tr>(p, start, Weighted_tag());
|
||||
}
|
||||
|
||||
private:
|
||||
void locate_in_all(const Point& p,
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle loc,
|
||||
Face_handle pos[maxlevel]) const;
|
||||
int random_level();
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class PTr >
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2(const Iso_rectangle& domain, const Geom_traits& traits)
|
||||
: PTr_Base(domain, traits)
|
||||
{
|
||||
hierarchy[0] = this;
|
||||
for(int i=1;i<maxlevel;++i)
|
||||
hierarchy[i] = new PTr_Base(domain, traits);
|
||||
}
|
||||
|
||||
|
||||
// copy constructor duplicates vertices and faces
|
||||
template <class PTr>
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
Periodic_2_triangulation_hierarchy_2(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
||||
: PTr_Base()
|
||||
{
|
||||
NGHK_NYI;
|
||||
// create an empty triangulation to be able to delete it !
|
||||
hierarchy[0] = this;
|
||||
for(int i=1;i<maxlevel;++i)
|
||||
hierarchy[i] = new PTr_Base(tr.geom_traits());
|
||||
copy_triangulation(tr);
|
||||
}
|
||||
|
||||
|
||||
//Assignement
|
||||
template <class PTr>
|
||||
Periodic_2_triangulation_hierarchy_2<PTr> &
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
operator=(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
||||
{
|
||||
NGHK_NYI;
|
||||
Periodic_2_triangulation_hierarchy_2 tmp(tr);
|
||||
swap(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
copy_triangulation(const Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
||||
{
|
||||
NGHK_NYI;
|
||||
{
|
||||
for(int i=0;i<maxlevel;++i)
|
||||
hierarchy[i]->copy_triangulation(*tr.hierarchy[i]);
|
||||
}
|
||||
|
||||
|
||||
//up and down have been copied in straightforward way
|
||||
// compute a map at lower level
|
||||
std::map<Vertex_handle, Vertex_handle > V;
|
||||
{
|
||||
for( Finite_vertices_iterator it=hierarchy[0]->finite_vertices_begin();
|
||||
it != hierarchy[0]->finite_vertices_end(); ++it) {
|
||||
if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it;
|
||||
}
|
||||
}
|
||||
|
||||
add_hidden_vertices_into_map(Weighted_tag(), V);
|
||||
|
||||
{
|
||||
for(int i=1;i<maxlevel;++i) {
|
||||
for( Finite_vertices_iterator it=hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* template <class PTr> */
|
||||
/* void */
|
||||
/* Periodic_2_triangulation_hierarchy_2<PTr>:: */
|
||||
/* add_hidden_vertices_into_map(Tag_false, */
|
||||
/* std::map<Vertex_handle,Vertex_handle >& V) { */
|
||||
/* return; */
|
||||
/* } */
|
||||
|
||||
|
||||
/* template <class PTr> */
|
||||
/* void */
|
||||
/* Periodic_2_triangulation_hierarchy_2<PTr>:: */
|
||||
/* add_hidden_vertices_into_map(Tag_true, */
|
||||
/* std::map<Vertex_handle,Vertex_handle >& V) */
|
||||
/* { */
|
||||
/* for (typename PTr_Base::Hidden_vertices_iterator */
|
||||
/* it=hierarchy[0]->hidden_vertices_begin(); */
|
||||
/* it != hierarchy[0]->hidden_vertices_end(); ++it) { */
|
||||
/* if (it->up() != Vertex_handle()) V[ it->up()->down() ] = it; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
swap(Periodic_2_triangulation_hierarchy_2<PTr> &tr)
|
||||
{
|
||||
NGHK_NYI;
|
||||
PTr_Base* temp;
|
||||
PTr_Base::swap(tr);
|
||||
for(int i= 1; i<maxlevel; ++i){
|
||||
temp = hierarchy[i];
|
||||
hierarchy[i] = tr.hierarchy[i];
|
||||
tr.hierarchy[i]= temp;
|
||||
}
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
~Periodic_2_triangulation_hierarchy_2()
|
||||
{
|
||||
clear();
|
||||
for(int i= 1; i<maxlevel; ++i){
|
||||
delete hierarchy[i];
|
||||
}
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
clear()
|
||||
{
|
||||
NGHK_NYI;
|
||||
for(int i=0;i<maxlevel;++i)
|
||||
hierarchy[i]->clear();
|
||||
}
|
||||
|
||||
|
||||
template <class PTr>
|
||||
bool
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
is_valid(bool verbose, int level) const
|
||||
{
|
||||
NGHK_NYI;
|
||||
bool result = true;
|
||||
int i;
|
||||
Finite_vertices_iterator it;
|
||||
//verify correctness of triangulation at all levels
|
||||
for(i=0;i<maxlevel;++i) {
|
||||
if(verbose) // pirnt 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)
|
||||
result = result && ( it->down() == Vertex_handle());
|
||||
//verify that other levels have down pointer and reciprocal link is fine
|
||||
for(i=1;i<maxlevel;++i)
|
||||
for( it = hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it)
|
||||
result = result &&
|
||||
( &*(it->down()->up()) == &*(it) );
|
||||
//verify that levels have up pointer and reciprocal link is fine
|
||||
for(i=0;i<maxlevel-1;++i)
|
||||
for( it = hierarchy[i]->finite_vertices_begin();
|
||||
it != hierarchy[i]->finite_vertices_end(); ++it)
|
||||
result = result && ( it->up() == Vertex_handle() ||
|
||||
&*it == &*(it->up())->down() );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
insert(const Point &p, Face_handle loc)
|
||||
{
|
||||
NGHK_NYI;
|
||||
int vertex_level = random_level();
|
||||
Locate_type lt;
|
||||
int i;
|
||||
// locate using hierarchy
|
||||
Face_handle positions[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;
|
||||
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
|
||||
previous->set_up(vertex);
|
||||
previous=vertex;
|
||||
level++;
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
insert(const Point& p,
|
||||
Locate_type lt,
|
||||
Face_handle loc,
|
||||
int li )
|
||||
{
|
||||
NGHK_NYI;
|
||||
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 first = vertex;
|
||||
|
||||
if (vertex_level > 0) {
|
||||
// locate using hierarchy
|
||||
Locate_type ltt;
|
||||
int lii;
|
||||
Face_handle positions[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
|
||||
previous->set_up(vertex);
|
||||
previous=vertex;
|
||||
level++;
|
||||
}
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
inline
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
push_back(const Point &p)
|
||||
{
|
||||
return insert(p);
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
remove(Vertex_handle v )
|
||||
{
|
||||
NGHK_NYI;
|
||||
Vertex_handle u=v->up();
|
||||
int l = 0 ;
|
||||
while(1){
|
||||
hierarchy[l++]->remove(v);
|
||||
if (u == Vertex_handle()) break;
|
||||
if (l >= maxlevel) break;
|
||||
v=u; u=v->up();
|
||||
}
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
inline void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
remove_degree_3(Vertex_handle v )
|
||||
{
|
||||
NGHK_NYI;
|
||||
remove(v);
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
inline void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
remove_first(Vertex_handle v )
|
||||
{
|
||||
NGHK_NYI;
|
||||
remove(v);
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
move_if_no_collision(Vertex_handle v, const Point &p) {
|
||||
NGHK_NYI;
|
||||
Vertex_handle u=v->up(), norm = v;
|
||||
int l = 0 ;
|
||||
while(1) {
|
||||
Vertex_handle w = hierarchy[l++]->move_if_no_collision(v, p);
|
||||
if(w != v) return w;
|
||||
if (u == Vertex_handle()) break;
|
||||
if (l >= maxlevel) break;
|
||||
v=u; u=v->up();
|
||||
}
|
||||
return norm;
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Vertex_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
move(Vertex_handle v, const Point &p) {
|
||||
NGHK_NYI;
|
||||
CGAL_triangulation_precondition(!this->is_infinite(v));
|
||||
Vertex_handle w = move_if_no_collision(v,p);
|
||||
if(w != v) {
|
||||
remove(v);
|
||||
return w;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Face_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
locate(const Point& p, Locate_type& lt, int& li, Face_handle loc) const
|
||||
{
|
||||
NGHK_NYI;
|
||||
Face_handle positions[maxlevel];
|
||||
locate_in_all(p,lt,li,loc,positions);
|
||||
return positions[0];
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
typename Periodic_2_triangulation_hierarchy_2<PTr>::Face_handle
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
locate(const Point& p, Face_handle loc ) const
|
||||
{
|
||||
NGHK_NYI;
|
||||
Locate_type lt;
|
||||
int li;
|
||||
return locate(p, lt, li, loc);
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
void
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
locate_in_all(const Point& p,
|
||||
Locate_type& lt,
|
||||
int& li,
|
||||
Face_handle loc,
|
||||
Face_handle pos[maxlevel]) const
|
||||
{
|
||||
NGHK_NYI;
|
||||
Face_handle position;
|
||||
Vertex_handle nearest;
|
||||
int level = maxlevel;
|
||||
typename Geom_traits::Compare_distance_2
|
||||
closer = this->geom_traits().compare_distance_2_object();
|
||||
|
||||
// find the highest level with enough vertices that is at the same time 2D
|
||||
while ( (hierarchy[--level]->number_of_vertices()
|
||||
< static_cast<size_type> (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<maxlevel;++i) pos[i]=0;
|
||||
while(level > 0) {
|
||||
pos[level]=position=hierarchy[level]->locate(p,position);
|
||||
// locate at that level from "position"
|
||||
// result is stored in "position" for the next level
|
||||
// find the nearest between vertices 0 and 1
|
||||
if (hierarchy[level]->is_infinite(position->vertex(0))){
|
||||
|
||||
nearest = position->vertex(1);
|
||||
}
|
||||
else if (hierarchy[level]->is_infinite(position->vertex(1))){
|
||||
nearest = position->vertex(0);
|
||||
} else if ( closer(p,
|
||||
position->vertex(0)->point(),
|
||||
position->vertex(1)->point()) == SMALLER){
|
||||
nearest = position->vertex(0);
|
||||
}
|
||||
else{
|
||||
nearest = position->vertex(1);
|
||||
}
|
||||
// compare to vertex 2, but only if the triangulation is 2D, because otherwise vertex(2) is NULL
|
||||
if ( (hierarchy[level]->dimension()==2) && (! hierarchy[level]->is_infinite(position->vertex(2)))){
|
||||
if ( closer( p,
|
||||
position->vertex(2)->point(),
|
||||
nearest->point()) == SMALLER ){
|
||||
nearest = position->vertex(2);
|
||||
}
|
||||
}
|
||||
// go at the same vertex on level below
|
||||
nearest = nearest->down();
|
||||
position = nearest->face(); // incident face
|
||||
--level;
|
||||
}
|
||||
pos[0]=hierarchy[0]->locate(p,lt,li,loc == Face_handle() ? position : loc); // at level 0
|
||||
}
|
||||
|
||||
template <class PTr>
|
||||
int
|
||||
Periodic_2_triangulation_hierarchy_2<PTr>::
|
||||
random_level()
|
||||
{
|
||||
NGHK_NYI;
|
||||
if ( level_mult_cover < maxlevel
|
||||
&& hierarchy[level_mult_cover]->number_of_sheets() == make_array(1,1) )
|
||||
++level_mult_cover;
|
||||
|
||||
boost::geometric_distribution<> proba(1.0/ratio);
|
||||
boost::variate_generator<boost::rand48&, boost::geometric_distribution<> >
|
||||
die(random, proba);
|
||||
return (std::min)(die()-1, level_mult_cover);
|
||||
}
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif // CGAL_PERIODIC_2_TRIANGULATION_HIERARCHY_2_H
|
||||
|
|
@ -29,7 +29,7 @@ template < class T >
|
|||
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
|
||||
// - STORED: output each primitive from the Tds exactly once
|
||||
// - UNIQUE: output exactly one periodic copy of each primitive, no matter
|
||||
// whether the current tds stores a n-sheeted covering for n!=1.
|
||||
// - STORED_COVER_DOMAIN: output each primitive whose intersection with the
|
||||
|
|
@ -304,7 +304,7 @@ template < class T >
|
|||
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
|
||||
// - STORED: output each primitive from the Tds exactly once
|
||||
// - UNIQUE: output exactly one periodic copy of each primitive, no matter
|
||||
// whether the current tds stores a n-sheeted covering for n!=1.
|
||||
// - STORED_COVER_DOMAIN: output each primitive whose intersection with the
|
||||
|
|
@ -558,7 +558,7 @@ template < class T >
|
|||
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
|
||||
// - STORED: output each primitive from the Tds exactly once
|
||||
// - UNIQUE: output exactly one periodic copy of each primitive, no matter
|
||||
// whether the current tds stores a n-sheeted covering for n!=1.
|
||||
// - STORED_COVER_DOMAIN: output each primitive whose intersection with the
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@
|
|||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL: svn+ssh://nicokruithof@scm.gforge.inria.fr/svnroot/cgal/trunk/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_ds_vertex_base_2.h $
|
||||
// $Id: Periodic_2_triangulation_ds_vertex_base_2.h 56667 2010-06-09 07:37:13Z sloriot $
|
||||
// $URL: svn+ssh://nicokruithof@scm.gforge.inria.fr/svnroot/cgal/trunk/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_vertex_base_2.h $
|
||||
// $Id: Periodic_2_triangulation_vertex_base_2.h 56667 2010-06-09 07:37:13Z sloriot $
|
||||
//
|
||||
//
|
||||
// Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr>
|
||||
// Manuel Caroli <Manuel.Caroli@sophia.inria.fr>
|
||||
// Nico Kruithof <Nico@nghk.nl>
|
||||
|
||||
#ifndef CGAL_PERIODIC_2_TRIANGULATION_DS_VERTEX_BASE_2_H
|
||||
#define CGAL_PERIODIC_2_TRIANGULATION_DS_VERTEX_BASE_2_H
|
||||
#ifndef CGAL_PERIODIC_2_TRIANGULATION_VERTEX_BASE_2_H
|
||||
#define CGAL_PERIODIC_2_TRIANGULATION_VERTEX_BASE_2_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Dummy_tds_2.h>
|
||||
|
|
@ -29,31 +29,34 @@
|
|||
namespace CGAL {
|
||||
|
||||
|
||||
/* A vertex class with an additionnal handle */
|
||||
template < class Gt, class Vb = CGAL::Triangulation_vertex_base_2<Gt> >
|
||||
class Periodic_2_triangulation_ds_vertex_base_2
|
||||
: public Vb
|
||||
class Periodic_2_triangulation_vertex_base_2
|
||||
: public Vb
|
||||
{
|
||||
typedef Vb Base;
|
||||
typedef Vb Base;
|
||||
typedef typename Vb::Triangulation_data_structure Tds;
|
||||
public:
|
||||
typedef typename Vb::Vertex_handle Vertex_handle;
|
||||
typedef typename Vb::Face_handle Face_handle;
|
||||
typedef typename Vb::Point Point;
|
||||
typedef Periodic_2_offset_2 Offset;
|
||||
typedef Gt Geom_traits;
|
||||
typedef typename Gt::Point_2 Point;
|
||||
typedef Tds Triangulation_data_structure;
|
||||
typedef typename Tds::Face_handle Face_handle;
|
||||
typedef typename Tds::Vertex_handle Vertex_handle;
|
||||
|
||||
template < typename TDS2 >
|
||||
typedef Periodic_2_offset_2 Offset;
|
||||
|
||||
template < typename Tds2 >
|
||||
struct Rebind_TDS {
|
||||
typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2;
|
||||
typedef Periodic_2_triangulation_ds_vertex_base_2<Gt,Vb2> Other;
|
||||
typedef typename Vb::template Rebind_TDS<Tds2>::Other Vb2;
|
||||
typedef Periodic_2_triangulation_vertex_base_2<Gt,Vb2> Other;
|
||||
};
|
||||
|
||||
public:
|
||||
Periodic_2_triangulation_ds_vertex_base_2() : Base() {}
|
||||
Periodic_2_triangulation_ds_vertex_base_2(const Point & p)
|
||||
Periodic_2_triangulation_vertex_base_2() : Base() {}
|
||||
Periodic_2_triangulation_vertex_base_2(const Point & p)
|
||||
: Base(p), _off(), _offset_flag(false) {}
|
||||
Periodic_2_triangulation_ds_vertex_base_2(const Point & p, Face_handle f)
|
||||
Periodic_2_triangulation_vertex_base_2(const Point & p, Face_handle f)
|
||||
: Base(f,p), _off(), _offset_flag(false) {}
|
||||
Periodic_2_triangulation_ds_vertex_base_2(Face_handle f)
|
||||
Periodic_2_triangulation_vertex_base_2(Face_handle f)
|
||||
: Base(f), _off(), _offset_flag(false) {}
|
||||
|
||||
const Offset& offset() const {
|
||||
|
|
@ -83,35 +86,22 @@ private:
|
|||
Offset _off;
|
||||
/// The flag is used to test whether _off has been set.
|
||||
bool _offset_flag;
|
||||
|
||||
|
||||
// // For use by the Compact_container.
|
||||
// void * for_compact_container() const
|
||||
// { return _c.for_compact_container(); }
|
||||
// void * & for_compact_container()
|
||||
// { return _c.for_compact_container(); }
|
||||
|
||||
// private:
|
||||
// Face_handle _c;
|
||||
// Offset _off;
|
||||
// int _index;
|
||||
// bool _offset_flag;
|
||||
};
|
||||
|
||||
template < class TDS >
|
||||
template < class Tds >
|
||||
inline
|
||||
std::istream&
|
||||
operator>>(std::istream &is, Periodic_2_triangulation_ds_vertex_base_2<TDS> &)
|
||||
operator>>(std::istream &is, Periodic_2_triangulation_vertex_base_2<Tds> &)
|
||||
// no combinatorial information.
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
template < class TDS >
|
||||
template < class Tds >
|
||||
inline
|
||||
std::ostream&
|
||||
operator<<(std::ostream &os,
|
||||
const Periodic_2_triangulation_ds_vertex_base_2<TDS> &)
|
||||
const Periodic_2_triangulation_vertex_base_2<Tds> &)
|
||||
// no combinatorial information.
|
||||
{
|
||||
return os;
|
||||
|
|
@ -119,18 +109,18 @@ operator<<(std::ostream &os,
|
|||
|
||||
// Specialization for void.
|
||||
template <>
|
||||
class Periodic_2_triangulation_ds_vertex_base_2<void>
|
||||
class Periodic_2_triangulation_vertex_base_2<void>
|
||||
{
|
||||
public:
|
||||
typedef Dummy_tds_2 Triangulation_data_structure;
|
||||
typedef Triangulation_data_structure::Vertex_handle Vertex_handle;
|
||||
typedef Triangulation_data_structure::Face_handle Face_handle;
|
||||
template <typename TDS2>
|
||||
struct Rebind_TDS {
|
||||
typedef Periodic_2_triangulation_ds_vertex_base_2<TDS2> Other;
|
||||
template <typename Tds2>
|
||||
struct Rebind_Tds {
|
||||
typedef Periodic_2_triangulation_vertex_base_2<Tds2> Other;
|
||||
};
|
||||
};
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#endif // CGAL_PERIODIC_2_TRIANGULATION_DS_VERTEX_BASE_2_H
|
||||
#endif // CGAL_PERIODIC_2_TRIANGULATION_VERTEX_BASE_2_H
|
||||
|
|
@ -497,8 +497,11 @@ int main() {
|
|||
|
||||
test<P2T2>();
|
||||
test<DP2T2>();
|
||||
// test<PTH_Dt>();
|
||||
// test<Delaunay_triangulation_hierarchy>();
|
||||
|
||||
test_nearest<DP2T2>();
|
||||
// test_nearest<Delaunay_triangulation_hierarchy>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include <CGAL/Periodic_2_triangulation_traits_2.h>
|
||||
#include <CGAL/Periodic_2_triangulation_2.h>
|
||||
#include <CGAL/Periodic_2_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Periodic_2_triangulation_hierarchy_2.h>
|
||||
// #include <CGAL/Periodic_2_triangulation_hierarchy_vertex_base_2.h>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
|
@ -41,7 +43,14 @@ typedef Triangulation::Periodic_triangle_iterator Periodic_triangle_iterator;
|
|||
|
||||
typedef Periodic_2_Delaunay_triangulation_2<Gt> Delaunay_triangulation;
|
||||
|
||||
typedef CGAL::Creator_uniform_2<double,Point> Creator;
|
||||
typedef CGAL::Random_points_in_square_2<Point, Creator> Random_points_in_square;
|
||||
typedef CGAL::Random_points_on_circle_2<Point, Creator> Random_points_on_circle;
|
||||
typedef Periodic_2_triangulation_vertex_base_2<Gt> PTH_Vbb;
|
||||
typedef Triangulation_hierarchy_vertex_base_2<PTH_Vbb> PTH_Vb;
|
||||
typedef Periodic_2_triangulation_face_base_2<Gt> PTH_Fb;
|
||||
typedef Triangulation_data_structure_2<PTH_Vb, PTH_Fb> PTH_Tds;
|
||||
typedef Periodic_2_Delaunay_triangulation_2<Gt, PTH_Tds> PTH_Dt;
|
||||
typedef Periodic_2_triangulation_hierarchy_2<PTH_Dt> Delaunay_triangulation_hierarchy;
|
||||
|
||||
typedef Creator_uniform_2<double,Point> Creator;
|
||||
typedef Random_points_in_square_2<Point, Creator> Random_points_in_square;
|
||||
typedef Random_points_on_circle_2<Point, Creator> Random_points_on_circle;
|
||||
#endif // P2T2_UNIT_TEST_TYPES_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue