Subject: CGAL users discussion list
List archive
- From: "Sebastien Loriot (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] Problems using Alpha Shapes
- Date: Tue, 24 May 2011 16:29:22 +0200
Iterate over REGULAR edges and build the graph of vertices.
From this you should be able to get the contour. You might also
might consider SINGULAR edges to get antennas.
S.
Markus Eich wrote:
Dear all.
I am using CGAL to recover the shape from a 2D point cloud. It works fine, except that the result always looks like the screenshot attached. This is due to the fact that the points are not ordered alpha shape output is not ordered in any way.
Here is the code snipped:
=========================
for(size_t i=0; i<cloud_ptr->points.size(); i++){
Eigen::Vector3f p3d(cloud_ptr->points[i].x,
cloud_ptr->points[i].y,
cloud_ptr->points[i].z);
// subtract all 3D points with a point in the plane
// this will move the origin of the 3D coordinate system
// onto the plane
p3d = p3d - p0;
K::Point_2 p2d(p3d.dot(u),p3d.dot(v));
lp.push_back(p2d);
}
// compute alpha shape
Alpha_shape_2 as(lp.begin(),lp.end());
// find optimal alpha value
Alpha_iterator opt = as.find_optimal_alpha(1);
//as.set_alpha(*opt);
as.set_alpha(0.01);
boost::geometry::polygon_2d sorted_poly;
for(Vertice_iterator it = as.alpha_shape_vertices_begin(); it != as.alpha_shape_vertices_end(); it++){
Alpha_shape_2::Vertex_handle vh = *it;
append(sorted_poly, boost::geometry::make<boost::geometry::point_2d>(vh->point().x(),vh->point().y()));
}
=========================
How can I convert the points that it is ordered (i.e. that only the nearest points are connected) and that it doesn't look like a spider web.
Cheers,
Markus
------------------------------------------------------------------------
- [cgal-discuss] Problems using Alpha Shapes, Markus Eich, 05/24/2011
- Re: [cgal-discuss] Problems using Alpha Shapes, Markus Eich, 05/24/2011
- Re: [cgal-discuss] Problems using Alpha Shapes, Sebastien Loriot (GeometryFactory), 05/24/2011
- Re: [cgal-discuss] Problems using Alpha Shapes, Mariette Yvinec, 05/24/2011
Archive powered by MHonArc 2.6.16.