From 30985f5cdc4439a6cee9dc85febb7f4c5e082b78 Mon Sep 17 00:00:00 2001 From: Nico Pietroni nicopietroni Date: Fri, 18 Sep 2009 10:20:08 +0000 Subject: [PATCH] * corrected 1 bug in getClosest function * pass 1 more parameters (num) in getSharedVertices to limitate the search in the input vectors to a specified numbers of elements. * corrected 1 bug in InterpolationSpace * corercted return in inv_GE0 function --- .../iso_parametrization.h | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/meshlabplugins/filter_isoparametrization/iso_parametrization.h b/src/meshlabplugins/filter_isoparametrization/iso_parametrization.h index 4f8eb3ed9..f6f977aaf 100644 --- a/src/meshlabplugins/filter_isoparametrization/iso_parametrization.h +++ b/src/meshlabplugins/filter_isoparametrization/iso_parametrization.h @@ -208,6 +208,7 @@ void CopyMeshFromVerticesAbs(std::vector &vertic new_mesh.vert[i].RPos=(*iteVI)->RPos; new_mesh.vert[i].T().P()=(*iteVI)->T().P(); new_mesh.vert[i].T().N()=(*iteVI)->T().N(); + new_mesh.vert[i].C()=(*iteVI)->C(); /*new_mesh.vert[i].father=(*iteVI)->father; new_mesh.vert[i].Bary=(*iteVI)->Bary;*/ //new_mesh.vert[i].Damp=(*iteVI)->Damp; @@ -334,6 +335,9 @@ private: face.resize(1); baryVal.resize(1); bool found=grid.getClosest(UV,face[0],baryVal[0]); + int index=face[0]-&(*HresDomain->face.begin()); + assert(indexfn); + face[0]=ordered_faces[index]; return found; } }; @@ -738,17 +742,22 @@ private: return num; } - int getSharedVertices(const std::vector &I,AbstractVertex *shared[3]) + int getSharedVertices(const std::vector &I,AbstractVertex *shared[3],int *_num=NULL) { ///else test the number of vertices shared AbstractVertex * shared_vert[3]; bool sharedB[3]; + int size; + if (_num==NULL) + size=I.size(); + else + size=*_num; ///quick test for 2 or 3 cases - if (I.size()==2) + if (size==2) return getSharedVertices(&AbsMesh()->face[I[0]],&AbsMesh()->face[I[1]],shared); else - if (I.size()==3) + if (size==3) return getSharedVertices(&AbsMesh()->face[I[0]],&AbsMesh()->face[I[1]],&AbsMesh()->face[I[2]],shared); AbstractFace* f0=&AbsMesh()->face[I[0]]; @@ -762,7 +771,7 @@ private: sharedB[1]=true; sharedB[2]=true; //for each face - for (int i=1;iface[I[i]]; //for each vertex @@ -935,18 +944,24 @@ public: } ///return 0 if is a face 1 is a diamaond and 2 is a star - int InterpolationSpace(const std::vector &I,int &IndexDomain) + int InterpolationSpace(const std::vector &I,int &IndexDomain,int *_num=NULL) { + int size; + if (_num==NULL) + size=I.size(); + else + size=*_num; + ///simple cases assert(I.size()>0); ///1 element - if (I.size()==1) + if (size==1) { IndexDomain=I[0]; return 0; } ///2 elements - if (I.size()==2) + if (size==2) return InterpolationSpace(I[0],I[1],IndexDomain); ///test if they all are the same @@ -954,7 +969,7 @@ public: bool sameface=true; int i=1; int I0=I[0]; - while ((i=0); //printf("%f,%f \n",UV.X(),UV.Y()); assert((UV.X()+UV.Y())<=(1+eps)); + //printf("%f,%f \n",UV.X(),UV.Y()); ///FACE SEARCH ///first test if is in the face domain //printf("face\n"); bool found=false; int indexFace=I; + /*if (indexFace>=face_meshes.size()) + printf("B");*/ + vcg::Point2 UVFace; GE2(indexFace,UV,UVFace); found=face_meshes[indexFace].Project(UVFace,face,baryVal); @@ -1162,6 +1181,8 @@ public: vcg::Point2 UVDiam; ///transform UV coordids in diamond GE1(I,UV,indexDiam,UVDiam); + /*if (indexDiam>=diamond_meshes.size())*/ + /*printf("C");*/ found=diamond_meshes[indexDiam].Project(UVDiam,face,baryVal); if (found) return 1; @@ -1181,6 +1202,7 @@ public: assert(found); #else star_meshes[indexStar].getClosest(UVStar,face,baryVal); + /*printf("D");*/ #endif } return 2; @@ -1213,7 +1235,9 @@ public: { std::vector face; std::vector baryVal; + int ret=Theta(I,UV,face,baryVal); + pos3D=CoordType(0,0,0); for (int i=0;iV(2)->P()*baryVal[i].Z(); pos3D+=pos; } + pos3D/=(ScalarType)face.size(); return ret; } @@ -1257,6 +1282,8 @@ public: CoordType bary; int index; bool done=GetBaryFaceFromUV(*star_domain,UVHstar.X(),UVHstar.Y(),bary,index); + if (!done) + return false; UV.X()=bary.X(); UV.Y()=bary.Y(); I=star_meshes[StarIndex].Local2Global(index); @@ -1733,10 +1760,10 @@ public: // } // fclose(f); //} - + template int LoadMCP(AbstractMesh * _abstract_mesh, ParamMesh * _param_mesh, - char* filename) + char* filename,MeshType *coloredMesh=NULL) { abstract_mesh=_abstract_mesh; param_mesh=_param_mesh; @@ -1802,7 +1829,11 @@ public: //vert->RPos=pos; vert->T().P()=vcg::Point2(bary.X(),bary.Y()); vert->T().N()=index_face; - + if (coloredMesh!=NULL) + { + vcg::Color4b col=coloredMesh->vert[i].C(); + vert->C()=col; + } } ///add faces