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

kent williams nkwmailinglists at gmail.com
Tue Oct 19 15:21:14 EDT 2010


I'm doing essentially the same thing Jonathan does. I also use
vtkImageActorPointPlacer.

My target application is to make 3d masks in an image volume, that are
manually traced using vtkContourWidgets.  So each of my mask tracings
(which I call a vtkMultiContourWidget) has this organization:

vtkMultiContourWidget
  std::map<int,PolyDataLIst> # map, keyed by slice #
     PolyDataList
         std::list<MyPolygon *> # one or more polygonal outlines
  std::vector<MyContour *>    # list of structures managing
vtkContourWidget instances

I store the polygon points separate from the vtkContourWidgets.  When
the slice changes, I turn off all my active vtkContourWidgets, and
then re-use them with the new slice's list of polygons.

So instead of having a vtkContourWidget per contour in a model, I only
have as many contours as I need to display and manipulate the current
slice's polygon/contours.  In a complicated mask -- especially one
that's converted from an existing binary image, there can be hundreds
of contours, but rarely more than a few on any give slice.


On Tue, Oct 19, 2010 at 1:03 PM, Jonathan Morra <jonmorra at gmail.com> wrote:
> 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
>>
>>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list