VTK  9.2.6
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 "vtkProp3D.h"
41 #include "vtkRenderingCoreModule.h" // For export macro
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]) { this->vtkProp3D::GetBounds(bounds); }
98  double GetMinXBound();
99  double GetMaxXBound();
100  double GetMinYBound();
101  double GetMaxYBound();
102  double GetMinZBound();
103  double GetMaxZBound();
105 
109  vtkMTimeType GetMTime() override;
110 
117  vtkMTimeType GetRedrawMTime() override;
118 
122  void ShallowCopy(vtkProp* prop) override;
123 
132  int RenderVolumetricGeometry(vtkViewport* viewport) override;
133 
140  void ReleaseGraphicsResources(vtkWindow*) override;
141 
146  float* GetCorrectedScalarOpacityArray(int);
148 
153  float* GetScalarOpacityArray(int);
154  float* GetScalarOpacityArray() { return this->GetScalarOpacityArray(0); }
155 
160  float* GetGradientOpacityArray(int);
161  float* GetGradientOpacityArray() { return this->GetGradientOpacityArray(0); }
162 
167  float* GetGrayArray(int);
168  float* GetGrayArray() { return this->GetGrayArray(0); }
169 
174  float* GetRGBArray(int);
175  float* GetRGBArray() { return this->GetRGBArray(0); }
176 
181  float GetGradientOpacityConstant(int);
183 
188  float GetArraySize() { return static_cast<float>(this->ArraySize); }
189 
194  void UpdateTransferFunctions(vtkRenderer* ren);
195 
200  void UpdateScalarOpacityforSampleSize(vtkRenderer* ren, float sample_distance);
201 
209  bool GetSupportsSelection() override { return true; }
210 
211 protected:
212  vtkVolume();
213  ~vtkVolume() override;
214 
217 
218  // The rgb transfer function array - for unsigned char data this
219  // is 256 elements, for short or unsigned short it is 65536 elements
220  // This is a sample at each scalar value of the rgb transfer
221  // function. A time stamp is kept to know when it needs rebuilding
222  float* RGBArray[VTK_MAX_VRCOMP];
223  vtkTimeStamp RGBArrayMTime[VTK_MAX_VRCOMP];
224 
225  // The gray transfer function array - for unsigned char data this
226  // is 256 elements, for short or unsigned short it is 65536 elements
227  // This is a sample at each scalar value of the gray transfer
228  // function. A time stamp is kept to know when it needs rebuilding
229  float* GrayArray[VTK_MAX_VRCOMP];
230  vtkTimeStamp GrayArrayMTime[VTK_MAX_VRCOMP];
231 
232  // The scalar opacity transfer function array - for unsigned char data this
233  // is 256 elements, for short or unsigned short it is 65536 elements
234  // This is a sample at each scalar value of the opacity transfer
235  // function. A time stamp is kept to know when it needs rebuilding
236  float* ScalarOpacityArray[VTK_MAX_VRCOMP];
237  vtkTimeStamp ScalarOpacityArrayMTime[VTK_MAX_VRCOMP];
238 
239  // The corrected scalar opacity transfer function array - this is identical
240  // to the opacity transfer function array when the step size is 1.
241  // In other cases, it is corrected to reflect the new material thickness
242  // modelled by a step size different than 1.
243  float* CorrectedScalarOpacityArray[VTK_MAX_VRCOMP];
244  vtkTimeStamp CorrectedScalarOpacityArrayMTime[VTK_MAX_VRCOMP];
245 
246  // CorrectedStepSize is the step size currently modelled by
247  // CorrectedArray. It is used to determine when the
248  // CorrectedArray needs to be updated to match SampleDistance
249  // in the volume mapper.
251 
252  // Number of elements in the rgb, gray, and opacity transfer function arrays
254 
255  // The magnitude of gradient opacity transfer function array
256  float GradientOpacityArray[VTK_MAX_VRCOMP][256];
257  float GradientOpacityConstant[VTK_MAX_VRCOMP];
258  vtkTimeStamp GradientOpacityArrayMTime[VTK_MAX_VRCOMP];
259 
260  // Function to compute screen coverage of this volume
261  double ComputeScreenCoverage(vtkViewport* vp);
262 
263 private:
264  vtkVolume(const vtkVolume&) = delete;
265  void operator=(const vtkVolume&) = delete;
266 };
267 
268 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
float GetArraySize()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkVolume.h:188
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:50
float CorrectedStepSize
Definition: vtkVolume.h:250
void GetBounds(T a, double bds[6])
double * GetBounds() override=0
Return a reference to the Prop3D's composite transform.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
abstract specification for Viewports
Definition: vtkViewport.h:55
int ArraySize
Definition: vtkVolume.h:253
vtkVolumeProperty * Property
Definition: vtkVolume.h:216
record modification and/or execution time
Definition: vtkTimeStamp.h:35
Abstract class for a volume mapper.
abstract specification for renderers
Definition: vtkRenderer.h:72
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:49
#define VTK_MAX_VRCOMP
float * GetGradientOpacityArray()
Definition: vtkVolume.h:161
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:309
window superclass for vtkRenderWindow
Definition: vtkWindow.h:38
virtual vtkMTimeType GetRedrawMTime()
Return the mtime of anything that would cause the rendered image to appear differently.
Definition: vtkProp.h:117
virtual int RenderVolumetricGeometry(vtkViewport *)
Definition: vtkProp.h:226
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:175
bool GetSupportsSelection() override
Used by vtkHardwareSelector to determine if the prop supports hardware selection. ...
Definition: vtkVolume.h:209
virtual void GetVolumes(vtkPropCollection *)
Definition: vtkProp.h:69
an ordered list of volumes
float GetGradientOpacityConstant()
Definition: vtkVolume.h:182
#define VTK_SIZEHINT(...)
float * GetGrayArray()
Definition: vtkVolume.h:168
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:154
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkAbstractVolumeMapper * Mapper
Definition: vtkVolume.h:215
vtkMTimeType GetMTime() override
Get the vtkProp3D's mtime.
float * GetCorrectedScalarOpacityArray()
Definition: vtkVolume.h:147