[vtkusers] vtkContourWidget

Nicolas Sarrasin nsarrasin at phenix-systems.com
Wed May 12 09:51:19 EDT 2010


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();/


-- 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100512/87a3a23e/attachment.htm>


More information about the vtkusers mailing list