[vtkusers] Poor results with vtkSurfaceReconstructionFilter
Carl Hetherington
lists at carlh.net
Wed Sep 4 06:40:35 EDT 2002
Hi,
I'm trying to reconstruct a surface from a set of unorganized points, and
to test it out I've written the following code. It builds a sphere out of
points and then tries to reconstruct its surface.
const float radius = 1.0;
const int angle_steps = 500;
vtkUnstructuredGrid* vtk_grid = vtkUnstructuredGrid::New();
vtkPoints* vtk_points = vtkPoints::New();
int pc = 0;
float step = 2 * pi / angle_steps;
for (float theta = 0; theta < 4 * pi; theta += step)
for (float phi = 0; phi < 2 * pi; phi += step)
{
float xyz[3];
xyz[0] = radius * cos(theta) * sin(phi);
xyz[1] = radius * sin(theta) * sin(phi);
xyz[2] = radius * cos(phi);
vtk_points->InsertNextPoint(xyz);
vtk_grid->InsertNextCell(VTK_VERTEX, 1, &pc);
pc++;
}
vtk_grid->SetPoints(vtk_points);
vtkSurfaceReconstructionFilter* recon = vtkSurfaceReconstructionFilter::New();
recon->SetInput(vtk_grid);
recon->Update();
vtkContourFilter* contour = vtkContourFilter::New();
contour->SetInput(recon->GetOutput());
contour->SetNumberOfContours(1);
contour->SetValue(0, 0.0);
contour->UseScalarTreeOn();
contour->Update();
The resulting surface is ok in most areas but has some fairly wild errors.
An example of the dodgy output is available at
http://www-users.york.ac.uk/~cth103/surf.vtk
Can anyone suggest why this might be happening?
Thanks in advance for any help
Carl
More information about the vtkusers
mailing list