VTK reads the whole file instead of the selected array.

The following code requests the “Q” scalar field to be read only, but VTK nevertheless attempts to read the whole thing, saturating 256GB of memory, and crashing. Is there something I am doing wrong?

#include <cstdint>
#include <string>

#include <vtkDataObject.h>
#include <vtkResampleToImage.h>
#include <vtkSmartPointer.h>
#include <vtkXMLImageDataWriter.h>
#include <vtkXMLUnstructuredGridReader.h>

// Usage: ./vtu_to_vti_converter [VTU_FILEPATH] [X_RESOLUTION] [Y_RESOLUTION] [Z_RESOLUTION].
std::int32_t main(std::int32_t argc, char** argv)
  auto filepath  = std::string(argv[1]);

  auto reader    = vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
  auto converter = vtkSmartPointer<vtkResampleToImage>          ::New();
  auto writer    = vtkSmartPointer<vtkXMLImageDataWriter>       ::New();

  reader   ->SetFileName           (filepath.c_str());
  reader   ->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, "Q");

  converter->SetInputConnection    (reader->GetOutputPort());
  converter->SetUseInputBounds     (true);
  converter->SetSamplingDimensions (std::stoi(argv[2]), std::stoi(argv[3]), std::stoi(argv[4]));

  writer   ->SetInputConnection    (converter->GetOutputPort());
  writer   ->SetFileName           ((filepath.substr(0, filepath.size() - 3) + std::string("vti")).c_str());
  writer   ->Update                ();

  return 0;

Solved via:

  std::cout << "Reading unstructured grid.\n";
  reader   ->SetFileName           (filepath.c_str());
  reader   ->UpdateInformation     ();
  for (auto i = 0; i < reader->GetNumberOfCellArrays(); ++i)
	reader->SetCellArrayStatus(reader->GetCellArrayName(i), reader->GetCellArrayName(i) == "Q" ? 1 : 0);
  reader   ->Update                ();
  auto input_data  = reader->GetOutput();

Very unintuitive.