From 5394d354f98b2929f96b3e6e301bb24ed633d6ba Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 28 Jan 2016 06:47:47 +0000 Subject: [PATCH] Minor changes to improve robustness of voronoi retriangulation --- vcg/complex/algorithms/voronoi_processing.h | 30 ++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/vcg/complex/algorithms/voronoi_processing.h b/vcg/complex/algorithms/voronoi_processing.h index 3bc92138..503a0a03 100644 --- a/vcg/complex/algorithms/voronoi_processing.h +++ b/vcg/complex/algorithms/voronoi_processing.h @@ -188,7 +188,22 @@ static void VoronoiColoring(MeshType &m, bool frontierFlag=true) GetAreaAndFrontier(m, sources, regionArea, frontierVec); tri::Geodesic::Compute(m,frontierVec); } - tri::UpdateColor::PerVertexQualityRamp(m); + float minQ = std::numeric_limits::max(); + float maxQ = -std::numeric_limits::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::PerVertexQualityRamp(m); } static void VoronoiAreaColoring(MeshType &m,std::vector &seedVec, @@ -1318,7 +1333,7 @@ static int VoronoiRelaxing(MeshType &m, std::vector &seedVec, else changed = QuadricRelax(m,seedVec,frontierVec, newSeedVec, df,vpp); - assert(newSeedVec.size() == seedVec.size()); + //assert(newSeedVec.size() == seedVec.size()); PruneSeedByRegionArea(newSeedVec,regionArea,vpp); for(size_t i=0;i &seedVec, // 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 &seedVec) { std::queue VQ; @@ -1666,7 +1684,7 @@ static void PreprocessForVoronoi(MeshType &m, float radius, VoronoiProcessingPar PreprocessForVoronoi >(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(delaMesh); @@ -1690,7 +1708,7 @@ static void RelaxRefineTriangulationSpring(MeshType &m, MeshType &delaMesh, int PerVertexBoolHandle fixed = tri::Allocator:: template GetPerVertexAttribute (m,"fixed"); const ScalarType maxDist = m.bbox.Diag()/4.f; - for(int kk=0;kk::FaceFace(delaMesh); @@ -1704,7 +1722,7 @@ static void RelaxRefineTriangulationSpring(MeshType &m, MeshType &delaMesh, int const float dist_upper_bound=m.bbox.Diag()/10.0; float dist; - for(int k=0;k avgForce(delaMesh.vn); std::vector avgLenVec(delaMesh.vn,0);