-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext_origin.cpp
More file actions
53 lines (41 loc) · 1.57 KB
/
Copy pathtext_origin.cpp
File metadata and controls
53 lines (41 loc) · 1.57 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
#include "vtkActor.h"
#include "vtkAxes.h"
#include "vtkCamera.h"
#include "vtkFollower.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
#include "vtkVectorText.h"
#include <iostream>
int main() {
const auto axes = vtkSmartPointer<vtkAxes>::New();
axes->SetOrigin(0, 0, 0);
const auto axes_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
axes_mapper->SetInputConnection(axes->GetOutputPort());
const auto axes_actor = vtkSmartPointer<vtkActor>::New();
axes_actor->SetMapper(axes_mapper);
const auto text = vtkSmartPointer<vtkVectorText>::New();
text->SetText("Origin");
const auto text_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
text_mapper->SetInputConnection(text->GetOutputPort());
const auto text_actor = vtkSmartPointer<vtkFollower>::New();
text_actor->SetMapper(text_mapper);
text_actor->SetScale(0.2, 0.2, 0.2);
text_actor->AddPosition(0, -0.1, 0);
const auto render = vtkSmartPointer<vtkRenderer>::New();
render->AddActor(text_actor);
render->AddActor(axes_actor);
const auto render_window = vtkSmartPointer<vtkRenderWindow>::New();
render_window->AddRenderer(render);
const auto interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(render_window);
render->ResetCamera();
render->GetActiveCamera()->Zoom(1.6);
render->ResetCameraClippingRange();
text_actor->SetCamera(render->GetActiveCamera());
interactor->Initialize();
render_window->Render();
interactor->Start();
}