VTK VolumeRendering.How to process .txt file data

Hello everyone,
I am a beginner to VTK.I’m trying to volume render with vtk C++ in VS.
My teacher sent me a txt file and asked me to perform volume rendering on the data inside.
In the past few days, I have studied some VTK cases and successfully rendered some .vtk and .mhd format documents.But I don’t know how to process txt format documents.

The document content is as follows:

Model data only knows size:100100240

What should I do with this data?Thanks!!

You can read the text file into a buffer using STL filestream and then use vtkImageImport to set the buffer as the scalar array on a vtkImageData.

This is my script:

std::ifstream file(“data501.txt”);
float value;

while (file>>value)

vtkSmartPointer<vtkImageData>imagedata =
imagedata->SetDimensions(100, 100, 240);

And then what should I do?Thank you very much

See https://examples.vtk.org/site/Cxx/Images/ImageImport/