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 
61 #ifndef vtkVolumeProperty_h
62 #define vtkVolumeProperty_h
63 
64 #include "vtkImplicitFunction.h" // For vtkImplicitFunction
65 #include "vtkNew.h" // Needed for vtkNew
66 #include "vtkObject.h"
67 #include "vtkRenderingCoreModule.h" // For export macro
68 #include "vtkSmartPointer.h" // Needed for vtkSmartPointer
69 
70 // STL includes
71 #include <set> // For labelmap labels set
72 #include <unordered_map> // For labelmap transfer function maps
73 
75 class vtkContourValues;
76 class vtkImageData;
78 class vtkTimeStamp;
79 
80 class VTKRENDERINGCORE_EXPORT vtkVolumeProperty : public vtkObject
81 {
82 public:
83  static vtkVolumeProperty* New();
84  vtkTypeMacro(vtkVolumeProperty, vtkObject);
85  void PrintSelf(ostream& os, vtkIndent indent) override;
86  void DeepCopy(vtkVolumeProperty* p);
87 
92  vtkMTimeType GetMTime() override;
93 
95 
116  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
117  vtkGetMacro(IndependentComponents, vtkTypeBool);
118  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
120 
122 
126  vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
127  vtkGetMacro(InterpolationType, int);
128  void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
129  void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
130  const char* GetInterpolationTypeAsString(void);
132 
134 
138  virtual void SetComponentWeight(int index, double value);
139  virtual double GetComponentWeight(int index);
141 
147  void SetColor(int index, vtkPiecewiseFunction* function);
148  void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
149 
156  void SetColor(int index, vtkColorTransferFunction* function);
157  void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
158 
163  int GetColorChannels(int index);
164  int GetColorChannels() { return this->GetColorChannels(0); }
165 
171  vtkPiecewiseFunction* GetGrayTransferFunction(int index);
173 
179  vtkColorTransferFunction* GetRGBTransferFunction(int index);
181 
186  void SetScalarOpacity(int index, vtkPiecewiseFunction* function);
187  void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
188 
194  vtkPiecewiseFunction* GetScalarOpacity(int index);
196 
198 
204  void SetScalarOpacityUnitDistance(int index, double distance);
205  void SetScalarOpacityUnitDistance(double distance)
206  {
207  this->SetScalarOpacityUnitDistance(0, distance);
208  }
209  double GetScalarOpacityUnitDistance(int index);
212 
217  void SetGradientOpacity(int index, vtkPiecewiseFunction* function);
218  void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
219 
221 
227  void SetTransferFunction2D(int index, vtkImageData* function);
228  void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); };
229 
230  vtkImageData* GetTransferFunction2D(int index);
232 
241  {
242  TF_1D = 0,
243  TF_2D
244  };
245 
246  vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
247  vtkGetMacro(TransferFunctionMode, int);
248  void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
249  void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
251 
260  vtkPiecewiseFunction* GetGradientOpacity(int index);
262 
264 
271  virtual void SetDisableGradientOpacity(int index, int value);
272  virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
273  virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
275  virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
277  virtual int GetDisableGradientOpacity(int index);
278  virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
279  vtkPiecewiseFunction* GetStoredGradientOpacity(int index);
282 
289  bool HasGradientOpacity(int index = 0)
290  {
291  switch (this->TransferFunctionMode)
292  {
293  case TF_1D:
294  return (this->GradientOpacity[index] != nullptr);
295  case TF_2D:
296  return true;
297  }
298  return false;
299  }
300 
301  /*
302  * Check whether or not we have label map gradient opacity functions.
303  */
304  bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
305 
307 
327  void SetShade(int index, int value);
328  void SetShade(int value) { this->SetShade(0, value); }
329  int GetShade(int index);
330  int GetShade() { return this->GetShade(0); }
331  void ShadeOn(int index);
332  void ShadeOn() { this->ShadeOn(0); }
333  void ShadeOff(int index);
334  void ShadeOff() { this->ShadeOff(0); }
336 
338 
341  void SetAmbient(int index, double value);
342  void SetAmbient(double value) { this->SetAmbient(0, value); }
343  double GetAmbient(int index);
344  double GetAmbient() { return this->GetAmbient(0); }
346 
348 
351  void SetDiffuse(int index, double value);
352  void SetDiffuse(double value) { this->SetDiffuse(0, value); }
353  double GetDiffuse(int index);
354  double GetDiffuse() { return this->GetDiffuse(0); }
356 
358 
361  void SetSpecular(int index, double value);
362  void SetSpecular(double value) { this->SetSpecular(0, value); }
363  double GetSpecular(int index);
364  double GetSpecular() { return this->GetSpecular(0); }
366 
368 
371  void SetSpecularPower(int index, double value);
372  void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
373  double GetSpecularPower(int index);
374  double GetSpecularPower() { return this->GetSpecularPower(0); }
376 
381  vtkContourValues* GetIsoSurfaceValues();
382 
384 
388  vtkSetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
389  vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
391 
393 
400  vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
401  vtkGetMacro(ScatteringAnisotropy, float);
403 
411  void UpdateMTimes();
412 
417  vtkTimeStamp GetGradientOpacityMTime(int index);
419 
424  vtkTimeStamp GetScalarOpacityMTime(int index);
426 
431  vtkTimeStamp GetRGBTransferFunctionMTime(int index);
433 
438  vtkTimeStamp GetGrayTransferFunctionMTime(int index);
440 
442 
451  vtkSetMacro(UseClippedVoxelIntensity, int);
452  vtkGetMacro(UseClippedVoxelIntensity, int);
453  vtkBooleanMacro(UseClippedVoxelIntensity, int);
455 
457 
466  vtkSetMacro(ClippedVoxelIntensity, double);
467  vtkGetMacro(ClippedVoxelIntensity, double);
469 
471 
474  void SetLabelColor(int label, vtkColorTransferFunction* function);
475  vtkColorTransferFunction* GetLabelColor(int label);
477 
479 
482  void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
483  vtkPiecewiseFunction* GetLabelScalarOpacity(int label);
485 
487 
490  void SetLabelGradientOpacity(int label, vtkPiecewiseFunction* function);
491  vtkPiecewiseFunction* GetLabelGradientOpacity(int label);
493 
498  vtkGetMacro(LabelColorMTime, vtkTimeStamp);
499 
504  vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
505 
510  vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
511 
516  std::size_t GetNumberOfLabels();
517 
522  std::set<int> GetLabelMapLabels();
523 
524 protected:
526  ~vtkVolumeProperty() override;
527 
532  vtkTimeStamp GetTransferFunction2DMTime(int index);
534 
535  virtual void CreateDefaultGradientOpacity(int index);
536 
538  double ComponentWeight[VTK_MAX_VRCOMP];
539 
541 
542  float ScatteringAnisotropy = 0.0;
543 
544  int ColorChannels[VTK_MAX_VRCOMP];
545 
546  vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
547  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
548 
550  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
551 
553  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
554  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
555 
557  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
558 
559  vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
560  int DisableGradientOpacity[VTK_MAX_VRCOMP];
561 
563  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
564  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
565 
569 
570  int Shade[VTK_MAX_VRCOMP];
571  double Ambient[VTK_MAX_VRCOMP];
572  double Diffuse[VTK_MAX_VRCOMP];
573  double Specular[VTK_MAX_VRCOMP];
574  double SpecularPower[VTK_MAX_VRCOMP];
575 
578 
583 
588 
592  std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
593  std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
594  std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
595  std::set<int> LabelMapLabels;
596 
597 private:
598  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
599  void operator=(const vtkVolumeProperty&) = delete;
600 };
601 
606 {
608  {
609  return "Nearest Neighbor";
610  }
612  {
613  return "Linear";
614  }
615  return "Unknown";
616 }
617 
618 #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:62
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:287
vtkTypeBool IndependentComponents
void SetColor(vtkColorTransferFunction *function)
vtkPiecewiseFunction * GetGrayTransferFunction()
record modification and/or execution time
Definition: vtkTimeStamp.h:35
#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:69
vtkPiecewiseFunction * GetScalarOpacity()
vtkTimeStamp GetRGBTransferFunctionMTime()
const char * GetInterpolationTypeAsString(void)
Return the interpolation type as a descriptive character string.
vtkPiecewiseFunction * GetStoredGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
vtkTimeStamp GetScalarOpacityMTime()
a simple class to control print indentation
Definition: vtkIndent.h:39
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
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.
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