VTK  9.2.6
vtkVolumeProperty.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkVolumeProperty.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
70 #ifndef vtkVolumeProperty_h
71 #define vtkVolumeProperty_h
72 
73 #include "vtkImplicitFunction.h" // For vtkImplicitFunction
74 #include "vtkNew.h" // Needed for vtkNew
75 #include "vtkObject.h"
76 #include "vtkRenderingCoreModule.h" // For export macro
77 #include "vtkSmartPointer.h" // Needed for vtkSmartPointer
78 
79 // STL includes
80 #include <set> // For labelmap labels set
81 #include <unordered_map> // For labelmap transfer function maps
82 
84 class vtkContourValues;
85 class vtkImageData;
87 class vtkTimeStamp;
88 
89 class VTKRENDERINGCORE_EXPORT vtkVolumeProperty : public vtkObject
90 {
91 public:
93  vtkTypeMacro(vtkVolumeProperty, vtkObject);
94  void PrintSelf(ostream& os, vtkIndent indent) override;
96 
101  vtkMTimeType GetMTime() override;
102 
104 
125  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
126  vtkGetMacro(IndependentComponents, vtkTypeBool);
127  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
129 
131 
135  vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
136  vtkGetMacro(InterpolationType, int);
137  void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
138  void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
139  const char* GetInterpolationTypeAsString(void);
141 
143 
147  virtual void SetComponentWeight(int index, double value);
148  virtual double GetComponentWeight(int index);
150 
156  void SetColor(int index, vtkPiecewiseFunction* function);
157  void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
158 
166  void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
167 
173  int GetColorChannels() { return this->GetColorChannels(0); }
174 
182 
190 
196  void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
197 
205 
207 
213  void SetScalarOpacityUnitDistance(int index, double distance);
214  void SetScalarOpacityUnitDistance(double distance)
215  {
216  this->SetScalarOpacityUnitDistance(0, distance);
217  }
221 
227  void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
228 
230 
237  void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); };
238 
241 
250  {
251  TF_1D = 0,
252  TF_2D
253  };
254 
255  vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
256  vtkGetMacro(TransferFunctionMode, int);
257  void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
258  void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
260 
271 
273 
280  virtual void SetDisableGradientOpacity(int index, int value);
281  virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
282  virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
284  virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
287  virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
291 
298  bool HasGradientOpacity(int index = 0)
299  {
300  switch (this->TransferFunctionMode)
301  {
302  case TF_1D:
303  return (this->GradientOpacity[index] != nullptr);
304  case TF_2D:
305  return true;
306  }
307  return false;
308  }
309 
310  /*
311  * Check whether or not we have label map gradient opacity functions.
312  */
313  bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
314 
316 
336  void SetShade(int index, int value);
337  void SetShade(int value) { this->SetShade(0, value); }
338  int GetShade(int index);
339  int GetShade() { return this->GetShade(0); }
340  void ShadeOn(int index);
341  void ShadeOn() { this->ShadeOn(0); }
342  void ShadeOff(int index);
343  void ShadeOff() { this->ShadeOff(0); }
345 
347 
350  void SetAmbient(int index, double value);
351  void SetAmbient(double value) { this->SetAmbient(0, value); }
352  double GetAmbient(int index);
353  double GetAmbient() { return this->GetAmbient(0); }
355 
357 
360  void SetDiffuse(int index, double value);
361  void SetDiffuse(double value) { this->SetDiffuse(0, value); }
362  double GetDiffuse(int index);
363  double GetDiffuse() { return this->GetDiffuse(0); }
365 
367 
370  void SetSpecular(int index, double value);
371  void SetSpecular(double value) { this->SetSpecular(0, value); }
372  double GetSpecular(int index);
373  double GetSpecular() { return this->GetSpecular(0); }
375 
377 
380  void SetSpecularPower(int index, double value);
381  void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
382  double GetSpecularPower(int index);
383  double GetSpecularPower() { return this->GetSpecularPower(0); }
385 
391 
393 
400 
402 
409  vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
410  vtkGetMacro(ScatteringAnisotropy, float);
412 
420  void UpdateMTimes();
421 
428 
435 
442 
449 
451 
460  vtkSetMacro(UseClippedVoxelIntensity, int);
461  vtkGetMacro(UseClippedVoxelIntensity, int);
462  vtkBooleanMacro(UseClippedVoxelIntensity, int);
464 
466 
475  vtkSetMacro(ClippedVoxelIntensity, double);
476  vtkGetMacro(ClippedVoxelIntensity, double);
478 
480 
483  void SetLabelColor(int label, vtkColorTransferFunction* function);
486 
488 
491  void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
494 
496 
499  void SetLabelGradientOpacity(int label, vtkPiecewiseFunction* function);
502 
507  vtkGetMacro(LabelColorMTime, vtkTimeStamp);
508 
513  vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
514 
519  vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
520 
525  std::size_t GetNumberOfLabels();
526 
531  std::set<int> GetLabelMapLabels();
532 
533 protected:
535  ~vtkVolumeProperty() override;
536 
543 
545 
547  double ComponentWeight[VTK_MAX_VRCOMP];
548 
550 
551  float ScatteringAnisotropy = 0.0;
552 
553  int ColorChannels[VTK_MAX_VRCOMP];
554 
555  vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
556  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
557 
559  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
560 
562  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
563  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
564 
566  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
567 
568  vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
569  int DisableGradientOpacity[VTK_MAX_VRCOMP];
570 
572  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
573  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
574 
578 
579  int Shade[VTK_MAX_VRCOMP];
580  double Ambient[VTK_MAX_VRCOMP];
581  double Diffuse[VTK_MAX_VRCOMP];
582  double Specular[VTK_MAX_VRCOMP];
583  double SpecularPower[VTK_MAX_VRCOMP];
584 
587 
592 
597 
601  std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
602  std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
603  std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
604  std::set<int> LabelMapLabels;
605 
606 private:
607  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
608  void operator=(const vtkVolumeProperty&) = delete;
609 };
610 
615 {
617  {
618  return "Nearest Neighbor";
619  }
621  {
622  return "Linear";
623  }
624  return "Unknown";
625 }
626 
627 #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:63
abstract interface for implicit functions
a simple class to control print indentation
Definition: vtkIndent.h:49
abstract base class for most VTK objects
Definition: vtkObject.h:72
Defines a 1D piecewise function.
record modification and/or execution time
Definition: vtkTimeStamp.h:45
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.
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.
const char * GetInterpolationTypeAsString(void)
Return the interpolation type as a descriptive character string.
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.
@ value
Definition: vtkX3D.h:226
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_MAX_VRCOMP
#define VTK_NEAREST_INTERPOLATION
#define VTK_LINEAR_INTERPOLATION
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287