39 bool triSurface::readOBJ(
const fileName& OBJfileName)
41 IFstream OBJfile(OBJfileName);
46 <<
"Cannot read file " << OBJfileName
51 DynamicList<labelledTri> faces;
52 HashTable<label> groupToPatch;
57 while (OBJfile.good())
59 string line = getLineNoComment(OBJfile);
61 if (line[line.size()-1] ==
'\\')
63 line.substr(0, line.size()-1);
64 line += getLineNoComment(OBJfile);
68 IStringStream lineStream(line);
76 lineStream >> x >> y >> z;
78 points.append(
point(x, y, z));
87 groupToPatch.find(group);
89 if (findGroup != groupToPatch.end())
91 groupID = findGroup();
97 groupToPatch.insert(group, groupID);
104 DynamicList<label> verts;
107 string::size_type endNum = 1;
111 string::size_type startNum =
112 line.find_first_not_of(
' ', endNum);
114 if (startNum == string::npos)
119 endNum = line.find(
' ', startNum);
122 if (endNum != string::npos)
124 vertexSpec = line.substr(startNum, endNum-startNum);
128 vertexSpec = line.substr(startNum, line.size() - startNum);
131 string::size_type slashPos = vertexSpec.find(
'/');
134 if (slashPos != string::npos)
136 IStringStream intStream(vertexSpec.substr(0, slashPos));
142 IStringStream intStream(vertexSpec);
146 verts.append(vertI - 1);
153 for (label fp = 1; fp < verts.size() - 1; fp++)
155 label fp1 = verts.fcIndex(fp);
157 labelledTri tri(verts[0], verts[fp], verts[fp1], groupID);
174 patches[0] = geometricSurfacePatch(
"empty",
"patch0", 0);
181 iter != groupToPatch.end();
185 patches[iter()] = geometricSurfacePatch