-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvis_quad.cpp
56 lines (44 loc) · 1.88 KB
/
vis_quad.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
#include "vtkActor.h"
#include "vtkContourFilter.h"
#include "vtkOutlineFilter.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkQuadric.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSampleFunction.h"
#include "vtkSmartPointer.h"
int main() {
const auto quadric = vtkSmartPointer<vtkQuadric>::New();
quadric->SetCoefficients(0.5, 1, 0.2, 0, 0.1, 0, 0, 0.2, 0, 0);
const auto sample = vtkSmartPointer<vtkSampleFunction>::New();
sample->SetSampleDimensions(30, 30, 30);
sample->SetImplicitFunction(quadric);
const auto contour = vtkSmartPointer<vtkContourFilter>::New();
contour->SetInputConnection(sample->GetOutputPort());
contour->GenerateValues(10, 0.0, 1.5);
const auto contour_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
contour_mapper->SetInputConnection(contour->GetOutputPort());
contour_mapper->SetScalarRange(0.0, 1.1);
const auto actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(contour_mapper);
const auto outline = vtkSmartPointer<vtkOutlineFilter>::New();
outline->SetInputConnection(sample->GetOutputPort());
const auto outline_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
outline_mapper->SetInputConnection(outline->GetOutputPort());
const auto outline_actor = vtkSmartPointer<vtkActor>::New();
outline_actor->SetMapper(outline_mapper);
outline_actor->GetProperty()->SetColor(0, 0, 0);
const auto render = vtkSmartPointer<vtkRenderer>::New();
render->AddActor(actor);
render->AddActor(outline_actor);
render->SetBackground(1, 1, 1);
const auto render_window = vtkSmartPointer<vtkRenderWindow>::New();
render_window->AddRenderer(render);
const auto interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(render_window);
render_window->Render();
interactor->Initialize();
interactor->Start();
}