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

Function ReadDenseArrayAscii

IO/Core/vtkArrayReader.cxx:323–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321
322template <typename ValueT>
323vtkDenseArray<ValueT>* ReadDenseArrayAscii(istream& stream)
324{
325 // Create the array ...
326 vtkSmartPointer<vtkDenseArray<ValueT>> array = vtkSmartPointer<vtkDenseArray<ValueT>>::New();
327
328 // Read the file header ...
329 vtkArrayExtents extents;
330 vtkArrayExtents::SizeT non_null_size = 0;
331 ReadHeader(stream, extents, non_null_size, array);
332
333 if (non_null_size != extents.GetSize())
334 throw std::runtime_error("Incorrect number of values for a dense array.");
335
336 // Read the file contents ...
337 ValueT value;
338 vtkArray::SizeT n = 0;
339 vtkArrayCoordinates coordinates;
340 for (; n < non_null_size; ++n)
341 {
342 ExtractValue(stream, value);
343 if (!stream)
344 break;
345 extents.GetRightToLeftCoordinatesN(n, coordinates);
346 array->SetValue(coordinates, value);
347 }
348
349 if (n != non_null_size)
350 throw std::runtime_error("Stream doesn't contain enough values.");
351
352 // If there is more in the stream (e.g. in vtkArrayDataReader),
353 // eat the newline so the stream is ready for the next vtkArray.
354 if (stream)
355 {
356 stream.get();
357 }
358
359 array->Register(nullptr);
360 return array;
361}
362
363} // End anonymous namespace
364

Callers

nothing calls this directly

Calls 8

ReadHeaderFunction · 0.85
ExtractValueFunction · 0.85
NewFunction · 0.50
GetSizeMethod · 0.45
SetValueMethod · 0.45
getMethod · 0.45
RegisterMethod · 0.45

Tested by

no test coverage detected