[vtkusers] VTK file data precision

Dominik Szczerba dominik at itis.ethz.ch
Tue Feb 16 14:26:19 EST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You can set up the writer to write in a binary format and not lose any
precision.

Dominik

Nico Schlömer wrote:
> Hi,
> 
> this issue may have come up before:
> 
> I'm using VTK to store some numerical data for me, specifically
> 
> I do so by
> 
> 1.) Filling the scalar field; notice vtkDOUBLEArray.
> =============================== *snip* ===============================
>     vtkSmartPointer<vtkDoubleArray> scalars =
>         vtkSmartPointer<vtkDoubleArray>::New();
>    [ fill with data ]
> =============================== *snap* ===============================
> 
> 2.) Plugging the field into imageData:
> =============================== *snip* ===============================
>     const vtkSmartPointer<vtkImageData>   imageData;
>     imageData->GetPointData()->AddArray ( scalars );
> =============================== *snap* ===============================
> 
> and (3.) Printing the image data to a file:
> =============================== *snip* ===============================
>     vtkSmartPointer<vtkStructuredPointsWriter> writer =
> vtkSmartPointer<vtkStructuredPointsWriter>::New();
>     writer->SetFileName ( "myfile.vtk" );
>     writer->SetInput ( imageData );
>     writer->Write();
> =============================== *snap* ===============================
> 
> What I eventually get is a nice standards-compliant VTK file; an
> extract from its contents would be
> =============================== *snip* ===============================
> [...]
> DIMENSIONS 61 61 1
> SPACING 0.0833333 0.0833333 0
> ORIGIN 0 0 0
> POINT_DATA 3721
> FIELD FieldData 1
> psi 2 3721 double
> 0.590845 -2.3876e-13 0.587619 0.0616976 0.57869 0.112716 0.565679
> 0.156785 0.549682
> [...]
> =============================== *snip* ===============================
> 
> Wow -- were have all the 15 digits of my machines double-precision
> gone? They seem like lousy floats!
> -- Any explanation for this? How would I be able to store all digits?
> 
> Cheers,
> Nico
> _______________________________________________
> 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
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkt68VEACgkQ/EBMh9bUuzJvkACfYoY0IZNlqlrFZTYgxiDifmmH
RzIAn2gKnKSt0DykK42KC3I8eaMQsvK6
=wx67
-----END PGP SIGNATURE-----



More information about the vtkusers mailing list