-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeci_fran.cpp
54 lines (44 loc) · 1.42 KB
/
deci_fran.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
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkDecimatePro.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataNormals.h"
#include "vtkPolyDataReader.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "platform.h"
#include <filesystem>
int main() {
vtkNew<vtkPolyDataReader> reader;
reader->SetFileName(
(fs::canonical("Data").string() + "/fran_cut.vtk").c_str());
vtkNew<vtkDecimatePro> decimate;
decimate->SetInputConnection(reader->GetOutputPort());
decimate->SetTargetReduction(0.9);
decimate->PreserveTopologyOn();
vtkNew<vtkPolyDataNormals> normals;
normals->SetInputConnection(reader->GetOutputPort());
normals->FlipNormalsOn();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(normals->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> render;
render->AddActor(actor);
render->SetBackground(1, 1, 1);
vtkNew<vtkCamera> camera;
camera->SetClippingRange(0.04, 2.4);
camera->SetFocalPoint(0.05, -0.129, -0.057);
camera->SetPosition(0.33, -0.12, -0.26);
camera->SetViewUp(-0.022, 0.999, 0.035);
render->SetActiveCamera(camera);
vtkNew<vtkRenderWindow> window;
window->AddRenderer(render);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(window);
interactor->Initialize();
window->Render();
interactor->Start();
}