[vtkusers] Draw a plane from planesource

Marc Huber marchuber.hft at gmx.de
Sat Apr 27 05:39:33 EDT 2013


Hi,

I want to write a very simple RANSAC algorithm and display a plane in 
the end.
Like this: http://www.vtkjournal.org/browse/publication/709

I get no error messages with my code but its not displaying a plane.
It would be nice if anybody could help me.


My simplified code is:

vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();

//Get plane normal
     double planeN[3],center[3], p1[3], p2[3], p3[3];
     points->GetPoint(0,p1);
     points->GetPoint(1,p2);
     points->GetPoint(2,p3);

     vtkSmartPointer<vtkTriangle> tri = vtkSmartPointer<vtkTriangle>::New();
         tri->ComputeNormal(p1, p2,p3,planeN);
         tri->TriangleCenter(p1,p2,p3,center); //Get center of triangle
     vtkSmartPointer<vtkPlaneSource> planesrc = 
vtkSmartPointer<vtkPlaneSource>::New();
         planesrc->SetCenter(center);
         planesrc->SetNormal(planeN);
         planesrc->Update();

     vtkSmartPointer<vtkPolyDataMapper> planeMapper = 
vtkSmartPointer<vtkPolyDataMapper>::New();
planeMapper->SetInputConnection(planesrc->GetOutputPort());

     //Actor
         planeActor->SetMapper(planeMapper);
         planeActor->GetProperty()->SetColor(1,0,0);
         planeActor->GetProperty()->SetOpacity(0.4);
     //Rendering
     vtkSmartPointer<vtkRenderer> renderer = 
vtkSmartPointer<vtkRenderer>::New();
         renderer->AddActor(planeActor);
ui.qvtkWidget->GetRenderWindow()->AddRenderer(renderer);
         ui.qvtkWidget->repaint();

-- 
Best regards
Marc




More information about the vtkusers mailing list