labelledTriI.H
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 "IOstreams.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  region_(-1)
33 {}
34 
35 
37 (
38  const triFace& tri,
39  const label region
40 )
41 :
42  triFace(tri),
43  region_(region)
44 {}
45 
46 
48 (
49  const label a,
50  const label b,
51  const label c,
52  const label region
53 )
54 :
55  triFace(a, b, c),
56  region_(region)
57 {}
58 
59 
61 {
62  operator>>(is, *this);
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
69 {
70  return region_;
71 }
72 
74 {
75  return region_;
76 }
77 
78 
79 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
80 
82 {
83  if (is.format() == IOstream::ASCII)
84  {
85  // Read beginning of labelledTri point pair
86  is.readBegin("labelledTri");
87 
88  is >> static_cast<triFace&>(t) >> t.region_;
89 
90  // Read end of labelledTri point pair
91  is.readEnd("labelledTri");
92  }
93  else
94  {
95  is.read(reinterpret_cast<char*>(&t), sizeof(labelledTri));
96  }
97 
98  // Check state of Ostream
99  is.check("Istream& operator>>(Istream&, labelledTri&)");
100 
101  return is;
102 }
103 
104 
106 {
107  if (os.format() == IOstream::ASCII)
108  {
109  os << token::BEGIN_LIST
110  << static_cast<const triFace&>(t) << token::SPACE << t.region_
111  << token::END_LIST;
112  }
113  else
114  {
115  os.write
116  (
117  reinterpret_cast<const char*>(&t),
118  sizeof(labelledTri)
119  );
120  }
121 
122  // Check state of Ostream
123  os.check("Ostream& operator<<(Ostream&, const labelledTri&)");
124 
125 
126  return os;
127 }
128 
129 
130 // ************************************************************************* //
Istream & readBegin(const char *funcName)
Definition: Istream.C:86
virtual Ostream & write(const char)=0
Write character.
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
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
labelledTri()
Construct null.
Definition: labelledTriI.H:30
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Istream & readEnd(const char *funcName)
Definition: Istream.C:103
label region() const
Return region label.
Definition: labelledTriI.H:68
virtual Istream & read(token &)=0
Return next token from stream.
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:68
Istream & operator>>(Istream &, directionInfo &)
friend Istream & operator>>(Istream &, labelledTri &)
Triangle with additional region number.
Definition: labelledTri.H:57
streamFormat format() const
Return current stream format.
Definition: IOstream.H:374
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
triFace()
Construct null.
Definition: triFaceI.H:64
Ostream & operator<<(Ostream &, const ensightPart &)