Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cxx/CompositeData/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
45 changes: 45 additions & 0 deletions Cxx/CompositeData/MultiBlockDataGroupFilter.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <vtkMultiBlockDataSet.h>
#include <vtkSphereSource.h>
#include <vtkNew.h>
#include <vtkCompositePolyDataMapper2.h>
#include <vtkMultiBlockDataGroupFilter.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>

int main( int argc, char *argv[] )
{
vtkNew<vtkMultiBlockDataGroupFilter> 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<vtkSphereSource> sphere;
sphere->SetCenter(2 * i, 2 * j,0);
sphere->SetRadius((50 - (i * i) - (j * j)) / 52.4);
groupFilter->AddInputConnection(sphere->GetOutputPort());
}
}

vtkNew<vtkCompositePolyDataMapper2> mapper;
mapper->SetInputConnection(groupFilter->GetOutputPort());

vtkNew<vtkActor> actor;
actor->SetMapper(mapper.Get());

vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer.Get());
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow.Get());

renderer->AddActor(actor.Get());

renderWindow->Render();
renderWindowInteractor->Start();

return EXIT_SUCCESS;
}