[vtkusers] surface reconstruction problem
Tim Hutton
tim.hutton at gmail.com
Sun Jan 10 08:28:05 EST 2010
Hi Yi,
The filter works by converting the points to a volume image, so it
does lose the scale and position of the points I'm afraid.
One solution would be to make your own version of
vtkSurfaceReconstructionFilter that added the transform back onto the
data at the end. With suitable options to turn this feature on and off
this would be a useful addition to VTK.
A better solution for you might be to use a different surface
reconstruction filter. Search for vtkPowerCrustSurfaceReconstruction.
Tim
2010/1/9 Gao, Yi <gaoyi.cn at gmail.com>:
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
Tim Hutton - http://www.sq3.org.uk - http://ferkeltongs.livejournal.com
More information about the vtkusers
mailing list