Skip to content

Commit 1838442

Browse files
committed
Add an example of the MultiBlockDataGroupFilter
This is the "Group Datasets" filter in ParaView and is useful for creating multiblock datasets.
1 parent faf13c4 commit 1838442

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

Cxx/CompositeData/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ ADD_TEST(${KIT}-OverlappingAMR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests
3434
TestOverlappingAMR -E 35)
3535
ADD_TEST(${KIT}-CompositePolyDataMapper ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests
3636
TestCompositePolyDataMapper)
37+
ADD_TEST(${KIT}-MultiBlockDataGroupFilter ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests
38+
TestMultiBlockDataGroupFilter)
3739

3840
INCLUDE(${WikiExamples_SOURCE_DIR}/CMake/ExamplesTesting.cmake)
3941

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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

Comments
 (0)