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);
72 bool triSurface::readNAS(
const fileName& fName)
79 <<
"Cannot read file " << fName
86 DynamicList<label> indices;
88 DynamicList<labelledTri> faces;
90 Map<label> groupToPatch;
93 Map<word> groupToName;
103 HashSet<word> unhandledCmd;
111 if (line.substr(0, 10) ==
"$ANSA_NAME")
113 string::size_type sem0 = line.find (
';', 0);
114 string::size_type sem1 = line.find (
';', sem0+1);
115 string::size_type sem2 = line.find (
';', sem1+1);
120 && sem1 != string::npos
121 && sem2 != string::npos
126 IStringStream(line.substr(sem0+1, sem1-sem0-1))()
128 ansaType = line.substr(sem1+1, sem2-sem1-1);
131 is.getLine(ansaName);
132 if (ansaName[ansaName.size()-1] ==
'\r')
134 ansaName = ansaName.substr(1, ansaName.size()-2);
138 ansaName = ansaName.substr(1, ansaName.size()-1);
152 line.substr(0, 12) ==
"$HMNAME COMP"
153 && line.find (
'"') != string::npos
156 label groupId = readLabel
158 IStringStream(line.substr(16, 16))()
161 IStringStream lineStream(line.substr(32));
164 lineStream >> rawName;
166 groupToName.insert(groupId, string::validate<word>(rawName));
167 Info<<
"group " << groupId <<
" => " << rawName <<
endl;
171 if (line.empty() || line[0] ==
'$')
178 if (line.size() > 72 && line[72] ==
'+')
180 line = line.substr(0, 72);
187 if (buf.size() > 72 && buf[72]==
'+')
189 line += buf.substr(8, 64);
193 line += buf.substr(8, buf.size()-8);
200 IStringStream lineStream(line);
206 label groupId = readLabel(IStringStream(line.substr(16,8))());
207 label a = readLabel(IStringStream(line.substr(24,8))());
208 label
b = readLabel(IStringStream(line.substr(32,8))());
209 label c = readLabel(IStringStream(line.substr(40,8))());
216 if (iter == groupToPatch.end())
219 groupToPatch.insert(groupId, patchI);
220 Info<<
"patch " << patchI <<
" => group " << groupId <<
endl;
227 faces.append(labelledTri(a, b, c, patchI));
229 else if (cmd ==
"CQUAD4")
231 label groupId = readLabel(IStringStream(line.substr(16,8))());
232 label a = readLabel(IStringStream(line.substr(24,8))());
233 label b = readLabel(IStringStream(line.substr(32,8))());
234 label c = readLabel(IStringStream(line.substr(40,8))());
235 label
d = readLabel(IStringStream(line.substr(48,8))());
241 if (iter == groupToPatch.end())
244 groupToPatch.insert(groupId, patchI);
245 Info<<
"patch " << patchI <<
" => group " << groupId <<
endl;
252 faces.append(labelledTri(a, b, c, patchI));
253 faces.append(labelledTri(c, d, a, patchI));
255 else if (cmd ==
"PSHELL")
258 label groupId = readLabel(IStringStream(line.substr(8,8))());
259 if (groupId == ansaId && ansaType ==
"PSHELL")
261 groupToName.insert(groupId, string::validate<word>(ansaName));
262 Info<<
"group " << groupId <<
" => " << ansaName <<
endl;
265 else if (cmd ==
"GRID")
267 label index = readLabel(IStringStream(line.substr(8,8))());
272 indices.append(index);
273 points.append(
point(x, y, z));
275 else if (cmd ==
"GRID*")
283 label index = readLabel(IStringStream(line.substr(8,16))());
291 <<
"Expected continuation symbol '*' when reading GRID*"
292 <<
" (double precision coordinate) output" <<
nl
293 <<
"Read:" << line <<
nl
294 <<
"File:" << is.name()
295 <<
" line:" << is.lineNumber()
300 indices.append(index);
301 points.append(
point(x, y, z));
303 else if (unhandledCmd.insert(cmd))
305 Info<<
"Unhandled Nastran command " << line <<
nl
306 <<
"File:" << is.name() <<
" line:" << is.lineNumber() <<
endl;
315 Info<<
"Read triangles:" << faces.size() <<
" points:" << points.size()
320 Map<label> indexToPoint(2*indices.size());
323 indexToPoint.insert(indices[i], i);
329 labelledTri&
f = faces[i];
331 f[0] = indexToPoint[f[0]];
332 f[1] = indexToPoint[f[1]];
333 f[2] = indexToPoint[f[2]];
343 label patchI = groupToPatch[iter.key()];
345 patches[patchI] = geometricSurfacePatch