

Here is an edited version of your script: from vtk import (vtkUnstructuredGridReader, vtkDataSetMapper, vtkActor,Īrray = c2p.GetOutput().GetPointData().GetArray(0)Ĭontours.GenerateValues(10,vrange,vrange) To make things more visible I would also suggest to place the contour line actor after the grid. Now the fitler should work as you expect.

For the latter you can do: contours.GenerateValues(10,vrange,vrange) So you need to either pick a value in this range or automatically generate few in the range. The selected array (first in your dataset) however has values only in the range: array = c2p.GetOutput().GetPointData().GetArray(0) This means that you want a contour line at value 9. Since you are using SetInputData/ GetOutput API you need to call c2p.Update() before calling c2p.GetOutput() # c2p.GetOutput() is empty ! To validate : call print(c2p.GetOutput().GetNumberOfPoints()) There are only two minor issues with your script. Interactor.SetRenderWindow(renderer_window)įor someone new to VTK this is very good ! # Create the RendererWindowInteractor and display the vtk_file Renderer.SetBackground(1, 1, 1) # Set background to white

Gridactor.GetProperty().EdgeVisibilityOn() Mapper.SetInputConnection(contours.GetOutputPort()) When you run Contour on a surface, you get lines. The total number of points is 10 × 20 × 30. You may need to apply filters such as Cell Data to Point Data or Point Data to Cell Data to convert arrays between different associations for that. #gridmapper.GetInput().GetCellData().SetActiveScalars("A") For example, an image data of extents ( 0, 9), ( 0, 19), ( 0, 29) has 10 points in the x-direction, 20 points in the y-direction, and 30 points in the z-direction. VtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor, vtkContourFilter) I need help pls from vtk import (vtkUnstructuredGridReader, vtkDataSetMapper, vtkActor, I can’t upload an image (I am a new user here). Hi, I am new in VTK, and I have a vtk UnstructuredGridFile and I read it, but it show me with polygons and I need to deploy it as isosurface.
