From 581acc3d2e4dd8c5be64e5ba8dd0c806560960fa Mon Sep 17 00:00:00 2001 From: nico Date: Thu, 4 May 2017 03:13:59 +0200 Subject: [PATCH] corrected some bug on CollapseBorderSmallEdgesStep function --- vcg/complex/algorithms/polygonal_algorithms.h | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/vcg/complex/algorithms/polygonal_algorithms.h b/vcg/complex/algorithms/polygonal_algorithms.h index f4d4dc51..aca16c15 100644 --- a/vcg/complex/algorithms/polygonal_algorithms.h +++ b/vcg/complex/algorithms/polygonal_algorithms.h @@ -169,7 +169,8 @@ private: static bool CollapseBorderSmallEdgesStep(PolyMeshType &poly_m, - const ScalarType edge_limit) + const ScalarType edge_limit, + ScalarType angleDeg=100) { //update topology vcg::tri::UpdateTopology::FaceFace(poly_m); @@ -178,6 +179,8 @@ private: vcg::tri::UpdateFlags::VertexBorderFromFaceAdj(poly_m); + vcg::tri::UpdateSelection::VertexCornerBorder(poly_m,math::ToRad(150.0)); + std::vector CollapsePos; std::vector InterpPos; @@ -194,10 +197,15 @@ private: bool IsBV0=v0->IsB(); bool IsBV1=v1->IsB(); + bool IsS0=v0->IsS(); + bool IsS1=v1->IsS(); + + if ((IsS0)&&(IsS1))continue; + //in these cases is not possible to collapse if ((!IsBV0)&&(!IsBV1))continue; - bool IsBorderE=poly_m.face[i].FFp(j); - if ((IsBorderE)&&(IsBV0)&&(IsBV1))continue; + bool IsBorderE=(poly_m.face[i].FFp(j)==&poly_m.face[i]); + if ((!IsBorderE)&&(IsBV0)&&(IsBV1))continue; assert((IsBV0)||(IsBV1)); CoordType pos0=v0->P(); @@ -209,8 +217,21 @@ private: CoordType CurrInterpPos; if ((IsBV0)&&(!IsBV1))CurrInterpPos=pos0; if ((!IsBV0)&&(IsBV1))CurrInterpPos=pos1; - if ((IsBV0)&&(IsBV1))CurrInterpPos=(pos0+pos1)/2.0; - + if ((IsBV0)&&(IsBV1)) + { + if ((!IsS0)&&(!IsS1)) + CurrInterpPos=(pos0+pos1)/2.0; + else + { + if ((!IsS0)&&(IsS1)) + CurrInterpPos=pos1; + else + { + assert((IsS0)&&(!IsS1)); + CurrInterpPos=pos0; + } + } + } CollapsePos.push_back(PosType(&poly_m.face[i],j)); InterpPos.push_back(CurrInterpPos); }