ifstream tf("tf.obj", std::ios::in);//打开文件
char s[50] = {0};
string v = "";
string x = "";
string y = "";
string z = "";
for (int i = 0; i < nstrands; i++)
{
for (int j = 0; j < r.strands[i].size(); j++)
{
tf.getline(s, sizeof(s));//逐行读取
stringstream word(s);//采用字符流格式将读取的str进行空格分隔,并放入str word中
word >> v;
word >> x;
word >> y;
word >> z;
//string类型转float类型
float a = atof(x.c_str());
float b = atof(y.c_str());
float c = atof(z.c_str());
r.strands[i][j][0] = a;
r.strands[i][j][1] = b;
r.strands[i][j][2] = c;
}
}