[vtkusers] vtkTransform: doesn't work for long distance translation

kenichiro yoshimi rccm.kyoshimi at gmail.com
Thu Dec 14 20:59:32 EST 2017


Hello,

Usually setting double precision for the transform filter solves the problem.
 transformFilter.SetOutputPointsPrecision(vtk.vtkAlgorithm.DOUBLE_PRECISION)

But in your case, switching to double is not sufficient for preventing
the loss of trailing digits because the difference in the absolute
value is too large between the coordinates of text polydata with 1e-10
and the translation-value with 1e+7. It might be more practical to
display string as labels using vtkLabeledDataMapper and so on.

Thanks

2017-12-15 1:10 GMT+09:00 Alexey Pechnikov <pechnikov at mobigroup.ru>:
> This sample code works correct:
>
> transform = vtk.vtkTransform()
> transform.Translate(0, 100, 0)
>
> but the same code produces bad geometry:
>
> transform = vtk.vtkTransform()
> transform.Translate(0,10000000, 0)
>
> P.S. Yes, I really need y=10000000 for GIS data. And I can use the same
> coordinates for VTK data arrays without any problem.
>
>
> There is the full test script below:
>
> import sys
>
> sys.path.append("/usr/local/Cellar/vtk/8.0.1_1//lib/python2.7/site-packages/vtk/")
>
>
> import vtk
>
>
> text = vtk.vtkVectorText()
>
> text.SetText('PLD003')
>
>
> # Set up a transform to move the label to a new position.
>
> transform = vtk.vtkTransform()
>
> transform.Identity()
>
> transform.Translate(0, 10000000, 0)
>
> #transform.Translate(100,100,100)
>
>
> transformFilter = vtk.vtkTransformPolyDataFilter()
>
> for x in range(100):
>
>     transformFilter.SetTransform(transform)
>
> transformFilter.SetInputConnection(text.GetOutputPort())
>
>
> writer = vtk.vtkXMLPolyDataWriter()
>
> writer.SetInputConnection(transformFilter.GetOutputPort())
>
> writer.SetFileName('text.vtp')
>
> writer.SetDataModeToAscii()
>
> writer.Write()
>
>
> --
> Best regards, Alexey Pechnikov.
>
> _______________________________________________
> 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:
> https://vtk.org/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list