opensubdiv/far/patchTableFactory.h Source File

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 numFVarChannels(-1),
69 fvarChannelIndices(0)
70 { }
71
73 EndCapType GetEndCapType() const { return (EndCapType)endCapType; }
74
76 void SetEndCapType(EndCapType e) { endCapType = e; }
77
78 unsigned int generateAllLevels : 1,
79 triangulateQuads : 1,
80 useSingleCreasePatch : 1,
81 useInfSharpPatch : 1,
82 maxIsolationLevel : 4,
83
84 // end-capping
85 endCapType : 3,
86 shareEndCapPatchPoints : 1,
87
89 // face-varying
90 generateFVarTables : 1,
91 generateFVarLegacyLinearPatches : 1;
92 int numFVarChannels;
93 int const * fvarChannelIndices;
94 };
95
104 static PatchTable * Create(TopologyRefiner const & refiner,
105 Options options=Options());
106
107 private:
108 //
109 // Private helper structures
110 //
111 struct BuilderContext;
112
113 //
114 // Methods for allocating and managing the patch table data arrays:
115 //
116 static PatchTable * createUniform(TopologyRefiner const & refiner,
117 Options options);
118
119 static PatchTable * createAdaptive(TopologyRefiner const & refiner,
120 Options options);
121
122 //
123 // High-level methods for identifying and populating patches associated with faces:
124 //
125
126 static void identifyAdaptivePatches(BuilderContext & context);
127
128 static void populateAdaptivePatches(BuilderContext & context,
129 PatchTable * table);
130
131 static void allocateVertexTables(BuilderContext const & context,
132 PatchTable * table);
133
134 static void allocateFVarChannels(BuilderContext const & context,
135 PatchTable * table);
136
137 static PatchParam computePatchParam(BuilderContext const & context,
138 int level, int face,
139 int boundaryMask, int transitionMask);
140
141 public:
142 // PatchFaceTag
143 // This simple struct was previously used within the factory to take inventory of
144 // various kinds of patches to fully allocate buffers prior to populating them. It
145 // was not intended to be exposed as part of the public interface.
146 //
147 // It is no longer used internally and is being kept here to respect preservation
148 // of the public interface, but it will be deprecated at the earliest opportunity.
149 //
150 struct PatchFaceTag {
151 public:
152 unsigned int _hasPatch : 1;
153 unsigned int _isRegular : 1;
154 unsigned int _transitionMask : 4;
155 unsigned int _boundaryMask : 4;
156 unsigned int _boundaryIndex : 2;
157 unsigned int _boundaryCount : 3;
158 unsigned int _hasBoundaryEdge : 3;
159 unsigned int _isSingleCrease : 1;
160
161 void clear();
162 void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
163 void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
164 void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask);
165 };
166 typedef std::vector<PatchFaceTag> PatchTagVector;
167 };
168
169 } // end namespace Far
170
171 } // end namespace OPENSUBDIV_VERSION
172 using namespace OPENSUBDIV_VERSION;
173
174 } // end namespace OpenSubdiv
175
176
177 #endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag
Definition: patchTableFactory.h:150
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isSingleCrease
unsigned int _isSingleCrease
Definition: patchTableFactory.h:159
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::_boundaryIndex
unsigned int _boundaryIndex
Definition: patchTableFactory.h:156
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::endCapType
unsigned int endCapType
EndCapType.
Definition: patchTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarTables
unsigned int generateFVarTables
Generate face-varying patch tables.
Definition: patchTableFactory.h:78
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
Public options for the PatchTable factory.
Definition: patchTableFactory.h:48
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::Options::SetEndCapType
void SetEndCapType(EndCapType e)
Set endcap patch type.
Definition: patchTableFactory.h:76
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_transitionMask
unsigned int _transitionMask
Definition: patchTableFactory.h:154
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasBoundaryEdge
unsigned int _hasBoundaryEdge
Definition: patchTableFactory.h:158
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory
Factory for constructing a PatchTable from a TopologyRefiner.
Definition: patchTableFactory.h:43
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasPatch
unsigned int _hasPatch
Definition: patchTableFactory.h:152
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchParam
Patch parameterization.
Definition: patchParam.h:152
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:50
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetEndCapType
EndCapType GetEndCapType() const
Get endcap patch type.
Definition: patchTableFactory.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::shareEndCapPatchPoints
unsigned int shareEndCapPatchPoints
Definition: patchTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useInfSharpPatch
unsigned int useInfSharpPatch
Use infinitely-sharp patch.
Definition: patchTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::Options
Options(unsigned int maxIsolation=10)
Definition: patchTableFactory.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::triangulateQuads
unsigned int triangulateQuads
Triangulate &#39;QUADS&#39; primitives (Uniform mode only)
Definition: patchTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::maxIsolationLevel
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
Definition: patchTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::numFVarChannels
int numFVarChannels
Number of channel indices and interpolation modes passed.
Definition: patchTableFactory.h:92
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_NONE
no endcap
Definition: patchTableFactory.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useSingleCreasePatch
unsigned int useSingleCreasePatch
Use single crease patch.
Definition: patchTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryCount
unsigned int _boundaryCount
Definition: patchTableFactory.h:157
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarLegacyLinearPatches
unsigned int generateFVarLegacyLinearPatches
Generate all linear face-varying patches (legacy)
Definition: patchTableFactory.h:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::EndCapType
EndCapType
Definition: patchTableFactory.h:50
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryMask
unsigned int _boundaryMask
Definition: patchTableFactory.h:155
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:78
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::fvarChannelIndices
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
Definition: patchTableFactory.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Create
static PatchTable * Create(TopologyRefiner const &refiner, Options options=Options())
Factory constructor for PatchTable.
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::PatchFaceTag::_isRegular
unsigned int _isRegular
Definition: patchTableFactory.h:153
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchTagVector
std::vector< PatchFaceTag > PatchTagVector
Definition: patchTableFactory.h:166