VTK  9.0.1
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 class vtkRenderer;
42 class vtkVolume;
44 class vtkCell;
45 class vtkGenericCell;
46 class vtkIdList;
47 class vtkPriorityQueue;
48 class vtkTransform;
49 class vtkMatrix4x4;
50 class vtkVolumeProperty;
51 class vtkDoubleArray;
53 class vtkRenderWindow;
54 
55 // Internal classes
57 {
58 class vtkScreenEdge;
59 class vtkSpan;
60 class vtkPixelListFrame;
61 class vtkUseSet;
62 class vtkVertices;
63 class vtkSimpleScreenEdge;
64 class vtkDoubleScreenEdge;
65 class vtkVertexEntry;
66 class vtkPixelListEntryMemory;
67 };
68 
69 class VTKRENDERINGVOLUME_EXPORT vtkUnstructuredGridVolumeZSweepMapper
71 {
72 public:
74  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
80 
82 
87  vtkSetClampMacro(ImageSampleDistance, float, 0.1f, 100.0f);
88  vtkGetMacro(ImageSampleDistance, float);
90 
92 
96  vtkSetClampMacro(MinimumImageSampleDistance, float, 0.1f, 100.0f);
97  vtkGetMacro(MinimumImageSampleDistance, float);
99 
101 
105  vtkSetClampMacro(MaximumImageSampleDistance, float, 0.1f, 100.0f);
106  vtkGetMacro(MaximumImageSampleDistance, float);
108 
110 
116  vtkSetClampMacro(AutoAdjustSampleDistances, vtkTypeBool, 0, 1);
117  vtkGetMacro(AutoAdjustSampleDistances, vtkTypeBool);
118  vtkBooleanMacro(AutoAdjustSampleDistances, vtkTypeBool);
120 
122 
126  vtkSetClampMacro(IntermixIntersectingGeometry, vtkTypeBool, 0, 1);
127  vtkGetMacro(IntermixIntersectingGeometry, vtkTypeBool);
128  vtkBooleanMacro(IntermixIntersectingGeometry, vtkTypeBool);
130 
137  int GetMaxPixelListSize();
138 
144  void SetMaxPixelListSize(int size);
145 
147 
151  virtual void SetRayIntegrator(vtkUnstructuredGridVolumeRayIntegrator* ri);
152  vtkGetObjectMacro(RayIntegrator, vtkUnstructuredGridVolumeRayIntegrator);
154 
160  void Render(vtkRenderer* ren, vtkVolume* vol) override;
161 
162  vtkGetVectorMacro(ImageInUseSize, int, 2);
163  vtkGetVectorMacro(ImageOrigin, int, 2);
164  vtkGetVectorMacro(ImageViewportSize, int, 2);
165 
166 protected:
169 
173  void BuildUseSets();
174 
179  int ReorderTriangle(vtkIdType v[3], vtkIdType w[3]);
180 
186  void ProjectAndSortVertices(vtkRenderer* ren, vtkVolume* vol);
187 
191  void CreateAndCleanPixelList();
192 
197  void MainLoop(vtkRenderWindow* renWin);
198 
203  void CompositeFunction(double zTarget);
204 
208  unsigned char ColorComponentRealToByte(float color);
209 
213  void RasterizeFace(vtkIdType faceIds[3], int externalSide);
214 
221  void RasterizeTriangle(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve0,
222  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve1,
223  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* ve2, bool exitFace);
224 
231  void RasterizeSpan(int y, vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge* left,
232  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkScreenEdge* right, bool exitFace);
233 
240  void RasterizeLine(vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* v0,
241  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertexEntry* v1, bool exitFace);
242 
243  void StoreRenderTime(vtkRenderer* ren, vtkVolume* vol, float t);
244 
245  float RetrieveRenderTime(vtkRenderer* ren, vtkVolume* vol);
246 
250  double GetZBufferValue(int x, int y);
251 
252  double GetMinimumBoundsDepth(vtkRenderer* ren, vtkVolume* vol);
253 
258  void AllocateUseSet(vtkIdType size);
259 
264  void AllocateVertices(vtkIdType size);
265 
269  void SavePixelListFrame();
270 
272 
277 
279 
280  // This is how big the image would be if it covered the entire viewport
281  int ImageViewportSize[2];
282 
283  // This is how big the allocated memory for image is. This may be bigger
284  // or smaller than ImageFullSize - it will be bigger if necessary to
285  // ensure a power of 2, it will be smaller if the volume only covers a
286  // small region of the viewport
287  int ImageMemorySize[2];
288 
289  // This is the size of subregion in ImageSize image that we are using for
290  // the current image. Since ImageSize is a power of 2, there is likely
291  // wasted space in it. This number will be used for things such as clearing
292  // the image if necessary.
293  int ImageInUseSize[2];
294 
295  // This is the location in ImageFullSize image where our ImageSize image
296  // is located.
297  int ImageOrigin[2];
298 
299  // This is the allocated image
300  unsigned char* Image;
301 
302  // This is the accumulating double RGBA image
304 
310 
312 
313  float* ZBuffer;
314  int ZBufferSize[2];
315  int ZBufferOrigin[2];
316 
319 
320  // if use CellScalars, we need to keep track of the
321  // values on each side of the face and figure out
322  // if the face is used by two cells (twosided) or one cell.
323  double FaceScalars[2];
324  int FaceSide;
325 
326  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSpan* Span;
327  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListFrame* PixelListFrame;
328 
329  // Used by BuildUseSets().
331 
332  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkUseSet* UseSet;
333 
335  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertices* Vertices;
336 
339 
340  // Used by the main loop
342  int XBounds[2];
343  int YBounds[2];
344 
345  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSimpleScreenEdge* SimpleEdge;
346  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkDoubleScreenEdge* DoubleEdge;
347 
350 
352 
353  // Used during compositing
357 
358  // Benchmark
360 
361  vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListEntryMemory* MemoryManager;
362 
363 private:
365  void operator=(const vtkUnstructuredGridVolumeZSweepMapper&) = delete;
366 };
367 
368 #endif
vtkUnstructuredGridVolumeZSweepMapper::PixelListFrame
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListFrame * PixelListFrame
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:327
vtkUnstructuredGridVolumeRayIntegrator
a superclass for volume ray integration functions
Definition: vtkUnstructuredGridVolumeRayIntegrator.h:41
vtkUnstructuredGridVolumeZSweepMapper::RealRayIntegrator
vtkUnstructuredGridVolumeRayIntegrator * RealRayIntegrator
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:349
vtkUnstructuredGridVolumeZSweepMapper::MaxRecordedPixelListSize
vtkIdType MaxRecordedPixelListSize
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:359
vtkVolume
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:44
vtkUnstructuredGridVolumeZSweepMapper::DoubleEdge
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkDoubleScreenEdge * DoubleEdge
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:346
vtkRayCastImageDisplayHelper
helper class that draws the image to the screen
Definition: vtkRayCastImageDisplayHelper.h:39
vtkUnstructuredGridVolumeZSweepMapper::ImageSampleDistance
float ImageSampleDistance
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:273
vtkUnstructuredGridVolumeZSweepMapper::RenderVolumeTable
vtkVolume ** RenderVolumeTable
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:306
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkUnstructuredGridVolumeZSweepMapper::Vertices
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkVertices * Vertices
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:335
vtkUnstructuredGridVolumeZSweepMapper::Image
unsigned char * Image
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:300
vtkUnstructuredGridVolumeZSweepMapper::MaximumImageSampleDistance
float MaximumImageSampleDistance
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:275
vtkUnstructuredGridVolumeZSweepMapper::SavedTriangleListMTime
vtkTimeStamp SavedTriangleListMTime
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:351
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkUnstructuredGridVolumeMapper::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUnstructuredGridVolumeZSweepMapper::FarIntersections
vtkDoubleArray * FarIntersections
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:356
vtkPriorityQueue
a list of ids arranged in priority order
Definition: vtkPriorityQueue.h:46
vtkUnstructuredGridVolumeZSweepMapper::EventList
vtkPriorityQueue * EventList
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:334
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkUnstructuredGridVolumeZSweepMapper::IntersectionLengths
vtkDoubleArray * IntersectionLengths
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:354
vtkUnstructuredGridVolumeZSweepMapper::RenderTimeTable
float * RenderTimeTable
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:305
vtkUnstructuredGridVolumeZSweepMapper::MaxPixelListSize
int MaxPixelListSize
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:271
vtkUnstructuredGridVolumeZSweepMapper::Span
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSpan * Span
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:326
vtkX3D::color
@ color
Definition: vtkX3D.h:227
vtkUnstructuredGridVolumeZSweepMapper::MemoryManager
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkPixelListEntryMemory * MemoryManager
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:361
vtkUnstructuredGridVolumeZSweepMapper
Unstructured grid volume mapper based the ZSweep Algorithm.
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:69
vtkUnstructuredGridVolumeZSweepMapper::RenderTableEntries
int RenderTableEntries
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:309
vtkUnstructuredGridVolumeZSweepMapperNamespace
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:56
vtkUnstructuredGridVolumeZSweepMapper::PerspectiveMatrix
vtkMatrix4x4 * PerspectiveMatrix
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:338
vtkUnstructuredGridVolumeZSweepMapper::RayIntegrator
vtkUnstructuredGridVolumeRayIntegrator * RayIntegrator
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:348
vtkCell
abstract class to specify cell behavior
Definition: vtkCell.h:56
vtkUnstructuredGridVolumeZSweepMapper::IntermixIntersectingGeometry
vtkTypeBool IntermixIntersectingGeometry
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:311
vtkUnstructuredGridVolumeZSweepMapper::ImageDisplayHelper
vtkRayCastImageDisplayHelper * ImageDisplayHelper
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:278
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkUnstructuredGridVolumeZSweepMapper::Scalars
vtkDataArray * Scalars
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:317
vtkUnstructuredGridVolumeZSweepMapper::UseSet
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkUseSet * UseSet
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:332
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkX3D::size
@ size
Definition: vtkX3D.h:259
vtkUnstructuredGridVolumeZSweepMapper::RenderTableSize
int RenderTableSize
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:308
vtkUnstructuredGridVolumeZSweepMapper::Cell
vtkGenericCell * Cell
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:330
vtkUnstructuredGridVolumeZSweepMapper::FaceSide
int FaceSide
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:324
vtkUnstructuredGridVolumeZSweepMapper::CellScalars
int CellScalars
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:318
vtkUnstructuredGridVolumeZSweepMapper::MaxPixelListSizeReached
int MaxPixelListSizeReached
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:341
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkUnstructuredGridVolumeMapper
Abstract class for an unstructured grid volume mapper.
Definition: vtkUnstructuredGridVolumeMapper.h:39
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkUnstructuredGridVolumeZSweepMapper::SimpleEdge
vtkUnstructuredGridVolumeZSweepMapperNamespace::vtkSimpleScreenEdge * SimpleEdge
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:345
vtkUnstructuredGridVolumeZSweepMapper::ZBuffer
float * ZBuffer
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:313
vtkUnstructuredGridVolumeMapper::Render
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...
vtkUnstructuredGridVolumeZSweepMapper::NearIntersections
vtkDoubleArray * NearIntersections
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:355
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:36
vtkDoubleArray
dynamic, self-adjusting array of double
Definition: vtkDoubleArray.h:35
vtkUnstructuredGridVolumeZSweepMapper::RealRGBAImage
float * RealRGBAImage
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:303
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:93
vtkUnstructuredGridVolumeMapper.h
vtkUnstructuredGridVolumeZSweepMapper::PerspectiveTransform
vtkTransform * PerspectiveTransform
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:337
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkUnstructuredGridVolumeZSweepMapper::MinimumImageSampleDistance
float MinimumImageSampleDistance
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:274
vtkUnstructuredGridVolumeZSweepMapper::AutoAdjustSampleDistances
vtkTypeBool AutoAdjustSampleDistances
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:276
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:74
vtkUnstructuredGridVolumeZSweepMapper::RenderRendererTable
vtkRenderer ** RenderRendererTable
Definition: vtkUnstructuredGridVolumeZSweepMapper.h:307