0

I haven't used CGAL before, and all I want is a function that takes a 2d set of points and alpha parameter, and returns a vector of points that represents the bounding polygon. I can make an alpha shape object, but I don't know how to get a vector from there. EDIT: One caveat is that there may be several disconnected components, and I would want to know that somehow. Is there a neat solution such that I get an ordered vector of vertices for each polygon?

Flowers
  • 191
  • 1
  • 9

3 Answers3

1

I've faced the same problem and finally ended up sorting all vertices like suggested in the top answer here. Maybe, it would help someone.

I'm not exactly satisfied by this approach, though. @Flowers, do you still have code with which you iterated over edges? I couldn't manage to do this. Sorry, I have not enough reputation to ask it in a comment.

0

Try something like this:

Alpha_shape_2 A(points.begin(), points.end(),
                FT(10000),
                Alpha_shape_2::GENERAL);

std::vector<Alpha_shape_2::Point> points;

for (Alpha_shape_2::Alpha_shape_vertices_iterator
       avit = A.alpha_shape_vertices_begin(),
       avit_end=A.alpha_shape_vertices_end();
       avit!=avit_end; ++avit)
{
  points.push_back(avit->point());
}

See the reference manual of the function here.

sloriot
  • 6,070
  • 18
  • 27
0

Ended up going over the edges instead and used that to find the vertices in order.

Flowers
  • 191
  • 1
  • 9