VTK
vtkOSPRayMaterialLibrary.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOSPRayMaterialLibrary.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 =========================================================================*/
25 #ifndef vtkOSPRayMaterialLibrary_h
26 #define vtkOSPRayMaterialLibrary_h
27 
28 #include "vtkRenderingOSPRayModule.h" // For export macro
29 #include "vtkObject.h"
30 
31 #include <initializer_list> //for initializer_list!
32 #include <set> //for set!
33 #include <vector> //for vector!
34 
35 class vtkOSPRayMaterialLibraryInternals;
36 class vtkTexture;
37 
38 class VTKRENDERINGOSPRAY_EXPORT vtkOSPRayMaterialLibrary : public vtkObject
39 {
40 public:
41  static vtkOSPRayMaterialLibrary *New();
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
48  void Fire();
49 
55  bool ReadFile(const char*FileName);
56 
60  const char *WriteBuffer();
61 
67  bool ReadBuffer(const char*Buffer);
68 
72  std::set<std::string> GetMaterialNames();
73 
77  std::string LookupImplName(const std::string& nickname);
78 
82  std::vector<double> GetDoubleShaderVariable(const std::string& nickname, const std::string& varname);
83 
87  vtkTexture* GetTexture(const std::string& nickname, const std::string& varname);
88 
94  void AddMaterial(const std::string& nickname, const std::string& implname);
95 
100  void AddTexture(const std::string& nickname, const std::string& texturename, vtkTexture* tex);
101 
107  void AddShaderVariable(const std::string& nickname,
108  const std::string& variablename,
109  int numVars, const double *x);
110  void AddShaderVariable(const std::string& nickname,
111  const std::string& variablename,
112  const std::initializer_list<double>& data)
113  {
114  this->AddShaderVariable(nickname, variablename,
115  static_cast<int>(data.size()), data.begin());
116  }
120 protected:
122  virtual ~vtkOSPRayMaterialLibrary();
123 
124  bool InternalParse(const char *name, bool IsFile);
125  bool InternalParseJSON(const char *name, bool IsFile, std::istream *doc);
126  bool InternalParseMTL(const char *name, bool IsFile, std::istream *doc);
127 
128 private:
130  void operator=(const vtkOSPRayMaterialLibrary&) = delete;
131 
132  vtkOSPRayMaterialLibraryInternals *Internal;
133 };
134 
135 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a collection of materials for vtk apps to draw from
a simple class to control print indentation
Definition: vtkIndent.h:33
handles properties associated with a texture map
Definition: vtkTexture.h:65
void AddShaderVariable(const std::string &nickname, const std::string &variablename, const std::initializer_list< double > &data)
Add control variable Adds a new control variable.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.