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
160#ifndef vtkVolumeProperty_h
161#define vtkVolumeProperty_h
162
163#include "vtkImplicitFunction.h" // For vtkImplicitFunction
164#include "vtkNew.h" // Needed for vtkNew
165#include "vtkObject.h"
166#include "vtkRenderingCoreModule.h" // For export macro
167#include "vtkSmartPointer.h" // Needed for vtkSmartPointer
168
169// STL includes
170#include <set> // For labelmap labels set
171#include <unordered_map> // For labelmap transfer function maps
172
174class vtkContourValues;
175class vtkImageData;
177class vtkTimeStamp;
178
179class VTKRENDERINGCORE_EXPORT vtkVolumeProperty : public vtkObject
180{
181public:
184 void PrintSelf(ostream& os, vtkIndent indent) override;
186
192
194
215 vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
216 vtkGetMacro(IndependentComponents, vtkTypeBool);
217 vtkBooleanMacro(IndependentComponents, vtkTypeBool);
219
221
225 vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
226 vtkGetMacro(InterpolationType, int);
227 void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
228 void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
229 const char* GetInterpolationTypeAsString(void);
231
233
237 virtual void SetComponentWeight(int index, double value);
238 virtual double GetComponentWeight(int index);
240
247 void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
248
256 void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
257
263 int GetColorChannels() { return this->GetColorChannels(0); }
264
272
280
287
295
297
303 void SetScalarOpacityUnitDistance(int index, double distance);
304 void SetScalarOpacityUnitDistance(double distance)
305 {
306 this->SetScalarOpacityUnitDistance(0, distance);
307 }
311
318
320
328
331
340 {
341 TF_1D = 0,
342 TF_2D
343 };
344
345 vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
346 vtkGetMacro(TransferFunctionMode, int);
347 void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
348 void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
350
361
363
370 virtual void SetDisableGradientOpacity(int index, int value);
371 virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
372 virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
374 virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
377 virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
381
389 {
390 switch (this->TransferFunctionMode)
391 {
392 case TF_1D:
393 return (this->GradientOpacity[index] != nullptr);
394 case TF_2D:
395 return true;
396 }
397 return false;
398 }
399
400 /*
401 * Check whether or not we have label map gradient opacity functions.
402 */
403 bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
404
406
426 void SetShade(int index, int value);
427 void SetShade(int value) { this->SetShade(0, value); }
428 int GetShade(int index);
429 int GetShade() { return this->GetShade(0); }
430 void ShadeOn(int index);
431 void ShadeOn() { this->ShadeOn(0); }
432 void ShadeOff(int index);
433 void ShadeOff() { this->ShadeOff(0); }
435
437
440 void SetAmbient(int index, double value);
441 void SetAmbient(double value) { this->SetAmbient(0, value); }
442 double GetAmbient(int index);
443 double GetAmbient() { return this->GetAmbient(0); }
445
447
450 void SetDiffuse(int index, double value);
451 void SetDiffuse(double value) { this->SetDiffuse(0, value); }
452 double GetDiffuse(int index);
453 double GetDiffuse() { return this->GetDiffuse(0); }
455
457
460 void SetSpecular(int index, double value);
461 void SetSpecular(double value) { this->SetSpecular(0, value); }
462 double GetSpecular(int index);
463 double GetSpecular() { return this->GetSpecular(0); }
465
467
470 void SetSpecularPower(int index, double value);
471 void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
473 double GetSpecularPower() { return this->GetSpecularPower(0); }
475
481
483
490
492
499 vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
500 vtkGetMacro(ScatteringAnisotropy, float);
502
511
518
525
532
539
541
550 vtkSetMacro(UseClippedVoxelIntensity, int);
551 vtkGetMacro(UseClippedVoxelIntensity, int);
552 vtkBooleanMacro(UseClippedVoxelIntensity, int);
554
556
565 vtkSetMacro(ClippedVoxelIntensity, double);
566 vtkGetMacro(ClippedVoxelIntensity, double);
568
570
576
578
584
586
592
597 vtkGetMacro(LabelColorMTime, vtkTimeStamp);
598
603 vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
604
609 vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
610
615 std::size_t GetNumberOfLabels();
616
621 std::set<int> GetLabelMapLabels();
622
623protected:
626
633
635
637 double ComponentWeight[VTK_MAX_VRCOMP];
638
640
641 float ScatteringAnisotropy = 0.0;
642
643 int ColorChannels[VTK_MAX_VRCOMP];
644
645 vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
646 vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
647
649 vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
650
652 vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
653 double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
654
656 vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
657
658 vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
659 int DisableGradientOpacity[VTK_MAX_VRCOMP];
660
662 vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
663 vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
664
668
669 int Shade[VTK_MAX_VRCOMP];
670 double Ambient[VTK_MAX_VRCOMP];
671 double Diffuse[VTK_MAX_VRCOMP];
672 double Specular[VTK_MAX_VRCOMP];
673 double SpecularPower[VTK_MAX_VRCOMP];
674
677
682
687
691 std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
692 std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
693 std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
694 std::set<int> LabelMapLabels;
695
696private:
697 vtkVolumeProperty(const vtkVolumeProperty&) = delete;
698 void operator=(const vtkVolumeProperty&) = delete;
699};
700
705{
707 {
708 return "Nearest Neighbor";
709 }
711 {
712 return "Linear";
713 }
714 return "Unknown";
715}
716
717#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:79
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.
void SetAmbient(int index, double value)
Set/Get the ambient lighting coefficient.
vtkMTimeType GetMTime() override
Get the modified time for this object (or the properties registered with this object).
double GetAmbient(int index)
Set/Get the ambient lighting coefficient.
virtual double GetComponentWeight(int index)
Set/Get the scalar component weights.
vtkPiecewiseFunction * GetLabelGradientOpacity(int label)
Set/Get the gradient opacity function for a label in the label map.
vtkTimeStamp LabelGradientOpacityMTime
vtkImageData * GetTransferFunction2D(int index)
Color-opacity transfer function mode.
vtkPiecewiseFunction * GetStoredGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
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.
vtkImageData * GetTransferFunction2D()
Color-opacity transfer function mode.
std::size_t GetNumberOfLabels()
Get the number of labels that are provided with transfer functions using either SetLabelColor,...
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.
vtkPiecewiseFunction * GetGrayTransferFunction()
void SetColor(vtkPiecewiseFunction *function)
vtkTimeStamp GetGrayTransferFunctionMTime(int index)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get the time that the GrayTransferFunction wa...
vtkTimeStamp LabelColorMTime
double GetSpecular()
Set/Get the specular lighting coefficient.
vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction)
Get/Set the function used for slicing.
vtkContourValues * GetIsoSurfaceValues()
Get contour values for isosurface blending mode.
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.
vtkPiecewiseFunction * GetStoredGradientOpacity(int index)
Enable/Disable the gradient opacity function for the given component.
vtkColorTransferFunction * GetRGBTransferFunction()
void SetTransferFunction2D(int index, vtkImageData *function)
Set/Get a 2D transfer function.
vtkTimeStamp GetScalarOpacityMTime()
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.
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.
vtkPiecewiseFunction * GetScalarOpacity()
std::unordered_map< int, vtkPiecewiseFunction * > LabelScalarOpacity
vtkPiecewiseFunction * GetScalarOpacity(int index)
Get the scalar opacity transfer function for the given component.
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.
vtkPiecewiseFunction * GetGradientOpacity()
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.
std::set< int > GetLabelMapLabels()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get access to the internal set that keeps tra...
int GetShade()
Set/Get the shading of a volume.
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.
const char * GetInterpolationTypeAsString(void)
Return the interpolation type as a descriptive character string.
vtkPiecewiseFunction * GetLabelScalarOpacity(int label)
Set/Get the opacity transfer function for a label in the label map.
virtual void DisableGradientOpacityOn()
Enable/Disable the gradient opacity function for the given component.
void DeepCopy(vtkVolumeProperty *p)
TransferMode
Color-opacity transfer function mode.
vtkTimeStamp GetRGBTransferFunctionMTime(int index)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Get the time that the RGBTransferFunction was...
static vtkVolumeProperty * New()
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.
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 * GetLabelColor(int label)
Set/Get the color transfer function for a label in the label map.
vtkPiecewiseFunction * GetGrayTransferFunction(int index)
Get the gray transfer function.
void SetInterpolationTypeToLinear()
Set the interpolation type for sampling a volume.
std::unordered_map< int, vtkPiecewiseFunction * > LabelGradientOpacity
vtkColorTransferFunction * GetRGBTransferFunction(int index)
Get the RGB transfer function for the given component.
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.
vtkPiecewiseFunction * GetGradientOpacity(int index)
Get the gradient magnitude opacity transfer function for the given component.
vtkTimeStamp LabelScalarOpacityMTime
double GetSpecular(int index)
Set/Get the specular lighting coefficient.
@ function
Definition: vtkX3D.h:255
@ 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