| 141 | |
| 142 | |
| 143 | void Foam::triSurface::writeSTLBINARY(std::ostream& os) const |
| 144 | { |
| 145 | // Write the STL header |
| 146 | string header("Foam binary STL", STLheaderSize); |
| 147 | os.write(header.c_str(), STLheaderSize); |
| 148 | |
| 149 | label nTris = size(); |
| 150 | os.write(reinterpret_cast<char*>(&nTris), sizeof(unsigned int)); |
| 151 | |
| 152 | const vectorField& normals = faceNormals(); |
| 153 | |
| 154 | forAll(*this, facei) |
| 155 | { |
| 156 | const labelledTri& f = (*this)[facei]; |
| 157 | |
| 158 | // Convert vector into STL single precision |
| 159 | STLpoint n(normals[facei]); |
| 160 | STLpoint pa(points()[f[0]]); |
| 161 | STLpoint pb(points()[f[1]]); |
| 162 | STLpoint pc(points()[f[2]]); |
| 163 | |
| 164 | STLtriangle stlTri(n, pa, pb, pc, f.region()); |
| 165 | |
| 166 | stlTri.write(os); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | |
| 171 | // ************************************************************************* // |