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 const string line = getLineNoComment(OBJfile);
55 IStringStream lineStream(line);
63 lineStream >>
x >>
y >> z;
74 groupToPatch.find(
group);
76 if (findGroup != groupToPatch.end())
78 groupID = findGroup();
84 groupToPatch.insert(
group, groupID);
91 DynamicList<label> verts;
99 line.find_first_not_of(
" \r", endNum);
101 if (startNum == string::npos)
106 endNum = line.find(
' ', startNum);
109 if (endNum != string::npos)
111 vertexSpec = line.substr(startNum, endNum-startNum);
115 vertexSpec = line.substr(startNum, line.size() - startNum);
121 if (slashPos != string::npos)
123 IStringStream intStream(vertexSpec.substr(0, slashPos));
129 IStringStream intStream(vertexSpec);
133 verts.append(vertI - 1);
140 for (
label fp = 1; fp < verts.size() - 1; fp++)
142 label fp1 = verts.fcIndex(fp);
144 labelledTri tri(verts[0], verts[fp], verts[fp1], groupID);
161 patches[0] = geometricSurfacePatch(
"empty",
"patch0", 0);
167 patches[iter()] = geometricSurfacePatch
graph_traits< Graph >::vertices_size_type size_type
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
friend class const_iterator
Declare friendship with the const_iterator.
void append(const T &)
Append an element at the end of the list.
void setSize(const label)
Reset size of List.
const Field< PointType > & points() const
Return reference to global points.
triSurface()
Construct null.
const geometricSurfacePatchList & patches() const
faceList faces() const
Return the list of triangles as a faceList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const char *const group
Group name for atomic constants.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List< geometricSurfacePatch > geometricSurfacePatchList
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.