CGAL 5.1 - 3D Polyhedral Surface
Polyhedron/polyhedron_prog_incr_builder.cpp
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_incremental_builder_3.h>
#include <CGAL/Polyhedron_3.h>
// A modifier creating a triangle with the incremental builder.
template <class HDS>
class Build_triangle : public CGAL::Modifier_base<HDS> {
public:
Build_triangle() {}
void operator()( HDS& hds) {
// Postcondition: hds is a valid polyhedral surface.
B.begin_surface( 3, 1, 6);
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
B.add_vertex( Point( 0, 0, 0));
B.add_vertex( Point( 1, 0, 0));
B.add_vertex( Point( 0, 1, 0));
B.end_facet();
}
};
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::HalfedgeDS HalfedgeDS;
int main() {
Polyhedron P;
Build_triangle<HalfedgeDS> triangle;
P.delegate( triangle);
CGAL_assertion( P.is_triangle( P.halfedges_begin()));
return 0;
}
CGAL::Polyhedron_incremental_builder_3::add_vertex_to_facet
void add_vertex_to_facet(size_type i)
adds a vertex with index i to the current facet.
HalfedgeDS
CGAL::Polyhedron_incremental_builder_3::end_surface
void end_surface()
ends the construction.
Kernel
CGAL::Polyhedron_incremental_builder_3::begin_surface
void begin_surface(size_type v, size_type f, size_type h=0, int mode=RELATIVE_INDEXING)
starts the construction.
CGAL::Polyhedron_3
Definition: Polyhedron_3.h:113
CGAL::Polyhedron_incremental_builder_3::begin_facet
Facet_handle begin_facet()
starts a new facet and returns its handle.
CGAL::Polyhedron_incremental_builder_3::end_facet
Halfedge_handle end_facet()
ends a newly constructed facet.
CGAL::Modifier_base
CGAL::Polyhedron_incremental_builder_3
Definition: Polyhedron_incremental_builder_3.h:62
CGAL::Polyhedron_incremental_builder_3::add_vertex
Vertex_handle add_vertex(const Point_3 &p)
adds a new vertex for p and returns its handle.
CGAL::Modifier_base::operator()
virtual void operator()(R &rep)
CGAL::Simple_cartesian