MCPcopy Create free account
hub / github.com/Kitware/VTK / operator()

Method operator()

IO/NetCDF/vtkNetCDFUGRIDReader.cxx:831–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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//--------------------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 11

nc_get_attFunction · 0.85
DataArrayValueRangeFunction · 0.85
NanFunction · 0.85
nc_get_varaFunction · 0.70
replaceFunction · 0.50
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
dataMethod · 0.45
GetPointerMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected