[vtkusers] Precision Loss During PolyData File Manipulation

Fastl, Thomas thomas.fastl at kcl.ac.uk
Tue Nov 10 12:40:17 EST 2015


Hello Sancho,

storing data as BINARY rather then ASCII solved the precision problem, thanks! But honestly, I don't understand why this is an issue when storing as ASCII, this should be possible since this can be quite convenient especially during code development for checking outputs. I'm still struggling with the vtkPolyDataReader() and associated precisions, therefore I want to provide a test example here:

def readPolyData(fileName):
    
    reader = vtk.vtkPolyDataReader()
    reader.SetFileName(fileName)
    reader.Update()

    return (reader.GetOutput())

personalizedMesh = readPolyData('test.vtk')

The first vertex in the file 'test.vtk' is specified to be at [32376.558590  16410.828120  19045.751950], however, running the provided test example leads to (32376.55859375  16410.828125  19045.751953125). I don't understand why random digits are added (would expect that only 0 are added) and therefore played around with DOUBLE, but couldn't get this to work. Can anybody help me on that? I read that more people had this problem, but couldn't find a solution, thanks!

Best, Thomas

________________________________________
From: vtkusers <vtkusers-bounces at vtk.org> on behalf of oyster <sancho at whu.edu.cn>
Sent: Tuesday, November 10, 2015 12:09 AM
To: vtkusers at vtk.org
Subject: Re: [vtkusers] Precision Loss During PolyData File Manipulation

Hi, Thomas
The precision loss is caused by the polydatawriter, since you stored it as
ASCII. Using BINARY would cure this usually.

BTW, is you are not sure float will be as precise as it, set vtkPoints'
datatype to DOUBLE. Some vtkAlgorithm also has similar settings.

Regards,
Sancho.



--
View this message in context: http://vtk.1045678.n5.nabble.com/Precision-Loss-During-PolyData-File-Manipulation-tp5734888p5734889.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


More information about the vtkusers mailing list