Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Straight_Skeleton_2

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Straight_Skeleton_2


Chronological Thread 
  • From: "Fernando Cacciola" <>
  • To: <>
  • Subject: Re: [cgal-discuss] Straight_Skeleton_2
  • Date: Thu, 22 Nov 2007 13:38:31 -0300
  • Organization: Geometry Factory

sinan mutlu wrote:
Hi,

Is there an example code that finds the "straight skeleton" of a simple
concave or convex polygon.

It's a subset of the example generating offset polygons since that is based on a straight skeleton.
But I guess which subset is a bit unclear, so here is it:

#include<vector>
#include<iterator>
#include<iostream>
#include<iomanip>
#include<string>
#include<boost/shared_ptr.hpp>
#include<CGAL/basic.h>
#include<CGAL/Cartesian.h>
#include<CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include<CGAL/Straight_skeleton_builder_2.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;

typedef Kernel::Point_2 Point_2;

typedef CGAL::Straight_skeleton_2<Kernel> Ss;

typedef CGAL::Straight_skeleton_builder_traits_2<Kernel> SsBuilderTraits;
typedef CGAL::Straight_skeleton_builder_2<SsBuilderTraits,Ss> SsBuilder;

int main()
{
// A start-shaped polygon, oriented counter-clockwise as required for outer contours.
Point_2 pts[] = { Point_2(-1,-1)
, Point_2(0,-12)
, Point_2(1,-1)
, Point_2(12,0)
, Point_2(1,1)
, Point_2(0,12)
, Point_2(-1,1)
, Point_2(-12,0)
} ;

std::vector<Point_2> star(pts,pts+8);

SsBuilder ssb ;

ssb.enter_contour(frame,frame+4);

boost::shared_ptr<Ss> ss = ssb.construct_skeleton();



FWIW, I'm working on a simplified API, based on simple free functions.
The updated manual will contain much more examples using the simplified API

Best

Fernando Cacciola
GeometryFactory


Archive powered by MHonArc 2.6.16.

Top of Page