| 32 | // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // |
| 33 | |
| 34 | void Foam::triSurface::writeSTLASCII(const bool writeSorted, Ostream& os) const |
| 35 | { |
| 36 | labelList faceMap; |
| 37 | |
| 38 | surfacePatchList patches(calcPatches(faceMap)); |
| 39 | |
| 40 | if (writeSorted) |
| 41 | { |
| 42 | label faceIndex = 0; |
| 43 | forAll(patches, patchi) |
| 44 | { |
| 45 | // Print all faces belonging to this region |
| 46 | const surfacePatch& patch = patches[patchi]; |
| 47 | |
| 48 | os << "solid " << patch.name() << endl; |
| 49 | |
| 50 | for |
| 51 | ( |
| 52 | label patchFacei = 0; |
| 53 | patchFacei < patch.size(); |
| 54 | patchFacei++ |
| 55 | ) |
| 56 | { |
| 57 | const label facei = faceMap[faceIndex++]; |
| 58 | |
| 59 | const vector& n = faceNormals()[facei]; |
| 60 | |
| 61 | os << " facet normal " |
| 62 | << n.x() << ' ' << n.y() << ' ' << n.z() << nl |
| 63 | << " outer loop" << endl; |
| 64 | |
| 65 | const labelledTri& f = (*this)[facei]; |
| 66 | const point& pa = points()[f[0]]; |
| 67 | const point& pb = points()[f[1]]; |
| 68 | const point& pc = points()[f[2]]; |
| 69 | |
| 70 | os << " vertex " |
| 71 | << pa.x() << ' ' << pa.y() << ' ' << pa.z() << nl |
| 72 | << " vertex " |
| 73 | << pb.x() << ' ' << pb.y() << ' ' << pb.z() << nl |
| 74 | << " vertex " |
| 75 | << pc.x() << ' ' << pc.y() << ' ' << pc.z() << nl |
| 76 | << " endloop" << nl |
| 77 | << " endfacet" << endl; |
| 78 | } |
| 79 | |
| 80 | os << "endsolid " << patch.name() << endl; |
| 81 | } |
| 82 | } |
| 83 | else |
| 84 | { |
| 85 | // Get patch (=compact region) per face |
| 86 | labelList patchIDs(size()); |
| 87 | forAll(patches, patchi) |
| 88 | { |
| 89 | label facei = patches[patchi].start(); |
| 90 | |
| 91 | forAll(patches[patchi], i) |