[vtkusers] Contour, ContourWidget and triangles filler
cory.quammen at kitware.com
Thu Jul 16 10:41:10 EDT 2015
Welcome to VTK!
Thanks for providing the code sample. You must be using VTK 5-something? In
6 and above, your SetInput() calls need to be changed to SetInputData().
Also, as a general note about using VTK, you can use
to create pipelines rather than pass vtkPolyData objects around. This is
usually preferable as any changes to your upstream algorithms will
propagate down to the renderer automatically. That might save you some code.
Otherwise your example is pretty nice and compact in my opinion.
To update the surface triangles, you need to set up an observer on the
contourWidget's InteractionEvent. You can do this with
where my_callback is defined with
def my_callback(contourWidget, unused):
global contourWidget, mapper
td = gen_triangles(cd)
Note that I've made the mapper global so you can access it in the callback.
The first argument is the contour widget and the second is just the event
type, which you don't need in this callback.
By the way, you will likely get better results for the surface if you use
the following definition of gen_triangles:
clsdPoly = vtk.vtkPolyData()
numPts = cd.GetNumberOfPoints()
idList = vtk.vtkIdList()
[idList.SetId(i, i) for i in xrange(numPts)]
triangles = vtk.vtkTriangleFilter()
This creates a VTK polygon cell which works better with the
vtkTriangleFilter than the line cells from the contour widget
Hope that helps,
On Wed, Jul 15, 2015 at 1:01 AM, Oleg Krivosheev <
oleg.krivosheev at xcision.com> wrote:
> Hi, All
> what I'm trying to do is to have editable contour in vtkContourWidget,
> with internal
> area filled with somewhat transparent color. What I managed to do is to
> make contour,
> put it into a widget, generate triangles strip from the contour via
> vtkTriangleFilter and
> draw it all together, Python code at the link
> Now questions. Is it a good way to proceed? Looks very cumbersome to me,
> but I'm new to VTK.
> Another big question is how to connect contour edit action (say, moving or
> adding point)
> with triangle strip update. Right now as soon as I move point, contour is
> but triangles filler is not
> Any help is greatly appreciated
> Powered by www.kitware.com
> Visit other Kitware open-source projects at
> Please keep messages on-topic and check the VTK FAQ at:
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> Follow this link to subscribe/unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers