| 33 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // |
| 34 | |
| 35 | void triSurface::writeOFF(const bool writeSorted, Ostream& os) const |
| 36 | { |
| 37 | // Write header |
| 38 | os << "OFF" << endl |
| 39 | << "# Geomview OFF file" << endl |
| 40 | << "# Regions:" << endl; |
| 41 | |
| 42 | labelList faceMap; |
| 43 | surfacePatchList patches(calcPatches(faceMap)); |
| 44 | |
| 45 | // Print patch names as comment |
| 46 | forAll(patches, patchi) |
| 47 | { |
| 48 | os << "# " << patchi << " " |
| 49 | << patches[patchi].name() << endl; |
| 50 | } |
| 51 | os << nl << endl; |
| 52 | |
| 53 | const pointField& ps = points(); |
| 54 | |
| 55 | os << "# nPoints nTriangles nEdges" << endl |
| 56 | << ps.size() |
| 57 | << ' ' << size() |
| 58 | << ' ' << nEdges() |
| 59 | << nl << endl; |
| 60 | |
| 61 | // Write vertex coords |
| 62 | forAll(ps, pointi) |
| 63 | { |
| 64 | os << ps[pointi].x() << ' ' |
| 65 | << ps[pointi].y() << ' ' |
| 66 | << ps[pointi].z() << " #" << pointi << endl; |
| 67 | } |
| 68 | |
| 69 | os << endl; |
| 70 | |
| 71 | if (writeSorted) |
| 72 | { |
| 73 | label faceIndex = 0; |
| 74 | |
| 75 | forAll(patches, patchi) |
| 76 | { |
| 77 | // Print all faces belonging to this patch |
| 78 | |
| 79 | for |
| 80 | ( |
| 81 | label patchFacei = 0; |
| 82 | patchFacei < patches[patchi].size(); |
| 83 | patchFacei++ |
| 84 | ) |
| 85 | { |
| 86 | const label facei = faceMap[faceIndex++]; |
| 87 | |
| 88 | os << "3 " |
| 89 | << operator[](facei)[0] << ' ' |
| 90 | << operator[](facei)[1] << ' ' |
| 91 | << operator[](facei)[2] << ' ' |
| 92 | << operator[](facei).region() |