<div dir="ltr"><div>Hi,</div><div> </div><div>I have not worked with the ASCII  VTK format, but looking at it I suspect that you have to drop the coordinates in the CELLS section and use point indices instead, so instead of:</div>
<div>1            0.00         0.00         0.00</div><div> </div><div>it should probably read:</div><div> </div><div>1 0</div><div> </div><div>The 1 means that for the definition of the cell you need one cell point. The 0 is the index to the cell point.</div>
<div> </div><div>If you have access to Python with the VTK bindings, I highly recommend you to use that. You can easily build an in-memory grid and export it to a VTK file. </div><div> </div><div>If you need a working example, drop me an e-mail and I will send you one.</div>
<div> </div><div>Marco</div><div> </div><div> </div><div> </div><div> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 26, 2013 at 6:12 AM, Hayden Smith <span dir="ltr">&lt;<a href="mailto:s_hayden_28@yahoo.com" target="_blank">s_hayden_28@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div><span>Hello,</span></div><div><span>   Thank you very much for the reply. Could you tell me what is the problem with the following vtk file, why it shows error reading cell data?</span></div>
<div><span></span> </div><div><span>/**************************************************/</span></div><span><span lang="EN"><div># vtk DataFile Version 1.0</div><div>
</div><div>track data of XX well</div><div>
</div><div>ASCII</div><div>
</div><div>DATASET POLYDATA</div><div>
</div><div>POINTS 10 float</div><div>
</div><div>             0.00         0.00         0.00</div><div>
</div><div>             0.00         0.00      1400.00</div><div>
</div><div>             0.00         0.48      1466.00</div><div>
</div><div>             0.50         2.34      1600.00</div><div>
</div><div>             2.68         4.17      1800.00</div><div>
</div><div>             5.53         4.68      2000.00</div><div>
</div><div>             9.15         4.36      2200.00</div><div>
</div><div>            12.02         1.95      2400.00</div><div>
</div><div>             8.68        -0.86      2599.96</div><div>
</div><div>            -1.14         4.81      2799.95</div><div>
</div><div>           </div><div>
</div><div>VERTICES 10 10</div><div>
</div><div>0   0.00         0.00         0.00</div><div>
</div><div>1   0.00         0.00      1400.00</div><div>
</div><div>2            0.00         0.48      1466.00</div><div>
</div><div>3            0.50         2.34      1600.00</div><div>
</div><div>4            2.68         4.17      1800.00</div><div>
</div><div>5            5.53         4.68      2000.00</div><div>
</div><div>6            9.15         4.36      2200.00</div><div>
</div><div>7  12.02         1.95      2400.00</div><div>
</div><div>8            8.68        -0.86      2599.96</div><div>
</div><div>9            -1.14         4.81      2799.95</div><div>

</div><div> </div><div>
</div><div>CELLS 10 10</div><div>
</div><div>1            0.00         0.00         0.00</div><div>
</div><div>1            0.00         0.00      1400.00</div><div>
</div><div>1             0.00         0.48      1466.00</div><div>
</div><div>1             0.50         2.34      1600.00</div><div>
</div><div>1             2.68         4.17      1800.00</div><div>
</div><div>1            5.53         4.68      2000.00</div><div>
</div><div>1            9.15         4.36      2200.00</div><div>
</div><div>1            12.02         1.95      2400.00</div><div>
</div><div>1            8.68        -0.86      2599.96</div><div>
</div><div>1    -1.14         4.81      2799.95</div><div>

</div><div>CELL_TYPES 10</div></span></span><div><span></span> </div><div><span></span> </div><div><span></span> </div><div><span>/***************************************************/</span></div><div>Thanks,</div><div>Hayden<var></var><br>
</div>  <div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div dir="ltr"> <div style="margin:5px 0px;padding:0px;border:1px solid rgb(204,204,204);line-height:0;font-size:0px;min-height:0px" readonly>
</div>  <font face="Arial"> <b><span style="font-weight:bold">From:</span></b> Hal Canary &lt;<a href="mailto:hal@cs.unc.edu" target="_blank">hal@cs.unc.edu</a>&gt;<br> <b><span style="font-weight:bold">To:</span></b> <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a> <br>
 <b><span style="font-weight:bold">Sent:</span></b> Thursday, April 25, 2013 9:21 PM<br> <b><span style="font-weight:bold">Subject:</span></b> Re: [vtkusers] Can a VTK file consists of Points only<br> </font> </div> <div>
<div><div class="h5"><br>
On 04/25/2013 10:08 PM, Hal Canary wrote:<br>&gt; On 04/25/2013 10:04 PM, Hayden Smith wrote:<br>&gt;&gt;       I have a set of points which I would like to use to make a VTK<br>&gt;&gt; file. As there are several formals, which formats will be suitable. I<br>
&gt;&gt; used Poydata type only with points. But I can&#39;t display the points.<br>&gt;&gt; Please provide me suggestions.<br>&gt; <br>&gt; Add a cell array for the vertices. vtkMaskPoints can do that.<br><br>Here&#39;s an example:<br>
<br>#!/usr/bin/env python<br>import vtk<br>fileName = &#39;/tmp/in.csv&#39;<br>outFileName = &#39;/tmp/out.vtp&#39;<br>with open(fileName,&#39;r&#39;) as f:<br>    columns = f.readline().strip().split(&#39;,&#39;)<br>reader = vtk.vtkDelimitedTextReader()<br>
reader.SetFileName(fileName)<br>reader.SetFieldDelimiterCharacters(&quot;,&quot;)<br>reader.DetectNumericColumnsOn()<br>reader.SetHaveHeaders(True)<br>reader.Update()<br>numberOfRows =
 reader.GetOutput().GetNumberOfRows()<br>tableToPolyData = vtk.vtkTableToPolyData()<br>tableToPolyData.SetInputConnection(reader.GetOutputPort())<br>tableToPolyData.SetXColumn(columns[0])<br>tableToPolyData.SetYColumn(columns[1])<br>
tableToPolyData.SetZColumn(columns[2])<br>try:<br>    tableToPolyData.PreserveCoordinateColumnsAsDataArraysOn();<br>except:<br>    pass # introduced in 5.10?<br>maskPoints = vtk.vtkMaskPoints()<br>maskPoints.SetInputConnection(tableToPolyData.GetOutputPort())<br>
maskPoints.SetOnRatio(1)<br>maskPoints.RandomModeOff()<br>maskPoints.SetMaximumNumberOfPoints(numberOfRows)<br>maskPoints.GenerateVerticesOn()<br>maskPoints.SingleVertexPerCellOn()<br>writer =
 vtk.vtkXMLPolyDataWriter()<br>writer.SetInputConnection(maskPoints.GetOutputPort())<br>writer.SetFileName(outFileName)<br>writer.Write()<br>###############<br>x,y,z,v<br>0,0,0,2<br>0,0,1,3<br>0,1,0,4<br>0,1,1,5<br>1,0,0,6<br>
1,0,1,7<br>1,1,0,8<br>1,1,1,9<br><br><br><br>_______________________________________________<br></div></div>Powered by <a href="http://www.kitware.com/" target="_blank">http://www.kitware.com/</a><div class="im"><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br><br></div></div> </div> </div>  </div></div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>