From 1fef63b1da31087bbce74db0fe99640f47272765 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 22 Mar 2013 17:07:55 +0000 Subject: [PATCH] improved a bit the basic step of the voronoi clustering --- vcg/complex/algorithms/voronoi_clustering.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/vcg/complex/algorithms/voronoi_clustering.h b/vcg/complex/algorithms/voronoi_clustering.h index 6e6da328..45a8925b 100644 --- a/vcg/complex/algorithms/voronoi_clustering.h +++ b/vcg/complex/algorithms/voronoi_clustering.h @@ -279,7 +279,23 @@ static void VoronoiRelaxing(MeshType &m, std::vector &seedVec, int sources = tri::Allocator:: template AddPerVertexAttribute (m,"sources"); tri::Geodesic::Compute(m,seedVec,std::numeric_limits::max(),0,&sources); - + + // Delete all the (hopefully) small regions that have not been reached by the seeds; + tri::UpdateFlags::VertexClearV(m); + for(int i=0;iV(0)->IsV() || fi->V(1)->IsV() || fi->V(2)->IsV() ) + { + face::VFDetach(*fi); + tri::Allocator::DeleteFace(m,*fi); + } + qDebug("Deleted faces not reached: %i -> %i",int(m.face.size()),m.fn); + tri::Clean::RemoveUnreferencedVertex(m); + tri::Allocator::CompactFaceVector(m); + tri::Allocator::CompactVertexVector(m); + std::pair zz(0,0); std::vector< std::pair > regionArea(m.vert.size(),zz); std::vector borderVec; @@ -305,7 +321,7 @@ static void VoronoiRelaxing(MeshType &m, std::vector &seedVec, int std::vector< std::pair > seedMaxima(m.vert.size(),zz); for(VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi) { - int seedIndex = sources[vi] - &*m.vert.begin(); + int seedIndex = tri::Index(m,sources[vi]); if(seedMaxima[seedIndex].first < (*vi).Q()) { seedMaxima[seedIndex].first=(*vi).Q();