added LoadCSVField function
This commit is contained in:
parent
03f41fd117
commit
1356db0573
|
@ -82,7 +82,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool LoadNDF(MeshType &mesh,
|
static bool LoadNDF(MeshType &mesh,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(path,"rt");
|
FILE *f = fopen(path,"rt");
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -99,8 +99,8 @@ public:
|
||||||
printf("%s\n",skipstr);
|
printf("%s\n",skipstr);
|
||||||
}while(strcmp(skipstr,"[Pjumps]")!=0);
|
}while(strcmp(skipstr,"[Pjumps]")!=0);
|
||||||
|
|
||||||
// fscanf(f,"%s\"",skipstr);
|
// fscanf(f,"%s\"",skipstr);
|
||||||
// printf("%s\n",skipstr);
|
// printf("%s\n",skipstr);
|
||||||
fseek(f, 7, SEEK_CUR);
|
fseek(f, 7, SEEK_CUR);
|
||||||
char final[1];
|
char final[1];
|
||||||
do{
|
do{
|
||||||
|
@ -112,37 +112,37 @@ public:
|
||||||
printf("%s\n",&final[0]);
|
printf("%s\n",&final[0]);
|
||||||
}while(strcmp(final,"\"")!=0);
|
}while(strcmp(final,"\"")!=0);
|
||||||
|
|
||||||
// printf("%s\n",skipstr);
|
// printf("%s\n",skipstr);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
// for (int i=0;i<mesh.fn;i++)
|
// for (int i=0;i<mesh.fn;i++)
|
||||||
// {
|
// {
|
||||||
// int i0=-1;
|
// int i0=-1;
|
||||||
// int i1=-1;
|
// int i1=-1;
|
||||||
// int i2=-1;
|
// int i2=-1;
|
||||||
// double u0,v0,u1,v1,u2,v2;
|
// 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);
|
// 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);
|
// assert(readed1==9);
|
||||||
// vcg::Point2<ScalarType> UV[3];
|
// vcg::Point2<ScalarType> UV[3];
|
||||||
// UV[0]= vcg::Point2<ScalarType>(u0,v0);
|
// UV[0]= vcg::Point2<ScalarType>(u0,v0);
|
||||||
// UV[1]= vcg::Point2<ScalarType>(u1,v1);
|
// UV[1]= vcg::Point2<ScalarType>(u1,v1);
|
||||||
// UV[2]= vcg::Point2<ScalarType>(u2,v2);
|
// UV[2]= vcg::Point2<ScalarType>(u2,v2);
|
||||||
// CoordType dir1;
|
// CoordType dir1;
|
||||||
// CoordType dir2;
|
// CoordType dir2;
|
||||||
// vcg::tri::CrossField<MeshType>::GradientToCross(mesh.face[i],UV[0],UV[1],UV[2],dir1,dir2);
|
// vcg::tri::CrossField<MeshType>::GradientToCross(mesh.face[i],UV[0],UV[1],UV[2],dir1,dir2);
|
||||||
// dir1.Normalize();
|
// dir1.Normalize();
|
||||||
// dir2.Normalize();
|
// dir2.Normalize();
|
||||||
// mesh.face[i].PD1()=dir1;
|
// mesh.face[i].PD1()=dir1;
|
||||||
// mesh.face[i].PD2()=dir2;
|
// mesh.face[i].PD2()=dir2;
|
||||||
// }
|
// }
|
||||||
// fclose(f);
|
// fclose(f);
|
||||||
// return true;
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
///load a field on the mesh, it could be a vfield file (per vertex)
|
///load a field on the mesh, it could be a vfield file (per vertex)
|
||||||
///or an ffield file (per face)
|
///or an ffield file (per face)
|
||||||
static bool LoadFFIELD(MeshType &mesh,
|
static bool LoadFFIELD(MeshType &mesh,
|
||||||
const char *path,
|
const char *path,
|
||||||
bool per_vertex=false)
|
bool per_vertex=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
FILE *f = fopen(path,"rt");
|
FILE *f = fopen(path,"rt");
|
||||||
|
@ -188,13 +188,13 @@ public:
|
||||||
vcg::Point3<float> u,v;
|
vcg::Point3<float> u,v;
|
||||||
float a,b;
|
float a,b;
|
||||||
if (fscanf(f,
|
if (fscanf(f,
|
||||||
"%f %f %f %f %f %f %f %f",
|
"%f %f %f %f %f %f %f %f",
|
||||||
&a,&b,
|
&a,&b,
|
||||||
&(v.X()),&(v.Y()),&(v.Z()),
|
&(v.X()),&(v.Y()),&(v.Z()),
|
||||||
&(u.X()),&(u.Y()),&(u.Z())
|
&(u.X()),&(u.Y()),&(u.Z())
|
||||||
)!=8) {
|
)!=8) {
|
||||||
//if (errorMsg) sprintf(errorMsg,"Format error reading vertex n. %d",i);
|
//if (errorMsg) sprintf(errorMsg,"Format error reading vertex n. %d",i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
u.Normalize();
|
u.Normalize();
|
||||||
|
@ -202,13 +202,13 @@ public:
|
||||||
|
|
||||||
if (per_vertex)
|
if (per_vertex)
|
||||||
{
|
{
|
||||||
mesh.vert[i].PD1().Import(u);
|
mesh.vert[i].PD1().Import(u);
|
||||||
mesh.vert[i].PD2().Import(v);
|
mesh.vert[i].PD2().Import(v);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mesh.face[i].PD1().Import(u);
|
mesh.face[i].PD1().Import(u);
|
||||||
mesh.face[i].PD2().Import(v);
|
mesh.face[i].PD2().Import(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,9 +220,9 @@ public:
|
||||||
///Interactive Visualization of Rotational Symmetry Fields on Surfaces
|
///Interactive Visualization of Rotational Symmetry Fields on Surfaces
|
||||||
///Jonathan Palacios and Eugene Zhang
|
///Jonathan Palacios and Eugene Zhang
|
||||||
static void Load4ROSY(MeshType &mesh,
|
static void Load4ROSY(MeshType &mesh,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(path,"rt");
|
FILE *f = fopen(path,"rt");
|
||||||
int num,symm;
|
int num,symm;
|
||||||
fscanf(f,"%d",&num);
|
fscanf(f,"%d",&num);
|
||||||
assert(num==mesh.vn);
|
assert(num==mesh.vn);
|
||||||
|
@ -317,7 +317,7 @@ public:
|
||||||
|
|
||||||
//Load a 4 rosy format file as pair of angles
|
//Load a 4 rosy format file as pair of angles
|
||||||
static bool Load2AngleFace(MeshType &mesh,
|
static bool Load2AngleFace(MeshType &mesh,
|
||||||
const char *path)
|
const char *path)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(path,"rt");
|
FILE *f = fopen(path,"rt");
|
||||||
if (f==NULL)return false;
|
if (f==NULL)return false;
|
||||||
|
@ -335,6 +335,38 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool LoadCSVField(MeshType &mesh,
|
||||||
|
const std::string &field_1,
|
||||||
|
const std::string &field_2,
|
||||||
|
bool Normalize=true)
|
||||||
|
{
|
||||||
|
FILE *f1=NULL;
|
||||||
|
FILE *f2=NULL;
|
||||||
|
f1=fopen(field_1.c_str(),"rt");
|
||||||
|
if(f1==NULL)return false;
|
||||||
|
f2=fopen(field_2.c_str(),"rt");
|
||||||
|
if(f2==NULL)return false;
|
||||||
|
for (size_t i=0;i<mesh.face.size();i++)
|
||||||
|
{
|
||||||
|
float Xdir,Ydir,Zdir;
|
||||||
|
fscanf(f1,"%f,%f,%f\n",&Xdir,&Ydir,&Zdir);
|
||||||
|
mesh.face[i].PD1()=CoordType(Xdir,Ydir,Zdir);
|
||||||
|
//std::cout<<Xdir<<" "<<Ydir<<std::endl;
|
||||||
|
fscanf(f2,"%f,%f,%f\n",&Xdir,&Ydir,&Zdir);
|
||||||
|
mesh.face[i].PD2()=CoordType(Xdir,Ydir,Zdir);
|
||||||
|
//set the quality as force Value
|
||||||
|
if (Normalize)
|
||||||
|
{
|
||||||
|
mesh.face[i].PD1().Normalize();
|
||||||
|
mesh.face[i].PD2().Normalize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//then color by quality
|
||||||
|
fclose(f1);
|
||||||
|
fclose(f2);
|
||||||
|
}
|
||||||
|
|
||||||
}; // end class
|
}; // end class
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue