mirror of https://github.com/CGAL/cgal
smoothing doc and examples
This commit is contained in:
parent
ccf1c2c7bb
commit
65a497f793
|
|
@ -1,8 +1,9 @@
|
|||
#include <CGAL/point_generators_d.h>
|
||||
#include <CGAL/Cartesian_d.h>
|
||||
//#include <CGAL/Simple_cartesian_d.h>
|
||||
//#include <CGAL/Filtered_kernel_d.h>
|
||||
#include <CGAL/Delaunay_triangulation.h>
|
||||
#include <CGAL/point_generators_d.h>
|
||||
#include <CGAL/Timer.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
|
@ -10,10 +11,9 @@
|
|||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
template<typename DT>
|
||||
void test(const int d, const string & type, const int N)
|
||||
void test(const int d, const std::string & type, const int N)
|
||||
{
|
||||
typedef typename DT::Vertex Vertex;
|
||||
typedef typename DT::Vertex_handle Vertex_handle;
|
||||
|
|
@ -25,19 +25,25 @@ void test(const int d, const string & type, const int N)
|
|||
typedef typename DT::Finite_full_cell_const_iterator Finite_full_cell_const_iterator;
|
||||
|
||||
typedef CGAL::Random_points_in_iso_box_d<Point> Random_points_iterator;
|
||||
CGAL::Timer cost; // timer
|
||||
|
||||
DT dt(d);
|
||||
cout << "\nBench'ing Delaunay_triangulation of (" << type << d << ") dimension with " << N << " points";
|
||||
assert(dt.empty());
|
||||
|
||||
vector<Point> points;
|
||||
std::vector<Point> points;
|
||||
CGAL::Random rng;
|
||||
Random_points_iterator rand_it(d, 2.0, rng);
|
||||
CGAL::copy_n(rand_it, N, std::back_inserter(points));
|
||||
cost.reset();cost.start();
|
||||
std::cout << " Delaunay triangulation of "<<N<<" points in dim "<<d<< std::flush;
|
||||
dt.insert(points.begin(), points.end());
|
||||
int nbfs(0);
|
||||
cout << '\n' << dt.number_of_vertices() << " vertices, " << (nbfs = dt.number_of_finite_simplices())
|
||||
<< " finite simplices and " << (dt.number_of_simplices() - nbfs) << " convex hull Facets.";
|
||||
std::cout << " done in "<<cost.time()<<" seconds." << std::endl;
|
||||
int nbfc= dt.number_of_finite_full_cells();
|
||||
int nbc= dt.number_of_full_cells();
|
||||
std::cout << dt.number_of_vertices() << " vertices, "
|
||||
<< nbfc << " finite simplices and "
|
||||
<< (nbc-nbfc) << " convex hull Facets."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
template< int D, typename RT >
|
||||
|
|
@ -53,18 +59,14 @@ void go(const int N)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
srand48(time(NULL));
|
||||
int N = 10;
|
||||
if( argc > 1 )
|
||||
N = atoi(argv[1]);
|
||||
// go<7>(N);
|
||||
// go<6>(N);
|
||||
// go<5>(N);
|
||||
int N = 100; if( argc > 1 ) N = atoi(argv[1]);
|
||||
go<2, double>(N);
|
||||
go<3, double>(N);
|
||||
go<4, double>(N);
|
||||
// go<3>(N);
|
||||
// go<2>(N);
|
||||
// go<2>(N);
|
||||
// go<1>(N);
|
||||
go<5, double>(N);
|
||||
go<6, double>(N);
|
||||
go<7, double>(N);
|
||||
|
||||
|
||||
cout << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ vertices $V$ and consists of a collection $S$ of subsets of $V$ such that
|
|||
\item if $s$ is a set of vertices in $S$, then all the subsets of $s$ are also
|
||||
in $S$.
|
||||
\end{itemize}
|
||||
See the
|
||||
\ccAnchor{http://en.wikipedia.org/wiki/Abstract_simplicial_complex}{wikipedia
|
||||
entry} for more about abstract simplicial complexes.
|
||||
|
||||
The sets in $S$ (which are subsets of $V$) are called
|
||||
\textbf{faces} or \textbf{simplices} (the
|
||||
|
|
@ -68,9 +65,9 @@ supports deletion of vertices.
|
|||
%The class \ccc{CGAL::Regular_triangulation<RegularTraits, TDS>} is a generalization of
|
||||
%the Delaunay triangulation.
|
||||
|
||||
The rest of this user manual gives more details about these classes and the
|
||||
data they store, but does not tell the whole story. For the latter, the user
|
||||
should have a look at the reference manual of this package.
|
||||
%The rest of this user manual gives more details about these classes and the
|
||||
%data they store, but does not tell the whole story. For the latter, the user
|
||||
%should have a look at the reference manual of this package.
|
||||
|
||||
%A last remark:
|
||||
%pure complexes are also called \emph{triangulations}. We feel more confortable
|
||||
|
|
@ -142,7 +139,8 @@ It always holds that $-2\leq\cd\leq\ad$ and $0<\ad$.
|
|||
|
||||
In a first approximation, a \tds\ can be viewed as
|
||||
a \emph{triangulation} of the topological sphere $\sphere^\cd$,
|
||||
\emph{i.e.}, its faces can be embedded to form a partition of $\sphere^\cd$ into $\cd$-simplices. When a
|
||||
\emph{i.e.}, its faces can be embedded to form a partition of
|
||||
$\sphere^\cd$ into $\cd$-simplices. When a
|
||||
\tds\ is used as the combinatorial part of a geometric triangulation, one
|
||||
special vertex of the \tds\ plays the role of the \textbf{vertex at
|
||||
infinity}; we can consider that the triangulation covers the whole
|
||||
|
|
@ -163,8 +161,8 @@ Possible values of $\cd$ (the \emph{current dimension} of the triangulation) inc
|
|||
the \tds.
|
||||
\item[$\cd=-1$] This corresponds to a single vertex and a single cell. In a
|
||||
geometric triangulation, this vertex corresponds to the vertex at infinity.
|
||||
\item[$\cd=0$] This corresponds to two vertices, each corresponding to
|
||||
a cell;
|
||||
\item[$\cd=0$] This corresponds to two vertices (geometrically, the finite vertex and
|
||||
the infinite vertex), each corresponding to a cell;
|
||||
The two cells being neighbor of each other. This is the unique
|
||||
triangulation of the $0$-sphere.
|
||||
\item[$0<\cd\le\ad$] This corresponds to a standard triangulation of
|
||||
|
|
@ -319,8 +317,9 @@ as various geometric predicates used by the \ccc{Triangulation} class.
|
|||
|
||||
The following example shows how to construct a triangulation in which we insert
|
||||
random points. In \ccc{STEP 1}, we generate one hundred random points in
|
||||
$\real^5$, which we then insert into a triangulation. In \ccc{STEP 2}, we have
|
||||
a little fun and ask the triangulation to construct the set of edges
|
||||
$\real^5$, which we then insert into a triangulation. In \ccc{STEP 2}, we
|
||||
%have a little fun and
|
||||
ask the triangulation to construct the set of edges
|
||||
($1$-cells) incident to the vertex at infinity. It is easy to see that
|
||||
these edges are in bijection with the vertices on the convex hull of the
|
||||
points. This gives us a handy way to count the convex hull vertices. (Note that
|
||||
|
|
@ -479,16 +478,16 @@ for( pit = points.begin(); pit != points.end(); ++pit )
|
|||
else
|
||||
{
|
||||
typedef std::vector<Full_cell_handle> Full_cells;
|
||||
Full_cells conflict_zone, new_full_cells;
|
||||
std::back_insert_iterator<Full_cells> out(conflict_zone);
|
||||
Full_cells zone, new_full_cells;
|
||||
std::back_insert_iterator<Full_cells> out(zone);
|
||||
Facet ftc = t.compute_conflict_zone(*pit, s, out);
|
||||
/*----------------------------------------------------\
|
||||
| Here, do something with the conflict zone cells |
|
||||
| stored in |conflict_zone|. |
|
||||
| DO NOT MODIFY the vector |conflict_zone|. |
|
||||
| stored in |zone|. |
|
||||
| DO NOT MODIFY the vector |zone|. |
|
||||
\----------------------------------------------------*/
|
||||
out = std::back_inserter(new_full_cells);
|
||||
v = t.insert_in_hole(p, conflict_zone.begin(), conflict_zone.end(), ftc, out);
|
||||
v = t.insert_in_hole(p, zone.begin(), zone.end(), ftc, out);
|
||||
/*----------------------------------------------------\
|
||||
| Here, do something with the newly created cells |
|
||||
| stored in |new_full_cells|. |
|
||||
|
|
@ -503,8 +502,8 @@ for( pit = points.begin(); pit != points.end(); ++pit )
|
|||
|
||||
\section{Design and Implementation History}
|
||||
|
||||
This package is heavily inspired by the works of Michael Seel
|
||||
(\ccc{Kernel_d}), Monique Teillaud and Sylvain Pion (\ccc{Triangulation_3})
|
||||
This package is heavily inspired by the works of
|
||||
Monique Teillaud and Sylvain Pion (\ccc{Triangulation_3})
|
||||
and Mariette Yvinec (\ccc{Triangulation_2}).
|
||||
The first version was written by Samuel Hornus and then
|
||||
pursued by Samuel Hornus and Olivier Devillers.
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ to ``close it''. A \ccc{Vertex_handle} to the new \ccc{Vertex} is returned.
|
|||
all of whose incident simplices are in $C$. (This implies that
|
||||
\ccVar.\ccc{current_dimension()}$\geq2$ if $|C|>1$.)\\ The boundary of
|
||||
$C$ must be a (combinatorial) triangulation of the sphere
|
||||
$\sphere^{d-1}$.}
|
||||
$\sphere^{d-1}$. $f$ must be on the boundary of $C$.}
|
||||
\ccGlue
|
||||
\ccMethod{template< class ForwardIterator, class OutputIterator >
|
||||
Vertex_handle insert_in_hole(ForwardIterator start, ForwardIterator end, Facet
|
||||
|
|
@ -422,8 +422,10 @@ full cell is such that, if \ccc{f} was a cell of maximal dimension in the
|
|||
initial complex, then \ccc{(f,v)}, in this order, is the corresponding cell
|
||||
in the updated triangulation. A handle to \ccc{v} is returned.
|
||||
\ccPrecond\ccVar.
|
||||
The current dimension is strictly less than the ambient dimension
|
||||
and \ccc{star} is a vertex of \ccVar.}
|
||||
If the current dimension is -2 (empty triangulation), then \ccc{star}
|
||||
has to be ommitted, otherwise
|
||||
the current dimension must be strictly less than the ambient dimension
|
||||
and \ccc{star} must be a vertex of \ccVar.}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,40 @@
|
|||
\ccRefChapter{Triangulations\label{chap:triangulation_ref}}
|
||||
\ccChapterAuthor{Samuel Hornus \and Olivier Devillers}
|
||||
|
||||
TODO: add some introductory text here.
|
||||
|
||||
A triangulation is a pure simplicial complex, connected and without
|
||||
singularities. Its faces are such that two of them either do not
|
||||
intersect or share a common face.
|
||||
|
||||
The basic triangulation class of \cgal is primarily designed to
|
||||
represent the triangulations of a set of points $A$ in $\R^d$.
|
||||
It can be
|
||||
viewed as a partition of the convex hull of $A$ into simplices whose
|
||||
vertices are the points of $A$. Together with the unbounded cells having
|
||||
the convex hull boundary as its frontier, the triangulation forms a
|
||||
partition of $\R^d$.
|
||||
|
||||
In order to deal only with full dimensional simplices (full cells),
|
||||
which is convenient for many
|
||||
applications, the space outside the convex hull is subdivided into simplices by
|
||||
considering that each convex hull facet is incident to an infinite
|
||||
cell having as vertex an auxiliary vertex called the infinite
|
||||
vertex. In that way, each facet is incident to exactly two cells and
|
||||
special cases at the boundary of the convex hull are simple to deal
|
||||
with.
|
||||
|
||||
A triangulation is a collection of vertices and cells that are linked
|
||||
together through incidence and adjacency relations. Each cell gives
|
||||
access to its its incident vertices and to its its adjacent
|
||||
cells. Each vertex gives access to one of its incident cells.
|
||||
|
||||
The vertices of a cell are indexed in positive
|
||||
orientation, the positive orientation being defined by the orientation
|
||||
of the underlying Euclidean space $\R^d$. The neighbors of a cell are also
|
||||
indexed in such a way that the neighbor indexed by $i$
|
||||
is opposite to the vertex with the same index.
|
||||
|
||||
|
||||
|
||||
\section{Reference Pages Sorted by Type}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <CGAL/Cartesian_d.h>
|
||||
#include <CGAL/point_generators_d.h>
|
||||
#include <CGAL/Filtered_kernel_d.h>
|
||||
#include <CGAL/point_generators_d.h>
|
||||
#include <CGAL/Triangulation.h>
|
||||
#include <CGAL/algorithm.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
|
@ -8,53 +8,36 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
typedef CGAL::Cartesian_d<double> K;
|
||||
typedef CGAL::Filtered_kernel_d<K> FK;
|
||||
typedef CGAL::Triangulation<FK> T;
|
||||
|
||||
int main()
|
||||
{
|
||||
const int D = 5; // we work in euclidean 5-space
|
||||
const int N = 100; // we will insert 100 points
|
||||
|
||||
// |Cartesian_d| is a model of the concept TriangulationTraits
|
||||
typedef CGAL::Cartesian_d<double> K;
|
||||
|
||||
// |Filtered_kernel_d| provides exact geometric predicates
|
||||
typedef CGAL::Filtered_kernel_d<K> FK;
|
||||
|
||||
// Here is our Triangulation type:
|
||||
typedef CGAL::Triangulation<FK> T;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - STEP 1
|
||||
|
||||
// Instanciate a random point generator
|
||||
CGAL::Random rng;
|
||||
CGAL::Random rng;
|
||||
typedef CGAL::Random_points_in_cube_d<T::Point> Random_points_iterator;
|
||||
Random_points_iterator rand_it(D, 1.0, rng);
|
||||
|
||||
// Generate N random points
|
||||
std::vector<T::Point> points;
|
||||
CGAL::copy_n(rand_it, N, std::back_inserter(points));
|
||||
|
||||
T t(D);
|
||||
T t(D); // create triangulation
|
||||
assert(t.empty());
|
||||
|
||||
// insert the points in the triangulation
|
||||
t.insert(points.begin(), points.end());
|
||||
t.insert(points.begin(), points.end()); // compute triangulation
|
||||
assert( t.is_valid() );
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - STEP 2
|
||||
|
||||
typedef T::Face Face;
|
||||
typedef std::vector<Face> Faces;
|
||||
Faces edges;
|
||||
std::back_insert_iterator<Faces> out(edges);
|
||||
t.incident_faces(t.infinite_vertex(), 1, out);
|
||||
// Count the number of points on the convex hull
|
||||
std::cout << "There are " << edges.size() << " vertices on the (triangulated) convex hull.";
|
||||
t.incident_faces(t.infinite_vertex(), 1, out); // collect edges
|
||||
std::cout << "There are " << edges.size()
|
||||
<< " vertices on the convex hull."<< std::endl;
|
||||
edges.clear();
|
||||
|
||||
// cleanup
|
||||
t.clear();
|
||||
assert(t.empty());
|
||||
|
||||
std::cout << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ int main()
|
|||
|
||||
assert( sdim == S.ambient_dimension() );
|
||||
assert( ddim == D.ambient_dimension() );
|
||||
|
||||
assert( -2 == S.current_dimension() );
|
||||
assert( S.is_valid() );
|
||||
|
||||
|
|
@ -30,42 +29,33 @@ int main()
|
|||
assert( -1 == S.current_dimension() );
|
||||
|
||||
for( int i = 1; i <= 5; ++i )
|
||||
V[i] = S.insert_increase_dimension(V[rand() % i]);
|
||||
|
||||
V[i] = S.insert_increase_dimension(V[0]);
|
||||
assert( 4 == S.current_dimension() );
|
||||
assert( 6 == S.number_of_vertices() );
|
||||
assert( 6 == S.number_of_full_cells() );
|
||||
|
||||
Full_cell_handle c = V[5]->full_cell();
|
||||
|
||||
V[6] = S.insert_in_full_cell(c);
|
||||
|
||||
assert( 7 == S.number_of_vertices() );
|
||||
assert( 10 == S.number_of_full_cells() );
|
||||
|
||||
c = V[3]->full_cell();
|
||||
// ft will designate the Facet opposite to vertex 2 in c:
|
||||
Facet ft(c, 2);
|
||||
|
||||
Facet ft(c, 2); // the Facet opposite to vertex 2 in c
|
||||
V[7] = S.insert_in_facet(ft);
|
||||
assert( 8 == S.number_of_vertices() );
|
||||
assert( 16 == S.number_of_full_cells() );
|
||||
|
||||
c = V[3]->full_cell();
|
||||
// face will be the edge joining vertices 2 and 4 in full_cell c:
|
||||
Face face(c);
|
||||
face.set_index(0, 2);
|
||||
face.set_index(1, 4);
|
||||
|
||||
Face face(c); // the edge joining vertices of full_cell c
|
||||
face.set_index(0, 2); // namely vertex 2
|
||||
face.set_index(1, 4); // and vertex 4
|
||||
V[8] = S.insert_in_face(face);
|
||||
assert( S.is_valid() );
|
||||
|
||||
Full_cell_handle hole[2];
|
||||
hole[0] = V[8]->full_cell();
|
||||
hole[1] = hole[0]->neighbor(0);
|
||||
// ft will be a face on the boundary of hole[0] union hole[1]:
|
||||
ft = Facet(hole[0], 1);
|
||||
|
||||
ft = Facet(hole[0], 1); // a face on the boundary of hole[0]
|
||||
V[9] = S.insert_in_hole(hole, hole+2, ft);
|
||||
assert( S.is_valid() );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue