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::writeGTS(const bool writeSorted, Ostream& os) const
39 os << "# GTS file" << endl
40 << "# Regions:" << endl;
44 surfacePatchList myPatches(calcPatches(faceMap));
46 // Print patch names as comment
47 forAll(myPatches, patchI)
49 os << "# " << patchI << " "
50 << myPatches[patchI].name() << endl;
55 const pointField& ps = points();
57 os << "# nPoints nEdges nTriangles" << endl
58 << ps.size() << ' ' << nEdges() << ' ' << size() << endl;
60 // Write vertex coords
64 os << ps[pointi].x() << ' '
65 << ps[pointi].y() << ' '
66 << ps[pointi].z() << endl;
70 // Note: edges are in local point labels so convert
71 const edgeList& es = edges();
72 const labelList& meshPts = meshPoints();
76 os << meshPts[es[edgei].start()] + 1 << ' '
77 << meshPts[es[edgei].end()] + 1 << endl;
80 // Write faces in terms of edges.
81 const labelListList& faceEs = faceEdges();
86 forAll(myPatches, patchI)
91 patchFaceI < myPatches[patchI].size();
95 const label faceI = faceMap[faceIndex++];
97 const labelList& fEdges = faceEdges()[faceI];
99 os << fEdges[0] + 1 << ' '
100 << fEdges[1] + 1 << ' '
101 << fEdges[2] + 1 << ' '
102 << (*this)[faceI].region() << endl;
108 forAll(faceEs, faceI)
110 const labelList& fEdges = faceEdges()[faceI];
112 os << fEdges[0] + 1 << ' '
113 << fEdges[1] + 1 << ' '
114 << fEdges[2] + 1 << ' '
115 << (*this)[faceI].region() << endl;
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 } // End namespace Foam
125 // ************************************************************************* //