-
Notifications
You must be signed in to change notification settings - Fork 1
/
transferfunction.h
81 lines (63 loc) · 1.86 KB
/
transferfunction.h
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
#ifndef TRANSFERFUNCTION_H
#define TRANSFERFUNCTION_H
// STD include
#include <iostream>
// Qt include
#include <QObject>
#include <QSharedPointer>
// CTK include
#include <ctkTransferFunction.h>
#include <ctkVTKPiecewiseFunction.h>
#include <ctkVTKColorTransferFunction.h>
#include <ctkVTKCompositeFunction.h>
// VTK include
#include <vtkSmartPointer.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
// cuda include
#include <cuda.h>
#include <cuda_runtime.h>
#include "cuda_utils.h"
#define TABLE_SIZE 1024
class TransferFunction : public QObject
{
Q_OBJECT
public:
explicit TransferFunction(vtkSmartPointer<vtkPiecewiseFunction> otf, vtkSmartPointer<vtkColorTransferFunction> ctf, QObject *parent = 0);
~TransferFunction();
cudaTextureObject_t GetCompositeTFTextureObject() {return compositeTex;}
void SaveCurrentTFConfiguration();
signals:
void Changed();
public slots:
protected slots:
void onOpacityTFChanged();
void onColorTFChanged();
private:
void CompositeTable();
private:
QSharedPointer<ctkTransferFunction> otf;
QSharedPointer<ctkTransferFunction> ctf;
vtkSmartPointer<vtkPiecewiseFunction> opacityTF;
vtkSmartPointer<vtkColorTransferFunction> colorTF;
float opacityTable[TABLE_SIZE];
float colorTable[TABLE_SIZE * 3];
float compositeTable[TABLE_SIZE * 4];
cudaArray *array;
cudaChannelFormatDesc channelDesc;
cudaResourceDesc resourceDesc;
cudaTextureDesc texDesc;
cudaTextureObject_t compositeTex;
};
inline void TransferFunction::CompositeTable()
{
size_t i = 0, j = 0, k = 0;
for(size_t c = 0; c < TABLE_SIZE; ++c)
{
compositeTable[i++] = colorTable[j++];
compositeTable[i++] = colorTable[j++];
compositeTable[i++] = colorTable[j++];
compositeTable[i++] = opacityTable[k++];
}
}
#endif // TRANSFERFUNCTION_H