Scaling to 0.001 produces unexpected result

Dear all I am trying to scale a mesh to 0.001 but I get a mesh that does not look like the original one.

Here is the code I used:

    reader = vtk.vtkSTLReader()
    reader.SetFileName(inputFilename) 
    reader.Update()
    mTransform = vtk.vtkTransform()
    mTransformFilter = vtk.vtkTransformPolyDataFilter()
    mTransform.Scale(0.001,0.001,0.001)
    mTransformFilter.SetInputConnection(reader.GetOutputPort())
    mTransformFilter.SetTransform(mTransform)
    mTransformFilter.Update()
    writer = vtk.vtkSTLWriter() 
    writer.SetFileName(outputFilename) ;
    writer.SetInputConnection(mTransformFilter.GetOutputPort()) ;
    writer.Update()

Here are the scaled image using Slicer and the scaled image result using VTK code above:

scaledSlicer

scaledVTK

Can you share the input file?

How do the coordinate values look in the original and transformed STL files? (you can set format to ASCII to make the values in the file human-readable)

Thanks @lassoan for your comment. I am not sure what happened, I probably was doing something wrong. The same code seems to work now. Here is the result:

Screenshot%20from%202019-12-13%2012-38-52

1 Like