VTK  9.5.20250803
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
138#ifndef vtkVolumeProperty_h
139#define vtkVolumeProperty_h
140
141#include "vtkImplicitFunction.h" // For vtkImplicitFunction
142#include "vtkNew.h" // Needed for vtkNew
143#include "vtkObject.h"
144#include "vtkRenderingCoreModule.h" // For export macro
145#include "vtkSmartPointer.h" // Needed for vtkSmartPointer
146#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
147
148// STL includes
149#include <set> // For labelmap labels set
150#include <unordered_map> // For labelmap transfer function maps
151
152VTK_ABI_NAMESPACE_BEGIN
154class vtkContourValues;
155class vtkImageData;
157class vtkTimeStamp;
158
159class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkVolumeProperty : public vtkObject
160{
161public:
164 void PrintSelf(ostream& os, vtkIndent indent) override;
166
172
174
195 vtkSetClampMacro(IndependentComponents, vtkTypeBool, 0, 1);
196 vtkGetMacro(IndependentComponents, vtkTypeBool);
197 vtkBooleanMacro(IndependentComponents, vtkTypeBool);
199
201
205 vtkSetClampMacro(InterpolationType, int, VTK_NEAREST_INTERPOLATION, VTK_LINEAR_INTERPOLATION);
206 vtkGetMacro(InterpolationType, int);
207 void SetInterpolationTypeToNearest() { this->SetInterpolationType(VTK_NEAREST_INTERPOLATION); }
208 void SetInterpolationTypeToLinear() { this->SetInterpolationType(VTK_LINEAR_INTERPOLATION); }
209 const char* GetInterpolationTypeAsString();
211
213
217 virtual void SetComponentWeight(int index, double value);
218 virtual double GetComponentWeight(int index);
220
226 void SetColor(int index, vtkPiecewiseFunction* function);
227 void SetColor(vtkPiecewiseFunction* function) { this->SetColor(0, function); }
228
235 void SetColor(int index, vtkColorTransferFunction* function);
236 void SetColor(vtkColorTransferFunction* function) { this->SetColor(0, function); }
237
242 int GetColorChannels(int index);
243 int GetColorChannels() { return this->GetColorChannels(0); }
244
252 vtkPiecewiseFunction* GetGrayTransferFunction() { return this->GetGrayTransferFunction(0); }
254 {
255 SetColor(index, function);
256 }
258
266 vtkColorTransferFunction* GetRGBTransferFunction() { return this->GetRGBTransferFunction(0); }
268 {
269 SetColor(index, function);
270 }
272
278 void SetScalarOpacity(int index, vtkPiecewiseFunction* function);
280 void SetScalarOpacity(vtkPiecewiseFunction* function) { this->SetScalarOpacity(0, function); }
281
288 vtkPiecewiseFunction* GetScalarOpacity(int index);
290 vtkPiecewiseFunction* GetScalarOpacity() { return this->GetScalarOpacity(0); }
291
293
298 {
299 SetScalarOpacity(index, function);
300 };
301 vtkPiecewiseFunction* GetScalarOpacityFunction(int index) { return this->ScalarOpacity[index]; }
304
306
312 void SetScalarOpacityUnitDistance(int index, double distance);
314 void SetScalarOpacityUnitDistance(double distance)
315 {
316 this->SetScalarOpacityUnitDistance(0, distance);
317 }
320 double GetScalarOpacityUnitDistance() { return this->GetScalarOpacityUnitDistance(0); }
322
328 void SetGradientOpacity(int index, vtkPiecewiseFunction* function);
330 void SetGradientOpacity(vtkPiecewiseFunction* function) { this->SetGradientOpacity(0, function); }
331
333
339 {
340 this->SetGradientOpacity(index, function);
341 }
342 vtkPiecewiseFunction* GetGradientOpacityFunction(int index) { return GradientOpacity[index]; }
345
347
353 void SetTransferFunction2D(int index, vtkImageData* function);
355 void SetTransferFunction2D(vtkImageData* function) { this->SetTransferFunction2D(0, function); }
356
359 vtkImageData* GetTransferFunction2D() { return this->GetTransferFunction2D(0); }
361
370 {
371 TF_1D = 0,
372 TF_2D
373 };
374
375 vtkSetClampMacro(TransferFunctionMode, int, 0, 1);
376 vtkGetMacro(TransferFunctionMode, int);
377 void SetTransferFunctionModeTo1D() { this->SetTransferFunctionMode(TF_1D); }
378 void SetTransferFunctionModeTo2D() { this->SetTransferFunctionMode(TF_2D); }
380
390 vtkPiecewiseFunction* GetGradientOpacity(int index);
392 vtkPiecewiseFunction* GetGradientOpacity() { return this->GetGradientOpacity(0); }
393
395
402 virtual void SetDisableGradientOpacity(int index, int value);
404 virtual void SetDisableGradientOpacity(int value) { this->SetDisableGradientOpacity(0, value); }
405 virtual void DisableGradientOpacityOn(int index) { this->SetDisableGradientOpacity(index, 1); }
407 virtual void DisableGradientOpacityOff(int index) { this->SetDisableGradientOpacity(index, 0); }
409 virtual int GetDisableGradientOpacity(int index);
411 virtual int GetDisableGradientOpacity() { return this->GetDisableGradientOpacity(0); }
415
422 bool HasGradientOpacity(int index = 0)
423 {
424 switch (this->TransferFunctionMode)
425 {
426 case TF_1D:
427 return (this->GradientOpacity[index] != nullptr);
428 case TF_2D:
429 return true;
430 }
431 return false;
432 }
433
434 /*
435 * Check whether or not we have label map gradient opacity functions.
436 */
437 bool HasLabelGradientOpacity() { return !this->LabelGradientOpacity.empty(); }
438
440
460 void SetShade(int index, int value);
461 void SetShade(int value) { this->SetShade(0, value); }
462 int GetShade(int index);
463 int GetShade() { return this->GetShade(0); }
464 void ShadeOn(int index);
465 void ShadeOn() { this->ShadeOn(0); }
466 void ShadeOff(int index);
467 void ShadeOff() { this->ShadeOff(0); }
469
471
474 void SetAmbient(int index, double value);
475 void SetAmbient(double value) { this->SetAmbient(0, value); }
476 double GetAmbient(int index);
477 double GetAmbient() { return this->GetAmbient(0); }
479
481
484 void SetDiffuse(int index, double value);
485 void SetDiffuse(double value) { this->SetDiffuse(0, value); }
486 double GetDiffuse(int index);
487 double GetDiffuse() { return this->GetDiffuse(0); }
489
491
494 void SetSpecular(int index, double value);
495 void SetSpecular(double value) { this->SetSpecular(0, value); }
496 double GetSpecular(int index);
497 double GetSpecular() { return this->GetSpecular(0); }
499
501
504 void SetSpecularPower(int index, double value);
505 void SetSpecularPower(double value) { this->SetSpecularPower(0, value); }
506 double GetSpecularPower(int index);
507 double GetSpecularPower() { return this->GetSpecularPower(0); }
509
515
517
521 vtkSetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
522 vtkGetSmartPointerMacro(SliceFunction, vtkImplicitFunction);
524
526
533 vtkSetClampMacro(ScatteringAnisotropy, float, -1.0, 1.0);
534 vtkGetMacro(ScatteringAnisotropy, float);
536
545
552
559
566
573
575
584 vtkSetMacro(UseClippedVoxelIntensity, int);
585 vtkGetMacro(UseClippedVoxelIntensity, int);
586 vtkBooleanMacro(UseClippedVoxelIntensity, int);
588
590
599 vtkSetMacro(ClippedVoxelIntensity, double);
600 vtkGetMacro(ClippedVoxelIntensity, double);
602
604
607 void SetLabelColor(int label, vtkColorTransferFunction* function);
610
612
615 void SetLabelScalarOpacity(int label, vtkPiecewiseFunction* function);
618
620
626
631 vtkGetMacro(LabelColorMTime, vtkTimeStamp);
632
637 vtkGetMacro(LabelScalarOpacityMTime, vtkTimeStamp);
638
643 vtkGetMacro(LabelGradientOpacityMTime, vtkTimeStamp);
644
649 std::size_t GetNumberOfLabels();
650
655 std::set<int> GetLabelMapLabels();
656
657protected:
660
667
668 virtual void CreateDefaultGradientOpacity(int index);
669
671 double ComponentWeight[VTK_MAX_VRCOMP];
672
674
675 float ScatteringAnisotropy = 0.0;
676
677 int ColorChannels[VTK_MAX_VRCOMP];
678
679 vtkPiecewiseFunction* GrayTransferFunction[VTK_MAX_VRCOMP];
680 vtkTimeStamp GrayTransferFunctionMTime[VTK_MAX_VRCOMP];
681
683 vtkTimeStamp RGBTransferFunctionMTime[VTK_MAX_VRCOMP];
684
686 vtkTimeStamp ScalarOpacityMTime[VTK_MAX_VRCOMP];
687 double ScalarOpacityUnitDistance[VTK_MAX_VRCOMP];
688
690 vtkTimeStamp GradientOpacityMTime[VTK_MAX_VRCOMP];
691
692 vtkPiecewiseFunction* DefaultGradientOpacity[VTK_MAX_VRCOMP];
693 int DisableGradientOpacity[VTK_MAX_VRCOMP];
694
696 vtkImageData* TransferFunction2D[VTK_MAX_VRCOMP];
697 vtkTimeStamp TransferFunction2DMTime[VTK_MAX_VRCOMP];
698
702
703 int Shade[VTK_MAX_VRCOMP];
704 double Ambient[VTK_MAX_VRCOMP];
705 double Diffuse[VTK_MAX_VRCOMP];
706 double Specular[VTK_MAX_VRCOMP];
707 double SpecularPower[VTK_MAX_VRCOMP];
708
711
716
721
725 std::unordered_map<int, vtkColorTransferFunction*> LabelColor;
726 std::unordered_map<int, vtkPiecewiseFunction*> LabelScalarOpacity;
727 std::unordered_map<int, vtkPiecewiseFunction*> LabelGradientOpacity;
728 std::set<int> LabelMapLabels;
729
730private:
731 vtkVolumeProperty(const vtkVolumeProperty&) = delete;
732 void operator=(const vtkVolumeProperty&) = delete;
733};
734
739{
741 {
742 return "Nearest Neighbor";
743 }
745 {
746 return "Linear";
747 }
748 return "Unknown";
749}
750
751VTK_ABI_NAMESPACE_END
752#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:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract base class for most VTK objects
Definition vtkObject.h:162
Defines a 1D piecewise function.
Hold a reference to a vtkObjectBase instance.
record modification and/or execution time
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 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()
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.
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.
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 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.
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
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.
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.
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)
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.
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:287
#define VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)