44 string getLine(std::ifstream& is)
49 std::getline(is,
line);
51 while (
line.size() &&
line[0] ==
'#');
69 if (startNum == string::npos)
74 endNum =
line.find(
' ', startNum);
77 if (endNum != string::npos)
79 vertexSpec =
line.substr(startNum, endNum-startNum);
83 vertexSpec =
line.substr(startNum,
line.size() - startNum);
89 if (slashPos != string::npos)
110 int main(
int argc,
char *argv[])
121 std::ifstream OBJfile(objName.c_str());
135 bool hasWarned =
false;
138 while (OBJfile.good())
140 string line = getLine(OBJfile);
152 lineStream >>
x >>
y >> z;
156 else if (cmd ==
"vn")
160 lineStream >>
x >>
y >> z;
179 <<
"Unrecognised OBJ command " << cmd <<
nl
180 <<
"In line " << lineStream.str()
181 <<
" at linenumber " << lineNo <<
nl
182 <<
"Only recognised commands are 'v' and 'l'.\n"
183 <<
"If this is a surface command use surfaceConvert instead"
184 <<
" to convert to a file format that can be read by VTK"
199 <<
"# vtk DataFile Version 2.0\n"
202 <<
"DATASET POLYDATA\n"
209 outFile << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
nl;
217 outFile << 1 <<
' ' << i <<
nl;
223 nItems += polyLines[polyI].
size() + 1;
227 <<
"LINES " << polyLines.
size() <<
' ' << nItems <<
nl;
233 outFile <<
line.size();
237 outFile <<
' ' <<
line[i];
246 nItems += polygons[polyI].
size() + 1;
250 <<
"POLYGONS " << polygons.
size() <<
' ' << nItems <<
nl;
256 outFile <<
line.size();
260 outFile <<
' ' <<
line[i];
268 <<
"SCALARS pointID float 1\n"
269 <<
"LOOKUP_TABLE default\n";
285 if (!pointNormals.
empty())
287 outFile <<
nl <<
"NORMALS pointNormals float\n";
291 const vector&
n = pointNormals[i];
293 outFile <<
n.x() <<
' ' <<
n.y() <<
' ' <<
n.z() <<
nl;
graph_traits< Graph >::vertices_size_type size_type
#define forAll(list, i)
Loop across all elements in list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Input from memory buffer stream.
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
Extract command arguments and options from the supplied argc and argv parameters.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
A class for handling file names.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
#define WarningInFunction
Report a warning using Foam::Warning.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
Vector< scalar > vector
A scalar version of the templated Vector.
Foam::argList args(argc, argv)