Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkMaterial.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkMaterial_h
14 #define mitkMaterial_h
15 
16 #include <MitkCoreExports.h>
17 #include <itkObject.h>
18 #include <itkRGBPixel.h>
19 #include <itkVectorContainer.h>
20 #include <mitkCommon.h>
21 #include <string>
22 #include <vtkSystemIncludes.h>
23 
24 namespace mitk
25 {
35  class MITKCORE_EXPORT Material : public itk::Object
36  {
37  public:
39 
40  typedef itk::RGBPixel<double> Color;
41 
43  {
46  Phong
47  };
48 
50  {
53  Surface
54  };
55 
66  static Pointer New()
67  {
68  Pointer smartPtr = new Material();
69  smartPtr->UnRegister();
70  return smartPtr;
71  }
72 
85  static Pointer New(Color color, double opacity = 1.0f)
86  {
87  Pointer smartPtr = new Material(color, opacity);
88  smartPtr->UnRegister();
89  return smartPtr;
90  }
91 
105  static Pointer New(double red, double green, double blue, double opacity = 1.0f)
106  {
107  Pointer smartPtr = new Material(red, green, blue, opacity);
108  smartPtr->UnRegister();
109  return smartPtr;
110  }
111 
131  static Pointer New(double red,
132  double green,
133  double blue,
134  double colorCoefficient,
135  double specularCoefficient,
136  double specularPower,
137  double opacity)
138  {
139  Pointer smartPtr = new Material(red, green, blue, colorCoefficient, specularCoefficient, specularPower, opacity);
140  smartPtr->UnRegister();
141  return smartPtr;
142  }
143 
162  static Pointer New(
163  Color color, double colorCoefficient, double specularCoefficient, double specularPower, double opacity)
164  {
165  Pointer smartPtr = new Material(color, colorCoefficient, specularCoefficient, specularPower, opacity);
166  smartPtr->UnRegister();
167  return smartPtr;
168  }
169 
172 
188  static Pointer New(
189  const Material &property, double red, double green, double blue, double opacity = 1.0, std::string name = "")
190  {
191  Pointer smartPtr = new Material(property, red, green, blue, opacity, name);
192  smartPtr->UnRegister();
193  return smartPtr;
194  }
195 
202  virtual bool Assignable(const Material &other) const;
203 
210  virtual Material &operator=(const Material &other);
211 
219  virtual void SetColor(Color color);
220 
230  virtual void SetColor(double red, double green, double blue);
231 
239  virtual void SetColorCoefficient(double coefficient);
240 
247  virtual void SetSpecularColor(Color color);
248 
256  virtual void SetSpecularColor(double red, double green, double blue);
257 
265  virtual void SetSpecularCoefficient(double specularCoefficient);
266 
274  virtual void SetSpecularPower(double specularPower);
275 
284  virtual void SetOpacity(double opacity);
285 
294  virtual void SetInterpolation(InterpolationType interpolation);
295 
304  virtual void SetRepresentation(RepresentationType representation);
305 
313  virtual void SetLineWidth(float lineWidth);
314 
319  virtual Color GetColor() const;
320 
325  virtual double GetColorCoefficient() const;
326 
331  virtual Color GetSpecularColor() const;
332 
337  virtual double GetSpecularCoefficient() const;
338 
343  virtual double GetSpecularPower() const;
344 
349  virtual double GetOpacity() const;
350 
356 
362 
367  virtual int GetVtkInterpolation() const;
368 
373  virtual int GetVtkRepresentation() const;
374 
379  virtual float GetLineWidth() const;
380 
387  virtual void Initialize(const Material &property);
388 
395  virtual bool operator==(const Material &property) const;
396 
402  void PrintSelf(std::ostream &os, itk::Indent) const override;
403 
410  itkSetMacro(Name, std::string);
411 
415  itkGetConstMacro(Name, std::string);
416 
417  protected:
427 
439  Material(Color color, double opacity = 1.0f);
440 
453  Material(double red, double green, double blue, double opacity = 1.0f);
454 
473  Material(double red,
474  double green,
475  double blue,
476  double colorCoefficient,
477  double specularCoefficient,
478  double specularPower,
479  double opacity);
480 
498  Material(Color color, double colorCoefficient, double specularCoefficient, double specularPower, double opacity);
499 
501  Material(const Material &property);
502 
510  const Material &property, double red, double green, double blue, double opacity = 1.0, std::string name = "");
511 
513  virtual void InitializeStandardValues();
514 
516  virtual void Update();
517 
518  std::string m_Name;
519 
521 
523 
525 
527 
529 
530  double m_Opacity;
531 
532  float m_LineWidth;
533 
535 
537  };
538 
539  typedef itk::VectorContainer<unsigned int, Material::Pointer> MaterialVectorContainer;
540 }
541 
542 #endif
#define MITKCORE_EXPORT
Encapsulates 3D visualization properties which are forwarded to VTK for color mapping.
Definition: mitkMaterial.h:36
static Pointer New(Color color, double opacity=1.0f)
Create a new Material with the given color and opacity.
Definition: mitkMaterial.h:85
itk::RGBPixel< double > Color
Definition: mitkMaterial.h:40
virtual double GetColorCoefficient() const
Get the color coefficient of the material.
static Pointer New(double red, double green, double blue, double opacity=1.0f)
Create a new Material with the given RGB color components and opacity.
Definition: mitkMaterial.h:105
static Pointer New(Color color, double colorCoefficient, double specularCoefficient, double specularPower, double opacity)
Create a new Material with the given color and lighting properties.
Definition: mitkMaterial.h:162
virtual void SetSpecularCoefficient(double specularCoefficient)
Set the specular coefficient which controls the shininess of the object together with the specular po...
static Pointer New(double red, double green, double blue, double colorCoefficient, double specularCoefficient, double specularPower, double opacity)
Create a new Material with full control over color and lighting properties.
Definition: mitkMaterial.h:131
virtual Color GetColor() const
Get the color of the material.
virtual double GetSpecularCoefficient() const
Get the specular coefficient used for rendering.
virtual RepresentationType GetRepresentation() const
Get the representation type used for rendering.
Material(double red, double green, double blue, double opacity=1.0f)
Constructor with RGB components and opacity.
virtual float GetLineWidth() const
Get the line width used for wireframe rendering.
virtual void SetSpecularPower(double specularPower)
Set the specular power which controls the shininess of the object together with the specular coeffici...
virtual void SetColor(Color color)
Set the material color in RGB space.
virtual int GetVtkInterpolation() const
Get the interpolation method as a VTK constant.
virtual void SetSpecularColor(Color color)
Set the specular color.
virtual void Initialize(const Material &property)
Fill the current material with the properties of the given material.
double m_SpecularPower
Definition: mitkMaterial.h:528
double m_SpecularCoefficient
Definition: mitkMaterial.h:526
Material()
Default constructor.
Color m_SpecularColor
Definition: mitkMaterial.h:522
InterpolationType m_Interpolation
Definition: mitkMaterial.h:534
virtual void SetOpacity(double opacity)
Set the opacity of the material.
mitkClassMacroItkParent(Material, itk::Object)
virtual double GetOpacity() const
Get the opacity of the material.
virtual Material & operator=(const Material &other)
Assignment operator. Copies all properties from the other material.
virtual void SetLineWidth(float lineWidth)
Set the width of a Line.
static Pointer New(const Material &property, double red, double green, double blue, double opacity=1.0, std::string name="")
Copy constructor with color and opacity override.
Definition: mitkMaterial.h:188
mitkNewMacro1Param(Material, const Material &)
Copy constructor.
virtual void SetColor(double red, double green, double blue)
Set the material color in RGB space.
void PrintSelf(std::ostream &os, itk::Indent) const override
Print the material properties to the given output stream.
virtual InterpolationType GetInterpolation() const
Get the interpolation method used for rendering.
Material(const Material &property)
Copy constructor.
virtual int GetVtkRepresentation() const
Get the representation type as a VTK constant.
std::string m_Name
Definition: mitkMaterial.h:518
virtual void SetColorCoefficient(double coefficient)
Set an attenuation coefficient for the color.
Material(const Material &property, double red, double green, double blue, double opacity=1.0, std::string name="")
Copy constructor with color and opacity override.
RepresentationType m_Representation
Definition: mitkMaterial.h:536
Material(double red, double green, double blue, double colorCoefficient, double specularCoefficient, double specularPower, double opacity)
Constructor with full control over color and lighting properties.
virtual void SetSpecularColor(double red, double green, double blue)
Set the specular color using RGB components.
virtual void InitializeStandardValues()
Initialize all member variables to standard default values.
virtual bool operator==(const Material &property) const
Comparison operator which uses the member variables for comparison.
Material(Color color, double opacity=1.0f)
Constructor with color and opacity.
virtual void SetInterpolation(InterpolationType interpolation)
Set the surface interpolation method of the object.
virtual void SetRepresentation(RepresentationType representation)
Set the surface representation method of the object.
Material(Color color, double colorCoefficient, double specularCoefficient, double specularPower, double opacity)
Constructor with color and lighting properties.
virtual bool Assignable(const Material &other) const
Check whether the given material can be assigned to this one.
static Pointer New()
Create a new Material with default values.
Definition: mitkMaterial.h:66
double m_ColorCoefficient
Definition: mitkMaterial.h:524
virtual Color GetSpecularColor() const
Get the specular color of the material.
virtual double GetSpecularPower() const
Get the specular power.
virtual void Update()
Re-apply all current property values, triggering Modified().
Data class for storing polygonal surfaces (vtkPolyData).
Definition: mitkSurface.h:37
Find image slices visible on a given plane.
itk::VectorContainer< unsigned int, Material::Pointer > MaterialVectorContainer
Definition: mitkMaterial.h:539