From a053454cab4e66e63add63840ee56d36eb1944ec Mon Sep 17 00:00:00 2001 From: Shawn Waldon Date: Thu, 27 Apr 2017 16:07:28 -0400 Subject: [PATCH] Add an example of the MultiBlockDataGroupFilter This is the "Group Datasets" filter in ParaView and is useful for creating multiblock datasets. --- Cxx/CompositeData/CMakeLists.txt | 2 + .../MultiBlockDataGroupFilter.cxx | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Cxx/CompositeData/MultiBlockDataGroupFilter.cxx diff --git a/Cxx/CompositeData/CMakeLists.txt b/Cxx/CompositeData/CMakeLists.txt index 5340171..707ae05 100644 --- a/Cxx/CompositeData/CMakeLists.txt +++ b/Cxx/CompositeData/CMakeLists.txt @@ -36,6 +36,8 @@ ADD_TEST(${KIT}-CompositePolyDataMapper ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT} TestCompositePolyDataMapper) ADD_TEST(${KIT}-MultiBlockDataSet ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests TestMultiBlockDataSet) +ADD_TEST(${KIT}-MultiBlockDataGroupFilter ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests + TestMultiBlockDataGroupFilter) INCLUDE(${WikiExamples_SOURCE_DIR}/CMake/ExamplesTesting.cmake) diff --git a/Cxx/CompositeData/MultiBlockDataGroupFilter.cxx b/Cxx/CompositeData/MultiBlockDataGroupFilter.cxx new file mode 100644 index 0000000..f4164c7 --- /dev/null +++ b/Cxx/CompositeData/MultiBlockDataGroupFilter.cxx @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main( int argc, char *argv[] ) +{ + vtkNew groupFilter; + // The vtkMultiBlockDataGroupFilter allows multiple inputs and adds + // each input as a block in its output multiblock dataset. + for (int i = 0; i < 5; ++i) + { + for (int j = 0; j < 5; ++j) + { + vtkNew sphere; + sphere->SetCenter(2 * i, 2 * j,0); + sphere->SetRadius((50 - (i * i) - (j * j)) / 52.4); + groupFilter->AddInputConnection(sphere->GetOutputPort()); + } + } + + vtkNew mapper; + mapper->SetInputConnection(groupFilter->GetOutputPort()); + + vtkNew actor; + actor->SetMapper(mapper.Get()); + + vtkNew renderer; + vtkNew renderWindow; + renderWindow->AddRenderer(renderer.Get()); + vtkNew renderWindowInteractor; + renderWindowInteractor->SetRenderWindow(renderWindow.Get()); + + renderer->AddActor(actor.Get()); + + renderWindow->Render(); + renderWindowInteractor->Start(); + + return EXIT_SUCCESS; +}