MantisBT - VTK
View Issue Details
0009068VTK(No Category)public2009-05-26 14:392016-08-12 09:55
ppeetteerr 
Kitware Robot 
normalmajoralways
closedmoved 
 
 
0009068: vtkPolyDataConnectivityFilter() doesn't filter data when passed to out using vtk_to_numpy
I'm not sure whether this is a vtkPolyDataConnectivityFilter() or a vtk_to_numpy issue, I assume the latter. vtkPolyDataConnectivityFilter() succesfully filters the data when rendering the data or writing the data to an stl. However when I use vtk_to_numpy the surronding regions are passed as well. The odd thing is that some of the regions are filtered. I can tell this by running size. In the example below SetExtractionModeToLargestRegion() eliminates some of the data (size(ar) shrinks from 618 to 597)

Using a standardized dataset the code is below

import vtk
import vtk.util.numpy_support as VN
from pylab import *

reader = vtk.vtkRectilinearGridReader()
reader.SetFileName('.\RectGrid2.vtk')

skinExtractor = vtk.vtkContourFilter()
skinExtractor.SetInputConnection(reader.GetOutputPort())
skinExtractor.SetValue(0, 5.2)

skinConnect=vtk.vtkPolyDataConnectivityFilter()
skinConnect.SetInputConnection(skinExtractor.GetOutputPort())
skinConnect.SetExtractionModeToLargestRegion()

skinNormals = vtk.vtkPolyDataNormals()
skinNormals.SetInputConnection(skinConnect.GetOutputPort())
skinNormals.SetFeatureAngle(60.0)

skinMapper = vtk.vtkPolyDataMapper()
skinMapper.SetInputConnection(skinNormals.GetOutputPort())
skinMapper.ScalarVisibilityOn()
skinMapper.SetColorModeToMapScalars()
skinMapper.SelectColorArray('scalars')

skinActor = vtk.vtkActor()
skinActor.SetMapper(skinMapper)

skinu = skinNormals.GetOutput()
# Force the pipeline to execute
skinu.Update()

ar = VN.vtk_to_numpy(skinu.GetPoints().GetData())
#print ar
temp=[]

for item in ar:
    if item[2]>0.899999:
        temp+=[item]


temp=array(temp)
x1=temp[:,0]
y1=temp[:,1]

scatter(x1,y1)
show()

ren = vtk.vtkRenderer()
ren.AddActor(skinActor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

ren.ResetCamera()
renWin.Render()
iren.Initialize()
iren.Start()

=========================================

No tags attached.
Issue History
2009-05-26 14:39ppeetteerrNew Issue
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2016-08-12 09:55Kitware RobotNote Added: 0037079
2016-08-12 09:55Kitware RobotStatusexpired => closed
2016-08-12 09:55Kitware RobotResolutionopen => moved
2016-08-12 09:55Kitware RobotAssigned To => Kitware Robot

Notes
(0037079)
Kitware Robot   
2016-08-12 09:55   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.