[vtkusers] Can't save after fillHoles filter
Bill Lorensen
bill.lorensen at gmail.com
Sat Aug 3 07:31:59 EDT 2013
If you read HoleFilled2.stl back into VTK are the holes still missing (in
the left view)?
On Sat, Aug 3, 2013 at 5:33 AM, andyjk <andrewkeeling at hotmail.com> wrote:
> 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.
> _______________________________________________
> 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
>
--
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130803/cf6a8441/attachment.htm>
More information about the vtkusers
mailing list