opensubdiv/far/stencilTableFactory.h Source File

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 class Stencil;
42 class StencilTable;
43 class LimitStencil;
44 class LimitStencilTable;
45
48 class StencilTableFactory {
49
50 public:
51
52 enum Mode {
53 INTERPOLATE_VERTEX=0,
54 INTERPOLATE_VARYING,
55 INTERPOLATE_FACE_VARYING
56 };
57
58 struct Options {
59
60 Options() : interpolationMode(INTERPOLATE_VERTEX),
61 generateOffsets(false),
62 generateControlVerts(false),
63 generateIntermediateLevels(true),
64 factorizeIntermediateLevels(true),
65 maxLevel(10),
66 fvarChannel(0) { }
67
68 unsigned int interpolationMode : 2,
69 generateOffsets : 1,
70 generateControlVerts : 1,
71 generateIntermediateLevels : 1,
72 factorizeIntermediateLevels : 1,
73 maxLevel : 4;
76 unsigned int fvarChannel;
77 };
79
91 static StencilTable const * Create(TopologyRefiner const & refiner,
92 Options options = Options());
93
94
107 static StencilTable const * Create(int numTables, StencilTable const ** tables);
108
109
124 static StencilTable const * AppendLocalPointStencilTable(
125 TopologyRefiner const &refiner,
126 StencilTable const *baseStencilTable,
127 StencilTable const *localPointStencilTable,
128 bool factorize = true);
129
147 static StencilTable const * AppendLocalPointStencilTableFaceVarying(
148 TopologyRefiner const &refiner,
149 StencilTable const *baseStencilTable,
150 StencilTable const *localPointStencilTable,
151 int channel = 0,
152 bool factorize = true);
153
154 private:
155
156 // Generate stencils for the coarse control-vertices (single weight = 1.0f)
157 static void generateControlVertStencils(int numControlVerts, Stencil & dst);
158
159 // Internal method to splice local point stencils
160 static StencilTable const * appendLocalPointStencilTable(
161 TopologyRefiner const &refiner,
162 StencilTable const * baseStencilTable,
163 StencilTable const * localPointStencilTable,
164 int channel,
165 bool factorize);
166 };
167
179 class LimitStencilTableFactory {
180
181 public:
182
184 struct LocationArray {
185
186 LocationArray() : ptexIdx(-1), numLocations(0), s(0), t(0) { }
187
188 int ptexIdx,
189 numLocations;
190
191 float const * s,
192 * t;
193 };
194
195 typedef std::vector<LocationArray> LocationArrayVec;
196
197 struct Options {
198
199 Options() : generate1stDerivatives(true),
200 generate2ndDerivatives(false) { }
201
202 unsigned int generate1stDerivatives : 1,
203 generate2ndDerivatives : 1;
204 };
205
224 static LimitStencilTable const * Create(TopologyRefiner const & refiner,
225 LocationArrayVec const & locationArrays,
226 StencilTable const * cvStencils=0,
227 PatchTable const * patchTable=0,
228 Options options=Options());
229
230 };
231
232
233 } // end namespace Far
234
235 } // end namespace OPENSUBDIV_VERSION
236 using namespace OPENSUBDIV_VERSION;
237
238 } // end namespace OpenSubdiv
239
240 #endif // OPENSUBDIV3_FAR_STENCILTABLE_FACTORY_H
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::Options::generate2ndDerivatives
unsigned int generate2ndDerivatives
Generate weights for 2nd derivatives.
Definition: stencilTableFactory.h:202
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::LocationArrayVec
std::vector< LocationArray > LocationArrayVec
Definition: stencilTableFactory.h:195
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Mode
Mode
Definition: stencilTableFactory.h:52
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::Options
Options()
Definition: stencilTableFactory.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::LocationArray::s
float const * s
array of u coordinates
Definition: stencilTableFactory.h:191
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::Options::Options
Options()
Definition: stencilTableFactory.h:199
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::generateControlVerts
unsigned int generateControlVerts
generate stencils for control-vertices
Definition: stencilTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::Stencil
Vertex stencil descriptor.
Definition: stencilTable.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::interpolationMode
unsigned int interpolationMode
interpolation mode
Definition: stencilTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Create
static StencilTable const * Create(TopologyRefiner const &refiner, Options options=Options())
Instantiates StencilTable from TopologyRefiner that have been refined uniformly or adaptively...
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)
Utility function for stencil splicing for local point face-varying stencils.
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options
Definition: stencilTableFactory.h:58
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::LocationArray::numLocations
int numLocations
number of (u,v) coordinates in the array
Definition: stencilTableFactory.h:188
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::LocationArray
Descriptor for limit surface locations.
Definition: stencilTableFactory.h:184
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::maxLevel
unsigned int maxLevel
generate stencils up to &#39;maxLevel&#39;
Definition: stencilTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:50
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::generateIntermediateLevels
unsigned int generateIntermediateLevels
vertices at all levels or highest only
Definition: stencilTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::INTERPOLATE_FACE_VARYING
face-varying primvar stencils
Definition: stencilTableFactory.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::INTERPOLATE_VARYING
varying primvar stencils
Definition: stencilTableFactory.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory
A specialized factory for StencilTable.
Definition: stencilTableFactory.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::factorizeIntermediateLevels
unsigned int factorizeIntermediateLevels
Definition: stencilTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTable
Table of subdivision stencils.
Definition: stencilTable.h:125
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::AppendLocalPointStencilTable
static StencilTable const * AppendLocalPointStencilTable(TopologyRefiner const &refiner, StencilTable const *baseStencilTable, StencilTable const *localPointStencilTable, bool factorize=true)
Utility function for stencil splicing for local point stencils.
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::LocationArray::t
float const * t
array of v coordinates
Definition: stencilTableFactory.h:191
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory
A specialized factory for LimitStencilTable.
Definition: stencilTableFactory.h:179
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTable
Table of limit subdivision stencils.
Definition: stencilTable.h:328
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())
Instantiates LimitStencilTable from a TopologyRefiner that has been refined either uniformly or adapt...
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::INTERPOLATE_VERTEX
vertex primvar stencils
Definition: stencilTableFactory.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::LocationArray::ptexIdx
int ptexIdx
ptex face index
Definition: stencilTableFactory.h:188
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::Options
Definition: stencilTableFactory.h:197
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::generateOffsets
unsigned int generateOffsets
populate optional "_offsets" field
Definition: stencilTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::LocationArray::LocationArray
LocationArray()
Definition: stencilTableFactory.h:186
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTableFactory::Options::generate1stDerivatives
unsigned int generate1stDerivatives
Generate weights for 1st derivatives.
Definition: stencilTableFactory.h:202
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTableFactory::Options::fvarChannel
unsigned int fvarChannel
Definition: stencilTableFactory.h:76