# How to show PartitionedDataSetCollection data?

**URL:** https://discourse.vtk.org/t/how-to-show-partitioneddatasetcollection-data/12933
**Category:** Support
**Tags:** code, proposal
**Created:** [December 19, 2023, 10:58am UTC](https://discourse.vtk.org/t/how-to-show-partitioneddatasetcollection-data/12933 "2023-12-19T10:58:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rockydut](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rockydut/32/4261_2.png) [@rockydut](https://discourse.vtk.org/u/rockydut)
#### Post date: [December 19, 2023, 10:58am UTC](https://discourse.vtk.org/t/how-to-show-partitioneddatasetcollection-data/12933/1 "2023-12-19T10:58:15Z")

</div>

I’m very confused forthe showing of vtkPartitionedDataSetCollection data, which mapper is suitable for such data.  
The following code shows that “mapper-\>SetInputConnection(partionDataSetColl)” is incorrect.  
How to correctly show the grids.

My code list below.

#include \<vtkSmartPointer.h\>  
#include \<vtkPartitionedDataSet.h\>  
#include \<vtkPartitionedDataSetCollection.h\>  
#include \<vtkUnstructuredGrid.h\>  
#include \<vtkPoints.h\>  
#include \<vtkDataSetMapper.h\>  
#include \<vtkActor.h\>  
#include \<vtkRenderer.h\>  
#include \<vtkRenderWindow.h\>  
#include \<vtkRenderWindowInteractor.h\>  
#include \<vtkProperty.h\>  
#include \<vtkPointData.h\>  
int main(int argc, char\* argv)  
{  
vtkNew points1;  
points1-\>InsertNextPoint(0.0, 0.0, 0.0);  
points1-\>InsertNextPoint(1.0, 0.0, 0.0);  
points1-\>InsertNextPoint(1.0, 1.0, 0.0);  
points1-\>InsertNextPoint(0.0, 1.0, 0.0);  
points1-\>InsertNextPoint(0.0, 0.0, 1.0);  
points1-\>InsertNextPoint(1.0, 0.0, 1.0);  
points1-\>InsertNextPoint(1.0, 1.0, 1.0);  
points1-\>InsertNextPoint(0.0, 1.0, 1.0);

```
vtkNew<vtkPoints> points2;
points2->InsertNextPoint(1.0, 0.0, 0.0);
points2->InsertNextPoint(2.0, 0.0, 0.0);
points2->InsertNextPoint(2.0, 1.0, 0.0);
points2->InsertNextPoint(1.0, 1.0, 0.0);
points2->InsertNextPoint(1.0, 0.0, 1.0);
points2->InsertNextPoint(2.0, 0.0, 1.0);
points2->InsertNextPoint(2.0, 1.0, 1.0);
points2->InsertNextPoint(1.0, 1.0, 1.0);

vtkNew<vtkCellArray> cells1;
vtkIdType hex1[8] = {0, 1, 2, 3, 4, 5, 6, 7};
cells1->InsertNextCell(8, hex1);
vtkNew<vtkUnstructuredGrid> grid1;
grid1->SetPoints(points1);
grid1->SetCells(VTK_HEXAHEDRON, cells1);

vtkNew<vtkCellArray> cells2;
vtkIdType hex2[8] = {0, 1, 2, 3, 4, 5, 6, 7};
cells2->InsertNextCell(8, hex2);
vtkNew<vtkUnstructuredGrid> grid2;
grid2->SetPoints(points2);
grid2->SetCells(VTK_HEXAHEDRON, cells2);

vtkNew<vtkIdTypeArray> id1;
id1->InsertNextValue(0);
id1->InsertNextValue(1);
id1->InsertNextValue(4);
id1->InsertNextValue(3);
id1->InsertNextValue(6);
id1->InsertNextValue(7);
id1->InsertNextValue(10);
id1->InsertNextValue(9);
grid1->GetPointData()->SetGlobalIds(id1);

vtkNew<vtkIdTypeArray> id2;
id2->InsertNextValue(1);
id2->InsertNextValue(2);
id2->InsertNextValue(5);
id2->InsertNextValue(4);
id2->InsertNextValue(7);
id2->InsertNextValue(8);
id2->InsertNextValue(11);
id2->InsertNextValue(10);
grid2->GetPointData()->SetGlobalIds(id2);

vtkNew<vtkPartitionedDataSet> partionDataSet;
partionDataSet->SetNumberOfPartitions(2);
partionDataSet->SetPartition(0, grid1);
partionDataSet->SetPartition(1, grid2);

vtkNew<vtkPartitionedDataSetCollection> partionDataSetColl;
partionDataSetColl->SetNumberOfPartitionedDataSets(1);
partionDataSetColl->SetPartitionedDataSet(0, partionDataSet);

vtkNew<vtkDataSetMapper> mapper;
mapper->SetInputConnection(partionDataSetColl);

vtkNew<vtkActor> actor;
actor->SetMapper(mapper);

vtkNew<vtkProperty> property;
property->SetColor(1.0, 0.0, 0.0);
actor->SetProperty(property);

vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renderWindow);

renderer->AddActor(actor);

renderer->SetBackground(0.1, 0.1, 0.1);
renderWindow->SetSize(800, 600);
renderWindow->Render();

interactor->Start();
return 0;

```

}

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 1, 2024, 3:50am UTC](https://discourse.vtk.org/t/how-to-show-partitioneddatasetcollection-data/12933/2 "2024-01-01T03:50:13Z")

</div>

SetInputConnection expects a vtkAlgorithmOutput but you’re pasing a Datset.

Use mapper.SetInpuDataObject instead

---

<div class="post-metadata">

### Author: ![rockydut](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rockydut/32/4261_2.png) [@rockydut](https://discourse.vtk.org/u/rockydut)
#### Post date: [January 2, 2024, 6:26am UTC](https://discourse.vtk.org/t/how-to-show-partitioneddatasetcollection-data/12933/3 "2024-01-02T06:26:33Z")

</div>

Thanks for you reply. However, even I change it to SetInputDataObject, it shows the following errors:  
vtkCompositeDataPipelin:143 ERR| vtkCompositeDataPipeline (0x112f78dbc20): Can not execute simple algorithm vtkDataSetMapper (0x112f7953b70) without output ports  
ERROR: In vtkCompositeDataPipeline.cxx, line 143  
vtkCompositeDataPipeline (0x112f78dbc20): Can not execute simple algorithm vtkDataSetMapper (0x112f7953b70) without output ports

My changes show as following.  
vtkNew partionDataSetColl;  
partionDataSetColl-\>SetNumberOfPartitionedDataSets(2);  
partionDataSetColl-\>SetPartitionedDataSet(0, partionDataSet1);  
partionDataSetColl-\>SetPartitionedDataSet(1, partionDataSet2);  
vtkNew mapper;  
mapper-\>SetInputDataObject(partionDataSetColl);  
vtkNew actor;  
actor-\>SetMapper(mapper);  
renderer-\>AddActor(actor);
