-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathHyperTreeGridSource.cxx
More file actions
67 lines (57 loc) · 3.07 KB
/
HyperTreeGridSource.cxx
File metadata and controls
67 lines (57 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <vtkHyperTreeGridSource.h>
#include <vtkShrinkFilter.h>
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkProperty.h>
#include <vtkDataSetMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkNamedColors.h>
int main( int, char*[] )
{
// Create hyper tree grid source
vtkSmartPointer<vtkHyperTreeGridSource> source =
vtkSmartPointer<vtkHyperTreeGridSource>::New();
source->SetMaximumLevel( 6 );
source->SetGridSize( 3, 3, 2 );
source->SetGridScale( 1.5, 1., .7 );
source->SetDimension( 3 );
source->SetBranchFactor( 4 );
source->SetDescriptor( "RRR .R. .RR ..R ..R .R.|R.......................... ........................... ........................... .............R............. ....RR.RR........R......... .....RRRR.....R.RR......... ........................... ........................... ...........................|........................... ........................... ........................... ...RR.RR.......RR.......... ........................... RR......................... ........................... ........................... ........................... ........................... ........................... ........................... ........................... ............RRR............|........................... ........................... .......RR.................. ........................... ........................... ........................... ........................... ........................... ........................... ........................... ...........................|........................... ..........................." );
source->Update();
vtkSmartPointer<vtkShrinkFilter> shrink =
vtkSmartPointer<vtkShrinkFilter>::New();
shrink->SetInputConnection(source->GetOutputPort());
shrink->SetShrinkFactor( .8 );
vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputConnection(shrink->GetOutputPort());
mapper->ScalarVisibilityOff();
vtkSmartPointer<vtkNamedColors> colors =
vtkSmartPointer<vtkNamedColors>::New();
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetDiffuseColor(colors->GetColor3d("Burlywood").GetData());
// Create the RenderWindow, Renderer and both Actors
//
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
renderer->SetBackground(colors->GetColor3d("SlateGray").GetData());
renderer->AddActor(actor);
renderer->ResetCamera();
renderer->GetActiveCamera()->Azimuth(150);
renderer->GetActiveCamera()->Elevation(30);
renderer->ResetCameraClippingRange();
renderWindow->SetSize(640, 480);
interactor->Start();
return EXIT_SUCCESS;
}