Modify Far::TopologyRefiner refinement options

- move level of refinement / isolation into the Options structs
- fix splash damage in rest of the code

note 1: this is less than ideal, because most compilers accept the previous
        call to these functions with an incorrect parameter list (ie. passing
        the level instead of the struct issues no warnings and compiles...)
        caveat emptor...

note 2: the level parameter names may not be final for adaptive modes
        as we will likely want independent controls over crease vs.
        extraordinary vertex isolation.
This commit is contained in:
manuelk 2014-12-30 14:07:24 -08:00
parent 7954fbab37
commit bfbd868fe2
18 changed files with 50 additions and 57 deletions

View File

@ -356,7 +356,8 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level) {
{
// Apply feature adaptive refinement to the mesh so that we can use the
// limit evaluation API features.
g_topologyRefiner->RefineAdaptive(level);
Far::TopologyRefiner::AdaptiveOptions options(level);
g_topologyRefiner->RefineAdaptive(options);
nverts = g_topologyRefiner->GetNumVerticesTotal();

View File

@ -619,9 +619,9 @@ createOsdMesh( const std::string &shapeStr, int level, Scheme scheme=kCatmark )
bool doAdaptive = (g_adaptive!=0 and scheme==kCatmark);
if (doAdaptive) {
refiner->RefineAdaptive(level);
refiner->RefineAdaptive(Far::TopologyRefiner::AdaptiveOptions(level));
} else {
refiner->RefineUniform(level);
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(level));
}
Far::StencilTables const * vertexStencils=0, * varyingStencils=0;

View File

@ -281,7 +281,7 @@ updateGeom() {
//------------------------------------------------------------------------------
static void
createMesh(ShapeDesc const & shapeDesc, int isolationLevel) {
createMesh(ShapeDesc const & shapeDesc, int level) {
typedef Far::ConstIndexArray IndexArray;
typedef Far::LimitStencilTablesFactory::LocationArray LocationArray;
@ -317,17 +317,14 @@ createMesh(ShapeDesc const & shapeDesc, int isolationLevel) {
g_orgPositions=shape->verts;
if (g_bilinear) {
Far::TopologyRefiner::UniformOptions options;
Far::TopologyRefiner::UniformOptions options(level);
options.fullTopologyInLastLevel = true;
refiner->RefineUniform(isolationLevel, options);
refiner->RefineUniform(options);
} else {
Far::TopologyRefiner::AdaptiveOptions options;
Far::TopologyRefiner::AdaptiveOptions options(level);
options.fullTopologyInLastLevel = false;
options.useSingleCreasePatch = false;
refiner->RefineAdaptive(isolationLevel, options);
refiner->RefineAdaptive(options);
}
int nfaces = refiner->GetNumPtexFaces();

View File

@ -647,7 +647,7 @@ MayaPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
assert(refiner);
// Refine & Interpolate
refiner->RefineUniform(subdivisionLevel);
refiner->RefineUniform(OpenSubdiv::Far::TopologyRefiner::UniformOptions(subdivisionLevel));
Vertex const * controlVerts =
reinterpret_cast<Vertex const *>(inMeshFn.getRawPoints(&status));

View File

@ -663,16 +663,14 @@ createVtrMesh(Shape * shape, int maxlevel) {
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Create(sdctype, sdcoptions, *shape);
if (g_Adaptive) {
OpenSubdiv::Far::TopologyRefiner::AdaptiveOptions options;
OpenSubdiv::Far::TopologyRefiner::AdaptiveOptions options(maxlevel);
options.fullTopologyInLastLevel = true;
options.useSingleCreasePatch = false;
refiner->RefineAdaptive(maxlevel, options);
refiner->RefineAdaptive(options);
} else {
OpenSubdiv::Far::TopologyRefiner::UniformOptions options;
OpenSubdiv::Far::TopologyRefiner::UniformOptions options(maxlevel);
options.fullTopologyInLastLevel = true;
refiner->RefineUniform(maxlevel, options);
refiner->RefineUniform(options);
}
//

View File

@ -317,7 +317,7 @@ TopologyRefiner::GetPtexAdjacency(int face, int quadrant,
// Main refinement method -- allocating and initializing levels and refinements:
//
void
TopologyRefiner::RefineUniform(int maxLevel, UniformOptions options) {
TopologyRefiner::RefineUniform(UniformOptions options) {
assert(_levels[0]->getNumVertices() > 0); // Make sure the base level has been initialized
@ -325,7 +325,7 @@ TopologyRefiner::RefineUniform(int maxLevel, UniformOptions options) {
// Allocate the stack of levels and the refinements between them:
//
_isUniform = true;
_maxLevel = maxLevel;
_maxLevel = options.refinementLevel;
Sdc::Split splitType = (_subdivType == Sdc::TYPE_LOOP) ? Sdc::SPLIT_TO_TRIS : Sdc::SPLIT_TO_QUADS;
@ -335,9 +335,9 @@ TopologyRefiner::RefineUniform(int maxLevel, UniformOptions options) {
Vtr::Refinement::Options refineOptions;
refineOptions._sparse = false;
for (int i = 1; i <= maxLevel; ++i) {
for (int i = 1; i <= options.refinementLevel; ++i) {
refineOptions._faceTopologyOnly =
options.fullTopologyInLastLevel ? false : (i == maxLevel);
options.fullTopologyInLastLevel ? false : (i == options.refinementLevel);
Vtr::Level& parentLevel = getLevel(i-1);
Vtr::Level& childLevel = *(new Vtr::Level);
@ -357,7 +357,7 @@ TopologyRefiner::RefineUniform(int maxLevel, UniformOptions options) {
void
TopologyRefiner::RefineAdaptive(int subdivLevel, AdaptiveOptions options ) {
TopologyRefiner::RefineAdaptive(AdaptiveOptions options) {
assert(_levels[0]->getNumVertices() > 0); // Make sure the base level has been initialized
@ -365,7 +365,7 @@ TopologyRefiner::RefineAdaptive(int subdivLevel, AdaptiveOptions options ) {
// Allocate the stack of levels and the refinements between them:
//
_isUniform = false;
_maxLevel = subdivLevel;
_maxLevel = options.isolationLevel;
_useSingleCreasePatch = options.useSingleCreasePatch;
//
@ -378,7 +378,7 @@ TopologyRefiner::RefineAdaptive(int subdivLevel, AdaptiveOptions options ) {
Sdc::Split splitType = (_subdivType == Sdc::TYPE_LOOP) ? Sdc::SPLIT_TO_TRIS : Sdc::SPLIT_TO_QUADS;
for (int i = 1; i <= subdivLevel; ++i) {
for (int i = 1; i <= options.isolationLevel; ++i) {
// Keeping full topology on for debugging -- may need to go back a level and "prune"
// its topology if we don't use the full depth
refineOptions._faceTopologyOnly = false;

View File

@ -104,20 +104,20 @@ public:
/// \brief Uniform refinement options
struct UniformOptions {
UniformOptions() :
UniformOptions(int level) :
refinementLevel(level),
fullTopologyInLastLevel(false) { }
unsigned int fullTopologyInLastLevel:1; ///< Skip secondary topological relationships
unsigned int refinementLevel:4, ///< Number of refinement iterations
fullTopologyInLastLevel:1; ///< Skip secondary topological relationships
///< at the highest level of refinement.
};
/// \brief Refine the topology uniformly
///
/// @param maxLevel Highest level of subdivision refinement
/// @param options Options controlling uniform refinement
///
/// @param options Options controlling the creation of the tables
///
void RefineUniform(int maxLevel, UniformOptions options=UniformOptions());
void RefineUniform(UniformOptions options);
//
// Adaptive refinement
@ -126,11 +126,14 @@ public:
/// \brief Adaptive refinement options
struct AdaptiveOptions {
AdaptiveOptions() :
AdaptiveOptions(int level) :
isolationLevel(level),
fullTopologyInLastLevel(false),
useSingleCreasePatch(false) { }
unsigned int fullTopologyInLastLevel:1, ///< Skip secondary topological relationships
unsigned int isolationLevel:4, ///< Number of iterations applied to isolate
///< extraordinary vertices and creases
fullTopologyInLastLevel:1, ///< Skip secondary topological relationships
///< at the highest level of refinement.
useSingleCreasePatch:1; ///< Use 'single-crease' patch and stop
///< isolation where applicable
@ -138,11 +141,9 @@ public:
/// \brief Feature Adaptive topology refinement
///
/// @param maxLevel Highest level of subdivision refinement
/// @param options Options controlling adaptive refinement
///
/// @param options Options controlling the creation of the tables
///
void RefineAdaptive(int maxLevel, AdaptiveOptions options=AdaptiveOptions());
void RefineAdaptive(AdaptiveOptions options);
/// \brief Unrefine the topology (keep control cage)
void Unrefine();

View File

@ -101,16 +101,14 @@ protected:
bool fullTopologyInLastLevel = refiner.GetNumFVarChannels()>0;
if (adaptive) {
Far::TopologyRefiner::AdaptiveOptions options;
Far::TopologyRefiner::AdaptiveOptions options(level);
options.fullTopologyInLastLevel = fullTopologyInLastLevel;
options.useSingleCreasePatch = singleCreasePatch;
refiner.RefineAdaptive(level, options);
refiner.RefineAdaptive(options);
} else {
Far::TopologyRefiner::UniformOptions options;
Far::TopologyRefiner::UniformOptions options(level);
options.fullTopologyInLastLevel = fullTopologyInLastLevel;
refiner.RefineUniform(level, options);
refiner.RefineUniform(options);
}
}
};

View File

@ -155,10 +155,9 @@ interpolateVtrVertexData(ShapeDesc const & desc, int maxlevel, std::vector<xyzVV
GetSdcType(*shape), GetSdcOptions(*shape), *shape);
assert(refiner);
FarTopologyRefiner::UniformOptions options;
FarTopologyRefiner::UniformOptions options(maxlevel);
options.fullTopologyInLastLevel=true;
refiner->RefineUniform(maxlevel, options);
refiner->RefineUniform(options);
// populate coarse mesh positions
data.resize(refiner->GetNumVerticesTotal());

View File

@ -125,7 +125,7 @@ int main(int, char **) {
int maxlevel = 2;
// Uniformly refine the topolgy up to 'maxlevel'
refiner->RefineUniform( maxlevel );
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
// Allocate a buffer for vertex primvar data. The buffer length is set to

View File

@ -425,7 +425,7 @@ int main(int, char **) {
int maxlevel = 5;
// Uniformly refine the topolgy up to 'maxlevel'
refiner->RefineUniform( maxlevel );
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
// Allocate a buffer for vertex primvar data. The buffer length is set to

View File

@ -139,7 +139,7 @@ int main(int, char **) {
Far::TopologyRefiner * refiner = createFarTopologyRefiner();
// Uniformly refine the topolgy up to 'maxlevel'
refiner->RefineUniform( maxlevel );
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
// Allocate a buffer for vertex primvar data. The buffer length is set to
// be the sum of all children vertices up to the highest level of refinement.

View File

@ -192,10 +192,9 @@ int main(int, char **) {
// Uniformly refine the topolgy up to 'maxlevel'
// note: fullTopologyInLastLevel must be true to work with face-varying data
{
Far::TopologyRefiner::UniformOptions options;
Far::TopologyRefiner::UniformOptions options(maxlevel);
options.fullTopologyInLastLevel = true;
refiner->RefineUniform( maxlevel, options );
refiner->RefineUniform(options);
}
// Allocate & interpolate the 'vertex' primvar data (see tutorial 2 for

View File

@ -115,7 +115,7 @@ int main(int, char **) {
// Uniformly refine the topolgy up to 'maxlevel'.
int maxlevel = 3;
refiner->RefineUniform( maxlevel );
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
// Use the FarStencilTables factory to create discrete stencil tables

View File

@ -119,7 +119,7 @@ int main(int, char **) {
// Uniformly refine the topolgy up to 'maxlevel'.
int maxlevel = 4;
refiner->RefineUniform( maxlevel );
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
int nverts = refiner->GetNumVertices(maxlevel);

View File

@ -140,7 +140,7 @@ int main(int, char **) {
// Adaptively refine the topology with an isolation level capped at 3
// because the sharpest crease in the shape is 3.0f (in g_creaseweights[])
int maxIsolation = 3;
refiner->RefineAdaptive(maxIsolation);
refiner->RefineAdaptive(Far::TopologyRefiner::AdaptiveOptions(maxIsolation));
// Create a buffer to hold the position of the

View File

@ -129,7 +129,7 @@ int main(int, char **) {
// Uniformly refine the topolgy up to 'maxlevel'.
int maxlevel = 4;
refiner->RefineUniform( maxlevel );
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
// Use the FarStencilTables factory to create cascading stencil tables
// note: we want stencils for the each refinement level

View File

@ -165,7 +165,7 @@ createTopologyRefiner(int maxlevel) {
Far::TopologyRefinerFactory<Descriptor>::Create(type, options, desc);
// Uniformly refine the topolgy up to 'maxlevel'
refiner->RefineUniform( maxlevel );
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
return refiner;
}