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

Method ReadScalar

IO/Parallel/vtkMultiBlockPLOT3DReader.cxx:2845–2925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2843}
2844
2845int vtkMultiBlockPLOT3DReader::ReadScalar(void* vfp, int extent[6], int wextent[6],
2846 vtkDataArray* scalar, vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& record)
2847{
2848 vtkIdType n = vtkStructuredData::GetNumberOfPoints(extent);
2849
2850 FILE* fp = reinterpret_cast<FILE*>(vfp);
2851
2852 if (this->Internal->Settings.BinaryFile)
2853 {
2854 // precond: we assume the offset has been updated properly to step over
2855 // sub-record markers, if any.
2856 if (vtk_fseek(fp, offset, SEEK_SET) != 0)
2857 {
2858 return 0;
2859 }
2860
2861 if (this->Internal->Settings.Precision == 4)
2862 {
2863 vtkPLOT3DArrayReader<float> arrayReader;
2864 arrayReader.ByteOrder = this->Internal->Settings.ByteOrder;
2865 vtkIdType preskip, postskip;
2866 vtkMultiBlockPLOT3DReaderInternals::CalculateSkips(extent, wextent, preskip, postskip);
2867 vtkFloatArray* floatArray = static_cast<vtkFloatArray*>(scalar);
2868 return arrayReader.ReadScalar(
2869 fp, preskip, n, postskip, floatArray->WritePointer(0, n), record) == n;
2870 }
2871 else
2872 {
2873 vtkPLOT3DArrayReader<double> arrayReader;
2874 arrayReader.ByteOrder = this->Internal->Settings.ByteOrder;
2875 vtkIdType preskip, postskip;
2876 vtkMultiBlockPLOT3DReaderInternals::CalculateSkips(extent, wextent, preskip, postskip);
2877 vtkDoubleArray* doubleArray = static_cast<vtkDoubleArray*>(scalar);
2878 return arrayReader.ReadScalar(
2879 fp, preskip, n, postskip, doubleArray->WritePointer(0, n), record) == n;
2880 }
2881 }
2882 else
2883 {
2884 if (this->Internal->Settings.Precision == 4)
2885 {
2886 vtkFloatArray* floatArray = static_cast<vtkFloatArray*>(scalar);
2887 float* values = floatArray->WritePointer(0, n);
2888
2889 int count = 0;
2890 for (int i = 0; i < n; i++)
2891 {
2892 if (auto result = vtk::scan_value<float>(fp))
2893 {
2894 values[i] = result->value();
2895 count++;
2896 }
2897 else
2898 {
2899 return 0;
2900 }
2901 }
2902 return count == n;

Callers 3

ReadArraysMethod · 0.95
ReadValuesMethod · 0.45
ReadIntScalarMethod · 0.45

Calls 3

GetNumberOfPointsFunction · 0.50
WritePointerMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected