VTK  9.0.3
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 "vtkObject.h"
29 #include "vtkRenderingRayTracingModule.h" // For export macro
30 
31 #include <initializer_list> //for initializer_list!
32 #include <map> //for map!
33 #include <set> //for set!
34 #include <vector> //for vector!
35 
36 class vtkOSPRayMaterialLibraryInternals;
37 class vtkTexture;
38 
39 class VTKRENDERINGRAYTRACING_EXPORT vtkOSPRayMaterialLibrary : public vtkObject
40 {
41 public:
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
49  void Fire();
50 
56  bool ReadFile(const char* FileName);
57 
61  const char* WriteBuffer();
62 
68  bool ReadBuffer(const char* Buffer);
69 
73  std::set<std::string> GetMaterialNames();
74 
79 
83  std::vector<std::string> GetDoubleShaderVariableList(const std::string& nickname);
84 
88  std::vector<double> GetDoubleShaderVariable(
89  const std::string& nickname, const std::string& varname);
90 
94  std::vector<std::string> GetTextureList(const std::string& nickname);
95 
99  vtkTexture* GetTexture(const std::string& nickname, const std::string& varname);
100 
106  void AddMaterial(const std::string& nickname, const std::string& implname);
107 
113  void RemoveMaterial(const std::string& nickname);
114 
119  void AddTexture(const std::string& nickname, const std::string& texturename, vtkTexture* tex);
120 
125  void RemoveTexture(const std::string& nickname, const std::string& texturename);
126 
130  void RemoveAllTextures(const std::string& nickname);
131 
138  const std::string& nickname, const std::string& variablename, int numVars, const double* x);
139  void AddShaderVariable(const std::string& nickname, const std::string& variablename,
140  const std::initializer_list<double>& data)
141  {
142  this->AddShaderVariable(nickname, variablename, static_cast<int>(data.size()), data.begin());
143  }
151  void RemoveShaderVariable(const std::string& nickname, const std::string& variablename);
152 
156  void RemoveAllShaderVariables(const std::string& nickname);
157 
161  enum class ParameterType : unsigned char
162  {
163  FLOAT,
164  NORMALIZED_FLOAT,
165  FLOAT_DATA,
166  VEC3,
167  COLOR_RGB,
168  BOOLEAN,
169  TEXTURE,
170  VEC2,
171  VEC4
172  };
173 
174  using ParametersMap = std::map<std::string, ParameterType>;
175 
179  static const std::map<std::string, ParametersMap>& GetParametersDictionary();
180 
181 protected:
184 
185  bool InternalParse(const char* name, bool IsFile);
186  bool InternalParseJSON(const char* name, bool IsFile, std::istream* doc);
187  bool InternalParseMTL(const char* name, bool IsFile, std::istream* doc);
188 
189 private:
191  void operator=(const vtkOSPRayMaterialLibrary&) = delete;
192 
193  vtkOSPRayMaterialLibraryInternals* Internal;
194 };
195 
196 #endif
a simple class to control print indentation
Definition: vtkIndent.h:34
a collection of materials for vtk apps to draw from
void RemoveMaterial(const std::string &nickname)
Remove Material Removes a material nickname from the set of known materials.
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 const std::map< std::string, ParametersMap > & GetParametersDictionary()
Get the dictionary of all possible materials based on OSPRay documentation.
bool ReadBuffer(const char *Buffer)
DeSerialize contents from an in memory buffer as ReadFile does from a file or set of files.
bool InternalParseJSON(const char *name, bool IsFile, std::istream *doc)
std::string LookupImplName(const std::string &nickname)
Return an implementation name for the given material nickname.
std::set< std::string > GetMaterialNames()
Returns the set of material nicknames.
bool InternalParseMTL(const char *name, bool IsFile, std::istream *doc)
void RemoveAllTextures(const std::string &nickname)
Remove all textures of a specific material.
void RemoveShaderVariable(const std::string &nickname, const std::string &variablename)
Remove control variable Removes a new control variable.
static vtkOSPRayMaterialLibrary * New()
std::vector< std::string > GetDoubleShaderVariableList(const std::string &nickname)
Returns list of variable names set for a specific material.
std::vector< std::string > GetTextureList(const std::string &nickname)
Returns list of texture names set for a specific material.
bool InternalParse(const char *name, bool IsFile)
void AddMaterial(const std::string &nickname, const std::string &implname)
Add Material Adds a new material nickname to the set of known materials.
std::map< std::string, ParameterType > ParametersMap
void RemoveTexture(const std::string &nickname, const std::string &texturename)
Remove Texture Removes a texture.
void AddShaderVariable(const std::string &nickname, const std::string &variablename, int numVars, const double *x)
Add control variable Adds a new control variable.
vtkTexture * GetTexture(const std::string &nickname, const std::string &varname)
Returns a texture.
void AddTexture(const std::string &nickname, const std::string &texturename, vtkTexture *tex)
Add Texture Adds a new texture.
std::vector< double > GetDoubleShaderVariable(const std::string &nickname, const std::string &varname)
Returns a uniform variable.
virtual ~vtkOSPRayMaterialLibrary()
void RemoveAllShaderVariables(const std::string &nickname)
Remove all control variables of a specific material.
ParameterType
Lists all different parameter types.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool ReadFile(const char *FileName)
Reads the given file of materials and creates the in memory data structures needed to display objects...
void Fire()
Called to kick off events in all followers.
const char * WriteBuffer()
Serialize contents to an in memory buffer.
abstract base class for most VTK objects
Definition: vtkObject.h:63
handles properties associated with a texture map
Definition: vtkTexture.h:66
@ name
Definition: vtkX3D.h:225
@ data
Definition: vtkX3D.h:321
@ string
Definition: vtkX3D.h:496