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;
}