I’m using vtkClipPolyData to clip a vtkPolyData object.
Is it possible to preserve the array data stored in the source object? I noticed that after clipping, the output does not contain any point- or cell-data. If it’s really the case that vtkClipPolyData drops any array data, how to achieve that the result contains array data?
The reason why vtkClipPolyData drops point- or cell data is because it creates new points and cells. For these new elements, it is not immediately clear what data has to be assigned to them.
It would be cool (==> FEATURE REQUEST <== ) if vtkClipPolyData supported a data-interpolation mode where array-data is updated by making use of available data through interpolation.
As of know, I circumvented that problem by applying a mask on the points, ignoring cells entirely. This was feasible for me, but of course does not solve the problem in general for all uses of vtkClipPolyData. (The mask here contains the information if a point is lying on one side of the clip-plane, which I precomputed in a separate step)
I’ve never experienced the vtkClipPolyData filter not preserving the point/cell data like you mention…
We use the vtkClipPolyData filter like so in PyVista:
import vtk
import pyvista as pv
from pyvista import examples
# get some poly data object - use PyVista eample with cell data present
poly_data = examples.download_doorman()
# Make some implicit function to clip with:
plane = vtk.vtkPlane()
plane.SetNormal([1,0,0])
plane.SetOrigin(poly_data.GetCenter())
alg = vtk.vtkClipPolyData()
alg.SetInputDataObject(poly_data)
alg.SetClipFunction(plane) # the the cutter to use the plane we made
alg.SetInsideOut(False) # invert the clip if needed
alg.Update() # Perfrom the Cut
clipped = alg.GetOutput()
# Plot it up... use PyVista because it's easy
pv.plot(clipped, scalars='m_doorMan_clothing')