VTK
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 "vtkNew.h" // Needed for vtkNew
59 #include "vtkRenderingCoreModule.h" // For export macro
60 #include "vtkObject.h"
61 
63 class vtkContourValues;
64 class vtkImageData;
66 class vtkTimeStamp;
67 
68 class VTKRENDERINGCORE_EXPORT vtkVolumeProperty : public vtkObject
69 {
70 public:
71  static vtkVolumeProperty *New();
72  vtkTypeMacro(vtkVolumeProperty, vtkObject);
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74  void DeepCopy(vtkVolumeProperty *p);
75 
80  vtkMTimeType GetMTime() override;
81 
83 
104  vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
105  vtkGetMacro(IndependentComponents, vtkTypeBool);
106  vtkBooleanMacro(IndependentComponents, vtkTypeBool);
108 
110 
114  vtkSetClampMacro(InterpolationType, int,
116  vtkGetMacro(InterpolationType, int);
118  { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
120  { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
121  const char *GetInterpolationTypeAsString(void);
123 
125 
129  virtual void SetComponentWeight(int index, double value);
130  virtual double GetComponentWeight(int index);
132 
138  void SetColor(int index, vtkPiecewiseFunction *function);
140  { this->SetColor(0, function); }
141 
148  void SetColor(int index, vtkColorTransferFunction *function);
150  { this->SetColor(0, function); }
151 
156  int GetColorChannels(int index);
158  { return this->GetColorChannels(0); }
159 
165  vtkPiecewiseFunction *GetGrayTransferFunction(int index);
167  { return this->GetGrayTransferFunction(0); }
168 
174  vtkColorTransferFunction *GetRGBTransferFunction(int index);
176  { return this->GetRGBTransferFunction(0); }
177 
182  void SetScalarOpacity(int index, vtkPiecewiseFunction *function);
184  { this->SetScalarOpacity(0, function); }
185 
191  vtkPiecewiseFunction *GetScalarOpacity(int index);
193  { return this->GetScalarOpacity(0); }
194 
196 
202  void SetScalarOpacityUnitDistance(int index, double distance);
203  void SetScalarOpacityUnitDistance(double distance)
204  { this->SetScalarOpacityUnitDistance(0, distance); }
205  double GetScalarOpacityUnitDistance(int index);
207  { return this->GetScalarOpacityUnitDistance(0); }
209 
210 
215  void SetGradientOpacity(int index, vtkPiecewiseFunction *function);
217  { this->SetGradientOpacity(0, function); }
218 
220 
226  void SetTransferFunction2D(int index, vtkImageData* function);
228  {
229  this->SetTransferFunction2D(0, function);
230  };
231 
232  vtkImageData* GetTransferFunction2D(int index);
234  {
235  return this->GetTransferFunction2D(0);
236  };
237 
246  {
247  TF_1D = 0,
248  TF_2D
249  };
250 
251  vtkSetClampMacro(TransferFunctionMode, int, 0, 1)
252  vtkGetMacro(TransferFunctionMode, int)
254 
263  vtkPiecewiseFunction *GetGradientOpacity(int index);
264  vtkPiecewiseFunction *GetGradientOpacity()
265  { return this->GetGradientOpacity(0); }
266 
268 
275  virtual void SetDisableGradientOpacity(int index, int value);
276  virtual void SetDisableGradientOpacity(int value)
277  { this->SetDisableGradientOpacity(0, value); }
278  virtual void DisableGradientOpacityOn(int index )
279  { this->SetDisableGradientOpacity(index, 1); }
281  { this->DisableGradientOpacityOn(0); }
282  virtual void DisableGradientOpacityOff(int index)
283  { this->SetDisableGradientOpacity(index, 0); }
285  { this->DisableGradientOpacityOff(0); }
286  virtual int GetDisableGradientOpacity(int index);
288  { return this->GetDisableGradientOpacity(0); }
289  vtkPiecewiseFunction *GetStoredGradientOpacity(int index);
291  { return this->GetStoredGradientOpacity(0); }
293 
300  bool HasGradientOpacity(int index = 0) {
301  switch(this->TransferFunctionMode) {
302  case TF_1D: return (this->GradientOpacity[index] != nullptr);
303  case TF_2D: return true;
304  }
305  return false;
306  }
307 
309 
329  void SetShade(int index, int value);
330  void SetShade(int value)
331  { this->SetShade(0,value); }
332  int GetShade(int index);
333  int GetShade()
334  { return this->GetShade(0); }
335  void ShadeOn(int index);
336  void ShadeOn()
337  { this->ShadeOn(0); }
338  void ShadeOff(int index);
339  void ShadeOff()
340  { this->ShadeOff(0); }
342 
344 
347  void SetAmbient(int index, double value);
348  void SetAmbient(double value)
349  { this->SetAmbient(0, value); }
350  double GetAmbient(int index);
351  double GetAmbient()
352  { return this->GetAmbient(0); }
354 
356 
359  void SetDiffuse(int index, double value);
360  void SetDiffuse(double value)
361  { this->SetDiffuse(0, value); }
362  double GetDiffuse(int index);
363  double GetDiffuse()
364  { return this->GetDiffuse(0); }
366 
368 
371  void SetSpecular(int index, double value);
372  void SetSpecular(double value)
373  { this->SetSpecular(0, value); }
374  double GetSpecular(int index);
375  double GetSpecular()
376  { return this->GetSpecular(0); }
378 
380 
383  void SetSpecularPower(int index, double value);
384  void SetSpecularPower(double value)
385  { this->SetSpecularPower(0, value); }
386  double GetSpecularPower(int index);
388  { return this->GetSpecularPower(0); }
390 
395  vtkContourValues* GetIsoSurfaceValues();
396 
404  void UpdateMTimes();
405 
410  vtkTimeStamp GetGradientOpacityMTime(int index);
412  { return this->GetGradientOpacityMTime(0); }
413 
418  vtkTimeStamp GetScalarOpacityMTime(int index);
420  { return this->GetScalarOpacityMTime(0); }
421 
426  vtkTimeStamp GetRGBTransferFunctionMTime(int index);
428  { return this->GetRGBTransferFunctionMTime(0); }
429 
434  vtkTimeStamp GetGrayTransferFunctionMTime(int index);
436  { return this->GetGrayTransferFunctionMTime(0); }
437 
439 
448  vtkSetMacro(UseClippedVoxelIntensity, int);
449  vtkGetMacro(UseClippedVoxelIntensity, int);
450  vtkBooleanMacro(UseClippedVoxelIntensity, int);
452 
454 
463  vtkSetMacro(ClippedVoxelIntensity, double);
464  vtkGetMacro(ClippedVoxelIntensity, double);
466 
467 
468 protected:
470  ~vtkVolumeProperty() override;
471 
476  vtkTimeStamp GetTransferFunction2DMTime(int index);
478  {
479  return this->GetTransferFunction2DMTime(0);
480  }
481 
482  virtual void CreateDefaultGradientOpacity(int index);
483 
485  double ComponentWeight[VTK_MAX_VRCOMP];
486 
488 
489  int ColorChannels[VTK_MAX_VRCOMP];
490 
491  vtkPiecewiseFunction *GrayTransferFunction[VTK_MAX_VRCOMP];
492  vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
493 
495  vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
496 
498  vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
499  double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
500 
502  vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
503 
504  vtkPiecewiseFunction *DefaultGradientOpacity[VTK_MAX_VRCOMP];
505  int DisableGradientOpacity[VTK_MAX_VRCOMP];
506 
508  vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
509  vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
510 
511  int Shade[VTK_MAX_VRCOMP];
512  double Ambient[VTK_MAX_VRCOMP];
513  double Diffuse[VTK_MAX_VRCOMP];
514  double Specular[VTK_MAX_VRCOMP];
515  double SpecularPower[VTK_MAX_VRCOMP];
516 
519 
524 
525 private:
526  vtkVolumeProperty(const vtkVolumeProperty&) = delete;
527  void operator=(const vtkVolumeProperty&) = delete;
528 };
529 
531 
535 {
536  if (this->InterpolationType == VTK_NEAREST_INTERPOLATION)
537  {
538  return "Nearest Neighbor";
539  }
540  if (this->InterpolationType == VTK_LINEAR_INTERPOLATION)
541  {
542  return "Linear";
543  }
544  return "Unknown";
545 }
547 
548 #endif
int GetShade()
Set/Get the shading of a volume.
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:59
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:302
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)
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.
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:45
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.
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.
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.
#define VTK_NEAREST_INTERPOLATION
void ShadeOn()
Set/Get the shading of a volume.
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.
double GetAmbient()
Set/Get the ambient lighting coefficient.
double GetSpecularPower()
Set/Get the specular power.