diff --git a/vcg/complex/algorithms/parametrization/tangent_field_operators.h b/vcg/complex/algorithms/parametrization/tangent_field_operators.h index 06f9cba4..b2cf8fb0 100644 --- a/vcg/complex/algorithms/parametrization/tangent_field_operators.h +++ b/vcg/complex/algorithms/parametrization/tangent_field_operators.h @@ -532,32 +532,6 @@ namespace vcg { } } - /*static void GradientToCross(const FaceType &f, - const vcg::Point2 &UV0, - const vcg::Point2 &UV1, - const vcg::Point2 &UV2, - CoordType &dirU, - CoordType &dirV) - { - ///compute non normalized normal - CoordType p1 =f.P(1) - f.P(0); - CoordType p2 =f.P(2) - f.P(0); - CoordType n = p1 ^ p2; - - CoordType _v1 = p2 ^ n; - CoordType _v2 = p1 ^ n; - - ScalarType d1 = _v1 * p1 ; - ScalarType d2 = _v2 * p2 ; - - - - for( int d=0 ; d<3 ; d++ ) - dirU.V(d) = - UV0.X()*_v1.V(d) - UV0.X()*_v2.V(d) + UV1.X()*_v1.V(d) + UV2.X()*_v2.V(d); - - for( int d=0 ; d<3 ; d++ ) - dirV.V(d) = - UV0.Y()*_v1.V(d) - UV0.Y()*_v2.V(d) + UV1.Y()*_v1.V(d) + UV2.Y()*_v2.V(d); - }*/ static void GradientToCross(const FaceType &f, const vcg::Point2 &UV0, @@ -582,176 +556,6 @@ namespace vcg { dirV = t[1]*UV0.Y() + t[2]*UV1.Y() + t[0]*UV2.Y(); } - static bool LoadGrad(MeshType *mesh, - const char *path) - { - FILE *f = fopen(path,"rt"); - if (!f) - { - return false; - } - int numF; - fscanf(f,"%d\n",&numF); - assert(numF==mesh->fn); - char skipstr[200]; - //int readed0; - for (int i=0;i<9;i++) - fscanf(f,"%s",&skipstr[0]); - - for (int i=0;ifn;i++) - { - int i0=-1; - int i1=-1; - int i2=-1; - double u0,v0,u1,v1,u2,v2; - int readed1=fscanf(f,"%d %d %d %lf %lf %lf %lf %lf %lf",&i0,&i1,&i2,&u0,&v0,&u1,&v1,&u2,&v2); - assert(readed1==9); - vcg::Point2 UV[3]; - UV[0]= vcg::Point2(u0,v0); - UV[1]= vcg::Point2(u1,v1); - UV[2]= vcg::Point2(u2,v2); - CoordType dir1; - CoordType dir2; - GradientToCross(mesh->face[i],UV[0],UV[1],UV[2],dir1,dir2); - dir1.Normalize(); - dir2.Normalize(); - mesh->face[i].PD1()=dir1; - mesh->face[i].PD2()=dir2; - } - fclose(f); - return true; - } - - ///load a field on the mesh, it could be a vfield file (per vertex) - ///or an ffield file (per face) - static bool LoadFFIELD(MeshType *mesh, - const char *path, - bool per_vertex=false) - { - - FILE *f = fopen(path,"rt"); - if (!f) - { - return false; - } - { - char word[512]; word[0]=0; - fscanf(f,"%s",word); - char c=0; - if (word[0]=='#') { - // skip comment line - while (fscanf(f,"%c",&c)!=EOF) if (c=='\n') break; - } - else - { - return false; - } - int nnv = -1; - if (fscanf(f,"%d",&nnv)!=1) - { - while (fscanf(f,"%c",&c)!=EOF) if (c=='\n') break; // skip - fscanf(f,"%d",&nnv); - } - int targetnum=mesh->fn; - if (per_vertex) - targetnum=mesh->vn; - if (nnv != (int)targetnum) - { - //if (errorMsg) sprintf(errorMsg,"Wrong element number. Found: %d. Expected: %d.",nnv,mesh->vn); - return false; - } - while (fscanf(f,"%c",&c)!=EOF) if (c=='\n') break; // skip - // skip strange string line - while (fscanf(f,"%c",&c)!=EOF) if (c=='\n') break; - for (int i=0; i u,v; - float a,b; - if (fscanf(f, - "%f %f %f %f %f %f %f %f", - &a,&b, - &(v.X()),&(v.Y()),&(v.Z()), - &(u.X()),&(u.Y()),&(u.Z()) - )!=8) { - //if (errorMsg) sprintf(errorMsg,"Format error reading vertex n. %d",i); - return false; - } - - //vcg::Point3 N; - //N.Import(mesh->face[i].N()); - //u=vcg::Point3(1,0,0); - //v=N^u; - u.Normalize(); - v.Normalize(); - - if (per_vertex) - { - mesh->vert[i].PD1().X()=(ScalarType) u.X(); - mesh->vert[i].PD1().Y()=(ScalarType) u.Y(); - mesh->vert[i].PD1().Z()=(ScalarType) u.Z(); - mesh->vert[i].PD2().X()=(ScalarType) v.X(); - mesh->vert[i].PD2().Y()=(ScalarType) v.Y(); - mesh->vert[i].PD2().Z()=(ScalarType) v.Z(); - } - else - { - mesh->face[i].PD1().X()=(ScalarType) u.X(); - mesh->face[i].PD1().Y()=(ScalarType) u.Y(); - mesh->face[i].PD1().Z()=(ScalarType) u.Z(); - mesh->face[i].PD2().X()=(ScalarType) v.X(); - mesh->face[i].PD2().Y()=(ScalarType) v.Y(); - mesh->face[i].PD2().Z()=(ScalarType) v.Z(); - mesh->face[i].PD1().Normalize(); - mesh->face[i].PD2().Normalize(); - } - } - } - fclose(f); - return true; - } - - ///Save a 4 rosy format file as used by - ///Interactive Visualization of Rotational Symmetry Fields on Surfaces - ///Jonathan Palacios and Eugene Zhang - static void Save4ROSY(MeshType &mesh, - const char *path) - { - FILE *f = fopen(path,"wt"); - fprintf(f,"%d\n",mesh.vn); - fprintf(f,"4\n"); - for (unsigned int i=0;i