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 
44 public:
45 
48  struct Options {
49 
50  enum EndCapType {
56  };
57 
58  Options(unsigned int maxIsolation=10) :
59  generateAllLevels(false),
60  triangulateQuads(false),
61  useSingleCreasePatch(false),
62  useInfSharpPatch(false),
63  maxIsolationLevel(maxIsolation),
66  generateFVarTables(false),
69  numFVarChannels(-1),
71  { }
72 
75 
78 
79  unsigned int generateAllLevels : 1,
80  triangulateQuads : 1,
82  useInfSharpPatch : 1,
83  maxIsolationLevel : 4,
84 
85  // end-capping
86  endCapType : 3,
88 
90  // face-varying
91  generateFVarTables : 1,
92 
93  // legacy behaviors (default to true)
96 
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 */
unsigned int triangulateQuads
Triangulate &#39;QUADS&#39; primitives (Uniform mode only)
use legacy (2.x) Gregory patches (4 cp + valence table) as end-caps
static PatchTable * Create(TopologyRefiner const &refiner, Options options=Options())
Instantiates a PatchTable from a client-provided TopologyRefiner.
unsigned int generateFVarLegacyLinearPatches
Generate all linear face-varying patches (legacy)
unsigned int generateAllLevels
Include levels from &#39;firstLevel&#39; to &#39;maxLevel&#39; (Uniform mode only)
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
Container for arrays of parametric patches.
Definition: patchTable.h:55
void SetEndCapType(EndCapType e)
Set endcap patch type.
unsigned int useInfSharpPatch
Use infinitely-sharp patch.
int numFVarChannels
Number of channel indices and interpolation modes passed.
Factory for constructing a PatchTable from a TopologyRefiner.
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
Stores topology data for a specified set of refinement options.
unsigned int generateLegacySharpCornerPatches
Generate sharp regular patches at smooth corners (legacy)
unsigned int generateFVarTables
Generate face-varying patch tables.
EndCapType GetEndCapType() const
Get endcap patch type.