OpenFOAM: API Guide
v1912
The open source CFD toolbox
faceTriangulation.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 OpenFOAM Foundation
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
Class
27
Foam::faceTriangulation
28
29
Description
30
Triangulation of faces. Handles concave polygons as well
31
(inefficiently)
32
33
Works by trying to subdivide the face at the vertex with 'flattest'
34
internal angle (i.e. closest to 180 deg).
35
36
Based on routine 'Diagonal' in
37
\verbatim
38
"Efficient Triangulation of Simple Polygons"
39
Godfried Toussaint, McGill University.
40
\endverbatim
41
42
After construction is the list of triangles the face is decomposed into.
43
(Or empty list if no valid triangulation could be found).
44
45
46
SourceFiles
47
faceTriangulation.C
48
49
\*---------------------------------------------------------------------------*/
50
51
#ifndef faceTriangulation_H
52
#define faceTriangulation_H
53
54
#include "
triFaceList.H
"
55
#include "
pointField.H
"
56
57
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59
namespace
Foam
60
{
61
62
// Forward declaration of classes
63
64
/*---------------------------------------------------------------------------*\
65
Class faceTriangulation Declaration
66
\*---------------------------------------------------------------------------*/
67
68
class
faceTriangulation
69
:
70
public
triFaceList
71
{
72
// Static Data
73
74
//- Relative tolerance on edge.
75
static
const
scalar edgeRelTol;
76
77
78
// Static Member Functions
79
80
//- Edge to the right of face vertex i
81
static
label
right(
const
label
size,
label
i);
82
83
//- Edge to the left of face vertex i
84
static
label
left(
const
label
size,
label
i);
85
86
//- Calculate normalized edge vectors
87
static
tmp<vectorField>
calcEdges(
const
face
&,
const
pointField
&);
88
89
//- Calculates half angle components of angle from e0 to e1
90
// in plane given by normal.
91
static
void
calcHalfAngle
92
(
93
const
vector
& normal,
94
const
vector
& e0,
95
const
vector
& e1,
96
scalar& cosHalfAngle,
97
scalar& sinHalfAngle
98
);
99
100
//- Calculate intersection point between edge p1-p2 and ray (in 2D).
101
// Return true and intersection point if intersection between p1 and p2.
102
static
pointHit
rayEdgeIntersect
103
(
104
const
vector
& normal,
105
const
point
& rayOrigin,
106
const
vector
& rayDir,
107
const
point
& p1,
108
const
point
& p2,
109
scalar& posOnEdge
110
);
111
112
// Return true if triangle given its three points
113
// (anticlockwise ordered) contains point
114
static
bool
triangleContainsPoint
115
(
116
const
vector
&
n
,
117
const
point
&
p0
,
118
const
point
& p1,
119
const
point
& p2,
120
const
point
& pt
121
);
122
123
//- Starting from startIndex find diagonal. Return in index1, index2.
124
// Index1 always startIndex except when convex polygon
125
static
void
findDiagonal
126
(
127
const
pointField
&
points
,
128
const
face
&
f
,
129
const
vectorField
& edges,
130
const
vector
& normal,
131
const
label
startIndex,
132
label
& index1,
133
label
& index2
134
);
135
136
//- Find label of vertex to start splitting from. This will be the
137
// vertex with edge angle:
138
// 1] flattest concave angle
139
// 2] flattest convex angle if no concave angles.
140
static
label
findStart
141
(
142
const
face
&
f
,
143
const
vectorField
& edges,
144
const
vector
& normal
145
);
146
147
148
// Private Member Functions
149
150
//- Split face f into triangles. Handles all simple (convex & concave)
151
// polygons. Returns false if could not produce valid split.
152
bool
split
153
(
154
const
bool
fallBack,
155
const
pointField
&
points
,
156
const
face
&
f
,
157
const
vector
& normal,
158
label
& triI
159
);
160
161
public
:
162
163
// Constructors
164
165
//- Construct null
166
faceTriangulation
();
167
168
//- Construct from face and points. Decomposition based on average
169
// normal. After construction *this is size 0 or holds the triangles.
170
// If fallBack and triangulation fails does naive triangulation
171
// and never returns 0 size.
172
faceTriangulation
173
(
174
const
pointField
&
points
,
175
const
face
&
f
,
176
const
bool
fallBack =
false
177
);
178
179
//- Construct from face and points and user supplied (unit) normal.
180
// After construction *this is size 0 or holds the triangles.
181
// If fallBack and triangulation fails does naive triangulation
182
// and never returns 0 size.
183
faceTriangulation
184
(
185
const
pointField
&
points
,
186
const
face
&
f
,
187
const
vector
&
n
,
188
const
bool
fallBack =
false
189
);
190
191
//- Construct from Istream
192
faceTriangulation
(
Istream
&);
193
};
194
195
196
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197
198
}
// End namespace Foam
199
200
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202
#endif
203
204
// ************************************************************************* //
Foam::tmp
A class for managing temporary objects.
Definition:
PtrList.H:59
Foam::PointHit< point >
n
label n
Definition:
TABSMDCalcMethod2.H:31
Foam::faceTriangulation::faceTriangulation
faceTriangulation()
Construct null.
Definition:
faceTriangulation.C:600
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:62
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition:
Istream.H:61
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:33
pointField.H
Foam::faceTriangulation
Triangulation of faces. Handles concave polygons as well (inefficiently)
Definition:
faceTriangulation.H:67
f
labelList f(nPoints)
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:102
points
const pointField & points
Definition:
gmvOutputHeader.H:1
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition:
face.H:74
p0
const volScalarField & p0
Definition:
EEqn.H:36
triFaceList.H
src
meshTools
triSurface
faceTriangulation
faceTriangulation.H
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.