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),
68  numFVarChannels(-1),
70  { }
71 
74 
77 
78  unsigned int generateAllLevels : 1,
79  triangulateQuads : 1,
81  useInfSharpPatch : 1,
82  maxIsolationLevel : 4,
83 
84  // end-capping
85  endCapType : 3,
87 
89  // face-varying
90  generateFVarTables : 1,
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 */
use legacy (2.x) Gregory patches (4 cp + valence table) as end-caps
Container for arrays of parametric patches.
Definition: patchTable.h:55
unsigned int generateFVarTables
Generate face-varying patch tables.
void SetEndCapType(EndCapType e)
Set endcap patch type.
Factory for constructing a PatchTable from a TopologyRefiner.
Stores topology data for a specified set of refinement options.
EndCapType GetEndCapType() const
Get endcap patch type.
unsigned int useInfSharpPatch
Use infinitely-sharp patch.
unsigned int triangulateQuads
Triangulate &#39;QUADS&#39; primitives (Uniform mode only)
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
int numFVarChannels
Number of channel indices and interpolation modes passed.
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.
static PatchTable * Create(TopologyRefiner const &refiner, Options options=Options())
Factory constructor for PatchTable.