|
| 1 | +#include <vtkMultiBlockDataSet.h> |
| 2 | +#include <vtkSphereSource.h> |
| 3 | +#include <vtkNew.h> |
| 4 | +#include <vtkCompositePolyDataMapper2.h> |
| 5 | +#include <vtkMultiBlockDataGroupFilter.h> |
| 6 | +#include <vtkActor.h> |
| 7 | +#include <vtkRenderer.h> |
| 8 | +#include <vtkRenderWindow.h> |
| 9 | +#include <vtkRenderWindowInteractor.h> |
| 10 | + |
| 11 | +int main( int argc, char *argv[] ) |
| 12 | +{ |
| 13 | + vtkNew<vtkMultiBlockDataGroupFilter> groupFilter; |
| 14 | + // The vtkMultiBlockDataGroupFilter allows multiple inputs and adds |
| 15 | + // each input as a block in its output multiblock dataset. |
| 16 | + for (int i = 0; i < 5; ++i) |
| 17 | + { |
| 18 | + for (int j = 0; j < 5; ++j) |
| 19 | + { |
| 20 | + vtkNew<vtkSphereSource> sphere; |
| 21 | + sphere->SetCenter(2 * i, 2 * j,0); |
| 22 | + sphere->SetRadius((50 - (i * i) - (j * j)) / 52.4); |
| 23 | + groupFilter->AddInputConnection(sphere->GetOutputPort()); |
| 24 | + } |
| 25 | + } |
| 26 | + |
| 27 | + vtkNew<vtkCompositePolyDataMapper2> mapper; |
| 28 | + mapper->SetInputConnection(groupFilter->GetOutputPort()); |
| 29 | + |
| 30 | + vtkNew<vtkActor> actor; |
| 31 | + actor->SetMapper(mapper.Get()); |
| 32 | + |
| 33 | + vtkNew<vtkRenderer> renderer; |
| 34 | + vtkNew<vtkRenderWindow> renderWindow; |
| 35 | + renderWindow->AddRenderer(renderer.Get()); |
| 36 | + vtkNew<vtkRenderWindowInteractor> renderWindowInteractor; |
| 37 | + renderWindowInteractor->SetRenderWindow(renderWindow.Get()); |
| 38 | + |
| 39 | + renderer->AddActor(actor.Get()); |
| 40 | + |
| 41 | + renderWindow->Render(); |
| 42 | + renderWindowInteractor->Start(); |
| 43 | + |
| 44 | + return EXIT_SUCCESS; |
| 45 | +} |
0 commit comments