[vtkusers] vtkSurfaceReconstructionFilter with vtkPolyData giving wrong output ?

Ashika Umanga Umagiliya aumanga at biggjapan.com
Tue Jan 25 02:27:45 EST 2011


Greetings all,

I use "vtkSurfaceReconstructionFilter" to generate mesh from a point cloud.
I refered the example at
http://www.vtk.org/doc/release/4.0/html/c2_vtk_e_1.html#c2_vtk_e_vtkSurfaceReconstructionFilter
Only different is, instead of "vtkProgrammableSource" , I have used
"vtkPolyData" as the input for the filter.(please refer code snippet
below)

Generated mesh from the vtkSurfaceReconstructionFilter looks like this -
http://oi53.tinypic.com/33dv81k.jpg

This is how the correct output should be similar to (these use the
same point data) -
 1) Draw original contour lines -  http://oi53.tinypic.com/33dv81k.jpg
 2) Generate mesh by vtkVoxelContoursToSurfaceFilter -
http://oi51.tinypic.com/9863c4.jpg

What could be the issue  ?

Thanks in advance.
umanga

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

//Prepare vtkPolyData

vtkPoints *points=vtkPoints::New();
vtkPolyData *polyData=vtkPolyData::New();
polyData->Initialize();
polyData->SetPoints(points);

//Then add points  to the vtkPolyData
for(int i=0;i<numOfContours;i++){
  double x=conters.getContour(i)->getX();
  double y=1.0*i;
  double z=contours->getContour(i)->getY();

 points->InsertNextPoint(x,y,z)
}


//Generate mesh rest if same as the example)

vtkSurfaceReconstructionFilter *surf=vtkSurfaceReconstructionFilter::New();
surf->SetInputConnection(pointSource->GetOutputPort());
surf->SetInput(polyData);  // <------ only different with the example

vtkContourFilter *cf=vtkContourFilter::New();
cf->SetInputConnection(surf->GetOutputPort());
cf->SetValue(0,0.0);

vtkReverseSense *reverse=vtkReverseSense::New();
reverse->SetInputConnection(cf->GetOutputPort());
reverse->ReverseCellsOn();
reverse->ReverseNormalsOn();

vtkPolyDataMapper *map=vtkPolyDataMapper::New();
map->SetInputConnection(reverse->GetOutputPort());
map->ScalarVisibilityOff();

//Create actor
vtkActor *surfaceActor=vtkActor::New();
surfaceActor->SetMapper(map);

renderer->AddActor(surfaceActor);



More information about the vtkusers mailing list