Refactored Far::PatchTableFactory

Re-organized the implementation of the patch table factory
in advance of adding support for bicubic face-varying patches.

- Renamed the AdaptiveContext internal class to BuilderContext
  since this can be used (eventually) to build patch tables for
  uniformly refined topology as well as adaptively refined
  topology.
- Added utility methods to gather patch vertices from the
  levels (and eventually fvarLevels) of a refiner.
- Replaced the FVarChannelCursor with a simpler array of integer
  face-varying channel indices.
- Extracted the topology inspection needed to identify
  patches into a computePatchTag() method.
- Simplified the two-pass traversal of the topology into a
  single pass traversal of the refined topology followed by
  an iteration over the patches that have been identified.
- Replaced internal templated PatchTypes class with simpler
  and more direct accounting and patch array building facilities.
- Changed the API of the end cap patch factories to no longer
  depend on the patch table factory's PatchFaceTag. This has
  been superseded by the specification of appropriate
  VSpans at the corners of the end patch.
This commit is contained in:
David G Yu 2016-07-21 18:47:44 -07:00
parent 4da88a8503
commit 35d8519895
8 changed files with 666 additions and 759 deletions

View File

@ -78,7 +78,6 @@ ConstIndexArray
EndCapBSplineBasisPatchFactory::GetPatchPoints(
Vtr::internal::Level const * level, Index thisFace,
Vtr::internal::Level::VSpan const cornerSpans[],
PatchTableFactory::PatchFaceTag const * /* levelPatchTags */,
int levelVertOffset) {
//

View File

@ -25,8 +25,8 @@
#ifndef OPENSUBDIV3_FAR_END_CAP_BSPLINE_BASIS_PATCH_FACTORY_H
#define OPENSUBDIV3_FAR_END_CAP_BSPLINE_BASIS_PATCH_FACTORY_H
#include "../far/patchTableFactory.h"
#include "../far/gregoryBasis.h"
#include "../far/types.h"
#include "../vtr/level.h"
namespace OpenSubdiv {
@ -74,14 +74,11 @@ public:
///
/// @param faceIndex vtr faceIndex at the level
///
/// @param levelPatchTags Array of patchTags for all faces in the level
///
/// @param levelVertOffset relative offset of patch vertex indices
///
ConstIndexArray GetPatchPoints(
Vtr::internal::Level const * level, Index faceIndex,
Vtr::internal::Level::VSpan const cornerSpans[],
PatchTableFactory::PatchFaceTag const * levelPatchTags,
int levelVertOffset);
private:

View File

@ -131,7 +131,6 @@ ConstIndexArray
EndCapGregoryBasisPatchFactory::GetPatchPoints(
Vtr::internal::Level const * level, Index faceIndex,
Vtr::internal::Level::VSpan const cornerSpans[],
PatchTableFactory::PatchFaceTag const * levelPatchTags,
int levelVertOffset) {
// allocate indices (awkward)
@ -179,8 +178,7 @@ EndCapGregoryBasisPatchFactory::GetPatchPoints(
// - exist (no boundary)
// - have already been processed (known CV indices)
// - are also Gregory basis patches
if ((adjFaceIndex != Vtr::INDEX_INVALID) && (adjFaceIndex < faceIndex) &&
(! levelPatchTags[adjFaceIndex]._isRegular)) {
if ((adjFaceIndex != Vtr::INDEX_INVALID) && (adjFaceIndex < faceIndex)) {
ConstIndexArray aedges = level->getFaceEdges(adjFaceIndex);
int aedge = aedges.FindIndexIn4Tuple(edge);

View File

@ -25,7 +25,6 @@
#ifndef OPENSUBDIV3_FAR_END_CAP_GREGORY_BASIS_PATCH_FACTORY_H
#define OPENSUBDIV3_FAR_END_CAP_GREGORY_BASIS_PATCH_FACTORY_H
#include "../far/patchTableFactory.h"
#include "../far/gregoryBasis.h"
#include "../far/stencilTable.h"
#include "../vtr/level.h"
@ -100,15 +99,11 @@ public:
/// @param faceIndex vtr faceIndex at the level
//
/// @param cornerSpans information about topology for each corner of patch
///
/// @param levelPatchTags Array of patchTags for all faces in the level
///
/// @param levelVertOffset relative offset of patch vertex indices
///
ConstIndexArray GetPatchPoints(
Vtr::internal::Level const * level, Index faceIndex,
Vtr::internal::Level::VSpan const cornerSpans[],
PatchTableFactory::PatchFaceTag const * levelPatchTags,
int levelVertOffset);
private:

View File

@ -41,15 +41,13 @@ EndCapLegacyGregoryPatchFactory::EndCapLegacyGregoryPatchFactory(
ConstIndexArray
EndCapLegacyGregoryPatchFactory::GetPatchPoints(
Vtr::internal::Level const * level, Index faceIndex,
PatchTableFactory::PatchFaceTag const * levelPatchTags,
Vtr::internal::Level::VSpan const cornerSpans[],
int levelVertOffset) {
PatchTableFactory::PatchFaceTag patchTag = levelPatchTags[faceIndex];
// Gregory Regular Patch (4 CVs + quad-offsets / valence tables)
Vtr::ConstIndexArray faceVerts = level->getFaceVertices(faceIndex);
if (patchTag._boundaryCount) {
if (level->getFaceCompositeVTag(faceVerts)._boundary) {
for (int j = 0; j < 4; ++j) {
// apply level offset
_gregoryBoundaryTopology.push_back(faceVerts[j] + levelVertOffset);

View File

@ -25,7 +25,8 @@
#ifndef OPENSUBDIV3_FAR_END_CAP_LEGACY_GREGORY_PATCH_FACTORY_H
#define OPENSUBDIV3_FAR_END_CAP_LEGACY_GREGORY_PATCH_FACTORY_H
#include "../far/patchTableFactory.h"
#include "../far/patchTable.h"
#include "../far/types.h"
#include "../vtr/level.h"
namespace OpenSubdiv {
@ -55,13 +56,12 @@ public:
///
/// @param faceIndex vtr faceIndex at the level
///
/// @param levelPatchTags Array of patchTags for all faces in the level
///
/// @param levelVertOffset relative offset of patch vertex indices
///
ConstIndexArray GetPatchPoints(Vtr::internal::Level const * level, Index faceIndex,
PatchTableFactory::PatchFaceTag const * levelPatchTags,
int levelVertOffset);
ConstIndexArray GetPatchPoints(
Vtr::internal::Level const * level, Index faceIndex,
Vtr::internal::Level::VSpan const cornerSpans[],
int levelVertOffset);
void Finalize(int maxValence,
PatchTable::QuadOffsetsTable *quadOffsetsTable,

File diff suppressed because it is too large Load Diff

View File

@ -58,7 +58,6 @@ public:
//
struct PatchFaceTag {
public:
unsigned int _hasPatch : 1;
unsigned int _isRegular : 1;
unsigned int _transitionMask : 4;
unsigned int _boundaryMask : 4;
@ -70,9 +69,6 @@ public:
void clear();
void assignBoundaryPropertiesFromEdgeMask(int boundaryEdgeMask);
void assignBoundaryPropertiesFromVertexMask(int boundaryVertexMask);
void assignTransitionPropertiesFromEdgeMask(int transitionMask) {
_transitionMask = transitionMask;
}
};
typedef std::vector<PatchFaceTag> PatchTagVector;
@ -135,7 +131,7 @@ private:
//
// Private helper structures
//
struct AdaptiveContext;
struct BuilderContext;
//
// Methods for allocating and managing the patch table data arrays:
@ -150,25 +146,24 @@ private:
// High-level methods for identifying and populating patches associated with faces:
//
static void identifyAdaptivePatches(AdaptiveContext & state);
static bool computePatchTag(BuilderContext & context,
Index const levelIndex,
Index const faceIndex,
PatchTableFactory::PatchFaceTag &patchTag);
static void populateAdaptivePatches(AdaptiveContext & state,
PtexIndices const &ptexIndices);
static void identifyAdaptivePatches(BuilderContext & context);
static void allocateVertexTables(PatchTable * table, int nlevels, bool hasSharpness);
static void populateAdaptivePatches(BuilderContext & context,
PatchTable * table);
static void allocateFVarChannels(TopologyRefiner const & refiner,
Options options, int npatches, PatchTable * table);
static void allocateVertexTables(PatchTable * table, bool hasSharpness);
static PatchParam * computePatchParam(TopologyRefiner const & refiner,
PtexIndices const & ptexIndices,
int level, int face,
int boundaryMask, int transitionMask, PatchParam * coord);
static int gatherFVarData(AdaptiveContext & state,
int level, Index faceIndex, Index levelFaceOffset, int rotation,
Index const * levelOffsets, Index fofss, Index ** fptrs);
static void allocateFVarChannels(BuilderContext const & context,
PatchTable * table);
static PatchParam computePatchParam(BuilderContext const & context,
int level, int face,
int boundaryMask, int transitionMask);
};
} // end namespace Far