apply filter multiple times
Martin Genet <[email protected]> Sat, 6 Jul 2019 22:30:56 +0200
| Newsgroups | gmane.comp.lib.vtk.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------853626218AB1CE47299AA67D
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Dear all:
I am having some issue setting up a rather complex pipeline involving,
but not exclusively, vtk objects and filters. I think basically the
issue boils down to this: I create an unstructured grid with some vector
field, warp it, modify the vector field (outside vtk), warp it again,
etc. Pretty basic, right? Of course I do not want to reallocate an
unstructured grid for the warped mesh each time I run the warp filter,
but rather modify the one that is allocated the first time I run the
warp filter. Makes sense? I have done this many times, for pipelines
that only involve vtk stuff. However, I am not sure how to do this for
pipelines involving non-vtk operations. Attached is a minimal example: I
create a sphere, warp it along the normals, scale the normals, warp it
again using the already existing warp filter (here the scaling is not
taken into account for some reason), and warp it using a new warp filter
(here it is, but I guess it creates a new object instead of modifying
the existing one, right?). This seem like a trivial issue, but I cannot
seem to figure it out. Can someone help me? Thank you so much.
Martin
--------------853626218AB1CE47299AA67D
Content-Type: text/x-python-script; x-mac-type="0"; x-mac-creator="0";
name="test_vtk.py"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment;
filename="test_vtk.py"
#coding=utf8
import vtk
import vtk.numpy_interface.dataset_adapter as dsa
import vtk.numpy_interface.algorithms as algs
sphere_source = vtk.vtkSphereSource()
sphere_source.Update()
sphere = sphere_source.GetOutput()
sphere.GetPointData().SetActiveVectors("Normals")
print (sphere.GetBounds()[4:6])
pdata_writer = vtk.vtkPolyDataWriter()
pdata_writer.SetInputData(sphere)
pdata_writer.SetFileName("test_vtk_sphere.vtk")
pdata_writer.Write()
warp = vtk.vtkWarpVector()
# warp.SetInputConnection(sphere_source.GetOutputPort())
warp.SetInputDataObject(sphere)
# warp.SetInputData(sphere)
warp.Update()
warp_sphere = warp.GetOutput()
print (warp_sphere.GetBounds()[4:6])
pdata_writer.SetInputData(warp_sphere)
pdata_writer.SetFileName("test_vtk_warp_sphere1.vtk")
pdata_writer.Write()
sphere_np = dsa.WrapDataObject(sphere)
sphere_np.GetPointData()["Normals"][:] = 2*sphere_np.GetPointData()["Normals"][:]
warp.Update()
print (warp_sphere.GetBounds()[4:6]) # does not take scaling of normals into account…
pdata_writer.SetInputData(warp_sphere)
pdata_writer.SetFileName("test_vtk_warp_sphere2.vtk")
pdata_writer.Write()
warp = vtk.vtkWarpVector()
# warp.SetInputConnection(sphere_source.GetOutputPort())
warp.SetInputDataObject(sphere)
# warp.SetInputData(sphere)
warp.Update()
warp_sphere = warp.GetOutput()
print (warp_sphere.GetBounds()[4:6]) # this one works
pdata_writer.SetInputData(warp_sphere)
pdata_writer.SetFileName("test_vtk_warp_sphere3.vtk")
pdata_writer.Write()
--------------853626218AB1CE47299AA67D
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
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
--------------853626218AB1CE47299AA67D--