# Import multiple data array from unstructured file into a polydata(cpp)

**URL:** https://discourse.vtk.org/t/import-multiple-data-array-from-unstructured-file-into-a-polydata-cpp/6255
**Category:** Support
**Created:** [July 27, 2021, 11:53pm UTC](https://discourse.vtk.org/t/import-multiple-data-array-from-unstructured-file-into-a-polydata-cpp/6255 "2021-07-27T23:53:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![lhy11009](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lhy11009/32/3713_2.png) [@lhy11009](https://discourse.vtk.org/u/lhy11009)
#### Post date: [July 27, 2021, 11:53pm UTC](https://discourse.vtk.org/t/import-multiple-data-array-from-unstructured-file-into-a-polydata-cpp/6255/1 "2021-07-27T23:53:10Z")

</div>

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.

```auto
    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

```auto
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.

```auto
vtkSmartPointer<vtkDataArray> vtk_data_array = vtk_point_data->GetArray("T"); // read temperature
iPolyData->GetPointData()->AddArray(vtk_data_array);
iPolyData->GetPointData()->Update();

```
