void straightSkeletonToMultiLineString( const CGAL::Straight_skeleton_2<K> & ss, MultiLineString& result ) { typedef CGAL::Straight_skeleton_2<K> Ss ; typedef typename Ss::Vertex_const_handle Vertex_const_handle ; typedef typename Ss::Halfedge_const_handle Halfedge_const_handle ; typedef typename Ss::Halfedge_const_iterator Halfedge_const_iterator ; Halfedge_const_handle null_halfedge ; Vertex_const_handle null_vertex ; for ( Halfedge_const_iterator it = ss.halfedges_begin(); it != ss.halfedges_end(); ++it ){ // skip contour edge if ( ! it->is_bisector() ){ continue ; } // avoid duplicates if ( it->opposite() < it ){ continue ; } result.addGeometry( new LineString( Point( it->opposite()->vertex()->point() ), Point( it->vertex()->point() ) ) ); } }
void print_straight_skeleton( CGAL::Straight_skeleton_2<K> const& ss ) { typedef CGAL::Straight_skeleton_2<K> Ss ; typedef typename Ss::Vertex_const_handle Vertex_const_handle ; typedef typename Ss::Halfedge_const_handle Halfedge_const_handle ; typedef typename Ss::Halfedge_const_iterator Halfedge_const_iterator ; Halfedge_const_handle null_halfedge ; Vertex_const_handle null_vertex ; std::cerr << "Straight skeleton with " << ss.size_of_vertices() << " vertices, " << ss.size_of_halfedges() << " halfedges and " << ss.size_of_faces() << " faces" << std::endl ; for ( Halfedge_const_iterator i = ss.halfedges_begin(); i != ss.halfedges_end(); ++i ) { if ( !i->is_bisector() ) continue; std::cout << "2 " ; print_point(i->opposite()->vertex()->point()) ; std::cout << " 0 " ; print_point(i->vertex()->point()); std::cout << " 0\n" ; //std::cout << " " << ( i->is_bisector() ? "bisector" : "contour" ) << std::endl; } }