OpenSubdiv
Loading...
Searching...
No Matches
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
34namespace OpenSubdiv {
35namespace OPENSUBDIV_VERSION {
36
37namespace Far {
38
39class TopologyRefiner;
40
41template <typename REAL> class StencilReal;
42template <typename REAL> class StencilTableReal;
43
44template <typename REAL> class LimitStencilReal;
45template <typename REAL> class LimitStencilTableReal;
46
47
50template <typename REAL>
52
53public:
54
60
82
95 TopologyRefiner const & refiner, Options options = Options());
96
97
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
181private:
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
208template <typename REAL>
210
211public:
212
218
231
234
235 LocationArray() : ptexIdx(-1), numLocations(0), s(0), t(0) { }
236
239
240 REAL const * s,
241 * t;
242 };
243
244 typedef std::vector<LocationArray> LocationArrayVec;
245
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//
282class Stencil;
283class StencilTable;
284
288private:
291
292public:
293 static StencilTable const * Create(
294 TopologyRefiner const & refiner, Options options = Options()) {
295
296 return reinterpret_cast<StencilTable const *>(
297 BaseFactory::Create(refiner, options));
298 }
299
300 static StencilTable const * Create(
301 int numTables, StencilTable const ** tables) {
302
303 return reinterpret_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 reinterpret_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 reinterpret_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 reinterpret_cast<StencilTable const *>(
343 static_cast<BaseTable const *>(baseStencilTable),
344 static_cast<BaseTable const *>(localPointStencilTable),
345 channel, factorize));
346 }
347};
348
349class LimitStencil;
350class LimitStencilTable;
351
355private:
358
359public:
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 reinterpret_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
380using namespace OPENSUBDIV_VERSION;
381
382} // end namespace OpenSubdiv
383
384#endif // OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
Container for arrays of parametric patches.
Definition patchTable.h:55
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.