writeTRI.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "triSurface.H"
27 #include "IOmanip.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
35 
36 void triSurface::writeTRI(const bool writeSorted, Ostream& os) const
37 {
38  const pointField& ps = points();
39 
40  // Write as cloud of triangles
41 
43 
44  surfacePatchList patches(calcPatches(faceMap));
45 
46  if (writeSorted)
47  {
48  label faceIndex = 0;
49 
51  {
52  for
53  (
54  label patchFacei = 0;
55  patchFacei < patches[patchi].size();
56  patchFacei++
57  )
58  {
59  const label facei = faceMap[faceIndex++];
60 
61  const point& p1 = ps[operator[](facei)[0]];
62  const point& p2 = ps[operator[](facei)[1]];
63  const point& p3 = ps[operator[](facei)[2]];
64 
65  os << p1.x() << token::SPACE
66  << p1.y() << token::SPACE
67  << p1.z() << token::SPACE
68 
69  << p2.x() << token::SPACE
70  << p2.y() << token::SPACE
71  << p2.z() << token::SPACE
72 
73  << p3.x() << token::SPACE
74  << p3.y() << token::SPACE
75  << p3.z() << token::SPACE
76 
77  << "0x" << hex << operator[](facei).region() << dec
78  << endl;
79  }
80  }
81  }
82  else
83  {
84  forAll(*this, facei)
85  {
86  const point& p1 = ps[operator[](facei)[0]];
87  const point& p2 = ps[operator[](facei)[1]];
88  const point& p3 = ps[operator[](facei)[2]];
89 
90  os << p1.x() << token::SPACE
91  << p1.y() << token::SPACE
92  << p1.z() << token::SPACE
93 
94  << p2.x() << token::SPACE
95  << p2.y() << token::SPACE
96  << p2.z() << token::SPACE
97 
98  << p3.x() << token::SPACE
99  << p3.y() << token::SPACE
100  << p3.z() << token::SPACE
101 
102  << "0x" << hex << operator[](facei).region() << dec
103  << endl;
104  }
105  }
106 }
107 
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 } // End namespace Foam
112 
113 // ************************************************************************* //
Istream and Ostream manipulators taking arguments.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
const Field< PointType > & points() const
Return reference to global points.
T & operator[](const label)
Return element of UList.
Definition: UListI.H:167
const Cmpt & x() const
Definition: VectorI.H:75
const geometricSurfacePatchList & patches() const
Definition: triSurface.H:322
label patchi
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: labelList.H:56
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
IOstream & dec(IOstream &io)
Definition: IOstream.H:555
IOstream & hex(IOstream &io)
Definition: IOstream.H:561
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
vector point
Point is a vector.
Definition: point.H:41
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< surfacePatch > surfacePatchList