diff --git a/vcg/complex/algorithms/voronoi_clustering.h b/vcg/complex/algorithms/voronoi_clustering.h index e136a522..485f8754 100644 --- a/vcg/complex/algorithms/voronoi_clustering.h +++ b/vcg/complex/algorithms/voronoi_clustering.h @@ -130,6 +130,10 @@ static void VoronoiColoring(MeshType &m, std::vector &seedVec, boo tri::UpdateColor::VertexQualityRamp(m); } +// It associates the faces with a given vertex according to the vertex associations +// +// It READS the PerVertex attribute 'sources' +// It WRITES the PerFace attribute 'sources' static void FaceAssociateRegion(MeshType &m) { @@ -141,7 +145,7 @@ static void FaceAssociateRegion(MeshType &m) std::vector vp(3); for(int i=0;i<3;++i) vp[i]=vertexSources[fi->V(i)]; - for(int i=0;i<3;++i) // First try to assoiciate to the most reached vertex + for(int i=0;i<3;++i) // First try to associate to the most reached vertex { if(vp[0]==vp[1] && vp[0]==vp[2]) faceSources[fi] = vp[0]; else @@ -165,7 +169,6 @@ static void FaceAssociateRegion(MeshType &m) for(int i=0;i<3;++i) vp[i]=faceSources[fi->FFp(i)]; - int cnt[3]={0,0,0}; if(vp[0]!=0 && (vp[0]==vp[1] || vp[0]==vp[2])) faceSources[fi] = vp[0]; else if(vp[1]!=0 && (vp[1]==vp[2])) @@ -179,12 +182,14 @@ static void FaceAssociateRegion(MeshType &m) while(unassCnt>0); } +// Select all the faces with a given source vertex +// It reads the PerFace attribute 'sources' + static int FaceSelectAssociateRegion(MeshType &m, VertexPointer vp) { PerFacePointerHandle sources = tri::Allocator:: template GetPerFaceAttribute (m,"sources"); assert(tri::Allocator::IsValidHandle(m,sources)); - tri::UpdateSelection::FaceClear(m); - tri::UpdateSelection::VertexClear(m); + tri::UpdateSelection::Clear(m); int selCnt=0; for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) { @@ -197,15 +202,16 @@ static int FaceSelectAssociateRegion(MeshType &m, VertexPointer vp) return selCnt; } -// Given a seed, it selects all the faces that have at least one vertex sourced by the given VertexPointer. -// vp can be null (it search for unreached faces...) +// Given a seed , it selects all the faces that have the minimal distance vertex sourced by the given . +// can be null (it search for unreached faces...) // returns the number of selected faces; +// +// It reads the PerVertex attribute 'sources' static int FaceSelectRegion(MeshType &m, VertexPointer vp) { PerVertexPointerHandle sources = tri::Allocator:: template GetPerVertexAttribute (m,"sources"); assert(tri::Allocator::IsValidHandle(m,sources)); - tri::UpdateSelection::FaceClear(m); - tri::UpdateSelection::VertexClear(m); + tri::UpdateSelection::Clear(m); int selCnt=0; for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi) { @@ -366,10 +372,13 @@ static void TopologicalVertexColoring(MeshType &m, std::vector &se } - // This function assumes that in the mOld mesh, for each vertex you have a quality that denotes the index of the cluster - // mNew is created by collasping onto a single vertex all the vertices that lies in the same cluster. - // Non degenerate triangles are preserved. - +// Drastic Simplification algorithm. +// Similar in philosopy to the classic grid clustering but using a voronoi partition instead of the regular grid. +// +// This function assumes that in the mOld mesh, for each vertex you have a quality that denotes the index of the cluster +// mNew is created by collasping onto a single vertex all the vertices that lies in the same cluster. +// Non degenerate triangles are preserved. + static void VoronoiClustering(MeshType &mOld, MeshType &mNew, std::vector &seedVec) { std::set clusteredFace; @@ -398,7 +407,7 @@ static void VoronoiClustering(MeshType &mOld, MeshType &mNew, std::vector