本文整理汇总了C++中FileIO::eof方法的典型用法代码示例。如果您正苦于以下问题:C++ FileIO::eof方法的具体用法?C++ FileIO::eof怎么用?C++ FileIO::eof使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO::eof方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readObject
BasicObject* Picture::readObject(char* fileName)
{
BasicObject* obj = new BasicObject();
FileIO* file = new FileIO(fileName, ' '); //assumed to be a read if a delimiter is specified
List<Vertex> vertices;
double x, y, z;
string* token;
int index1, index2, index3, temp;
//parsing the complex index information for the triangular face
//could include a vertex index, a vertex normal index, and texture coord information
string* str1;
string* str2;
string* str3;
string str11;
string str22;
string str33;
string* v = new string("v");
string* f = new string("f");
while (!file->eof())
{
ListIterator<string>* iter = file->getTokens();
token = iter->next();
//all vertices are held in the vertices list so that the faces can be created
if (*token == *v) //vertices
{
delete token;
token = iter->next();
x = atof((*token).c_str());
delete token;
token = iter->next();
y = atof((*token).c_str());
delete token;
token = iter->next();
z = atof((*token).c_str());
delete token;
Vertex* vertex = new Vertex(x, y, z);
vertices.add(vertex);
obj->addVertex(vertex);
}
else if (*token == *f) //face definition
{
delete token;
//get the complex index information for the triangle face
str1 = iter->next();
str2 = iter->next();
str3 = iter->next();
//parse the index information for the vertex index
temp = str1->find("/");
str11 = str1->erase(temp, str1->size() - 1);
temp = str2->find("/");
str22 = str2->erase(temp, str2->size() - 1);
temp = str3->find("/");
str33 = str3->erase(temp, str3->size() - 1);
char* cp;
int len;
cp = new char[10];
len = str11.length();
str11.copy(cp, len, 0);
cp[len] = '\0';
index1 = atoi(cp);
delete[] cp;
cp = new char[10];
len = str22.length();
str22.copy(cp, len, 0);
cp[len] = '\0';
index2 = atoi(cp);
delete[] cp;
cp = new char[10];
len = str33.length();
str33.copy(cp, len, 0);
cp[len] = '\0';
index3 = atoi(cp);
delete[] cp;
Face* face = new Face();
Vertex* vertex1 = vertices.get(index1);
Vertex* vertex2 = vertices.get(index2);
Vertex* vertex3 = vertices.get(index3);
face->addVertex(vertex1);
face->addVertex(vertex2);
face->addVertex(vertex3);
//.........这里部分代码省略.........