VTK  9.2.5
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 
150 #ifndef vtkVolumeProperty_h
151 #define vtkVolumeProperty_h
152 
153 #include "vtkImplicitFunction.h" // For vtkImplicitFunction
154 #include "vtkNew.h" // Needed for vtkNew
155 #include "vtkObject.h"
156 #include "vtkRenderingCoreModule.h" // For export macro
157 #include "vtkSmartPointer.h" // Needed for vtkSmartPointer
158 
159 // STL includes
160 #include <set> // For labelmap labels set
161 #include <unordered_map> // For labelmap transfer function maps
162 
164 class vtkContourValues;
165 class vtkImageData;
167 class vtkTimeStamp;
168 
169 class VTKRENDERINGCORE_EXPORT vtkVolumeProperty : public vtkObject
170 {
171 public:
173  vtkTypeMacro(vtkVolumeProperty, vtkObject);
174  void PrintSelf(ostream& os, vtkIndent indent) override;
176 
181  vtkMTimeType GetMTime() override;
182 
184 
205  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
206  vtkGetMacro(IndependentComponents, vtkTypeBool);
207  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
209 
211 
215  vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
216  vtkGetMacro(InterpolationType, int);
217  void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
218  void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
219  const char* GetInterpolationTypeAsString(void);
221 
223 
227  virtual void SetComponentWeight(int index, double value);
228  virtual double GetComponentWeight(int index);
230 
236  void SetColor(int index, vtkPiecewiseFunction* function);
237  void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
238 
246  void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
247 
253  int GetColorChannels() { return this->GetColorChannels(0); }
254 
262 
270 
276  void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
277 
285 
287 
293  void SetScalarOpacityUnitDistance(int index, double distance);
294  void SetScalarOpacityUnitDistance(double distance)
295  {
296  this->SetScalarOpacityUnitDistance(0, distance);
297  }
301 
307  void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
308 
310 
317  void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); };
318 
321 
330  {
331  TF_1D = 0,
332  TF_2D
333  };
334 
335  vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
336  vtkGetMacro(TransferFunctionMode, int);
337  void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
338  void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
340 
351 
353 
360  virtual void SetDisableGradientOpacity(int index, int value);
361  virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
362  virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
364  virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
367  virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
371 
378  bool HasGradientOpacity(int index = 0)
379  {
380  switch (this->TransferFunctionMode)
381  {
382  case TF_1D:
383  return (this->GradientOpacity[index] != nullptr);
384  case TF_2D:
385  return true;
386  }
387  return false;
388  }
389 
390  /*
391  * Check whether or not we have label map gradient opacity functions.
392  */
393  bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
394 
396 
416  void SetShade(int index, int value);
417  void SetShade(int value) { this->SetShade(0, value); }
418  int GetShade(int index);
419  int GetShade() { return this->GetShade(0); }
420  void ShadeOn(int index);
421  void ShadeOn() { this->ShadeOn(0); }
422  void ShadeOff(int index);
423  void ShadeOff() { this->ShadeOff(0); }
425 
427 
430  void SetAmbient(int index, double value);
431  void SetAmbient(double value) { this->SetAmbient(0, value); }
432  double GetAmbient(int index);
433  double GetAmbient() { return this->GetAmbient(0); }
435 
437 
440  void SetDiffuse(int index, double value);
441  void SetDiffuse(double value) { this->SetDiffuse(0, value); }
442  double GetDiffuse(int index);
443  double GetDiffuse() { return this->GetDiffuse(0); }
445 
447 
450  void SetSpecular(int index, double value);
451  void SetSpecular(double value) { this->SetSpecular(0, value); }
452  double GetSpecular(int index);
453  double GetSpecular() { return this->GetSpecular(0); }
455 
457 
460  void SetSpecularPower(int index, double value);
461  void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
462  double GetSpecularPower(int index);
463  double GetSpecularPower() { return this->GetSpecularPower(0); }
465 
471 
473 
480 
482 
489  vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
490  vtkGetMacro(ScatteringAnisotropy, float);
492 
500  void UpdateMTimes();
501 
508 
515 
522 
529 
531 
540  vtkSetMacro(UseClippedVoxelIntensity, int);
541  vtkGetMacro(UseClippedVoxelIntensity, int);
542  vtkBooleanMacro(UseClippedVoxelIntensity, int);
544 
546 
555  vtkSetMacro(ClippedVoxelIntensity, double);
556  vtkGetMacro(ClippedVoxelIntensity, double);
558 
560 
563  void SetLabelColor(int label, vtkColorTransferFunction* function);
566 
568 
571  void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
574 
576 
579  void SetLabelGradientOpacity(int label, vtkPiecewiseFunction* function);
582 
587  vtkGetMacro(LabelColorMTime, vtkTimeStamp);
588 
593  vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
594 
599  vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
600 
605  std::size_t GetNumberOfLabels();
606 
611  std::set<int> GetLabelMapLabels();
612 
613 protected:
615  ~vtkVolumeProperty() override;
616 
623 
625 
627  double ComponentWeight[VTK_MAX_VRCOMP];
628 
630 
631  float ScatteringAnisotropy = 0.0;
632 
633  int ColorChannels[VTK_MAX_VRCOMP];
634 
635  vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
636  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
637 
639  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
640 
642  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
643  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
644 
646  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
647 
648  vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
649  int DisableGradientOpacity[VTK_MAX_VRCOMP];
650 
652  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
653  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
654 
658 
659  int Shade[VTK_MAX_VRCOMP];
660  double Ambient[VTK_MAX_VRCOMP];
661  double Diffuse[VTK_MAX_VRCOMP];
662  double Specular[VTK_MAX_VRCOMP];
663  double SpecularPower[VTK_MAX_VRCOMP];
664 
667 
672 
677 
681  std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
682  std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
683  std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
684  std::set<int> LabelMapLabels;
685 
686 private:
687  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
688  void operator=(const vtkVolumeProperty&) = delete;
689 };
690 
695 {
697  {
698  return "Nearest Neighbor";
699  }
701  {
702  return "Linear";
703  }
704  return "Unknown";
705 }
706 
707 #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:163
abstract interface for implicit functions
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
Defines a 1D piecewise function.
record modification and/or execution time
Definition: vtkTimeStamp.h:55
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