From c90b11ca80ec2768cd0ef2a923b845a81470670f Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 25 Jan 2012 10:23:22 +0000 Subject: [PATCH] Changed all the MeshType::HasSomething() into the now standard tri::HasSomething(MeshType &m) This changed implied the fact that you need different functor constructor (you have to keep the mesh inside it to know at runtime if some attribute are present or not) --- vcg/complex/algorithms/refine.h | 11 +++++++---- vcg/complex/algorithms/refine_loop.h | 12 +++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/vcg/complex/algorithms/refine.h b/vcg/complex/algorithms/refine.h index 8cc38015..6365f2ba 100644 --- a/vcg/complex/algorithms/refine.h +++ b/vcg/complex/algorithms/refine.h @@ -126,13 +126,13 @@ struct MidPoint : public std::unary_functionV(ep.z)->P()+ep.f->V1(ep.z)->P())/2.0; - if( MESH_TYPE::HasPerVertexNormal()) + if( tri::HasPerVertexNormal(*mp)) nv.N()= (ep.f->V(ep.z)->N()+ep.f->V1(ep.z)->N()).normalized(); - if( MESH_TYPE::HasPerVertexColor()) + if( tri::HasPerVertexColor(*mp)) nv.C().lerp(ep.f->V(ep.z)->C(),ep.f->V1(ep.z)->C(),.5f); - if( MESH_TYPE::HasPerVertexQuality()) + if( tri::HasPerVertexQuality(*mp)) nv.Q() = ((ep.f->V(ep.z)->Q()+ep.f->V1(ep.z)->Q())) / 2.0; if( tri::HasPerVertexTexCoord(*mp)) @@ -538,6 +538,9 @@ Siggraph 2000 Course Notes template struct MidPointButterfly : public std::unary_function , typename MESH_TYPE::CoordType> { + MESH_TYPE &m; + MidPointButterfly(MESH_TYPE &_m):m(_m){} + void operator()(typename MESH_TYPE::VertexType &nv, face::Pos ep) { face::Pos he(ep.f,ep.z,ep.f->V(ep.z)); @@ -548,7 +551,7 @@ struct MidPointButterfly : public std::unary_functionP(); - if( MESH_TYPE::HasPerVertexColor()) + if( tri::HasPerVertexColor(m)) nv.C().lerp(ep.f->V(ep.z)->C(),ep.f->V1(ep.z)->C(),.5f); if(he.IsBorder()) diff --git a/vcg/complex/algorithms/refine_loop.h b/vcg/complex/algorithms/refine_loop.h index 55913cfb..bfb19226 100644 --- a/vcg/complex/algorithms/refine_loop.h +++ b/vcg/complex/algorithms/refine_loop.h @@ -347,16 +347,17 @@ struct LS3Projection { template, class WEIGHT_TYPE=LoopWeight > struct OddPointLoopGeneric : public std::unary_function , typename MESH_TYPE::VertexType> { - typedef METHOD_TYPE Projection; + typedef METHOD_TYPE Projection; typedef WEIGHT_TYPE Weight; typedef typename MESH_TYPE::template PerVertexAttributeHandle ValenceAttr; + MESH_TYPE &m; Projection proj; Weight weight; ValenceAttr *valence; - inline OddPointLoopGeneric(Projection proj = Projection(), Weight weight = Weight()) : - proj(proj), weight(weight), valence(0) {} + inline OddPointLoopGeneric(MESH_TYPE &_m, Projection proj = Projection(), Weight weight = Weight()) : + m(_m), proj(proj), weight(weight), valence(0) {} void operator()(typename MESH_TYPE::VertexType &nv, face::Pos ep) { proj.reset(); @@ -367,7 +368,7 @@ struct OddPointLoopGeneric : public std::unary_functionV(ep.z)->C(),ep.f->V1(ep.z)->C(),.5f); if (he.IsBorder()) { @@ -521,6 +522,7 @@ struct EvenPointLoopGeneric : public std::unary_function struct OddPointLoop : OddPointLoopGeneric > { + OddPointLoop(MESH_TYPE &_m):OddPointLoopGeneric >(_m){} }; template @@ -575,7 +577,7 @@ bool RefineOddEvenE(MESH_TYPE &m, ODD_VERT odd, EVEN_VERT even, PREDICATE edgePr //if (RefineSelected && !(*fi).V(i)->IsS() ) // break; face::Posaux (&(*fi),i); - if( MESH_TYPE::HasPerVertexColor() ) { + if( tri::HasPerVertexColor(m) ) { (*fi).V(i)->C().lerp((*fi).V0(i)->C() , (*fi).V1(i)->C(),0.5f); }