Added relaxOnlyConstrainedFlag to the voronoi processing relax procedure that allow to relax only the vertexes that are constrainted (onto their domain) ignoring all the other samples (except the fixed one). It allows to get more even distributions on the constrains.

This commit is contained in:
Paolo Cignoni 2014-05-09 21:50:28 +00:00
parent 329057ea96
commit b79c323a77
1 changed files with 26 additions and 1 deletions

View File

@ -57,6 +57,7 @@ struct VoronoiProcessingParameter
triangulateRegion=false; triangulateRegion=false;
unbiasedSeedFlag = true; unbiasedSeedFlag = true;
geodesicRelaxFlag = true; geodesicRelaxFlag = true;
relaxOnlyConstrainedFlag=false;
refinementRatio = 5.0f; refinementRatio = 5.0f;
} }
int colorStrategy; int colorStrategy;
@ -72,6 +73,8 @@ struct VoronoiProcessingParameter
/// domains, for example moving only along some linear features /// domains, for example moving only along some linear features
/// like border of creases. /// like border of creases.
bool relaxOnlyConstrainedFlag;
bool preserveFixedSeed; /// If true the 'fixed' seeds are not moved during relaxation. bool preserveFixedSeed; /// If true the 'fixed' seeds are not moved during relaxation.
/// \see FixVertexVector function to see how to fix a set of seeds. /// \see FixVertexVector function to see how to fix a set of seeds.
@ -1176,7 +1179,9 @@ static void FixVertexVector(MeshType &m, std::vector<VertexType *> &vertToFixVec
} }
/// \brief Perform a Lloyd relaxation cycle over a mesh /// \brief Perform a Lloyd relaxation cycle over a mesh
/// /// It uses two conventions:
/// 1) a few vertexes can remain fixed, you have to set a per vertex bool attribute named 'fixed'
/// 2)
/// ///
static int VoronoiRelaxing(MeshType &m, std::vector<VertexType *> &seedVec, static int VoronoiRelaxing(MeshType &m, std::vector<VertexType *> &seedVec,
@ -1188,6 +1193,14 @@ static int VoronoiRelaxing(MeshType &m, std::vector<VertexType *> &seedVec,
tri::RequireCompactness(m); tri::RequireCompactness(m);
for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi) for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi)
assert(vi->VFp() && "Require mesh without unreferenced vertexes\n"); assert(vi->VFp() && "Require mesh without unreferenced vertexes\n");
std::vector<VertexType *> selectedVec;
if(vpp.relaxOnlyConstrainedFlag)
{
for(size_t i=0;i<seedVec.size();++i)
if(seedVec[i]->IsS())
selectedVec.push_back(seedVec[i]);
std::swap(seedVec,selectedVec);
}
tri::UpdateFlags<MeshType>::FaceBorderFromVF(m); tri::UpdateFlags<MeshType>::FaceBorderFromVF(m);
tri::UpdateFlags<MeshType>::VertexBorderFromFace(m); tri::UpdateFlags<MeshType>::VertexBorderFromFace(m);
@ -1246,6 +1259,18 @@ static int VoronoiRelaxing(MeshType &m, std::vector<VertexType *> &seedVec,
if(iter==relaxIter) if(iter==relaxIter)
tri::Geodesic<MeshType>::Compute(m, seedVec, df,std::numeric_limits<ScalarType>::max(),0,&sources); tri::Geodesic<MeshType>::Compute(m, seedVec, df,std::numeric_limits<ScalarType>::max(),0,&sources);
if(vpp.relaxOnlyConstrainedFlag)
{
std::swap(seedVec,selectedVec);
int i=0,j=0;
for(i=0,j=0;i<seedVec.size();++i){
if(seedVec[i]->IsS())
{
seedVec[i]=selectedVec[j];
++j;
}
}
}
return iter; return iter;
} }