From 598cb77fb67ed6b2e22a7249a4f7d09f5b8a1936 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 7 Apr 2008 12:58:48 +0000 Subject: [PATCH] Changed the edge split predicate, now it takes a pos instead of two pnts Added quality interpolation --- vcg/complex/trimesh/refine.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/vcg/complex/trimesh/refine.h b/vcg/complex/trimesh/refine.h index ace6fca8..5fd49435 100644 --- a/vcg/complex/trimesh/refine.h +++ b/vcg/complex/trimesh/refine.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.18 2008/03/18 10:31:47 cignoni +added color interpolation to butterfly + Revision 1.17 2007/03/27 09:25:14 cignoni corrected managment of selected flag when refining the whole mesh flipmesh @@ -149,6 +152,9 @@ struct MidPoint : public std::unary_functionV(ep.z)->C(),ep.f->V1(ep.z)->C(),.5f); + + if( MESH_TYPE::HasPerVertexQuality()) + nv.Q() = ((ep.f->V(ep.z)->Q()+ep.f->V1(ep.z)->Q())) / 2.0; } Color4 WedgeInterp(Color4 &c0, Color4 &c1) @@ -289,14 +295,14 @@ tutti uguali per tutti i wedge sulla stessa 'vecchia' faccia. // la refine usa qt funzione di default: raffina se l'edge^2 e' piu lungo di thr2 -template +template class EdgeLen { public: FLT thr2; - bool operator()(const Point3 &p0, const Point3 &p1) const + bool operator()(face::Pos ep) const { - return SquaredDistance(p0,p1)>thr2; + return SquaredDistance(ep.f->V(ep.z)->P(), ep.f->V1(ep.z)->P())>thr2; } }; /* @@ -331,7 +337,7 @@ bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep, bool RefineSelectedP=false template bool Refine(MESH_TYPE &m, MIDPOINT mid, typename MESH_TYPE::ScalarType thr=0,bool RefineSelected=false, CallBackPos *cb = 0) { - EdgeLen ep; + EdgeLen ep; ep.thr2=thr*thr; return RefineE(m,mid,ep,RefineSelected,cb); } @@ -351,7 +357,7 @@ bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep,bool RefineSelected=false, { if(cb && (++step%PercStep)==0)(*cb)(step/PercStep,"Refining..."); for(j=0;j<3;j++){ - if(ep((*fi).P(j),(*fi).P1(j)) && + if(ep(face::Pos (&*fi,j)) && (!RefineSelected || ((*fi).IsS() && (*fi).FFp(j)->IsS())) ){ ++NewFaceNum; if( ((*fi).V(j)<(*fi).V1(j)) || (*fi).IsB(j) ) @@ -370,7 +376,7 @@ bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep,bool RefineSelected=false, { if(cb && (++step%PercStep)==0)(*cb)(step/PercStep,"Refining..."); for(j=0;j<3;j++) - if(ep((*fi).V(j)->P(),(*fi).V1(j)->P()) && + if(ep(face::Pos (&*fi,j)) && (!RefineSelected || ((*fi).IsS() && (*fi).FFp(j)->IsS())) ) if((*fi).V(j)<(*fi).V1(j) || (*fi).IsB(j)){ mid( (*lastv), face::Pos (&*fi,j)); @@ -417,9 +423,9 @@ bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep,bool RefineSelected=false, vv[0]=(*fi).V(0); vv[1]=(*fi).V(1); vv[2]=(*fi).V(2); - bool e0=ep((*fi).V(0)->P(),(*fi).V(1)->P()); - bool e1=ep((*fi).V(1)->P(),(*fi).V(2)->P()); - bool e2=ep((*fi).V(2)->P(),(*fi).V(0)->P()); + bool e0=ep(face::Pos (&*fi,0)); + bool e1=ep(face::Pos (&*fi,1)); + bool e2=ep(face::Pos (&*fi,2)); if(e0) if((*fi).V(0)<(*fi).V(1)|| (*fi).IsB(0)) vv[3]=Edge2Vert[ vvpair((*fi).V(0),(*fi).V(1)) ];