38 #include "triSurface.H"
52 size_t expSign =
s.find_last_of(
"+-");
54 if (expSign != string::npos && expSign > 0 && !
isspace(
s[expSign-1]))
59 if (
s[expSign] ==
'-')
63 return mantissa*
pow(10, exponent);
81 size_t indexStart, indexEnd;
85 indexEnd =
line.find(
',', indexStart);
88 if (indexEnd == std::string::npos)
90 indexEnd = indexStart + width;
94 return line.substr(indexStart, indexEnd - indexStart);
105 <<
"Cannot read file " << fName
110 DynamicList<point>
points;
112 DynamicList<label> indices;
114 DynamicList<labelledTri> faces;
116 Map<label> groupToPatch;
119 Map<word> groupToName;
129 HashSet<word> unhandledCmd;
138 if (line.substr(0, 10) ==
"$ANSA_NAME")
147 && sem1 != string::npos
148 && sem2 != string::npos
153 IStringStream(line.substr(sem0+1, sem1-sem0-1))()
155 ansaType = line.substr(sem1+1, sem2-sem1-1);
158 is.getLine(ansaName);
159 if (ansaName[ansaName.size()-1] ==
'\r')
161 ansaName = ansaName.substr(1, ansaName.size()-2);
165 ansaName = ansaName.substr(1, ansaName.size()-1);
179 line.substr(0, 12) ==
"$HMNAME COMP"
180 && line.find (
'"') != string::npos
185 IStringStream(line.substr(16, 16))()
188 IStringStream lineStream(line.substr(32));
191 lineStream >> rawName;
193 groupToName.insert(groupId, string::validate<word>(rawName));
194 Info<<
"group " << groupId <<
" => " << rawName <<
endl;
198 if (line.empty() || line[0] ==
'$')
205 if (line.size() > 72 && line[72] ==
'+')
207 line = line.substr(0, 72);
214 if (buf.size() > 72 && buf[72]==
'+')
216 line += buf.substr(8, 64);
220 line += buf.substr(8, buf.size()-8);
227 word cmd(IStringStream(
readNASToken(line, 8, linei))());
242 if (iter == groupToPatch.end())
245 groupToPatch.insert(groupId, patchI);
246 Info<<
"patch " << patchI <<
" => group " << groupId <<
endl;
253 faces.append(labelledTri(a,
b,
c, patchI));
255 else if (cmd ==
"CQUAD4")
269 if (iter == groupToPatch.end())
272 groupToPatch.insert(groupId, patchI);
273 Info<<
"patch " << patchI <<
" => group " << groupId <<
endl;
280 faces.append(labelledTri(a,
b,
c, patchI));
281 faces.append(labelledTri(
c, d, a, patchI));
283 else if (cmd ==
"PSHELL")
288 if (groupId == ansaId && ansaType ==
"PSHELL")
290 groupToName.insert(groupId, string::validate<word>(ansaName));
291 Info<<
"group " << groupId <<
" => " << ansaName <<
endl;
294 else if (cmd ==
"GRID")
303 indices.append(index);
306 else if (cmd ==
"GRID*")
324 <<
"Expected continuation symbol '*' when reading GRID*"
325 <<
" (double precision coordinate) output" <<
nl
326 <<
"Read:" << line <<
nl
327 <<
"File:" << is.name()
328 <<
" line:" << is.lineNumber()
334 indices.append(index);
337 else if (unhandledCmd.insert(cmd))
339 Info<<
"Unhandled Nastran command " << line <<
nl
340 <<
"File:" << is.name() <<
" line:" << is.lineNumber() <<
endl;
349 Info<<
"Read triangles:" << faces.size() <<
" points:" <<
points.size()
354 Map<label> indexToPoint(2*indices.size());
357 indexToPoint.insert(indices[i], i);
363 labelledTri&
f = faces[i];
365 f[0] = indexToPoint[
f[0]];
366 f[1] = indexToPoint[
f[1]];
367 f[2] = indexToPoint[
f[2]];
377 label patchI = groupToPatch[iter.key()];
379 patches[patchI] = geometricSurfacePatch