# How to combile vtkGlyph3DMapper and vtkMultiBlockDataset

**URL:** https://discourse.vtk.org/t/how-to-combile-vtkglyph3dmapper-and-vtkmultiblockdataset/12960
**Category:** Support
**Created:** [December 22, 2023, 3:22pm UTC](https://discourse.vtk.org/t/how-to-combile-vtkglyph3dmapper-and-vtkmultiblockdataset/12960 "2023-12-22T15:22:13Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![baker-Xie](https://discourse.vtk.org/user_avatar/discourse.vtk.org/baker-xie/32/8169_2.png) [@baker-Xie](https://discourse.vtk.org/u/baker-Xie)
#### Post date: [December 22, 2023, 3:22pm UTC](https://discourse.vtk.org/t/how-to-combile-vtkglyph3dmapper-and-vtkmultiblockdataset/12960/1 "2023-12-22T15:22:13Z")

</div>

1. The following code doesn’t show anything

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

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

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

```

---

<div class="post-metadata">

### Author: ![mau\_igna\_06](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mau_igna_06/32/8064_2.png) [@mau\_igna\_06](https://discourse.vtk.org/u/mau_igna_06)
#### Post date: [December 22, 2023, 4:01pm UTC](https://discourse.vtk.org/t/how-to-combile-vtkglyph3dmapper-and-vtkmultiblockdataset/12960/2 "2023-12-22T16:01:02Z")

</div>

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

---

<div class="post-metadata">

### Author: ![baker-Xie](https://discourse.vtk.org/user_avatar/discourse.vtk.org/baker-xie/32/8169_2.png) [@baker-Xie](https://discourse.vtk.org/u/baker-Xie)
#### Post date: [December 23, 2023, 12:36am UTC](https://discourse.vtk.org/t/how-to-combile-vtkglyph3dmapper-and-vtkmultiblockdataset/12960/3 "2023-12-23T00:36:52Z")

</div>

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

```auto
        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();

```
