void MSDM2_Component::Matching_Multires_Update(PolyhedronPtr m_PolyDegrad, Facet * _TabMatchedFacet) { int ind=0; for(Vertex_iterator pVertex = m_PolyDegrad->vertices_begin(); pVertex != m_PolyDegrad->vertices_end(); pVertex++) { //Point3d Nearest=pVertex->match; // MT Facet* f_Nearest=&_TabMatchedFacet[ind]; pVertex->tag(ind); ind++; //for debug //pVertex->point()=Nearest; ///calculation of the nearest point curvature value using vertices of the Nearest triangle //we use linear interpolation using barycentric coordinates Point3d x1=f_Nearest->halfedge()->vertex()->point(); Point3d x2=f_Nearest->halfedge()->next()->vertex()->point(); Point3d x3=f_Nearest->halfedge()->next()->next()->vertex()->point(); double l1=sqrt((x3-x2)*(x3-x2)); double l2=sqrt((x1-x3)*(x1-x3)); double l3=sqrt((x1-x2)*(x1-x2)); Vector v1=f_Nearest->halfedge()->vertex()->point()-pVertex->point(); Vector v2=f_Nearest->halfedge()->next()->vertex()->point()-pVertex->point(); Vector v3=f_Nearest->halfedge()->next()->next()->vertex()->point()-pVertex->point(); double t1=sqrt(v1*v1); double t2=sqrt(v2*v2); double t3=sqrt(v3*v3); double p1=(l1+t2+t3)/2; double p2=(t1+l2+t3)/2; double p3=(t1+t2+l3)/2; double A1=(p1*(p1-l1)*(p1-t3)*(p1-t2)); double A2=(p2*(p2-l2)*(p2-t3)*(p2-t1)); double A3=(p3*(p3-l3)*(p3-t1)*(p3-t2)); if(A1>0) A1=sqrt(A1); else A1=0; if(A2>0) A2=sqrt(A2); else A2=0; if(A3>0) A3=sqrt(A3); else A3=0; double c1=f_Nearest->halfedge()->vertex()->KmaxCurv; double c2=f_Nearest->halfedge()->next()->vertex()->KmaxCurv; double c3=f_Nearest->halfedge()->next()->next()->vertex()->KmaxCurv; if((A1+A2+A3)>0) pVertex->curvmatch=(A1*c1+A2*c2+A3*c3)/(A1+A2+A3); else pVertex->curvmatch=(c1+c2+c3)/3; } }
void MSDM2_Component::ProcessMSDM2_per_vertex( Vertex_iterator pVertex,double radius,std::vector<double> & TabDistance1,std::vector<double>& TabDistance2,std::vector<Point3d> &TabPoint1,std::vector<Point3d> &TabPoint2) { std::set<int> vertices ; std::stack<Vertex_iterator> S ; Point3d O = pVertex->point() ; S.push(pVertex) ; vertices.insert(pVertex->tag()) ; TabDistance1.push_back(pVertex->KmaxCurv); TabPoint1.push_back(pVertex->point()); TabDistance2.push_back(pVertex->curvmatch); TabPoint2.push_back(pVertex->match); int NbSommetInSphere=0; //double SommeDistance=0; // MT while(!S.empty()) { Vertex_iterator v = S.top() ; S.pop() ; Point3d P = v->point() ; Halfedge_around_vertex_circulator h = v->vertex_begin(); Halfedge_around_vertex_circulator pHalfedgeStart = h; CGAL_For_all(h,pHalfedgeStart) { Point3d p1 = h->vertex()->point(); Point3d p2 = h->opposite()->vertex()->point(); Point3d p1m = h->vertex()->match; Point3d p2m = h->opposite()->vertex()->match; Vector V = (p2-p1); Vector Vm = (p2m-p1m); if(v==pVertex || V * (P - O) > 0.0) { double len_old = std::sqrt(V*V); bool isect = sphere_clip_vector_MSDM2(O, radius, P, V) ; double len_edge = std::sqrt(V*V); NbSommetInSphere++; double WeightedCurv1,WeightedCurv2; Point3d WeightedP1,WeightedP2; bool IsAlreadyIntegrated=false; if(!isect) { Vertex_iterator w=h->opposite()->vertex(); if(vertices.find(w->tag()) == vertices.end()) { vertices.insert(w->tag()) ; S.push(w) ; } else IsAlreadyIntegrated=true; } if (IsAlreadyIntegrated==false) { if(len_old!=0) { if(isect) { WeightedCurv1=(1-len_edge/len_old)*h->vertex()->KmaxCurv+len_edge/len_old*h->opposite()->vertex()->KmaxCurv; WeightedP1=p1+V; WeightedCurv2=(1-len_edge/len_old)*h->vertex()->curvmatch+len_edge/len_old*h->opposite()->vertex()->curvmatch; WeightedP2=p1m+(len_edge/len_old)*Vm; } else { WeightedCurv1=h->opposite()->vertex()->KmaxCurv; WeightedCurv2=h->opposite()->vertex()->curvmatch; WeightedP1=p2; WeightedP2=p2m; } } else { WeightedCurv1=h->opposite()->vertex()->KmaxCurv; WeightedCurv2=h->opposite()->vertex()->curvmatch; WeightedP1=p2; WeightedP2=p2m; } TabDistance1.push_back(WeightedCurv1); TabPoint1.push_back(WeightedP1); TabDistance2.push_back(WeightedCurv2); TabPoint2.push_back(WeightedP2); } } } }