[vtkusers] Question about contour widget

Jonathan Morra jonmorra at gmail.com
Wed Oct 13 11:39:36 EDT 2010


I have followed your suggestion and tried the following code
// The contour rep requires a suitable point placer
        double[] bounds =
panel.getImageViewer().GetImageActor().GetBounds();
        vtkBoundedPlanePointPlacer placer = new
vtkBoundedPlanePointPlacer();
        placer.SetProjectionNormalToZAxis();
        placer.SetProjectionPosition(bounds[4]);

        placer.RemoveAllBoundingPlanes();
        vtkPlane plane1 = new vtkPlane();
        plane1.SetOrigin(bounds[0], bounds[2], bounds[4]);
        plane1.SetNormal(0.0, 0.0, 1.0);
        placer.AddBoundingPlane(plane1);

        vtkPlane plane2 = new vtkPlane();
        plane2.SetOrigin(bounds[1], bounds[3], bounds[5]);
        plane2.SetNormal(0.0, 0.0, -1.0);
        placer.AddBoundingPlane(plane2);

        rep.SetPointPlacer(placer);
        contourWidget.SetRepresentation(rep);

When I do this I cannot see any contours.  I have tried it with both with
and without the line
        placer.SetProjectionPosition(bounds[4]);
and I didn't notice any change.  Is there something else that I am missing?
 I also tried setting the vtkOrientedGlyphContourRepresentation to
AlwaysOnTopOn(), but that didn't make a difference.  But if I comment out
from
        placer.RemoveAllBoundingPlanes();
to the end of the snippet, I'm back where I was before which is having the
contour show up on two planes.

Thanks for all your help, and I'm eagerly awaiting your response as this is
the last bug in version 1.0 of my software.

On Wed, Oct 13, 2010 at 12:44 AM, Karthik Krishnan <
karthik.krishnan at kitware.com> wrote:

> You need to add the bounding planes to confine it to a single plane.
> Something like :
>
>   placer.RemoveAllBoundingPlanes();
>   placer.SetProjectionNormalToZAxis();
>
>   imageActor.GetBounds(bounds);
>   plane = new vtkPLane()
>   plane->SetOrigin( bounds[0], bounds[2], bounds[4] );
>   plane->SetNormal( 0.0, 0.0, 1.0 );
>   this->Placer->AddBoundingPlane( plane );
>
>   plane2 = vtkPlane::New();
>   plane2->SetOrigin( bounds[1], bounds[3], bounds[5] );
>   plane2->SetNormal( 0.0, 0.0, -1.0 );
>   placer.AddBoundingPlane( plane2 );
>
> On Tue, Oct 12, 2010 at 9:04 PM, Jonathan Morra <jonmorra at gmail.com>wrote:
>
>> Thanks for your help, I replaced the placer as you suggested, and now my
>> code looks like the following
>>
>> vtkBoundedPlanePointPlacer placer = new vtkBoundedPlanePointPlacer();
>>         placer.SetProjectionNormalToZAxis();
>>
>>  placer.SetProjectionPosition(panel.getImageViewer().GetImageActor().GetCenter()[2]);
>>         rep.SetPointPlacer(placer);
>>
>> This is almost right.  The contour now appears on the plane that I drew it
>> on and the plane above it and that is it.  I just want the contour on the
>> plane I drew it on.  I tried playing around with placer.SetPixelTolerance()
>> but that didn't make a difference.
>>
>> On Tue, Oct 12, 2010 at 2:33 AM, Karthik Krishnan <
>> karthik.krishnan at kitware.com> wrote:
>>
>>> On Tue, Oct 12, 2010 at 10:33 AM, Jonathan Morra <jonmorra at gmail.com>wrote:
>>>
>>>> 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);
>>>>
>>>
>>> What this point placer does is to constrain the contour to the plane
>>> defined by the ImageActor. However, given that the same image actor is used
>>> for multiple slices, when you change the slice, the position of the image
>>> actor effectively changes and the contour updates itself to lie on the new
>>> plane.
>>>
>>> What you need is to use a vtkBoundedPlanePointPlacer with the bounding
>>> planes de-lienating the bounds of the image actor when the contour is
>>> defined. That way it won't change when you change the slice.
>>>
>>> Also to manage visibility of the contour (the contour will be visible for
>>> all slices in front of the defined slice), you could subclass the contour
>>> representation, insert a clipper that clips the polydata based on the
>>> bounding planes, that way, visibility is implicitly managed by the
>>> representation.
>>>
>>> --
>>> karthik
>>>
>>>         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
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101013/956f0c37/attachment.htm>


More information about the vtkusers mailing list