VTK  9.3.1
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 
130  int GetMaxPixelListSize();
131 
137  void SetMaxPixelListSize(int size);
138 
140 
144  virtual void SetRayIntegrator(vtkUnstructuredGridVolumeRayIntegrator* ri);
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 
172  int ReorderTriangle(vtkIdType v[3], vtkIdType w[3]);
173 
179  void ProjectAndSortVertices(vtkRenderer* ren, vtkVolume* vol);
180 
184  void CreateAndCleanPixelList();
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 
238  float RetrieveRenderTime(vtkRenderer* ren, vtkVolume* vol);
239 
243  double GetZBufferValue(int x, int y);
244 
245  double GetMinimumBoundsDepth(vtkRenderer* ren, vtkVolume* vol);
246 
251  void AllocateUseSet(vtkIdType size);
252 
257  void AllocateVertices(vtkIdType size);
258 
262  void SavePixelListFrame();
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
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSpan * Span
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListEntryMemory * MemoryManager
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSimpleScreenEdge * SimpleEdge
record modification and/or execution time
Definition: vtkTimeStamp.h:24
abstract specification for renderers
Definition: vtkRenderer.h:61
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
void Render(vtkRenderer *ren, vtkVolume *vol) override=0
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
int vtkIdType
Definition: vtkType.h:315
provides thread-safe access to cells
vtkUnstructuredGridVolumeRayIntegrator * RealRayIntegrator
helper class that draws the image to the screen
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertices * Vertices
dynamic, self-adjusting array of double
a list of ids arranged in priority order
a superclass for volume ray integration functions
int vtkTypeBool
Definition: vtkABI.h:64
abstract class to specify cell behavior
Definition: vtkCell.h:49
a simple class to control print indentation
Definition: vtkIndent.h:28
Abstract class for an unstructured grid volume mapper.
list of point or cell ids
Definition: vtkIdList.h:22
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
represents the common properties for rendering a volume.
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListFrame * PixelListFrame
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkUseSet * UseSet
create a window for renderers to draw into
static vtkAlgorithm * New()
Unstructured grid volume mapper based the ZSweep Algorithm.
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkDoubleScreenEdge * DoubleEdge
vtkUnstructuredGridVolumeRayIntegrator * RayIntegrator