MCPcopy Create free account
hub / github.com/Kitware/VTK / TestNetCDFCAMReader

Function TestNetCDFCAMReader

IO/NetCDF/Testing/Cxx/TestNetCDFCAMReader.cxx:26–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#include <iostream>
25
26int TestNetCDFCAMReader(int argc, char* argv[])
27{
28 // Read file names.
29 char* pointsFileName =
30 vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/NetCDF/CAMReaderPoints.nc");
31 char* connectivityFileName =
32 vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/NetCDF/CAMReaderConnectivity.nc");
33
34 // Create the reader.
35 vtkNew<vtkNetCDFCAMReader> reader;
36 reader->SetFileName(pointsFileName);
37 reader->SetConnectivityFileName(connectivityFileName);
38 delete[] pointsFileName;
39 pointsFileName = nullptr;
40 delete[] connectivityFileName;
41 connectivityFileName = nullptr;
42 reader->Update();
43
44 // Check that the lev variable is loaded correctly
45 auto output = reader->GetOutput()->GetPointData();
46 auto lev = vtkFloatArray::SafeDownCast(output->GetAbstractArray("lev"));
47 const vtkIdType numTuples = lev->GetNumberOfTuples();
48
49 std::set<float> expectedLevels = { 3.54463800000002, 7.38881300000002, 13.9672100000001, 23.94463,
50 37.2302900000001, 53.1146000000002, 70.0591400000001, 85.4391200000001, 100.514690000001,
51 118.25033, 139.11538, 163.66205, 192.539940000001, 226.51321, 266.48106, 313.501270000001,
52 368.81799, 433.895230000001, 510.455250000002, 600.524100000001, 696.796239999999,
53 787.702010000002, 867.160710000001, 929.648975, 970.554785000003, 992.556100000005 };
54
55 // Valid that the level values valid
56 for (auto tupleIdx = 0; tupleIdx < numTuples; ++tupleIdx)
57 {
58 auto level = *lev->GetTuple(tupleIdx);
59 if (expectedLevels.count(level) != 1)
60 {
61 std::cerr << "Invalid level value:" << level << std::endl;
62 return EXIT_FAILURE;
63 }
64 }
65
66 // Convert to PolyData.
67 vtkNew<vtkGeometryFilter> geometryFilter;
68 geometryFilter->SetInputConnection(reader->GetOutputPort());
69
70 // Create a mapper and LUT.
71 vtkNew<vtkPolyDataMapper> mapper;
72 mapper->SetInputConnection(geometryFilter->GetOutputPort());
73 mapper->ScalarVisibilityOn();
74 mapper->SetColorModeToMapScalars();
75 mapper->SetScalarRange(205, 250);
76 mapper->SetScalarModeToUsePointFieldData();
77 mapper->SelectColorArray("T");
78
79 // Create the actor.
80 vtkNew<vtkActor> actor;
81 actor->SetMapper(mapper);
82
83 // Basic visualisation.

Callers

nothing calls this directly

Calls 15

vtkRegressionTestImageFunction · 0.85
GetAbstractArrayMethod · 0.80
RenderMethod · 0.65
SetFileNameMethod · 0.45
UpdateMethod · 0.45
GetPointDataMethod · 0.45
GetOutputMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetTupleMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected