VTK  9.3.20240328
vtkUnstructuredGridVolumeZSweepMapper.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
23 #ifndef vtkUnstructuredGridVolumeZSweepMapper_h
24 #define vtkUnstructuredGridVolumeZSweepMapper_h
25 
26 #include "vtkRenderingVolumeModule.h" // For export macro
28 
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkRenderer;
31 class vtkVolume;
33 class vtkCell;
34 class vtkGenericCell;
35 class vtkIdList;
36 class vtkPriorityQueue;
37 class vtkTransform;
38 class vtkMatrix4x4;
39 class vtkVolumeProperty;
40 class vtkDoubleArray;
42 class vtkRenderWindow;
43 VTK_ABI_NAMESPACE_END
44 
45 // Internal classes
47 {
48 VTK_ABI_NAMESPACE_BEGIN
49 class vtkScreenEdge;
50 class vtkSpan;
51 class vtkPixelListFrame;
52 class vtkUseSet;
53 class vtkVertices;
54 class vtkSimpleScreenEdge;
55 class vtkDoubleScreenEdge;
56 class vtkVertexEntry;
57 class vtkPixelListEntryMemory;
58 VTK_ABI_NAMESPACE_END
59 }
60 
61 VTK_ABI_NAMESPACE_BEGIN
62 class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridVolumeZSweepMapper
64 {
65 public:
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
73 
75 
80  vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
81  vtkGetMacro(ImageSampleDistance, float);
83 
85 
89  vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
90  vtkGetMacro(MinimumImageSampleDistance, float);
92 
94 
98  vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
99  vtkGetMacro(MaximumImageSampleDistance, float);
101 
103 
109  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
110  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
111  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
113 
115 
119  vtkSetClampMacro(IntermixIntersectingGeometry, vtkTypeBool, 0, 1);
120  vtkGetMacro(IntermixIntersectingGeometry, vtkTypeBool);
121  vtkBooleanMacro(IntermixIntersectingGeometry, vtkTypeBool);
123 
131 
138 
140 
145  vtkGetObjectMacro(RayIntegrator, vtkUnstructuredGridVolumeRayIntegrator);
147 
153  void Render(vtkRenderer* ren, vtkVolume* vol) override;
154 
155  vtkGetVectorMacro(ImageInUseSize, int, 2);
156  vtkGetVectorMacro(ImageOrigin, int, 2);
157  vtkGetVectorMacro(ImageViewportSize, int, 2);
158 
159 protected:
162 
166  void BuildUseSets();
167 
173 
180 
185 
190  void MainLoop(vtkRenderWindow* renWin);
191 
196  void CompositeFunction(double zTarget);
197 
201  unsigned char ColorComponentRealToByte(float color);
202 
206  void RasterizeFace(vtkIdType faceIds[3], int externalSide);
207 
214  void RasterizeTriangle(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve0,
215  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve1,
216  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve2, bool externalFace);
217 
224  void RasterizeSpan(int y, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge* left,
225  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge* right, bool exitFace);
226 
233  void RasterizeLine(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* v0,
234  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* v1, bool exitFace);
235 
236  void StoreRenderTime(vtkRenderer* ren, vtkVolume* vol, float t);
237 
239 
243  double GetZBufferValue(int x, int y);
244 
246 
252 
258 
263 
265 
270 
272 
273  // This is how big the image would be if it covered the entire viewport
274  int ImageViewportSize[2];
275 
276  // This is how big the allocated memory for image is. This may be bigger
277  // or smaller than ImageFullSize - it will be bigger if necessary to
278  // ensure a power of 2, it will be smaller if the volume only covers a
279  // small region of the viewport
280  int ImageMemorySize[2];
281 
282  // This is the size of subregion in ImageSize image that we are using for
283  // the current image. Since ImageSize is a power of 2, there is likely
284  // wasted space in it. This number will be used for things such as clearing
285  // the image if necessary.
286  int ImageInUseSize[2];
287 
288  // This is the location in ImageFullSize image where our ImageSize image
289  // is located.
290  int ImageOrigin[2];
291 
292  // This is the allocated image
293  unsigned char* Image;
294 
295  // This is the accumulating double RGBA image
297 
303 
305 
306  float* ZBuffer;
307  int ZBufferSize[2];
308  int ZBufferOrigin[2];
309 
312 
313  // if use CellScalars, we need to keep track of the
314  // values on each side of the face and figure out
315  // if the face is used by two cells (twosided) or one cell.
316  double FaceScalars[2];
317  int FaceSide;
318 
319  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSpan* Span;
320  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListFrame* PixelListFrame;
321 
322  // Used by BuildUseSets().
324 
325  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkUseSet* UseSet;
326 
328  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertices* Vertices;
329 
332 
333  // Used by the main loop
335  int XBounds[2];
336  int YBounds[2];
337 
338  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSimpleScreenEdge* SimpleEdge;
339  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkDoubleScreenEdge* DoubleEdge;
340 
343 
345 
346  // Used during compositing
350 
351  // Benchmark
353 
354  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListEntryMemory* MemoryManager;
355 
356 private:
358  void operator=(const vtkUnstructuredGridVolumeZSweepMapper&) = delete;
359 };
360 
361 VTK_ABI_NAMESPACE_END
362 #endif
abstract class to specify cell behavior
Definition: vtkCell.h:130
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
dynamic, self-adjusting array of double
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:132
a simple class to control print indentation
Definition: vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:140
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:171
record modification and/or execution time
Definition: vtkTimeStamp.h:44
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:159
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:119
@ color
Definition: vtkX3D.h:221
@ size
Definition: vtkX3D.h:253
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315