patchTableFactory.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_PATCH_TABLE_FACTORY_H
26 #define OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H
27
28 #include "../version.h"
29
30 #include "../far/patchTable.h"
31
32 namespace OpenSubdiv {
33 namespace OPENSUBDIV_VERSION {
34
35 namespace Far {
36
37 // Forward declarations (for internal implementation purposes):
38 class PtexIndices;
39 class TopologyRefiner;
40
43 class PatchTableFactory {
44 public:
45
48 struct Options {
49
50 enum EndCapType {
51 ENDCAP_NONE = 0,
52 ENDCAP_BILINEAR_BASIS,
53 ENDCAP_BSPLINE_BASIS,
54 ENDCAP_GREGORY_BASIS,
55 ENDCAP_LEGACY_GREGORY
56 };
57
58 Options(unsigned int maxIsolation=10) :
59 generateAllLevels(false),
60 triangulateQuads(false),
61 useSingleCreasePatch(false),
62 useInfSharpPatch(false),
63 maxIsolationLevel(maxIsolation),
64 endCapType(ENDCAP_GREGORY_BASIS),
65 shareEndCapPatchPoints(true),
66 generateFVarTables(false),
67 generateFVarLegacyLinearPatches(true),
68 generateLegacySharpCornerPatches(true),
69 numFVarChannels(-1),
70 fvarChannelIndices(0)
71 { }
72
74 EndCapType GetEndCapType() const { return (EndCapType)endCapType; }
75
77 void SetEndCapType(EndCapType e) { endCapType = e; }
78
79 unsigned int generateAllLevels : 1,
80 triangulateQuads : 1,
81 useSingleCreasePatch : 1,
82 useInfSharpPatch : 1,
83 maxIsolationLevel : 4,
84
85 // end-capping
86 endCapType : 3,
87 shareEndCapPatchPoints : 1,
88
90 // face-varying
91 generateFVarTables : 1,
92
93 // legacy behaviors (default to true)
94 generateFVarLegacyLinearPatches : 1,
95 generateLegacySharpCornerPatches : 1;
96
97 int numFVarChannels;
98 int const * fvarChannelIndices;
99 };
100
127 static PatchTable * Create(TopologyRefiner const & refiner,
128 Options options=Options());
129
130 private:
131 //
132 // Private helper structures
133 //
134 struct BuilderContext;
135
136 //
137 // Methods for allocating and managing the patch table data arrays:
138 //
139 static PatchTable * createUniform(TopologyRefiner const & refiner,
140 Options options);
141
142 static PatchTable * createAdaptive(TopologyRefiner const & refiner,
143 Options options);
144
145 //
146 // High-level methods for identifying and populating patches associated with faces:
147 //
148
149 static void identifyAdaptivePatches(BuilderContext & context);
150
151 static void populateAdaptivePatches(BuilderContext & context,
152 PatchTable * table);
153
154 static void allocateVertexTables(BuilderContext const & context,
155 PatchTable * table);
156
157 static void allocateFVarChannels(BuilderContext const & context,
158 PatchTable * table);
159
160 static PatchParam computePatchParam(BuilderContext const & context,
161 int level, int face,
162 int boundaryMask, int transitionMask);
163
164 public:
165 // PatchFaceTag
166 // This simple struct was previously used within the factory to take inventory of
167 // various kinds of patches to fully allocate buffers prior to populating them. It
168 // was not intended to be exposed as part of the public interface.
169 //
170 // It is no longer used internally and is being kept here to respect preservation
171 // of the public interface, but it will be deprecated at the earliest opportunity.
172 //
173 struct PatchFaceTag {
174 public:
175 unsigned int _hasPatch : 1;
176 unsigned int _isRegular : 1;
177 unsigned int _transitionMask : 4;
178 unsigned int _boundaryMask : 4;
179 unsigned int _boundaryIndex : 2;
180 unsigned int _boundaryCount : 3;
181 unsigned int _hasBoundaryEdge : 3;
182 unsigned int _isSingleCrease : 1;
183
184 void clear();
185 void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
186 void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
187 void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask);
188 };
189 typedef std::vector<PatchFaceTag> PatchTagVector;
190 };
191
192 } // end namespace Far
193
194 } // end namespace OPENSUBDIV_VERSION
195 using namespace OPENSUBDIV_VERSION;
196
197 } // end namespace OpenSubdiv
198
199
200 #endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::triangulateQuads
unsigned int triangulateQuads
Triangulate &#39;QUADS&#39; primitives (Uniform mode only)
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_LEGACY_GREGORY
use legacy (2.x) Gregory patches (4 cp + valence table) as end-caps
Definition: patchTableFactory.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromVertexMask
void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::shareEndCapPatchPoints
unsigned int shareEndCapPatchPoints
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryIndex
unsigned int _boundaryIndex
Definition: patchTableFactory.h:179
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Create
static PatchTable * Create(TopologyRefiner const &refiner, Options options=Options())
Instantiates a PatchTable from a client-provided TopologyRefiner.
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarLegacyLinearPatches
unsigned int generateFVarLegacyLinearPatches
Generate all linear face-varying patches (legacy)
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateAllLevels
unsigned int generateAllLevels
Include levels from &#39;firstLevel&#39; to &#39;maxLevel&#39; (Uniform mode only)
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_transitionMask
unsigned int _transitionMask
Definition: patchTableFactory.h:177
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchTagVector
std::vector< PatchFaceTag > PatchTagVector
Definition: patchTableFactory.h:189
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options
Public options for the PatchTable factory.
Definition: patchTableFactory.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::fvarChannelIndices
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
Definition: patchTableFactory.h:98
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetEndCapType
void SetEndCapType(EndCapType e)
Set endcap patch type.
Definition: patchTableFactory.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignTransitionPropertiesFromEdgeMask
void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useInfSharpPatch
unsigned int useInfSharpPatch
Use infinitely-sharp patch.
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromEdgeMask
void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::endCapType
unsigned int endCapType
EndCapType.
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS
use BSpline basis patches (16 cp) as end-caps
Definition: patchTableFactory.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::EndCapType
EndCapType
Definition: patchTableFactory.h:50
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::numFVarChannels
int numFVarChannels
Number of channel indices and interpolation modes passed.
Definition: patchTableFactory.h:97
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasBoundaryEdge
unsigned int _hasBoundaryEdge
Definition: patchTableFactory.h:181
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useSingleCreasePatch
unsigned int useSingleCreasePatch
Use single crease patch.
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory
Factory for constructing a PatchTable from a TopologyRefiner.
Definition: patchTableFactory.h:43
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchParam
Patch parameterization.
Definition: patchParam.h:152
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::maxIsolationLevel
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:50
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::clear
void clear()
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isRegular
unsigned int _isRegular
Definition: patchTableFactory.h:176
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag
Definition: patchTableFactory.h:173
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryCount
unsigned int _boundaryCount
Definition: patchTableFactory.h:180
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_NONE
no endcap
Definition: patchTableFactory.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BILINEAR_BASIS
use bilinear quads (4 cp) as end-caps
Definition: patchTableFactory.h:52
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::Options
Options(unsigned int maxIsolation=10)
Definition: patchTableFactory.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateLegacySharpCornerPatches
unsigned int generateLegacySharpCornerPatches
Generate sharp regular patches at smooth corners (legacy)
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS
use Gregory basis patches (20 cp) as end-caps
Definition: patchTableFactory.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasPatch
unsigned int _hasPatch
Definition: patchTableFactory.h:175
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryMask
unsigned int _boundaryMask
Definition: patchTableFactory.h:178
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isSingleCrease
unsigned int _isSingleCrease
Definition: patchTableFactory.h:182
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarTables
unsigned int generateFVarTables
Generate face-varying patch tables.
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetEndCapType
EndCapType GetEndCapType() const
Get endcap patch type.
Definition: patchTableFactory.h:74