[vtkusers] Question about drawing contours on different slices and display them

Jonathan Morra jonmorra at gmail.com
Tue Oct 19 14:03:08 EDT 2010


I don't have a vtkPlane.  I have just one vtkImageViewer2 and a list of
vtkContourWidgets.  I defined by own mechanism in Java identify when a slice
needs to be changed (catching keyboard/mouse events and using a JSlider).
 When one of these events occurs I use the SetSlice(int i) method of
vtkImageViewer2 to set the slice.  Then I call vtkContourWidget.Off() for
all of my contours, finally I call vtkContourWidget.On() for just the ones
on the slice I'm interested in.  You appear to be using a
vtkBoundedPlanePointPlacer.  While I experimented a lot with this point
placer, I ultimately couldn't get it to do what I wanted.  That's why I went
to the vtkImageActorPointPlacer.  The thing that I noticed when using this
point placer was that every contour appears on every slice.  This lead me to
the solution I have now which is manually disabling/enabling contours as a
function of image slice being viewed.

On Tue, Oct 19, 2010 at 10:41 AM, shengwen guo <shengwen.guo at gmail.com>wrote:

> Thank for your help.
> Could you tell me what's the relationship between vtkContourWidget and
> vtkPlane? I have define two arrays, vtkContourWidget array and vtkPlane
> array for all slices. When I change the slice, a  ContourWidget is set
> inactive and another ContourWidget is set active, how can it find the
> corresponding plane?
>      I define and initialize two arrays as following:
>     for(int i = 0 ; i < SliceCount ; i++)
> {
> ContourWidgetArray[i] = vtkContourWidget::New();
>  PlaneArray[i] = vtkPlane::New();
> }
>        for(int i = 0 ; i < SliceCount ; i++)
>     {
>           placer->AddBoundingPlane(PlaneArray[i]);
>    }
>
>    But I don;t know how to find the corresponding plane and contourwidget.
>
>    Shengwen
>
> On Tue, Oct 19, 2010 at 2:43 AM, Jonathan Morra <jonmorra at gmail.com>wrote:
>
>> 1.  This will get the poly data from the contour
>> vtkPolyData polyData =
>>
>>  ((vtkOrientedGlyphContourRepresentation)contour.GetRepresentation()).
>>                         GetContourRepresentationAsPolyData();
>> 2.  Here's the code I use to turn on/off contour widgets
>> public void turnOffEditingForAllExcept(int slice) {
>>         for (int i=0; i<contours.length; i++) {
>>             for (vtkContourWidget widget : contours[i]) {
>>                 if (slice == i)
>>                     widget.On();
>>                 else
>>                     widget.Off();
>>             }
>>         }
>>     }
>>  After this I just render the scene again and it works.
>>
>> On Mon, Oct 18, 2010 at 11:06 AM, shengwen guo <shengwen.guo at gmail.com>wrote:
>>
>>> Thank for your sample code. I'll try this smart way later. I'm working on
>>> it using a vtkContourWidget array and I have two questions:
>>> (1) How can I get the points or polydata from the current contourwidget?
>>> (2) After slice is changed, I will use a new contourwidget or set the
>>> corresponding contourwidget active. How can I refresh the window to display
>>> new contour using the initial contour, such as two "zero" points in your
>>> code?
>>> I'm sorry that I bother you again.
>>>
>>>               Shengwen
>>>
>>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101019/89462813/attachment.htm>


More information about the vtkusers mailing list