Loading...
Searching...
No Matches
patchTableFactory.h
Go to the documentation of this file.
//
// Copyright 2013 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H
#define OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H
#include "../version.h"
#include "../far/topologyRefiner.h"
#include "../far/patchTable.h"
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
namespace Far {
class PatchTableFactory {
public:
struct Options {
enum EndCapType {
ENDCAP_NONE = 0,
ENDCAP_BILINEAR_BASIS,
ENDCAP_BSPLINE_BASIS,
ENDCAP_GREGORY_BASIS,
ENDCAP_LEGACY_GREGORY
};
Options(unsigned int maxIsolation=10) :
generateAllLevels(false),
includeBaseLevelIndices(true),
includeFVarBaseLevelIndices(false),
triangulateQuads(false),
useSingleCreasePatch(false),
useInfSharpPatch(false),
maxIsolationLevel(maxIsolation),
endCapType(ENDCAP_GREGORY_BASIS),
shareEndCapPatchPoints(true),
generateVaryingTables(true),
generateVaryingLocalPoints(true),
generateFVarTables(false),
patchPrecisionDouble(false),
fvarPatchPrecisionDouble(false),
generateFVarLegacyLinearPatches(true),
generateLegacySharpCornerPatches(true),
numFVarChannels(-1),
fvarChannelIndices(0)
{ }
EndCapType GetEndCapType() const { return (EndCapType)endCapType; }
void SetEndCapType(EndCapType e) { endCapType = e; }
template <typename REAL> void SetPatchPrecision();
template <typename REAL> void SetFVarPatchPrecision();
TopologyRefiner::AdaptiveOptions GetRefineAdaptiveOptions() const {
TopologyRefiner::AdaptiveOptions adaptiveOptions(maxIsolationLevel);
adaptiveOptions.useInfSharpPatch = useInfSharpPatch;
adaptiveOptions.useSingleCreasePatch = useSingleCreasePatch;
adaptiveOptions.considerFVarChannels = generateFVarTables &&
!generateFVarLegacyLinearPatches;
return adaptiveOptions;
}
unsigned int generateAllLevels : 1,
includeBaseLevelIndices : 1,
includeFVarBaseLevelIndices : 1,
triangulateQuads : 1,
useSingleCreasePatch : 1,
useInfSharpPatch : 1,
maxIsolationLevel : 4,
// end-capping
endCapType : 3,
shareEndCapPatchPoints : 1,
// varying
generateVaryingTables : 1,
generateVaryingLocalPoints : 1,
// face-varying
generateFVarTables : 1,
// precision
patchPrecisionDouble : 1,
fvarPatchPrecisionDouble : 1,
// legacy behaviors (default to true)
generateFVarLegacyLinearPatches : 1,
generateLegacySharpCornerPatches : 1;
int numFVarChannels;
int const * fvarChannelIndices;
};
static PatchTable * Create(TopologyRefiner const & refiner,
Options options = Options(),
ConstIndexArray selectedFaces = ConstIndexArray());
public:
// PatchFaceTag
//
// This simple struct was previously used within the factory to take inventory of
// various kinds of patches to fully allocate buffers prior to populating them. It
// was not intended to be exposed as part of the public interface.
//
// It is no longer used internally and is being kept here to respect preservation
// of the public interface, but it will be deprecated at the earliest opportunity.
//
//
struct PatchFaceTag {
public:
unsigned int _hasPatch : 1;
unsigned int _isRegular : 1;
unsigned int _transitionMask : 4;
unsigned int _boundaryMask : 4;
unsigned int _boundaryIndex : 2;
unsigned int _boundaryCount : 3;
unsigned int _hasBoundaryEdge : 3;
unsigned int _isSingleCrease : 1;
void clear();
void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
void assignTransitionPropertiesFromEdgeMask(int boundaryVertexMask);
};
typedef std::vector<PatchFaceTag> PatchTagVector;
};
template <> inline void PatchTableFactory::Options::SetPatchPrecision<float>() {
patchPrecisionDouble = false;
}
template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<float>() {
fvarPatchPrecisionDouble = false;
}
template <> inline void PatchTableFactory::Options::SetPatchPrecision<double>() {
patchPrecisionDouble = true;
}
template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<double>() {
fvarPatchPrecisionDouble = true;
}
} // end namespace Far
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
topologyRefiner.h
patchTable.h
OpenSubdiv
Definition error.h:30
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:205
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:122
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateLegacySharpCornerPatches
unsigned int generateLegacySharpCornerPatches
Generate sharp regular patches at smooth corners (legacy)
Definition patchTableFactory.h:134
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::shareEndCapPatchPoints
unsigned int shareEndCapPatchPoints
Definition patchTableFactory.h:119
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::GetRefineAdaptiveOptions
TopologyRefiner::AdaptiveOptions GetRefineAdaptiveOptions() const
Determine adaptive refinement options to match assigned patch options.
Definition patchTableFactory.h:97
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::maxIsolationLevel
unsigned int maxIsolationLevel
Cap adaptive feature isolation to the given level (max. 10)
Definition patchTableFactory.h:114
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:133
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:130
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::endCapType
unsigned int endCapType
EndCapType.
Definition patchTableFactory.h:117
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::fvarChannelIndices
int const * fvarChannelIndices
List containing the indices of the channels selected for the factory.
Definition patchTableFactory.h:137
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useSingleCreasePatch
unsigned int useSingleCreasePatch
Use single crease patch.
Definition patchTableFactory.h:112
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::useInfSharpPatch
unsigned int useInfSharpPatch
Use infinitely-sharp patch.
Definition patchTableFactory.h:113
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:123
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:109
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateAllLevels
unsigned int generateAllLevels
Generate levels from 'firstLevel' to 'maxLevel' (Uniform mode only)
Definition patchTableFactory.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::patchPrecisionDouble
unsigned int patchPrecisionDouble
Generate double-precision stencils for vertex patches.
Definition patchTableFactory.h:129
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::generateFVarTables
unsigned int generateFVarTables
Generate face-varying patch tables.
Definition patchTableFactory.h:126
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::includeBaseLevelIndices
unsigned int includeBaseLevelIndices
Include base level in patch point indices (Uniform mode only)
Definition patchTableFactory.h:108
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:136
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::Options::triangulateQuads
unsigned int triangulateQuads
Triangulate 'QUADS' primitives (Uniform mode only)
Definition patchTableFactory.h:110
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:189
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isSingleCrease
unsigned int _isSingleCrease
Definition patchTableFactory.h:198
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_isRegular
unsigned int _isRegular
Definition patchTableFactory.h:192
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryIndex
unsigned int _boundaryIndex
Definition patchTableFactory.h:195
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::assignBoundaryPropertiesFromVertexMask
void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask)
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_transitionMask
unsigned int _transitionMask
Definition patchTableFactory.h:193
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasBoundaryEdge
unsigned int _hasBoundaryEdge
Definition patchTableFactory.h:197
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_boundaryMask
unsigned int _boundaryMask
Definition patchTableFactory.h:194
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTableFactory::PatchFaceTag::_hasPatch
unsigned int _hasPatch
Definition patchTableFactory.h:191
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:196
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:153
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useSingleCreasePatch
unsigned int useSingleCreasePatch
Definition topologyRefiner.h:167
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::useInfSharpPatch
unsigned int useInfSharpPatch
Definition topologyRefiner.h:169
OpenSubdiv::OPENSUBDIV_VERSION::Far::TopologyRefiner::AdaptiveOptions::considerFVarChannels
unsigned int considerFVarChannels
Definition topologyRefiner.h:171
OpenSubdiv::OPENSUBDIV_VERSION::Vtr::ConstArray< Index >