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
meshTools
octree
octreeDataPoint.C
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
\*---------------------------------------------------------------------------*/
25
26
#include "
octreeDataPoint.H
"
27
28
#include <
OpenFOAM/labelList.H
>
29
#include "
treeBoundBox.H
"
30
#include "
octree.H
"
31
#include <
OpenFOAM/linePointRef.H
>
32
#include <
OpenFOAM/pointHit.H
>
33
34
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35
36
// Construct from components
37
Foam::octreeDataPoint::octreeDataPoint
(
const
pointField
&
points
)
38
:
39
points_(points)
40
{}
41
42
43
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
44
45
//- Get type of volume
46
Foam::label
Foam::octreeDataPoint::getSampleType
47
(
48
const
octree<octreeDataPoint>
&,
49
const
point
&
50
)
const
51
{
52
return
octree<octreeDataPoint>::UNKNOWN
;
53
}
54
55
56
bool
Foam::octreeDataPoint::overlaps
57
(
58
const
label index,
59
const
treeBoundBox
& sampleBb
60
)
const
61
{
62
return
sampleBb.
contains
(points_[index]);
63
}
64
65
66
bool
Foam::octreeDataPoint::contains
67
(
68
const
label,
69
const
point
&
70
)
const
71
{
72
notImplemented
73
(
74
"octreeDataPoint::contains(const label, const point&)"
75
);
76
77
return
false
;
78
}
79
80
81
bool
Foam::octreeDataPoint::intersects
82
(
83
const
label,
84
const
point
&,
85
const
point
&,
86
point
&
87
)
const
88
{
89
notImplemented
90
(
91
"octreeDataPoint::intersects(const label, const point&,"
92
"const point&, point&)"
93
);
94
95
return
false
;
96
}
97
98
99
bool
Foam::octreeDataPoint::findTightest
100
(
101
const
label,
102
const
point
&,
103
treeBoundBox
&
104
)
const
105
{
106
notImplemented
107
(
108
"octreeDataPoint::findTightest(const label, const point&,"
109
"treeBoundBox&)"
110
);
111
112
return
false
;
113
}
114
115
116
Foam::scalar
Foam::octreeDataPoint::calcSign
117
(
118
const
label,
119
const
point
&,
120
vector
& n
121
)
const
122
{
123
n =
vector::zero
;
124
125
return
1;
126
}
127
128
129
// Calculate nearest point on/in shapei
130
inline
Foam::scalar
Foam::octreeDataPoint::calcNearest
131
(
132
const
label index,
133
const
point
& sample,
134
point
& nearest
135
)
const
136
{
137
nearest = points_[index];
138
return
magSqr
(points_[index] - sample);
139
}
140
141
142
void
Foam::octreeDataPoint::write
143
(
144
Ostream
& os,
145
const
label index
146
)
const
147
{
148
if
((index < 0) || (index >
points
().size()))
149
{
150
FatalErrorIn
(
"octreeDataPoint::write(Ostream&, const label)"
)
151
<<
"Index "
<< index <<
" outside 0.."
<<
points
().
size
()
152
<<
abort
(
FatalError
);
153
}
154
os <<
' '
<<
points
()[index];
155
}
156
157
158
// Calculate nearest point on/in shapei
159
Foam::scalar
Foam::octreeDataPoint::calcNearest
160
(
161
const
label index,
162
const
linePointRef
&
ln
,
163
point
& linePt,
164
point
& shapePt
165
)
const
166
{
167
// Nearest point on shape
168
shapePt = points_[index];
169
170
// Nearest point on line
171
pointHit
pHit = ln.
nearestDist
(shapePt);
172
173
linePt = pHit.
rawPoint
();
174
175
return
pHit.
distance
();
176
}
177
178
179
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
180
181
Foam::Ostream
& Foam::operator<<
182
(
183
Foam::Ostream
& os,
184
const
Foam::octreeDataPoint
& ocPts
185
)
186
{
187
return
os << ocPts.points();
188
}
189
190
191
// ************************ vim: set sw=4 sts=4 et: ************************ //