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/topologyRefiner.h"
31 #include "../far/patchTable.h"
32 
33 namespace OpenSubdiv {
34 namespace OPENSUBDIV_VERSION {
35 
36 namespace Far {
37 
41 public:
42 
45  struct Options {
46 
55  enum EndCapType {
61  };
62 
63  Options(unsigned int maxIsolation=10) :
64  generateAllLevels(false),
67  triangulateQuads(false),
68  useSingleCreasePatch(false),
69  useInfSharpPatch(false),
70  maxIsolationLevel(maxIsolation),
75  generateFVarTables(false),
76  patchPrecisionDouble(false),
80  numFVarChannels(-1),
82  { }
83 
86 
89 
91  template <typename REAL> void SetPatchPrecision();
92 
94  template <typename REAL> void SetFVarPatchPrecision();
95 
99 
100  adaptiveOptions.useInfSharpPatch = useInfSharpPatch;
101  adaptiveOptions.useSingleCreasePatch = useSingleCreasePatch;
102  adaptiveOptions.considerFVarChannels = generateFVarTables &&
104  return adaptiveOptions;
105  }
106 
107  unsigned int generateAllLevels : 1,
110  triangulateQuads : 1,
111 
113  useInfSharpPatch : 1,
114  maxIsolationLevel : 4,
115 
116  // end-capping
117  endCapType : 3,
119 
121  // varying
124 
125  // face-varying
126  generateFVarTables : 1,
127 
128  // precision
131 
132  // legacy behaviors (default to true)
135 
137  int const * fvarChannelIndices;
138  };
139 
172  static PatchTable * Create(TopologyRefiner const & refiner,
173  Options options = Options(),
174  ConstIndexArray selectedFaces = ConstIndexArray());
175 
176 public:
177  // PatchFaceTag
178  //
179  // This simple struct was previously used within the factory to take inventory of
180  // various kinds of patches to fully allocate buffers prior to populating them. It
181  // was not intended to be exposed as part of the public interface.
182  //
183  // It is no longer used internally and is being kept here to respect preservation
184  // of the public interface, but it will be deprecated at the earliest opportunity.
185  //
188  //
189  struct PatchFaceTag {
190  public:
191  unsigned int _hasPatch : 1;
192  unsigned int _isRegular : 1;
193  unsigned int _transitionMask : 4;
194  unsigned int _boundaryMask : 4;
195  unsigned int _boundaryIndex : 2;
196  unsigned int _boundaryCount : 3;
197  unsigned int _hasBoundaryEdge : 3;
198  unsigned int _isSingleCrease : 1;
199 
200  void clear();
201  void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
202  void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
203  void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask);
204  };
205  typedef std::vector<PatchFaceTag> PatchTagVector;
206 };
207 
208 
209 template <> inline void PatchTableFactory::Options::SetPatchPrecision<float>() {
210  patchPrecisionDouble = false;
211 }
212 template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<float>() {
213  fvarPatchPrecisionDouble = false;
214 }
215 
216 template <> inline void PatchTableFactory::Options::SetPatchPrecision<double>() {
217  patchPrecisionDouble = true;
218 }
219 template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<double>() {
220  fvarPatchPrecisionDouble = true;
221 }
222 
223 
224 } // end namespace Far
225 
226 } // end namespace OPENSUBDIV_VERSION
227 using namespace OPENSUBDIV_VERSION;
228 
229 } // end namespace OpenSubdiv
230 
231 
232 #endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
EndCapType GetEndCapType() const
Get endcap basis type.
void SetEndCapType(EndCapType e)
Set endcap basis type.
static PatchTable * Create(TopologyRefiner const &refiner, Options options=Options(), ConstIndexArray selectedFaces=ConstIndexArray())
Instantiates a PatchTable from a client-provided TopologyRefiner.
int numFVarChannels
Number of channel indices and interpolation modes passed.
unsigned int includeFVarBaseLevelIndices
Include base level in face-varying patch point indices (Uniform mode only)
void SetPatchPrecision()
Set precision of vertex patches.
unsigned int includeBaseLevelIndices
Include base level in patch point indices (Uniform mode only)
unsigned int generateVaryingTables
Generate varying patch tables.
unsigned int generateFVarTables
Generate face-varying patch tables.
unsigned int generateLegacySharpCornerPatches
Generate sharp regular patches at smooth corners (legacy)
Factory for constructing a PatchTable from a TopologyRefiner.
unsigned int generateFVarLegacyLinearPatches
Generate all linear face-varying patches (legacy)
unsigned int generateAllLevels
Generate levels from 'firstLevel' to 'maxLevel' (Uniform mode only)
Stores topology data for a specified set of refinement options.
unsigned int triangulateQuads
Triangulate 'QUADS' primitives (Uniform mode only)
Container for arrays of parametric patches.
Definition: patchTable.h:55
unsigned int patchPrecisionDouble
Generate double-precision stencils for vertex patches.
Vtr::ConstIndexArray ConstIndexArray
Definition: types.h:47
EndCapType
Choice for approximating irregular patches (end-caps)
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
unsigned int fvarPatchPrecisionDouble
Generate double-precision stencils for face-varying patches.
unsigned int generateVaryingLocalPoints
Generate local points with varying patches.
TopologyRefiner::AdaptiveOptions GetRefineAdaptiveOptions() const
Determine adaptive refinement options to match assigned patch options.
Obsolete internal struct not intended for public use – due to be deprecated.
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
void SetFVarPatchPrecision()
Set precision of face-varying patches.