[vtkusers] Can a VTK file consists of Points only

Marco Nawijn nawijn at gmail.com
Fri Apr 26 01:18:08 EDT 2013


Hi,

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:
1 0.00 0.00 0.00

it should probably read:

1 0

The 1 means that for the definition of the cell you need one cell point.
The 0 is the index to the cell point.

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.

If you need a working example, drop me an e-mail and I will send you one.

Marco






On Fri, Apr 26, 2013 at 6:12 AM, Hayden Smith <s_hayden_28 at yahoo.com> wrote:

> Hello,
>    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?
>
> /**************************************************/
> # vtk DataFile Version 1.0
> track data of XX well
> ASCII
> DATASET POLYDATA
> POINTS 10 float
>  0.00 0.00 0.00
>  0.00 0.00 1400.00
>  0.00 0.48 1466.00
>  0.50 2.34 1600.00
>  2.68 4.17 1800.00
>  5.53 4.68 2000.00
>  9.15 4.36 2200.00
>  12.02 1.95 2400.00
>  8.68 -0.86 2599.96
>  -1.14 4.81 2799.95
>  VERTICES 10 10
> 0   0.00 0.00 0.00
> 1   0.00 0.00 1400.00
> 2  0.00 0.48 1466.00
> 3   0.50 2.34 1600.00
> 4   2.68 4.17 1800.00
> 5   5.53 4.68 2000.00
> 6   9.15 4.36 2200.00
> 7  12.02 1.95 2400.00
> 8  8.68 -0.86 2599.96
> 9   -1.14 4.81 2799.95
>  CELLS 10 10
> 1   0.00 0.00 0.00
> 1   0.00 0.00 1400.00
> 1   0.00 0.48 1466.00
> 1   0.50 2.34 1600.00
> 1   2.68 4.17 1800.00
> 1   5.53 4.68 2000.00
> 1   9.15 4.36 2200.00
> 1   12.02 1.95 2400.00
> 1   8.68 -0.86 2599.96
> 1    -1.14 4.81 2799.95
> CELL_TYPES 10
>
>
>
> /***************************************************/
> Thanks,
> Hayden
>    *From:* Hal Canary <hal at cs.unc.edu>
> *To:* vtkusers at vtk.org
> *Sent:* Thursday, April 25, 2013 9:21 PM
> *Subject:* Re: [vtkusers] Can a VTK file consists of Points only
>
> On 04/25/2013 10:08 PM, Hal Canary wrote:
> > On 04/25/2013 10:04 PM, Hayden Smith wrote:
> >>      I have a set of points which I would like to use to make a VTK
> >> file. As there are several formals, which formats will be suitable. I
> >> used Poydata type only with points. But I can't display the points.
> >> Please provide me suggestions.
> >
> > Add a cell array for the vertices. vtkMaskPoints can do that.
>
> Here's an example:
>
> #!/usr/bin/env python
> import vtk
> fileName = '/tmp/in.csv'
> outFileName = '/tmp/out.vtp'
> with open(fileName,'r') as f:
>     columns = f.readline().strip().split(',')
> reader = vtk.vtkDelimitedTextReader()
> reader.SetFileName(fileName)
> reader.SetFieldDelimiterCharacters(",")
> reader.DetectNumericColumnsOn()
> reader.SetHaveHeaders(True)
> reader.Update()
> numberOfRows = reader.GetOutput().GetNumberOfRows()
> tableToPolyData = vtk.vtkTableToPolyData()
> tableToPolyData.SetInputConnection(reader.GetOutputPort())
> tableToPolyData.SetXColumn(columns[0])
> tableToPolyData.SetYColumn(columns[1])
> tableToPolyData.SetZColumn(columns[2])
> try:
>     tableToPolyData.PreserveCoordinateColumnsAsDataArraysOn();
> except:
>     pass # introduced in 5.10?
> maskPoints = vtk.vtkMaskPoints()
> maskPoints.SetInputConnection(tableToPolyData.GetOutputPort())
> maskPoints.SetOnRatio(1)
> maskPoints.RandomModeOff()
> maskPoints.SetMaximumNumberOfPoints(numberOfRows)
> maskPoints.GenerateVerticesOn()
> maskPoints.SingleVertexPerCellOn()
> writer = vtk.vtkXMLPolyDataWriter()
> writer.SetInputConnection(maskPoints.GetOutputPort())
> writer.SetFileName(outFileName)
> writer.Write()
> ###############
> x,y,z,v
> 0,0,0,2
> 0,0,1,3
> 0,1,0,4
> 0,1,1,5
> 1,0,0,6
> 1,0,1,7
> 1,1,0,8
> 1,1,1,9
>
>
>
> _______________________________________________
> Powered by http://www.kitware.com/
>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130426/e54c0072/attachment.htm>


More information about the vtkusers mailing list