VTK  9.6.1
vtkVolumeProperty.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
48
49#ifndef vtkVolumeProperty_h
50#define vtkVolumeProperty_h
51
52#include "vtkImplicitFunction.h" // For vtkImplicitFunction
53#include "vtkNew.h" // Needed for vtkNew
54#include "vtkObject.h"
55#include "vtkRenderingCoreModule.h" // For export macro
56#include "vtkSmartPointer.h" // Needed for vtkSmartPointer
57#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
58
59// STL includes
60#include <set> // For labelmap labels set
61#include <unordered_map> // For labelmap transfer function maps
62
63VTK_ABI_NAMESPACE_BEGIN
66class vtkImageData;
68class vtkTimeStamp;
69
70class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkVolumeProperty : public vtkObject
71{
72public:
75 void PrintSelf(ostream& os, vtkIndent indent) override;
77
83
85
106 vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
110
112
117 vtkGetMacro(InterpolationType, int);
120 const char* GetInterpolationTypeAsString();
122
124
128 virtual void SetComponentWeight(int index, double value);
129 virtual double GetComponentWeight(int index);
131
137 void SetColor(int index, vtkPiecewiseFunction* function);
138 void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
139
146 void SetColor(int index, vtkColorTransferFunction* function);
147 void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
148
153 int GetColorChannels(int index);
154 int GetColorChannels() { return this->GetColorChannels(0); }
155
165 {
166 SetColor(index, function);
167 }
169
179 {
180 SetColor(index, function);
181 }
183
189 void SetScalarOpacity(int index, vtkPiecewiseFunction* function);
191 void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
192
202
204
209 {
210 SetScalarOpacity(index, function);
211 };
215
217
223 void SetScalarOpacityUnitDistance(int index, double distance);
225 void SetScalarOpacityUnitDistance(double distance)
226 {
227 this->SetScalarOpacityUnitDistance(0, distance);
228 }
233
239 void SetGradientOpacity(int index, vtkPiecewiseFunction* function);
241 void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
242
244
250 {
251 this->SetGradientOpacity(index, function);
252 }
256
258
264 void SetTransferFunction2D(int index, vtkImageData* function);
266 void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); }
267
272
281 {
282 TF_1D = 0,
284 };
285
286 vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
287 vtkGetMacro(TransferFunctionMode, int);
291
304
306
313 virtual void SetDisableGradientOpacity(int index, int value);
315 virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
316 virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
318 virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
320 virtual int GetDisableGradientOpacity(int index);
322 virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
326
333 bool HasGradientOpacity(int index = 0)
334 {
335 switch (this->TransferFunctionMode)
336 {
337 case TF_1D:
338 return (this->GradientOpacity[index] != nullptr);
339 case TF_2D:
340 return true;
341 }
342 return false;
343 }
344
345 /*
346 * Check whether or not we have label map gradient opacity functions.
347 */
348 bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
349
351
371 void SetShade(int index, int value);
372 void SetShade(int value) { this->SetShade(0, value); }
373 int GetShade(int index);
374 int GetShade() { return this->GetShade(0); }
375 void ShadeOn(int index);
376 void ShadeOn() { this->ShadeOn(0); }
377 void ShadeOff(int index);
378 void ShadeOff() { this->ShadeOff(0); }
380
382
385 void SetAmbient(int index, double value);
386 void SetAmbient(double value) { this->SetAmbient(0, value); }
387 double GetAmbient(int index);
388 double GetAmbient() { return this->GetAmbient(0); }
390
392
395 void SetDiffuse(int index, double value);
396 void SetDiffuse(double value) { this->SetDiffuse(0, value); }
397 double GetDiffuse(int index);
398 double GetDiffuse() { return this->GetDiffuse(0); }
400
402
405 void SetSpecular(int index, double value);
406 void SetSpecular(double value) { this->SetSpecular(0, value); }
407 double GetSpecular(int index);
408 double GetSpecular() { return this->GetSpecular(0); }
410
412
415 void SetSpecularPower(int index, double value);
416 void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
417 double GetSpecularPower(int index);
418 double GetSpecularPower() { return this->GetSpecularPower(0); }
420
426
428
432 vtkSetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
433 vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
435
437
444 vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
445 vtkGetMacro(ScatteringAnisotropy, float);
447
456
463
470
477
484
486
495 vtkSetMacro(UseClippedVoxelIntensity, int);
496 vtkGetMacro(UseClippedVoxelIntensity, int);
497 vtkBooleanMacro(UseClippedVoxelIntensity, int);
499
501
510 vtkSetMacro(ClippedVoxelIntensity, double);
511 vtkGetMacro(ClippedVoxelIntensity, double);
513
515
518 void SetLabelColor(int label, vtkColorTransferFunction* function);
521
523
526 void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
529
531
537
543
549
555
560 std::size_t GetNumberOfLabels();
561
566 std::set<int> GetLabelMapLabels();
567
568protected:
571
578
579 virtual void CreateDefaultGradientOpacity(int index);
580
583
585
587
589
592
595
599
602
605
609
613
619
622
627
632
636 std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
637 std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
638 std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
639 std::set<int> LabelMapLabels;
640
641private:
642 vtkVolumeProperty(const vtkVolumeProperty&) = delete;
643 void operator=(const vtkVolumeProperty&) = delete;
644};
645
650{
652 {
653 return "Nearest Neighbor";
654 }
656 {
657 return "Linear";
658 }
659 return "Unknown";
660}
661
662VTK_ABI_NAMESPACE_END
663#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
abstract interface for implicit functions
a simple class to control print indentation
Definition vtkIndent.h:29
Allocate and hold a VTK object.
Definition vtkNew.h:58
Defines a 1D piecewise function.
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
void SetSpecular(int index, double value)
Set/Get the specular lighting coefficient.
void SetDiffuse(double value)
Set/Get the diffuse lighting coefficient.
void SetGradientOpacityFunction(int index, vtkPiecewiseFunction *function)
Set/Get the gradient magnitude opacity transfer function for the given component.
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 * GetGradientOpacityFunction(int index)
Set/Get the gradient magnitude opacity transfer function for the given component.
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()
int ColorChannels[VTK_MAX_VRCOMP]
void SetShade(int index, int value)
Set/Get the shading of a volume.
void ShadeOn()
Set/Get the shading of a volume.
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.
double Diffuse[VTK_MAX_VRCOMP]
void SetTransferFunction2D(vtkImageData *function)
Color-opacity transfer function mode.
int GetNumberOfScalarOpacityFunctions()
Get/Set the scalar opacity transfer function for the given component.
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.
virtual void SetInterpolationType(int)
Set the interpolation type for sampling a volume.
int GetNumberOfGradientOpacityFunctions()
Set/Get the gradient magnitude opacity transfer function for the given component.
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...
vtkPiecewiseFunction * ScalarOpacity[VTK_MAX_VRCOMP]
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.
vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP]
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.
double SpecularPower[VTK_MAX_VRCOMP]
vtkPiecewiseFunction * GrayTransferFunction[VTK_MAX_VRCOMP]
double ComponentWeight[VTK_MAX_VRCOMP]
virtual void DisableGradientOpacityOff(int index)
Enable/Disable the gradient opacity function for the given component.
double Specular[VTK_MAX_VRCOMP]
void ShadeOn(int index)
Set/Get the shading of a volume.
void ShadeOff(int index)
Set/Get the shading of a volume.
const char * GetInterpolationTypeAsString()
Return the interpolation type as a descriptive character string.
void SetShade(int value)
Set/Get the shading of a volume.
void SetGrayTransferFunction(int index, vtkPiecewiseFunction *function)
void SetScalarOpacityUnitDistance(int index, double distance)
Set/Get the unit distance on which the scalar opacity transfer function is defined.
void SetRGBTransferFunction(int index, vtkColorTransferFunction *function)
vtkPiecewiseFunction * GetScalarOpacity()
int GetNumberOfTransferFunction2Ds()
Color-opacity transfer function mode.
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.
vtkImageData * TransferFunction2D[VTK_MAX_VRCOMP]
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.
vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP]
vtkPiecewiseFunction * GetGradientOpacity()
vtkColorTransferFunction * RGBTransferFunction[VTK_MAX_VRCOMP]
virtual void SetDisableGradientOpacity(int value)
Enable/Disable the gradient opacity function for the given component.
double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP]
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.
double Ambient[VTK_MAX_VRCOMP]
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.
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 SetScalarOpacityFunction(int index, vtkPiecewiseFunction *function)
Get/Set the scalar opacity transfer function for the given component.
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 ...
vtkPiecewiseFunction * GetScalarOpacityFunction(int index)
Get/Set the scalar opacity transfer function for the given component.
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.
vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP]
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.
int DisableGradientOpacity[VTK_MAX_VRCOMP]
double GetAmbient()
Set/Get the ambient lighting coefficient.
void SetGradientOpacity(vtkPiecewiseFunction *function)
vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP]
vtkPiecewiseFunction * DefaultGradientOpacity[VTK_MAX_VRCOMP]
void SetScalarOpacity(vtkPiecewiseFunction *function)
double GetDiffuse(int index)
Set/Get the diffuse lighting coefficient.
vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP]
virtual int GetDisableGradientOpacity()
Enable/Disable the gradient opacity function for the given component.
int Shade[VTK_MAX_VRCOMP]
void SetColor(vtkColorTransferFunction *function)
~vtkVolumeProperty() override
double GetScalarOpacityUnitDistance(int index)
Set/Get the unit distance on which the scalar opacity transfer function is defined.
virtual void SetTransferFunctionMode(int)
Color-opacity transfer function mode.
vtkPiecewiseFunction * GradientOpacity[VTK_MAX_VRCOMP]
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.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_MAX_VRCOMP
#define VTK_NEAREST_INTERPOLATION
#define VTK_LINEAR_INTERPOLATION
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:323
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)