MeshedSurfaceIO.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9  Copyright (C) 2016-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "MeshedSurface.H"
30 #include "boundBox.H"
31 #include "faceTraits.H"
32 #include "Istream.H"
33 #include "Ostream.H"
34 
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 
37 template<class Face>
39 {
40  is >> this->storedZones()
41  >> this->storedPoints()
42  >> this->storedFaces();
43 
44  is.check(FUNCTION_NAME);
45  return is;
46 }
47 
48 
49 template<class Face>
51 {
52  os << this->surfZones()
53  << this->points()
54  << this->surfFaces();
55 
56  os.check(FUNCTION_NAME);
57  return os;
58 }
59 
60 
61 template<class Face>
63 {
64  os << "points : " << this->points().size() << nl;
66  {
67  os << "triangles : " << this->size() << nl;
68  }
69  else
70  {
71  label nTri = 0, nQuad = 0;
72  for (const Face& f : *this)
73  {
74  const label n = f.size();
75 
76  if (n == 3)
77  {
78  ++nTri;
79  }
80  else if (n == 4)
81  {
82  ++nQuad;
83  }
84  }
85 
86  os << "faces : " << this->size()
87  << " (tri:" << nTri << " quad:" << nQuad
88  << " poly:" << (this->size() - nTri - nQuad) << ")" << nl;
89  }
90 
91  os << "boundingBox : " << boundBox(this->points()) << endl;
92 }
93 
94 
95 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
96 
97 template<class Face>
99 {
100  return surf.read(is);
101 }
102 
103 
104 template<class Face>
105 Foam::Ostream& Foam::operator<<(Ostream& os, const MeshedSurface<Face>& surf)
106 {
107  return surf.write(os);
108 }
109 
110 
111 // ************************************************************************* //
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::MeshedSurface::writeStats
void writeStats(Ostream &os) const
Definition: MeshedSurfaceIO.C:62
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::faceTraits
Traits class for faces.
Definition: faceTraits.H:50
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Istream.H
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Ostream.H
boundBox.H
Foam::nl
constexpr char nl
Definition: Ostream.H:404
f
labelList f(nPoints)
points
const pointField & points
Definition: gmvOutputHeader.H:1
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::MeshedSurface
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: triSurfaceTools.H:80
faceTraits.H
MeshedSurface.H