Commit c2bd54f7 authored by Vladimír Chalupecký's avatar Vladimír Chalupecký

vtkAVSucdReader: add C++ tests and test ASCII data with noncontiguous IDs

parent 182807c3
Pipeline #690 passed with stage
......@@ -44,6 +44,16 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestPTSReader,TestPTSReader.cxx DATA{${VTK_TEST_INPUT_DIR}/samplePTS.pts}
)
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestAVSucdReaderContiguousASCII,TestAVSucdReader.cxx DATA{${VTK_TEST_INPUT_DIR}/cellsnd.ascii.inp}
)
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestAVSucdReaderNonContiguousASCII,TestAVSucdReader.cxx DATA{${VTK_TEST_INPUT_DIR}/cellsnd.noncontiguous.ascii.inp}
)
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestAVSucdReaderBinary,TestAVSucdReader.cxx DATA{${VTK_TEST_INPUT_DIR}/cellsnd.bin.inp}
)
set(_known_little_endian FALSE)
if (DEFINED CMAKE_WORDS_BIGENDIAN)
if (NOT CMAKE_WORDS_BIGENDIAN)
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestAVSucdReader.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkAVSucdReader.h>
#include <vtkDataSetMapper.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkUnstructuredGrid.h>
#include <vtkTestUtilities.h>
#include <vtkRegressionTestImage.h>
int TestAVSucdReader(int argc, char* argv[])
{
if (argc < 2)
{
std::cerr << "Required parameters: <filename>" << std::endl;
return EXIT_FAILURE;
}
std::string filename = argv[1];
vtkNew<vtkAVSucdReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
reader->Print(std::cout);
reader->GetOutput()->Print(std::cout);
vtkUnstructuredGrid* grid = vtkUnstructuredGrid::SafeDownCast(reader->GetOutput());
grid->GetPointData()->SetActiveScalars("temperature");
vtkNew<vtkDataSetMapper> mapper;
mapper->SetInputData(reader->GetOutput());
mapper->ScalarVisibilityOn();
mapper->SetScalarRange(grid->GetPointData()->GetScalars()->GetRange());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper.GetPointer());
actor->GetProperty()->EdgeVisibilityOn();
vtkNew<vtkRenderer> ren;
ren->AddActor(actor.GetPointer());
ren->SetBackground(0, 0, 0);
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(ren.GetPointer());
renWin->SetSize(300, 300);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin.GetPointer());
renWin->Render();
int r = vtkRegressionTestImage(renWin.GetPointer());
if (r == vtkRegressionTester::FAILED)
{
return EXIT_FAILURE;
}
if (r == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return EXIT_SUCCESS;
}
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