VTK  9.3.1
vtkVolumeProperty.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
3 
49 #ifndef vtkVolumeProperty_h
50 #define vtkVolumeProperty_h
51 
52 #include "vtkImplicitFunction.h" // For vtkImplicitFunction
53 #include "vtkNew.h" // Needed for vtkNew
54 #include "vtkObject.h"
55 #include "vtkRenderingCoreModule.h" // For export macro
56 #include "vtkSmartPointer.h" // Needed for vtkSmartPointer
57 
58 // STL includes
59 #include <set> // For labelmap labels set
60 #include <unordered_map> // For labelmap transfer function maps
61 
62 VTK_ABI_NAMESPACE_BEGIN
64 class vtkContourValues;
65 class vtkImageData;
67 class vtkTimeStamp;
68 
69 class VTKRENDERINGCORE_EXPORT vtkVolumeProperty : public vtkObject
70 {
71 public:
72  static vtkVolumeProperty* New();
73  vtkTypeMacro(vtkVolumeProperty, vtkObject);
74  void PrintSelf(ostream& os, vtkIndent indent) override;
75  void DeepCopy(vtkVolumeProperty* p);
76 
81  vtkMTimeType GetMTime() override;
82 
84 
105  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
106  vtkGetMacro(IndependentComponents, vtkTypeBool);
107  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
109 
111 
115  vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
116  vtkGetMacro(InterpolationType, int);
117  void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
118  void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
119  const char* GetInterpolationTypeAsString();
121 
123 
127  virtual void SetComponentWeight(int index, double value);
128  virtual double GetComponentWeight(int index);
130 
136  void SetColor(int index, vtkPiecewiseFunction* function);
137  void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
138 
145  void SetColor(int index, vtkColorTransferFunction* function);
146  void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
147 
152  int GetColorChannels(int index);
153  int GetColorChannels() { return this->GetColorChannels(0); }
154 
160  vtkPiecewiseFunction* GetGrayTransferFunction(int index);
162 
168  vtkColorTransferFunction* GetRGBTransferFunction(int index);
170 
175  void SetScalarOpacity(int index, vtkPiecewiseFunction* function);
176  void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
177 
183  vtkPiecewiseFunction* GetScalarOpacity(int index);
185 
187 
193  void SetScalarOpacityUnitDistance(int index, double distance);
194  void SetScalarOpacityUnitDistance(double distance)
195  {
196  this->SetScalarOpacityUnitDistance(0, distance);
197  }
198  double GetScalarOpacityUnitDistance(int index);
201 
206  void SetGradientOpacity(int index, vtkPiecewiseFunction* function);
207  void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
208 
210 
216  void SetTransferFunction2D(int index, vtkImageData* function);
217  void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); };
218 
219  vtkImageData* GetTransferFunction2D(int index);
221 
230  {
231  TF_1D = 0,
232  TF_2D
233  };
234 
235  vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
236  vtkGetMacro(TransferFunctionMode, int);
237  void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
238  void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
240 
249  vtkPiecewiseFunction* GetGradientOpacity(int index);
251 
253 
260  virtual void SetDisableGradientOpacity(int index, int value);
261  virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
262  virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
264  virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
266  virtual int GetDisableGradientOpacity(int index);
267  virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
268  vtkPiecewiseFunction* GetStoredGradientOpacity(int index);
271 
278  bool HasGradientOpacity(int index = 0)
279  {
280  switch (this->TransferFunctionMode)
281  {
282  case TF_1D:
283  return (this->GradientOpacity[index] != nullptr);
284  case TF_2D:
285  return true;
286  }
287  return false;
288  }
289 
290  /*
291  * Check whether or not we have label map gradient opacity functions.
292  */
293  bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
294 
296 
316  void SetShade(int index, int value);
317  void SetShade(int value) { this->SetShade(0, value); }
318  int GetShade(int index);
319  int GetShade() { return this->GetShade(0); }
320  void ShadeOn(int index);
321  void ShadeOn() { this->ShadeOn(0); }
322  void ShadeOff(int index);
323  void ShadeOff() { this->ShadeOff(0); }
325 
327 
330  void SetAmbient(int index, double value);
331  void SetAmbient(double value) { this->SetAmbient(0, value); }
332  double GetAmbient(int index);
333  double GetAmbient() { return this->GetAmbient(0); }
335 
337 
340  void SetDiffuse(int index, double value);
341  void SetDiffuse(double value) { this->SetDiffuse(0, value); }
342  double GetDiffuse(int index);
343  double GetDiffuse() { return this->GetDiffuse(0); }
345 
347 
350  void SetSpecular(int index, double value);
351  void SetSpecular(double value) { this->SetSpecular(0, value); }
352  double GetSpecular(int index);
353  double GetSpecular() { return this->GetSpecular(0); }
355 
357 
360  void SetSpecularPower(int index, double value);
361  void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
362  double GetSpecularPower(int index);
363  double GetSpecularPower() { return this->GetSpecularPower(0); }
365 
370  vtkContourValues* GetIsoSurfaceValues();
371 
373 
377  vtkSetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
378  vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
380 
382 
389  vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
390  vtkGetMacro(ScatteringAnisotropy, float);
392 
400  void UpdateMTimes();
401 
406  vtkTimeStamp GetGradientOpacityMTime(int index);
408 
413  vtkTimeStamp GetScalarOpacityMTime(int index);
415 
420  vtkTimeStamp GetRGBTransferFunctionMTime(int index);
422 
427  vtkTimeStamp GetGrayTransferFunctionMTime(int index);
429 
431 
440  vtkSetMacro(UseClippedVoxelIntensity, int);
441  vtkGetMacro(UseClippedVoxelIntensity, int);
442  vtkBooleanMacro(UseClippedVoxelIntensity, int);
444 
446 
455  vtkSetMacro(ClippedVoxelIntensity, double);
456  vtkGetMacro(ClippedVoxelIntensity, double);
458 
460 
463  void SetLabelColor(int label, vtkColorTransferFunction* function);
464  vtkColorTransferFunction* GetLabelColor(int label);
466 
468 
471  void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
472  vtkPiecewiseFunction* GetLabelScalarOpacity(int label);
474 
476 
479  void SetLabelGradientOpacity(int label, vtkPiecewiseFunction* function);
480  vtkPiecewiseFunction* GetLabelGradientOpacity(int label);
482 
487  vtkGetMacro(LabelColorMTime, vtkTimeStamp);
488 
493  vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
494 
499  vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
500 
505  std::size_t GetNumberOfLabels();
506 
511  std::set<int> GetLabelMapLabels();
512 
513 protected:
515  ~vtkVolumeProperty() override;
516 
521  vtkTimeStamp GetTransferFunction2DMTime(int index);
523 
524  virtual void CreateDefaultGradientOpacity(int index);
525 
527  double ComponentWeight[VTK_MAX_VRCOMP];
528 
530 
531  float ScatteringAnisotropy = 0.0;
532 
533  int ColorChannels[VTK_MAX_VRCOMP];
534 
535  vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
536  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
537 
539  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
540 
542  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
543  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
544 
546  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
547 
548  vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
549  int DisableGradientOpacity[VTK_MAX_VRCOMP];
550 
552  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
553  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
554 
558 
559  int Shade[VTK_MAX_VRCOMP];
560  double Ambient[VTK_MAX_VRCOMP];
561  double Diffuse[VTK_MAX_VRCOMP];
562  double Specular[VTK_MAX_VRCOMP];
563  double SpecularPower[VTK_MAX_VRCOMP];
564 
567 
572 
577 
581  std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
582  std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
583  std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
584  std::set<int> LabelMapLabels;
585 
586 private:
587  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
588  void operator=(const vtkVolumeProperty&) = delete;
589 };
590 
595 {
597  {
598  return "Nearest Neighbor";
599  }
601  {
602  return "Linear";
603  }
604  return "Unknown";
605 }
606 
607 VTK_ABI_NAMESPACE_END
608 #endif
abstract interface for implicit functions
void SetTransferFunctionModeTo2D()
Color-opacity transfer function mode.
int GetShade()
Set/Get the shading of a volume.
vtkSmartPointer< vtkImplicitFunction > SliceFunction
Function used for slice.
vtkColorTransferFunction * GetRGBTransferFunction()
helper object to manage setting and generating contour values
virtual void DisableGradientOpacityOn()
Enable/Disable the gradient opacity function for the given component.
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
double GetDiffuse()
Set/Get the diffuse lighting coefficient.
void SetAmbient(double value)
Set/Get the ambient lighting coefficient.
Defines a 1D piecewise function.
void SetSpecularPower(double value)
Set/Get the specular power.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
vtkTypeBool IndependentComponents
void SetColor(vtkColorTransferFunction *function)
vtkPiecewiseFunction * GetGrayTransferFunction()
record modification and/or execution time
Definition: vtkTimeStamp.h:24
#define VTK_LINEAR_INTERPOLATION
void SetScalarOpacity(vtkPiecewiseFunction *function)
double GetSpecular()
Set/Get the specular lighting coefficient.
vtkImageData * GetTransferFunction2D()
Color-opacity transfer function mode.
void SetGradientOpacity(vtkPiecewiseFunction *function)
std::unordered_map< int, vtkPiecewiseFunction * > LabelGradientOpacity
void SetColor(vtkPiecewiseFunction *function)
double GetScalarOpacityUnitDistance()
Set/Get the unit distance on which the scalar opacity transfer function is defined.
#define VTK_MAX_VRCOMP
TransferMode
Color-opacity transfer function mode.
void SetTransferFunctionModeTo1D()
Color-opacity transfer function mode.
int vtkTypeBool
Definition: vtkABI.h:64
vtkPiecewiseFunction * GetScalarOpacity()
vtkTimeStamp GetRGBTransferFunctionMTime()
vtkPiecewiseFunction * GetStoredGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
vtkTimeStamp GetScalarOpacityMTime()
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
bool HasGradientOpacity(int index=0)
Check whether or not we have the gradient opacity.
vtkTimeStamp GetGrayTransferFunctionMTime()
void ShadeOff()
Set/Get the shading of a volume.
virtual vtkMTimeType GetMTime()
Return this object's modified time.
void SetInterpolationTypeToNearest()
Set the interpolation type for sampling a volume.
represents the common properties for rendering a volume.
virtual void SetDisableGradientOpacity(int value)
Enable/Disable the gradient opacity function for the given component.
void SetSpecular(double value)
Set/Get the specular lighting coefficient.
vtkTimeStamp LabelGradientOpacityMTime
void SetShade(int value)
Set/Get the shading of a volume.
Defines a transfer function for mapping a property to an RGB color value.
const char * GetInterpolationTypeAsString()
Return the interpolation type as a descriptive character string.
vtkTimeStamp GetTransferFunction2DMTime()
void SetTransferFunction2D(vtkImageData *function)
Color-opacity transfer function mode.
vtkTimeStamp LabelScalarOpacityMTime
std::set< int > LabelMapLabels
vtkNew< vtkContourValues > IsoSurfaceValues
Contour values for isosurface blend mode.
void SetDiffuse(double value)
Set/Get the diffuse lighting coefficient.
void SetInterpolationTypeToLinear()
Set the interpolation type for sampling a volume.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual int GetDisableGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
vtkTimeStamp GetGradientOpacityMTime()
virtual void DisableGradientOpacityOff(int index)
Enable/Disable the gradient opacity function for the given component.
virtual void DisableGradientOpacityOn(int index)
Enable/Disable the gradient opacity function for the given component.
vtkTimeStamp LabelColorMTime
#define VTK_NEAREST_INTERPOLATION
void ShadeOn()
Set/Get the shading of a volume.
std::unordered_map< int, vtkColorTransferFunction * > LabelColor
Label map transfer functions.
virtual void DisableGradientOpacityOff()
Enable/Disable the gradient opacity function for the given component.
void SetScalarOpacityUnitDistance(double distance)
Set/Get the unit distance on which the scalar opacity transfer function is defined.
vtkPiecewiseFunction * GetGradientOpacity()
double GetAmbient()
Set/Get the ambient lighting coefficient.
double GetSpecularPower()
Set/Get the specular power.
std::unordered_map< int, vtkPiecewiseFunction * > LabelScalarOpacity