[vtkusers] surface reconstruction problem

Gao, Yi gaoyi.cn at gmail.com
Fri Jan 8 23:33:32 EST 2010


Dear all,

I used the vtkSurfaceReconstructionFilter class to reconstruct surface
from point set (sitting on a surface), following the example at
http://www.vtk.org/Wiki/Create_a_surface_from_Unorganized_Points

The result looks like the right shape, but it's shifted and scaled.
Seems there's some bug in the filter...

The code is as follows, the input point set is at:
http://zoe.bme.gatech.edu/~gth818n/pt.vtk

Any hint is appreciated!

Thanks!

Best,
yi



#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
#include <vtkPolyDataWriter.h>

#include <vtkSurfaceReconstructionFilter.h>
#include <vtkContourFilter.h>
#include <vtkReverseSense.h>

#include <vtkSmartPointer.h>


vtkPoints* CreatePoints();

int main(int argc, char **argv)
{
  if (3 != argc)
    {
      std::cerr<<"Param: "<<argv[0]<<" pt.vtk surf.vtk\n";
      exit(-1);
    }

  const char* inname = argv[1];
  const char* outname = argv[2];


  vtkSmartPointer<vtkPolyDataReader> reader =
vtkSmartPointer<vtkPolyDataReader>::New();
  reader->SetFileName(inname);
  reader->Update();

  vtkSmartPointer<vtkPolyData> polydata = reader->GetOutput();


// Construct the surface and create isosurface.	
  vtkSmartPointer<vtkSurfaceReconstructionFilter> surf =
vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();
  surf->SetInput(polydata);

  vtkSmartPointer<vtkContourFilter> contourFilter =
vtkSmartPointer<vtkContourFilter>::New();
  contourFilter->SetInputConnection(surf->GetOutputPort());
  contourFilter->SetValue(0, 0.0);

//   // Sometimes the contouring algorithm can create a volume whose gradient
//   // vector and ordering of polygon (using the right hand rule) are
//   // inconsistent. vtkReverseSense cures this problem.
//   vtkSmartPointer<vtkReverseSense> reverse =
vtkSmartPointer<vtkReverseSense>::New();
//   reverse->SetInputConnection(contourFilter->GetOutputPort());
//   reverse->ReverseCellsOn();
//   reverse->ReverseNormalsOn();

  vtkSmartPointer<vtkPolyDataWriter> writer =
vtkSmartPointer<vtkPolyDataWriter>::New();
  //writer->SetInput(reverse->GetOutput());
  writer->SetInputConnection(contourFilter->GetOutputPort());
  writer->SetFileName(outname);
  writer->Update();



  return 0;
}


-- 
Yi Gao
Graduate Student
Dept. Biomedical Engineering
Georgia Institute of Technology



More information about the vtkusers mailing list