[vtkusers] vtkContourWidget

Karthik Krishnan karthik.krishnan at kitware.com
Fri May 14 04:13:27 EDT 2010


On Fri, May 14, 2010 at 1:15 PM, Nicolas Sarrasin <
nsarrasin at phenix-systems.com> wrote:

>  Ok thanks for your reply.
>

Please keep mails on the list, so others may chime in.


>
> I'm gonna use *vtkPolygonalSurfaceContourLineInterpolator*, it satisfied
> me, for the moment.
>

Great.


>
>  The interpolator internally traces the shortest path between the two
> nodes along vertices of the mesh, so its not as good as a projection that
> cuts through the cells, but if your mesh is dense enough the traced path
> might be good enough.
>
>
> What do you suggest me if my mesh isn't dense enough ? How can i project
> the contour on my sphere ?
>

The path is an approximation of a projection onto the mesh, such that the
projected path lies wholly along the vertices of the mesh.


> Now I encounter a new "problem" in using contour widget. After closing a
> contour, everytime I try to modify it by dragging a node, the node can be
> move outside the surface (it's still inside the silhouette of the sphere but
> it's not lying on any more and approach the screen).
>

This should not happen if you are using a vtkPolygonalSurfacePointPlacer to
constrain the nodes and the vtkPolygonalSurfaceContourLineInterpolator to
constrain the path.

Please post a minimal, (compiling) example. Also take a look a look at
TestDijkstraImageGeodesicPath. The contour and the interpolated path are
confined to the surface of the mesh, while you manipulate interactively.

--
karthik


>
> How can I manage this problem and constrain the position of the node of the
> contour during all its lifetime in the visualisation?
>
> Thanks by advance,
>
> Nicolas
>
> Le 12/05/2010 18:43, Karthik Krishnan a écrit :
>
> Yes Nicolas:
>
> The contour widget uses two sets of classes, which (are generally
> independent of each other).
>
> A subclass of vtkPointPlacer dictates the constraints imposed on the nodes.
>
> A subclass of vtkContourLIneInterpolator dictates the constraints imposed
> on the path in between the nodes.
>
> In your case, you might want to look at the following combination :
>
>   vtkPolygonalSurfacePointPlacer ->
> vtkPolygonalSurfaceContourLineInterpolator
>
> The interpolator internally traces the shortest path between the two nodes
> along vertices of the mesh, so its not as good as a projection that cuts
> through the cells, but if your mesh is dense enough the traced path might be
> good enough.
>
>
> Something like :
>
>
>    vtkContourWidget *contourWidget = vtkContourWidget::New();
>   contourWidget->SetInteractor(iren);
>
>   vtkOrientedGlyphContourRepresentation *rep =
>       vtkOrientedGlyphContourRepresentation::SafeDownCast(
>                         contourWidget->GetRepresentation());
>
>   vtkPolygonalSurfacePointPlacer * pointPlacer
>         = vtkPolygonalSurfacePointPlacer::New();
>   pointPlacer->AddProp( sphereActor );
>   rep->SetPointPlacer(pointPlacer);
>
>   vtkPolygonalSurfaceContourLineInterpolator * lineInterpolator
>         = vtkPolygonalSurfaceContourLineInterpolator::New();
>   rep->SetLineInterpolator(lineInterpolator);
>
>   iren->Initialize();
>   contourWidget->EnabledOn();
>
>
> Hope this helps.. Here is a minimal example..
>
> --
> karthik
>
>
> On Wed, May 12, 2010 at 7:21 PM, Nicolas Sarrasin <
> nsarrasin at phenix-systems.com> wrote:
>
>> Hi all,
>>
>> I'm quite new in developping with vtk and I have some questions concerning
>> vtkContourWidget.
>>
>> I built a quick project which uses vtkContourWidget and
>> vtkPolyDataPointPlacer to display a contour on a sphere.
>>
>> When I click on this sphere, there's no problem : the points of the
>> contour are well positionned on the sphere. But it's not the case for the
>> spans which are outside or inside the sphere (but not on).
>>
>> Is there a way to force the borders of the contour to follow the surface ?
>>
>> A solution would be to project the contour on the sphere but I can find
>> any documentation about that.
>>
>> For more clarity, I post a sample of my code.
>>
>> Thanks by advance.
>>
>> Nicolas
>>
>> code:
>>
>>     //sphere definition
>>
>>      vtkSphereSource* theSphere = vtkSphereSource::New();
>>
>>      vtkPolyDataMapper * sphereMapper = vtkPolyDataMapper::New();
>>      sphereMapper->SetInput(theSphere->GetOutput());
>>
>>      vtkLODActor* sphereActor = vtkLODActor::New();
>>      sphereActor->SetMapper( sphereMapper);
>>
>>      vtkRenderer *renderer1 = vtkRenderer::New();
>>      renderer1->AddActor(sphereActor);
>>
>>      vtkRenderWindow *renWin = vtkRenderWindow::New();
>>      renWin->AddRenderer(renderer1);
>>
>>      vtkRenderWindowInteractor *rendIter = vtkRenderWindowInteractor::New();
>>      rendIter->SetRenderWindow(renWin);
>>
>>      // Here comes the image actor constrained handle widget stuff.....
>>      vtkContourWidget *widget = vtkContourWidget::New();
>>      widget->SetInteractor(rendIter);
>>
>>      vtkSmartPointer<vtkLinearContourLineInterpolator> contourStyle =
>> vtkSmartPointer<vtkLinearContourLineInterpolator>::New();
>>
>>      vtkOrientedGlyphContourRepresentation *rep
>> =vtkOrientedGlyphContourRepresentation::SafeDownCast(
>> widget->GetRepresentation() );
>>      rep->SetLineInterpolator(contourStyle);
>>
>>     // we define a Placer to force the contour to be on the sphere
>>      vtkPolyDataPointPlacer * spherePlacer = vtkPolyDataPointPlacer::New();
>>      spherePlacer->AddProp(sphereActor);
>>      rep->SetPointPlacer(spherePlacer);
>>
>>      renWin->Render();
>>      rendIter->Initialize();
>>      widget->EnabledOn();
>>      rendIter->Start();/
>>
>>
>>
>> --
>>
>>
>> _______________________________________________
>> 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/20100514/9c6a4c11/attachment.htm>


More information about the vtkusers mailing list