-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreader_source_object.cpp
45 lines (35 loc) · 1.24 KB
/
reader_source_object.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
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkLODActor.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSTLReader.h"
#include "vtkSmartPointer.h"
#include "platform.h"
#include <string>
namespace {
const std::string data_root = "Data/";
} // namespace
auto main() -> int {
const auto reader = vtkSmartPointer<vtkSTLReader>::New();
reader->SetFileName(
(fs::canonical("Data").string() + "/42400-IDGH.stl").c_str());
const auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
const auto actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
const auto render = vtkSmartPointer<vtkRenderer>::New();
render->AddActor(actor);
const auto window = vtkSmartPointer<vtkRenderWindow>::New();
window->AddRenderer(render);
const auto interactor_style
= vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
const auto interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetInteractorStyle(interactor_style);
interactor->SetRenderWindow(window);
window->Render();
interactor->Initialize();
interactor->Start();
return 0;
}