1 #ifndef COPY_POLYHEDRON_H
2 #define COPY_POLYHEDRON_H
4 #include <CGAL/Polyhedron_incremental_builder_3.h>
8 template <
class Polyhedron_input,
9 class Polyhedron_output>
11 :
public CGAL::Modifier_base<typename Polyhedron_output::HalfedgeDS>
16 void operator()(
typename Polyhedron_output::HalfedgeDS& out_hds)
18 typedef typename Polyhedron_output::HalfedgeDS Output_HDS;
20 CGAL::Polyhedron_incremental_builder_3<Output_HDS> builder(out_hds);
22 typedef typename Polyhedron_input::Vertex_const_iterator Vertex_const_iterator;
23 typedef typename Polyhedron_input::Facet_const_iterator Facet_const_iterator;
24 typedef typename Polyhedron_input::Halfedge_around_facet_const_circulator HFCC;
26 builder.begin_surface(in_poly->size_of_vertices(),
27 in_poly->size_of_facets(),
28 in_poly->size_of_halfedges());
30 for(Vertex_const_iterator
31 vi = in_poly->vertices_begin(), end = in_poly->vertices_end();
34 typename Polyhedron_output::Point_3 p(::CGAL::to_double( vi->point().x()),
35 ::CGAL::to_double( vi->point().y()),
36 ::CGAL::to_double( vi->point().z()));
37 builder.add_vertex(p);
40 typedef CGAL::Inverse_index<Vertex_const_iterator> Index;
41 Index index( in_poly->vertices_begin(), in_poly->vertices_end());
43 for(Facet_const_iterator
44 fi = in_poly->facets_begin(), end = in_poly->facets_end();
47 HFCC hc = fi->facet_begin();
49 builder.begin_facet ();
51 builder.add_vertex_to_facet(index[hc->vertex()]);
53 }
while( hc != hc_end);
56 builder.end_surface();
59 std::shared_ptr<Polyhedron_input> in_poly;
62 template <
class Poly_B,
class Poly_A>
63 void poly_copy(std::shared_ptr<Poly_B> poly_b, std::shared_ptr<Poly_A> poly_a)
67 poly_b->delegate(modifier);
Definition: copy_polyhedron.h:10