Hi Paulo,<br><br>You can use vtkMeshQuality to compute the quality of a mesh, but I don&#39;t think there is anything in VTK for improving the quality of a mesh.  Hopefully someone will tell me that I&#39;m wrong about this...<div>

<br></div><div>  David</div><div><br><br>On Sun, Dec 12, 2010 at 1:58 PM, Paulo Henrique Junqueira Amorim &lt;<a href="mailto:paulojamorim@gmail.com">paulojamorim@gmail.com</a>&gt; wrote:<br>&gt; Thank&#39;s David and Jim.<br>

&gt;<br>&gt; Generate a triangle is really what I wanted.<br>&gt;<br>&gt; By the same token, there is some way from a vtkPolyData, generate a mesh of<br>&gt; triangles more regular?<br>&gt;<br>&gt; I would like to improve the mesh for use in finite elements.<br>

&gt;<br>&gt; Ragards,<br>&gt; Paulo<br>&gt;<br>&gt;<br>&gt;<br>&gt; On 12 December 2010 14:04, David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; I&#39;m going to throw in a little addition.  You say &quot;triangle verts&quot; so<br>

&gt;&gt; I&#39;m guessing<br>&gt;&gt; you want your cells to be triangles, not verts.  If that is the case,<br>&gt;&gt; the code you<br>&gt;&gt; really need is as follows:<br>&gt;&gt;<br>&gt;&gt;  ids = vtkIdList()<br>&gt;&gt;  ids.SetNumberOfIds(3)<br>

&gt;&gt;<br>&gt;&gt;  for i in xrange(3):<br>&gt;&gt;     ids.SetId(i, i)<br>&gt;&gt;     points.InsertNextPoint(X[i],Y[i],Z[i])<br>&gt;&gt;<br>&gt;&gt;  vertices.InsertNextCell(ids) # call for every cell, not for every point<br>

&gt;&gt;<br>&gt;&gt;  polydata = vtkPolyData()<br>&gt;&gt;  polydata.SetPoints(points)<br>&gt;&gt;  polydata.SetPolys(vertices)  # use SetPolys for triangles<br>&gt;&gt;  polydata.Update()<br>&gt;&gt;<br>&gt;&gt; The above code will create a polydata that has one triangle.<br>

&gt;&gt;<br>&gt;&gt;  David<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; On Sun, Dec 12, 2010 at 8:43 AM, David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;<br>&gt;&gt; wrote:<br>&gt;&gt; &gt;<br>

&gt;&gt; &gt; On Sun, Dec 12, 2010 at 6:39 AM, Jim Peterson &lt;<a href="mailto:jimcp@cox.net">jimcp@cox.net</a>&gt; wrote:<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; Paulo,<br>&gt;&gt; &gt;&gt; I am no Python expert, but if I understand the sequence of events, you<br>

&gt;&gt; &gt;&gt; should create the polydata object before writing the file.<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; Hope that helps,<br>&gt;&gt; &gt;&gt; Jim<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; What Jim said.  Also, the id list is never filled in.  The following<br>

&gt;&gt; &gt; code is wrong:<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; ids = vtkIdList()<br>&gt;&gt; &gt; ids.SetNumberOfIds(3)<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; for i in xrange(3):<br>&gt;&gt; &gt;     ids.SetId(i, i)<br>&gt;&gt; &gt;     points.InsertNextPoint(X[i],Y[i],Z[i])<br>

&gt;&gt; &gt;     vertices.InsertNextCell(ids)<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; To fix it, you have two choices.  You can have all three verts in the<br>&gt;&gt; &gt; same cell:<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; ids = vtkIdList()<br>

&gt;&gt; &gt; ids.SetNumberOfIds(3)<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; for i in xrange(3):<br>&gt;&gt; &gt;     ids.SetId(i, i)<br>&gt;&gt; &gt;     points.InsertNextPoint(X[i],Y[i],Z[i])<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; vertices.InsertNextCell(ids)<br>

&gt;&gt; &gt; Or you can have each vert in its own cell:<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; ids = vtkIdList()<br>&gt;&gt; &gt; ids.SetNumberOfIds(1)<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; for i in xrange(3):<br>&gt;&gt; &gt;     ids.SetId(0, i)<br>

&gt;&gt; &gt;     points.InsertNextPoint(X[i],Y[i],Z[i])<br>&gt;&gt; &gt;     vertices.InsertNextCell(ids)<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; In the &quot;for&quot; loop, you were calling vertices.InsertNextCell(ids)<br>&gt;&gt; &gt; when &quot;ids&quot; still had some unititialized values, since the three<br>

&gt;&gt; &gt; ids values were not filled in until the third loop iteration.<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;   - David<br>&gt;<br>&gt;<br><br></div>