| 321 | |
| 322 | template <typename ValueT> |
| 323 | vtkDenseArray<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 |
nothing calls this directly
no test coverage detected