I am trying to stream a ply file instead of reading it from a file using SetInputString()
. The data
is a binary string, which looks like:
ply
format binary_little_endian 1.0
comment VTK generated PLY File
comment SPACE=LPS
obj_info vtkPolyData points and polygons: vtk4.0
element vertex 120
property float x
property float y
property float z
property float u
property float v
element face 120
property list uchar int vertex_indices
end_header
??B"?B??
If I read the same data from a file using reader->SetFileName()
, it works as expected. But for the following case, the number of read cells are 0.
vtkSmartPointer<vtkPLYReader> reader = vtkSmartPointer<vtkPLYReader>::New();
reader->SetReadFromInputString(true);
reader->ReadFromInputStringOn();
reader->SetInputString(data.c_str());
reader->Update();
vtkSmartPointer<vtkPolyData> polyData = reader->GetOutput();
polyData->Modified();
std::cout << "data: " << data.c_str() <<std::endl;
std::cout << "number of cells: " << polyData->GetNumberOfCells() <<std::endl;