VTK  9.0.1
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 
55 #ifndef vtkVolumeProperty_h
56 #define vtkVolumeProperty_h
57 
58 #include "vtkImplicitFunction.h" // For vtkImplicitFunction
59 #include "vtkNew.h" // Needed for vtkNew
60 #include "vtkObject.h"
61 #include "vtkRenderingCoreModule.h" // For export macro
62 #include "vtkSmartPointer.h" // Needed for vtkSmartPointer
63 
64 // STL includes
65 #include <set> // For labelmap labels set
66 #include <unordered_map> // For labelmap transfer function maps
67 
69 class vtkContourValues;
70 class vtkImageData;
72 class vtkTimeStamp;
73 
74 class VTKRENDERINGCORE_EXPORT vtkVolumeProperty : public vtkObject
75 {
76 public:
77  static vtkVolumeProperty* New();
78  vtkTypeMacro(vtkVolumeProperty, vtkObject);
79  void PrintSelf(ostream& os, vtkIndent indent) override;
80  void DeepCopy(vtkVolumeProperty* p);
81 
86  vtkMTimeType GetMTime() override;
87 
89 
110  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
111  vtkGetMacro(IndependentComponents, vtkTypeBool);
112  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
114 
116 
120  vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
121  vtkGetMacro(InterpolationType, int);
122  void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
123  void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
124  const char* GetInterpolationTypeAsString(void);
126 
128 
132  virtual void SetComponentWeight(int index, double value);
133  virtual double GetComponentWeight(int index);
135 
141  void SetColor(int index, vtkPiecewiseFunction* function);
142  void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
143 
150  void SetColor(int index, vtkColorTransferFunction* function);
151  void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
152 
157  int GetColorChannels(int index);
158  int GetColorChannels() { return this->GetColorChannels(0); }
159 
165  vtkPiecewiseFunction* GetGrayTransferFunction(int index);
167 
173  vtkColorTransferFunction* GetRGBTransferFunction(int index);
175 
180  void SetScalarOpacity(int index, vtkPiecewiseFunction* function);
181  void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
182 
188  vtkPiecewiseFunction* GetScalarOpacity(int index);
190 
192 
198  void SetScalarOpacityUnitDistance(int index, double distance);
199  void SetScalarOpacityUnitDistance(double distance)
200  {
201  this->SetScalarOpacityUnitDistance(0, distance);
202  }
203  double GetScalarOpacityUnitDistance(int index);
206 
211  void SetGradientOpacity(int index, vtkPiecewiseFunction* function);
212  void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
213 
215 
221  void SetTransferFunction2D(int index, vtkImageData* function);
222  void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); };
223 
224  vtkImageData* GetTransferFunction2D(int index);
226 
235  {
236  TF_1D = 0,
237  TF_2D
238  };
239 
240  vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
241  vtkGetMacro(TransferFunctionMode, int);
243 
252  vtkPiecewiseFunction* GetGradientOpacity(int index);
254 
256 
263  virtual void SetDisableGradientOpacity(int index, int value);
264  virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
265  virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
267  virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
269  virtual int GetDisableGradientOpacity(int index);
270  virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
271  vtkPiecewiseFunction* GetStoredGradientOpacity(int index);
274 
281  bool HasGradientOpacity(int index = 0)
282  {
283  switch (this->TransferFunctionMode)
284  {
285  case TF_1D:
286  return (this->GradientOpacity[index] != nullptr);
287  case TF_2D:
288  return true;
289  }
290  return false;
291  }
292 
293  /*
294  * Check whether or not we have label map gradient opacity functions.
295  */
296  bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
297 
299 
319  void SetShade(int index, int value);
320  void SetShade(int value) { this->SetShade(0, value); }
321  int GetShade(int index);
322  int GetShade() { return this->GetShade(0); }
323  void ShadeOn(int index);
324  void ShadeOn() { this->ShadeOn(0); }
325  void ShadeOff(int index);
326  void ShadeOff() { this->ShadeOff(0); }
328 
330 
333  void SetAmbient(int index, double value);
334  void SetAmbient(double value) { this->SetAmbient(0, value); }
335  double GetAmbient(int index);
336  double GetAmbient() { return this->GetAmbient(0); }
338 
340 
343  void SetDiffuse(int index, double value);
344  void SetDiffuse(double value) { this->SetDiffuse(0, value); }
345  double GetDiffuse(int index);
346  double GetDiffuse() { return this->GetDiffuse(0); }
348 
350 
353  void SetSpecular(int index, double value);
354  void SetSpecular(double value) { this->SetSpecular(0, value); }
355  double GetSpecular(int index);
356  double GetSpecular() { return this->GetSpecular(0); }
358 
360 
363  void SetSpecularPower(int index, double value);
364  void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
365  double GetSpecularPower(int index);
366  double GetSpecularPower() { return this->GetSpecularPower(0); }
368 
373  vtkContourValues* GetIsoSurfaceValues();
374 
376 
380  vtkSetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
381  vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
383 
391  void UpdateMTimes();
392 
397  vtkTimeStamp GetGradientOpacityMTime(int index);
399 
404  vtkTimeStamp GetScalarOpacityMTime(int index);
406 
411  vtkTimeStamp GetRGBTransferFunctionMTime(int index);
413 
418  vtkTimeStamp GetGrayTransferFunctionMTime(int index);
420 
422 
431  vtkSetMacro(UseClippedVoxelIntensity, int);
432  vtkGetMacro(UseClippedVoxelIntensity, int);
433  vtkBooleanMacro(UseClippedVoxelIntensity, int);
435 
437 
446  vtkSetMacro(ClippedVoxelIntensity, double);
447  vtkGetMacro(ClippedVoxelIntensity, double);
449 
451 
454  void SetLabelColor(int label, vtkColorTransferFunction* function);
455  vtkColorTransferFunction* GetLabelColor(int label);
457 
459 
462  void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
463  vtkPiecewiseFunction* GetLabelScalarOpacity(int label);
465 
467 
470  void SetLabelGradientOpacity(int label, vtkPiecewiseFunction* function);
471  vtkPiecewiseFunction* GetLabelGradientOpacity(int label);
473 
478  vtkGetMacro(LabelColorMTime, vtkTimeStamp);
479 
484  vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
485 
490  vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
491 
496  std::size_t GetNumberOfLabels();
497 
502  std::set<int> GetLabelMapLabels();
503 
504 protected:
506  ~vtkVolumeProperty() override;
507 
512  vtkTimeStamp GetTransferFunction2DMTime(int index);
514 
515  virtual void CreateDefaultGradientOpacity(int index);
516 
518  double ComponentWeight[VTK_MAX_VRCOMP];
519 
521 
522  int ColorChannels[VTK_MAX_VRCOMP];
523 
524  vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
525  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
526 
528  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
529 
531  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
532  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
533 
535  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
536 
537  vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
538  int DisableGradientOpacity[VTK_MAX_VRCOMP];
539 
541  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
542  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
543 
547 
548  int Shade[VTK_MAX_VRCOMP];
549  double Ambient[VTK_MAX_VRCOMP];
550  double Diffuse[VTK_MAX_VRCOMP];
551  double Specular[VTK_MAX_VRCOMP];
552  double SpecularPower[VTK_MAX_VRCOMP];
553 
556 
561 
566 
570  std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
571  std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
572  std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
573  std::set<int> LabelMapLabels;
574 
575 private:
576  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
577  void operator=(const vtkVolumeProperty&) = delete;
578 };
579 
581 
585 {
587  {
588  return "Nearest Neighbor";
589  }
591  {
592  return "Linear";
593  }
594  return "Unknown";
595 }
597 
598 #endif
vtkVolumeProperty::DisableGradientOpacityOn
virtual void DisableGradientOpacityOn(int index)
Definition: vtkVolumeProperty.h:265
vtkVolumeProperty::LabelColorMTime
vtkTimeStamp LabelColorMTime
Definition: vtkVolumeProperty.h:544
vtkVolumeProperty::DisableGradientOpacityOff
virtual void DisableGradientOpacityOff()
Definition: vtkVolumeProperty.h:268
vtkVolumeProperty::GetSpecular
double GetSpecular()
Definition: vtkVolumeProperty.h:356
vtkVolumeProperty::SetScalarOpacityUnitDistance
void SetScalarOpacityUnitDistance(double distance)
Definition: vtkVolumeProperty.h:199
vtkVolumeProperty::GetGradientOpacity
vtkPiecewiseFunction * GetGradientOpacity()
Definition: vtkVolumeProperty.h:253
vtkX3D::value
@ value
Definition: vtkX3D.h:226
vtkVolumeProperty::GetGrayTransferFunction
vtkPiecewiseFunction * GetGrayTransferFunction()
Definition: vtkVolumeProperty.h:166
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkVolumeProperty::SliceFunction
vtkSmartPointer< vtkImplicitFunction > SliceFunction
Function used for slice.
Definition: vtkVolumeProperty.h:565
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkVolumeProperty::GetShade
int GetShade()
Definition: vtkVolumeProperty.h:322
vtkVolumeProperty::GetRGBTransferFunction
vtkColorTransferFunction * GetRGBTransferFunction()
Definition: vtkVolumeProperty.h:174
vtkVolumeProperty::SetSpecularPower
void SetSpecularPower(double value)
Definition: vtkVolumeProperty.h:364
vtkVolumeProperty::SetColor
void SetColor(vtkColorTransferFunction *function)
Definition: vtkVolumeProperty.h:151
vtkVolumeProperty::DisableGradientOpacityOn
virtual void DisableGradientOpacityOn()
Definition: vtkVolumeProperty.h:266
vtkSmartPointer< vtkImplicitFunction >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkVolumeProperty::ClippedVoxelIntensity
double ClippedVoxelIntensity
Definition: vtkVolumeProperty.h:554
vtkVolumeProperty::GetRGBTransferFunctionMTime
vtkTimeStamp GetRGBTransferFunctionMTime()
Definition: vtkVolumeProperty.h:412
vtkVolumeProperty::SetScalarOpacity
void SetScalarOpacity(vtkPiecewiseFunction *function)
Definition: vtkVolumeProperty.h:181
vtkVolumeProperty::GetTransferFunction2D
vtkImageData * GetTransferFunction2D()
Definition: vtkVolumeProperty.h:225
vtkVolumeProperty::IndependentComponents
vtkTypeBool IndependentComponents
Definition: vtkVolumeProperty.h:517
VTK_NEAREST_INTERPOLATION
#define VTK_NEAREST_INTERPOLATION
Definition: vtkSystemIncludes.h:94
vtkColorTransferFunction
Defines a transfer function for mapping a property to an RGB color value.
Definition: vtkColorTransferFunction.h:54
vtkVolumeProperty::SetGradientOpacity
void SetGradientOpacity(vtkPiecewiseFunction *function)
Definition: vtkVolumeProperty.h:212
vtkVolumeProperty::GetScalarOpacity
vtkPiecewiseFunction * GetScalarOpacity()
Definition: vtkVolumeProperty.h:189
vtkVolumeProperty::GetScalarOpacityUnitDistance
double GetScalarOpacityUnitDistance()
Definition: vtkVolumeProperty.h:204
vtkVolumeProperty::HasLabelGradientOpacity
bool HasLabelGradientOpacity()
Definition: vtkVolumeProperty.h:296
vtkImplicitFunction
abstract interface for implicit functions
Definition: vtkImplicitFunction.h:60
vtkVolumeProperty::GetScalarOpacityMTime
vtkTimeStamp GetScalarOpacityMTime()
Definition: vtkVolumeProperty.h:405
vtkVolumeProperty::LabelGradientOpacity
std::unordered_map< int, vtkPiecewiseFunction * > LabelGradientOpacity
Definition: vtkVolumeProperty.h:572
vtkVolumeProperty::InterpolationType
int InterpolationType
Definition: vtkVolumeProperty.h:520
vtkVolumeProperty::SetColor
void SetColor(vtkPiecewiseFunction *function)
Definition: vtkVolumeProperty.h:142
vtkVolumeProperty::HasGradientOpacity
bool HasGradientOpacity(int index=0)
Check whether or not we have the gradient opacity.
Definition: vtkVolumeProperty.h:281
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkContourValues
helper object to manage setting and generating contour values
Definition: vtkContourValues.h:35
vtkVolumeProperty::TransferMode
TransferMode
Color-opacity transfer function mode.
Definition: vtkVolumeProperty.h:234
vtkVolumeProperty::TransferFunctionMode
int TransferFunctionMode
Definition: vtkVolumeProperty.h:540
vtkVolumeProperty::GetStoredGradientOpacity
vtkPiecewiseFunction * GetStoredGradientOpacity()
Definition: vtkVolumeProperty.h:272
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartPointer.h
vtkVolumeProperty::ShadeOff
void ShadeOff()
Definition: vtkVolumeProperty.h:326
vtkVolumeProperty::GetGrayTransferFunctionMTime
vtkTimeStamp GetGrayTransferFunctionMTime()
Definition: vtkVolumeProperty.h:419
vtkNew< vtkContourValues >
vtkVolumeProperty::GetColorChannels
int GetColorChannels()
Definition: vtkVolumeProperty.h:158
VTK_LINEAR_INTERPOLATION
#define VTK_LINEAR_INTERPOLATION
Definition: vtkSystemIncludes.h:95
vtkVolumeProperty::SetDisableGradientOpacity
virtual void SetDisableGradientOpacity(int value)
Definition: vtkVolumeProperty.h:264
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkVolumeProperty::SetSpecular
void SetSpecular(double value)
Definition: vtkVolumeProperty.h:354
vtkVolumeProperty::UseClippedVoxelIntensity
int UseClippedVoxelIntensity
Definition: vtkVolumeProperty.h:555
vtkVolumeProperty::GetInterpolationTypeAsString
const char * GetInterpolationTypeAsString(void)
Return the interpolation type as a descriptive character string.
Definition: vtkVolumeProperty.h:584
vtkVolumeProperty::LabelScalarOpacityMTime
vtkTimeStamp LabelScalarOpacityMTime
Definition: vtkVolumeProperty.h:545
vtkObject.h
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:45
vtkVolumeProperty::GetTransferFunction2DMTime
vtkTimeStamp GetTransferFunction2DMTime()
Definition: vtkVolumeProperty.h:513
vtkVolumeProperty::GetGradientOpacityMTime
vtkTimeStamp GetGradientOpacityMTime()
Definition: vtkVolumeProperty.h:398
vtkNew.h
vtkVolumeProperty::DisableGradientOpacityOff
virtual void DisableGradientOpacityOff(int index)
Definition: vtkVolumeProperty.h:267
vtkVolumeProperty::SetInterpolationTypeToNearest
void SetInterpolationTypeToNearest()
Definition: vtkVolumeProperty.h:122
vtkImplicitFunction.h
vtkVolumeProperty::GetDisableGradientOpacity
virtual int GetDisableGradientOpacity()
Definition: vtkVolumeProperty.h:270
vtkVolumeProperty::LabelGradientOpacityMTime
vtkTimeStamp LabelGradientOpacityMTime
Definition: vtkVolumeProperty.h:546
vtkVolumeProperty::SetShade
void SetShade(int value)
Definition: vtkVolumeProperty.h:320
vtkVolumeProperty::LabelMapLabels
std::set< int > LabelMapLabels
Definition: vtkVolumeProperty.h:573
vtkVolumeProperty::LabelColor
std::unordered_map< int, vtkColorTransferFunction * > LabelColor
Label map transfer functions.
Definition: vtkVolumeProperty.h:570
vtkVolumeProperty::IsoSurfaceValues
vtkNew< vtkContourValues > IsoSurfaceValues
Contour values for isosurface blend mode.
Definition: vtkVolumeProperty.h:560
vtkVolumeProperty::SetInterpolationTypeToLinear
void SetInterpolationTypeToLinear()
Definition: vtkVolumeProperty.h:123
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkVolumeProperty::SetTransferFunction2D
void SetTransferFunction2D(vtkImageData *function)
Definition: vtkVolumeProperty.h:222
vtkVolumeProperty::GetAmbient
double GetAmbient()
Definition: vtkVolumeProperty.h:336
vtkVolumeProperty::LabelScalarOpacity
std::unordered_map< int, vtkPiecewiseFunction * > LabelScalarOpacity
Definition: vtkVolumeProperty.h:571
vtkVolumeProperty::GetSpecularPower
double GetSpecularPower()
Definition: vtkVolumeProperty.h:366
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkVolumeProperty::GetDiffuse
double GetDiffuse()
Definition: vtkVolumeProperty.h:346
vtkVolumeProperty
represents the common properties for rendering a volume.
Definition: vtkVolumeProperty.h:74
vtkVolumeProperty::ShadeOn
void ShadeOn()
Definition: vtkVolumeProperty.h:324
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
vtkVolumeProperty::SetAmbient
void SetAmbient(double value)
Definition: vtkVolumeProperty.h:334
VTK_MAX_VRCOMP
#define VTK_MAX_VRCOMP
Definition: vtkSystemIncludes.h:105
vtkVolumeProperty::SetDiffuse
void SetDiffuse(double value)
Definition: vtkVolumeProperty.h:344