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