forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkOSPRayMaterialLibrary.h
135 lines (109 loc) · 4.09 KB
/
vtkOSPRayMaterialLibrary.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOSPRayMaterialLibrary.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkOSPRayMaterialLibrary
* @brief a collection of materials for vtk apps to draw from
*
* A singleton instance of this class manages a collection of materials.
* The materials can be read in from disk or created programmatically.
*
* @sa vtkOSPRayMaterialHelpers
*/
#ifndef vtkOSPRayMaterialLibrary_h
#define vtkOSPRayMaterialLibrary_h
#include "vtkRenderingOSPRayModule.h" // For export macro
#include "vtkObject.h"
#include <initializer_list> //for initializer_list!
#include <set> //for set!
#include <vector> //for vector!
class vtkOSPRayMaterialLibraryInternals;
class vtkTexture;
class VTKRENDERINGOSPRAY_EXPORT vtkOSPRayMaterialLibrary : public vtkObject
{
public:
static vtkOSPRayMaterialLibrary *New();
vtkTypeMacro(vtkOSPRayMaterialLibrary,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Called to kick off events in all followers.
*/
void Fire();
/**
* Reads the given file of materials and creates the in memory data
* structures needed to display objects with them. Returns false only if
* file could not be meaningfully interpreted.
*/
bool ReadFile(const char*FileName);
/**
* Serialize contents to an in memory buffer.
*/
const char *WriteBuffer();
/**
* DeSerialize contents from an in memory buffer as ReadFile does from a
* file or set of files. Returns false only if buffer could not be
* meaningfully interpreted.
*/
bool ReadBuffer(const char*Buffer);
/**
* Returns the set of material nicknames.
*/
std::set<std::string> GetMaterialNames();
/**
* Return an implementation name for the given material nickname.
*/
std::string LookupImplName(const std::string& nickname);
/**
* Returns a unform variable, the name format is nickname:varname.
*/
std::vector<double> GetDoubleShaderVariable(const std::string& nickname, const std::string& varname);
/**
* Returns a texture, the name format is nickname:varname.
*/
vtkTexture* GetTexture(const std::string& nickname, const std::string& varname);
/**
* Add Material
* Adds a new material nickname to the set of known materials.
* If the name is a repeat, we replace the old one.
**/
void AddMaterial(const std::string& nickname, const std::string& implname);
/**
* Add Texture
* Adds a new texture. Replaces any previous content.
**/
void AddTexture(const std::string& nickname, const std::string& texturename, vtkTexture* tex);
/**
* Add control variable
* Adds a new control variable. Replaces any previous content.
* @{
**/
void AddShaderVariable(const std::string& nickname,
const std::string& variablename,
int numVars, const double *x);
void AddShaderVariable(const std::string& nickname,
const std::string& variablename,
const std::initializer_list<double>& data)
{
this->AddShaderVariable(nickname, variablename,
static_cast<int>(data.size()), data.begin());
}
/**@}*/
protected:
vtkOSPRayMaterialLibrary();
virtual ~vtkOSPRayMaterialLibrary();
bool InternalParse(const char *name, bool IsFile);
bool InternalParseJSON(const char *name, bool IsFile, std::istream *doc);
bool InternalParseMTL(const char *name, bool IsFile, std::istream *doc);
private:
vtkOSPRayMaterialLibrary(const vtkOSPRayMaterialLibrary&) = delete;
void operator=(const vtkOSPRayMaterialLibrary&) = delete;
vtkOSPRayMaterialLibraryInternals *Internal;
};
#endif