-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
104 lines (77 loc) · 2.72 KB
/
main.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <vtkSmartPointer.h>
//#include <vtkHAVSVolumeMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkStructuredPointsReader.h>
#include <vtkStructuredPoints.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetTriangleFilter.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
#include <vtkVolumeProperty.h>
#include <vtkVolume.h>
#include <vtkCamera.h>
#include <vtkStdString.h>
#include<vtkUnstructuredGrid.h>
#include<vtkUnstructuredGridReader.h>
#include<vtkStructuredGridReader.h>
#include<vtkStructuredGrid.h>
#include<vtkPointData.h>
#include<vtkUnstructuredGridVolumeRayCastMapper.h>
#include<vtkUnstructuredGridVolumeZSweepMapper.h>
#include<vtkMultiBlockDataSet.h>
#include"vtkTecplotReaderBinary.h"
#include<vtkPlot3DMetaReader.h>
#include<vtkMultiBlockPLOT3DReader.h>
#include<vtkObjectFactory.h>
#include"vtkPProjectedTetrahedraMapper.h"
#include"vtkOpenGLPProjectedTetrahedraMapper.h"
#include"vtkPRenderingVolumeOpenGL2ObjectFactory.h"
#include <omp.h>
#include<iostream>
using namespace std;
#define VTK_CREATE(type,name) vtkSmartPointer<type> name=vtkSmartPointer<type>::New()
int main(int argc, char*argv[])
{
vtkPRenderingVolumeOpenGL2ObjectFactory *f = vtkPRenderingVolumeOpenGL2ObjectFactory::New();
vtkObjectFactory::RegisterFactory(f);
f->Delete();
VTK_CREATE(vtkRenderer, renderer);
VTK_CREATE(vtkRenderWindow, renwin);
renwin->AddRenderer(renderer);
VTK_CREATE(vtkRenderWindowInteractor, iren);
iren->SetRenderWindow(renwin);
VTK_CREATE(vtkStructuredGridReader, reader);
reader->SetFileName("../block71blk.vtk");
reader->Update();
VTK_CREATE(vtkDataSetTriangleFilter, filter);
filter->SetInputData(reader->GetOutput());
filter->Update();
double range[2];
reader->GetOutput()->GetScalarRange(range);
double mid = (range[0] + range[1]) / 2;
VTK_CREATE(vtkColorTransferFunction, color);
color->AddRGBPoint(range[0], 1, 0, 0);
color->AddRGBPoint(mid, 0, 1, 0);
color->AddRGBPoint(range[1], 0, 0, 1);
VTK_CREATE(vtkPiecewiseFunction, opacity);
opacity->AddPoint(range[0], 0);
opacity->AddPoint(range[1], 1);
VTK_CREATE(vtkPProjectedTetrahedraMapper, mapper);
mapper->SetInputConnection(filter->GetOutputPort());
mapper->SetNumberOfVST(40);
mapper->SetNumberOfCDT(40);
VTK_CREATE(vtkVolumeProperty, property);
property->SetColor(color);
property->SetScalarOpacity(opacity);
vtkVolume *volume = vtkVolume::New();
volume->SetMapper(mapper);
volume->SetProperty(property);
renderer->AddVolume(volume);
renwin->SetSize(500, 500);
renwin->Render();
iren->Initialize();
iren->Start();
return EXIT_SUCCESS;
}