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