| OpenSubdiv

Loading...
Searching...
No Matches
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
40 class PatchTableFactory {
41 public:
42
45 struct Options {
46
55 enum EndCapType {
56 ENDCAP_NONE = 0,
57 ENDCAP_BILINEAR_BASIS,
58 ENDCAP_BSPLINE_BASIS,
59 ENDCAP_GREGORY_BASIS,
60 ENDCAP_LEGACY_GREGORY
61 };
62
63 Options(unsigned int maxIsolation=10) :
64 generateAllLevels(false),
65 includeBaseLevelIndices(true),
66 includeFVarBaseLevelIndices(false),
67 triangulateQuads(false),
68 useSingleCreasePatch(false),
69 useInfSharpPatch(false),
70 maxIsolationLevel(maxIsolation & 0xf),
71 endCapType(ENDCAP_GREGORY_BASIS),
72 shareEndCapPatchPoints(true),
73 generateVaryingTables(true),
74 generateVaryingLocalPoints(true),
75 generateFVarTables(false),
76 patchPrecisionDouble(false),
77 fvarPatchPrecisionDouble(false),
78 generateFVarLegacyLinearPatches(true),
79 generateLegacySharpCornerPatches(true),
80 numFVarChannels(-1),
81 fvarChannelIndices(0)
82 { }
83
85 EndCapType GetEndCapType() const { return (EndCapType)endCapType; }
86
88 void SetEndCapType(EndCapType e) { endCapType = e & 0x7; }
89
91 void SetMaxIsolationLevel(unsigned int level) { maxIsolationLevel = level & 0xf; }
92
94 template <typename REAL> void SetPatchPrecision();
95
97 template <typename REAL> void SetFVarPatchPrecision();
98
100 TopologyRefiner::AdaptiveOptions GetRefineAdaptiveOptions() const {
101 TopologyRefiner::AdaptiveOptions adaptiveOptions(maxIsolationLevel);
102
103 adaptiveOptions.useInfSharpPatch = useInfSharpPatch;
104 adaptiveOptions.useSingleCreasePatch = useSingleCreasePatch;
105 adaptiveOptions.considerFVarChannels = generateFVarTables &&
106 !generateFVarLegacyLinearPatches;
107 return adaptiveOptions;
108 }
109
110 unsigned int generateAllLevels : 1,
111 includeBaseLevelIndices : 1,
112 includeFVarBaseLevelIndices : 1,
113 triangulateQuads : 1,
114
115 useSingleCreasePatch : 1,
116 useInfSharpPatch : 1,
117 maxIsolationLevel : 4,
118
119 // end-capping
120 endCapType : 3,
121 shareEndCapPatchPoints : 1,
123
124 // varying
125 generateVaryingTables : 1,
126 generateVaryingLocalPoints : 1,
127
128 // face-varying
129 generateFVarTables : 1,
130
131 // precision
132 patchPrecisionDouble : 1,
133 fvarPatchPrecisionDouble : 1,
134
135 // legacy behaviors (default to true)
136 generateFVarLegacyLinearPatches : 1,
137 generateLegacySharpCornerPatches : 1;
138
139 int numFVarChannels;
140 int const * fvarChannelIndices;
141 };
142
175 static PatchTable * Create(TopologyRefiner const & refiner,
176 Options options = Options(),
177 ConstIndexArray selectedFaces = ConstIndexArray());
178
179 public:
180 // PatchFaceTag
181 //
182 // This simple struct was previously used within the factory to take inventory of
183 // various kinds of patches to fully allocate buffers prior to populating them. It
184 // was not intended to be exposed as part of the public interface.
185 //
186 // It is no longer used internally and is being kept here to respect preservation
187 // of the public interface, but it will be deprecated at the earliest opportunity.
188 //
191 //
192 struct PatchFaceTag {
193 public:
194 unsigned int _hasPatch : 1;
195 unsigned int _isRegular : 1;
196 unsigned int _transitionMask : 4;
197 unsigned int _boundaryMask : 4;
198 unsigned int _boundaryIndex : 2;
199 unsigned int _boundaryCount : 3;
200 unsigned int _hasBoundaryEdge : 3;
201 unsigned int _isSingleCrease : 1;
202
203 void clear();
204 void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
205 void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
206 void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask);
207 };
208 typedef std::vector<PatchFaceTag> PatchTagVector;
209};
210
211
212 template <> inline void PatchTableFactory::Options::SetPatchPrecision<float>() {
213 patchPrecisionDouble = false;
214}
215 template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<float>() {
216 fvarPatchPrecisionDouble = false;
217}
218
219 template <> inline void PatchTableFactory::Options::SetPatchPrecision<double>() {
220 patchPrecisionDouble = true;
221}
222 template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<double>() {
223 fvarPatchPrecisionDouble = true;
224}
225
226
227} // end namespace Far
228
229} // end namespace OPENSUBDIV_VERSION
230 using namespace OPENSUBDIV_VERSION;
231
232} // end namespace OpenSubdiv
233
234
235#endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
topologyRefiner.h
patchTable.h
OpenSubdiv
Definition limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:36
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstIndexArray
Vtr::ConstIndexArray ConstIndexArray
Definition types.h:47
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition patchTable.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory
Factory for constructing a PatchTable from a TopologyRefiner.
Definition patchTableFactory.h:40
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchTagVector
std::vector< PatchFaceTag > PatchTagVector
Definition patchTableFactory.h:208
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Create
static PatchTable * Create(TopologyRefiner const &refiner, Options options=Options(), ConstIndexArray selectedFaces=ConstIndexArray())
Instantiates a PatchTable from a client-provided TopologyRefiner.
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options
Public options for the PatchTable factory.
Definition patchTableFactory.h:45
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateVaryingTables
unsigned int generateVaryingTables
Generate varying patch tables.
Definition patchTableFactory.h:125
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateLegacySharpCornerPatches
unsigned int generateLegacySharpCornerPatches
Generate sharp regular patches at smooth corners (legacy)
Definition patchTableFactory.h:137
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::shareEndCapPatchPoints
unsigned int shareEndCapPatchPoints
Definition patchTableFactory.h:122
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetRefineAdaptiveOptions
TopologyRefiner::AdaptiveOptions GetRefineAdaptiveOptions() const
Determine adaptive refinement options to match assigned patch options.
Definition patchTableFactory.h:100
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::maxIsolationLevel
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
Definition patchTableFactory.h:117
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetEndCapType
EndCapType GetEndCapType() const
Get endcap basis type.
Definition patchTableFactory.h:85
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarLegacyLinearPatches
unsigned int generateFVarLegacyLinearPatches
Generate all linear face-varying patches (legacy)
Definition patchTableFactory.h:136
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetPatchPrecision
void SetPatchPrecision()
Set precision of vertex patches.
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::fvarPatchPrecisionDouble
unsigned int fvarPatchPrecisionDouble
Generate double-precision stencils for face-varying patches.
Definition patchTableFactory.h:133
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetMaxIsolationLevel
void SetMaxIsolationLevel(unsigned int level)
Set maximum isolation level.
Definition patchTableFactory.h:91
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::endCapType
unsigned int endCapType
EndCapType.
Definition patchTableFactory.h:120
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::fvarChannelIndices
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
Definition patchTableFactory.h:140
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useSingleCreasePatch
unsigned int useSingleCreasePatch
Use single crease patch.
Definition patchTableFactory.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useInfSharpPatch
unsigned int useInfSharpPatch
Use infinitely-sharp patch.
Definition patchTableFactory.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetEndCapType
void SetEndCapType(EndCapType e)
Set endcap basis type.
Definition patchTableFactory.h:88
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateVaryingLocalPoints
unsigned int generateVaryingLocalPoints
Generate local points with varying patches.
Definition patchTableFactory.h:126
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::includeFVarBaseLevelIndices
unsigned int includeFVarBaseLevelIndices
Include base level in face-varying patch point indices (Uniform mode only)
Definition patchTableFactory.h:112
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateAllLevels
unsigned int generateAllLevels
Generate levels from 'firstLevel' to 'maxLevel' (Uniform mode only)
Definition patchTableFactory.h:110
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::patchPrecisionDouble
unsigned int patchPrecisionDouble
Generate double-precision stencils for vertex patches.
Definition patchTableFactory.h:132
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarTables
unsigned int generateFVarTables
Generate face-varying patch tables.
Definition patchTableFactory.h:129
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::includeBaseLevelIndices
unsigned int includeBaseLevelIndices
Include base level in patch point indices (Uniform mode only)
Definition patchTableFactory.h:111
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetFVarPatchPrecision
void SetFVarPatchPrecision()
Set precision of face-varying patches.
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::numFVarChannels
int numFVarChannels
Number of channel indices and interpolation modes passed.
Definition patchTableFactory.h:139
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::triangulateQuads
unsigned int triangulateQuads
Triangulate 'QUADS' primitives (Uniform mode only)
Definition patchTableFactory.h:113
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::EndCapType
EndCapType
Choice for approximating irregular patches (end-caps)
Definition patchTableFactory.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_LEGACY_GREGORY
@ ENDCAP_LEGACY_GREGORY
legacy option for 2.x style Gregory patches (Catmark only)
Definition patchTableFactory.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS
@ ENDCAP_GREGORY_BASIS
use Gregory patches (highest quality, recommended default)
Definition patchTableFactory.h:59
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_NONE
@ ENDCAP_NONE
unspecified
Definition patchTableFactory.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BILINEAR_BASIS
@ ENDCAP_BILINEAR_BASIS
use linear patches (simple quads or tris)
Definition patchTableFactory.h:57
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS
@ ENDCAP_BSPLINE_BASIS
use BSpline-like patches (same patch type as regular)
Definition patchTableFactory.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::Options
Options(unsigned int maxIsolation=10)
Definition patchTableFactory.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag
Obsolete internal struct not intended for public use – due to be deprecated.
Definition patchTableFactory.h:192
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isSingleCrease
unsigned int _isSingleCrease
Definition patchTableFactory.h:201
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isRegular
unsigned int _isRegular
Definition patchTableFactory.h:195
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryIndex
unsigned int _boundaryIndex
Definition patchTableFactory.h:198
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromVertexMask
void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_transitionMask
unsigned int _transitionMask
Definition patchTableFactory.h:196
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasBoundaryEdge
unsigned int _hasBoundaryEdge
Definition patchTableFactory.h:200
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryMask
unsigned int _boundaryMask
Definition patchTableFactory.h:197
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasPatch
unsigned int _hasPatch
Definition patchTableFactory.h:194
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignTransitionPropertiesFromEdgeMask
void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::clear
void clear()
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromEdgeMask
void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryCount
unsigned int _boundaryCount
Definition patchTableFactory.h:199
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition topologyRefiner.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions
Adaptive refinement options.
Definition topologyRefiner.h:156
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useSingleCreasePatch
unsigned int useSingleCreasePatch
Definition topologyRefiner.h:176
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useInfSharpPatch
unsigned int useInfSharpPatch
Definition topologyRefiner.h:178
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::considerFVarChannels
unsigned int considerFVarChannels
Definition topologyRefiner.h:180