32 bool Foam::triSurface::readOBJ(
const fileName& OBJfileName)
34 IFstream OBJfile(OBJfileName);
39 <<
"Cannot read file " << OBJfileName
44 DynamicList<labelledTri>
faces;
45 HashTable<label> groupToPatch;
50 while (OBJfile.good())
52 string line = getLineNoComment(OBJfile);
54 label sz = line.size();
56 if (sz && line[sz-1] ==
'\\')
59 line += getLineNoComment(OBJfile);
63 IStringStream lineStream(line);
71 lineStream >> x >> y >> z;
73 points.append(
point(x, y, z));
82 groupToPatch.find(group);
84 if (findGroup != groupToPatch.end())
86 groupID = findGroup();
92 groupToPatch.insert(group, groupID);
99 DynamicList<label> verts;
107 line.find_first_not_of(
" \r", endNum);
109 if (startNum == string::npos)
114 endNum = line.find(
' ', startNum);
117 if (endNum != string::npos)
119 vertexSpec = line.substr(startNum, endNum-startNum);
123 vertexSpec = line.substr(startNum, line.size() - startNum);
129 if (slashPos != string::npos)
131 IStringStream intStream(vertexSpec.substr(0, slashPos));
137 IStringStream intStream(vertexSpec);
141 verts.append(vertI - 1);
148 for (
label fp = 1; fp < verts.size() - 1; fp++)
150 label fp1 = verts.fcIndex(fp);
152 labelledTri tri(verts[0], verts[fp], verts[fp1], groupID);
169 patches[0] = geometricSurfacePatch(
"empty",
"patch0", 0);
175 patches[iter()] = geometricSurfacePatch
const char *const group
Group name for atomic constants.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< geometricSurfacePatch > geometricSurfacePatchList
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
vectorField pointField
pointField is a vectorField.
friend class const_iterator
Declare friendship with the const_iterator.
const Field< PointType > & points() const
Return reference to global points.
graph_traits< Graph >::vertices_size_type size_type
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void setSize(const label)
Reset size of List.
const geometricSurfacePatchList & patches() const
triSurface()
Construct null.
vector point
Point is a vector.
faceList faces() const
Return the list of triangles as a faceList.