[vtkusers] Obtain single contour line from vtkStripper

pedrommcs pedrommcs at hotmail.com
Tue Feb 23 10:37:56 EST 2016


Hi everyone,

I'm having trouble extracting a specific line from a vtkStripper. For
example, for an isovalue = 90 I have 3 contour lines, which I can check in
*numberOfContourLines *variable. And I can get the lines in *cells*
variable. But how do I define a specific line to be the input for a
vtkPolyData? For example, how do I get the first line? Something similar to
cells[0] (this doesn't work)? 

Here is my code:

file_path = " path to some .vti file"

reader = vtk.vtkXMLImageDataReader()
reader.SetFileName(file_path)
reader.GetOutput().SetUpdateExtentToWholeExtent()
reader.Update()

flipYFilter = vtk.vtkImageFlip()
flipYFilter.SetFilteredAxis(1)
flipYFilter.SetInput(reader.GetOutput())
flipYFilter.Update()

image = flipYFilter.GetOutput()

extractSlice = vtk.vtkExtractVOI()
extractSlice.SetInput(image)
extractSlice.SetVOI(image.GetExtent()[0], image.GetExtent()[1], \
               image.GetExtent()[2], image.GetExtent()[3], \
               5, 5)
extractSlice.SetSampleRate(1, 1, 1)
extractSlice.Update()

contour = vtk.vtkContourFilter()
contour.SetInputConnection(extractSlice.GetOutputPort())
contour.SetValue(1,90)

contourStripper = vtk.vtkStripper()
contourStripper.SetInputConnection(contour.GetOutputPort())
contourStripper.Update()

numberOfContourLines = contourStripper.GetOutput().GetNumberOfLines()

cells  = contourStripper.GetOutput().GetLines()

cutPoly=vtk.vtkPolyData() 
cutPoly.SetPolys(cells[0]) #I want to change this to get first line,
cells[0] doesn't work, how to do it?

Thanks in advance.




--
View this message in context: http://vtk.1045678.n5.nabble.com/Obtain-single-contour-line-from-vtkStripper-tp5736755.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list