-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathencapsulate_in_class.cpp
80 lines (66 loc) · 2.17 KB
/
encapsulate_in_class.cpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <vtkActor.h>
#include <vtkConeSource.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
namespace {
// source parameter
const double source_heiht = 3.0;
const double source_radius = 1.0;
const double source_resolution = 100;
// backgroud color
const double background_color_r = 0.2;
const double background_color_g = 0.4;
const double background_color_b = 0.3;
} // namespace
class MyVTKApp {
using source_type = vtkSmartPointer<vtkConeSource>;
using render_type = vtkSmartPointer<vtkRenderer>;
using interactor_type = vtkSmartPointer<vtkRenderWindowInteractor>;
using mapper_type = vtkSmartPointer<vtkPolyDataMapper>;
using actor_type = vtkSmartPointer<vtkActor>;
using render_window_type = vtkSmartPointer<vtkRenderWindow>;
using interactor_style_type
= vtkSmartPointer<vtkInteractorStyleTrackballCamera>;
public:
MyVTKApp() {
source_ = source_type::New();
source_->SetHeight(source_heiht);
source_->SetRadius(source_radius);
source_->SetResolution(source_resolution);
mapper_ = mapper_type::New();
mapper_->SetInputConnection(source_->GetOutputPort());
actor_ = actor_type::New();
actor_->SetMapper(mapper_);
render_ = render_type::New();
render_->AddActor(actor_);
render_->SetBackground(background_color_r, background_color_g,
background_color_b);
render_window_ = render_window_type::New();
render_window_->AddRenderer(render_);
// render_window_->SetParentId(parent);
render_window_->SetSize(400, 400);
const auto style = interactor_style_type::New();
interactor_ = interactor_type::New();
interactor_->SetInteractorStyle(style);
interactor_->SetRenderWindow(render_window_);
render_window_->Render();
interactor_->Initialize();
interactor_->Start();
}
~MyVTKApp() = default;
private:
source_type source_;
render_window_type render_window_;
render_type render_;
interactor_type interactor_;
mapper_type mapper_;
actor_type actor_;
};
auto main() -> int {
MyVTKApp app;
return 0;
}