| OpenSubdiv

Loading...
Searching...
No Matches
patchTableFactory.h
Go to the documentation of this file.
1//
2// Copyright 2013 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H
9#define OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H
10
11#include "../version.h"
12
13#include "../far/topologyRefiner.h"
14#include "../far/patchTable.h"
15
16 namespace OpenSubdiv {
17 namespace OPENSUBDIV_VERSION {
18
19 namespace Far {
20
23 class PatchTableFactory {
24 public:
25
28 struct Options {
29
38 enum EndCapType {
39 ENDCAP_NONE = 0,
40 ENDCAP_BILINEAR_BASIS,
41 ENDCAP_BSPLINE_BASIS,
42 ENDCAP_GREGORY_BASIS,
43 ENDCAP_LEGACY_GREGORY
44 };
45
46 Options(unsigned int maxIsolation=10) :
47 generateAllLevels(false),
48 includeBaseLevelIndices(true),
49 includeFVarBaseLevelIndices(false),
50 triangulateQuads(false),
51 useSingleCreasePatch(false),
52 useInfSharpPatch(false),
53 maxIsolationLevel(maxIsolation & 0xf),
54 endCapType(ENDCAP_GREGORY_BASIS),
55 shareEndCapPatchPoints(true),
56 generateVaryingTables(true),
57 generateVaryingLocalPoints(true),
58 generateFVarTables(false),
59 patchPrecisionDouble(false),
60 fvarPatchPrecisionDouble(false),
61 generateFVarLegacyLinearPatches(true),
62 generateLegacySharpCornerPatches(true),
63 numFVarChannels(-1),
64 fvarChannelIndices(0)
65 { }
66
68 EndCapType GetEndCapType() const { return (EndCapType)endCapType; }
69
71 void SetEndCapType(EndCapType e) { endCapType = e & 0x7; }
72
74 void SetMaxIsolationLevel(unsigned int level) { maxIsolationLevel = level & 0xf; }
75
77 template <typename REAL> void SetPatchPrecision();
78
80 template <typename REAL> void SetFVarPatchPrecision();
81
83 TopologyRefiner::AdaptiveOptions GetRefineAdaptiveOptions() const {
84 TopologyRefiner::AdaptiveOptions adaptiveOptions(maxIsolationLevel);
85
86 adaptiveOptions.useInfSharpPatch = useInfSharpPatch;
87 adaptiveOptions.useSingleCreasePatch = useSingleCreasePatch;
88 adaptiveOptions.considerFVarChannels = generateFVarTables &&
89 !generateFVarLegacyLinearPatches;
90 return adaptiveOptions;
91 }
92
93 unsigned int generateAllLevels : 1,
94 includeBaseLevelIndices : 1,
95 includeFVarBaseLevelIndices : 1,
96 triangulateQuads : 1,
97
98 useSingleCreasePatch : 1,
99 useInfSharpPatch : 1,
100 maxIsolationLevel : 4,
101
102 // end-capping
103 endCapType : 3,
104 shareEndCapPatchPoints : 1,
106
107 // varying
108 generateVaryingTables : 1,
109 generateVaryingLocalPoints : 1,
110
111 // face-varying
112 generateFVarTables : 1,
113
114 // precision
115 patchPrecisionDouble : 1,
116 fvarPatchPrecisionDouble : 1,
117
118 // legacy behaviors (default to true)
119 generateFVarLegacyLinearPatches : 1,
120 generateLegacySharpCornerPatches : 1;
121
122 int numFVarChannels;
123 int const * fvarChannelIndices;
124 };
125
158 static PatchTable * Create(TopologyRefiner const & refiner,
159 Options options = Options(),
160 ConstIndexArray selectedFaces = ConstIndexArray());
161
162 public:
163 // PatchFaceTag
164 //
165 // This simple struct was previously used within the factory to take inventory of
166 // various kinds of patches to fully allocate buffers prior to populating them. It
167 // was not intended to be exposed as part of the public interface.
168 //
169 // It is no longer used internally and is being kept here to respect preservation
170 // of the public interface, but it will be deprecated at the earliest opportunity.
171 //
174 //
175 struct PatchFaceTag {
176 public:
177 unsigned int _hasPatch : 1;
178 unsigned int _isRegular : 1;
179 unsigned int _transitionMask : 4;
180 unsigned int _boundaryMask : 4;
181 unsigned int _boundaryIndex : 2;
182 unsigned int _boundaryCount : 3;
183 unsigned int _hasBoundaryEdge : 3;
184 unsigned int _isSingleCrease : 1;
185
186 void clear();
187 void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
188 void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
189 void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask);
190 };
191 typedef std::vector<PatchFaceTag> PatchTagVector;
192};
193
194
195 template <> inline void PatchTableFactory::Options::SetPatchPrecision<float>() {
196 patchPrecisionDouble = false;
197}
198 template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<float>() {
199 fvarPatchPrecisionDouble = false;
200}
201
202 template <> inline void PatchTableFactory::Options::SetPatchPrecision<double>() {
203 patchPrecisionDouble = true;
204}
205 template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<double>() {
206 fvarPatchPrecisionDouble = true;
207}
208
209
210} // end namespace Far
211
212} // end namespace OPENSUBDIV_VERSION
213 using namespace OPENSUBDIV_VERSION;
214
215} // end namespace OpenSubdiv
216
217
218#endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
patchTable.h
topologyRefiner.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Far::ConstIndexArray
Vtr::ConstIndexArray ConstIndexArray
Definition types.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition patchTable.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory
Factory for constructing a PatchTable from a TopologyRefiner.
Definition patchTableFactory.h:23
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchTagVector
std::vector< PatchFaceTag > PatchTagVector
Definition patchTableFactory.h:191
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:28
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateVaryingTables
unsigned int generateVaryingTables
Generate varying patch tables.
Definition patchTableFactory.h:108
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateLegacySharpCornerPatches
unsigned int generateLegacySharpCornerPatches
Generate sharp regular patches at smooth corners (legacy).
Definition patchTableFactory.h:120
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::shareEndCapPatchPoints
unsigned int shareEndCapPatchPoints
Definition patchTableFactory.h:105
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetRefineAdaptiveOptions
TopologyRefiner::AdaptiveOptions GetRefineAdaptiveOptions() const
Determine adaptive refinement options to match assigned patch options.
Definition patchTableFactory.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::maxIsolationLevel
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10).
Definition patchTableFactory.h:100
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetEndCapType
EndCapType GetEndCapType() const
Get endcap basis type.
Definition patchTableFactory.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarLegacyLinearPatches
unsigned int generateFVarLegacyLinearPatches
Generate all linear face-varying patches (legacy).
Definition patchTableFactory.h:119
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:116
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetMaxIsolationLevel
void SetMaxIsolationLevel(unsigned int level)
Set maximum isolation level.
Definition patchTableFactory.h:74
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::endCapType
unsigned int endCapType
EndCapType.
Definition patchTableFactory.h:103
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::fvarChannelIndices
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
Definition patchTableFactory.h:123
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useSingleCreasePatch
unsigned int useSingleCreasePatch
Use single crease patch.
Definition patchTableFactory.h:98
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useInfSharpPatch
unsigned int useInfSharpPatch
Use infinitely-sharp patch.
Definition patchTableFactory.h:99
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::SetEndCapType
void SetEndCapType(EndCapType e)
Set endcap basis type.
Definition patchTableFactory.h:71
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateVaryingLocalPoints
unsigned int generateVaryingLocalPoints
Generate local points with varying patches.
Definition patchTableFactory.h:109
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:95
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateAllLevels
unsigned int generateAllLevels
Generate levels from 'firstLevel' to 'maxLevel' (Uniform mode only).
Definition patchTableFactory.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::patchPrecisionDouble
unsigned int patchPrecisionDouble
Generate double-precision stencils for vertex patches.
Definition patchTableFactory.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarTables
unsigned int generateFVarTables
Generate face-varying patch tables.
Definition patchTableFactory.h:112
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::includeBaseLevelIndices
unsigned int includeBaseLevelIndices
Include base level in patch point indices (Uniform mode only).
Definition patchTableFactory.h:94
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:122
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::triangulateQuads
unsigned int triangulateQuads
Triangulate 'QUADS' primitives (Uniform mode only).
Definition patchTableFactory.h:96
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::EndCapType
EndCapType
Choice for approximating irregular patches (end-caps).
Definition patchTableFactory.h:38
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:43
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS
@ ENDCAP_GREGORY_BASIS
use Gregory patches (highest quality, recommended default)
Definition patchTableFactory.h:42
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_NONE
@ ENDCAP_NONE
unspecified
Definition patchTableFactory.h:39
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BILINEAR_BASIS
@ ENDCAP_BILINEAR_BASIS
use linear patches (simple quads or tris)
Definition patchTableFactory.h:40
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS
@ ENDCAP_BSPLINE_BASIS
use BSpline-like patches (same patch type as regular)
Definition patchTableFactory.h:41
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::Options
Options(unsigned int maxIsolation=10)
Definition patchTableFactory.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag
Obsolete internal struct not intended for public use – due to be deprecated.
Definition patchTableFactory.h:175
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isSingleCrease
unsigned int _isSingleCrease
Definition patchTableFactory.h:184
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isRegular
unsigned int _isRegular
Definition patchTableFactory.h:178
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryIndex
unsigned int _boundaryIndex
Definition patchTableFactory.h:181
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromVertexMask
void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_transitionMask
unsigned int _transitionMask
Definition patchTableFactory.h:179
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasBoundaryEdge
unsigned int _hasBoundaryEdge
Definition patchTableFactory.h:183
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryMask
unsigned int _boundaryMask
Definition patchTableFactory.h:180
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasPatch
unsigned int _hasPatch
Definition patchTableFactory.h:177
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:182
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner
Stores topology data for a specified set of refinement options.
Definition topologyRefiner.h:34
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions
Adaptive refinement options.
Definition topologyRefiner.h:139
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useSingleCreasePatch
unsigned int useSingleCreasePatch
Definition topologyRefiner.h:159
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useInfSharpPatch
unsigned int useInfSharpPatch
Definition topologyRefiner.h:161
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::considerFVarChannels
unsigned int considerFVarChannels
Definition topologyRefiner.h:163