64 string::size_type space = line.find(
' ');
66 if (space != string::npos)
68 cmd = line.substr(0, space);
69 args = line.substr(space+1);
92 string::size_type space = line.find(
' ');
94 if (space != string::npos && line.substr(0, space) == cmd)
96 args = line.substr(space+1);
110 const string errorMsg
116 <<
"Cannot find command " << cmd
124 bool triSurface::readAC(
const fileName& ACfileName)
126 IFstream ACfile(ACfileName);
131 <<
"Cannot read file " << ACfileName
138 string version = line.substr(4);
142 WarningIn(
"bool triSurface::readAC(const fileName& ACfileName)")
143 <<
"When reading AC3D file " << ACfileName
144 <<
" read header " << line <<
" with version " << version
145 <<
endl <<
"Only tested reading with version 'b'."
146 <<
" This might give problems" <<
endl;
153 if (!
readUpto(
"OBJECT", ACfile, args) || (args !=
"world"))
155 FatalErrorIn(
"bool triSurface::readAC(const fileName& ACfileName)")
156 <<
"Cannot find \"OBJECT world\" in file " << ACfileName
168 DynamicList<point>
points;
169 DynamicList<labelledTri> faces;
174 label patchStartVert = 0;
176 for (label patchI = 0; patchI <
nPatches; patchI++)
178 readUpto(
"OBJECT", ACfile, args,
" while reading patch " + patchI);
181 string patchName = string(
"patch") +
name(patchI);
187 while (ACfile.
good())
191 if (!
readCmd(ACfile, cmd, args))
194 <<
"Did not read up to \"kids 0\" while reading patch "
195 << patchI <<
" from file " << ACfileName
201 IStringStream nameStream(args);
203 nameStream >> patchName;
205 else if (cmd ==
"rot")
208 IStringStream lineStream(args);
211 >> rot.xx() >> rot.xy() >> rot.xz()
212 >> rot.yx() >> rot.yy() >> rot.yz()
213 >> rot.zx() >> rot.zy() >> rot.zz();
215 WarningIn(
"triSurface::readAC(const fileName&)")
216 <<
"rot (rotation tensor) command not implemented"
217 <<
"Line:" << cmd <<
' ' << args <<
endl
218 <<
"while reading patch " << patchI <<
endl;
220 else if (cmd ==
"loc")
222 IStringStream lineStream(args);
224 lineStream >> loc.x() >> loc.y() >> loc.z();
226 else if (cmd ==
"numvert")
230 for (label vertI = 0; vertI < nVerts; vertI++)
234 IStringStream lineStream(line);
238 lineStream >> pt.
x() >> pt.y() >> pt.z();
241 points.append(pt+loc);
244 else if (cmd ==
"numsurf")
248 for (label triI = 0; triI < nTris; triI++)
250 static string errorMsg =
251 string(
" while reading face ")
252 +
name(triI) +
" on patch " +
name(patchI)
253 +
" from file " + ACfileName;
255 readUpto(
"SURF", ACfile, args, errorMsg);
256 readUpto(
"mat", ACfile, args, errorMsg);
257 readUpto(
"refs", ACfile, args, errorMsg);
264 <<
"Can only read surfaces with 3 vertices."
266 <<
"Detected " << size <<
" when reading triangle "
267 << triI <<
" of patch " << patchI
297 patchStartVert += nVerts;
299 else if (cmd ==
"kids")
308 <<
"Can only read objects without kids."
309 <<
" Encountered " << nKids <<
" kids when"
310 <<
" reading patch " << patchI
315 geometricSurfacePatch
335 stitchTriangles(allPoints);