[vtkusers] [Paraview] (no subject)
Dan Lipsa
dan.lipsa at kitware.com
Thu Aug 6 23:11:43 EDT 2015
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> 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
>
> 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/e315752c/attachment.html>
More information about the vtkusers
mailing list