2020-05-11 21:08:44 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt 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 <string>
|
|
|
|
#include <vtkm/cont/testing/Testing.h>
|
|
|
|
#include <vtkm/io/BOVDataSetReader.h>
|
2020-05-19 20:31:14 +00:00
|
|
|
#include <vtkm/io/ErrorIO.h>
|
2020-05-11 21:08:44 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
inline vtkm::cont::DataSet readBOVDataSet(const char* fname)
|
|
|
|
{
|
|
|
|
vtkm::cont::DataSet ds;
|
|
|
|
vtkm::io::BOVDataSetReader reader(fname);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ds = reader.ReadDataSet();
|
|
|
|
}
|
|
|
|
catch (vtkm::io::ErrorIO& e)
|
|
|
|
{
|
|
|
|
std::string message("Error reading ");
|
|
|
|
message += fname;
|
|
|
|
message += ", ";
|
|
|
|
message += e.GetMessage();
|
|
|
|
|
|
|
|
VTKM_TEST_FAIL(message.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return ds;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
void TestReadingBOVDataSet()
|
|
|
|
{
|
2023-03-02 17:47:37 +00:00
|
|
|
std::string bovFile =
|
|
|
|
vtkm::cont::testing::Testing::DataPath("third_party/visit/example_temp.bov");
|
2020-05-11 21:08:44 +00:00
|
|
|
|
|
|
|
auto const& ds = readBOVDataSet(bovFile.data());
|
|
|
|
|
2022-10-31 17:22:37 +00:00
|
|
|
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
2020-05-11 21:08:44 +00:00
|
|
|
// See the .bov file: DATA SIZE: 50 50 50
|
|
|
|
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points");
|
|
|
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50,
|
|
|
|
"Incorrect number of points (from cell set)");
|
|
|
|
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == 49 * 49 * 49, "Incorrect number of cells");
|
|
|
|
// See the .bov file: VARIABLE: "var"
|
|
|
|
VTKM_TEST_ASSERT(ds.HasField("var"), "Should have field 'var', but does not.");
|
2022-10-31 17:22:37 +00:00
|
|
|
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "There is only one field in noise.bov");
|
2020-05-11 21:08:44 +00:00
|
|
|
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
|
|
|
|
"There is only one coordinate system in noise.bov");
|
|
|
|
|
|
|
|
auto const& field = ds.GetField("var");
|
|
|
|
// I'm pretty sure that all .bov files have their fields associated with points . . .
|
2022-03-17 17:02:37 +00:00
|
|
|
VTKM_TEST_ASSERT(field.GetAssociation() == vtkm::cont::Field::Association::Points,
|
2020-05-11 21:08:44 +00:00
|
|
|
"The field should be associated with points.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int UnitTestBOVDataSetReader(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
return vtkm::cont::testing::Testing::Run(TestReadingBOVDataSet, argc, argv);
|
|
|
|
}
|