VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
VolumeRendering
vtkUnstructuredGridBunykRayCastFunction.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkUnstructuredGridBunykRayCastFunction.h
5
6
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7
All rights reserved.
8
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10
This software is distributed WITHOUT ANY WARRANTY; without even
11
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
PURPOSE. See the above copyright notice for more information.
13
14
=========================================================================*/
15
59
#ifndef __vtkUnstructuredGridBunykRayCastFunction_h
60
#define __vtkUnstructuredGridBunykRayCastFunction_h
61
62
#include "
vtkUnstructuredGridVolumeRayCastFunction.h
"
63
64
class
vtkRenderer
;
65
class
vtkVolume
;
66
class
vtkUnstructuredGridVolumeRayCastMapper
;
67
class
vtkMatrix4x4
;
68
class
vtkPiecewiseFunction
;
69
class
vtkColorTransferFunction
;
70
class
vtkUnstructuredGrid
;
71
class
vtkIdList
;
72
class
vtkDoubleArray
;
73
class
vtkDataArray
;
74
75
// We manage the memory for the list of intersections ourself - this is the
76
// storage used. We keep 10,000 elements in each array, and we can have up to
77
// 1,000 arrays.
78
#define VTK_BUNYKRCF_MAX_ARRAYS 10000
79
#define VTK_BUNYKRCF_ARRAY_SIZE 10000
80
81
class
VTK_VOLUMERENDERING_EXPORT
vtkUnstructuredGridBunykRayCastFunction
:
public
vtkUnstructuredGridVolumeRayCastFunction
82
{
83
public
:
84
static
vtkUnstructuredGridBunykRayCastFunction
*
New
();
85
vtkTypeMacro(
vtkUnstructuredGridBunykRayCastFunction
,
vtkUnstructuredGridVolumeRayCastFunction
);
86
virtual
void
PrintSelf
(ostream& os,
vtkIndent
indent);
87
88
//BTX
90
virtual
void
Initialize
(
vtkRenderer
*ren,
vtkVolume
*vol );
91
93
virtual
void
Finalize
();
94
95
virtual
vtkUnstructuredGridVolumeRayCastIterator
*
NewIterator
();
96
97
// Used to store each triangle - made public because of the
98
// templated function
99
class
Triangle
{
100
public
:
101
vtkIdType
PointIndex[3];
102
vtkIdType
ReferredByTetra[2];
103
double
P1X,
P1Y
;
104
double
P2X,
P2Y
;
105
double
Denominator
;
106
double
A, B, C,
D
;
107
Triangle
*
Next
;
108
};
109
110
// Used to store each intersection for the pixel rays - made
111
// public because of the templated function
112
class
Intersection
{
113
public
:
114
Triangle
*
TriPtr
;
115
double
Z
;
116
Intersection
*
Next
;
117
};
118
120
122
int
InTriangle(
double
x,
double
y,
123
Triangle
*triPtr );
125
126
128
double
*
GetPoints
() {
return
this->Points;}
129
131
132
vtkGetObjectMacro( ViewToWorldMatrix,
vtkMatrix4x4
);
134
136
137
vtkGetVectorMacro( ImageOrigin,
int
, 2 );
139
141
142
vtkGetVectorMacro( ImageViewportSize,
int
, 2 );
144
146
Triangle
**
GetTetraTriangles
() {
return
this->TetraTriangles;}
147
149
Intersection
*
GetIntersectionList
(
int
x,
int
y ) {
return
this->Image[y*this->ImageSize[0] + x]; }
150
151
//ETX
152
153
protected
:
154
vtkUnstructuredGridBunykRayCastFunction
();
155
~
vtkUnstructuredGridBunykRayCastFunction
();
156
157
// These are cached during the initialize method so that they do not
158
// need to be passed into subsequent CastRay calls.
159
vtkRenderer
*
Renderer
;
160
vtkVolume
*
Volume
;
161
vtkUnstructuredGridVolumeRayCastMapper
*
Mapper
;
162
163
// Computed during the initialize method - if something is
164
// wrong (no mapper, no volume, no input, etc.) then no rendering
165
// will actually be performed.
166
int
Valid
;
167
168
// These are the transformed points
169
int
NumberOfPoints
;
170
double
*
Points
;
171
172
// This is the matrix that will take a transformed point back
173
// to world coordinates
174
vtkMatrix4x4
*
ViewToWorldMatrix
;
175
176
177
// This is the intersection list per pixel in the image
178
Intersection
**
Image
;
179
180
// This is the size of the image we are computing (which does
181
// not need to match the screen size)
182
int
ImageSize[2];
183
184
// Since we may only be computing a subregion of the "full" image,
185
// this is the origin of the region we are computing. We must
186
// subtract this origin from any pixel (x,y) locations before
187
// accessing the pixel in this->Image (which represents only the
188
// subregion)
189
int
ImageOrigin[2];
190
191
// This is the full size of the image
192
int
ImageViewportSize[2];
193
194
// These are values saved for the building of the TriangleList. Basically
195
// we need to check if the data has changed in some way.
196
vtkUnstructuredGrid
*
SavedTriangleListInput
;
197
vtkTimeStamp
SavedTriangleListMTime
;
198
199
//BTX
200
// This is a memory intensive algorithm! For each tetra in the
201
// input data we create up to 4 triangles (we don't create duplicates)
202
// This is the TriangleList. Then, for each tetra we keep track of
203
// the pointer to each of its four triangles - this is the
204
// TetraTriangles. We also keep a duplicate list of points
205
// (transformed into view space) - these are the Points.
206
Triangle
**
TetraTriangles
;
207
vtkIdType
TetraTrianglesSize
;
208
209
Triangle
*
TriangleList
;
210
211
// Compute whether a boundary triangle is front facing by
212
// looking at the fourth point in the tetra to see if it is
213
// in front (triangle is backfacing) or behind (triangle is
214
// front facing) the plane containing the triangle.
215
int
IsTriangleFrontFacing(
Triangle
*triPtr,
vtkIdType
tetraIndex );
216
217
// The image contains lists of intersections per pixel - we
218
// need to clear this during the initialization phase for each
219
// render.
220
void
ClearImage();
221
222
// This is the memory buffer used to build the intersection
223
// lists. We do our own memory management here because allocating
224
// a bunch of small elements during rendering is too slow.
225
Intersection
*IntersectionBuffer[
VTK_BUNYKRCF_MAX_ARRAYS
];
226
int
IntersectionBufferCount[
VTK_BUNYKRCF_MAX_ARRAYS
];
227
228
// This method replaces new for creating a new element - it
229
// returns one from the big block already allocated (it
230
// allocates another big block if necessary)
231
void
*NewIntersection();
232
233
// This method is used during the initialization process to
234
// check the validity of the objects - missing information
235
// such as the volume, renderer, mapper, etc. will be flagged
236
// and reported.
237
int
CheckValidity(
vtkRenderer
*ren,
238
vtkVolume
*vol);
239
240
// This method is used during the initialization process to
241
// transform the points to view coordinates
242
void
TransformPoints();
243
244
// This method is used during the initialization process to
245
// create the list of triangles if the data has changed
246
void
UpdateTriangleList();
247
248
// This method is used during the initialization process to
249
// update the view dependent information in the triangle list
250
void
ComputeViewDependentInfo();
251
252
// This method is used during the initialization process to
253
// compute the intersections for each pixel with the boundary
254
// triangles.
255
void
ComputePixelIntersections();
256
257
//ETX
258
259
private
:
260
vtkUnstructuredGridBunykRayCastFunction
(
const
vtkUnstructuredGridBunykRayCastFunction
&);
// Not implemented.
261
void
operator=(
const
vtkUnstructuredGridBunykRayCastFunction
&);
// Not implemented.
262
};
263
264
#endif
265
266
267
268
269
270
271
Generated on Fri Aug 2 2013 12:20:03 for VTK by
1.8.4