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; diff --git a/vcg/simplex/face/topology.h b/vcg/simplex/face/topology.h index 82d3f485..004067c8 100644 --- a/vcg/simplex/face/topology.h +++ b/vcg/simplex/face/topology.h @@ -889,7 +889,7 @@ void VFDetach(FaceType & f, int z) /// Append a face in VF list of vertex f->V(z) template -void VFAppend(FaceType* & f, int z) +void VFAppend(FaceType * f, int z) { typename FaceType::VertexType *v = f->V(z); if (v->VFp()!=0) diff --git a/wrap/igl/arap_parametrization.h b/wrap/igl/arap_parametrization.h index e1952704..0a472c85 100644 --- a/wrap/igl/arap_parametrization.h +++ b/wrap/igl/arap_parametrization.h @@ -35,6 +35,7 @@ * Example of usage: * MeshType m; * ... + * vcg::tri::UpdateBounding::Box(m); * vcg::tri::UpdateFlags::Clear(m); * vcg::tri::UpdateFlags::VertexBorderFromNone(m); * vcg::tri::OptimizeUV_ARAP(m);