[vtkusers] vtkUnstructuredGridWriter only stores 6 digits?

Nico Schlömer nico.schloemer at gmail.com
Thu Dec 17 05:40:54 EST 2015


This smells very much like the vtk_array data being interpreted as single
precision even though
```
  Data type: double
```
Cheers,
Nico

On Thu, Dec 17, 2015 at 2:23 AM Nico Schlömer <nico.schloemer at gmail.com>
wrote:

> Hi everyone,
>
> with
> ```
> import numpy
> import vtk
> from vtk.util import numpy_support
>
> mesh = vtk.vtkUnstructuredGrid()
>
> # add points to mesh
> points = numpy.array([
>     [0.123456789, 3.14159265, 0.0]
>     ])
> vtk_points = vtk.vtkPoints()
> vtk_array = numpy_support.numpy_to_vtk(points)
> vtk_points.SetData(vtk_array)
> mesh.SetPoints(vtk_points)
>
> # write to VTK
> writer = vtk.vtkUnstructuredGridWriter()
> writer.SetFileTypeToASCII()
> writer.SetFileName('test.vtk')
> writer.SetInputData(mesh)
> writer.Write()
> ```
> I noticed that, although the `point` is given with some precision, the
> output `test.vtk` file only contains 6 digits of accuracy,
> ```
> 0.123457 3.14159 0
> ```
> The numpy data type hosts 8 digits.
>
> Is this a bug or expected? How to mitigate?
>
> Cheers,
> Nico
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151217/925d5af0/attachment.html>


More information about the vtkusers mailing list