| 33 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // |
| 34 | |
| 35 | void triSurface::writeVTK(const bool writeSorted, Ostream& os) const |
| 36 | { |
| 37 | // Write header |
| 38 | os << "# vtk DataFile Version 2.0" << nl |
| 39 | << "triSurface" << nl |
| 40 | << "ASCII" << nl |
| 41 | << "DATASET POLYDATA" |
| 42 | << nl; |
| 43 | |
| 44 | const pointField& ps = points(); |
| 45 | |
| 46 | os << "POINTS " << ps.size() << " float" << nl; |
| 47 | |
| 48 | // Write vertex coords |
| 49 | forAll(ps, pointi) |
| 50 | { |
| 51 | if (pointi > 0 && (pointi % 10) == 0) |
| 52 | { |
| 53 | os << nl; |
| 54 | } |
| 55 | else |
| 56 | { |
| 57 | os << ' '; |
| 58 | } |
| 59 | os << ps[pointi].x() << ' ' |
| 60 | << ps[pointi].y() << ' ' |
| 61 | << ps[pointi].z(); |
| 62 | } |
| 63 | os << nl; |
| 64 | |
| 65 | os << "POLYGONS " << size() << ' ' << 4*size() << nl; |
| 66 | |
| 67 | labelList faceMap; |
| 68 | surfacePatchList patches(calcPatches(faceMap)); |
| 69 | |
| 70 | if (writeSorted) |
| 71 | { |
| 72 | label faceIndex = 0; |
| 73 | |
| 74 | forAll(patches, patchi) |
| 75 | { |
| 76 | // Print all faces belonging to this patch |
| 77 | |
| 78 | for |
| 79 | ( |
| 80 | label patchFacei = 0; |
| 81 | patchFacei < patches[patchi].size(); |
| 82 | patchFacei++ |
| 83 | ) |
| 84 | { |
| 85 | if (faceIndex > 0 && (faceIndex % 10) == 0) |
| 86 | { |
| 87 | os << nl; |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | os << ' '; |
| 92 | } |