writeTRI.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend 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 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. 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 
45 
46  if (writeSorted)
47  {
48  label faceIndex = 0;
49 
50  forAll(myPatches, patchI)
51  {
52  for
53  (
54  label patchFaceI = 0;
55  patchFaceI < myPatches[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 // ************************************************************************* //
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
Foam::PrimitivePatch< labelledTri, List, pointField, point >::points
const Field< point > & points() const
Return reference to global points.
Definition: PrimitivePatchTemplate.H:282
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::dec
IOstream & dec(IOstream &io)
Definition: IOstream.H:558
IOmanip.H
Istream and Ostream manipulators taking arguments.
Foam::Vector::x
const Cmpt & x() const
Definition: VectorI.H:65
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::Vector::z
const Cmpt & z() const
Definition: VectorI.H:77
Foam::hex
IOstream & hex(IOstream &io)
Definition: IOstream.H:564
Foam::triSurface::calcPatches
surfacePatchList calcPatches(labelList &faceMap) const
Sort faces according to region. Returns patch list.
Definition: triSurface.C:501
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::Vector::y
const Cmpt & y() const
Definition: VectorI.H:71
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::triSurface::writeTRI
void writeTRI(const bool writeSorted, Ostream &) const
Write to Ostream in TRI (AC3D) format.
Definition: writeTRI.C:36
Foam::token::SPACE
@ SPACE
Definition: token.H:95