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

Method ReadVector

IO/Parallel/vtkMultiBlockPLOT3DReader.cxx:2927–3006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2925}
2926
2927int vtkMultiBlockPLOT3DReader::ReadVector(void* vfp, int extent[6], int wextent[6], int numDims,
2928 vtkDataArray* vector, vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& record)
2929{
2930 vtkIdType n = vtkStructuredData::GetNumberOfPoints(extent);
2931 vtkIdType nValues = n * numDims;
2932
2933 FILE* fp = reinterpret_cast<FILE*>(vfp);
2934
2935 if (this->Internal->Settings.BinaryFile)
2936 {
2937 // precond: we assume the offset has been updated properly to step over
2938 // sub-record markers, if any.
2939 if (vtk_fseek(fp, offset, SEEK_SET) != 0)
2940 {
2941 return 0;
2942 }
2943 if (this->Internal->Settings.Precision == 4)
2944 {
2945 vtkPLOT3DArrayReader<float> arrayReader;
2946 arrayReader.ByteOrder = this->Internal->Settings.ByteOrder;
2947 vtkFloatArray* floatArray = static_cast<vtkFloatArray*>(vector);
2948 return arrayReader.ReadVector(fp, extent, wextent, numDims,
2949 floatArray->WritePointer(0, 3 * vtkStructuredData::GetNumberOfPoints(extent)),
2950 record) == nValues;
2951 }
2952 else
2953 {
2954 vtkPLOT3DArrayReader<double> arrayReader;
2955 arrayReader.ByteOrder = this->Internal->Settings.ByteOrder;
2956 vtkDoubleArray* doubleArray = static_cast<vtkDoubleArray*>(vector);
2957 return arrayReader.ReadVector(fp, extent, wextent, numDims,
2958 doubleArray->WritePointer(0, 3 * vtkStructuredData::GetNumberOfPoints(extent)),
2959 record) == nValues;
2960 }
2961 }
2962 else
2963 {
2964
2965 // Initialize the 3rd component to 0 in case the input file is
2966 // 2D
2967 vector->FillComponent(2, 0);
2968
2969 vtkIdType count = 0;
2970
2971 if (this->Internal->Settings.Precision == 4)
2972 {
2973 vtkFloatArray* floatArray = static_cast<vtkFloatArray*>(vector);
2974
2975 vtkFloatArray* tmpArray = vtkFloatArray::New();
2976 tmpArray->Allocate(n);
2977 for (int component = 0; component < numDims; component++)
2978 {
2979 count += this->ReadValues(fp, n, tmpArray);
2980 for (vtkIdType i = 0; i < n; i++)
2981 {
2982 floatArray->SetValue(3 * i + component, tmpArray->GetValue(i));
2983 }
2984 }

Callers 2

ReadMeshMethod · 0.95
ReadArraysMethod · 0.95

Calls 9

ReadValuesMethod · 0.95
FillComponentMethod · 0.80
DeleteMethod · 0.65
GetNumberOfPointsFunction · 0.50
NewFunction · 0.50
WritePointerMethod · 0.45
AllocateMethod · 0.45
SetValueMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected