initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / triSurface / triSurface / interfaces / TRI / writeTRI.C
blobb36f3ef20ee426e47d9b915ee54409dd726dd292
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
28 #include "IOmanip.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
37 void triSurface::writeTRI(const bool writeSorted, Ostream& os) const
39     const pointField& ps = points();
41     // Write as cloud of triangles
43     labelList faceMap;
45     surfacePatchList myPatches(calcPatches(faceMap));
47     if (writeSorted)
48     {
49         label faceIndex = 0;
51         forAll(myPatches, patchI)
52         {
53             for
54             (
55                 label patchFaceI = 0;
56                 patchFaceI < myPatches[patchI].size();
57                 patchFaceI++
58             )
59             {
60                 const label faceI = faceMap[faceIndex++];
62                 const point& p1 = ps[operator[](faceI)[0]];
63                 const point& p2 = ps[operator[](faceI)[1]];
64                 const point& p3 = ps[operator[](faceI)[2]];
66                 os  << p1.x() << token::SPACE
67                     << p1.y() << token::SPACE
68                     << p1.z() << token::SPACE
70                     << p2.x() << token::SPACE
71                     << p2.y() << token::SPACE
72                     << p2.z() << token::SPACE
74                     << p3.x() << token::SPACE
75                     << p3.y() << token::SPACE
76                     << p3.z() << token::SPACE
78                     << "0x" << hex << operator[](faceI).region() << dec
79                     << endl;
80             }
81         }
82     }
83     else
84     {
85         forAll(*this, faceI)
86         {
87             const point& p1 = ps[operator[](faceI)[0]];
88             const point& p2 = ps[operator[](faceI)[1]];
89             const point& p3 = ps[operator[](faceI)[2]];
91             os  << p1.x() << token::SPACE
92                 << p1.y() << token::SPACE
93                 << p1.z() << token::SPACE
95                 << p2.x() << token::SPACE
96                 << p2.y() << token::SPACE
97                 << p2.z() << token::SPACE
99                 << p3.x() << token::SPACE
100                 << p3.y() << token::SPACE
101                 << p3.z() << token::SPACE
103                 << "0x" << hex << operator[](faceI).region() << dec
104                 << endl;
105         }
106     }
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 } // End namespace Foam
114 // ************************************************************************* //