VTK
vtkVolume.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkVolume.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 =========================================================================*/
37 #ifndef vtkVolume_h
38 #define vtkVolume_h
39 
40 #include "vtkRenderingCoreModule.h" // For export macro
41 #include "vtkProp3D.h"
42 
43 class vtkRenderer;
44 class vtkPropCollection;
46 class vtkWindow;
47 class vtkVolumeProperty;
49 
50 class VTKRENDERINGCORE_EXPORT vtkVolume : public vtkProp3D
51 {
52 public:
53  vtkTypeMacro(vtkVolume, vtkProp3D);
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
61  static vtkVolume *New();
62 
64 
67  void SetMapper(vtkAbstractVolumeMapper *mapper);
68  vtkGetObjectMacro(Mapper, vtkAbstractVolumeMapper);
70 
72 
75  virtual void SetProperty(vtkVolumeProperty *property);
76  virtual vtkVolumeProperty *GetProperty();
78 
84  void GetVolumes(vtkPropCollection *vc) override;
85 
89  void Update();
90 
92 
96  double *GetBounds() VTK_SIZEHINT(6) override;
97  void GetBounds(double bounds[6])
98  { this->vtkProp3D::GetBounds(bounds); }
99  double GetMinXBound();
100  double GetMaxXBound();
101  double GetMinYBound();
102  double GetMaxYBound();
103  double GetMinZBound();
104  double GetMaxZBound();
106 
110  vtkMTimeType GetMTime() override;
111 
118  vtkMTimeType GetRedrawMTime() override;
119 
123  void ShallowCopy(vtkProp *prop) override;
124 
133  int RenderVolumetricGeometry(vtkViewport *viewport) override;
134 
141  void ReleaseGraphicsResources(vtkWindow *) override;
142 
147  float *GetCorrectedScalarOpacityArray(int);
149  { return this->GetCorrectedScalarOpacityArray(0); }
150 
155  float *GetScalarOpacityArray(int);
157  { return this->GetScalarOpacityArray(0); }
158 
163  float *GetGradientOpacityArray(int);
165  { return this->GetGradientOpacityArray(0); }
166 
171  float *GetGrayArray(int);
172  float *GetGrayArray()
173  { return this->GetGrayArray(0); }
174 
179  float *GetRGBArray(int);
180  float *GetRGBArray()
181  { return this->GetRGBArray(0); }
182 
187  float GetGradientOpacityConstant(int);
189  { return this->GetGradientOpacityConstant(0); }
190 
195  float GetArraySize()
196  { return static_cast<float>(this->ArraySize); }
197 
202  void UpdateTransferFunctions(vtkRenderer *ren);
203 
208  void UpdateScalarOpacityforSampleSize(vtkRenderer *ren,
209  float sample_distance);
210 
218  bool GetSupportsSelection() override
219  { return true; }
220 
221 protected:
222  vtkVolume();
223  ~vtkVolume() override;
224 
227 
228  // The rgb transfer function array - for unsigned char data this
229  // is 256 elements, for short or unsigned short it is 65536 elements
230  // This is a sample at each scalar value of the rgb transfer
231  // function. A time stamp is kept to know when it needs rebuilding
232  float *RGBArray[VTK_MAX_VRCOMP];
233  vtkTimeStamp RGBArrayMTime[VTK_MAX_VRCOMP];
234 
235  // The gray transfer function array - for unsigned char data this
236  // is 256 elements, for short or unsigned short it is 65536 elements
237  // This is a sample at each scalar value of the gray transfer
238  // function. A time stamp is kept to know when it needs rebuilding
239  float *GrayArray[VTK_MAX_VRCOMP];
240  vtkTimeStamp GrayArrayMTime[VTK_MAX_VRCOMP];
241 
242  // The scalar opacity transfer function array - for unsigned char data this
243  // is 256 elements, for short or unsigned short it is 65536 elements
244  // This is a sample at each scalar value of the opacity transfer
245  // function. A time stamp is kept to know when it needs rebuilding
246  float *ScalarOpacityArray[VTK_MAX_VRCOMP];
247  vtkTimeStamp ScalarOpacityArrayMTime[VTK_MAX_VRCOMP];
248 
249  // The corrected scalar opacity transfer function array - this is identical
250  // to the opacity transfer function array when the step size is 1.
251  // In other cases, it is corrected to reflect the new material thickness
252  // modelled by a step size different than 1.
253  float *CorrectedScalarOpacityArray[VTK_MAX_VRCOMP];
254  vtkTimeStamp CorrectedScalarOpacityArrayMTime[VTK_MAX_VRCOMP];
255 
256  // CorrectedStepSize is the step size currently modelled by
257  // CorrectedArray. It is used to determine when the
258  // CorrectedArray needs to be updated to match SampleDistance
259  // in the volume mapper.
261 
262  // Number of elements in the rgb, gray, and opacity transfer function arrays
264 
265  // The magnitude of gradient opacity transfer function array
266  float GradientOpacityArray[VTK_MAX_VRCOMP][256];
267  float GradientOpacityConstant[VTK_MAX_VRCOMP];
268  vtkTimeStamp GradientOpacityArrayMTime[VTK_MAX_VRCOMP];
269 
270  // Function to compute screen coverage of this volume
271  double ComputeScreenCoverage(vtkViewport *vp);
272 
273 private:
274  vtkVolume(const vtkVolume&) = delete;
275  void operator=(const vtkVolume&) = delete;
276 };
277 
278 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
float GetArraySize()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkVolume.h:195
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
float CorrectedStepSize
Definition: vtkVolume.h:260
double * GetBounds() override=0
Return a reference to the Prop3D&#39;s composite transform.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
abstract specification for Viewports
Definition: vtkViewport.h:47
int ArraySize
Definition: vtkVolume.h:263
vtkVolumeProperty * Property
Definition: vtkVolume.h:226
record modification and/or execution time
Definition: vtkTimeStamp.h:35
Abstract class for a volume mapper.
abstract specification for renderers
Definition: vtkRenderer.h:63
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:46
#define VTK_MAX_VRCOMP
float * GetGradientOpacityArray()
Definition: vtkVolume.h:164
an ordered list of Props
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkProp.h:305
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
virtual vtkMTimeType GetRedrawMTime()
Return the mtime of anything that would cause the rendered image to appear differently.
Definition: vtkProp.h:113
virtual int RenderVolumetricGeometry(vtkViewport *)
Definition: vtkProp.h:228
a simple class to control print indentation
Definition: vtkIndent.h:39
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkProp3D.
float * GetRGBArray()
Definition: vtkVolume.h:180
bool GetSupportsSelection() override
Used by vtkHardwareSelector to determine if the prop supports hardware selection. ...
Definition: vtkVolume.h:218
virtual void GetVolumes(vtkPropCollection *)
Definition: vtkProp.h:65
an ordered list of volumes
float GetGradientOpacityConstant()
Definition: vtkVolume.h:188
#define VTK_SIZEHINT(...)
float * GetGrayArray()
Definition: vtkVolume.h:172
represents the common properties for rendering a volume.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
float * GetScalarOpacityArray()
Definition: vtkVolume.h:156
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkAbstractVolumeMapper * Mapper
Definition: vtkVolume.h:225
vtkMTimeType GetMTime() override
Get the vtkProp3D&#39;s mtime.
float * GetCorrectedScalarOpacityArray()
Definition: vtkVolume.h:148