VTK  9.3.20240425
vtkUnstructuredGridBunykRayCastFunction.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
48#ifndef vtkUnstructuredGridBunykRayCastFunction_h
49#define vtkUnstructuredGridBunykRayCastFunction_h
50
51#include "vtkRenderingVolumeModule.h" // For export macro
53
54VTK_ABI_NAMESPACE_BEGIN
55class vtkRenderer;
56class vtkVolume;
58class vtkMatrix4x4;
62class vtkIdList;
63class vtkDoubleArray;
64class vtkDataArray;
65
66// We manage the memory for the list of intersections ourself - this is the
67// storage used. We keep 10,000 elements in each array, and we can have up to
68// 1,000 arrays.
69#define VTK_BUNYKRCF_MAX_ARRAYS 10000
70#define VTK_BUNYKRCF_ARRAY_SIZE 10000
71
72class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridBunykRayCastFunction
74{
75public:
78 void PrintSelf(ostream& os, vtkIndent indent) override;
79
83 void Initialize(vtkRenderer* ren, vtkVolume* vol) override;
84
88 void Finalize() override;
89
92
93 // Used to store each triangle - made public because of the
94 // templated function
96 {
97 public:
98 vtkIdType PointIndex[3];
99 vtkIdType ReferredByTetra[2];
100 double P1X, P1Y;
101 double P2X, P2Y;
103 double A, B, C, D;
105 };
106
107 // Used to store each intersection for the pixel rays - made
108 // public because of the templated function
110 {
111 public:
113 double Z;
115 };
116
121 int InTriangle(double x, double y, Triangle* triPtr);
122
126 double* GetPoints() { return this->Points; }
127
129
132 vtkGetObjectMacro(ViewToWorldMatrix, vtkMatrix4x4);
134
136
139 vtkGetVectorMacro(ImageOrigin, int, 2);
141
143
146 vtkGetVectorMacro(ImageViewportSize, int, 2);
148
152 Triangle** GetTetraTriangles() { return this->TetraTriangles; }
153
158 {
159 return this->Image[y * this->ImageSize[0] + x];
160 }
161
162protected:
165
166 // These are cached during the initialize method so that they do not
167 // need to be passed into subsequent CastRay calls.
171
172 // Computed during the initialize method - if something is
173 // wrong (no mapper, no volume, no input, etc.) then no rendering
174 // will actually be performed.
175 int Valid;
176
177 // These are the transformed points
179 double* Points;
180
181 // This is the matrix that will take a transformed point back
182 // to world coordinates
184
185 // This is the intersection list per pixel in the image
187
188 // This is the size of the image we are computing (which does
189 // not need to match the screen size)
190 int ImageSize[2];
191
192 // Since we may only be computing a subregion of the "full" image,
193 // this is the origin of the region we are computing. We must
194 // subtract this origin from any pixel (x,y) locations before
195 // accessing the pixel in this->Image (which represents only the
196 // subregion)
197 int ImageOrigin[2];
198
199 // This is the full size of the image
200 int ImageViewportSize[2];
201
202 // These are values saved for the building of the TriangleList. Basically
203 // we need to check if the data has changed in some way.
206
207 // This is a memory intensive algorithm! For each tetra in the
208 // input data we create up to 4 triangles (we don't create duplicates)
209 // This is the TriangleList. Then, for each tetra we keep track of
210 // the pointer to each of its four triangles - this is the
211 // TetraTriangles. We also keep a duplicate list of points
212 // (transformed into view space) - these are the Points.
215
217
218 // Compute whether a boundary triangle is front facing by
219 // looking at the fourth point in the tetra to see if it is
220 // in front (triangle is backfacing) or behind (triangle is
221 // front facing) the plane containing the triangle.
222 int IsTriangleFrontFacing(Triangle* triPtr, vtkIdType tetraIndex);
223
224 // The image contains lists of intersections per pixel - we
225 // need to clear this during the initialization phase for each
226 // render.
228
229 // This is the memory buffer used to build the intersection
230 // lists. We do our own memory management here because allocating
231 // a bunch of small elements during rendering is too slow.
233 int IntersectionBufferCount[VTK_BUNYKRCF_MAX_ARRAYS];
234
235 // This method replaces new for creating a new element - it
236 // returns one from the big block already allocated (it
237 // allocates another big block if necessary)
239
240 // This method is used during the initialization process to
241 // check the validity of the objects - missing information
242 // such as the volume, renderer, mapper, etc. will be flagged
243 // and reported.
245
246 // This method is used during the initialization process to
247 // transform the points to view coordinates
249
250 // This method is used during the initialization process to
251 // create the list of triangles if the data has changed
253
254 // This method is used during the initialization process to
255 // update the view dependent information in the triangle list
257
258 // This method is used during the initialization process to
259 // compute the intersections for each pixel with the boundary
260 // triangles.
262
263private:
265 void operator=(const vtkUnstructuredGridBunykRayCastFunction&) = delete;
266};
267
268VTK_ABI_NAMESPACE_END
269#endif
Defines a transfer function for mapping a property to an RGB color value.
abstract superclass for arrays of numeric data
dynamic, self-adjusting array of double
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
Defines a 1D piecewise function.
abstract specification for renderers
record modification and/or execution time
dataset represents arbitrary combinations of all possible cell types.
int CheckValidity(vtkRenderer *ren, vtkVolume *vol)
static vtkUnstructuredGridBunykRayCastFunction * New()
vtkUnstructuredGridVolumeRayCastIterator * NewIterator() override
Returns a new object that will iterate over all the intersections of a ray with the cells of the inpu...
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.
void Finalize() override
Called by the ray cast mapper at the end of rendering.
int IsTriangleFrontFacing(Triangle *triPtr, vtkIdType tetraIndex)
void Initialize(vtkRenderer *ren, vtkVolume *vol) override
Called by the ray cast mapper at the start of rendering.
int InTriangle(double x, double y, Triangle *triPtr)
Is the point x, y, in the given triangle? Public for access from the templated function.
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.
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:120
int vtkIdType
Definition vtkType.h:315
#define VTK_NEWINSTANCE