Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <triSurface/triSurface.H>
00032
00033
00034
00035 namespace Foam
00036 {
00037
00038
00039
00040 void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
00041 {
00042
00043 os << "# Wavefront OBJ file" << endl
00044 << "# Regions:" << endl;
00045
00046 labelList faceMap;
00047
00048 surfacePatchList myPatches(calcPatches(faceMap));
00049
00050 const pointField& ps = points();
00051
00052
00053 forAll(myPatches, patchI)
00054 {
00055 os << "# " << patchI << " "
00056 << myPatches[patchI].name() << endl;
00057 }
00058 os << "#" << endl;
00059
00060 os << "# points : " << ps.size() << endl
00061 << "# triangles : " << size() << endl
00062 << "#" << endl;
00063
00064
00065
00066 forAll(ps, pointi)
00067 {
00068 os << "v "
00069 << ps[pointi].x() << ' '
00070 << ps[pointi].y() << ' '
00071 << ps[pointi].z() << endl;
00072 }
00073
00074 if (writeSorted)
00075 {
00076 label faceIndex = 0;
00077
00078 forAll(myPatches, patchI)
00079 {
00080
00081
00082 os << "g " << myPatches[patchI].name() << endl;
00083
00084 for
00085 (
00086 label patchFaceI = 0;
00087 patchFaceI < myPatches[patchI].size();
00088 patchFaceI++
00089 )
00090 {
00091 const label faceI = faceMap[faceIndex++];
00092
00093 os << "f "
00094 << operator[](faceI)[0] + 1 << ' '
00095 << operator[](faceI)[1] + 1 << ' '
00096 << operator[](faceI)[2] + 1
00097
00098 << endl;
00099 }
00100 }
00101 }
00102 else
00103 {
00104 forAll(*this, faceI)
00105 {
00106 os << "f "
00107 << operator[](faceI)[0] + 1 << ' '
00108 << operator[](faceI)[1] + 1 << ' '
00109 << operator[](faceI)[2] + 1
00110
00111 << endl;
00112 }
00113 }
00114 }
00115
00116
00117
00118
00119 }
00120
00121