VTK  9.3.1
vtkVolume.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
25 #ifndef vtkVolume_h
26 #define vtkVolume_h
27 
28 #include "vtkProp3D.h"
29 #include "vtkRenderingCoreModule.h" // For export macro
30 
31 VTK_ABI_NAMESPACE_BEGIN
32 class vtkRenderer;
33 class vtkPropCollection;
35 class vtkWindow;
36 class vtkVolumeProperty;
38 
39 class VTKRENDERINGCORE_EXPORT vtkVolume : public vtkProp3D
40 {
41 public:
42  vtkTypeMacro(vtkVolume, vtkProp3D);
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
50  static vtkVolume* New();
51 
53 
56  void SetMapper(vtkAbstractVolumeMapper* mapper);
57  vtkGetObjectMacro(Mapper, vtkAbstractVolumeMapper);
59 
61 
64  virtual void SetProperty(vtkVolumeProperty* property);
65  virtual vtkVolumeProperty* GetProperty();
67 
73  void GetVolumes(vtkPropCollection* vc) override;
74 
78  void Update();
79 
81 
85  double* GetBounds() VTK_SIZEHINT(6) override;
86  void GetBounds(double bounds[6]) { this->vtkProp3D::GetBounds(bounds); }
87  double GetMinXBound();
88  double GetMaxXBound();
89  double GetMinYBound();
90  double GetMaxYBound();
91  double GetMinZBound();
92  double GetMaxZBound();
94 
98  vtkMTimeType GetMTime() override;
99 
106  vtkMTimeType GetRedrawMTime() override;
107 
111  void ShallowCopy(vtkProp* prop) override;
112 
121  int RenderVolumetricGeometry(vtkViewport* viewport) override;
122 
129  void ReleaseGraphicsResources(vtkWindow*) override;
130 
135  float* GetCorrectedScalarOpacityArray(int);
137 
142  float* GetScalarOpacityArray(int);
143  float* GetScalarOpacityArray() { return this->GetScalarOpacityArray(0); }
144 
149  float* GetGradientOpacityArray(int);
150  float* GetGradientOpacityArray() { return this->GetGradientOpacityArray(0); }
151 
156  float* GetGrayArray(int);
157  float* GetGrayArray() { return this->GetGrayArray(0); }
158 
163  float* GetRGBArray(int);
164  float* GetRGBArray() { return this->GetRGBArray(0); }
165 
170  float GetGradientOpacityConstant(int);
172 
177  float GetArraySize() { return static_cast<float>(this->ArraySize); }
178 
183  void UpdateTransferFunctions(vtkRenderer* ren);
184 
189  void UpdateScalarOpacityforSampleSize(vtkRenderer* ren, float sample_distance);
190 
198  bool GetSupportsSelection() override { return true; }
199 
200 protected:
201  vtkVolume();
202  ~vtkVolume() override;
203 
206 
207  // The rgb transfer function array - for unsigned char data this
208  // is 256 elements, for short or unsigned short it is 65536 elements
209  // This is a sample at each scalar value of the rgb transfer
210  // function. A time stamp is kept to know when it needs rebuilding
211  float* RGBArray[VTK_MAX_VRCOMP];
212  vtkTimeStamp RGBArrayMTime[VTK_MAX_VRCOMP];
213 
214  // The gray transfer function array - for unsigned char data this
215  // is 256 elements, for short or unsigned short it is 65536 elements
216  // This is a sample at each scalar value of the gray transfer
217  // function. A time stamp is kept to know when it needs rebuilding
218  float* GrayArray[VTK_MAX_VRCOMP];
219  vtkTimeStamp GrayArrayMTime[VTK_MAX_VRCOMP];
220 
221  // The scalar opacity transfer function array - for unsigned char data this
222  // is 256 elements, for short or unsigned short it is 65536 elements
223  // This is a sample at each scalar value of the opacity transfer
224  // function. A time stamp is kept to know when it needs rebuilding
225  float* ScalarOpacityArray[VTK_MAX_VRCOMP];
226  vtkTimeStamp ScalarOpacityArrayMTime[VTK_MAX_VRCOMP];
227 
228  // The corrected scalar opacity transfer function array - this is identical
229  // to the opacity transfer function array when the step size is 1.
230  // In other cases, it is corrected to reflect the new material thickness
231  // modelled by a step size different than 1.
232  float* CorrectedScalarOpacityArray[VTK_MAX_VRCOMP];
233  vtkTimeStamp CorrectedScalarOpacityArrayMTime[VTK_MAX_VRCOMP];
234 
235  // CorrectedStepSize is the step size currently modelled by
236  // CorrectedArray. It is used to determine when the
237  // CorrectedArray needs to be updated to match SampleDistance
238  // in the volume mapper.
240 
241  // Number of elements in the rgb, gray, and opacity transfer function arrays
243 
244  // The magnitude of gradient opacity transfer function array
245  float GradientOpacityArray[VTK_MAX_VRCOMP][256];
246  float GradientOpacityConstant[VTK_MAX_VRCOMP];
247  vtkTimeStamp GradientOpacityArrayMTime[VTK_MAX_VRCOMP];
248 
249  // Function to compute screen coverage of this volume
250  double ComputeScreenCoverage(vtkViewport* vp);
251 
252 private:
253  vtkVolume(const vtkVolume&) = delete;
254  void operator=(const vtkVolume&) = delete;
255 };
256 
257 VTK_ABI_NAMESPACE_END
258 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
float GetArraySize()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THIS METHOD OUTSIDE OF THE RENDERI...
Definition: vtkVolume.h:177
represents a volume (data & properties) in a rendered scene
Definition: vtkVolume.h:39
float CorrectedStepSize
Definition: vtkVolume.h:239
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:270
abstract specification for Viewports
Definition: vtkViewport.h:44
int ArraySize
Definition: vtkVolume.h:242
vtkVolumeProperty * Property
Definition: vtkVolume.h:205
record modification and/or execution time
Definition: vtkTimeStamp.h:24
Abstract class for a volume mapper.
abstract specification for renderers
Definition: vtkRenderer.h:61
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:38
#define VTK_MAX_VRCOMP
float * GetGradientOpacityArray()
Definition: vtkVolume.h:150
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:298
window superclass for vtkRenderWindow
Definition: vtkWindow.h:27
virtual vtkMTimeType GetRedrawMTime()
Return the mtime of anything that would cause the rendered image to appear differently.
Definition: vtkProp.h:106
virtual int RenderVolumetricGeometry(vtkViewport *)
Definition: vtkProp.h:215
a simple class to control print indentation
Definition: vtkIndent.h:28
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkProp3D.
float * GetRGBArray()
Definition: vtkVolume.h:164
bool GetSupportsSelection() override
Used by vtkHardwareSelector to determine if the prop supports hardware selection. ...
Definition: vtkVolume.h:198
virtual void GetVolumes(vtkPropCollection *)
Definition: vtkProp.h:58
an ordered list of volumes
float GetGradientOpacityConstant()
Definition: vtkVolume.h:171
#define VTK_SIZEHINT(...)
float * GetGrayArray()
Definition: vtkVolume.h:157
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:143
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkAbstractVolumeMapper * Mapper
Definition: vtkVolume.h:204
vtkMTimeType GetMTime() override
Get the vtkProp3D's mtime.
float * GetCorrectedScalarOpacityArray()
Definition: vtkVolume.h:136