1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "triSurface.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 void triSurface::writeVTK(const bool writeSorted, Ostream& os) const
39 os << "# vtk DataFile Version 2.0" << nl
45 const pointField& ps = points();
47 os << "POINTS " << ps.size() << " float" << nl;
49 // Write vertex coords
52 if (pointi > 0 && (pointi % 10) == 0)
60 os << ps[pointi].x() << ' '
61 << ps[pointi].y() << ' '
66 os << "POLYGONS " << size() << ' ' << 4*size() << nl;
69 surfacePatchList myPatches(calcPatches(faceMap));
75 forAll(myPatches, patchI)
77 // Print all faces belonging to this patch
82 patchFaceI < myPatches[patchI].size();
86 if (faceIndex > 0 && (faceIndex % 10) == 0)
95 const label faceI = faceMap[faceIndex++];
98 << operator[](faceI)[0] << ' '
99 << operator[](faceI)[1] << ' '
100 << operator[](faceI)[2];
106 // Print region numbers
108 os << "CELL_DATA " << size() << nl;
109 os << "FIELD attributes 1" << nl;
110 os << "region 1 " << size() << " float" << nl;
114 forAll(myPatches, patchI)
118 label patchFaceI = 0;
119 patchFaceI < myPatches[patchI].size();
123 if (faceIndex > 0 && (faceIndex % 10) == 0)
132 const label faceI = faceMap[faceIndex++];
134 os << operator[](faceI).region();
143 if (faceI > 0 && (faceI % 10) == 0)
152 << operator[](faceI)[0] << ' '
153 << operator[](faceI)[1] << ' '
154 << operator[](faceI)[2];
158 os << "CELL_DATA " << size() << nl;
159 os << "FIELD attributes 1" << nl;
160 os << "region 1 " << size() << " float" << nl;
164 if (faceI > 0 && (faceI % 10) == 0)
172 os << operator[](faceI).region();
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // ************************************************************************* //