VTK  9.7.1
vtkProperty.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
25 #ifndef vtkProperty_h
26 #define vtkProperty_h
27 
28 #include "vtkObject.h"
29 #include "vtkRenderingCoreModule.h" // For export macro
30 #include "vtkSetGet.h"
31 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
32 
33 #include <map> // used for ivar
34 #include <string> // used for ivar
35 
36 // shading models
37 #define VTK_FLAT 0
38 #define VTK_GOURAUD 1
39 #define VTK_PHONG 2
40 #define VTK_PBR 3
41 
42 // representation models
43 #define VTK_POINTS 0
44 #define VTK_WIREFRAME 1
45 #define VTK_SURFACE 2
46 
47 VTK_ABI_NAMESPACE_BEGIN
48 class vtkActor;
49 class vtkInformation;
50 class vtkRenderer;
51 class vtkShaderProgram;
52 class vtkTexture;
53 class vtkWindow;
54 class vtkXMLDataElement;
55 class vtkXMLMaterial;
56 
57 class vtkPropertyInternals;
58 
59 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkProperty : public vtkObject
60 {
61 public:
62  vtkTypeMacro(vtkProperty, vtkObject);
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
71  static vtkProperty* New();
72 
76  void DeepCopy(vtkProperty* p);
77 
85  virtual void Render(vtkActor*, vtkRenderer*);
86 
93  virtual void BackfaceRender(vtkActor*, vtkRenderer*) {}
94 
100  virtual void PostRender(vtkActor*, vtkRenderer*);
101 
103 
106  vtkGetMacro(Lighting, bool);
107  vtkSetMacro(Lighting, bool);
108  vtkBooleanMacro(Lighting, bool);
110 
111  enum class Point2DShapeType
112  {
113  Round,
114  Square,
115  };
116 
121  vtkSetEnumMacro(Point2DShape, Point2DShapeType);
122  vtkGetEnumMacro(Point2DShape, Point2DShapeType);
123 
125 
131  vtkGetMacro(RenderPointsAsSpheres, bool);
132  vtkSetMacro(RenderPointsAsSpheres, bool);
133  vtkBooleanMacro(RenderPointsAsSpheres, bool);
135 
136  enum class LineJoinType
137  {
138  RoundCapRoundJoin,
139  MiterJoin,
140  NoJoin,
141  };
142 
147  vtkSetEnumMacro(LineJoin, LineJoinType);
148  vtkGetEnumMacro(LineJoin, LineJoinType);
149 
151 
158  vtkGetMacro(RenderLinesAsTubes, bool);
159  vtkSetMacro(RenderLinesAsTubes, bool);
160  vtkBooleanMacro(RenderLinesAsTubes, bool);
162 
164 
167  vtkSetClampMacro(Interpolation, int, VTK_FLAT, VTK_PBR);
168  vtkGetMacro(Interpolation, int);
169  void SetInterpolationToFlat() { this->SetInterpolation(VTK_FLAT); }
170  void SetInterpolationToGouraud() { this->SetInterpolation(VTK_GOURAUD); }
171  void SetInterpolationToPhong() { this->SetInterpolation(VTK_PHONG); }
172  void SetInterpolationToPBR() { this->SetInterpolation(VTK_PBR); }
173  const char* GetInterpolationAsString();
175 
177 
180  vtkSetClampMacro(Representation, int, VTK_POINTS, VTK_SURFACE);
181  vtkGetMacro(Representation, int);
182  void SetRepresentationToPoints() { this->SetRepresentation(VTK_POINTS); }
183  void SetRepresentationToWireframe() { this->SetRepresentation(VTK_WIREFRAME); }
184  void SetRepresentationToSurface() { this->SetRepresentation(VTK_SURFACE); }
185  const char* GetRepresentationAsString();
187 
189 
194  virtual void SetColor(double r, double g, double b);
195  virtual void SetColor(double a[3]);
196  double* GetColor() VTK_SIZEHINT(3);
197  void GetColor(double rgb[3]);
198  void GetColor(double& r, double& g, double& b);
200 
202 
213  vtkSetClampMacro(BaseIOR, double, 1.0, VTK_FLOAT_MAX);
214  vtkGetMacro(BaseIOR, double);
216 
218 
224  vtkSetClampMacro(Metallic, double, 0.0, 1.0);
225  vtkGetMacro(Metallic, double);
227 
229 
236  vtkSetClampMacro(Roughness, double, 0.0, 1.0);
237  vtkGetMacro(Roughness, double);
239 
241 
247  vtkSetClampMacro(Anisotropy, double, 0.0, 1.0);
248  vtkGetMacro(Anisotropy, double);
250 
252 
258  vtkSetClampMacro(AnisotropyRotation, double, 0.0, 1.0);
259  vtkGetMacro(AnisotropyRotation, double);
261 
263 
268  vtkSetClampMacro(CoatIOR, double, 1.0, VTK_FLOAT_MAX);
269  vtkGetMacro(CoatIOR, double);
271 
273 
279  vtkSetClampMacro(CoatRoughness, double, 0.0, 1.0);
280  vtkGetMacro(CoatRoughness, double);
282 
284 
290  vtkSetClampMacro(CoatStrength, double, 0.0, 1.0);
291  vtkGetMacro(CoatStrength, double);
293 
295 
300  vtkSetVector3Macro(CoatColor, double);
301  vtkGetVector3Macro(CoatColor, double);
303 
305 
311  vtkSetClampMacro(CoatNormalScale, double, 0.0, 1.0);
312  vtkGetMacro(CoatNormalScale, double);
314 
316 
321  vtkSetMacro(NormalScale, double);
322  vtkGetMacro(NormalScale, double);
324 
326 
332  vtkSetClampMacro(OcclusionStrength, double, 0.0, 1.0);
333  vtkGetMacro(OcclusionStrength, double);
335 
337 
343  vtkSetVector3Macro(EmissiveFactor, double);
344  vtkGetVector3Macro(EmissiveFactor, double);
346 
348 
354  vtkSetVector3Macro(EdgeTint, double);
355  vtkGetVector3Macro(EdgeTint, double);
357 
359 
362  vtkSetClampMacro(Ambient, double, 0.0, 1.0);
363  vtkGetMacro(Ambient, double);
365 
367 
370  vtkSetClampMacro(Diffuse, double, 0.0, 1.0);
371  vtkGetMacro(Diffuse, double);
373 
375 
378  vtkSetClampMacro(Specular, double, 0.0, 1.0);
379  vtkGetMacro(Specular, double);
381 
383 
386  vtkSetClampMacro(SpecularPower, double, 0.0, 128.0);
387  vtkGetMacro(SpecularPower, double);
389 
391 
395  vtkSetClampMacro(Opacity, double, 0.0, 1.0);
396  vtkGetMacro(Opacity, double);
398 
400 
404  vtkSetClampMacro(EdgeOpacity, double, 0.0, 1.0);
405  vtkGetMacro(EdgeOpacity, double);
407 
409 
415  vtkSetVector3Macro(AmbientColor, double);
416  vtkGetVector3Macro(AmbientColor, double);
418 
420 
424  vtkSetVector3Macro(DiffuseColor, double);
425  vtkGetVector3Macro(DiffuseColor, double);
427 
429 
432  vtkSetVector3Macro(SpecularColor, double);
433  vtkGetVector3Macro(SpecularColor, double);
435 
437 
442  vtkGetMacro(EdgeVisibility, vtkTypeBool);
443  vtkSetMacro(EdgeVisibility, vtkTypeBool);
444  vtkBooleanMacro(EdgeVisibility, vtkTypeBool);
446 
448 
451  vtkSetVector3Macro(EdgeColor, double);
452  vtkGetVector3Macro(EdgeColor, double);
454 
456 
461  vtkGetMacro(VertexVisibility, vtkTypeBool);
462  vtkSetMacro(VertexVisibility, vtkTypeBool);
463  vtkBooleanMacro(VertexVisibility, vtkTypeBool);
465 
467 
470  vtkSetVector3Macro(VertexColor, double);
471  vtkGetVector3Macro(VertexColor, double);
473 
475 
479  vtkSetVector4Macro(SelectionColor, double);
480  vtkGetVector4Macro(SelectionColor, double);
482 
484 
488  vtkSetMacro(SelectionLineWidth, float);
489  vtkGetMacro(SelectionLineWidth, float);
491 
493 
497  vtkSetMacro(SelectionPointSize, float);
498  vtkGetMacro(SelectionPointSize, float);
500 
502 
506  vtkSetClampMacro(LineWidth, float, 0, VTK_FLOAT_MAX);
507  vtkGetMacro(LineWidth, float);
509 
511 
517  vtkSetClampMacro(EdgeWidth, float, 0, VTK_FLOAT_MAX);
518  vtkGetMacro(EdgeWidth, float);
520 
522 
529  vtkBooleanMacro(UseLineWidthForEdgeThickness, bool);
530  vtkSetMacro(UseLineWidthForEdgeThickness, bool);
531  vtkGetMacro(UseLineWidthForEdgeThickness, bool);
533 
535 
540  vtkSetMacro(LineStipplePattern, int);
541  vtkGetMacro(LineStipplePattern, int);
543 
545 
550  vtkSetClampMacro(LineStippleRepeatFactor, int, 1, VTK_INT_MAX);
551  vtkGetMacro(LineStippleRepeatFactor, int);
553 
555 
559  vtkSetClampMacro(PointSize, float, 0, VTK_FLOAT_MAX);
560  vtkGetMacro(PointSize, float);
562 
564 
569  vtkGetMacro(BackfaceCulling, vtkTypeBool);
570  vtkSetMacro(BackfaceCulling, vtkTypeBool);
571  vtkBooleanMacro(BackfaceCulling, vtkTypeBool);
573 
575 
580  vtkGetMacro(FrontfaceCulling, vtkTypeBool);
581  vtkSetMacro(FrontfaceCulling, vtkTypeBool);
582  vtkBooleanMacro(FrontfaceCulling, vtkTypeBool);
584 
586 
589  vtkSetStringMacro(MaterialName);
590  vtkGetStringMacro(MaterialName);
592 
594 
598  vtkSetMacro(Shading, vtkTypeBool);
599  vtkGetMacro(Shading, vtkTypeBool);
600  vtkBooleanMacro(Shading, vtkTypeBool);
602 
604 
608  vtkSetMacro(ShowTexturesOnBackface, bool);
609  vtkGetMacro(ShowTexturesOnBackface, bool);
610  vtkBooleanMacro(ShowTexturesOnBackface, bool);
612 
614 
627  void SetTexture(const char* name, vtkTexture* texture);
628  vtkTexture* GetTexture(const char* name);
630 
637  void SetBaseColorTexture(vtkTexture* texture) { this->SetTexture("albedoTex", texture); }
638 
648  void SetORMTexture(vtkTexture* texture) { this->SetTexture("materialTex", texture); }
649 
660  void SetAnisotropyTexture(vtkTexture* texture) { this->SetTexture("anisotropyTex", texture); }
661 
670  void SetNormalTexture(vtkTexture* texture) { this->SetTexture("normalTex", texture); }
671 
679  void SetEmissiveTexture(vtkTexture* texture) { this->SetTexture("emissiveTex", texture); }
680 
689  void SetCoatNormalTexture(vtkTexture* texture) { this->SetTexture("coatNormalTex", texture); }
690 
694  void RemoveTexture(const char* name);
695 
699  void RemoveAllTextures();
700 
704  int GetNumberOfTextures();
705 
707 
710  void SetAllTextures(std::map<std::string, vtkTexture*>& textures);
711  std::map<std::string, vtkTexture*>& GetAllTextures() { return this->Textures; }
713 
719  virtual void ReleaseGraphicsResources(vtkWindow* win);
720 
722 
725  vtkGetObjectMacro(Information, vtkInformation);
726  virtual void SetInformation(vtkInformation*);
728 
730 
734  static double ComputeReflectanceFromIOR(double IORTo, double IORFrom);
736 
738 
742  static double ComputeIORFromReflectance(double reflectance, double ior);
744 
746 
752  double ComputeReflectanceOfBaseLayer();
754 
755 protected:
756  vtkProperty();
757  ~vtkProperty() override;
758 
762  static void ComputeCompositeColor(double result[3], double ambient, const double ambient_color[3],
763  double diffuse, const double diffuse_color[3], double specular, const double specular_color[3]);
764 
765  double Color[3];
766  double AmbientColor[3];
767  double DiffuseColor[3];
768  double SpecularColor[3];
769  double EdgeColor[3];
770  double VertexColor[3];
771  double SelectionColor[4] = { 1.0, 0.0, 0.0, 1.0 };
772  double Ambient;
773  double Diffuse;
774  double Metallic;
775  double Roughness;
776  double Anisotropy;
778  double BaseIOR;
779  double CoatIOR;
780  double CoatColor[3];
782  double CoatStrength;
784  double NormalScale;
786  double EmissiveFactor[3];
787  double Specular;
789  double Opacity;
790  double EdgeOpacity = 1.0;
791  double EdgeTint[3];
792  float PointSize;
793  float LineWidth;
794  float EdgeWidth = 1.0;
795  float SelectionPointSize = 2.f;
796  float SelectionLineWidth = 2.f;
797  bool UseLineWidthForEdgeThickness = true;
806  bool Lighting;
807  Point2DShapeType Point2DShape = Point2DShapeType::Square;
809  LineJoinType LineJoin = LineJoinType::NoJoin;
812 
814 
816 
817  typedef std::map<std::string, vtkTexture*> MapOfTextures;
818  MapOfTextures Textures;
819 
820  // Arbitrary extra information associated with this Property.
822 
823 private:
824  vtkProperty(const vtkProperty&) = delete;
825  void operator=(const vtkProperty&) = delete;
826 };
827 
832 {
833  if (this->Interpolation == VTK_FLAT)
834  {
835  return "Flat";
836  }
837  else if (this->Interpolation == VTK_GOURAUD)
838  {
839  return "Gouraud";
840  }
841  else if (this->Interpolation == VTK_PHONG)
842  {
843  return "Phong";
844  }
845  else // if (this->Interpolation == VTK_PBR)
846  {
847  return "Physically based rendering";
848  }
849 }
850 
855 {
856  if (this->Representation == VTK_POINTS)
857  {
858  return "Points";
859  }
860  else if (this->Representation == VTK_WIREFRAME)
861  {
862  return "Wireframe";
863  }
864  else
865  {
866  return "Surface";
867  }
868 }
869 
870 VTK_ABI_NAMESPACE_END
871 #endif
double Opacity
Definition: vtkProperty.h:789
void SetORMTexture(vtkTexture *texture)
Set the ORM texture.
Definition: vtkProperty.h:648
double Anisotropy
Definition: vtkProperty.h:776
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
double BaseIOR
Definition: vtkProperty.h:778
void SetInterpolationToPhong()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:171
abstract base class for most VTK objects
Definition: vtkObject.h:52
float PointSize
Definition: vtkProperty.h:792
bool RenderLinesAsTubes
Definition: vtkProperty.h:810
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Represents an XML element and those nested inside.
int LineStipplePattern
Definition: vtkProperty.h:798
vtkTypeBool EdgeVisibility
Definition: vtkProperty.h:802
Store vtkAlgorithm input/output information.
float LineWidth
Definition: vtkProperty.h:793
represent surface properties of a geometric object
Definition: vtkProperty.h:59
const char * GetRepresentationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:854
#define VTK_SURFACE
Definition: vtkProperty.h:45
#define VTK_INT_MAX
Definition: vtkType.h:192
void SetInterpolationToPBR()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:172
void SetInterpolationToFlat()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:169
double CoatRoughness
Definition: vtkProperty.h:781
double Ambient
Definition: vtkProperty.h:772
double SpecularPower
Definition: vtkProperty.h:788
char * MaterialName
Definition: vtkProperty.h:815
abstract specification for renderers
Definition: vtkRenderer.h:63
double Metallic
Definition: vtkProperty.h:774
bool ShowTexturesOnBackface
Definition: vtkProperty.h:811
std::map< std::string, vtkTexture * > MapOfTextures
Definition: vtkProperty.h:817
double CoatStrength
Definition: vtkProperty.h:782
void SetEmissiveTexture(vtkTexture *texture)
Set the emissive texture.
Definition: vtkProperty.h:679
void SetRepresentationToPoints()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:182
void SetInterpolationToGouraud()
Set the shading interpolation method for an object.
Definition: vtkProperty.h:170
double Roughness
Definition: vtkProperty.h:775
int vtkTypeBool
Definition: vtkABI.h:64
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
double Diffuse
Definition: vtkProperty.h:773
double CoatNormalScale
Definition: vtkProperty.h:783
#define VTK_FLOAT_MAX
Definition: vtkType.h:200
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetCoatNormalTexture(vtkTexture *texture)
Set the coat normal texture.
Definition: vtkProperty.h:689
#define VTK_FLAT
Definition: vtkProperty.h:37
void SetRepresentationToWireframe()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:183
double NormalScale
Definition: vtkProperty.h:784
int Interpolation
Definition: vtkProperty.h:800
handles properties associated with a texture map
Definition: vtkTexture.h:58
int Representation
Definition: vtkProperty.h:801
void SetRepresentationToSurface()
Control the surface geometry representation for the object.
Definition: vtkProperty.h:184
double CoatIOR
Definition: vtkProperty.h:779
void SetNormalTexture(vtkTexture *texture)
Set the normal texture.
Definition: vtkProperty.h:670
#define VTK_SIZEHINT(...)
double OcclusionStrength
Definition: vtkProperty.h:785
#define VTK_POINTS
Definition: vtkProperty.h:43
void SetAnisotropyTexture(vtkTexture *texture)
Set the anisotropy texture.
Definition: vtkProperty.h:660
#define VTK_GOURAUD
Definition: vtkProperty.h:38
vtkTypeBool Shading
Definition: vtkProperty.h:813
#define VTK_PHONG
Definition: vtkProperty.h:39
virtual void BackfaceRender(vtkActor *, vtkRenderer *)
This method renders the property as a backface property.
Definition: vtkProperty.h:93
vtkTypeBool FrontfaceCulling
Definition: vtkProperty.h:805
double AnisotropyRotation
Definition: vtkProperty.h:777
int LineStippleRepeatFactor
Definition: vtkProperty.h:799
std::map< std::string, vtkTexture * > & GetAllTextures()
Set/get all the textures in this property and their names.
Definition: vtkProperty.h:711
#define VTK_PBR
Definition: vtkProperty.h:40
const char * GetInterpolationAsString()
Return the method of shading as a descriptive character string.
Definition: vtkProperty.h:831
bool RenderPointsAsSpheres
Definition: vtkProperty.h:808
MapOfTextures Textures
Definition: vtkProperty.h:818
vtkTypeBool VertexVisibility
Definition: vtkProperty.h:803
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkInformation * Information
Definition: vtkProperty.h:821
double Specular
Definition: vtkProperty.h:787
#define VTK_WIREFRAME
Definition: vtkProperty.h:44
vtkTypeBool BackfaceCulling
Definition: vtkProperty.h:804
The ShaderProgram uses one or more Shader objects.