How to combile vtkGlyph3DMapper and vtkMultiBlockDataset

  1. The following code doesn’t show anything
        vtkNew<vtkCubeSource> cube_source;
        vtkNew<vtkArrowSource> arrow_source;
        vtkNew<vtkSphereSource> sphere_source;

        vtkNew<vtkMultiPieceDataSet> dataset;
        vtkNew<vtkGlyph3DMapper> obj_mapper;

        dataset->SetNumberOfPieces(3);
        dataset->SetPiece(0, cube_source->GetOutput());
        dataset->SetPiece(1, arrow_source->GetOutput());
        dataset->SetPiece(2, sphere_source->GetOutput());
        obj_mapper->SetUseSourceTableTree(true);
        obj_mapper->SetSourceTableTree(dataset);
        ...
        obj_mapper->Update();

but if I modify the code to ↓,it works. Why?

        obj_mapper->SetSourceConnection(0, cube_source->GetOutputPort());
        obj_mapper->SetSourceConnection(1, arrow_source->GetOutputPort());
        obj_mapper->SetSourceConnection(2, sphere_source->GetOutputPort());
  1. What the difference between SetSourceConnect and SetSourceData?
vtkNew<vtkCubeSource> cube_source;
vtkNew<vtkGlyph3DMapper> obj_mapper;
obj_mapper->SetSourceConnection(cube_source->GetOutputPort());  // This work
obj_mapper->SetSourceData(cube_source->GetOutput());                   // This doesn't work

If you use a filter’s SetInputConnection() instead of SetInputData() you don’t need to execute the filter’s Update() method before referencing to its GetOutput().

By using connections, the pipeline is in charge of calling all the needed Update() methods

Hi could you tell me why the following code doesn’t work?

        vtkNew<vtkCubeSource> cube_source;
        vtkNew<vtkArrowSource> arrow_source;
        vtkNew<vtkSphereSource> sphere_source;

        vtkNew<vtkMultiPieceDataSet> dataset;
        vtkNew<vtkGlyph3DMapper> obj_mapper;

        dataset->SetNumberOfPieces(3);
        dataset->SetPiece(0, cube_source->GetOutput());
        dataset->SetPiece(1, arrow_source->GetOutput());
        dataset->SetPiece(2, sphere_source->GetOutput());
        obj_mapper->SetUseSourceTableTree(true);
        obj_mapper->SetSourceTableTree(dataset);
        ...
        obj_mapper->Update();