VTK  9.7.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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
58 
59 // STL includes
60 #include <set> // For labelmap labels set
61 #include <unordered_map> // For labelmap transfer function maps
62 
63 VTK_ABI_NAMESPACE_BEGIN
65 class vtkContourValues;
66 class vtkImageData;
68 class vtkTimeStamp;
69 
70 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkVolumeProperty : public vtkObject
71 {
72 public:
73  static vtkVolumeProperty* New();
74  vtkTypeMacro(vtkVolumeProperty, vtkObject);
75  void PrintSelf(ostream& os, vtkIndent indent) override;
76  void DeepCopy(vtkVolumeProperty* p);
77 
82  vtkMTimeType GetMTime() override;
83 
85 
106  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
107  vtkGetMacro(IndependentComponents, vtkTypeBool);
108  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
110 
112 
116  vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
117  vtkGetMacro(InterpolationType, int);
118  void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
119  void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
120  const char* GetInterpolationTypeAsString();
122 
124 
128  virtual void SetComponentWeight(int index, double value);
129  virtual double GetComponentWeight(int index);
131 
137  void SetColor(int index, vtkPiecewiseFunction* function);
138  void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
139 
146  void SetColor(int index, vtkColorTransferFunction* function);
147  void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
148 
153  int GetColorChannels(int index);
154  int GetColorChannels() { return this->GetColorChannels(0); }
155 
161  vtkPiecewiseFunction* GetGrayTransferFunction(int index);
163  vtkPiecewiseFunction* GetGrayTransferFunction() { return this->GetGrayTransferFunction(0); }
165  {
166  SetColor(index, function);
167  }
169 
175  vtkColorTransferFunction* GetRGBTransferFunction(int index);
177  vtkColorTransferFunction* GetRGBTransferFunction() { return this->GetRGBTransferFunction(0); }
179  {
180  SetColor(index, function);
181  }
183 
189  void SetScalarOpacity(int index, vtkPiecewiseFunction* function);
191  void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
192 
199  vtkPiecewiseFunction* GetScalarOpacity(int index);
201  vtkPiecewiseFunction* GetScalarOpacity() { return this->GetScalarOpacity(0); }
202 
204 
209  {
210  SetScalarOpacity(index, function);
211  };
212  vtkPiecewiseFunction* GetScalarOpacityFunction(int index) { return this->ScalarOpacity[index]; }
215 
217 
223  void SetScalarOpacityUnitDistance(int index, double distance);
225  void SetScalarOpacityUnitDistance(double distance)
226  {
227  this->SetScalarOpacityUnitDistance(0, distance);
228  }
229  double GetScalarOpacityUnitDistance(int index);
231  double GetScalarOpacityUnitDistance() { return this->GetScalarOpacityUnitDistance(0); }
233 
239  void SetGradientOpacity(int index, vtkPiecewiseFunction* function);
241  void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
242 
244 
250  {
251  this->SetGradientOpacity(index, function);
252  }
253  vtkPiecewiseFunction* GetGradientOpacityFunction(int index) { return GradientOpacity[index]; }
256 
258 
264  void SetTransferFunction2D(int index, vtkImageData* function);
266  void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); }
267 
268  vtkImageData* GetTransferFunction2D(int index);
270  vtkImageData* GetTransferFunction2D() { return this->GetTransferFunction2D(0); }
272 
281  {
282  TF_1D = 0,
283  TF_2D
284  };
285 
286  vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
287  vtkGetMacro(TransferFunctionMode, int);
288  void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
289  void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
291 
301  vtkPiecewiseFunction* GetGradientOpacity(int index);
303  vtkPiecewiseFunction* GetGradientOpacity() { return this->GetGradientOpacity(0); }
304 
306 
313  virtual void SetDisableGradientOpacity(int index, int value);
315  virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
316  virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
318  virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
320  virtual int GetDisableGradientOpacity(int index);
322  virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
323  vtkPiecewiseFunction* GetStoredGradientOpacity(int index);
326 
333  bool HasGradientOpacity(int index = 0)
334  {
335  switch (this->TransferFunctionMode)
336  {
337  case TF_1D:
338  return (this->GradientOpacity[index] != nullptr);
339  case TF_2D:
340  return true;
341  }
342  return false;
343  }
344 
345  /*
346  * Check whether or not we have label map gradient opacity functions.
347  */
348  bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
349 
351 
371  void SetShade(int index, int value);
372  void SetShade(int value) { this->SetShade(0, value); }
373  int GetShade(int index);
374  int GetShade() { return this->GetShade(0); }
375  void ShadeOn(int index);
376  void ShadeOn() { this->ShadeOn(0); }
377  void ShadeOff(int index);
378  void ShadeOff() { this->ShadeOff(0); }
380 
382 
385  void SetAmbient(int index, double value);
386  void SetAmbient(double value) { this->SetAmbient(0, value); }
387  double GetAmbient(int index);
388  double GetAmbient() { return this->GetAmbient(0); }
390 
392 
395  void SetDiffuse(int index, double value);
396  void SetDiffuse(double value) { this->SetDiffuse(0, value); }
397  double GetDiffuse(int index);
398  double GetDiffuse() { return this->GetDiffuse(0); }
400 
402 
405  void SetSpecular(int index, double value);
406  void SetSpecular(double value) { this->SetSpecular(0, value); }
407  double GetSpecular(int index);
408  double GetSpecular() { return this->GetSpecular(0); }
410 
412 
415  void SetSpecularPower(int index, double value);
416  void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
417  double GetSpecularPower(int index);
418  double GetSpecularPower() { return this->GetSpecularPower(0); }
420 
425  vtkContourValues* GetIsoSurfaceValues();
426 
428 
432  vtkSetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
433  vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
435 
437 
444  vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
445  vtkGetMacro(ScatteringAnisotropy, float);
447 
455  void UpdateMTimes();
456 
461  vtkTimeStamp GetGradientOpacityMTime(int index);
463 
468  vtkTimeStamp GetScalarOpacityMTime(int index);
470 
475  vtkTimeStamp GetRGBTransferFunctionMTime(int index);
477 
482  vtkTimeStamp GetGrayTransferFunctionMTime(int index);
484 
486 
495  vtkSetMacro(UseClippedVoxelIntensity, int);
496  vtkGetMacro(UseClippedVoxelIntensity, int);
497  vtkBooleanMacro(UseClippedVoxelIntensity, int);
499 
501 
510  vtkSetMacro(ClippedVoxelIntensity, double);
511  vtkGetMacro(ClippedVoxelIntensity, double);
513 
515 
518  void SetLabelColor(int label, vtkColorTransferFunction* function);
519  vtkColorTransferFunction* GetLabelColor(int label);
521 
523 
526  void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
527  vtkPiecewiseFunction* GetLabelScalarOpacity(int label);
529 
531 
534  void SetLabelGradientOpacity(int label, vtkPiecewiseFunction* function);
535  vtkPiecewiseFunction* GetLabelGradientOpacity(int label);
537 
542  vtkGetMacro(LabelColorMTime, vtkTimeStamp);
543 
548  vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
549 
554  vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
555 
560  std::size_t GetNumberOfLabels();
561 
566  std::set<int> GetLabelMapLabels();
567 
568 protected:
570  ~vtkVolumeProperty() override;
571 
576  vtkTimeStamp GetTransferFunction2DMTime(int index);
578 
579  virtual void CreateDefaultGradientOpacity(int index);
580 
582  double ComponentWeight[VTK_MAX_VRCOMP];
583 
585 
586  float ScatteringAnisotropy = 0.0;
587 
588  int ColorChannels[VTK_MAX_VRCOMP];
589 
590  vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
591  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
592 
594  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
595 
597  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
598  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
599 
601  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
602 
603  vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
604  int DisableGradientOpacity[VTK_MAX_VRCOMP];
605 
607  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
608  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
609 
613 
614  int Shade[VTK_MAX_VRCOMP];
615  double Ambient[VTK_MAX_VRCOMP];
616  double Diffuse[VTK_MAX_VRCOMP];
617  double Specular[VTK_MAX_VRCOMP];
618  double SpecularPower[VTK_MAX_VRCOMP];
619 
622 
627 
632 
636  std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
637  std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
638  std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
639  std::set<int> LabelMapLabels;
640 
641 private:
642  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
643  void operator=(const vtkVolumeProperty&) = delete;
644 };
645 
650 {
652  {
653  return "Nearest Neighbor";
654  }
656  {
657  return "Linear";
658  }
659  return "Unknown";
660 }
661 
662 VTK_ABI_NAMESPACE_END
663 #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
int GetNumberOfGrayTransferFunctions()
virtual void DisableGradientOpacityOn()
Enable/Disable the gradient opacity function for the given component.
abstract base class for most VTK objects
Definition: vtkObject.h:52
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:318
vtkTypeBool IndependentComponents
void SetColor(vtkColorTransferFunction *function)
vtkPiecewiseFunction * GetGrayTransferFunction()
record modification and/or execution time
Definition: vtkTimeStamp.h:24
void SetScalarOpacityFunction(int index, vtkPiecewiseFunction *function)
Get/Set the scalar opacity transfer function for the given component.
#define VTK_LINEAR_INTERPOLATION
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
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()
void SetRGBTransferFunction(int index, vtkColorTransferFunction *function)
vtkTimeStamp GetRGBTransferFunctionMTime()
void SetGrayTransferFunction(int index, vtkPiecewiseFunction *function)
vtkPiecewiseFunction * GetStoredGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
vtkTimeStamp GetScalarOpacityMTime()
vtkPiecewiseFunction * GetScalarOpacityFunction(int index)
Get/Set the scalar opacity transfer function for the given component.
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
bool HasGradientOpacity(int index=0)
Check whether or not we have the gradient opacity.
vtkTimeStamp GetGrayTransferFunctionMTime()
int GetNumberOfScalarOpacityFunctions()
Get/Set the scalar opacity transfer function for the given component.
void ShadeOff()
Set/Get the shading of a volume.
virtual vtkMTimeType GetMTime()
Return this object's modified time.
int GetNumberOfRGBTransferFunctions()
void SetGradientOpacityFunction(int index, vtkPiecewiseFunction *function)
Set/Get the gradient magnitude opacity transfer function for the given component. ...
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.
#define VTK_MARSHALEXCLUDE(reason)
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
int GetNumberOfGradientOpacityFunctions()
Set/Get the gradient magnitude opacity transfer function for the given component. ...
std::set< int > LabelMapLabels
vtkPiecewiseFunction * GetGradientOpacityFunction(int index)
Set/Get the gradient magnitude opacity transfer function for the given component. ...
#define VTK_MARSHALAUTO
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.
vtkPiecewiseFunction * GetGradientOpacity()
int GetNumberOfTransferFunction2Ds()
Color-opacity transfer function mode.
double GetAmbient()
Set/Get the ambient lighting coefficient.
double GetSpecularPower()
Set/Get the specular power.
std::unordered_map< int, vtkPiecewiseFunction * > LabelScalarOpacity