[vtkusers] Can't save after fillHoles filter
andyjk
andrewkeeling at hotmail.com
Sat Aug 3 05:33:18 EDT 2013
I am applying vtkFillHolesFilter to an .stl file. (from the C++ example)
This works fine when I view the result.
However, when I save the output of fillHoles using vtkSTLWriter, and reload,
the holes are back again! The same thing happens if I try to save it as a
.ply file, so it looks like the output of fillHoles is getting sent to any
of the vtkWriters.
#include <vtkPolyData.h>
#include <vtkSTLReader.h>
#include <vtkSTLWriter.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleSwitch.h>
#include <vtkFillHolesFilter.h>
int main ( int argc, char *argv[] )
{
if ( argc != 2 )
{
cout << "Required parameters: Filename" << endl;
return EXIT_FAILURE;
}
std::string inputFilename = argv[1];
vtkSmartPointer<vtkSTLReader> reader =
vtkSmartPointer<vtkSTLReader>::New();
reader->SetFileName(inputFilename.c_str());
reader->Update();
vtkSmartPointer<vtkPolyData> input = vtkSmartPointer<vtkPolyData> ::New();
input->ShallowCopy(reader->GetOutput());
vtkSmartPointer<vtkFillHolesFilter> fillHolesFilter =
vtkSmartPointer<vtkFillHolesFilter>::New();
#if VTK_MAJOR_VERSION <= 5
fillHolesFilter->SetInputConnection(input->GetProducerPort());
#else
fillHolesFilter->SetInputData(input);
#endif
fillHolesFilter->Update();
// Save STL
vtkSmartPointer<vtkSTLWriter> stlWriter =
vtkSmartPointer<vtkSTLWriter>::New();
stlWriter->SetFileName("D:\\akfiles\\HoleFilled2.stl");
stlWriter->SetInputConnection(fillHolesFilter->GetOutputPort());
stlWriter->Write();
// Visualize
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(fillHolesFilter->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkInteractorStyleSwitch> style =
vtkSmartPointer<vtkInteractorStyleSwitch>::New();
style->SetCurrentStyleToTrackballCamera();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindowInteractor->SetInteractorStyle(style);
renderer->AddActor(actor);
renderer->SetBackground(.3, .6, .3); // Background color green
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
The visualization is fine - the holes are filled. But when I load
HoleFilled2.stl in Meshlab, the holes are back!
Can anyone see what I'm doing wrong ?
Thanks
--
View this message in context: http://vtk.1045678.n5.nabble.com/Can-t-save-after-fillHoles-filter-tp5722435.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list