[vtkusers] Question about contour widget
Dean Inglis
dean.inglis at camris.ca
Wed Oct 13 22:23:27 EDT 2010
Hi John,
you are doing everything right as far as I can tell from your code. The
solution
we implemented was to create a slice viewer based on vtkImageViewer2 that
broadcasted SliceChanged events whenever its ivar vtkImageActor changed
slices / display extents. We created a vtkContour class inherited from
vtkProp that displays itself
in response to those events as well as stores and maintains its history of
edits,
calculates its perimeter and area metrics, if closed displays the area as a
translucent image overlay
etc etc. The contour "knows" which slice extents it belongs to and
switches its visibility accordingly.
One could for example define a contour on a current vtkImageActor slice as
done
in your code and then send the vtkPolyData via the widget's rep method
GetContourRepresentationAsPolyData to initialize an isntance of the
vtkContour class.
We also subclassed a picker that adds vtkContour to the possible type of
props it can pick
so that one can mouse hover and cause it to automagically highlight itself
or pick
and cause it to remain highlighted in a selected state. A selected contour
is unselected
whenever the slice viewer changes slices. Editing of contours is
accomplished by passing its vtkPolyData ivar back to the vtkContourWidget
via
its Initialize method. There is a lot more interaction logic embedded in
this approach
but maybe you have some ideas to go on...
regards,
Dean
I have a vtkImageViewer2 and wish to use vtkContourWidget to draw a contour
on the image. The data I'm loading is a 3D DICOM CT volume. I have found
the following question
http://vtk.1045678.n5.nabble.com/vtkContourWidget-with-vtkImageViewer2-td1236295.html
and
created the following code as a result (in Java)
vtkContourWidget contourWidget = new vtkContourWidget();
contourWidget.SetInteractor(panel.getRenWin().getIren());
contourWidget.FollowCursorOn();
vtkOrientedGlyphContourRepresentation rep = new
vtkOrientedGlyphContourRepresentation();
contourWidget.SetRepresentation(rep);
vtkImageActorPointPlacer placer = new vtkImageActorPointPlacer();
placer.SetImageActor(panel.getImageViewer().GetImageActor());
rep.SetPointPlacer(placer);
contourWidget.EnabledOn();
contourWidget.ProcessEventsOn();
When I do this and draw a contour and then scroll through the image planes
the same contour appears on every plane. Ideally I'd like a different
contour on every plane. If I don't use the vtkImageActorPointPlacer then
the contour only appears on one plane but it's the same plane regardless of
which plane is being viewed, which is also wrong.
Any suggestions about how to do this correctly would be greatly appreciated.
Thanks
More information about the vtkusers
mailing list