OpenSubdiv
Loading...
Searching...
No Matches
stencilTableFactory.h
Go to the documentation of this file.
1//
2// Copyright 2013 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
9#define OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
10
11#include "../version.h"
12
13#include "../far/patchTable.h"
14
15#include <vector>
16
17namespace OpenSubdiv {
18namespace OPENSUBDIV_VERSION {
19
20namespace Far {
21
22class TopologyRefiner;
23
24template <typename REAL> class StencilReal;
25template <typename REAL> class StencilTableReal;
26
27template <typename REAL> class LimitStencilReal;
28template <typename REAL> class LimitStencilTableReal;
29
30
33template <typename REAL>
35
36public:
37
43
65
78 TopologyRefiner const & refiner, Options options = Options());
79
80
94 int numTables, StencilTableReal<REAL> const ** tables);
95
96
112 TopologyRefiner const &refiner,
113 StencilTableReal<REAL> const *baseStencilTable,
114 StencilTableReal<REAL> const *localPointStencilTable,
115 bool factorize = true);
116
132 TopologyRefiner const &refiner,
133 StencilTableReal<REAL> const *baseStencilTable,
134 StencilTableReal<REAL> const *localPointStencilTable,
135 bool factorize = true) {
137 refiner, baseStencilTable, localPointStencilTable, factorize);
138 }
139
158 TopologyRefiner const &refiner,
159 StencilTableReal<REAL> const *baseStencilTable,
160 StencilTableReal<REAL> const *localPointStencilTable,
161 int channel = 0,
162 bool factorize = true);
163
164private:
165
166 // Generate stencils for the coarse control-vertices (single weight = 1.0f)
167 static void generateControlVertStencils(
168 int numControlVerts,
169 StencilReal<REAL> & dst);
170
171 // Internal method to splice local point stencils
172 static StencilTableReal<REAL> const * appendLocalPointStencilTable(
173 TopologyRefiner const &refiner,
174 StencilTableReal<REAL> const * baseStencilTable,
175 StencilTableReal<REAL> const * localPointStencilTable,
176 int channel,
177 bool factorize);
178};
179
191template <typename REAL>
193
194public:
195
201
214
217
218 LocationArray() : ptexIdx(-1), numLocations(0), s(0), t(0) { }
219
222
223 REAL const * s,
224 * t;
225 };
226
227 typedef std::vector<LocationArray> LocationArrayVec;
228
253 TopologyRefiner const & refiner,
254 LocationArrayVec const & locationArrays,
255 StencilTableReal<REAL> const * cvStencils = 0,
256 PatchTable const * patchTable = 0,
257 Options options = Options());
258
259};
260
261
262//
263// Public wrapper classes for the templates
264//
265class Stencil;
266class StencilTable;
267
271private:
274
275public:
276 static StencilTable const * Create(
277 TopologyRefiner const & refiner, Options options = Options()) {
278
279 return reinterpret_cast<StencilTable const *>(
280 BaseFactory::Create(refiner, options));
281 }
282
283 static StencilTable const * Create(
284 int numTables, StencilTable const ** tables) {
285
286 return reinterpret_cast<StencilTable const *>(
287 BaseFactory::Create(numTables,
288 reinterpret_cast<BaseTable const **>(tables)));
289 }
290
292 TopologyRefiner const &refiner,
293 StencilTable const *baseStencilTable,
294 StencilTable const *localPointStencilTable,
295 bool factorize = true) {
296
297 return reinterpret_cast<StencilTable const *>(
299 static_cast<BaseTable const *>(baseStencilTable),
300 static_cast<BaseTable const *>(localPointStencilTable),
301 factorize));
302 }
303
305 TopologyRefiner const &refiner,
306 StencilTable const *baseStencilTable,
307 StencilTable const *localPointStencilTable,
308 bool factorize = true) {
309
310 return reinterpret_cast<StencilTable const *>(
312 static_cast<BaseTable const *>(baseStencilTable),
313 static_cast<BaseTable const *>(localPointStencilTable),
314 factorize));
315 }
316
318 TopologyRefiner const &refiner,
319 StencilTable const *baseStencilTable,
320 StencilTable const *localPointStencilTable,
321 int channel = 0,
322 bool factorize = true) {
323
324 return reinterpret_cast<StencilTable const *>(
326 static_cast<BaseTable const *>(baseStencilTable),
327 static_cast<BaseTable const *>(localPointStencilTable),
328 channel, factorize));
329 }
330};
331
332class LimitStencil;
333class LimitStencilTable;
334
338private:
341
342public:
343 static LimitStencilTable const * Create(
344 TopologyRefiner const & refiner,
345 LocationArrayVec const & locationArrays,
346 StencilTable const * cvStencils = 0,
347 PatchTable const * patchTable = 0,
348 Options options = Options()) {
349
350 return reinterpret_cast<LimitStencilTable const *>(
352 refiner,
353 locationArrays,
354 static_cast<BaseTable const *>(cvStencils),
355 patchTable,
356 options));
357 }
358};
359
360} // end namespace Far
361
362} // end namespace OPENSUBDIV_VERSION
363using namespace OPENSUBDIV_VERSION;
364
365} // end namespace OpenSubdiv
366
367#endif // OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
Container for arrays of parametric patches.
Definition patchTable.h:38
static StencilTableReal< REAL > const * Create(TopologyRefiner const &refiner, Options options=Options())
Instantiates StencilTable from TopologyRefiner that have been refined uniformly or adaptively.
static StencilTableReal< REAL > const * AppendLocalPointStencilTableFaceVarying(TopologyRefiner const &refiner, StencilTableReal< REAL > const *baseStencilTable, StencilTableReal< REAL > const *localPointStencilTable, int channel=0, bool factorize=true)
Utility function for stencil splicing for local point face-varying stencils.
static StencilTableReal< REAL > const * AppendLocalPointStencilTableVarying(TopologyRefiner const &refiner, StencilTableReal< REAL > const *baseStencilTable, StencilTableReal< REAL > const *localPointStencilTable, bool factorize=true)
Utility function for stencil splicing for local point varying stencils.
static StencilTableReal< REAL > const * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTableReal< REAL > const *baseStencilTable, StencilTableReal< REAL > const *localPointStencilTable, bool factorize=true)
Utility function for stencil splicing for local point stencils.
static StencilTableReal< REAL > const * Create(int numTables, StencilTableReal< REAL > const **tables)
Instantiates StencilTable by concatenating an array of existing stencil tables.
static LimitStencilTableReal< REAL > const * Create(TopologyRefiner const &refiner, LocationArrayVec const &locationArrays, StencilTableReal< REAL > const *cvStencils=0, PatchTable const *patchTable=0, Options options=Options())
Instantiates LimitStencilTable from a TopologyRefiner that has been refined either uniformly or adapt...
Vertex stencil class wrapping the template for compatibility.
Stencil table class wrapping the template for compatibility.
Limit stencil table class wrapping the template for compatibility.
unsigned int generateIntermediateLevels
vertices at all levels or highest only
unsigned int generateControlVerts
generate stencils for control-vertices
unsigned int generate2ndDerivatives
Generate weights for 2nd derivatives.
unsigned int generate1stDerivatives
Generate weights for 1st derivatives.
Stencil table factory class wrapping the template for compatibility.
static StencilTable const * AppendLocalPointStencilTableVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
static StencilTable const * Create(TopologyRefiner const &refiner, Options options=Options())
static StencilTable const * AppendLocalPointStencilTableFaceVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, int channel=0, bool factorize=true)
static StencilTable const * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
static StencilTable const * Create(int numTables, StencilTable const **tables)
Stencil table factory class wrapping the template for compatibility.
static LimitStencilTable const * Create(TopologyRefiner const &refiner, LocationArrayVec const &locationArrays, StencilTable const *cvStencils=0, PatchTable const *patchTable=0, Options options=Options())
Stores topology data for a specified set of refinement options.