Commit ce35f13f authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot

Merge topic 'fix-stl-reader-for-multiple-patches'

b128eb33 Added test for STL reader
40937e93 Fix vtkSTLReader bug with ASCII STL files containing multiple patches.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Joachim Pouderoux's avatarJoachim Pouderoux <joachim.pouderoux@kitware.com>
Merge-request: !592
parents d2e9ab97 b128eb33
......@@ -31,6 +31,14 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestSimplePointsReaderWriter.cxx,NO_VALID
)
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestSTLReaderSinglePatch,TestSTLReader.cxx DATA{${VTK_TEST_INPUT_DIR}/42400-IDGH.stl}
)
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestSTLReaderMultiplePatches,TestSTLReader.cxx DATA{${VTK_TEST_INPUT_DIR}/multiple_patches.stl}
)
set(_known_little_endian FALSE)
if (DEFINED CMAKE_WORDS_BIGENDIAN)
if (NOT CMAKE_WORDS_BIGENDIAN)
......
#include <vtkActor.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRegressionTestImage.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSTLReader.h>
#include <vtkSmartPointer.h>
int TestSTLReader(int argc, char *argv[])
{
if (argc < 2)
{
std::cerr << "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();
// Visualize
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(reader->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();
renderWindowInteractor->SetRenderWindow(renderWindow);
renderer->AddActor(actor);
renderer->SetBackground(.3, .6, .3); // Background color green
renderWindow->Render();
int retVal = vtkRegressionTestImage( renderWindow );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
renderWindowInteractor->Start();
}
return !retVal;
}
......@@ -448,7 +448,7 @@ bool vtkSTLReader::ReadASCIISTL(FILE *fp, vtkPoints *newPts,
done = done || (fscanf(fp,"%s", line)==EOF);
}
}
if (!done)
else if (!done)
{
done = (fgets(line, 255, fp) == 0);
lineCount++;
......
3a09b79f491e1e9facc1e81a14e7889a
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment