[vtkusers] [Paraview] (no subject)
Schubert, Raphael
raphael.schubert at iwm.fraunhofer.de
Fri Aug 7 05:01:57 EDT 2015
The way I understand the file format specification it should be illegal to define a FIELD dataset in addition to, e.g, STRUCTURED_POINTS, as I can find it neither explicitly allowed (there is only mention of one dataset per file) nor presented in an example. It therefore seems like an accidental feature in vtk that I can actually read back the produced files.
Am I missing something in the file format?
Maybe I presented this poorly, please let me give another example with additional point data, also straight out of python. Here are two fields, one in the dataset section, and one in the point data section. By my reading of the file format spec, the field in the dataset section should not be permitted to be there, even after the details for the STRUCTURED_POINTS.
# vtk DataFile Version 3.0
ASCII
DATASET STRUCTURED_POINTS
FIELD FieldData 1
Pi 1 1 double
3.141
DIMENSIONS 2 2 2
SPACING 1 1 1
ORIGIN 0 0 0
POINT_DATA 8
FIELD FieldData 1
Index 1 8 long
0 1 2 3 4 5 6 7
________________________________
Von: Dan Lipsa [dan.lipsa at kitware.com]
Gesendet: Freitag, 7. August 2015 05:11
Bis: Schubert, Raphael; paraview at paraview.org; vtkusers at vtk.org
Betreff: Re: [Paraview] (no subject)
Raphael,
Indeed, the FIELD definitions have to be after the dataset details according to:
http://www.vtk.org/wp-content/uploads/2015/04/file-formats.pdf
On Thu, Aug 6, 2015 at 11:14 AM Schubert, Raphael <raphael.schubert at iwm.fraunhofer.de<mailto:raphael.schubert at iwm.fraunhofer.de>> wrote:
I use the following script to generate three vtk files containing different dataset types and an additional FIELD.
import numpy as np
import vtk
from vtk.util.numpy_support import numpy_to_vtk
for dataset in (vtk.vtkStructuredPoints,
vtk.vtkRectilinearGrid,
vtk.vtkPolyData):
vtkData = dataset()
if dataset is vtk.vtkStructuredPoints:
vtkWriter = vtk.vtkStructuredPointsWriter()
vtkData.SetOrigin(0.0, 0.0, 0.0)
vtkData.SetSpacing(1.0, 1.0, 1.0)
vtkData.SetExtent(0, 1, 0, 1, 0, 1)
elif dataset is vtk.vtkPolyData:
vtkWriter = vtk.vtkPolyDataWriter()
vtkPoints = vtk.vtkPoints()
vtkPoints.SetData(numpy_to_vtk(np.asarray(
[[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[1.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[1.0, 0.0, 1.0],
[0.0, 1.0, 1.0],
[1.0, 1.0, 1.0]])))
vtkData.SetPoints(vtkPoints)
elif dataset is vtk.vtkRectilinearGrid:
vtkWriter = vtk.vtkRectilinearGridWriter()
vtkData.SetDimensions(2,2,2)
vtkData.SetXCoordinates(numpy_to_vtk(np.asarray([0.0, 1.0])))
vtkData.SetYCoordinates(numpy_to_vtk(np.asarray([0.0, 1.0])))
vtkData.SetZCoordinates(numpy_to_vtk(np.asarray([0.0, 1.0])))
# file scope definition of Pi
vtkArray = numpy_to_vtk(np.asarray(3.141).reshape(1,1),deep=1)
vtkArray.SetName("Pi")
vtkData.GetFieldData().AddArray(vtkArray)
vtkWriter.SetFileName(str(dataset) + ".vtk")
vtkWriter.SetHeader("")
vtkWriter.SetFileTypeToASCII()
vtkWriter.SetInput(vtkData)
vtkWriter.Write()
/endscript
The files generated from this are
# vtk DataFile Version 3.0
ASCII
DATASET POLYDATA
FIELD FieldData 1
Pi 1 1 double
3.141
POINTS 8 double
0 0 0 1 0 0 0 1 0
1 1 0 0 0 1 1 0 1
0 1 1 1 1 1
# vtk DataFile Version 3.0
ASCII
DATASET RECTILINEAR_GRID
FIELD FieldData 1
Pi 1 1 double
3.141
DIMENSIONS 2 2 2
X_COORDINATES 2 double
0 1
Y_COORDINATES 2 double
0 1
Z_COORDINATES 2 double
0 1
# vtk DataFile Version 3.0
ASCII
DATASET STRUCTURED_POINTS
FIELD FieldData 1
Pi 1 1 double
3.141
DIMENSIONS 2 2 2
SPACING 1 1 1
ORIGIN 0 0 0
Note the FIELD preceding the dataset details. All files can be read back into python without problems, but when trying to view each file in using Paraview 4.3.1, things get interesting:
- POLYDATA works.
- RECTILINEAR_GRID produces an error (which, btw, contains a typo), refuses to render anything but displays everything correctly in the Information tab.
ERROR: In /home/kitware/Dashboards/buildbot/paraview-debian4dash-linux-shared-release_qt4_superbuild/source-paraview/VTK/IO/Parallel/vtkPDataSetReader.cxx, line 701
vtkPDataSetReader (0x8874010): Expecting 'DIMENSIONS' insted of: FIELD
- STRUCTURED_POINTS does not produce any errors, still refuses to render but displays everything correctly in the Information tab.
If I now (manually) put the FIELDS definition after the dataset details, everything works fine.
Is this problem with Paraview, or am I doing something with the vtk format that should not be possible at all? I got the idea from http://www.visitusers.org/index.php?title=Time_and_Cycle_in_VTK_files.
Thanks
Raphael
Software versions:
Paraview 4.3.1 Linux 64bit
Python 2.7.8 |Anaconda 2.1.0 (64-bit)| (default, Aug 21 2014, 18:22:21)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
vtk.vtkVersion().GetVTKVersion()
'5.10.1'
_______________________________________________
Powered by www.kitware.com<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 ParaView Wiki at: http://paraview.org/Wiki/ParaView
Search the list archives at: http://markmail.org/search/?q=ParaView
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150807/96323984/attachment.html>
More information about the vtkusers
mailing list