@@ -145,6 +145,25 @@ namespace SCIRun {
145145 std::vector<uint8_t > bitmap;
146146 };
147147
148+ struct SpireTexture2D
149+ {
150+ SpireTexture2D () : name(" " ), width(0 ), height(0 ) {}
151+ SpireTexture2D (std::string name , size_t width, size_t height, const char * data) :
152+ name (name),
153+ width (width),
154+ height (height)
155+ {
156+ size_t size = width*height*4 ;
157+ bitmap.resize (size);
158+ std::copy (data, data + size, bitmap.begin ());
159+ }
160+ std::string name;
161+ size_t width;
162+ size_t height;
163+ std::vector<uint8_t > bitmap;
164+ };
165+
166+
148167 // / Defines a Spire object 'pass'.
149168 struct SpireSubPass
150169 {
@@ -153,7 +172,7 @@ namespace SCIRun {
153172 const std::string& iboName, const std::string& program,
154173 ColorScheme scheme, const RenderState& state,
155174 RenderType renType, const SpireVBO& vbo, const SpireIBO& ibo,
156- const SpireText& text) :
175+ const SpireText& text, const SpireTexture2D& texture = SpireTexture2D() ) :
157176 passName (name),
158177 vboName (vboName),
159178 iboName (iboName),
@@ -163,6 +182,7 @@ namespace SCIRun {
163182 vbo (vbo),
164183 ibo (ibo),
165184 text (text),
185+ texture (texture),
166186 scalar (1.0 ),
167187 mColorScheme (scheme)
168188 {}
@@ -184,8 +204,10 @@ namespace SCIRun {
184204 SpireVBO vbo;
185205 SpireIBO ibo;
186206 SpireText text;// draw a string (usually single character) on geometry
207+ SpireTexture2D texture;
187208 double scalar;
188209
210+
189211 struct Uniform
190212 {
191213 enum class UniformType
@@ -195,16 +217,17 @@ namespace SCIRun {
195217 };
196218
197219 Uniform () : type(UniformType::UNIFORM_SCALAR) {}
198- Uniform (const std::string& nameIn, float d) :
220+
221+ Uniform (const std::string& nameIn, float scalar) :
199222 name (nameIn),
200223 type (UniformType::UNIFORM_SCALAR),
201- data (d , 0 .0f , 0 .0f , 0 .0f )
224+ data (scalar , 0 .0f , 0 .0f , 0 .0f )
202225 {}
203226
204- Uniform (const std::string& nameIn, const glm::vec4& vec ) :
227+ Uniform (const std::string& nameIn, const glm::vec4& vector ) :
205228 name (nameIn),
206229 type (UniformType::UNIFORM_VEC4),
207- data (vec )
230+ data (vector )
208231 {}
209232
210233 std::string name;
@@ -215,40 +238,9 @@ namespace SCIRun {
215238 std::vector<Uniform> mUniforms ;
216239 ColorScheme mColorScheme ;
217240
218- void addUniform (const std::string& name, float scalar)
219- {
220- bool existed = false ;
221- for (auto & i : mUniforms )
222- {
223- if (i.name == name && i.type == Uniform::UniformType::UNIFORM_SCALAR)
224- {
225- i.data .x = scalar;
226- existed = true ;
227- }
228- }
229- if (!existed)
230- mUniforms .push_back (Uniform (name, scalar));
231- }
232-
233- void addUniform (const std::string& name, const glm::vec4& vector)
234- {
235- bool existed = false ;
236- for (auto & i : mUniforms )
237- {
238- if (i.name == name && i.type == Uniform::UniformType::UNIFORM_VEC4)
239- {
240- i.data = vector;
241- existed = true ;
242- }
243- }
244- if (!existed)
245- mUniforms .push_back (Uniform (name, vector));
246- }
247-
248- void addUniform (const Uniform& uniform)
249- {
250- mUniforms .push_back (uniform);
251- }
241+ void addUniform (const std::string& name, const glm::vec4& vector);
242+ void addOrModifyUniform (const Uniform& uniform);
243+ void addUniform (const Uniform& uniform);
252244 };
253245
254246 using VBOList = std::list<SpireVBO>;
@@ -268,21 +260,18 @@ namespace SCIRun {
268260 const PassList& passes () const { return mPasses ; }
269261 PassList& passes () { return mPasses ; }
270262
271- bool isClippable () const { return isClippable_; }
263+ bool isClippable () const {return isClippable_;}
272264
273- void setColorMap (const std::string& name) { mColorMap = name; }
265+ void setColorMap (const std::string& name) { }
274266 boost::optional<std::string> colorMap () const { return mColorMap ; }
267+
275268 private:
276269 VBOList mVBOs ; // /< Array of vertex buffer objects.
277270 IBOList mIBOs ; // /< Array of index buffer objects.
278-
279- // / List of passes to setup.
280- PassList mPasses ;
281-
282- // / Optional colormap name.
271+ PassList mPasses ; // / List of passes to setup.
272+ bool isClippable_;
283273 boost::optional<std::string> mColorMap ;
284274
285- bool isClippable_;
286275 };
287276
288277 typedef boost::shared_ptr<GeometryObjectSpire> GeometryHandle;
0 commit comments