TTK
Loading...
Searching...
No Matches
ttkCinemaDarkroomShader.h
Go to the documentation of this file.
1
37
38#pragma once
39
40// VTK Module
41#include <ttkAlgorithm.h>
42#include <ttkCinemaDarkroomModule.h>
43#include <vtkSmartPointer.h>
44
45#include <unordered_map>
46
47class vtkImageData;
48class vtkPolyData;
49class vtkActor;
50class vtkRenderer;
51class vtkRenderWindow;
52
53class TTKCINEMADARKROOM_EXPORT ttkCinemaDarkroomShader : public ttkAlgorithm {
54
55private:
56 struct Replacement {
57 std::vector<double> values;
58 bool isInt{false};
59
60 Replacement(const std::vector<double> &values_, const bool &isInt_)
61 : values(values_), isInt(isInt_) {
62 }
63
64 std::string toString() const {
65 std::string result = "";
66 if(this->values.size() == 0) {
67 return "";
68 }
69
70 if(this->values.size() > 1) {
71 if(this->isInt)
72 result += "i";
73
74 result += "vec" + std::to_string(this->values.size()) + "(";
75 }
76
77 if(this->isInt)
78 result += std::to_string((int)this->values[0]);
79 else
80 result += std::to_string(this->values[0]);
81
82 for(size_t i = 1; i < this->values.size(); i++)
83 if(this->isInt)
84 result += "," + std::to_string((int)this->values[i]);
85 else
86 result += "," + std::to_string(this->values[i]);
87
88 if(this->values.size() > 1)
89 result += ")";
90
91 return result;
92 }
93 };
94
95 std::unordered_map<std::string, Replacement> Replacements;
96
97 vtkSmartPointer<vtkPolyData> FullScreenQuad;
98 vtkSmartPointer<vtkActor> FullScreenQuadActor;
101
102public:
105
106protected:
109
110 int FillInputPortInformation(int port, vtkInformation *info) override;
111 int FillOutputPortInformation(int port, vtkInformation *info) override;
112
115 std::string PerformReplacements(const std::string &input);
116
119 int AddReplacement(const std::string &name,
120 const std::vector<double> &values,
121 const bool &isInt = false);
122
123 int CreateFullScreenQuad();
124 int CreateRenderer();
125
128 int InitRenderer(vtkImageData *outputImage);
129
133 int AddTexture(vtkImageData *image, int arrayIdx, int textureIdx);
134
135 virtual std::string GetVertexShaderCode();
136 virtual std::string GetFragmentShaderCode();
137
140 virtual int Render(vtkImageData *image, const std::string &name);
141};
Baseclass of all VTK filters that wrap ttk modules.
int FillInputPortInformation(int ttkNotUsed(port), vtkInformation *ttkNotUsed(info)) override
int FillOutputPortInformation(int ttkNotUsed(port), vtkInformation *ttkNotUsed(info)) override
Base Class for all CinemaDarkroom Shaders.
~ttkCinemaDarkroomShader() override
static ttkCinemaDarkroomShader * New()