54 const bool mustTriangulate = this->isTri();
62 "fileFormats::OBJsurfaceFormat::read(const fileName&)"
64 <<
"Cannot read file " << filename
80 lookup.
insert(
"zone0", zoneI);
86 string line = this->getLineNoComment(is);
89 if (line[line.size()-1] ==
'\\')
91 line.substr(0, line.size()-1);
92 line += this->getLineNoComment(is);
103 lineStream >> x >> y >> z;
112 if (fnd != lookup.
end())
123 zoneI = dynSizes.
size();
124 lookup.
insert(name, zoneI);
134 string::size_type endNum = 1;
138 string::size_type startNum =
139 line.find_first_not_of(
' ', endNum);
141 if (startNum == string::npos)
146 endNum = line.find(
' ', startNum);
149 if (endNum != string::npos)
151 vertexSpec = line.substr(startNum, endNum-startNum);
155 vertexSpec = line.substr(startNum, line.size() - startNum);
158 string::size_type slashPos = vertexSpec.find(
'/');
161 if (slashPos != string::npos)
173 dynVertices.
append(vertI - 1);
179 if (mustTriangulate && f.
size() > 3)
183 for (label fp1 = 1; fp1 < f.
size() - 1; fp1++)
203 this->storedPoints().
transfer(dynPoints);
205 sortFacesAndStore(dynFaces.
xfer(), dynZones.
xfer(), sorted);
208 this->addZones(dynSizes, dynNames,
true);
229 : oneZone(faceLst,
"")
239 "fileFormats::OBJsurfaceFormat::write"
240 "(const fileName&, const MeshedSurfaceProxy<Face>&)"
242 <<
"Cannot open file for writing " << filename
247 os <<
"# Wavefront OBJ file written " << clock::dateTime().c_str() <<
nl
250 <<
"# points : " << pointLst.
size() <<
nl
251 <<
"# faces : " << faceLst.
size() <<
nl
252 <<
"# zones : " << zones.
size() <<
nl;
257 os <<
"# " << zoneI <<
" " << zones[zoneI].name()
258 <<
" (nFaces: " << zones[zoneI].
size() <<
")" <<
nl;
262 <<
"# <points count=\"" << pointLst.
size() <<
"\">" <<
nl;
267 const point& pt = pointLst[ptI];
269 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
nl;
272 os <<
"# </points>" <<
nl
274 <<
"# <faces count=\"" << faceLst.
size() <<
"\">" <<
endl;
280 const surfZone& zone = zones[zoneI];
282 if (zone.
name().size())
291 const Face&
f = faceLst[faceMap[faceIndex++]];
296 os <<
' ' << f[fp] + 1;
305 const Face&
f = faceLst[faceIndex++];
310 os <<
' ' << f[fp] + 1;
316 os <<
"# </faces>" <<
endl;