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
primitiveShapes
plane
plane.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::plane
26
27
Description
28
Geometric class that creates a 2D plane and can return the intersection
29
point between a line and the plane.
30
31
SourceFiles
32
plane.C
33
34
\*---------------------------------------------------------------------------*/
35
36
#ifndef plane_H
37
#define plane_H
38
39
#include <
OpenFOAM/point.H
>
40
#include <
OpenFOAM/scalarList.H
>
41
#include <
OpenFOAM/dictionary.H
>
42
#include <
OpenFOAM/line.H
>
43
44
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46
namespace
Foam
47
{
48
49
// Forward declaration of friend functions and operators
50
51
class
plane;
52
bool
operator==
(
const
plane&,
const
plane&);
53
bool
operator!=
(
const
plane&,
const
plane&);
54
Ostream&
operator<<
(Ostream&,
const
plane&);
55
56
57
/*---------------------------------------------------------------------------*\
58
Class plane Declaration
59
\*---------------------------------------------------------------------------*/
60
61
class
plane
62
{
63
public
:
64
65
//- A direction and a reference point
66
class
ray
67
{
68
point
refPoint_;
69
70
vector
dir_;
71
72
public
:
73
74
ray
(
const
point
&
refPoint
,
const
vector
&
dir
)
75
:
76
refPoint_(refPoint),
77
dir_(dir)
78
{}
79
80
const
point
&
refPoint
()
const
81
{
82
return
refPoint_;
83
}
84
85
const
vector
&
dir
()
const
86
{
87
return
dir_;
88
}
89
};
90
91
92
private
:
93
94
// Private data
95
96
//- Plane normal
97
vector
unitVector_;
98
99
//- Base point
100
point
basePoint_;
101
102
103
// Private Member Functions
104
105
//- Calculates basePoint and normal vector given plane coefficients
106
void
calcPntAndVec(
const
scalarList
&
C
);
107
108
//- Calculates basePoint and normal vector given three points
109
//- Normal vector determined using right hand rule
110
void
calcPntAndVec
111
(
112
const
point
& point1,
113
const
point
& point2,
114
const
point
& point3
115
);
116
117
118
public
:
119
120
// Constructors
121
122
//- Construct from normal vector through the origin
123
plane
(
const
vector
& normalVector);
124
125
//- Construct from normal vector and point in plane
126
plane
(
const
point
& basePoint,
const
vector
& normalVector);
127
128
//- Construct from three points in plane
129
plane
(
const
point
& point1,
const
point
& point2,
const
point
& point3);
130
131
//- Construct from coefficients for the
132
// plane equation: ax + by + cz + d = 0
133
plane
(
const
scalarList
&
C
);
134
135
//- Construct from dictionary
136
plane
(
const
dictionary
& planeDict);
137
138
//- Construct from Istream. Assumes the base + normal notation.
139
plane
(
Istream
& is);
140
141
142
// Member Functions
143
144
//- Return plane normal
145
const
vector
&
normal
()
const
;
146
147
//- Return or return plane base point
148
const
point
&
refPoint
()
const
;
149
150
//- Return coefficients for the
151
// plane equation: ax + by + cz + d = 0
152
FixedList<scalar, 4>
planeCoeffs
()
const
;
153
154
//- Return nearest point in the plane for the given point
155
point
nearestPoint
(
const
point
&
p
)
const
;
156
157
//- Return distance from the given point to the plane
158
scalar
distance
(
const
point
&
p
)
const
;
159
160
//- Return cut coefficient for plane and line defined by
161
// origin and direction
162
scalar
normalIntersect
(
const
point
& pnt0,
const
vector
& dir)
const
;
163
164
//- Return cut coefficient for plane and ray
165
scalar
normalIntersect
(
const
ray
& r)
const
166
{
167
return
normalIntersect
(r.
refPoint
(), r.
dir
());
168
}
169
170
//- Return the cutting point between the plane and
171
// a line passing through the supplied points
172
template
<
class
Po
int
,
class
Po
int
Ref>
173
scalar
lineIntersect
(
const
line<Point, PointRef>
& l)
const
174
{
175
return
normalIntersect
(l.
start
(), l.
vec
());
176
}
177
178
//- Return the cutting line between this plane and another.
179
// Returned as direction vector and point line goes through.
180
ray
planeIntersect
(
const
plane
&)
const
;
181
182
//- Return the cutting point between this plane and two other planes
183
point
planePlaneIntersect
(
const
plane
&,
const
plane
&)
const
;
184
185
//- Write to dictionary
186
void
writeDict
(
Ostream
&)
const
;
187
188
189
// friend Operators
190
191
friend
bool
operator==
(
const
plane
&,
const
plane
&);
192
friend
bool
operator!=
(
const
plane
&,
const
plane
&);
193
194
195
// IOstream Operators
196
197
//- Write plane properties
198
friend
Ostream
&
operator<<
(
Ostream
&,
const
plane
&);
199
};
200
201
202
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204
}
// End namespace Foam
205
206
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208
#endif
209
210
// ************************ vim: set sw=4 sts=4 et: ************************ //