| 33 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // |
| 34 | |
| 35 | void triSurface::writeGTS(const bool writeSorted, Ostream& os) const |
| 36 | { |
| 37 | // Write header |
| 38 | os << "# GTS file" << endl |
| 39 | << "# Regions:" << endl; |
| 40 | |
| 41 | labelList faceMap; |
| 42 | |
| 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 << "#" << endl; |
| 52 | |
| 53 | |
| 54 | const pointField& ps = points(); |
| 55 | |
| 56 | os << "# nPoints nEdges nTriangles" << endl |
| 57 | << ps.size() << ' ' << nEdges() << ' ' << size() << endl; |
| 58 | |
| 59 | // Write vertex coords |
| 60 | |
| 61 | forAll(ps, pointi) |
| 62 | { |
| 63 | os << ps[pointi].x() << ' ' |
| 64 | << ps[pointi].y() << ' ' |
| 65 | << ps[pointi].z() << endl; |
| 66 | } |
| 67 | |
| 68 | // Write edges. |
| 69 | // Note: edges are in local point labels so convert |
| 70 | const edgeList& es = edges(); |
| 71 | const labelList& meshPts = meshPoints(); |
| 72 | |
| 73 | forAll(es, edgei) |
| 74 | { |
| 75 | os << meshPts[es[edgei].start()] + 1 << ' ' |
| 76 | << meshPts[es[edgei].end()] + 1 << endl; |
| 77 | } |
| 78 | |
| 79 | // Write faces in terms of edges. |
| 80 | const labelListList& faceEs = faceEdges(); |
| 81 | |
| 82 | if (writeSorted) |
| 83 | { |
| 84 | label faceIndex = 0; |
| 85 | forAll(patches, patchi) |
| 86 | { |
| 87 | for |
| 88 | ( |
| 89 | label patchFacei = 0; |
| 90 | patchFacei < patches[patchi].size(); |
| 91 | patchFacei++ |
| 92 | ) |