opensubdiv/far/patchTableFactory.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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
41 class PatchTableFactory {
42 public:
43 // PatchFaceTag
44 // A simple struct containing all information gathered about a face that is relevant
45 // to constructing a patch for it (some of these enums should probably be defined more
46 // as part of PatchTable)
47 //
48 // Like the HbrFace<T>::AdaptiveFlags, this struct aggregates all of the face tags
49 // supporting feature adaptive refinement. For now it is not used elsewhere and can
50 // remain local to this implementation, but we may want to move it into a header of
51 // its own if it has greater use later.
52 //
53 // Note that several properties being assigned here attempt to do so given a 4-bit
54 // mask of properties at the edges or vertices of the quad. Still not sure exactly
55 // what will be done this way, but the goal is to create lookup tables (of size 16
56 // for the 4 bits) to quickly determine was is needed, rather than iteration and
57 // branching on the edges or vertices.
58 //
59 struct PatchFaceTag {
60 public:
61 unsigned int _hasPatch : 1;
62 unsigned int _isRegular : 1;
63 unsigned int _transitionMask : 4;
64 unsigned int _boundaryMask : 4;
65 unsigned int _boundaryIndex : 2;
66 unsigned int _boundaryCount : 3;
67 unsigned int _hasBoundaryEdge : 3;
68 unsigned int _isSingleCrease : 1;
69
70 void clear();
71 void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
72 void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
73 void assignTransitionPropertiesFromEdgeMask(int transitionMask) {
74 _transitionMask = transitionMask;
75 }
76 };
77 typedef std::vector<PatchFaceTag> PatchTagVector;
78
79 struct Options {
80
81 enum EndCapType {
82 ENDCAP_NONE = 0,
83 ENDCAP_BILINEAR_BASIS,
84 ENDCAP_BSPLINE_BASIS,
85 ENDCAP_GREGORY_BASIS,
86 ENDCAP_LEGACY_GREGORY
87 };
88
89 Options(unsigned int maxIsolation=10) :
90 generateAllLevels(false),
91 triangulateQuads(false),
92 useSingleCreasePatch(false),
93 maxIsolationLevel(maxIsolation),
94 endCapType(ENDCAP_GREGORY_BASIS),
95 shareEndCapPatchPoints(true),
96 generateFVarTables(false),
97 numFVarChannels(-1),
98 fvarChannelIndices(0)
99 { }
100
102 EndCapType GetEndCapType() const { return (EndCapType)endCapType; }
103
105 void SetEndCapType(EndCapType e) { endCapType = e; }
106
107 unsigned int generateAllLevels : 1,
108 triangulateQuads : 1,
109 useSingleCreasePatch : 1,
110 maxIsolationLevel : 4,
111
112 // end-capping
113 endCapType : 3,
114 shareEndCapPatchPoints : 1,
115
117 // face-varying
118 generateFVarTables : 1;
119 int numFVarChannels;
120 int const * fvarChannelIndices;
121 };
122
131 static PatchTable * Create(TopologyRefiner const & refiner,
132 Options options=Options());
133
134 private:
135 //
136 // Private helper structures
137 //
138 struct AdaptiveContext;
139
140 //
141 // Methods for allocating and managing the patch table data arrays:
142 //
143 static PatchTable * createUniform(TopologyRefiner const & refiner,
144 Options options);
145
146 static PatchTable * createAdaptive(TopologyRefiner const & refiner,
147 Options options);
148
149 //
150 // High-level methods for identifying and populating patches associated with faces:
151 //
152
153 static void identifyAdaptivePatches(AdaptiveContext & state);
154
155 static void populateAdaptivePatches(AdaptiveContext & state,
156 PtexIndices const &ptexIndices);
157
158 static void allocateVertexTables(PatchTable * table, int nlevels, bool hasSharpness);
159
160 static void allocateFVarChannels(TopologyRefiner const & refiner,
161 Options options, int npatches, PatchTable * table);
162
163 static PatchParam * computePatchParam(TopologyRefiner const & refiner,
164 PtexIndices const & ptexIndices,
165 int level, int face,
166 int boundaryMask, int transitionMask, PatchParam * coord);
167
168 static int gatherFVarData(AdaptiveContext & state,
169 int level, Index faceIndex, Index levelFaceOffset, int rotation,
170 Index const * levelOffsets, Index fofss, Index ** fptrs);
171
172 };
173
174 } // end namespace Far
175
176 } // end namespace OPENSUBDIV_VERSION
177 using namespace OPENSUBDIV_VERSION;
178
179 } // end namespace OpenSubdiv
180
181
182 #endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isRegular
unsigned int _isRegular
Definition: patchTableFactory.h:62
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:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryCount
unsigned int _boundaryCount
Definition: patchTableFactory.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchParam
Local patch parameterization descriptor.
Definition: patchParam.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::shareEndCapPatchPoints
unsigned int shareEndCapPatchPoints
Definition: patchTableFactory.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryIndex
unsigned int _boundaryIndex
Definition: patchTableFactory.h:65
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options
Definition: patchTableFactory.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::Options
Options(unsigned int maxIsolation=10)
Definition: patchTableFactory.h:89
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::fvarChannelIndices
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
Definition: patchTableFactory.h:120
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryMask
unsigned int _boundaryMask
Definition: patchTableFactory.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetEndCapType
void SetEndCapType(EndCapType e)
Set endcap patch type.
Definition: patchTableFactory.h:105
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasPatch
unsigned int _hasPatch
Definition: patchTableFactory.h:61
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag
Definition: patchTableFactory.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::triangulateQuads
unsigned int triangulateQuads
Triangulate &#39;QUADS&#39; primitives (Uniform mode only)
Definition: patchTableFactory.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory
Definition: patchTableFactory.h:41
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useSingleCreasePatch
unsigned int useSingleCreasePatch
Use single crease patch.
Definition: patchTableFactory.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_NONE
no endcap
Definition: patchTableFactory.h:82
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::numFVarChannels
int numFVarChannels
Number of channel indices and interpolation modes passed.
Definition: patchTableFactory.h:119
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::maxIsolationLevel
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
Definition: patchTableFactory.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_transitionMask
unsigned int _transitionMask
Definition: patchTableFactory.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetEndCapType
EndCapType GetEndCapType() const
Get endcap patch type.
Definition: patchTableFactory.h:102
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BILINEAR_BASIS
use bilinear quads (4 cp) as end-caps
Definition: patchTableFactory.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::clear
void clear()
OpenSubdiv::OPENSUBDIV_VERSION::Far::Index
Vtr::Index Index
Definition: types.h:41
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isSingleCrease
unsigned int _isSingleCrease
Definition: patchTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::endCapType
unsigned int endCapType
EndCapType.
Definition: patchTableFactory.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition: patchTable.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarTables
unsigned int generateFVarTables
Generate face-varying patch tables.
Definition: patchTableFactory.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasBoundaryEdge
unsigned int _hasBoundaryEdge
Definition: patchTableFactory.h:67
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition: topologyRefiner.h:49
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:86
OpenSubdiv::OPENSUBDIV_VERSION::Far::PtexIndices
Object used to compute and query ptex face indices.
Definition: ptexIndices.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromVertexMask
void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS
use Gregory basis patches (20 cp) as end-caps
Definition: patchTableFactory.h:85
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchTagVector
std::vector< PatchFaceTag > PatchTagVector
Definition: patchTableFactory.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignTransitionPropertiesFromEdgeMask
void assignTransitionPropertiesFromEdgeMask(int transitionMask)
Definition: patchTableFactory.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromEdgeMask
void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS
use BSpline basis patches (16 cp) as end-caps
Definition: patchTableFactory.h:84
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::EndCapType
EndCapType
Definition: patchTableFactory.h:81