Yes Nicolas:<br><br>The contour widget uses two sets of classes, which (are generally independent of each other).<br><br>A subclass of vtkPointPlacer dictates the constraints imposed on the nodes. <br>A subclass of vtkContourLIneInterpolator dictates the constraints imposed on the path in between the nodes. <br>
<br>In your case, you might want to look at the following combination :<br><br> vtkPolygonalSurfacePointPlacer -> vtkPolygonalSurfaceContourLineInterpolator<br><br>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.<br>
<br><br>Something like :<br><br><br> vtkContourWidget *contourWidget = vtkContourWidget::New();<br> contourWidget->SetInteractor(iren);<br><br> vtkOrientedGlyphContourRepresentation *rep = <br> vtkOrientedGlyphContourRepresentation::SafeDownCast(<br>
contourWidget->GetRepresentation());<br><br> vtkPolygonalSurfacePointPlacer * pointPlacer <br> = vtkPolygonalSurfacePointPlacer::New();<br> pointPlacer->AddProp( sphereActor );<br> rep->SetPointPlacer(pointPlacer);<br>
<br> vtkPolygonalSurfaceContourLineInterpolator * lineInterpolator <br> = vtkPolygonalSurfaceContourLineInterpolator::New();<br> rep->SetLineInterpolator(lineInterpolator);<br> <br> iren->Initialize();<br>
contourWidget->EnabledOn();<br><br><br>Hope this helps.. Here is a minimal example..<br><br>--<br>karthik<br><br><br><div class="gmail_quote">On Wed, May 12, 2010 at 7:21 PM, Nicolas Sarrasin <span dir="ltr"><<a href="mailto:nsarrasin@phenix-systems.com">nsarrasin@phenix-systems.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#003333">
Hi all,<br>
<br>
I'm quite new in developping with vtk and I have some questions
concerning vtkContourWidget.<br>
<br>
I built a quick project which uses vtkContourWidget and
vtkPolyDataPointPlacer to display a contour on a sphere.<br>
<br>
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).<br>
<br>
Is there a way to force the borders of the contour to follow the
surface ?<br>
<br>
A solution would be to project the contour on the sphere but I can find
any documentation about that.<br>
<br>
For more clarity, I post a sample of my code.<br>
<br>
Thanks by advance.<br>
<br>
Nicolas<br>
<br>
code:<br>
<pre> //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();/
</pre>
<br>
<div>-- <br>
<br>
</div>
</div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br><br>