<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:10pt;color:#000000;background-color:#FFFFFF;font-family:Arial,Helvetica,sans-serif;">
<div id="divtagdefaultwrapper" style="font-size:10pt; color:#000000; background-color:#FFFFFF; font-family:Arial,Helvetica,sans-serif">
Hey VTK-User,</div>
<div id="divtagdefaultwrapper" style="font-size:10pt; color:#000000; background-color:#FFFFFF; font-family:Arial,Helvetica,sans-serif">
<span style="font-size: 10pt;"><br>
</span></div>
<div id="divtagdefaultwrapper" style="background-color: rgb(255, 255, 255);"><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">I recently started using the </span></font><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">VTK </span></font><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">libraries
 in Python and would need some help to preserve the initial precision of 12 digits lost during </span></font><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">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 </span></font><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">the </span>initial<span style="font-size: 10pt;"> precision is lost. </span></font><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">I
 checked the coordinates after the reading and the </span><span style="font-size: 10pt;">cleaning phase </span><span style="font-size: 10pt;">and realized that the precision loss occurs in the writing stage. In addition, some random numerical </span>artifacts </font><font face="Arial, Helvetica, sans-serif" style="font-size: 10pt;"><span style="font-size: 10pt;">seem
 to be added to the coordinates after the reading which I cannot explain. </span></font><span style="font-size: 10pt; font-family: Arial, Helvetica, sans-serif;">Below is the code I'm using:</span></div>
<div id="divtagdefaultwrapper" style="background-color: rgb(255, 255, 255);">
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;"><br>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;">def readPolyData(fileName):</span><br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;">
<div>    </div>
<div>    reader = vtk.vtkPolyDataReader()</div>
<div>    reader.SetFileName(fileName)</div>
<div>    reader.Update()</div>
<div>    </div>
<div>    return (reader.GetOutput())</div>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;"><br>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;">
<div>def writePolyData(outputPolyData,fileName):</div>
<div><br>
</div>
<div>    writer = vtk.vtkPolyDataWriter()</div>
<div>    writer.SetInput(outputPolyData)</div>
<div>    writer.SetFileTypeToASCII()</div>
<div>    writer.SetFileName(fileName)</div>
<div><br>
</div>
<div>    return (writer.Write())</div>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;"><br>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;">
<div>def cleanPolyData(inputPolyData):</div>
<div><br>
</div>
<div>    cleaner = vtk.vtkCleanPolyData()</div>
<div>    cleaner.SetInput(inputPolyData)</div>
<div>    cleaner.Update()</div>
<div><br>
</div>
<div>    return (cleaner.GetOutput())</div>
</span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
if __name__ == '__main__':<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;"><span>    </span></span></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;"><span>    </span>personalizedMesh = readPolyData(inputPersonalized)</span><br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<div><span>    </span>personalizedMesh = cleanPolyData(personalizedMesh)</div>
<div><span style="font-size: 10pt;"><span>    </span>personalizedAdapt = writePolyData(personalizedMesh,preFix+inputPersonalized)</span><br>
</div>
</div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<span style="font-size: 10pt;"><br>
</span></div>
<div>
<div><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">How can I increase the number of digits when writing the cleaned mesh data back to a file in</span></font><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;"> writePolyData()?
 W</span></font><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;">hy are there numerical </span>artifacts<span style="font-size: 10pt;"> </span>occurring<span style="font-size: 10pt;"> 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!</span></font></div>
</div>
<div><font face="Arial, Helvetica, sans-serif"><span style="font-size: 10pt;"><br>
</span></font></div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
Best, Thomas</div>
<div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 10pt;">
<br>
</div>
</div>
</div>
</body>
</html>