added LoadCSVField function
This commit is contained in:
parent
03f41fd117
commit
1356db0573
|
@ -335,6 +335,38 @@ public:
|
|||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue