Cleaned up protected access to TopologyRefiner from its Factories:

- fixed naming consistency of protected methods used by Factory
    - removed other unused and/or redundant protected methods
    - update Far Factories to reflect changes to Refiner methods
    - updated usage in tutorials and regression
This commit is contained in:
barfowl 2015-01-04 16:33:18 -08:00
parent 5c9b373e44
commit 127152a511
7 changed files with 73 additions and 73 deletions

View File

@ -906,7 +906,7 @@ PatchTablesFactory::identifyAdaptivePatches( TopologyRefiner const & refiner,
PatchFaceTag * levelPatchTags = &patchTags[0];
for (int i = 0; i < (int)refiner.getNumLevels(); ++i) {
for (int i = 0; i < refiner.GetNumLevels(); ++i) {
Vtr::Level const * level = &refiner.getLevel(i);
//
@ -922,7 +922,7 @@ PatchTablesFactory::identifyAdaptivePatches( TopologyRefiner const & refiner,
// - what Faces are "complete" (done for child vertices in Refinement)
//
bool isLevelFirst = (i == 0);
bool isLevelLast = (i == ((int)refiner.getNumLevels() - 1));
bool isLevelLast = (i == refiner.GetMaxLevel());
Vtr::Refinement const * refinePrev = isLevelFirst ? 0 : &refiner.getRefinement(i-1);
Vtr::Refinement const * refineNext = isLevelLast ? 0 : &refiner.getRefinement(i);
@ -1210,7 +1210,7 @@ PatchTablesFactory::populateAdaptivePatches( TopologyRefiner const & refiner,
memset(levelFVarVertOffsets, 0, refiner.GetNumFVarChannels()*sizeof(int));
}
for (int i = 0; i < (int)refiner.getNumLevels(); ++i) {
for (int i = 0; i < refiner.GetNumLevels(); ++i) {
Vtr::Level const * level = &refiner.getLevel(i);
const PatchFaceTag * levelPatchTags = &patchTags[levelFaceOffset];
@ -1406,7 +1406,7 @@ PatchTablesFactory::populateAdaptivePatches( TopologyRefiner const & refiner,
vTable.resize(refiner.GetNumVerticesTotal() * SizePerVertex);
int vOffset = 0;
int levelLast = (int)refiner.getNumLevels() - 1;
int levelLast = refiner.GetMaxLevel();
for (int i = 0; i <= levelLast; ++i) {
Vtr::Level const * level = &refiner.getLevel(i);

View File

@ -73,12 +73,15 @@ public:
/// \brief Returns true if uniform subdivision has been applied
bool IsUniform() const { return _isUniform; }
/// \ brief Returns true if faces have been tagged as holes
bool HasHoles() const { return _hasHoles; }
/// \brief Returns the number of refinement levels
int GetNumLevels() const { return (int)_levels.size(); }
/// \brief Returns the highest level of refinement
int GetMaxLevel() const { return _maxLevel; }
/// \ brief Returns true if faces have been tagged as holes
bool HasHoles() const { return _hasHoles; }
// XXXX barfowl -- should cache these internally for trivial return)
/// \brief Returns the total number of vertices in all levels
@ -497,26 +500,12 @@ public:
protected:
//
// For use by the Factory base and subclasses to construct the base level:
// For use by the TopologyRefinerFactory<MESH> subclasses to construct the base level:
//
template <class MESH>
friend class TopologyRefinerFactory;
friend class TopologyRefinerFactoryBase;
friend class PatchTablesFactory;
friend class GregoryBasisFactory;
int getNumLevels() const { return (int)_levels.size(); }
Vtr::Level & getBaseLevel() { return *_levels.front(); }
Vtr::Level & getLevel(int l) { return *_levels[l]; }
Vtr::Level const & getLevel(int l) const { return *_levels[l]; }
Vtr::Refinement & getRefinement(int l) { return *_refinements[l]; }
Vtr::Refinement const & getRefinement(int l) const { return *_refinements[l]; }
int getNumBaseFaces() const { return GetNumFaces(0); }
int getNumBaseEdges() const { return GetNumEdges(0); }
int getNumBaseVertices() const { return GetNumVertices(0); }
// Sizing specifications required before allocation:
// Topology sizing methods required before allocation:
void setNumBaseFaces( int count) { _levels[0]->resizeFaces(count); }
void setNumBaseEdges( int count) { _levels[0]->resizeEdges(count); }
void setNumBaseVertices(int count) { _levels[0]->resizeVertices(count); }
@ -526,7 +515,7 @@ protected:
void setNumBaseVertexFaces( Index v, int count) { _levels[0]->resizeVertexFaces(v, count); }
void setNumBaseVertexEdges( Index v, int count) { _levels[0]->resizeVertexEdges(v, count); }
// Access to populate the base level topology after allocation:
// Topology assignment methods to populate base level after allocation:
IndexArray setBaseFaceVertices(Index f) { return _levels[0]->getFaceVertices(f); }
IndexArray setBaseFaceEdges( Index f) { return _levels[0]->getFaceEdges(f); }
IndexArray setBaseEdgeVertices(Index e) { return _levels[0]->getEdgeVertices(e); }
@ -534,33 +523,40 @@ protected:
IndexArray setBaseVertexFaces( Index v) { return _levels[0]->getVertexFaces(v); }
IndexArray setBaseVertexEdges( Index v) { return _levels[0]->getVertexEdges(v); }
// Not sure yet if we will determine these internally...
LocalIndexArray setBaseVertexFaceLocalIndices(Index v) { return _levels[0]->getVertexFaceLocalIndices(v); }
LocalIndexArray setBaseVertexEdgeLocalIndices(Index v) { return _levels[0]->getVertexEdgeLocalIndices(v); }
// Optionally available to get/set sharpness values:
float& baseEdgeSharpness(Index e) { return _levels[0]->getEdgeSharpness(e); }
float& baseVertexSharpness(Index v) { return _levels[0]->getVertexSharpness(v); }
void setBaseFaceHole(Index f, bool b) { _levels[0]->setHole(f, b); _hasHoles |= b; }
void populateBaseLocalIndices() { _levels[0]->populateLocalIndices(); }
void setBaseEdgeNonManifold(Index e, bool b) { _levels[0]->setEdgeNonManifold(e, b); }
void setBaseVertexNonManifold(Index v, bool b) { _levels[0]->setVertexNonManifold(v, b); }
// Face-varying modifiers for constructing face-varying channels:
int createFVarChannel(int numValues) {
return _levels[0]->createFVarChannel(numValues, _subdivOptions);
}
int createFVarChannel(int numValues, Sdc::Options const& options) {
return _levels[0]->createFVarChannel(numValues, options);
}
void completeFVarChannelTopology(int channel = 0) { _levels[0]->completeFVarChannelTopology(channel); }
// Optional feature tagging methods for setting sharpness, holes, etc.:
void setBaseEdgeSharpness(Index e, float s) { _levels[0]->getEdgeSharpness(e) = s; }
void setBaseVertexSharpness(Index v, float s) { _levels[0]->getVertexSharpness(v) = s; }
IndexArray getBaseFVarFaceValues(Index face, int channel = 0) { return _levels[0]->getFVarFaceValues(face, channel); }
void setBaseFaceHole(Index f, bool b) { _levels[0]->setHole(f, b); _hasHoles |= b; }
void populateLocalIndices() {
getBaseLevel().populateLocalIndices();
}
// Optional methods for creating and assigning face-varying data channels:
int createBaseFVarChannel(int numValues) { return _levels[0]->createFVarChannel(numValues, _subdivOptions); }
int createBaseFVarChannel(int numValues, Sdc::Options const& options) { return _levels[0]->createFVarChannel(numValues, options); }
IndexArray setBaseFVarFaceValues(Index face, int channel = 0) { return _levels[0]->getFVarFaceValues(face, channel); }
protected:
//
// Lower level protected methods intended stricty for internal use:
//
friend class TopologyRefinerFactoryBase;
friend class PatchTablesFactory;
friend class GregoryBasisFactory;
Vtr::Level & getLevel(int l) { return *_levels[l]; }
Vtr::Level const & getLevel(int l) const { return *_levels[l]; }
Vtr::Refinement & getRefinement(int l) { return *_refinements[l]; }
Vtr::Refinement const & getRefinement(int l) const { return *_refinements[l]; }
private:
void selectFeatureAdaptiveComponents(Vtr::SparseSelector& selector);

View File

@ -39,7 +39,7 @@ namespace Far {
void
TopologyRefinerFactoryBase::validateComponentTopologySizing(TopologyRefiner& refiner) {
Vtr::Level& baseLevel = refiner.getBaseLevel();
Vtr::Level& baseLevel = refiner.getLevel(0);
//
// At minimum we require face-vertices (the total count of which can be determined
@ -83,8 +83,10 @@ TopologyRefinerFactoryBase::validateComponentTopologySizing(TopologyRefiner& ref
void
TopologyRefinerFactoryBase::validateFaceVaryingComponentTopologyAssignment(TopologyRefiner& refiner) {
Vtr::Level& baseLevel = refiner.getLevel(0);
for (int channel=0; channel<refiner.GetNumFVarChannels(); ++channel) {
refiner.completeFVarChannelTopology(channel);
baseLevel.completeFVarChannelTopology(channel);
}
}
@ -97,7 +99,7 @@ TopologyRefinerFactoryBase::validateFaceVaryingComponentTopologyAssignment(Topol
void
TopologyRefinerFactoryBase::applyInternalTagsAndBoundarySharpness(TopologyRefiner& refiner) {
Vtr::Level& baseLevel = refiner.getBaseLevel();
Vtr::Level& baseLevel = refiner.getLevel(0);
assert((int)baseLevel._edgeTags.size() == baseLevel.getNumEdges());
assert((int)baseLevel._vertTags.size() == baseLevel.getNumVertices());
@ -246,14 +248,14 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignFa
int const* channelIndices = desc.fvarChannels[channel].valueIndices;
#if defined(DEBUG) or defined(_DEBUG)
int channelIndex = refiner.createFVarChannel(channelSize);
int channelIndex = refiner.createBaseFVarChannel(channelSize);
assert(channelIndex == channel);
#else
refiner.createFVarChannel(channelSize);
refiner.createBaseFVarChannel(channelSize);
#endif
for (int face=0, idx=0; face<desc.numFaces; ++face) {
IndexArray dstFaceValues = refiner.getBaseFVarFaceValues(face, channel);
IndexArray dstFaceValues = refiner.setBaseFVarFaceValues(face, channel);
for (int vert=0; vert<dstFaceValues.size(); ++vert) {
@ -278,7 +280,7 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignCo
Index idx = refiner.FindEdge(0, vertIndexPairs[0], vertIndexPairs[1]);
if (idx!=Vtr::INDEX_INVALID) {
refiner.baseEdgeSharpness(idx) = desc.creaseWeights[edge];
refiner.setBaseEdgeSharpness(idx, desc.creaseWeights[edge]);
} else {
char msg[1024];
snprintf(msg, 1024, "Edge %d specified to be sharp does not exist (%d, %d)",
@ -295,7 +297,7 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignCo
int idx = desc.cornerVertexIndices[vert];
if (idx > 0 and idx < refiner.GetNumVertices(0)) {
refiner.baseVertexSharpness(idx) = desc.cornerWeights[vert];
refiner.setBaseVertexSharpness(idx, desc.cornerWeights[vert]);
} else {
char msg[1024];
snprintf(msg, 1024, "Vertex %d specified to be sharp does not exist", idx);

View File

@ -200,8 +200,8 @@ TopologyRefinerFactory<MESH>::Create(Sdc::Type type, Sdc::Options options, MESH
//
assignComponentTopology(refiner, mesh);
if (refiner.getBaseLevel().getNumEdges() == 0) {
refiner.getBaseLevel().completeTopologyFromFaceVertices();
if (refiner.getLevel(0).getNumEdges() == 0) {
refiner.getLevel(0).completeTopologyFromFaceVertices();
}
//
@ -294,11 +294,16 @@ TopologyRefinerFactory<MESH>::assignComponentTopology(TopologyRefiner& /* refine
// LocalIndexArray TopologyRefiner::setBaseVertexFaceLocalIndices(Index vertex)
// LocalIndexArray TopologyRefiner::setBaseVertexEdgeLocalIndices(Index vertex)
//
// or, if the mesh is manifold, explicit assignment of these can be deferred and
// all will be determined via:
//
// void TopologyRefiner::populateBaseLocalIndices()
//
// All components are assumed to be locally manifold and ordering of components in
// the above relations is expected to be counter-clockwise.
//
// For non-manifold components, no ordering/orientation of incident components is
// assumed or required, but be sure to explicitly tag such components (vertices as
// assumed or required, but be sure to explicitly tag such components (vertices and
// edges) as non-manifold:
//
// void TopologyRefiner::setBaseEdgeNonManifold(Index edge, bool b);
@ -318,10 +323,10 @@ TopologyRefinerFactory<MESH>::assignFaceVaryingTopology(TopologyRefiner& /* refi
// Optional assigning face-varying topology tables:
//
// Create independent face-varying primitive variable channels:
// int TopologyRefiner::createFVarChannel(int numValues)
// int TopologyRefiner::createBaseFVarChannel(int numValues)
//
// For each channel, populate the face-vertex values:
// IndexArray TopologyRefiner::getBaseFVarFaceValues(Index face, int channel = 0)
// IndexArray TopologyRefiner::setBaseFVarFaceValues(Index face, int channel = 0)
//
}
@ -332,15 +337,12 @@ TopologyRefinerFactory<MESH>::assignComponentTags(TopologyRefiner& /* refiner */
//
// Optional tagging:
// This is where any additional feature tags -- sharpness, holes, etc. -- can be
// specified. For now, this is limited to sharpness using the following:
// specified using:
//
// float& TopologyRefiner::baseEdgeSharpness(Index edge)
// float& TopologyRefiner::baseVertexSharpness(Index vertex)
// void TopologyRefiner::setBaseEdgeSharpness(Index edge, float sharpness)
// void TopologyRefiner::setBaseVertexSharpness(Index vertex, float sharpness)
//
// which can be used on the LHS of assignments.
//
// Tagging holes will become available in the near future as sets of bitfields for
// each component type are introduced and propogated through the refinement hierarchy.
// void TopologyRefiner::setBaseFaceHole(Index face, bool hole)
//
}

View File

@ -160,7 +160,7 @@ TopologyRefinerFactory<Shape>::assignComponentTopology(
Far::TopologyRefiner & refiner, Shape const & shape) {
{ // Face relations:
int nfaces = refiner.getNumBaseFaces();
int nfaces = refiner.GetNumFaces(0);
for (int i=0, ofs=0; i < nfaces; ++i) {
@ -183,13 +183,13 @@ TopologyRefinerFactory<Shape>::assignFaceVaryingTopology(
// UV layyout (we only parse 1 channel)
if (not shape.faceuvs.empty()) {
int nfaces = refiner.getNumBaseFaces(),
channel = refiner.createFVarChannel( (int)shape.faceuvs.size() );
int nfaces = refiner.GetNumFaces(0),
channel = refiner.createBaseFVarChannel( (int)shape.faceuvs.size() );
for (int i=0, ofs=0; i < nfaces; ++i) {
Far::IndexArray dstFaceUVs =
refiner.getBaseFVarFaceValues(i, channel);
refiner.setBaseFVarFaceValues(i, channel);
for (int j=0; j<dstFaceUVs.size(); ++j) {
dstFaceUVs[j] = shape.faceuvs[ofs++];
@ -218,8 +218,8 @@ TopologyRefinerFactory<Shape>::assignComponentTags(
printf("cannot find edge for crease tag (%d,%d)\n", t->intargs[j], t->intargs[j+1] );
} else {
int nfloat = (int) t->floatargs.size();
refiner.baseEdgeSharpness(edge) =
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0]));
refiner.setBaseEdgeSharpness(edge,
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0])));
}
}
} else if (t->name=="corner") {
@ -230,8 +230,8 @@ TopologyRefinerFactory<Shape>::assignComponentTags(
printf("cannot find vertex for corner tag (%d)\n", vertex );
} else {
int nfloat = (int) t->floatargs.size();
refiner.baseVertexSharpness(vertex) =
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0]));
refiner.setBaseVertexSharpness(vertex,
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0])));
}
}
}

View File

@ -327,7 +327,7 @@ TopologyRefinerFactory<Converter>::assignComponentTopology(
}
}
refiner.populateLocalIndices();
refiner.populateBaseLocalIndices();
};
template <>
@ -337,7 +337,7 @@ TopologyRefinerFactory<Converter>::assignComponentTags(
// arbitrarily sharpen the 4 bottom edges of the pyramid to 2.5f
for (int edge=0; edge<conv.GetNumEdges(); ++edge) {
refiner.baseEdgeSharpness(edge) = g_edgeCreases[edge];
refiner.setBaseEdgeSharpness(edge, g_edgeCreases[edge]);
}
}

View File

@ -447,12 +447,12 @@ FarTopologyRefinerFactory<OsdHbrConverter>::assignComponentTags(
sharpness = std::max(sharpness, e->GetOpposite()->GetSharpness());
}
refiner.baseEdgeSharpness(it->second) = sharpness;
refiner.setBaseEdgeSharpness(it->second, sharpness);
}
// Initialize vertex sharpness
for (int i=0; i<refiner.GetNumVertices(/*level*/0); ++i) {
refiner.baseVertexSharpness(i) = hmesh.GetVertex(i)->GetSharpness();
refiner.setBaseVertexSharpness(i, hmesh.GetVertex(i)->GetSharpness());
}
// XXXX Initialize h-edits