Loading...
Searching...
No Matches
STLtriangle.H
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-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::STLtriangle
29
30Description
31 A triangle representation for STL files.
32
33SourceFiles
34 STLtriangleI.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_STLtriangle_H
39#define Foam_STLtriangle_H
40
41#include <cstdint>
42#include "STLpoint.H"
43#include "Istream.H"
44#include "Ostream.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51// Forward Declarations
52class STLtriangle;
53inline Ostream& operator<<(Ostream& os, const STLtriangle& tri);
55/*---------------------------------------------------------------------------*\
56 Class STLtriangle Declaration
57\*---------------------------------------------------------------------------*/
58
59class STLtriangle
60{
61 // Typedefs
62
63 //- Attribute is 16-bit
64 typedef uint16_t STLattrib;
65
66 // Private data
67 // NB: The order of the members (1 normal, 3 points, 1 attribute) is
68 // essential when reading/writing binary content.
69
70 //- The face normal and the three points defining the triangle.
71 // Some programs may write zero or other junk for the normal.
72 STLpoint normal_, a_, b_, c_;
73
74 //- The attribute information could be for 'color' or solid id, etc
75 STLattrib attrib_;
76
77
78public:
79
80 // Constructors
81
82 //- Default construct
83 STLtriangle() = default;
84
85 //- Construct from components
86 inline STLtriangle
87 (
88 const STLpoint& normal,
89 const STLpoint& p0,
90 const STLpoint& p1,
91 const STLpoint& p2,
92 uint16_t attrib
93 );
94
95 //- Construct from istream (read binary)
96 inline STLtriangle(std::istream& is);
97
98
99 // Member Functions
100
101 // Access
102
103 const STLpoint& normal() const noexcept { return normal_; }
104 const STLpoint& a() const noexcept { return a_; }
105 const STLpoint& b() const noexcept { return b_; }
106 const STLpoint& c() const noexcept { return c_; }
107 uint16_t attrib() const noexcept { return attrib_; }
108
109
110 // Read
112 //- Read from istream (binary)
113 inline void read(std::istream& is);
116 // Write
117
118 //- Write to ostream (binary)
119 inline void write(std::ostream& os) const;
120
121 //- Write to Ostream (ASCII)
122 inline Ostream& print(Ostream& os) const;
123
124
125 //- Write components to Ostream (ASCII)
126 inline static void write
127 (
128 Ostream& os,
129 const vector& norm,
130 const point& p0,
131 const point& p1,
132 const point& p2
133 );
134
135 //- Write components to Ostream (ASCII), calculating the normal
136 inline static void write
137 (
138 Ostream& os,
139 const point& p0,
140 const point& p1,
141 const point& p2
142 );
143
144
145 // Ostream Operator
146
147 //- Print triangle contents
148 friend Ostream& operator<<(Ostream& os, const STLtriangle& tri);
149};
150
151
152// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153
154} // End namespace Foam
155
156// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157
158#include "STLtriangleI.H"
159
160// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161
162#endif
163
164// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A vertex point or facet normal representation for STL files.
Definition STLpoint.H:46
A triangle representation for STL files.
Definition STLtriangle.H:55
const STLpoint & a() const noexcept
const STLpoint & normal() const noexcept
Ostream & print(Ostream &os) const
Write to Ostream (ASCII).
const STLpoint & b() const noexcept
const STLpoint & c() const noexcept
STLtriangle()=default
Default construct.
uint16_t attrib() const noexcept
friend Ostream & operator<<(Ostream &os, const STLtriangle &tri)
Print triangle contents.
void read(std::istream &is)
Read from istream (binary).
const volScalarField & p0
Definition EEqn.H:36
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
Vector< scalar > vector
Definition vector.H:57
runTime write()