Go to the documentation of this file.
46 string getLine(std::ifstream& is)
51 std::getline(is,
line);
53 while (
line.size() &&
line[0] ==
'#');
71 if (startNum == string::npos)
76 endNum =
line.find(
' ', startNum);
79 if (endNum != string::npos)
81 vertexSpec =
line.substr(startNum, endNum-startNum);
85 vertexSpec =
line.substr(startNum,
line.size() - startNum);
91 if (slashPos != string::npos)
112 int main(
int argc,
char *argv[])
122 std::ifstream OBJfile(objName.c_str());
136 bool hasWarned =
false;
139 while (OBJfile.good())
141 string line = getLine(OBJfile);
153 lineStream >>
x >>
y >> z;
157 else if (cmd ==
"vn")
161 lineStream >>
x >>
y >> z;
180 <<
"Unrecognized OBJ command " << cmd <<
nl
181 <<
"In line " << lineStream.str()
182 <<
" at linenumber " << lineNo <<
nl
183 <<
"Only recognized commands are 'v' and 'l'.\n"
184 <<
"If this is a surface command use surfaceConvert instead"
185 <<
" to convert to a file format that can be read by VTK"
200 <<
"# vtk DataFile Version 2.0\n"
203 <<
"DATASET POLYDATA\n"
204 <<
"POINTS " <<
points.size() <<
" float\n";
210 outFile << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
nl;
214 <<
"VERTICES " <<
points.size() <<
' ' << (2 *
points.size()) <<
nl;
218 outFile << 1 <<
' ' << i <<
nl;
224 nItems += polyLines[polyI].size() + 1;
228 <<
"LINES " << polyLines.size() <<
' ' << nItems <<
nl;
234 outFile <<
line.size();
238 outFile <<
' ' <<
line[i];
247 nItems += polygons[polyI].size() + 1;
251 <<
"POLYGONS " << polygons.size() <<
' ' << nItems <<
nl;
257 outFile <<
line.size();
261 outFile <<
' ' <<
line[i];
268 <<
"POINT_DATA " <<
points.size() <<
nl
269 <<
"SCALARS pointID float 1\n"
270 <<
"LOOKUP_TABLE default\n";
286 if (!pointNormals.empty())
288 outFile <<
nl <<
"NORMALS pointNormals float\n";
292 const vector&
n = pointNormals[i];
294 outFile <<
n.x() <<
' ' <<
n.y() <<
' ' <<
n.z() <<
nl;
static SLList< string > validArgs
A list of valid (mandatory) arguments.
A class for handling words, derived from string.
A class for handling file names.
#define forAll(list, i)
Loop across all elements in list.
Extract command arguments and options from the supplied argc and argv parameters.
Ostream & endl(Ostream &os)
Add newline and flush stream.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
int main(int argc, char *argv[])
graph_traits< Graph >::vertices_size_type size_type
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Input from memory buffer stream.
Vector< scalar > vector
A scalar version of the templated Vector.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
vector point
Point is a vector.
static void noParallel()
Remove the parallel options.
Foam::argList args(argc, argv)
#define WarningInFunction
Report a warning using Foam::Warning.