diff --git a/vcg/complex/algorithms/refine_loop.h b/vcg/complex/algorithms/refine_loop.h index bfb19226..8b229e46 100644 --- a/vcg/complex/algorithms/refine_loop.h +++ b/vcg/complex/algorithms/refine_loop.h @@ -221,14 +221,12 @@ struct Centroid { } inline void addVertex(const typename MESH_TYPE::VertexType &v, LScalar w) { LVector p(v.cP().X(), v.cP().Y(), v.cP().Z()); - LVector n(v.cN().X(), v.cN().Y(), v.cN().Z()); - sumP += p * w; sumW += w; } - inline void project(typename MESH_TYPE::VertexType &v) const { + inline void project(std::pair &nv) const { LVector position = sumP / sumW; - v.P() = Coord(position.X(), position.Y(), position.Z()); + nv.first = Coord(position.X(), position.Y(), position.Z()); } }; @@ -274,7 +272,7 @@ struct LS3Projection { sumDotPP += w * vcg::SquaredNorm(p); sumW += w; } - void project(typename MESH_TYPE::VertexType &v) const { + void project(std::pair &nv) const { LScalar invSumW = Scalar(1)/sumW; LScalar aux4 = beta * LScalar(0.5) * (sumDotPN - invSumW*sumP.dot(sumN)) @@ -339,8 +337,8 @@ struct LS3Projection { normal.Normalize(); } - v.P() = Coord(position.X(), position.Y(), position.Z()); - v.N() = Coord(normal.X(), normal.Y(), normal.Z()); + nv.first = Coord(position.X(), position.Y(), position.Z()); + nv.second = Coord(normal.X(), normal.Y(), normal.Z()); } }; @@ -374,7 +372,10 @@ struct OddPointLoopGeneric : public std::unary_functionpp; + proj.project(pp); + nv.P()=pp.first; + nv.N()=pp.second; } else { he.FlipE(); he.FlipV(); @@ -398,7 +399,11 @@ struct OddPointLoopGeneric : public std::unary_functionpp; + proj.project(pp); + nv.P()=pp.first; + nv.N()=pp.second; +// proj.project(nv); } } @@ -437,7 +442,7 @@ struct EvenPointLoopGeneric : public std::unary_function ep) { + void operator()(std::pair &nv, face::Pos ep) { proj.reset(); face::Pos he(ep.f,ep.z,ep.f->V(ep.z)); @@ -473,7 +478,11 @@ struct EvenPointLoopGeneric : public std::unary_functionpp; proj.project(nv); +// nv.P()=pp.first; +// nv.N()=pp.second; +// proj.project(nv); } else { // Inner rule // assert(!he.v->IsB()); border flag no longer updated (useless) @@ -565,7 +574,8 @@ bool RefineOddEvenE(MESH_TYPE &m, ODD_VERT odd, EVEN_VERT even, PREDICATE edgePr // store updated vertices std::vector updatedList(m.vn, false); - std::vector newEven(m.vn); + //std::vector newEven(m.vn); + std::vector > newEven(m.vn); typename MESH_TYPE::VertexIterator vi; typename MESH_TYPE::FaceIterator fi; @@ -597,11 +607,13 @@ bool RefineOddEvenE(MESH_TYPE &m, ODD_VERT odd, EVEN_VERT even, PREDICATE edgePr // refine dei vertici odd, crea dei nuovi vertici in coda RefineE< MESH_TYPE, ODD_VERT > (m, odd, edgePred, RefineSelected, cbOdd); - typename std::vector::iterator nei; + typename std::vector >::iterator nei; for (nei=newEven.begin(); nei!=newEven.end(); ++nei) { if(updatedList[nei-newEven.begin()]) { - m.vert[nei-newEven.begin()].ImportData(*nei); - assert(m.vert[nei-newEven.begin()].N() == nei->N()); +// m.vert[nei-newEven.begin()].ImportData(*nei); +// assert(m.vert[nei-newEven.begin()].N() == nei->N()); + m.vert[nei-newEven.begin()].P()=(*nei).first; + m.vert[nei-newEven.begin()].N()=(*nei).second; } }