Commit 7782d0bd authored by Bill Lorensen's avatar Bill Lorensen Committed by Code Review

Merge topic 'Coverage_POpenFOAMReader' into master

2dc2e641 ENH: Add test for POpenFOAMReader
parents 55232e6a 2dc2e641
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(
TestPOpenFOAMReader.cxx
)
vtk_test_cxx_executable(${vtk-module}CxxTests)
if(VTK_USE_LARGE_DATA)
# Tell ExternalData to fetch test input at build time.
ExternalData_Expand_Arguments(VTKData _
......
/*=========================================================================
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 <vtkPOpenFOAMReader.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkTestUtilities.h>
#include <vtkRegressionTestImage.h>
int TestPOpenFOAMReader(int argc, char* argv[])
{
// Read file name.
char* filename =
vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/OpenFOAM/cavity/cavity.foam");
// Read the file
vtkSmartPointer<vtkPOpenFOAMReader> reader =
vtkSmartPointer<vtkPOpenFOAMReader>::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;
}
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