diff --git a/vcg/complex/algorithms/clean.h b/vcg/complex/algorithms/clean.h index b248dfb3..eb77faf8 100644 --- a/vcg/complex/algorithms/clean.h +++ b/vcg/complex/algorithms/clean.h @@ -674,7 +674,7 @@ public: } /// \brief This function expand current selection to cover the whole connected component. - static size_t SplitManifoldComponents(MeshType &m) + static size_t SplitManifoldComponents(MeshType &m, const ScalarType moveThreshold = 0) { typedef typename MeshType::FacePointer FacePointer; typedef typename MeshType::FaceIterator FaceIterator; @@ -720,6 +720,30 @@ public: ++selCnt; } + vcg::tri::UpdateTopology::VertexFace(tmpMesh); + vcg::tri::UpdateFlags::VertexBorderFromNone(tmpMesh); + for (size_t i = 0; i < size_t(tmpMesh.VN()); ++i) + { + VertexType & v = tmpMesh.vert[i]; + + if (v.IsB()) + { + std::vector faceVec; + std::vector idxVec; + + vcg::face::VFStarVF(&v, faceVec, idxVec); + + CoordType delta(0, 0, 0); + for (auto fp : faceVec) + { + delta += vcg::Barycenter(*fp) - v.cP(); + } + delta /= faceVec.size(); + + v.P() += delta * moveThreshold; + } + } + UpdateSelection::Clear(tmpMesh); Append::MeshCopy(m, tmpMesh); return selCnt;