From 437d258a22b93a69834beeea3882fbf0853850b1 Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 15 Jul 2008 07:15:18 +0000 Subject: [PATCH] Added (from an idea of Fabio Ganovelli) the possibility of adding face-quality driving quadrics. For each face, three quadric perpendicular to the face plane and passing through the edges are added (just like for borders, but with a much lower weight). In case of very planar surface these quadrics try to keep the original shapes of triangles, preferring small edge collapse. Without this in planar zones collapse order could be random. --- vcg/complex/local_optimization/tri_edge_collapse_quadric.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vcg/complex/local_optimization/tri_edge_collapse_quadric.h b/vcg/complex/local_optimization/tri_edge_collapse_quadric.h index a90c22ca..8d4ec762 100644 --- a/vcg/complex/local_optimization/tri_edge_collapse_quadric.h +++ b/vcg/complex/local_optimization/tri_edge_collapse_quadric.h @@ -150,6 +150,7 @@ public: bool ComplexCheck; bool ScaleIndependent; //*********************** + bool QualityQuadric; // During the initialization manage all the edges as border edges adding a set of additional quadrics that are useful mostly for keeping face aspect ratio good. bool PreserveTopology; bool PreserveBoundary; bool MarkComplex; @@ -349,6 +350,7 @@ public: Params().QualityCheck=true; Params().QualityThr=.1; Params().BoundaryWeight=.5; + Params().QualityQuadric=false; Params().OptimalPlacement=true; Params().ScaleIndependent=true; Params().ComplexCheck=false; @@ -549,7 +551,7 @@ static void InitQuadric(TriMeshType &m) if( (*pf).V(j)->IsW() ) QH::Qd((*pf).V(j)) += q; // Sommo la quadrica ai vertici for(j=0;j<3;++j) - if( (*pf).IsB(j)) // Bordo! + if( (*pf).IsB(j) || Params().QualityQuadric ) // Bordo! { Plane3 pb; // Piano di bordo @@ -558,7 +560,8 @@ static void InitQuadric(TriMeshType &m) // poiche' la pesatura in funzione dell'area e'gia fatta in p.Direction() // Senza la normalize il bordo e' pesato in funzione della grandezza della mesh (mesh grandi non decimano sul bordo) pb.SetDirection(p.Direction() ^ ( (*pf).V1(j)->cP() - (*pf).V(j)->cP() ).Normalize()); - pb.SetDirection(pb.Direction()* (ScalarType)Params().BoundaryWeight); // amplify border planes + if( (*pf).IsB(j) ) pb.SetDirection(pb.Direction()* (ScalarType)Params().BoundaryWeight); // amplify border planes + else pb.SetDirection(pb.Direction()* (ScalarType)(Params().BoundaryWeight/100.0)); // and consider much less quadric for quality pb.SetOffset(pb.Direction() * (*pf).V(j)->cP()); q.ByPlane(pb);