[vtkusers] vtkContourWidget
Karthik Krishnan
karthik.krishnan at kitware.com
Wed May 12 12:43:43 EDT 2010
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/20100512/449a6f99/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SurfaceConstrainedContourWidget2.cxx
Type: text/x-c++src
Size: 3131 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100512/449a6f99/attachment.cxx>
More information about the vtkusers
mailing list