forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkOpenGLProjectedAAHexahedraMapper.h
157 lines (122 loc) · 4.25 KB
/
vtkOpenGLProjectedAAHexahedraMapper.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOpenGLProjectedAAHexahedraMapper.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkOpenGLProjectedAAHexahedraMapper
* @brief OpenGL implementation of a volume mapper for axis-aligned hexahedra
*
* High quality volume renderer for axis-aligned hexahedra
*
* @par Implementation:
* Implementation by Stephane Marchesin (stephane.marchesin@gmail.com)
* CEA/DIF - Commissariat a l'Energie Atomique, Centre DAM Ile-De-France
* BP12, F-91297 Arpajon, France.
*
* @par Implementation:
* This mapper implements the paper
* "High-Quality, Semi-Analytical Volume Rendering for AMR Data",
* Stephane Marchesin and Guillaume Colin de Verdiere, IEEE Vis 2009.
*/
#ifndef vtkOpenGLProjectedAAHexahedraMapper_h
#define vtkOpenGLProjectedAAHexahedraMapper_h
#include "vtkRenderingVolumeOpenGLModule.h" // For export macro
#include "vtkProjectedAAHexahedraMapper.h"
class vtkFloatArray;
class vtkPoints;
class vtkUnsignedCharArray;
class vtkVisibilitySort;
class vtkVolumeProperty;
class vtkRenderWindow;
class vtkShaderProgram2;
class VTKRENDERINGVOLUMEOPENGL_EXPORT vtkOpenGLProjectedAAHexahedraMapper
: public vtkProjectedAAHexahedraMapper
{
public:
vtkTypeMacro(vtkOpenGLProjectedAAHexahedraMapper,
vtkProjectedAAHexahedraMapper);
static vtkOpenGLProjectedAAHexahedraMapper *New();
virtual void PrintSelf(ostream &os, vtkIndent indent);
/**
* Check if the required OpenGL extensions are supported by the OpenGL
* context attached to the render window `w'.
*/
bool IsRenderSupported(vtkRenderWindow *w);
void Render(vtkRenderer *renderer, vtkVolume *volume);
void ReleaseGraphicsResources(vtkWindow *window);
protected:
vtkOpenGLProjectedAAHexahedraMapper();
~vtkOpenGLProjectedAAHexahedraMapper();
/**
* Convert the input scalar values to floats.
*/
float* ConvertScalars(vtkDataArray* inScalars);
/**
* Convert the input cell coordinates to floats.
*/
float* ConvertPoints(vtkPoints* inPoints);
/**
* Iterate over all the hexahedal input cells,
* sort and render them.
*/
virtual void ProjectHexahedra(vtkRenderer *renderer, vtkVolume *volume);
/**
* Load the OpenGL extensions and allocate the vertex arrays.
*/
void Initialize(vtkRenderer *renderer, vtkVolume *volume);
/**
* Update the preintegration texture; this is needed whenever the mesh
* changes.
*/
void UpdatePreintegrationTexture(vtkVolume *vome, vtkDataArray *scalars);
/**
* Create the OpenGL geometry/vertex/fragment programs for
* hexahedral cell rendering.
*/
void CreateProgram(vtkRenderWindow *w);
/**
* Set the OpenGL state for hexahedral cell rendering.
*/
void SetState(double* observer);
/**
* Render a single axis-aligned hexahedal cell.
*/
void RenderHexahedron(float min[3], float max[3], float scalars[8]);
/**
* Restore the OpenGL state touched by SetState().
*/
void UnsetState();
bool Initialized;
int UsingCellColors;
float MaxCellSize;
vtkTimeStamp InputAnalyzedTime;
vtkTimeStamp PreintTextureTime;
vtkTimeStamp ColorsMappedTime;
unsigned int PreintTexture;
// OpenGL arrays for primitive submission
float* pos_points;
float* min_points;
float* node_data1;
float* node_data2;
// number of pending points
int num_points;
static const int max_points = 4096;
// our shader
vtkShaderProgram2 *Shader;
int GaveError;
float ScalarScale, ScalarShift, ScalarResolution;
float LengthScale;
vtkVolumeProperty *LastProperty;
vtkFloatArray *ConvertedPoints;
vtkFloatArray *ConvertedScalars;
private:
vtkOpenGLProjectedAAHexahedraMapper(const vtkOpenGLProjectedAAHexahedraMapper &) VTK_DELETE_FUNCTION;
void operator=(const vtkOpenGLProjectedAAHexahedraMapper &) VTK_DELETE_FUNCTION;
};
#endif