fix bug on edgecollapse

This commit is contained in:
T.Alderighi 2018-08-06 11:15:15 +02:00
parent 96a8e0e08f
commit 3dd1f38353
1 changed files with 577 additions and 571 deletions

View File

@ -156,7 +156,7 @@ private:
{
ScalarType angle = fastAngle(NormalizedTriangleNormal(*(p.F())), NormalizedTriangleNormal(*(p.FFlip())));
return angle <= creaseCosineThr;
// return (angle <= creaseCosineThr && angle >= -creaseCosineThr);
// return (angle <= creaseCosineThr && angle >= -creaseCosineThr);
}
// this stores in minQ the value of the 10th percentile of the VertQuality distribution and in
// maxQ the value of the 90th percentile.
@ -402,7 +402,7 @@ private:
Point3<ScalarType> oldN = NormalizedTriangleNormal(*(pi.F()));
Point3<ScalarType> newN = Normal(mp, v1->P(), v2->P()).Normalize();
float div = fastAngle(oldN, newN);
// if(AngleN(oldN,newN) > math::ToRad(1.0)) return false;
// if(AngleN(oldN,newN) > math::ToRad(1.0)) return false;
if(div <= params.creaseAngleCosThr )
return false;
@ -475,7 +475,8 @@ private:
computeVQualityDistrMinMax(m, minQ, maxQ);
tri::UpdateTopology<MeshType>::VertexFace(m);
tri::UpdateFlags<MeshType>::VertexBorderFromNone(m);
tri::UpdateFlags<MeshType>::FaceBorderFromVF(m);
tri::UpdateFlags<MeshType>::VertexBorderFromFaceBorder(m);
for(auto fi=m.face.begin(); fi!=m.face.end(); ++fi)
if(!(*fi).IsD() && (params.selectedOnly == false || fi->IsS()))
@ -486,14 +487,19 @@ private:
++candidates;
VertexPair bp = VertexPair(pi.V(), pi.VFlip());
Point3<ScalarType> mp = (pi.V()->P()+pi.VFlip()->P())/2.f;
bool boundary = false;
bool boundary = false;
//if both border or both internal use midpoint
if(pi.V()->IsB() == pi.VFlip()->IsB())
{
if(pi.V()->IsB() && !(boundary = chooseBoundaryCollapse(pi, bp)))
//if both border but not on border edge..abort..if chooseBoundaryCollapse can't find good collapse..abort..
if(pi.V()->IsB() && !fi->IsB(i) && !(boundary = chooseBoundaryCollapse(pi, bp)))
continue;
mp = (pi.V()->IsB()) ? bp.V(1)->P() : (pi.V()->P()+pi.VFlip()->P())/2.f;
} else {
}
else //if only one is border...collapse on it!
{
bp = (pi.V()->IsB()) ? VertexPair(pi.VFlip(), pi.V()) : VertexPair(pi.V(), pi.VFlip());
mp = (pi.V()->IsB()) ? pi.V()->P() : pi.VFlip()->P();
}