[vtkusers] Precision Loss During PolyData File Manipulation
Fastl, Thomas
thomas.fastl at kcl.ac.uk
Mon Nov 9 15:06:33 EST 2015
Hey VTK-User,
I recently started using the VTK libraries in Python and would need some help to preserve the initial precision of 12 digits lost during file writing. I want to read a file containing polydata to perform a cleaning and write the resulting data back to another file, however, during this manipulation the initial precision is lost. I checked the coordinates after the reading and the cleaning phase and realized that the precision loss occurs in the writing stage. In addition, some random numerical artifacts seem to be added to the coordinates after the reading which I cannot explain. Below is the code I'm using:
def readPolyData(fileName):
reader = vtk.vtkPolyDataReader()
reader.SetFileName(fileName)
reader.Update()
return (reader.GetOutput())
def writePolyData(outputPolyData,fileName):
writer = vtk.vtkPolyDataWriter()
writer.SetInput(outputPolyData)
writer.SetFileTypeToASCII()
writer.SetFileName(fileName)
return (writer.Write())
def cleanPolyData(inputPolyData):
cleaner = vtk.vtkCleanPolyData()
cleaner.SetInput(inputPolyData)
cleaner.Update()
return (cleaner.GetOutput())
if __name__ == '__main__':
personalizedMesh = readPolyData(inputPersonalized)
personalizedMesh = cleanPolyData(personalizedMesh)
personalizedAdapt = writePolyData(personalizedMesh,preFix+inputPersonalized)
How can I increase the number of digits when writing the cleaned mesh data back to a file in writePolyData()? Why are there numerical artifacts occurring in the reading of the polydata and how can I get rid of them? Basically, I want the coordinates of the polydata to be exactly the same before and after the reading, only the mesh should be cleaned. I really appreciate any help/hint from your side, thanks!
Best, Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151109/f3dfb43c/attachment.html>
More information about the vtkusers
mailing list