[vtkusers] Marching Cubes with Polydata

David Doria daviddoria at gmail.com
Sat May 2 08:24:27 EDT 2009


I asked about this a while back, but was never able to get it to work - Here
is an attempt at a simple example:

Input data: polydata, points on a sphere
http://rpi.edu/~doriad/SpherePoints.vtp

required output: the surface of the sphere

    vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
    reader->SetFileName(Filename.c_str());
    reader->Update();

    vtkPolyData* InputPolydata = reader->GetOutput();

    vtkSmartPointer<vtkContourFilter> CF =
vtkSmartPointer<vtkContourFilter>::New();
    CF->SetInput(InputPolydata);
    CF->Update();

    vtkMarchingCubes* MC = vtkMarchingCubes::New();
    MC->SetInput(CF->GetOutput()); //ERROR: cannot do this, because the
input is vtkPolyData, not vtkImageData
    MC->Update();

    vtkPolyData* Output = MC->GetOutput();

    //write
    vtkSmartPointer<vtkXMLPolyDataWriter> writer =
vtkSmartPointer<vtkXMLPolyDataWriter>::New();
    writer->SetFileName(Filename.c_str());
    writer->SetInput(Output);
    writer->Write();

I thought the ContourFilter was supposed to do this polydata to imagedata
conversion? A while back Bryn had recommended creating an empty image data
and manually binning the points, but I feel like there should be a filter
that does this? Also recommended was Deluanay triangulation. I've had bad
luck with this in the past with the type of surfaces I'm trying to
reconstruct, so I would like to compare it to marching cubes.

There have been several questions about this, but I haven't seen any
resolutions. Has anyone gotten it to work?

Thanks,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090502/312ea107/attachment.htm>


More information about the vtkusers mailing list