VTK  9.2.20220926
vtkUnstructuredGridVolumeZSweepMapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkUnstructuredGridVolumeZSweepMapper.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 =========================================================================*/
35 #ifndef vtkUnstructuredGridVolumeZSweepMapper_h
36 #define vtkUnstructuredGridVolumeZSweepMapper_h
37 
38 #include "vtkRenderingVolumeModule.h" // For export macro
40 
41 VTK_ABI_NAMESPACE_BEGIN
42 class vtkRenderer;
43 class vtkVolume;
45 class vtkCell;
46 class vtkGenericCell;
47 class vtkIdList;
48 class vtkPriorityQueue;
49 class vtkTransform;
50 class vtkMatrix4x4;
51 class vtkVolumeProperty;
52 class vtkDoubleArray;
54 class vtkRenderWindow;
56 
57 // Internal classes
59 {
60 VTK_ABI_NAMESPACE_BEGIN
61 class vtkScreenEdge;
62 class vtkSpan;
63 class vtkPixelListFrame;
64 class vtkUseSet;
65 class vtkVertices;
66 class vtkSimpleScreenEdge;
67 class vtkDoubleScreenEdge;
68 class vtkVertexEntry;
69 class vtkPixelListEntryMemory;
71 };
72 
73 VTK_ABI_NAMESPACE_BEGIN
74 class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridVolumeZSweepMapper
76 {
77 public:
79  void PrintSelf(ostream& os, vtkIndent indent) override;
80 
85 
87 
92  vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
93  vtkGetMacro(ImageSampleDistance, float);
95 
97 
101  vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
102  vtkGetMacro(MinimumImageSampleDistance, float);
104 
106 
110  vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
111  vtkGetMacro(MaximumImageSampleDistance, float);
113 
115 
121  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
122  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
123  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
125 
127 
131  vtkSetClampMacro(IntermixIntersectingGeometry, vtkTypeBool, 0, 1);
132  vtkGetMacro(IntermixIntersectingGeometry, vtkTypeBool);
133  vtkBooleanMacro(IntermixIntersectingGeometry, vtkTypeBool);
135 
143 
150 
152 
157  vtkGetObjectMacro(RayIntegrator, vtkUnstructuredGridVolumeRayIntegrator);
159 
165  void Render(vtkRenderer* ren, vtkVolume* vol) override;
166 
167  vtkGetVectorMacro(ImageInUseSize, int, 2);
168  vtkGetVectorMacro(ImageOrigin, int, 2);
169  vtkGetVectorMacro(ImageViewportSize, int, 2);
170 
171 protected:
174 
178  void BuildUseSets();
179 
185 
192 
197 
202  void MainLoop(vtkRenderWindow* renWin);
203 
208  void CompositeFunction(double zTarget);
209 
213  unsigned char ColorComponentRealToByte(float color);
214 
218  void RasterizeFace(vtkIdType faceIds[3], int externalSide);
219 
226  void RasterizeTriangle(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve0,
227  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve1,
228  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve2, bool externalFace);
229 
236  void RasterizeSpan(int y, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge* left,
237  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge* right, bool exitFace);
238 
245  void RasterizeLine(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* v0,
246  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* v1, bool exitFace);
247 
248  void StoreRenderTime(vtkRenderer* ren, vtkVolume* vol, float t);
249 
251 
255  double GetZBufferValue(int x, int y);
256 
258 
264 
270 
275 
277 
282 
284 
285  // This is how big the image would be if it covered the entire viewport
286  int ImageViewportSize[2];
287 
288  // This is how big the allocated memory for image is. This may be bigger
289  // or smaller than ImageFullSize - it will be bigger if necessary to
290  // ensure a power of 2, it will be smaller if the volume only covers a
291  // small region of the viewport
292  int ImageMemorySize[2];
293 
294  // This is the size of subregion in ImageSize image that we are using for
295  // the current image. Since ImageSize is a power of 2, there is likely
296  // wasted space in it. This number will be used for things such as clearing
297  // the image if necessary.
298  int ImageInUseSize[2];
299 
300  // This is the location in ImageFullSize image where our ImageSize image
301  // is located.
302  int ImageOrigin[2];
303 
304  // This is the allocated image
305  unsigned char* Image;
306 
307  // This is the accumulating double RGBA image
309 
315 
317 
318  float* ZBuffer;
319  int ZBufferSize[2];
320  int ZBufferOrigin[2];
321 
324 
325  // if use CellScalars, we need to keep track of the
326  // values on each side of the face and figure out
327  // if the face is used by two cells (twosided) or one cell.
328  double FaceScalars[2];
329  int FaceSide;
330 
331  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSpan* Span;
332  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListFrame* PixelListFrame;
333 
334  // Used by BuildUseSets().
336 
337  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkUseSet* UseSet;
338 
340  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertices* Vertices;
341 
344 
345  // Used by the main loop
347  int XBounds[2];
348  int YBounds[2];
349 
350  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSimpleScreenEdge* SimpleEdge;
351  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkDoubleScreenEdge* DoubleEdge;
352 
355 
357 
358  // Used during compositing
362 
363  // Benchmark
365 
366  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListEntryMemory* MemoryManager;
367 
368 private:
370  void operator=(const vtkUnstructuredGridVolumeZSweepMapper&) = delete;
371 };
372 
374 #endif
abstract class to specify cell behavior
Definition: vtkCell.h:151
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:166
dynamic, self-adjusting array of double
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:144
a simple class to control print indentation
Definition: vtkIndent.h:120
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:152
a list of ids arranged in priority order
helper class that draws the image to the screen
create a window for renderers to draw into
abstract specification for renderers
Definition: vtkRenderer.h:183
record modification and/or execution time
Definition: vtkTimeStamp.h:56
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:171
Abstract class for an unstructured grid volume mapper.
a superclass for volume ray integration functions
Unstructured grid volume mapper based the ZSweep Algorithm.
void AllocateUseSet(vtkIdType size)
Allocate an array of usesets of size ‘size’ only if the current one is not large enough.
void RasterizeTriangle(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *ve0, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *ve1, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *ve2, bool externalFace)
Perform scan conversion of a triangle defined by its vertices.
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSimpleScreenEdge * SimpleEdge
int ReorderTriangle(vtkIdType v[3], vtkIdType w[3])
Reorder vertices ‘v’ in increasing order in ‘w’.
vtkUnstructuredGridVolumeRayIntegrator * RealRayIntegrator
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListFrame * PixelListFrame
float RetrieveRenderTime(vtkRenderer *ren, vtkVolume *vol)
virtual void SetRayIntegrator(vtkUnstructuredGridVolumeRayIntegrator *ri)
Set/Get the helper class for integrating rays.
void RasterizeLine(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *v0, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry *v1, bool exitFace)
Scan conversion of a straight line defined by endpoints v0 and v1.
void MainLoop(vtkRenderWindow *renWin)
MainLoop of the Zsweep algorithm.
unsigned char ColorComponentRealToByte(float color)
Convert and clamp a float color component into a unsigned char.
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSpan * Span
void CreateAndCleanPixelList()
Create an empty "pixel list" for each pixel of the screen.
void CompositeFunction(double zTarget)
Do delayed compositing from back to front, stopping at zTarget for each pixel inside the bounding box...
void RasterizeFace(vtkIdType faceIds[3], int externalSide)
Perform scan conversion of a triangle face.
double GetZBufferValue(int x, int y)
Return the value of the z-buffer at screen coordinates (x,y).
void RasterizeSpan(int y, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge *left, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge *right, bool exitFace)
Perform scan conversion of an horizontal span from left ro right at line y.
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListEntryMemory * MemoryManager
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkUseSet * UseSet
void AllocateVertices(vtkIdType size)
Allocate a vertex array of size ‘size’ only if the current one is not large enough.
static vtkUnstructuredGridVolumeZSweepMapper * New()
Set MaxPixelListSize to 32.
void Render(vtkRenderer *ren, vtkVolume *vol) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
double GetMinimumBoundsDepth(vtkRenderer *ren, vtkVolume *vol)
void SetMaxPixelListSize(int size)
Change the maximum size allowed for a pixel list.
void ProjectAndSortVertices(vtkRenderer *ren, vtkVolume *vol)
Project and sort the vertices by z-coordinates in view space in the "event list" (an heap).
void StoreRenderTime(vtkRenderer *ren, vtkVolume *vol, float t)
void BuildUseSets()
For each vertex, find the list of incident faces.
vtkUnstructuredGridVolumeRayIntegrator * RayIntegrator
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertices * Vertices
void SavePixelListFrame()
For debugging purpose, save the pixel list frame as a dataset.
int GetMaxPixelListSize()
Maximum size allowed for a pixel list.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkDoubleScreenEdge * DoubleEdge
represents the common properties for rendering a volume.
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:141
@ color
Definition: vtkX3D.h:233
@ size
Definition: vtkX3D.h:265
int vtkTypeBool
Definition: vtkABI.h:71
int vtkIdType
Definition: vtkType.h:326