Subject: CGAL users discussion list
List archive
- From: kinju <>
- To:
- Subject: [cgal-discuss] Create a simple 2D skeleton
- Date: Sat, 17 Jul 2010 04:55:28 -0700 (PDT)
Hello,
I have a polygon with one exterior contour and 0 or more interior holes.
I'm trying to build a 2D skeleton from predefine simple polygon, a box of
10x10 while a hole in the middle of 5x5. The goal is to obtain triangles in
order to draw the polygon without holes.
typedef CGAL::Exact_predicates_inexact_constructions_kernel
K;
typedef K::Point_2
Point;
typedef CGAL::Polygon_2<K>
Polygon;
typedef CGAL::Polygon_with_holes_2<K>
Polygon_with_holes;
typedef boost::shared_ptr<Polygon>
PolygonPtr;
typedef std::vector<PolygonPtr>
PolygonSequence ;
typedef CGAL::Straight_skeleton_2<K>
Ss;
typedef boost::shared_ptr<Ss>
SsPtr;
typedef Ss::Vertex_const_handle
Vertex_const_handle;
typedef Ss::Halfedge_const_handle
Halfedge_const_handle;
typedef Ss::Halfedge_const_iterator
Halfedge_const_iterator;
Polygon outer;
outer.push_back(0.0, 0.0);
outer.push_back(0.0, 10.0);
outer.push_back(10.0, 10.0);
outer.push_back(10.0, 0.0);
Polygon_with_holes poly(outer);
Polygon hole;
hole.push_back(2.5, 2.5);
hole.push_back(2.5, 7.5);
hole.push_back(7.5, 7.5);
hole.push_back(7.5, 2.5);
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly);
Ss& ss = *iss;
I print the result :
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 )
{
const Point& p = i->opposite()->vertex()->point();
std::cout << "(" << p.x() << "," << p.y() << ")" ;
std::cout << "->" ;
std::cout << "(" << p.x() << "," << p.y() << ")" ;
std::cout << " " << ( i->is_bisector() ? "bisector" :
"contour" ) <<
std::endl;
}
And I have this result :
(0,10) -> (0,10) contour
(0,0) -> (0,0) contour
(0,0) -> (0,0) contour
(10,0) -> (10,0) contour
(10,0) -> (10,0) contour
(10,10) -> (10,10) contour
(10,10) -> (10,10) contour
(0,10) -> (0,10) contour
(0,0) -> (0,0) bisector
(5,5) -> (5,5) bisector
(10,0) -> (10,0) bisector
(5,5) -> (5,5) bisector
(10,0) -> (10,0) bisector
(5,5) -> (5,5) bisector
(0,10) -> (0,10) bisector
(5,5) -> (5,5) bisector
I've checked vertices, I have 4 vertices witch define the outer contour, and
one which is (5,5)..
I think I'm not using the right functionalities for my problem..
Can you help me ?
Thank you very much (and sorry for my bad english),
Aurélien
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Create-a-simple-2D-skeleton-tp2292307p2292307.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Create a simple 2D skeleton, kinju, 07/17/2010
- Re: [cgal-discuss] Create a simple 2D skeleton, Fernando Cacciola, 07/17/2010
- [cgal-discuss] Re: Create a simple 2D skeleton, kinju, 07/18/2010
- [cgal-discuss] Re: Create a simple 2D skeleton, kinju, 07/18/2010
- Re: [cgal-discuss] Create a simple 2D skeleton, Fernando Cacciola, 07/19/2010
- Re: [cgal-discuss] Create a simple 2D skeleton, Fernando Cacciola, 07/17/2010
Archive powered by MHonArc 2.6.16.