\subsubsection{Combinatorial Modification} \cgalpoly\ provides a set of operators for combinatorial modifications. Most of them are categorized as Euler operations that maintain the Euler-Poincar\'e equality: $V - E + F = 2 - 2G$. These atomic operators can split/join of two facets, two vertices or two loops. They can also create/erase a center vertex or a facet. TODO: example of creating a triangle strip. \begin{lstlisting} typedef CGAL::Cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; typedef Polyhedron::Halfedge_handle Halfedge_handle; int main() { Polyhedron P; Point p0(0, 0, 0), p1(1, 0, 0), p2(0, 1, 0); Halfedge_handle e = P.make_triangle( p0, p1, p2); // e points to p0 e = e->prev(); // e points to p2 e = P.add_vertex_and_facet_to_border(e->next()->opposite(), e->opposite()); e->point() = Point(1, 1, 0); e = P.add_vertex_and_facet_to_border(e->next()->opposite(), e->opposite()); e->point() = Point(2, 0, 0); e = e->next(); e = P.add_vertex_and_facet_to_border(e->next()->opposite(), e->opposite()); e->point() = Point(2, 1, 0); } \end{lstlisting} Reader should refer the references manual for precise definitions and examples. \footnote{See \href{http://www.cgal.org/Manual/doc_html/ basic_lib/Polyhedron/Chapter_main.html}{Euleroperators}}. \subsubsection{Modifier and Polyhedron Incremental Builder} \label{sec:builder} In addition to the modification operators \poly\ has, the \polybuilder\ countenances the direct accesses and modifications of the internal representation, i.e. the halfedge data structure, of the \poly\ in a controlled manner. A \polybuilder\ is a function object serving the callback mechanism of the modifier. A modifier is a function object derived from \lstinline!Modifier_base! that implements a pure virtual member function \lstinline!operator()!. A call of \lstinline!delegate(a_modifier)! triggers the callback and authorizes the access of the internal representation of the polyhedron. When called, the \lstinline!operator()! receives the internal halfedge data structure. A \polybuilder\ is then created to build incrementally the geometry and the connectivity of the halfedge data struture. On return, the check for the polyhedron validity of the halfedge data structure is enforced. %The validity check is implemented %as an expensive postcondition at the end of the delegate() %member function, i.e., it is not %called by default, only when expensive checks are activated. Following example shows how to create a triangle strip using the modifier and the incremental builder. \lstinline!Build_triangle_strip! is a function object derived from \lstinline!Modifier_base!. The \lstinline!P.delegate()! accepts this function object and direct the call to the \lstinline!operator()! with a reference of the internally halfedge data structure. TODO: a figure for the excution flow. \begin{lstlisting} template class Build_triangle_strip : public CGAL::Modifier_base<_HDS> { typedef typename _HDS::Vertex Vertex; typedef typename Vertex::Point Point; public: Build_triangle_strip() {} void operator()(_HDS& hds) { CGAL::Polyhedron_incremental_builder_3<_HDS> B(hds); B.begin_surface(6, 4, 12); { B.add_vertex(Point(0, 0, 0)); B.add_vertex(Point(1, 0, 0)); B.add_vertex(Point(0, 1, 0)); B.add_vertex(Point(1, 1, 0)); B.add_vertex(Point(2, 0, 0)); B.add_vertex(Point(2, 1, 0)); B.begin_facet(); B.add_vertex_to_facet(0); B.add_vertex_to_facet(1); B.add_vertex_to_facet(2); B.end_facet(); B.begin_facet(); B.add_vertex_to_facet(1); B.add_vertex_to_facet(3); B.add_vertex_to_facet(2); B.end_facet(); B.begin_facet(); B.add_vertex_to_facet(1); B.add_vertex_to_facet(4); B.add_vertex_to_facet(3); B.end_facet(); B.begin_facet(); B.add_vertex_to_facet(4); B.add_vertex_to_facet(5); B.add_vertex_to_facet(3); B.end_facet(); } B.end_surface(); } }; typedef CGAL::Cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; Polyhedron P; Build_triangle_strip tstrip; P.delegate(tstrip); \end{lstlisting} % ------------------------------------------------------------------------ % initialize a specific polyhedron (incremental builder on enriched-polyhedron?) \subsubsection{Polyhedron Initialization} The \polybuilder is particularly useful for implementing file reader for common file formats. TODO: initilaize the enriched-polyhedron %\input ??