[vtkusers] vtkTransform: doesn't work for long distance translation
Todd Martin
nztoddler at yahoo.com
Thu Dec 14 21:25:45 EST 2017
As a work-around could you not just change your length unit to km? Or do you lose accuracy then?
Todd.
On Friday, December 15, 2017, 2:59:58 PM GMT+13, kenichiro yoshimi <rccm.kyoshimi at gmail.com> wrote:
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
>
_______________________________________________
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vtk.org/pipermail/vtkusers/attachments/20171215/d95fc420/attachment.html>
More information about the vtkusers
mailing list