2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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:
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
#ifndef OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H
|
|
|
|
#define OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
#include "../far/patchTable.h"
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
namespace Far {
|
2014-03-20 21:52:42 +00:00
|
|
|
|
2015-05-26 03:34:50 +00:00
|
|
|
// Forward declarations (for internal implementation purposes):
|
2014-09-05 22:07:46 +00:00
|
|
|
class TopologyRefiner;
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2016-10-18 00:52:20 +00:00
|
|
|
/// \brief Factory for constructing a PatchTable from a TopologyRefiner
|
|
|
|
///
|
2015-05-22 18:50:01 +00:00
|
|
|
class PatchTableFactory {
|
2014-09-05 22:07:46 +00:00
|
|
|
public:
|
2013-05-16 00:53:40 +00:00
|
|
|
|
2016-09-03 03:53:24 +00:00
|
|
|
/// \brief Public options for the PatchTable factory
|
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
struct Options {
|
2013-10-05 00:06:23 +00:00
|
|
|
|
2015-04-23 23:58:45 +00:00
|
|
|
enum EndCapType {
|
|
|
|
ENDCAP_NONE = 0, ///< no endcap
|
|
|
|
ENDCAP_BILINEAR_BASIS, ///< use bilinear quads (4 cp) as end-caps
|
|
|
|
ENDCAP_BSPLINE_BASIS, ///< use BSpline basis patches (16 cp) as end-caps
|
|
|
|
ENDCAP_GREGORY_BASIS, ///< use Gregory basis patches (20 cp) as end-caps
|
|
|
|
ENDCAP_LEGACY_GREGORY ///< use legacy (2.x) Gregory patches (4 cp + valence table) as end-caps
|
|
|
|
};
|
|
|
|
|
2015-01-06 18:56:29 +00:00
|
|
|
Options(unsigned int maxIsolation=10) :
|
2014-11-11 19:27:25 +00:00
|
|
|
generateAllLevels(false),
|
2018-08-27 17:58:46 +00:00
|
|
|
includeBaseLevelIndices(true),
|
|
|
|
includeFVarBaseLevelIndices(false),
|
2014-11-11 19:27:25 +00:00
|
|
|
triangulateQuads(false),
|
|
|
|
useSingleCreasePatch(false),
|
2016-09-29 22:05:59 +00:00
|
|
|
useInfSharpPatch(false),
|
2015-01-06 18:56:29 +00:00
|
|
|
maxIsolationLevel(maxIsolation),
|
2015-04-23 23:58:45 +00:00
|
|
|
endCapType(ENDCAP_GREGORY_BASIS),
|
|
|
|
shareEndCapPatchPoints(true),
|
2018-08-27 17:58:46 +00:00
|
|
|
generateVaryingTables(true),
|
|
|
|
generateVaryingLocalPoints(true),
|
2015-02-26 21:57:47 +00:00
|
|
|
generateFVarTables(false),
|
2018-07-28 21:56:43 +00:00
|
|
|
setPatchPrecisionDouble(false),
|
|
|
|
setFVarPatchPrecisionDouble(false),
|
2016-08-19 00:21:59 +00:00
|
|
|
generateFVarLegacyLinearPatches(true),
|
2017-01-28 00:22:04 +00:00
|
|
|
generateLegacySharpCornerPatches(true),
|
2015-02-26 21:57:47 +00:00
|
|
|
numFVarChannels(-1),
|
2015-04-18 00:36:55 +00:00
|
|
|
fvarChannelIndices(0)
|
2015-04-08 01:34:05 +00:00
|
|
|
{ }
|
2014-10-13 15:52:09 +00:00
|
|
|
|
2015-04-23 23:58:45 +00:00
|
|
|
/// \brief Get endcap patch type
|
|
|
|
EndCapType GetEndCapType() const { return (EndCapType)endCapType; }
|
|
|
|
|
|
|
|
/// \brief Set endcap patch type
|
|
|
|
void SetEndCapType(EndCapType e) { endCapType = e; }
|
|
|
|
|
2018-07-28 21:56:43 +00:00
|
|
|
/// \brief Set precision of vertex patches
|
|
|
|
template <typename REAL> void SetPatchPrecision();
|
|
|
|
|
|
|
|
/// \brief Set precision of face-varying patches
|
|
|
|
template <typename REAL> void SetFVarPatchPrecision();
|
|
|
|
|
2018-08-27 17:58:46 +00:00
|
|
|
unsigned int generateAllLevels : 1, ///< Generate levels from 'firstLevel' to 'maxLevel' (Uniform mode only)
|
|
|
|
includeBaseLevelIndices : 1, ///< Include base level in patch point indices (Uniform mode only)
|
|
|
|
includeFVarBaseLevelIndices : 1, ///< Include base level in face-varying patch point indices (Uniform mode only)
|
|
|
|
triangulateQuads : 1, ///< Triangulate 'QUADS' primitives (Uniform mode only)
|
|
|
|
|
2014-10-13 15:52:09 +00:00
|
|
|
useSingleCreasePatch : 1, ///< Use single crease patch
|
2016-09-29 22:05:59 +00:00
|
|
|
useInfSharpPatch : 1, ///< Use infinitely-sharp patch
|
2015-02-26 21:57:47 +00:00
|
|
|
maxIsolationLevel : 4, ///< Cap adaptive feature isolation to the given level (max. 10)
|
|
|
|
|
2015-04-23 23:58:45 +00:00
|
|
|
// end-capping
|
|
|
|
endCapType : 3, ///< EndCapType
|
|
|
|
shareEndCapPatchPoints : 1, ///< Share endcap patch points among adjacent endcap patches.
|
|
|
|
///< currently only work with GregoryBasis.
|
|
|
|
|
2018-08-27 17:58:46 +00:00
|
|
|
// varying
|
|
|
|
generateVaryingTables : 1, ///< Generate varying patch tables
|
|
|
|
generateVaryingLocalPoints : 1, ///< Generate local points with varying patches
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
// face-varying
|
2017-01-28 00:22:04 +00:00
|
|
|
generateFVarTables : 1, ///< Generate face-varying patch tables
|
|
|
|
|
2018-07-28 21:56:43 +00:00
|
|
|
// precision
|
|
|
|
setPatchPrecisionDouble : 1, ///< Generate double-precision stencils for vertex patches
|
|
|
|
setFVarPatchPrecisionDouble : 1, ///< Generate double-precision stencils for face-varying patches
|
|
|
|
|
2017-01-28 00:22:04 +00:00
|
|
|
// legacy behaviors (default to true)
|
|
|
|
generateFVarLegacyLinearPatches : 1, ///< Generate all linear face-varying patches (legacy)
|
|
|
|
generateLegacySharpCornerPatches : 1; ///< Generate sharp regular patches at smooth corners (legacy)
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
int numFVarChannels; ///< Number of channel indices and interpolation modes passed
|
|
|
|
int const * fvarChannelIndices; ///< List containing the indices of the channels selected for the factory
|
2014-09-05 22:07:46 +00:00
|
|
|
};
|
2014-06-30 20:25:33 +00:00
|
|
|
|
2017-09-22 22:43:16 +00:00
|
|
|
/// \brief Instantiates a PatchTable from a client-provided TopologyRefiner.
|
|
|
|
///
|
|
|
|
/// A PatchTable can be constructed from a TopologyRefiner that has been
|
|
|
|
/// either adaptively or uniformly refined. In both cases, the resulting
|
|
|
|
/// patches reference vertices in the various refined levels by index,
|
|
|
|
/// and those indices accumulate with the levels in different ways.
|
|
|
|
///
|
|
|
|
/// For adaptively refined patches, patches are defined at different levels,
|
|
|
|
/// including the base level, so the indices of patch vertices include
|
2018-09-11 23:13:06 +00:00
|
|
|
/// vertices from all levels. A sparse set of patches can be created by
|
|
|
|
/// restricting the patches generated to those descending from a given set
|
|
|
|
/// of faces at the base level. This sparse set of base faces is expected
|
|
|
|
/// to be a subset of the faces that were adaptively refined in the given
|
|
|
|
/// TopologyRefiner, otherwise results are undefined.
|
2017-09-22 22:43:16 +00:00
|
|
|
///
|
|
|
|
/// For uniformly refined patches, all patches are completely defined within
|
|
|
|
/// the last level. There is often no use for intermediate levels and they
|
|
|
|
/// can usually be ignored. Indices of patch vertices might therefore be
|
|
|
|
/// expected to be defined solely within the last level. While this is true
|
|
|
|
/// for face-varying patches, for historical reasons it is not the case for
|
|
|
|
/// vertex and varying patches. Indices for vertex and varying patches include
|
|
|
|
/// the base level in addition to the last level while indices for face-varying
|
|
|
|
/// patches include only the last level.
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2018-09-11 23:13:06 +00:00
|
|
|
/// @param refiner TopologyRefiner from which to generate patches
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2018-09-11 23:13:06 +00:00
|
|
|
/// @param options Options controlling the creation of the table
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2018-09-11 23:13:06 +00:00
|
|
|
/// @param selectedFaces Only create patches for the given set of base faces.
|
|
|
|
///
|
|
|
|
/// @return A new instance of PatchTable
|
2014-06-30 20:25:33 +00:00
|
|
|
///
|
2015-05-22 18:50:01 +00:00
|
|
|
static PatchTable * Create(TopologyRefiner const & refiner,
|
2018-09-11 23:13:06 +00:00
|
|
|
Options options = Options(),
|
|
|
|
ConstIndexArray selectedFaces = ConstIndexArray());
|
2015-04-23 23:58:45 +00:00
|
|
|
|
2016-09-03 03:53:24 +00:00
|
|
|
public:
|
|
|
|
// PatchFaceTag
|
2018-09-11 23:13:06 +00:00
|
|
|
//
|
2016-09-03 03:53:24 +00:00
|
|
|
// 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.
|
|
|
|
//
|
2018-09-11 23:13:06 +00:00
|
|
|
/// \brief Obsolete internal struct accidentally exposed for public use -- due to
|
|
|
|
/// be deprecated.
|
|
|
|
//
|
2016-09-03 03:53:24 +00:00
|
|
|
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;
|
2015-04-18 00:36:55 +00:00
|
|
|
};
|
|
|
|
|
2018-07-28 21:56:43 +00:00
|
|
|
|
|
|
|
template <> inline void PatchTableFactory::Options::SetPatchPrecision<float>() {
|
|
|
|
setPatchPrecisionDouble = false;
|
|
|
|
}
|
|
|
|
template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<float>() {
|
|
|
|
setFVarPatchPrecisionDouble = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <> inline void PatchTableFactory::Options::SetPatchPrecision<double>() {
|
|
|
|
setPatchPrecisionDouble = true;
|
|
|
|
}
|
|
|
|
template <> inline void PatchTableFactory::Options::SetFVarPatchPrecision<double>() {
|
|
|
|
setFVarPatchPrecisionDouble = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
} // end namespace Far
|
2013-11-16 01:42:57 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
2015-04-18 00:36:55 +00:00
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
#endif /* OPENSUBDIV3_FAR_PATCH_TABLE_FACTORY_H */
|