Minor changes to improve robustness of voronoi retriangulation
This commit is contained in:
parent
8b9efe576d
commit
5394d354f9
|
@ -188,7 +188,22 @@ static void VoronoiColoring(MeshType &m, bool frontierFlag=true)
|
||||||
GetAreaAndFrontier(m, sources, regionArea, frontierVec);
|
GetAreaAndFrontier(m, sources, regionArea, frontierVec);
|
||||||
tri::Geodesic<MeshType>::Compute(m,frontierVec);
|
tri::Geodesic<MeshType>::Compute(m,frontierVec);
|
||||||
}
|
}
|
||||||
tri::UpdateColor<MeshType>::PerVertexQualityRamp(m);
|
float minQ = std::numeric_limits<float>::max();
|
||||||
|
float maxQ = -std::numeric_limits<float>::max();
|
||||||
|
|
||||||
|
for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
|
if(sources[*vi])
|
||||||
|
{
|
||||||
|
if( (*vi).Q() < minQ) minQ=(*vi).Q();
|
||||||
|
if( (*vi).Q() > maxQ) maxQ=(*vi).Q();
|
||||||
|
}
|
||||||
|
for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
|
if(sources[*vi])
|
||||||
|
(*vi).C().SetColorRamp(minQ,maxQ,(*vi).Q());
|
||||||
|
else
|
||||||
|
(*vi).C()=Color4b::DarkGray;
|
||||||
|
|
||||||
|
// tri::UpdateColor<MeshType>::PerVertexQualityRamp(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VoronoiAreaColoring(MeshType &m,std::vector<VertexType *> &seedVec,
|
static void VoronoiAreaColoring(MeshType &m,std::vector<VertexType *> &seedVec,
|
||||||
|
@ -1318,7 +1333,7 @@ static int VoronoiRelaxing(MeshType &m, std::vector<VertexType *> &seedVec,
|
||||||
else
|
else
|
||||||
changed = QuadricRelax(m,seedVec,frontierVec, newSeedVec, df,vpp);
|
changed = QuadricRelax(m,seedVec,frontierVec, newSeedVec, df,vpp);
|
||||||
|
|
||||||
assert(newSeedVec.size() == seedVec.size());
|
//assert(newSeedVec.size() == seedVec.size());
|
||||||
PruneSeedByRegionArea(newSeedVec,regionArea,vpp);
|
PruneSeedByRegionArea(newSeedVec,regionArea,vpp);
|
||||||
|
|
||||||
for(size_t i=0;i<frontierVec.size();++i)
|
for(size_t i=0;i<frontierVec.size();++i)
|
||||||
|
@ -1354,7 +1369,10 @@ static int VoronoiRelaxing(MeshType &m, std::vector<VertexType *> &seedVec,
|
||||||
|
|
||||||
|
|
||||||
// Base vertex voronoi coloring algorithm.
|
// Base vertex voronoi coloring algorithm.
|
||||||
// it assumes VF adjacency. No attempt of computing real geodesic distnace is done. Just a BFS visit starting from the seeds.
|
// It assumes VF adjacency.
|
||||||
|
// No attempt of computing real geodesic distnace is done. Just a BFS visit starting from the seeds
|
||||||
|
// It leaves in each vertex quality the index of the seed.
|
||||||
|
|
||||||
static void TopologicalVertexColoring(MeshType &m, std::vector<VertexType *> &seedVec)
|
static void TopologicalVertexColoring(MeshType &m, std::vector<VertexType *> &seedVec)
|
||||||
{
|
{
|
||||||
std::queue<VertexPointer> VQ;
|
std::queue<VertexPointer> VQ;
|
||||||
|
@ -1666,7 +1684,7 @@ static void PreprocessForVoronoi(MeshType &m, float radius, VoronoiProcessingPar
|
||||||
PreprocessForVoronoi<tri::MidPoint<MeshType> >(m, radius,mid,vpp);
|
PreprocessForVoronoi<tri::MidPoint<MeshType> >(m, radius,mid,vpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RelaxRefineTriangulationSpring(MeshType &m, MeshType &delaMesh, int refineStep=3, int relaxStep=10 )
|
static void RelaxRefineTriangulationSpring(MeshType &m, MeshType &delaMesh, int relaxStep=10, int refineStep=3 )
|
||||||
{
|
{
|
||||||
tri::RequireCompactness(m);
|
tri::RequireCompactness(m);
|
||||||
tri::RequireCompactness(delaMesh);
|
tri::RequireCompactness(delaMesh);
|
||||||
|
@ -1690,7 +1708,7 @@ static void RelaxRefineTriangulationSpring(MeshType &m, MeshType &delaMesh, int
|
||||||
PerVertexBoolHandle fixed = tri::Allocator<MeshType>:: template GetPerVertexAttribute<bool> (m,"fixed");
|
PerVertexBoolHandle fixed = tri::Allocator<MeshType>:: template GetPerVertexAttribute<bool> (m,"fixed");
|
||||||
|
|
||||||
const ScalarType maxDist = m.bbox.Diag()/4.f;
|
const ScalarType maxDist = m.bbox.Diag()/4.f;
|
||||||
for(int kk=0;kk<refineStep;kk++)
|
for(int kk=0;kk<refineStep+1;kk++)
|
||||||
{
|
{
|
||||||
tri::UpdateTopology<MeshType>::FaceFace(delaMesh);
|
tri::UpdateTopology<MeshType>::FaceFace(delaMesh);
|
||||||
|
|
||||||
|
@ -1704,7 +1722,7 @@ static void RelaxRefineTriangulationSpring(MeshType &m, MeshType &delaMesh, int
|
||||||
const float dist_upper_bound=m.bbox.Diag()/10.0;
|
const float dist_upper_bound=m.bbox.Diag()/10.0;
|
||||||
float dist;
|
float dist;
|
||||||
|
|
||||||
for(int k=0;k<relaxStep;k++)
|
for(int k=0;k<relaxStep;k++)
|
||||||
{
|
{
|
||||||
std::vector<Point3f> avgForce(delaMesh.vn);
|
std::vector<Point3f> avgForce(delaMesh.vn);
|
||||||
std::vector<float> avgLenVec(delaMesh.vn,0);
|
std::vector<float> avgLenVec(delaMesh.vn,0);
|
||||||
|
|
Loading…
Reference in New Issue