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;
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
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.