Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Problems using Alpha Shapes

Subject: CGAL users discussion list

List archive

[cgal-discuss] Problems using Alpha Shapes


Chronological Thread 
  • From: Markus Eich <>
  • To:
  • Subject: [cgal-discuss] Problems using Alpha Shapes
  • Date: Tue, 24 May 2011 14:22:56 +0200

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






--
Dipl. Inf. Markus Eich
Researcher

DFKI Bremen
Robotics Innovation Center
Mary-Somerville-Str. 9
28359 Bremen, Germany

Phone: +49 (0)421 17845-4105
Fax: +49 (0)421 17845-4150
E-Mail:


Weitere Informationen: http://www.dfki.de/robotik
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.: DE 148646973
Steuernummer: 19/673/0060/3
-----------------------------------------------------------------------

Attachment: Bildschirmfoto.png
Description: PNG image




Archive powered by MHonArc 2.6.16.

Top of Page