Merge pull request #534 from barfowl/face_uniform

Moved base-face propagation to Far::PrimvarRefiner
This commit is contained in:
David G Yu 2015-05-27 15:32:01 -04:00
commit 7f03b864b7
6 changed files with 42 additions and 47 deletions

View File

@ -160,6 +160,15 @@ public:
///
template <class T, class U> void InterpolateVarying(int level, T const & src, U & dst) const;
/// \brief Apply uniform (per-face) primvar data between levels. Data is simply copied
/// from a parent face to its child faces and does not involve any weighting. Setting
/// the source primvar data for the base level to be the index of each face allows the
/// propagation of the base face to primvar data for child faces in all levels.
///
template <class T, class U> void InterpolateFaceUniform(T const * src, U * dst) const;
template <class T, class U> void InterpolateFaceUniform(int level, T const & src, U & dst) const;
/// \brief Apply face-varying interpolation weights to a primvar buffer
// associated with a particular face-varying channel
///
@ -441,6 +450,39 @@ PrimvarRefiner::interpolateChildVertsFromVerts(
}
}
//
// Face-uniform "interpolation":
//
template <class T, class U>
inline void
PrimvarRefiner::InterpolateFaceUniform(T const * src, U * dst) const {
for (int level = 1; level <= _refiner.GetMaxLevel(); ++level) {
InterpolateFaceUniform(level, src, dst);
src = dst;
dst += _refiner.GetLevel(level).GetNumFaces();
}
}
template <class T, class U>
inline void
PrimvarRefiner::InterpolateFaceUniform(int level, T const & src, U & dst) const {
assert(level>0 and level<=(int)_refiner._refinements.size());
Vtr::internal::Refinement const & refinement = _refiner.getRefinement(level-1);
Vtr::internal::Level const & child = refinement.child();
for (int cFace = 0; cFace < child.getNumFaces(); ++cFace) {
Vtr::Index pFace = refinement.getChildFaceParentFace(cFace);
dst[cFace] = src[pFace];
}
}
//
// Varying only interpolation
//

View File

@ -84,7 +84,6 @@ public:
Index GetVertexChildVertex(Index v) const { return _refToChild->getVertexChildVertex(v); }
Index GetFaceParentFace(Index f) const { return _refToParent->getChildFaceParentFace(f); }
Index GetFaceBaseFace( Index f) const { return _refToParent->getChildFaceBaseFace(f); }
bool ValidateTopology() const { return _level->validateTopology(); }
void PrintTopology(bool children = true) const { _level->print((children && _refToChild) ? _refToChild : 0); }

View File

@ -141,16 +141,6 @@ TopologyRefiner::appendLevel(Vtr::internal::Level & newLevel) {
void
TopologyRefiner::appendRefinement(Vtr::internal::Refinement & newRefinement) {
//
// There may be properties to transfer between refinements that cannot be passed on
// when refining between the parent and child since they exist "above" the parent:
//
bool applyBaseFace = (_isUniform && _uniformOptions.applyBaseFacePerFace) ||
(!_isUniform && _adaptiveOptions.applyBaseFacePerFace);
if (applyBaseFace) {
newRefinement.propagateBaseFace(_refinements.size() ? _refinements.back() : 0);
}
_refinements.push_back(&newRefinement);
}

View File

@ -118,13 +118,10 @@ public:
UniformOptions(int level) :
refinementLevel(level),
applyBaseFacePerFace(false),
orderVerticesFromFacesFirst(false),
fullTopologyInLastLevel(false) { }
unsigned int refinementLevel:4, ///< Number of refinement iterations
applyBaseFacePerFace:1, ///< For each refined face, record the index
///< of the base face from which it originates
orderVerticesFromFacesFirst:1, ///< Order child vertices from faces first
///< instead of child vertices of vertices
fullTopologyInLastLevel:1; ///< Skip topological relationships in the last
@ -151,15 +148,12 @@ public:
AdaptiveOptions(int level) :
isolationLevel(level),
useSingleCreasePatch(false),
applyBaseFacePerFace(false),
orderVerticesFromFacesFirst(false) { }
unsigned int isolationLevel:4, ///< Number of iterations applied to isolate
///< extraordinary vertices and creases
useSingleCreasePatch:1, ///< Use 'single-crease' patch and stop
///< isolation where applicable
applyBaseFacePerFace:1, ///< For each refined face, record the index
///< of the base face from which it originates
orderVerticesFromFacesFirst:1; ///< Order child vertices from faces first
///< instead of child vertices of vertices
};

View File

@ -1080,26 +1080,6 @@ Refinement::subdivideFVarChannels() {
}
}
//
// Methods to inherit properties between refinements in a hierarchy:
//
void
Refinement::propagateBaseFace(Refinement const * grandParent) {
_childFaceBaseFaceIndex.resize(_child->_faceCount);
if (grandParent == 0) {
_childFaceBaseFaceIndex = _childFaceParentIndex;
} else {
IndexVector & childBaseFace = _childFaceBaseFaceIndex;
IndexVector const & parentBaseFace = grandParent->_childFaceBaseFaceIndex;
for (Index cFace = 0; cFace < _child->_faceCount; ++cFace) {
childBaseFace[cFace] = parentBaseFace[_childFaceParentIndex[cFace]];
}
}
}
//
// Marking of sparse child components -- including those selected and those neighboring...
//

View File

@ -147,9 +147,6 @@ public:
Index getChildVertexParentIndex(Index v) const { return _childVertexParentIndex[v]; }
// Child-to-"ancestor" relationships:
Index getChildFaceBaseFace(Index f) const { return _childFaceBaseFaceIndex[f]; }
//
// Modifiers intended for internal/protected use:
//
@ -248,8 +245,6 @@ public:
void populateVertexTagsFromParentEdges();
void populateVertexTagsFromParentVertices();
void propagateBaseFace(Refinement const * previousRefinement);
//
// Methods (and types) involved in subdividing the topology -- though not
// fully exploited, any subset of the 6 relations can be generated:
@ -379,11 +374,6 @@ public:
// Refinement data for face-varying channels present in the Levels being refined:
//
std::vector<FVarRefinement*> _fvarChannels;
//
// Child-to-base/ancestor mappings:
//
IndexVector _childFaceBaseFaceIndex;
};
inline ConstIndexArray