Hi David,<div><br></div><div>You&#39;re right, vtkDelaunay3D is not the correct approach in this case. Now I&#39;m trying to obtain a 2D convex hull (vtkDelaunay2D) by projecting the 3-D points onto a plane. Here&#39;s the code:</div>
<div><div><br></div><div>// 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)</div><div>vtkSmartPointer&lt;vtkPlane&gt; plane = vtkSmartPointer&lt;vtkPlane&gt;::New();</div>
<div>plane-&gt;SetOrigin(0.0, 0.0, 0.0);</div><div>plane-&gt;SetNormal(N[0], N[1], N[2]);</div><div><br></div><div> // project each point in the neighborhood onto the plane</div><div>vtkSmartPointer&lt;vtkPoints&gt; ptsProj = vtkSmartPointer&lt;vtkPoints&gt;::New();</div>
<div>double origin[3] = {0.0, 0.0, 0.0};</div><div>double normal[3] = {N[0], N[1], N[2]};</div><div>double projected[3];</div><div>for ( int i = 0; i &lt; pts-&gt;GetNumberOfPoints(); i++ ) {</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>pts-&gt;GetPoint(i,p);</div>
<div> <span class="Apple-tab-span" style="white-space:pre">        </span>plane-&gt;ProjectPoint( p, origin, normal, projected );</div><div> <span class="Apple-tab-span" style="white-space:pre">        </span>ptsProj-&gt;InsertNextPoint(projected);}</div>
<div><br></div><div>// store projected points in a polydata</div><div>vtkSmartPointer&lt;vtkPolyData&gt; ptsForTriang = vtkSmartPointer&lt;vtkPolyData&gt;::New();</div><div>ptsForTriang-&gt;SetPoints(ptsProj);</div><div><br>
</div><div>// apply delaunay2D</div><div>vtkSmartPointer&lt;vtkDelaunay2D&gt; delaunay2D = vtkSmartPointer&lt;vtkDelaunay2D&gt;::New();</div><div>delaunay2D-&gt;SetInput(ptsForTriang);</div><div>delaunay2D-&gt;Update();</div>
<div><br></div><div>When using this approach to my initial problem I get this:</div><div><a href="http://tinypic.com/r/2mre8ma/7">http://tinypic.com/r/2mre8ma/7</a></div><div><br></div><div>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)...</div>
<div><br></div><div>Is this the correct approach for computing the 2D convex hull (using projections)? Am I missing something?</div><div>Thanks again,</div><div>Miguel</div><br><div class="gmail_quote">2011/7/26 David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Miguel,<br>
<br>
By applying vtkDelaunay3D to a flat (or nearly-flat) mesh, you are<br>
asking it to create degenerate tetrahedrons, so it should not be<br>
surprising that it fails on one or more of the points.<br>
<br>
Checking to see if a neighbor is within a 2D convex hull should be<br>
easy, you can use vtkPolygon::PointInPolygon() or, since the hull is<br>
convex, you can do a quick orientation check with the closest edge<br>
of the polygon.<br>
<div><div></div><div class="h5"><br>
 - David<br>
<br>
<br>
2011/7/25 Miguel Sotaquirá &lt;<a href="mailto:msotaquira@gmail.com">msotaquira@gmail.com</a>&gt;:<br>
&gt; Hi David,<br>
&gt;<br>
&gt; Yes indeed, it is a triangle mesh... However as I mentioned vtkDelaunay3D<br>
&gt; seems to work on all of the other vertices of my mesh, except on the one<br>
&gt; included the previous e-mail... This seems so odd!<br>
&gt;<br>
&gt; The problem is that I need the 3-D convex hull, since I later want to know<br>
&gt; if current vertex is enclosed by its neighbors&#39; convex hull... If I use<br>
&gt; delaunay2D (by projecting my mesh onto a flat surface) would still be<br>
&gt; possible to check if the point is contained in this convex hull.<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Miguel<br>
&gt;<br>
&gt; 2011/7/26 David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi Miguel,<br>
&gt;&gt;<br>
&gt;&gt; The vtkDelaunay3D filter is for tetrahedral meshes, but your mesh<br>
&gt;&gt; looks like a triangle mesh.  So my guess is that you should be using<br>
&gt;&gt; vtkDelaunay2D instead.  But since Delanay2D is a 2D filter, you might<br>
&gt;&gt; have to project your mesh onto a flat surface first.<br>
&gt;&gt;<br>
&gt;&gt; Also, Delaunay often performs worse on noiseless data.  If you are<br>
&gt;&gt; working with synthetic data, you will get better results if you<br>
&gt;&gt; perturb each point with a small, random displacement.  With noiseless<br>
&gt;&gt; data, it is often the case that three points will lie along a straight<br>
&gt;&gt; line, and the Delaunay algorithm will consider three such points as<br>
&gt;&gt; forming a degenerate triangle.  Another problem with noiseless data,<br>
&gt;&gt; specifically for rectangular grids, is that they can result in<br>
&gt;&gt; situations where there is more than one valid Delaunay triangulation.<br>
&gt;&gt; These will cause the algorithm to go into deep recursion.<br>
&gt;&gt;<br>
&gt;&gt;  - David<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; 2011/7/25 Miguel Sotaquirá &lt;<a href="mailto:msotaquira@gmail.com">msotaquira@gmail.com</a>&gt;:<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt; I&#39;m using vtkDelaunay3D to create the local (1-ring neighborhood) convex<br>
&gt;&gt; &gt; hull for each point in a mesh. For now I&#39;m using a synthetic, perfectly<br>
&gt;&gt; &gt; regular, noiseless mesh, where each vertex has exactly 6 neighbors.<br>
&gt;&gt; &gt; I&#39;m having troubles creating this convex hull only on one of the<br>
&gt;&gt; &gt; vertices<br>
&gt;&gt; &gt; (the others are computed correctly). In this particular case the convex<br>
&gt;&gt; &gt; hull<br>
&gt;&gt; &gt; computed does NOT include one of the six neighbors, as seen on the image<br>
&gt;&gt; &gt; below:<br>
&gt;&gt; &gt; <a href="http://tinypic.com/r/2944hag/7" target="_blank">http://tinypic.com/r/2944hag/7</a><br>
&gt;&gt; &gt; the purple point being the center of the neighborhood, the gray spheres<br>
&gt;&gt; &gt; its<br>
&gt;&gt; &gt; neighbors and the gray lines the convex hull obtained from<br>
&gt;&gt; &gt; vtkDelaunay3D.<br>
&gt;&gt; &gt; Here&#39;s the code I&#39;m using (neighbors are introduced as a polydata named<br>
&gt;&gt; &gt; &quot;pointcloud&quot;):<br>
&gt;&gt; &gt; vtkSmartPointer&lt;vtkDelaunay3D&gt; delaunay3D =<br>
&gt;&gt; &gt; vtkSmartPointer&lt;vtkDelaunay3D&gt;::New();<br>
&gt;&gt; &gt; delaunay3D-&gt;SetInput(pointCloud);<br>
&gt;&gt; &gt; delaunay3D-&gt;Update();<br>
&gt;&gt; &gt; during execution I get this warning: &quot;vtkDelaunay3D (0x10345a490): 1<br>
&gt;&gt; &gt; degenerate triangles encountered, mesh quality suspect&quot;<br>
&gt;&gt; &gt; How come, since I&#39;m using a synthetic and perfectly regular mesh? As I<br>
&gt;&gt; &gt; mentioned before, for other points (which have the exact same<br>
&gt;&gt; &gt; characteristics) the convex hull is computed correctly.... Also, I&#39;ve<br>
&gt;&gt; &gt; tried<br>
&gt;&gt; &gt; using the methods &quot;SetTolerance&quot; and &quot;BoundingTriangulationOn&quot; of<br>
&gt;&gt; &gt; vtkDelaunay3D but with no success<br>
&gt;&gt; &gt; Thanks!<br>
&gt;&gt; &gt; Miguel<br>
</div></div></blockquote></div><br></div>