[vtkusers] vtkDelaunay3D: wrong convex hull

David Doria daviddoria at gmail.com
Tue Jul 26 13:50:59 EDT 2011


2011/7/26 Miguel Sotaquirá <msotaquira at gmail.com>:
> Hi David,
> You're right, vtkDelaunay3D is not the correct approach in this case. Now
> I'm trying to obtain a 2D convex hull (vtkDelaunay2D) by projecting the 3-D
> points onto a plane. Here's the code:
> // create a plane, seting its origin in (0,0,0) and its normal N (N is the
> normal to  the current vertex, the center of the neighborhood)
> vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
> plane->SetOrigin(0.0, 0.0, 0.0);
> plane->SetNormal(N[0], N[1], N[2]);
>  // project each point in the neighborhood onto the plane
> vtkSmartPointer<vtkPoints> ptsProj = vtkSmartPointer<vtkPoints>::New();
> double origin[3] = {0.0, 0.0, 0.0};
> double normal[3] = {N[0], N[1], N[2]};
> double projected[3];
> for ( int i = 0; i < pts->GetNumberOfPoints(); i++ ) {
>   pts->GetPoint(i,p);
>   plane->ProjectPoint( p, origin, normal, projected );
>   ptsProj->InsertNextPoint(projected);}
> // store projected points in a polydata
> vtkSmartPointer<vtkPolyData> ptsForTriang =
> vtkSmartPointer<vtkPolyData>::New();
> ptsForTriang->SetPoints(ptsProj);
> // apply delaunay2D
> vtkSmartPointer<vtkDelaunay2D> delaunay2D =
> vtkSmartPointer<vtkDelaunay2D>::New();
> delaunay2D->SetInput(ptsForTriang);
> delaunay2D->Update();
> When using this approach to my initial problem I get this:
> http://tinypic.com/r/2mre8ma/7
> again, some vertices were not included in the convex hull . When I check the
> 2D convex hull info it says that has 6 points (which is correct) but only 2
> cells (the ones that can be seen in the image)...
> Is this the correct approach for computing the 2D convex hull (using
> projections)? Am I missing something?
> Thanks again,
> Miguel

Can you hardcode those points into a compilable demo of this?

David



More information about the vtkusers mailing list