diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/issue4533.cpp b/Straight_skeleton_2/test/Straight_skeleton_2/issue4533.cpp new file mode 100644 index 00000000000..38c0503e939 --- /dev/null +++ b/Straight_skeleton_2/test/Straight_skeleton_2/issue4533.cpp @@ -0,0 +1,40 @@ +#include +#include + +#include +#include +#include + +#include "print.h" + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K ; + +typedef K::Point_2 Point ; +typedef CGAL::Polygon_2 Polygon_2 ; +typedef CGAL::Straight_skeleton_2 Ss ; + +typedef boost::shared_ptr SsPtr ; + +int main() +{ + Polygon_2 poly ; + + + poly.push_back( Point( 0, 0 ) ); + poly.push_back( Point( 2000, 8000 ) ); + poly.push_back( Point( 10000, 10000 ) ); + poly.push_back( Point( 2000, 12000 ) ); + poly.push_back( Point( 0, 20000 ) ); + poly.push_back( Point( -2000, 12000 ) ); + poly.push_back( Point( -10000, 10000 ) ); + poly.push_back( Point( -2000, 8000 ) ); + assert(poly.is_simple()); + assert(poly.is_counterclockwise_oriented()); + + // You can pass the polygon via an iterator pair + SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end()); + + print_straight_skeleton(*iss); + + return 0; +} diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/print.h b/Straight_skeleton_2/test/Straight_skeleton_2/print.h new file mode 100644 index 00000000000..5243e912667 --- /dev/null +++ b/Straight_skeleton_2/test/Straight_skeleton_2/print.h @@ -0,0 +1,84 @@ +#include +#include + +template +void print_point ( CGAL::Point_2 const& p ) +{ + std::cout << "(" << p.x() << "," << p.y() << ")" ; +} + +template +void print_polygon ( CGAL::Polygon_2 const& poly ) +{ + typedef CGAL::Polygon_2 Polygon ; + + std::cout << "Polygon with " << poly.size() << " vertices" << std::endl ; + + for( typename Polygon::Vertex_const_iterator vi = poly.vertices_begin() ; vi != poly.vertices_end() ; ++ vi ) + { + print_point(*vi); std::cout << std::endl ; + } +} + +template +void print_polygons ( std::vector< boost::shared_ptr< CGAL::Polygon_2 > > const& polies ) +{ + typedef std::vector< boost::shared_ptr< CGAL::Polygon_2 > > PolygonVector ; + + std::cout << "Polygon list with " << polies.size() << " polygons" << std::endl ; + + for( typename PolygonVector::const_iterator pi = polies.begin() ; pi != polies.end() ; ++ pi ) + print_polygon(**pi); +} + +template +void print_polygon_with_holes ( CGAL::Polygon_with_holes_2 const& polywh ) +{ + typedef CGAL::Polygon_with_holes_2 PolygonWithHoles ; + + std::cout << "Polygon_with_holes having " << polywh.number_of_holes() << " holes" << std::endl ; + + print_polygon(polywh.outer_boundary()); + + for( typename PolygonWithHoles::Hole_const_iterator hi = polywh.holes_begin() ; hi != polywh.holes_end() ; ++ hi ) + print_polygon(*hi); +} + +template +void print_polygons_with_holes ( std::vector< boost::shared_ptr< CGAL::Polygon_with_holes_2 > > const& polies ) +{ + + typedef std::vector< boost::shared_ptr< CGAL::Polygon_with_holes_2 > > PolygonWithHolesVector ; + + std::cout << "Polygon_with_holes list with " << polies.size() << " element" << std::endl ; + + for( typename PolygonWithHolesVector::const_iterator pi = polies.begin() ; pi != polies.end() ; ++ pi ) + print_polygon_with_holes(**pi); +} + + +template +void print_straight_skeleton( CGAL::Straight_skeleton_2 const& ss ) +{ + typedef CGAL::Straight_skeleton_2 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::cout << "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 ) + { + print_point(i->opposite()->vertex()->point()) ; + std::cout << "->" ; + print_point(i->vertex()->point()); + std::cout << " " << ( i->is_bisector() ? "bisector" : "contour" ) << std::endl; + } +}