cgal/Packages/Tutorial/tutorial/Polyhedron/doc/poly_decl.tex

66 lines
2.7 KiB
TeX

The simplest declaration of the polyhedron consists
of templating with a cartesian kernel and double
number precision:
\begin{lstlisting}
#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>
typedef CGAL::Cartesian<double> kernel;
typedef CGAL::Polyhedron_3<kernel> Polyhedron;
Polyhedron p;
\end{lstlisting}
The full template declaration of \poly\ has four template parameters:
\begin{lstlisting}
template <class PolyhedronTraits_3,
class PolyhedronItems_3 = CGAL::Polyhedron_items_3,
template <class T, class I> class HalfedgeDS = CGAL::HalfedgeDS_default,
class Alloc = CGAL_ALLOCATOR(int)>
class Polyhedron_3;
\end{lstlisting}
The \polytrait\ is a concept defines the point and plane required in
the \poly . This concept is a subset of the 3d kernel traits and any
CGAL kernel model can be used directly as the template argument.
The \polyitem\ is an extended concept of the \hdsitem\ that wraps three
item types of vertex, halfedge and face. The \polyitem\ is also required
to define the point of vertices and plane of facets.
The \hds\ is a class template of a model of the \hds\ concept. It is
defined and instansiated based on \polytrait\ and \polyitem .
The fourth parameter \lstinline!Alloc! requires a standard allocator
for STL container classes.
The default container of \poly\ is the linked list. In situations
list is prefered, the polyhedron with vector container can be declared
as:
\begin{lstlisting}
typedef CGAL::Cartesian<double> Kernel;
typedef CGAL::Polyhedron_3< Kernel,
CGAL::Polyhedron_items_3,
CGAL::HalfedgeDS_vector> Polyhedron;
\end{lstlisting}
TODO: pros and cons of list vs vector
CGAL provide a \lstinline!Polyhedron_traits_with_normals_3!
defining the plane equation of the facet as the vector from \kernel .
Following codes demonstrate a polyhderon with normal vector of
the facet (and vector container).
\begin{lstlisting}
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Vector_3 NormalVector;
typedef CGAL::Polyhedron_traits_with_normals_3<Kernel> Traits;
typedef CGAL::Polyhedron_3<Traits,
CGAL::Polyhedron_items_3,
CGAL::HalfedgeDS_vector> Polyhedron;
\end{lstlisting}
In addition to positions of vertices and plane equations (or normals)
of facets, different graphics applications require different
attribute associations. For examples, colors of facets, normals of
vertices or texture coordinates of corners (halfedges). To tailor
the \poly\ to fufill the application requirements, a user-defined
model of the concept of the \polyitem\ need to be provided as the
second template parameter. See next section.