From ba507529c86410a3d2c570690c391ae77996592c Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 18 Apr 2012 21:09:08 +0000 Subject: [PATCH] Modified intersectionPlaneQuality so that it also compute the per vertex normal according to the mesh... --- vcg/complex/algorithms/intersection.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vcg/complex/algorithms/intersection.h b/vcg/complex/algorithms/intersection.h index fefcffcb..21603540 100644 --- a/vcg/complex/algorithms/intersection.h +++ b/vcg/complex/algorithms/intersection.h @@ -148,22 +148,30 @@ bool IntersectionPlaneMeshQuality(TriMeshType & m, EdgeMeshType & em) { std::vector ptVec; + std::vector nmVec; tri::UpdateQuality::VertexFromPlane(m,pl); for(size_t i=0;iQ() * m.face[i].V1(j)->Q())<0) { const Point3f &p0 = m.face[i].V0(j)->cP(); const Point3f &p1 = m.face[i].V1(j)->cP(); + const Point3f &n0 = m.face[i].V0(j)->cN(); + const Point3f &n1 = m.face[i].V1(j)->cN(); + float q0 = m.face[i].V0(j)->Q(); + float q1 = m.face[i].V1(j)->Q(); // printf("Intersection ( %3.2f %3.2f %3.2f )-( %3.2f %3.2f %3.2f )\n",p0[0],p0[1],p0[2],p1[0],p1[1],p1[2]); Point3f pp; Segment3f seg(p0,p1); IntersectionPlaneSegment(pl,seg,pp); ptVec.push_back(pp); + Point3f nn =(n0*fabs(q1) + n1*fabs(q0))/fabs(q0-q1); + nmVec.push_back(nn); } if(m.face[i].V(j)->Q()==0) ptVec.push_back(m.face[i].V(j)->cP()); } @@ -173,9 +181,11 @@ bool IntersectionPlaneMeshQuality(TriMeshType & m, vcg::tri::Allocator::AddEdges(em,1); vi = vcg::tri::Allocator::AddVertices(em,2); (*vi).P() = ptVec[0]; + (*vi).N() = nmVec[0]; em.edge.back().V(0) = &(*vi); vi++; (*vi).P() = ptVec[1]; + (*vi).N() = nmVec[1]; em.edge.back().V(1) = &(*vi); } }