VTK  9.3.20240419
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 
128 #ifndef vtkVolumeProperty_h
129 #define vtkVolumeProperty_h
130 
131 #include "vtkImplicitFunction.h" // For vtkImplicitFunction
132 #include "vtkNew.h" // Needed for vtkNew
133 #include "vtkObject.h"
134 #include "vtkRenderingCoreModule.h" // For export macro
135 #include "vtkSmartPointer.h" // Needed for vtkSmartPointer
136 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
137 
138 // STL includes
139 #include <set> // For labelmap labels set
140 #include <unordered_map> // For labelmap transfer function maps
141 
142 VTK_ABI_NAMESPACE_BEGIN
144 class vtkContourValues;
145 class vtkImageData;
147 class vtkTimeStamp;
148 
149 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkVolumeProperty : public vtkObject
150 {
151 public:
153  vtkTypeMacro(vtkVolumeProperty, vtkObject);
154  void PrintSelf(ostream& os, vtkIndent indent) override;
156 
161  vtkMTimeType GetMTime() override;
162 
164 
185  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
186  vtkGetMacro(IndependentComponents, vtkTypeBool);
187  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
189 
191 
195  vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
196  vtkGetMacro(InterpolationType, int);
197  void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
198  void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
199  const char* GetInterpolationTypeAsString();
201 
203 
207  virtual void SetComponentWeight(int index, double value);
208  virtual double GetComponentWeight(int index);
210 
216  void SetColor(int index, vtkPiecewiseFunction* function);
217  VTK_MARSHALSETTER(GrayTransferFunction)
218  void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
219 
227  VTK_MARSHALSETTER(RGBTransferFunction)
228  void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
229 
235  int GetColorChannels() { return this->GetColorChannels(0); }
236 
243  VTK_MARSHALGETTER(GrayTransferFunction)
244  vtkPiecewiseFunction* GetGrayTransferFunction() { return this->GetGrayTransferFunction(0); }
245 
252  VTK_MARSHALGETTER(RGBTransferFunction)
253  vtkColorTransferFunction* GetRGBTransferFunction() { return this->GetRGBTransferFunction(0); }
254 
260  void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
261 
269 
271 
277  void SetScalarOpacityUnitDistance(int index, double distance);
278  void SetScalarOpacityUnitDistance(double distance)
279  {
280  this->SetScalarOpacityUnitDistance(0, distance);
281  }
285 
291  void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
292 
294 
301  void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); }
302 
305 
314  {
315  TF_1D = 0,
316  TF_2D
317  };
318 
319  vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
320  vtkGetMacro(TransferFunctionMode, int);
321  void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
322  void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
324 
335 
337 
344  virtual void SetDisableGradientOpacity(int index, int value);
345  virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
346  virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
348  virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
351  virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
355 
362  bool HasGradientOpacity(int index = 0)
363  {
364  switch (this->TransferFunctionMode)
365  {
366  case TF_1D:
367  return (this->GradientOpacity[index] != nullptr);
368  case TF_2D:
369  return true;
370  }
371  return false;
372  }
373 
374  /*
375  * Check whether or not we have label map gradient opacity functions.
376  */
377  bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
378 
380 
400  void SetShade(int index, int value);
401  void SetShade(int value) { this->SetShade(0, value); }
402  int GetShade(int index);
403  int GetShade() { return this->GetShade(0); }
404  void ShadeOn(int index);
405  void ShadeOn() { this->ShadeOn(0); }
406  void ShadeOff(int index);
407  void ShadeOff() { this->ShadeOff(0); }
409 
411 
414  void SetAmbient(int index, double value);
415  void SetAmbient(double value) { this->SetAmbient(0, value); }
416  double GetAmbient(int index);
417  double GetAmbient() { return this->GetAmbient(0); }
419 
421 
424  void SetDiffuse(int index, double value);
425  void SetDiffuse(double value) { this->SetDiffuse(0, value); }
426  double GetDiffuse(int index);
427  double GetDiffuse() { return this->GetDiffuse(0); }
429 
431 
434  void SetSpecular(int index, double value);
435  void SetSpecular(double value) { this->SetSpecular(0, value); }
436  double GetSpecular(int index);
437  double GetSpecular() { return this->GetSpecular(0); }
439 
441 
444  void SetSpecularPower(int index, double value);
445  void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
446  double GetSpecularPower(int index);
447  double GetSpecularPower() { return this->GetSpecularPower(0); }
449 
455 
457 
464 
466 
473  vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
474  vtkGetMacro(ScatteringAnisotropy, float);
476 
484  void UpdateMTimes();
485 
492 
499 
506 
513 
515 
524  vtkSetMacro(UseClippedVoxelIntensity, int);
525  vtkGetMacro(UseClippedVoxelIntensity, int);
526  vtkBooleanMacro(UseClippedVoxelIntensity, int);
528 
530 
539  vtkSetMacro(ClippedVoxelIntensity, double);
540  vtkGetMacro(ClippedVoxelIntensity, double);
542 
544 
547  void SetLabelColor(int label, vtkColorTransferFunction* function);
550 
552 
555  void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
558 
560 
563  void SetLabelGradientOpacity(int label, vtkPiecewiseFunction* function);
566 
571  vtkGetMacro(LabelColorMTime, vtkTimeStamp);
572 
577  vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
578 
583  vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
584 
589  std::size_t GetNumberOfLabels();
590 
595  std::set<int> GetLabelMapLabels();
596 
597 protected:
599  ~vtkVolumeProperty() override;
600 
607 
609 
611  double ComponentWeight[VTK_MAX_VRCOMP];
612 
614 
615  float ScatteringAnisotropy = 0.0;
616 
617  int ColorChannels[VTK_MAX_VRCOMP];
618 
619  vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
620  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
621 
623  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
624 
626  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
627  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
628 
630  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
631 
632  vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
633  int DisableGradientOpacity[VTK_MAX_VRCOMP];
634 
636  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
637  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
638 
642 
643  int Shade[VTK_MAX_VRCOMP];
644  double Ambient[VTK_MAX_VRCOMP];
645  double Diffuse[VTK_MAX_VRCOMP];
646  double Specular[VTK_MAX_VRCOMP];
647  double SpecularPower[VTK_MAX_VRCOMP];
648 
651 
656 
661 
665  std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
666  std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
667  std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
668  std::set<int> LabelMapLabels;
669 
670 private:
671  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
672  void operator=(const vtkVolumeProperty&) = delete;
673 };
674 
679 {
681  {
682  return "Nearest Neighbor";
683  }
685  {
686  return "Linear";
687  }
688  return "Unknown";
689 }
690 
691 VTK_ABI_NAMESPACE_END
692 #endif
Defines a transfer function for mapping a property to an RGB color value.
helper object to manage setting and generating contour values
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
abstract interface for implicit functions
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:162
Defines a 1D piecewise function.
record modification and/or execution time
Definition: vtkTimeStamp.h:44
represents the common properties for rendering a volume.
void SetSpecular(int index, double value)
Set/Get the specular lighting coefficient.
void SetDiffuse(double value)
Set/Get the diffuse lighting coefficient.
vtkPiecewiseFunction * GetGrayTransferFunction(int index)
Get the gray transfer function.
void SetAmbient(int index, double value)
Set/Get the ambient lighting coefficient.
std::set< int > GetLabelMapLabels()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get access to the internal set that keeps tra...
vtkMTimeType GetMTime() override
Get the modified time for this object (or the properties registered with this object).
vtkContourValues * GetIsoSurfaceValues()
Get contour values for isosurface blending mode.
double GetAmbient(int index)
Set/Get the ambient lighting coefficient.
virtual double GetComponentWeight(int index)
Set/Get the scalar component weights.
vtkTimeStamp LabelGradientOpacityMTime
vtkTimeStamp GetRGBTransferFunctionMTime()
void SetShade(int index, int value)
Set/Get the shading of a volume.
void ShadeOn()
Set/Get the shading of a volume.
void SetScalarOpacityUnitDistance(double distance)
Set/Get the unit distance on which the scalar opacity transfer function is defined.
void SetLabelScalarOpacity(int label, vtkPiecewiseFunction *function)
Set/Get the opacity transfer function for a label in the label map.
std::size_t GetNumberOfLabels()
Get the number of labels that are provided with transfer functions using either SetLabelColor,...
static vtkVolumeProperty * New()
virtual int GetDisableGradientOpacity(int index)
Enable/Disable the gradient opacity function for the given component.
void SetTransferFunction2D(vtkImageData *function)
Color-opacity transfer function mode.
void SetSpecular(double value)
Set/Get the specular lighting coefficient.
vtkColorTransferFunction * GetLabelColor(int label)
Set/Get the color transfer function for a label in the label map.
void SetColor(vtkPiecewiseFunction *function)
vtkTimeStamp GetGrayTransferFunctionMTime(int index)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get the time that the GrayTransferFunction wa...
vtkPiecewiseFunction * GetStoredGradientOpacity(int index)
Enable/Disable the gradient opacity function for the given component.
vtkTimeStamp LabelColorMTime
double GetSpecular()
Set/Get the specular lighting coefficient.
vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction)
Get/Set the function used for slicing.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer< vtkImplicitFunction > SliceFunction
Function used for slice.
double GetSpecularPower(int index)
Set/Get the specular power.
vtkImageData * GetTransferFunction2D(int index)
Color-opacity transfer function mode.
void SetTransferFunction2D(int index, vtkImageData *function)
Set/Get a 2D transfer function.
vtkColorTransferFunction * GetRGBTransferFunction(int index)
Get the RGB transfer function for the given component.
vtkTimeStamp GetScalarOpacityMTime()
vtkPiecewiseFunction * GetStoredGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
void SetGradientOpacity(int index, vtkPiecewiseFunction *function)
Set the opacity of a volume to an opacity transfer function based on gradient magnitude for the given...
void SetTransferFunctionModeTo1D()
Color-opacity transfer function mode.
double GetSpecularPower()
Set/Get the specular power.
virtual void DisableGradientOpacityOn(int index)
Enable/Disable the gradient opacity function for the given component.
void SetSpecularPower(double value)
Set/Get the specular power.
double GetScalarOpacityUnitDistance()
Set/Get the unit distance on which the scalar opacity transfer function is defined.
void SetTransferFunctionModeTo2D()
Color-opacity transfer function mode.
vtkPiecewiseFunction * GetLabelGradientOpacity(int label)
Set/Get the gradient opacity function for a label in the label map.
virtual void DisableGradientOpacityOff(int index)
Enable/Disable the gradient opacity function for the given component.
void ShadeOn(int index)
Set/Get the shading of a volume.
void ShadeOff(int index)
Set/Get the shading of a volume.
const char * GetInterpolationTypeAsString()
Return the interpolation type as a descriptive character string.
void SetShade(int value)
Set/Get the shading of a volume.
void SetScalarOpacityUnitDistance(int index, double distance)
Set/Get the unit distance on which the scalar opacity transfer function is defined.
std::unordered_map< int, vtkPiecewiseFunction * > LabelScalarOpacity
virtual void SetComponentWeight(int index, double value)
Set/Get the scalar component weights.
double GetDiffuse()
Set/Get the diffuse lighting coefficient.
virtual void SetDisableGradientOpacity(int index, int value)
Enable/Disable the gradient opacity function for the given component.
vtkTypeBool IndependentComponents
void SetAmbient(double value)
Set/Get the ambient lighting coefficient.
vtkTimeStamp GetGrayTransferFunctionMTime()
std::set< int > LabelMapLabels
virtual void DisableGradientOpacityOff()
Enable/Disable the gradient opacity function for the given component.
virtual void SetDisableGradientOpacity(int value)
Enable/Disable the gradient opacity function for the given component.
void SetLabelColor(int label, vtkColorTransferFunction *function)
Set/Get the color transfer function for a label in the label map.
int GetShade()
Set/Get the shading of a volume.
vtkPiecewiseFunction * GetScalarOpacity()
void UpdateMTimes()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE UpdateMTimes performs a Modified() on all Tim...
void SetInterpolationTypeToNearest()
Set the interpolation type for sampling a volume.
int GetColorChannels(int index)
Get the number of color channels in the transfer function for the given component.
vtkImageData * GetTransferFunction2D()
Color-opacity transfer function mode.
virtual void DisableGradientOpacityOn()
Enable/Disable the gradient opacity function for the given component.
void DeepCopy(vtkVolumeProperty *p)
TransferMode
Color-opacity transfer function mode.
vtkPiecewiseFunction * GetGradientOpacity(int index)
Get the gradient magnitude opacity transfer function for the given component.
vtkTimeStamp GetRGBTransferFunctionMTime(int index)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get the time that the RGBTransferFunction was...
void SetLabelGradientOpacity(int label, vtkPiecewiseFunction *function)
Set/Get the gradient opacity function for a label in the label map.
bool HasGradientOpacity(int index=0)
Check whether or not we have the gradient opacity.
void SetSpecularPower(int index, double value)
Set/Get the specular power.
vtkTimeStamp GetTransferFunction2DMTime(int index)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get the time when the TransferFunction2D was ...
void SetScalarOpacity(int index, vtkPiecewiseFunction *function)
Set the opacity of a volume to an opacity transfer function based on scalar value for the component i...
int GetShade(int index)
Set/Get the shading of a volume.
void SetColor(int index, vtkColorTransferFunction *function)
Set the color of a volume to an RGB transfer function for the component indicated by index.
vtkNew< vtkContourValues > IsoSurfaceValues
Contour values for isosurface blend mode.
vtkPiecewiseFunction * GetScalarOpacity(int index)
Get the scalar opacity transfer function for the given component.
std::unordered_map< int, vtkColorTransferFunction * > LabelColor
Label map transfer functions.
void ShadeOff()
Set/Get the shading of a volume.
vtkTimeStamp GetTransferFunction2DMTime()
void SetColor(int index, vtkPiecewiseFunction *function)
Set the color of a volume to a gray level transfer function for the component indicated by index.
vtkColorTransferFunction * GetRGBTransferFunction()
void SetInterpolationTypeToLinear()
Set the interpolation type for sampling a volume.
vtkPiecewiseFunction * GetLabelScalarOpacity(int label)
Set/Get the opacity transfer function for a label in the label map.
std::unordered_map< int, vtkPiecewiseFunction * > LabelGradientOpacity
vtkPiecewiseFunction * GetGrayTransferFunction()
double GetAmbient()
Set/Get the ambient lighting coefficient.
void SetGradientOpacity(vtkPiecewiseFunction *function)
vtkSetSmartPointerMacro(SliceFunction, vtkImplicitFunction)
Get/Set the function used for slicing.
void SetScalarOpacity(vtkPiecewiseFunction *function)
double GetDiffuse(int index)
Set/Get the diffuse lighting coefficient.
virtual int GetDisableGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
void SetColor(vtkColorTransferFunction *function)
~vtkVolumeProperty() override
double GetScalarOpacityUnitDistance(int index)
Set/Get the unit distance on which the scalar opacity transfer function is defined.
vtkTimeStamp GetGradientOpacityMTime(int index)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get the time that the gradient opacity transf...
virtual void CreateDefaultGradientOpacity(int index)
vtkTimeStamp GetScalarOpacityMTime(int index)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get the time that the scalar opacity transfer...
vtkTimeStamp GetGradientOpacityMTime()
void SetDiffuse(int index, double value)
Set/Get the diffuse lighting coefficient.
vtkTimeStamp LabelScalarOpacityMTime
vtkPiecewiseFunction * GetGradientOpacity()
double GetSpecular(int index)
Set/Get the specular lighting coefficient.
@ function
Definition: vtkX3D.h:249
@ value
Definition: vtkX3D.h:220
@ index
Definition: vtkX3D.h:246
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_MAX_VRCOMP
#define VTK_NEAREST_INTERPOLATION
#define VTK_LINEAR_INTERPOLATION
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_MARSHALSETTER(property)
#define VTK_MARSHALGETTER(property)
#define VTK_MARSHALAUTO