STLtriangleI.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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
29 {}
30 
31 
33 (
34  const STLpoint& normal,
35  const STLpoint& a,
36  const STLpoint& b,
37  const STLpoint& c,
38  unsigned short attrib
39 )
40 :
41  normal_(normal),
42  a_(a),
43  b_(b),
44  c_(c),
45  attrib_(attrib)
46 {}
47 
48 
49 inline Foam::STLtriangle::STLtriangle(istream& is)
50 {
51  read(is);
52 }
53 
54 
55 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
56 
58 {
59  return normal_;
60 }
61 
62 
63 inline const Foam::STLpoint& Foam::STLtriangle::a() const
64 {
65  return a_;
66 }
67 
68 
69 inline const Foam::STLpoint& Foam::STLtriangle::b() const
70 {
71  return b_;
72 }
73 
74 
75 inline const Foam::STLpoint& Foam::STLtriangle::c() const
76 {
77  return c_;
78 }
79 
80 
81 inline unsigned short Foam::STLtriangle::attrib() const
82 {
83  return attrib_;
84 }
85 
86 
87 inline void Foam::STLtriangle::read(istream& is)
88 {
89  is.read(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
90  is.read(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
91 }
92 
93 
94 inline void Foam::STLtriangle::write(ostream& os)
95 {
96  os.write(reinterpret_cast<char*>(this), 4*sizeof(STLpoint));
97  os.write(reinterpret_cast<char*>(&attrib_), sizeof(STLattrib));
98 }
99 
100 
101 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
102 
104 {
105  os << t.normal_ << token::SPACE
106  << t.a_ << token::SPACE
107  << t.b_ << token::SPACE
108  << t.c_ << token::SPACE
109  << t.attrib_;
110 
111  return os;
112 }
113 
114 
115 // ************************************************************************* //
const STLpoint & c() const
Definition: STLtriangleI.H:75
STLtriangle()
Construct null.
Definition: STLtriangleI.H:28
unsigned short attrib() const
Definition: STLtriangleI.H:81
const STLpoint & a() const
Definition: STLtriangleI.H:63
A triangle representation for STL files.
Definition: STLtriangle.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void write(ostream &)
Write to ostream (binary)
Definition: STLtriangleI.H:94
Ostream & operator<<(Ostream &, const ensightPart &)
const STLpoint & b() const
Definition: STLtriangleI.H:69
const STLpoint & normal() const
Definition: STLtriangleI.H:57
void read(istream &)
Read from istream (binary)
Definition: STLtriangleI.H:87
A vertex point representation for STL files.
Definition: STLpoint.H:48