output g command even if not sorted

This commit is contained in:
mattijs
2009-08-11 23:08:26 +01:00
parent 6b691f1776
commit 23c6c069c0

View File

@ -41,8 +41,8 @@ namespace Foam
void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
{
// Write header
os << "# Wavefront OBJ file" << endl
<< "# Regions:" << endl;
os << "# Wavefront OBJ file" << nl
<< "# Regions:" << nl;
labelList faceMap;
@ -54,13 +54,13 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
forAll(myPatches, patchI)
{
os << "# " << patchI << " "
<< myPatches[patchI].name() << endl;
<< myPatches[patchI].name() << nl;
}
os << "#" << endl;
os << "#" << nl;
os << "# points : " << ps.size() << endl
<< "# triangles : " << size() << endl
<< "#" << endl;
os << "# points : " << ps.size() << nl
<< "# triangles : " << size() << nl
<< "#" << nl;
// Write vertex coords
@ -69,7 +69,7 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
os << "v "
<< ps[pointi].x() << ' '
<< ps[pointi].y() << ' '
<< ps[pointi].z() << endl;
<< ps[pointi].z() << nl;
}
if (writeSorted)
@ -80,7 +80,7 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
{
// Print all faces belonging to this patch
os << "g " << myPatches[patchI].name() << endl;
os << "g " << myPatches[patchI].name() << nl;
for
(
@ -96,20 +96,39 @@ void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
<< operator[](faceI)[1] + 1 << ' '
<< operator[](faceI)[2] + 1
//<< " # " << operator[](faceI).region()
<< endl;
<< nl;
}
}
}
else
{
// Get patch (=compact region) per face
labelList patchIDs(size());
forAll(myPatches, patchI)
{
label faceI = myPatches[patchI].start();
forAll(myPatches[patchI], i)
{
patchIDs[faceMap[faceI++]] = patchI;
}
}
label prevPatchI = -1;
forAll(*this, faceI)
{
if (prevPatchI != patchIDs[faceI])
{
prevPatchI = patchIDs[faceI];
os << "g " << myPatches[patchIDs[faceI]].name() << nl;
}
os << "f "
<< operator[](faceI)[0] + 1 << ' '
<< operator[](faceI)[1] + 1 << ' '
<< operator[](faceI)[2] + 1
//<< " # " << operator[](faceI).region()
<< endl;
<< nl;
}
}
}