VTK
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
60#ifndef vtkUnstructuredGridBunykRayCastFunction_h
61#define vtkUnstructuredGridBunykRayCastFunction_h
62
63#include "vtkRenderingVolumeModule.h" // For export macro
65
66class vtkRenderer;
67class vtkVolume;
69class vtkMatrix4x4;
73class vtkIdList;
74class vtkDoubleArray;
75class vtkDataArray;
76
77// We manage the memory for the list of intersections ourself - this is the
78// storage used. We keep 10,000 elements in each array, and we can have up to
79// 1,000 arrays.
80#define VTK_BUNYKRCF_MAX_ARRAYS 10000
81#define VTK_BUNYKRCF_ARRAY_SIZE 10000
82
84{
85public:
88 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
89
93 virtual void Initialize( vtkRenderer *ren, vtkVolume *vol );
94
98 virtual void Finalize();
99
102
103 // Used to store each triangle - made public because of the
104 // templated function
105 class Triangle {
106 public:
107 vtkIdType PointIndex[3];
108 vtkIdType ReferredByTetra[2];
109 double P1X, P1Y;
110 double P2X, P2Y;
112 double A, B, C, D;
114 };
115
116 // Used to store each intersection for the pixel rays - made
117 // public because of the templated function
119 public:
121 double Z;
123 };
124
129 int InTriangle( double x, double y,
130 Triangle *triPtr );
131
132
136 double *GetPoints() {return this->Points;}
137
139
142 vtkGetObjectMacro( ViewToWorldMatrix, vtkMatrix4x4 );
144
146
149 vtkGetVectorMacro( ImageOrigin, int, 2 );
151
153
156 vtkGetVectorMacro( ImageViewportSize, int, 2 );
158
162 Triangle **GetTetraTriangles () {return this->TetraTriangles;}
163
167 Intersection *GetIntersectionList( int x, int y ) { return this->Image[y*this->ImageSize[0] + x]; }
168
169protected:
172
173 // These are cached during the initialize method so that they do not
174 // need to be passed into subsequent CastRay calls.
178
179 // Computed during the initialize method - if something is
180 // wrong (no mapper, no volume, no input, etc.) then no rendering
181 // will actually be performed.
182 int Valid;
183
184 // These are the transformed points
186 double *Points;
187
188 // This is the matrix that will take a transformed point back
189 // to world coordinates
191
192
193 // This is the intersection list per pixel in the image
195
196 // This is the size of the image we are computing (which does
197 // not need to match the screen size)
198 int ImageSize[2];
199
200 // Since we may only be computing a subregion of the "full" image,
201 // this is the origin of the region we are computing. We must
202 // subtract this origin from any pixel (x,y) locations before
203 // accessing the pixel in this->Image (which represents only the
204 // subregion)
205 int ImageOrigin[2];
206
207 // This is the full size of the image
208 int ImageViewportSize[2];
209
210 // These are values saved for the building of the TriangleList. Basically
211 // we need to check if the data has changed in some way.
214
215 // This is a memory intensive algorithm! For each tetra in the
216 // input data we create up to 4 triangles (we don't create duplicates)
217 // This is the TriangleList. Then, for each tetra we keep track of
218 // the pointer to each of its four triangles - this is the
219 // TetraTriangles. We also keep a duplicate list of points
220 // (transformed into view space) - these are the Points.
223
225
226 // Compute whether a boundary triangle is front facing by
227 // looking at the fourth point in the tetra to see if it is
228 // in front (triangle is backfacing) or behind (triangle is
229 // front facing) the plane containing the triangle.
230 int IsTriangleFrontFacing( Triangle *triPtr, vtkIdType tetraIndex );
231
232 // The image contains lists of intersections per pixel - we
233 // need to clear this during the initialization phase for each
234 // render.
236
237 // This is the memory buffer used to build the intersection
238 // lists. We do our own memory management here because allocating
239 // a bunch of small elements during rendering is too slow.
241 int IntersectionBufferCount[VTK_BUNYKRCF_MAX_ARRAYS];
242
243 // This method replaces new for creating a new element - it
244 // returns one from the big block already allocated (it
245 // allocates another big block if necessary)
247
248 // This method is used during the initialization process to
249 // check the validity of the objects - missing information
250 // such as the volume, renderer, mapper, etc. will be flagged
251 // and reported.
253 vtkVolume *vol);
254
255 // This method is used during the initialization process to
256 // transform the points to view coordinates
258
259 // This method is used during the initialization process to
260 // create the list of triangles if the data has changed
262
263 // This method is used during the initialization process to
264 // update the view dependent information in the triangle list
266
267 // This method is used during the initialization process to
268 // compute the intersections for each pixel with the boundary
269 // triangles.
271
272private:
274 void operator=(const vtkUnstructuredGridBunykRayCastFunction&) VTK_DELETE_FUNCTION;
275};
276
277#endif
278
279
280
281
282
283
284
Defines a transfer function for mapping a property to an RGB color value.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
dynamic, self-adjusting array of double
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
Defines a 1D piecewise function.
abstract specification for renderers
Definition: vtkRenderer.h:64
record modification and/or execution time
Definition: vtkTimeStamp.h:36
dataset represents arbitrary combinations of all possible cell types.
int CheckValidity(vtkRenderer *ren, vtkVolume *vol)
static vtkUnstructuredGridBunykRayCastFunction * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Triangle ** GetTetraTriangles()
Access to an internal structure for the templated method.
int IsTriangleFrontFacing(Triangle *triPtr, vtkIdType tetraIndex)
int InTriangle(double x, double y, Triangle *triPtr)
Is the point x, y, in the given triangle? Public for access from the templated function.
virtual void Finalize()
Called by the ray cast mapper at the end of rendering.
virtual void Initialize(vtkRenderer *ren, vtkVolume *vol)
Called by the ray cast mapper at the start of rendering.
double * GetPoints()
Access to an internal structure for the templated method.
Intersection * GetIntersectionList(int x, int y)
Access to an internal structure for the templated method.
virtual VTK_NEWINSTANCE vtkUnstructuredGridVolumeRayCastIterator * NewIterator()
Returns a new object that will iterate over all the intersections of a ray with the cells of the inpu...
vtkUnstructuredGridVolumeRayCastIterator is a superclass for iterating over the intersections of a vi...
A software mapper for unstructured volumes.
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:51
int vtkIdType
Definition: vtkType.h:287
#define VTK_NEWINSTANCE