-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmooth_fran.cpp
58 lines (46 loc) · 1.6 KB
/
smooth_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
55
56
57
58
#include "vtkActor.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataNormals.h"
#include "vtkPolyDataReader.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSmoothPolyDataFilter.h"
#include "platform.h"
#include <filesystem>
int main() {
vtkNew<vtkPolyDataReader> reader;
reader->SetFileName(
(fs::canonical("Data").string() + "/fran_cut.vtk").c_str());
vtkNew<vtkSmoothPolyDataFilter> smooth;
smooth->SetInputConnection(reader->GetOutputPort());
smooth->SetNumberOfIterations(100);
vtkNew<vtkPolyDataNormals> normals;
normals->SetInputConnection(smooth->GetOutputPort());
normals->FlipNormalsOn();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(normals->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkPolyDataMapper> original_mapper;
original_mapper->SetInputConnection(reader->GetOutputPort());
vtkNew<vtkActor> original_actor;
original_actor->SetMapper(original_mapper);
vtkNew<vtkRenderer> render;
render->AddActor(actor);
render->SetBackground(0.1, 0.2, 0.4);
render->SetViewport(0.0, 0.0, 0.5, 1.0);
vtkNew<vtkRenderer> original_render;
original_render->AddActor(original_actor);
original_render->SetBackground(1, 1, 1);
original_render->SetViewport(0.5, 0.0, 1.0, 1.0);
vtkNew<vtkRenderWindow> window;
window->AddRenderer(render);
window->AddRenderer(original_render);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(window);
interactor->Initialize();
window->Render();
interactor->Start();
}