From 3e8acdd1dc4cb593f10b48fdc74ded22eb404e4a Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Mon, 21 Nov 2005 16:02:28 +0000 Subject: [PATCH] work in progress on even iterations --- src/test/loop/new_refine.h | 73 ++++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/src/test/loop/new_refine.h b/src/test/loop/new_refine.h index 223833973..90da4912d 100644 --- a/src/test/loop/new_refine.h +++ b/src/test/loop/new_refine.h @@ -24,6 +24,9 @@ History $Log$ +Revision 1.5 2005/11/21 16:02:28 mariolatronico +work in progress on even iterations + Revision 1.4 2005/11/18 10:59:09 mariolatronico cleaned RefineEvenOddE. It doesn't work because missed deleted flags @@ -76,7 +79,7 @@ first working version #include #include #include - +#include #define PI 3.14159265 namespace vcg{ @@ -150,7 +153,7 @@ struct OddPointLoop : public std::unary_function struct EvenPointLoop : public std::unary_function , typename MESH_TYPE::CoordType> { - void operator()(typename MESH_TYPE::VertexType &nv, face::Pos ep) { + void operator()(typename MESH_TYPE::CoordType &nP, face::Pos ep) { face::Pos he(ep.f,ep.z,ep.f->V(ep.z)); typename MESH_TYPE::CoordType *r, *l, *curr; @@ -166,7 +169,7 @@ struct EvenPointLoop : public std::unary_functionP() == curr) he.FlipV(); l = &he.v->P(); - nv.P() = ( *(curr) * (3.0)/(4.0) + (*l)*(1.0/8.0) + (*r)*(1.0/8.0)); + nP = ( *(curr) * (3.0)/(4.0) + (*l)*(1.0/8.0) + (*r)*(1.0/8.0)); } else { // compute valence of this vertex @@ -195,7 +198,7 @@ struct EvenPointLoop : public std::unary_function oldVertVec(m.vn); + std::vector oldVertVec(m.vert.size()); - //memorizzo il numero iniziale di vertici - int n = m.vn; - // memorizzo i vertici nel vettore typename MESH_TYPE::VertexIterator vi; - for ( vi = m.vert.begin(); vi != m.vert.end(); ++vi) { - oldVertVec.push_back((*vi)); + int j = 0; + int i = 0; + for (vi = m.vert.begin(); vi != m.vert.end(); vi++, i++) { + typename MESH_TYPE::FaceType *fc = (*vi).VFp(); + if ((*vi) == *(fc->V(0))) + j = 0; + if ((*vi) == *(fc->V(1))) + j = 1; + if ((*vi) == *(fc->V(2))) + j = 2; +// if (m.vert[i] == fc.V(0)) +// j = 0; +// if (m.vert[i] == fc.V(1)) +// j = 1; +// if (m.vert[i] == fc.V(2)) +// j = 2; + + face::Posaux (fc,j); + + even(oldVertVec[i], aux ); + } + + for ( vi = m.vert.begin(); vi != m.vert.end(); ++vi) { + oldVertVec.push_back(((*vi).P())); + } + // refine dei vertici odd, crea dei nuovi vertici in coda Refine< MESH_TYPE,OddPointLoop > (m, odd, length); - - for (int i = 0 ; i < n; ++i) - { + + vcg::tri::UpdateTopology::VertexFace(m); + vcg::tri::UpdateTopology::FaceFace(m); + + for (int i = 0; i < oldVertVec.size(); i++) { + + m.vert[i].P() = oldVertVec[i]; + + } + +// for (int i = 0 ; i < n; ++i) +// { - even(m.vert[i], face::Pos((oldVertVec[i].VFp()),1)); + +// // even(m.vert[i], face::Pos(m.vert[i].VFp(),1)); +// // if (m.vert[i].VFp() && !m.vert[i].VFp()->IsD()) { +// qDebug("%p", oldVertVec[i].VFp()); +// //even(m.vert[i], face::Pos(m.vert[i].VFp(),1)); +// // even(oldVertVec[i], face::Pos(m.vert[i].VFp(),1)); +// if (! oldVertVec[i].VFp()->IsD()) +// even(oldVertVec[i], face::Pos(oldVertVec[i].VFp(),1)); + +// m.vert[i] = oldVertVec[i]; - } +// //} +// } // 1) calcola nuova pos vertici old e memorizza in un vett ausiliairio