<div dir="ltr">For VTK 6, you will need to replace:<div><br></div><div>writer.SetInput(grid)</div><div><br></div><div>with</div><div><br></div><div>writer.SetInputData(grid)<br></div><div><br></div><div style>See: <a href="http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput">http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput</a></div>
<div style><br></div><div style>Regards</div><div style>   Andrew</div><div style><br></div><div><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
---------- Forwarded message ----------<br>From: Marco Nawijn &lt;<a href="mailto:nawijn@gmail.com" target="_blank">nawijn@gmail.com</a>&gt;<br>
To: Hayden Smith &lt;<a href="mailto:s_hayden_28@yahoo.com" target="_blank">s_hayden_28@yahoo.com</a>&gt;<br>Cc: &quot;<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>&quot; &lt;<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>&gt;<br>

Date: Mon, 29 Apr 2013 19:28:01 +0200<br>Subject: Re: [vtkusers] Can a VTK file consists of Points only<br><div dir="ltr">Hi Hayden,<div><br></div><div>Find below a fully functional example in Python for creating a &quot;mesh&quot;  with only vertices as cells.</div>

<div><br></div><div>I provided some comments in the file, so it should be relatively easy to follow. If not drop</div>
<div>more questions on the list and we will try to help. I also attached the file that is produced</div><div>by the script. </div><div><br></div><div>===== SCRIPT ========================================</div>
<div><div>#!/usr/bin/env python  </div><div><br></div><div>from vtk import vtkPoints, vtkCellArray, vtkVertex, vtkUnstructuredGrid</div><div>from vtk import vtkFloatArray</div><div>from vtk import vtkXMLUnstructuredGridWriter</div>


<div><br></div><div>from random import random</div><div><br></div><div>coords = (</div><div>    (0,0,2),</div><div>    (1,0,2),</div><div>    (1,1,2),</div><div>    (0,1,2),</div><div>    (2,0,2),</div><div>    (3,0,2),</div>


<div>    (3,1,2),</div><div>    (2,1,2))</div><div><br></div><div>#=== Create a VTK array to store points</div><div>points = vtkPoints()</div><div><br></div><div>#=== Loop over the list of coordinates and insert them into the array; store</div>


<div>#    corresponding point index (or id)</div><div>pids = []</div><div>for crd in coords:</div><div>    pids.append(points.InsertNextPoint(crd))</div><div><br></div><div># Create a VTK array to store cells</div><div>cells = vtkCellArray()</div>


<div><br></div><div>vertex      = vtkVertex()</div><div>typecode    = vertex.GetCellType()</div><div>ncellpoints = vertex.GetNumberOfPoints()</div><div><br></div><div>for p in pids:</div><div>    # Notify the cells array of how many cellpoints are needed to describe the</div>


<div>    # next cell that we want to insert</div><div>    cells.InsertNextCell(ncellpoints)</div><div><br></div><div>    # For a vertex, we only need to insert a single point index; for a triangle</div><div>    # this would typically be a loop</div>


<div>    cells.InsertCellPoint(p)</div><div><br></div><div># Create a data array</div><div>#</div><div><br></div><div>temperature = vtkFloatArray()</div><div>temperature.SetName(&#39;temperature&#39;)</div><div><br></div>


<div>npoints = points.GetNumberOfPoints()</div><div>temperature.SetNumberOfValues(npoints)</div><div><br></div><div># Insert some random data</div><div>for i in range(npoints):</div><div>    temperature.SetValue(i, random())</div>


<div><br></div><div>grid = vtkUnstructuredGrid()</div><div>grid.SetPoints(points)</div><div>grid.SetCells(typecode, cells)</div><div><br></div><div>grid.GetPointData().SetScalars(temperature)</div><div><br></div><div>writer = vtkXMLUnstructuredGridWriter()</div>


<div>writer.SetDataModeToAscii()</div><div>writer.SetInput(grid)</div><div>writer.SetFileName(&#39;vertex_demo.vtu&#39;)</div><div>writer.Write()</div><div><br></div></div><div><br></div><div><br></div><div>
<br></div><div><br></div></div><div class="gmail_extra"><br></div></blockquote></div><div><br></div>-- <br>___________________________________________<br>Andrew J. P. Maclean<br><br>___________________________________________
</div></div></div>