My Project
stencilTableFactory.h
Go to the documentation of this file.
1 //
2 // Copyright 2013 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
26 #define OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
27 
28 #include "../version.h"
29 
30 #include "../far/patchTable.h"
31 
32 #include <vector>
33 
34 namespace OpenSubdiv {
35 namespace OPENSUBDIV_VERSION {
36 
37 namespace Far {
38 
39 class TopologyRefiner;
40 
41 template <typename REAL> class StencilReal;
42 template <typename REAL> class StencilTableReal;
43 
44 template <typename REAL> class LimitStencilReal;
45 template <typename REAL> class LimitStencilTableReal;
46 
47 
50 template <typename REAL>
51 class StencilTableFactoryReal {
52 
53 public:
54 
55  enum Mode {
59  };
60 
61  struct Options {
62 
64  generateOffsets(false),
65  generateControlVerts(false),
68  maxLevel(10),
69  fvarChannel(0) { }
70 
71  unsigned int interpolationMode : 2,
76  maxLevel : 4;
79  unsigned int fvarChannel;
80  };
82 
94  static StencilTableReal<REAL> const * Create(
95  TopologyRefiner const & refiner, Options options = Options());
96 
97 
110  static StencilTableReal<REAL> const * Create(
111  int numTables, StencilTableReal<REAL> const ** tables);
112 
113 
129  TopologyRefiner const &refiner,
130  StencilTableReal<REAL> const *baseStencilTable,
131  StencilTableReal<REAL> const *localPointStencilTable,
132  bool factorize = true);
133 
149  TopologyRefiner const &refiner,
150  StencilTableReal<REAL> const *baseStencilTable,
151  StencilTableReal<REAL> const *localPointStencilTable,
152  bool factorize = true) {
154  refiner, baseStencilTable, localPointStencilTable, factorize);
155  }
156 
175  TopologyRefiner const &refiner,
176  StencilTableReal<REAL> const *baseStencilTable,
177  StencilTableReal<REAL> const *localPointStencilTable,
178  int channel = 0,
179  bool factorize = true);
180 
181 private:
182 
183  // Generate stencils for the coarse control-vertices (single weight = 1.0f)
184  static void generateControlVertStencils(
185  int numControlVerts,
186  StencilReal<REAL> & dst);
187 
188  // Internal method to splice local point stencils
189  static StencilTableReal<REAL> const * appendLocalPointStencilTable(
190  TopologyRefiner const &refiner,
191  StencilTableReal<REAL> const * baseStencilTable,
192  StencilTableReal<REAL> const * localPointStencilTable,
193  int channel,
194  bool factorize);
195 };
196 
208 template <typename REAL>
209 class LimitStencilTableFactoryReal {
210 
211 public:
212 
213  enum Mode {
217  };
218 
219  struct Options {
220 
223  generate2ndDerivatives(false),
224  fvarChannel(0) { }
225 
226  unsigned int interpolationMode : 2,
229  unsigned int fvarChannel;
230  };
231 
233  struct LocationArray {
234 
235  LocationArray() : ptexIdx(-1), numLocations(0), s(0), t(0) { }
236 
237  int ptexIdx,
239 
240  REAL const * s,
241  * t;
242  };
243 
244  typedef std::vector<LocationArray> LocationArrayVec;
245 
269  static LimitStencilTableReal<REAL> const * Create(
270  TopologyRefiner const & refiner,
271  LocationArrayVec const & locationArrays,
272  StencilTableReal<REAL> const * cvStencils = 0,
273  PatchTable const * patchTable = 0,
274  Options options = Options());
275 
276 };
277 
278 
279 //
280 // Public wrapper classes for the templates
281 //
282 class Stencil;
283 class StencilTable;
284 
288 private:
291 
292 public:
293  static StencilTable const * Create(
294  TopologyRefiner const & refiner, Options options = Options()) {
295 
296  return static_cast<StencilTable const *>(
297  BaseFactory::Create(refiner, options));
298  }
299 
300  static StencilTable const * Create(
301  int numTables, StencilTable const ** tables) {
302 
303  return static_cast<StencilTable const *>(
304  BaseFactory::Create(numTables,
305  reinterpret_cast<BaseTable const **>(tables)));
306  }
307 
309  TopologyRefiner const &refiner,
310  StencilTable const *baseStencilTable,
311  StencilTable const *localPointStencilTable,
312  bool factorize = true) {
313 
314  return static_cast<StencilTable const *>(
316  static_cast<BaseTable const *>(baseStencilTable),
317  static_cast<BaseTable const *>(localPointStencilTable),
318  factorize));
319  }
320 
322  TopologyRefiner const &refiner,
323  StencilTable const *baseStencilTable,
324  StencilTable const *localPointStencilTable,
325  bool factorize = true) {
326 
327  return static_cast<StencilTable const *>(
329  static_cast<BaseTable const *>(baseStencilTable),
330  static_cast<BaseTable const *>(localPointStencilTable),
331  factorize));
332  }
333 
335  TopologyRefiner const &refiner,
336  StencilTable const *baseStencilTable,
337  StencilTable const *localPointStencilTable,
338  int channel = 0,
339  bool factorize = true) {
340 
341  return static_cast<StencilTable const *>(
343  static_cast<BaseTable const *>(baseStencilTable),
344  static_cast<BaseTable const *>(localPointStencilTable),
345  channel, factorize));
346  }
347 };
348 
349 class LimitStencil;
350 class LimitStencilTable;
351 
355 private:
358 
359 public:
360  static LimitStencilTable const * Create(
361  TopologyRefiner const & refiner,
362  LocationArrayVec const & locationArrays,
363  StencilTable const * cvStencils = 0,
364  PatchTable const * patchTable = 0,
365  Options options = Options()) {
366 
367  return static_cast<LimitStencilTable const *>(
369  refiner,
370  locationArrays,
371  static_cast<BaseTable const *>(cvStencils),
372  patchTable,
373  options));
374  }
375 };
376 
377 } // end namespace Far
378 
379 } // end namespace OPENSUBDIV_VERSION
380 using namespace OPENSUBDIV_VERSION;
381 
382 } // end namespace OpenSubdiv
383 
384 #endif // OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTableVarying
static const StencilTable * AppendLocalPointStencilTableVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
Definition: stencilTableFactory.h:321
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::INTERPOLATE_VARYING
@ INTERPOLATE_VARYING
varying primvar stencils
Definition: stencilTableFactory.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Create
static const StencilTableReal< REAL > * Create(TopologyRefiner const &refiner, Options options=Options())
Instantiates StencilTable from TopologyRefiner that have been refined uniformly or adaptively.
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal< float >::Mode
Mode
Definition: stencilTableFactory.h:213
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableReal
Table of subdivision stencils.
Definition: stencilTable.h:141
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal< float >::Mode
Mode
Definition: stencilTableFactory.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal
A specialized factory for LimitStencilTable.
Definition: stencilTable.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::Create
static const LimitStencilTable * Create(TopologyRefiner const &refiner, LocationArrayVec const &locationArrays, StencilTable const *cvStencils=0, PatchTable const *patchTable=0, Options options=Options())
Definition: stencilTableFactory.h:360
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::s
const REAL * s
array of u coordinates
Definition: stencilTableFactory.h:240
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTable
static const StencilTable * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
Definition: stencilTableFactory.h:308
OpenSubdiv::OPENSUBDIV_VERSION::Far::Stencil
Vertex stencil class wrapping the template for compatibility.
Definition: stencilTable.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::generate2ndDerivatives
unsigned int generate2ndDerivatives
Generate weights for 2nd derivatives.
Definition: stencilTableFactory.h:228
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal
A specialized factory for StencilTable.
Definition: stencilTable.h:45
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateOffsets
unsigned int generateOffsets
populate optional "_offsets" field
Definition: stencilTableFactory.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::generate1stDerivatives
unsigned int generate1stDerivatives
Generate weights for 1st derivatives.
Definition: stencilTableFactory.h:227
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::factorizeIntermediateLevels
unsigned int factorizeIntermediateLevels
Definition: stencilTableFactory.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::t
const REAL * t
array of v coordinates
Definition: stencilTableFactory.h:241
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::maxLevel
unsigned int maxLevel
generate stencils up to 'maxLevel'
Definition: stencilTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTableFaceVarying
static const StencilTableReal< REAL > * 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::LimitStencilTableFactoryReal::LocationArray::numLocations
int numLocations
number of (u,v) coordinates in the array
Definition: stencilTableFactory.h:238
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::ptexIdx
int ptexIdx
ptex face index
Definition: stencilTableFactory.h:237
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray
Descriptor for limit surface locations.
Definition: stencilTableFactory.h:233
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::interpolationMode
unsigned int interpolationMode
interpolation mode
Definition: stencilTableFactory.h:226
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::INTERPOLATE_VARYING
@ INTERPOLATE_VARYING
varying primvar stencils
Definition: stencilTableFactory.h:215
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArrayVec
std::vector< LocationArray > LocationArrayVec
Definition: stencilTableFactory.h:244
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::fvarChannel
unsigned int fvarChannel
Definition: stencilTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateControlVerts
unsigned int generateControlVerts
generate stencils for control-vertices
Definition: stencilTableFactory.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::INTERPOLATE_FACE_VARYING
@ INTERPOLATE_FACE_VARYING
face-varying primvar stencils
Definition: stencilTableFactory.h:216
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::fvarChannel
unsigned int fvarChannel
face-varying channel to use
Definition: stencilTableFactory.h:229
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::generateIntermediateLevels
unsigned int generateIntermediateLevels
vertices at all levels or highest only
Definition: stencilTableFactory.h:74
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options::Options
Options()
Definition: stencilTableFactory.h:221
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::Options
Options()
Definition: stencilTableFactory.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Create
static const StencilTable * Create(int numTables, StencilTable const **tables)
Definition: stencilTableFactory.h:300
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::LocationArray::LocationArray
LocationArray()
Definition: stencilTableFactory.h:235
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::INTERPOLATE_VERTEX
@ INTERPOLATE_VERTEX
vertex primvar stencils
Definition: stencilTableFactory.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory
Stencil table factory class wrapping the template for compatibility.
Definition: stencilTableFactory.h:354
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Options
Definition: stencilTableFactory.h:219
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options::interpolationMode
unsigned int interpolationMode
interpolation mode
Definition: stencilTableFactory.h:71
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::INTERPOLATE_FACE_VARYING
@ INTERPOLATE_FACE_VARYING
face-varying primvar stencils
Definition: stencilTableFactory.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTable
Limit stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:583
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTableVarying
static const StencilTableReal< REAL > * 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:148
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory
Stencil table factory class wrapping the template for compatibility.
Definition: stencilTableFactory.h:287
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Create
static const StencilTable * Create(TopologyRefiner const &refiner, Options options=Options())
Definition: stencilTableFactory.h:293
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilReal
Vertex stencil descriptor.
Definition: stencilTable.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::Options
Definition: stencilTableFactory.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::INTERPOLATE_VERTEX
@ INTERPOLATE_VERTEX
vertex primvar stencils
Definition: stencilTableFactory.h:214
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactoryReal::Create
static const LimitStencilTableReal< REAL > * 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::LimitStencilTableReal
Table of limit subdivision stencils.
Definition: stencilTable.h:409
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTable
Stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:273
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTableFaceVarying
static const StencilTable * AppendLocalPointStencilTableFaceVarying(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, int channel=0, bool factorize=true)
Definition: stencilTableFactory.h:334
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactoryReal::AppendLocalPointStencilTable
static const StencilTableReal< REAL > * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTableReal< REAL > const *baseStencilTable, StencilTableReal< REAL > const *localPointStencilTable, bool factorize=true)
Utility function for stencil splicing for local point stencils.