OpenSubdiv: opensubdiv/far/stencilTableFactory.h Source File

| 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>
34 class StencilTableFactoryReal {
35
36public:
37
38 enum Mode {
39 INTERPOLATE_VERTEX=0,
40 INTERPOLATE_VARYING,
41 INTERPOLATE_FACE_VARYING
42 };
43
44 struct Options {
45
46 Options() : interpolationMode(INTERPOLATE_VERTEX),
47 generateOffsets(false),
48 generateControlVerts(false),
49 generateIntermediateLevels(true),
50 factorizeIntermediateLevels(true),
51 maxLevel(10),
52 fvarChannel(0) { }
53
54 unsigned int interpolationMode : 2,
55 generateOffsets : 1,
56 generateControlVerts : 1,
57 generateIntermediateLevels : 1,
58 factorizeIntermediateLevels : 1,
61 maxLevel : 4;
62 unsigned int fvarChannel;
64 };
65
77 static StencilTableReal<REAL> const * Create(
78 TopologyRefiner const & refiner, Options options = Options());
79
80
93 static StencilTableReal<REAL> const * Create(
94 int numTables, StencilTableReal<REAL> const ** tables);
95
96
111 static StencilTableReal<REAL> const * AppendLocalPointStencilTable(
112 TopologyRefiner const &refiner,
113 StencilTableReal<REAL> const *baseStencilTable,
114 StencilTableReal<REAL> const *localPointStencilTable,
115 bool factorize = true);
116
131 static StencilTableReal<REAL> const * AppendLocalPointStencilTableVarying(
132 TopologyRefiner const &refiner,
133 StencilTableReal<REAL> const *baseStencilTable,
134 StencilTableReal<REAL> const *localPointStencilTable,
135 bool factorize = true) {
136 return AppendLocalPointStencilTable(
137 refiner, baseStencilTable, localPointStencilTable, factorize);
138 }
139
157 static StencilTableReal<REAL> const * AppendLocalPointStencilTableFaceVarying(
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>
192 class LimitStencilTableFactoryReal {
193
194public:
195
196 enum Mode {
197 INTERPOLATE_VERTEX=0,
198 INTERPOLATE_VARYING,
199 INTERPOLATE_FACE_VARYING
200 };
201
202 struct Options {
203
204 Options() : interpolationMode(INTERPOLATE_VERTEX),
205 generate1stDerivatives(true),
206 generate2ndDerivatives(false),
207 fvarChannel(0) { }
208
209 unsigned int interpolationMode : 2,
210 generate1stDerivatives : 1,
211 generate2ndDerivatives : 1;
212 unsigned int fvarChannel;
213 };
214
216 struct LocationArray {
217
218 LocationArray() : ptexIdx(-1), numLocations(0), s(0), t(0) { }
219
220 int ptexIdx,
221 numLocations;
222
223 REAL const * s,
224 * t;
225 };
226
227 typedef std::vector<LocationArray> LocationArrayVec;
228
252 static LimitStencilTableReal<REAL> const * Create(
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
270 class StencilTableFactory : public StencilTableFactoryReal<float> {
271private:
272 typedef StencilTableFactoryReal<float> BaseFactory;
273 typedef StencilTableReal<float> BaseTable;
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
291 static StencilTable const * AppendLocalPointStencilTable(
292 TopologyRefiner const &refiner,
293 StencilTable const *baseStencilTable,
294 StencilTable const *localPointStencilTable,
295 bool factorize = true) {
296
297 return reinterpret_cast<StencilTable const *>(
298 BaseFactory::AppendLocalPointStencilTable(refiner,
299 static_cast<BaseTable const *>(baseStencilTable),
300 static_cast<BaseTable const *>(localPointStencilTable),
301 factorize));
302 }
303
304 static StencilTable const * AppendLocalPointStencilTableVarying(
305 TopologyRefiner const &refiner,
306 StencilTable const *baseStencilTable,
307 StencilTable const *localPointStencilTable,
308 bool factorize = true) {
309
310 return reinterpret_cast<StencilTable const *>(
311 BaseFactory::AppendLocalPointStencilTableVarying(refiner,
312 static_cast<BaseTable const *>(baseStencilTable),
313 static_cast<BaseTable const *>(localPointStencilTable),
314 factorize));
315 }
316
317 static StencilTable const * AppendLocalPointStencilTableFaceVarying(
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 *>(
325 BaseFactory::AppendLocalPointStencilTableFaceVarying(refiner,
326 static_cast<BaseTable const *>(baseStencilTable),
327 static_cast<BaseTable const *>(localPointStencilTable),
328 channel, factorize));
329 }
330};
331
332class LimitStencil;
333class LimitStencilTable;
334
337 class LimitStencilTableFactory : public LimitStencilTableFactoryReal<float> {
338private:
339 typedef LimitStencilTableFactoryReal<float> BaseFactory;
340 typedef StencilTableReal<float> BaseTable;
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 *>(
351 BaseFactory::Create(
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
patchTable.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition patchTable.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal
A specialized factory for StencilTable.
Definition stencilTableFactory.h:34
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Create
static StencilTableReal< REAL > const * Create(TopologyRefiner const &refiner, Options options=Options())
Instantiates StencilTable from TopologyRefiner that have been refined uniformly or adaptively.
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTableFaceVarying
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.
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Mode
Mode
Definition stencilTableFactory.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal< float >::INTERPOLATE_FACE_VARYING
@ INTERPOLATE_FACE_VARYING
Definition stencilTableFactory.h:41
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal< float >::INTERPOLATE_VARYING
@ INTERPOLATE_VARYING
Definition stencilTableFactory.h:40
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal< float >::INTERPOLATE_VERTEX
@ INTERPOLATE_VERTEX
Definition stencilTableFactory.h:39
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTableVarying
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.
Definition stencilTableFactory.h:131
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTable
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.
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Create
static StencilTableReal< REAL > const * Create(int numTables, StencilTableReal< REAL > const **tables)
Instantiates StencilTable by concatenating an array of existing stencil tables.
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal
A specialized factory for LimitStencilTable.
Definition stencilTableFactory.h:192
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Mode
Mode
Definition stencilTableFactory.h:196
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal< float >::INTERPOLATE_FACE_VARYING
@ INTERPOLATE_FACE_VARYING
Definition stencilTableFactory.h:199
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal< float >::INTERPOLATE_VARYING
@ INTERPOLATE_VARYING
Definition stencilTableFactory.h:198
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal< float >::INTERPOLATE_VERTEX
@ INTERPOLATE_VERTEX
Definition stencilTableFactory.h:197
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArrayVec
std::vector< LocationArray > LocationArrayVec
Definition stencilTableFactory.h:227
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Create
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...
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilReal
Vertex stencil descriptor.
Definition stencilTable.h:36
OpenSubdiv::OPENSUBDIV_VERSION::Far::Stencil
Vertex stencil class wrapping the template for compatibility.
Definition stencilTable.h:99
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableReal
Table of subdivision stencils.
Definition stencilTable.h:124
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTable
Stencil table class wrapping the template for compatibility.
Definition stencilTable.h:256
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilReal
Limit point stencil descriptor.
Definition stencilTable.h:286
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableReal
Table of limit subdivision stencils.
Definition stencilTable.h:392
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTable
Limit stencil table class wrapping the template for compatibility.
Definition stencilTable.h:566
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::factorizeIntermediateLevels
unsigned int factorizeIntermediateLevels
Definition stencilTableFactory.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::maxLevel
unsigned int maxLevel
generate stencils up to 'maxLevel'
Definition stencilTableFactory.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::Options
Options()
Definition stencilTableFactory.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateIntermediateLevels
unsigned int generateIntermediateLevels
vertices at all levels or highest only
Definition stencilTableFactory.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateControlVerts
unsigned int generateControlVerts
generate stencils for control-vertices
Definition stencilTableFactory.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateOffsets
unsigned int generateOffsets
populate optional "_offsets" field
Definition stencilTableFactory.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::fvarChannel
unsigned int fvarChannel
Definition stencilTableFactory.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::interpolationMode
unsigned int interpolationMode
interpolation mode
Definition stencilTableFactory.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::Options
Options()
Definition stencilTableFactory.h:204
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::fvarChannel
unsigned int fvarChannel
face-varying channel to use
Definition stencilTableFactory.h:212
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::interpolationMode
unsigned int interpolationMode
interpolation mode
Definition stencilTableFactory.h:209
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::generate2ndDerivatives
unsigned int generate2ndDerivatives
Generate weights for 2nd derivatives.
Definition stencilTableFactory.h:211
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::generate1stDerivatives
unsigned int generate1stDerivatives
Generate weights for 1st derivatives.
Definition stencilTableFactory.h:210
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::t
REAL const * t
array of v coordinates
Definition stencilTableFactory.h:224
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::s
REAL const * s
array of u coordinates
Definition stencilTableFactory.h:223
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::LocationArray
LocationArray()
Definition stencilTableFactory.h:218
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::numLocations
int numLocations
number of (u,v) coordinates in the array
Definition stencilTableFactory.h:221
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::ptexIdx
int ptexIdx
ptex face index
Definition stencilTableFactory.h:220
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory
Stencil table factory class wrapping the template for compatibility.
Definition stencilTableFactory.h:270
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTableVarying
static StencilTable const * AppendLocalPointStencilTableVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
Definition stencilTableFactory.h:304
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Create
static StencilTable const * Create(TopologyRefiner const &refiner, Options options=Options())
Definition stencilTableFactory.h:276
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTableFaceVarying
static StencilTable const * AppendLocalPointStencilTableFaceVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, int channel=0, bool factorize=true)
Definition stencilTableFactory.h:317
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTable
static StencilTable const * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
Definition stencilTableFactory.h:291
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Create
static StencilTable const * Create(int numTables, StencilTable const **tables)
Definition stencilTableFactory.h:283
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory
Stencil table factory class wrapping the template for compatibility.
Definition stencilTableFactory.h:337
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::Create
static LimitStencilTable const * Create(TopologyRefiner const &refiner, LocationArrayVec const &locationArrays, StencilTable const *cvStencils=0, PatchTable const *patchTable=0, Options options=Options())
Definition stencilTableFactory.h:343
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition topologyRefiner.h:34