I am a new user of VTK, everything is working before I get this problem. First, let me apologize for the dumb question I am asking here.
What I want to do is reading in an Unstructured dataset from a file, and put them into a vtkPolyData. So I wrote the following CPP code and it’s working, so far so good.
However, I have some other data other than ‘T’ and I want to put them into vtkPolyData once and for all.
vtkSmartPointer<vtkPoints> vtk_points = reader->GetOutput()->GetPoints(); // coordinates
// field data
vtkSmartPointer<vtkPointData> vtk_point_data = reader->GetOutputAsDataSet()->GetPointData();
vtk_point_data->Update();
vtkSmartPointer<vtkDataArray> vtk_data_array = vtk_point_data->GetArray("T"); // read temperature
// set value of the private member
iPolyData = vtkSmartPointer<vtkPolyData>::New();
iPolyData->SetPoints(vtk_points); //set as original vector
//todo: get multiple data array as inputs
iPolyData->GetPointData()->SetScalars(vtk_data_array);
iPolyData->GetPointData()->Update();
so I tried something like
iPolyData->GetPointData()->DeepCopy(reader->GetOutputAsDataSet()->GetPointData());
iPolyData->GetPointData()->Update();
this doesn’t work, as I am getting no output(actually I didn’t figure out how to debug other than see the output, how do I make gdb work for this, okay, that’s another confusion I have).
I also tried something like adding this array one by one. It doesn’t work as well.
vtkSmartPointer<vtkDataArray> vtk_data_array = vtk_point_data->GetArray("T"); // read temperature
iPolyData->GetPointData()->AddArray(vtk_data_array);
iPolyData->GetPointData()->Update();