Thanks a lot for all the advice, I went with Dean and John's solution, and it works perfectly. Internally I keep the following data structure (in java)<div>HashSet<vtkContourWidget>[]</div><div>where the array is the same length as the number of planes, and I can store multiple contours per plane. There's only one thing left for me to make this complete. After I draw the contour, I use the vtkAppendPolyData to create one vtkPolyData. I want to display that vtkPolyData on top of the vtkImageViewer2 in the same fashion as I do with the contours. In order to accomplish this, I tried to use the following code, but it's not working yet</div>
<div><br></div><div><div> vtkPolyDataMapper mapper = new vtkPolyDataMapper();</div><div> mapper.SetInput(polyData);</div><div><br></div><div> vtkActor actor = new vtkActor();</div><div> actor.SetMapper(mapper);</div>
<div><br></div><div> imageViewer.GetRenderer().AddActor(actor);</div><div><br></div><div><div> double[] bounds = imageViewer.GetImageActor().GetBounds();</div><div><br></div><div> vtkPlane topPlane = new vtkPlane();</div>
<div> topPlane.SetOrigin(bounds[0], bounds[2], bounds[4]);</div><div> normals[getPerpendicularSlice()] = 1;</div><div> topPlane.SetNormal(0, 0, 1);</div><div><br></div><div> vtkPlane bottomPlane = new vtkPlane();</div>
<div> bottomPlane.SetOrigin(bounds[1], bounds[3], bounds[5]);</div><div> bottomPlane.SetNormal(0, 0, -1);</div><div><br></div><div> actor.GetMapper().RemoveAllClippingPlanes();</div><div> actor.GetMapper().AddClippingPlane(topPlane);</div>
<div> actor.GetMapper().AddClippingPlane(bottomPlane);</div></div><div><br></div><div>Am I on the right track with this?</div><div><br></div><div>Thanks</div><div><br><div class="gmail_quote">On Wed, Oct 13, 2010 at 7:23 PM, Dean Inglis <span dir="ltr"><<a href="mailto:dean.inglis@camris.ca">dean.inglis@camris.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi John,<br>
<br>
you are doing everything right as far as I can tell from your code. The solution<br>
we implemented was to create a slice viewer based on vtkImageViewer2 that<br>
broadcasted SliceChanged events whenever its ivar vtkImageActor changed<br>
slices / display extents. We created a vtkContour class inherited from vtkProp that displays itself<br>
in response to those events as well as stores and maintains its history of edits,<br>
calculates its perimeter and area metrics, if closed displays the area as a translucent image overlay<br>
etc etc. The contour "knows" which slice extents it belongs to and switches its visibility accordingly.<br>
One could for example define a contour on a current vtkImageActor slice as done<br>
in your code and then send the vtkPolyData via the widget's rep method<br>
GetContourRepresentationAsPolyData to initialize an isntance of the vtkContour class.<br>
We also subclassed a picker that adds vtkContour to the possible type of props it can pick<br>
so that one can mouse hover and cause it to automagically highlight itself or pick<br>
and cause it to remain highlighted in a selected state. A selected contour is unselected<br>
whenever the slice viewer changes slices. Editing of contours is<br>
accomplished by passing its vtkPolyData ivar back to the vtkContourWidget via<br>
its Initialize method. There is a lot more interaction logic embedded in this approach<br>
but maybe you have some ideas to go on...<br>
<br>
regards,<br><font color="#888888">
Dean</font><div class="im"><br>
<br>
<br>
I have a vtkImageViewer2 and wish to use vtkContourWidget to draw a contour<br>
on the image. The data I'm loading is a 3D DICOM CT volume. I have found<br>
the following question<br>
<a href="http://vtk.1045678.n5.nabble.com/vtkContourWidget-with-vtkImageViewer2-td1236295.html" target="_blank">http://vtk.1045678.n5.nabble.com/vtkContourWidget-with-vtkImageViewer2-td1236295.html</a><br>
and<br>
created the following code as a result (in Java)<br>
<br>
vtkContourWidget contourWidget = new vtkContourWidget();<br>
contourWidget.SetInteractor(panel.getRenWin().getIren());<br>
contourWidget.FollowCursorOn();<br>
<br>
vtkOrientedGlyphContourRepresentation rep = new<br>
vtkOrientedGlyphContourRepresentation();<br>
contourWidget.SetRepresentation(rep);<br>
<br>
vtkImageActorPointPlacer placer = new vtkImageActorPointPlacer();<br>
placer.SetImageActor(panel.getImageViewer().GetImageActor());<br>
rep.SetPointPlacer(placer);<br>
<br></div><div><div></div><div class="h5">
contourWidget.EnabledOn();<br>
contourWidget.ProcessEventsOn();<br>
<br>
When I do this and draw a contour and then scroll through the image planes<br>
the same contour appears on every plane. Ideally I'd like a different<br>
contour on every plane. If I don't use the vtkImageActorPointPlacer then<br>
the contour only appears on one plane but it's the same plane regardless of<br>
which plane is being viewed, which is also wrong.<br>
<br>
Any suggestions about how to do this correctly would be greatly appreciated.<br>
<br>
Thanks <br>
</div></div></blockquote></div><br></div></div>