Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
meshes
meshShapes
triFace
triFace.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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
Class
25
Foam::triFace
26
27
Description
28
A triangle face primitive using a FixedList.
29
30
SourceFiles
31
triFaceI.H
32
33
\*---------------------------------------------------------------------------*/
34
35
#ifndef triFace_H
36
#define triFace_H
37
38
#include <
OpenFOAM/FixedList.H
>
39
#include <
OpenFOAM/edgeList.H
>
40
#include <
OpenFOAM/pointHit.H
>
41
#include <
OpenFOAM/intersection.H
>
42
#include <
OpenFOAM/pointField.H
>
43
#include <
OpenFOAM/triPointRef.H
>
44
45
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47
namespace
Foam
48
{
49
50
class
face;
51
52
// Forward declaration of friend functions and operators
53
54
class
triFace
;
55
inline
bool
operator==
(
const
triFace
&,
const
triFace
&);
56
inline
bool
operator!=
(
const
triFace
&,
const
triFace
&);
57
58
59
/*---------------------------------------------------------------------------*\
60
class triFace Declaration
61
\*---------------------------------------------------------------------------*/
62
63
class
triFace
64
:
65
public
FixedList
<label, 3>
66
{
67
68
public
:
69
70
// Constructors
71
72
//- Construct null
73
inline
triFace
();
74
75
//- Construct from three point labels
76
inline
triFace
77
(
78
const
label a,
79
const
label
b
,
80
const
label c
81
);
82
83
//- Construct from a UList<label>
84
explicit
inline
triFace
(
const
UList<label>
&);
85
86
//- Construct from Istream
87
inline
triFace
(
Istream
&);
88
89
90
// Member Functions
91
92
//- Collapse face by removing duplicate point labels
93
// return the collapsed size, set collapsed point labels to -1
94
inline
label
collapse
();
95
96
//- Return the edge direction on the face
97
// - +1: forward (counter-clockwise) on the face
98
// - -1: reverse (clockwise) on the face
99
// - 0: edge not found on the face
100
inline
int
edgeDirection
(
const
edge
&)
const
;
101
102
103
// Properties
104
105
//- Return the points corresponding to this face
106
inline
pointField
points
(
const
pointField
&
points
)
const
;
107
108
//- Return triangle as a face
109
inline
face
triFaceFace
()
const
;
110
111
//- Return number of edges
112
inline
label
nEdges
()
const
;
113
114
//- Return edges
115
inline
edgeList
edges
()
const
;
116
117
//- Return centre (centroid)
118
inline
point
centre
(
const
pointField
&)
const
;
119
120
//- Return scalar magnitude
121
inline
scalar
mag
(
const
pointField
&)
const
;
122
123
//- Return vector normal
124
inline
vector
normal
(
const
pointField
&)
const
;
125
126
//- Number of triangles after splitting
127
inline
label
nTriangles
()
const
;
128
129
//- Return face with reverse direction
130
inline
triFace
reverseFace
()
const
;
131
132
//- Return swept-volume
133
inline
scalar
sweptVol
134
(
135
const
pointField
& oldPoints,
136
const
pointField
& newPoints
137
)
const
;
138
139
//- Return point intersection with a ray starting at p, with
140
// direction n.
141
inline
pointHit
ray
142
(
143
const
point
&
p
,
144
const
vector
& q,
145
const
pointField
& points,
146
const
intersection::algorithm
=
intersection::FULL_RAY
,
147
const
intersection::direction
dir =
intersection::VECTOR
148
)
const
;
149
150
//- Return the triangle
151
inline
triPointRef
tri
(
const
pointField
&)
const
;
152
153
//- compare triFaces
154
// - 0: different
155
// - +1: identical
156
// - -1: same face, but different orientation
157
static
inline
int
compare
(
const
triFace
&,
const
triFace
&);
158
159
// Friend Operators
160
161
friend
bool
operator==
(
const
triFace
&,
const
triFace
&);
162
friend
bool
operator!=
(
const
triFace
&,
const
triFace
&);
163
};
164
165
166
//- Hash specialization for hashing triFace - a commutative hash value.
167
// Hash incrementally.
168
template
<>
169
inline
unsigned
Hash<triFace>::operator()
(
const
triFace
& t,
unsigned
seed)
const
170
{
171
// Fortunately we don't need this very often
172
const
uLabel
t0(t[0]);
173
const
uLabel
t1(t[1]);
174
const
uLabel
t2(t[2]);
175
176
const
uLabel
val = (t0*t1*t2 + t0+t1+t2);
177
178
return
Hash<uLabel>
()(val, seed);
179
}
180
181
182
//- Hash specialization for hashing triFace - a commutative hash value.
183
// Hash incrementally.
184
template
<>
185
inline
unsigned
Hash<triFace>::operator()
(
const
triFace
& t)
const
186
{
187
return
Hash<triFace>::operator()
(t, 0);
188
}
189
190
191
template
<>
192
inline
bool
contiguous<triFace>
() {
return
true
;}
193
194
195
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197
}
// End namespace Foam
198
199
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201
#include <
OpenFOAM/triFaceI.H
>
202
203
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205
#endif
206
207
// ************************ vim: set sw=4 sts=4 et: ************************ //