| 829 | { |
| 830 | template <typename OutArray> |
| 831 | void operator()(OutArray* output, int NcId, int var, std::size_t time, std::size_t size, |
| 832 | bool isTemporal, bool replaceFill, int& result) |
| 833 | { |
| 834 | using T = vtk::GetAPIType<OutArray>; |
| 835 | |
| 836 | output->SetNumberOfComponents(1); |
| 837 | output->SetNumberOfTuples(size); |
| 838 | |
| 839 | if (isTemporal) |
| 840 | { |
| 841 | const std::array<std::size_t, 2> start{ time, 0 }; |
| 842 | const std::array<std::size_t, 2> count{ 1, size }; |
| 843 | result = nc_get_vara(NcId, var, start.data(), count.data(), output->GetPointer(0)); |
| 844 | } |
| 845 | else |
| 846 | { |
| 847 | const std::array<std::size_t, 1> start{ 0 }; |
| 848 | const std::array<std::size_t, 1> count{ size }; |
| 849 | result = nc_get_vara(NcId, var, start.data(), count.data(), output->GetPointer(0)); |
| 850 | } |
| 851 | |
| 852 | if (result != NC_NOERR) |
| 853 | { |
| 854 | return; |
| 855 | } |
| 856 | |
| 857 | if (replaceFill && (std::is_same<T, float>::value || std::is_same<T, double>::value)) |
| 858 | { |
| 859 | T fillValue{}; |
| 860 | if (nc_get_att(NcId, var, "_FillValue", &fillValue) != NC_NOERR) |
| 861 | { |
| 862 | vtkDebugWithObjectMacro(output, "No fill value defined"); |
| 863 | return; |
| 864 | } |
| 865 | |
| 866 | auto range(vtk::DataArrayValueRange(output)); |
| 867 | std::replace(range.begin(), range.end(), fillValue, static_cast<T>(vtkMath::Nan())); |
| 868 | } |
| 869 | } |
| 870 | }; |
| 871 | |
| 872 | //-------------------------------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected