Commit 352e3122 authored by Bill Lorensen's avatar Bill Lorensen

ENH: Add test for vtkOpenFOAMReader

Change-Id: Ib3fe1840f712a626179de7de4261427de1aeeb60
parent 84653eb2
# Tests with data
ExternalData_Expand_Arguments(VTKData _
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/0/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/0.5/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/0.5/uniform/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/1/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/1/uniform/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/1.5/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/1.5/uniform/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/2/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/2/uniform/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/2.5/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/2.5/uniform/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/constant/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/constant/polyMesh/,REGEX:.*}"
"DATA{${VTK_TEST_INPUT_DIR}/OpenFOAM/cavity/system/,REGEX:.*}"
)
vtk_add_test_cxx(
TestOpenFOAMReader.cxx
TestProStarReader.cxx
TestTecplotReader.cxx
TestAMRReadWrite.cxx,NO_VALID
......@@ -29,8 +47,7 @@ if(VTK_USE_LARGE_DATA AND _known_little_endian)
)
vtk_add_test_cxx(NO_VALID
TestMFIXReader.cxx
)
)
endif()
vtk_test_cxx_executable(${vtk-module}CxxTests)
/*=========================================================================
Program: Visualization Toolkit
Module: TestSimplePointsReaderWriter.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 <vtkSmartPointer.h>
#include <vtkProperty.h>
#include <vtkUnstructuredGrid.h>
#include <vtkPointData.h>
#include <vtkCellData.h>
#include <vtkDataSetMapper.h>
#include <vtkOpenFOAMReader.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkTestUtilities.h>
#include <vtkRegressionTestImage.h>
int TestOpenFOAMReader(int argc, char* argv[])
{
// Read file name.
char* filename =
vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/OpenFOAM/cavity/cavity.foam");
// Read the file
vtkSmartPointer<vtkOpenFOAMReader> reader =
vtkSmartPointer<vtkOpenFOAMReader>::New();
reader->SetFileName(filename);
delete [] filename;
reader->Update();
reader->SetTimeValue(.5);
// reader->CreateCellToPointOn();
reader->ReadZonesOn();
reader->Update();
reader->Print(std::cout);
reader->GetOutput()->Print(std::cout);
reader->GetOutput()->GetBlock(0)->Print(std::cout);
// 1) Default array settings
int numberOfCellArrays = reader->GetNumberOfCellArrays();
std::cout << "----- Default array settings" << std::endl;
for (int i = 0; i < numberOfCellArrays; ++i)
{
const char * name = reader->GetCellArrayName(i);
std::cout << " Cell Array: " << i
<< " is named " << name
<< " and is "
<< (reader->GetCellArrayStatus(name) ? "Enabled" : "Disabled")
<< std::endl;
}
int numberOfPointArrays = reader->GetNumberOfPointArrays();
std::cout << "----- Default array settings" << std::endl;
for (int i = 0; i < numberOfPointArrays; ++i)
{
const char * name = reader->GetPointArrayName(i);
std::cout << " Point Array: " << i
<< " is named " << name
<< " and is "
<< (reader->GetPointArrayStatus(name) ? "Enabled" : "Disabled")
<< std::endl;
}
int numberOfLagrangianArrays = reader->GetNumberOfLagrangianArrays();
std::cout << "----- Default array settings" << std::endl;
for (int i = 0; i < numberOfLagrangianArrays; ++i)
{
const char * name = reader->GetLagrangianArrayName(i);
std::cout << " Lagrangian Array: " << i
<< " is named " << name
<< " and is "
<< (reader->GetLagrangianArrayStatus(name) ? "Enabled" : "Disabled")
<< std::endl;
}
int numberOfPatchArrays = reader->GetNumberOfPatchArrays();
std::cout << "----- Default array settings" << std::endl;
for (int i = 0; i < numberOfPatchArrays; ++i)
{
const char * name = reader->GetPatchArrayName(i);
std::cout << " Patch Array: " << i
<< " is named " << name
<< " and is "
<< (reader->GetPatchArrayStatus(name) ? "Enabled" : "Disabled")
<< std::endl;
}
vtkUnstructuredGrid *block0 = vtkUnstructuredGrid::SafeDownCast(reader->GetOutput()->GetBlock(0));
block0->GetCellData()->SetActiveScalars("p");
std::cout << "Scalar range: "
<< block0->GetCellData()->GetScalars()->GetRange()[0] << ", "
<< block0->GetCellData()->GetScalars()->GetRange()[1] << std::endl;
// Visualize
vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputData(block0);
mapper->SetScalarRange(block0->GetScalarRange());
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(.2, .4, .6);
renderWindow->Render();
int retVal = vtkRegressionTestImage( renderWindow );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
renderWindowInteractor->Start();
}
return EXIT_SUCCESS;
}
236abd9a367e5a390f2728fd931a7f1c
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
2c30e5974e4e78b843346176692ac42f
a7d3a6e9e477a5dd2ad77dd2860667a9
7595fc186b1e3085cf2a6dd539513d3d
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
20ba46c478adc2f23bbd8f3485acf255
c2b0351edefd1a9fe7911e45abedb72f
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
c444d6251cfb08b2392be26a33d395f1
1fafe79d35980b7055b56e81a345a51d
64a336b8261a2339513857204e105095
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
5f90b349da746f00f20f2efd2d5ecd6a
5eaaa8d2c73c1888754b31b1a8c4f63c
3c0d1a193cf59d242171d823249418f9
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
d4bce4042e9a9e6591706be61b16ef0a
8d3f3fcdd6a9374508a94937f3b9b95f
bbedde123cb5a6be39021510a899d646
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
d25e958d7091b7bea01729afa0be890f
31b04b63a35d264289aa66f95a3534d9
af835e44b41806054775428d4e365b6a
f5aed65f5a8bda516599b2f1949858dc
d41d8cd98f00b204e9800998ecf8427e
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