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
treeLeaf.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::treeLeaf
26
27
Description
28
An octree treeLeaf.
29
30
SourceFiles
31
treeLeaf.C
32
octreeDataPointTreaLeaf.H (specialization for points)
33
octreeDataPointTreeLeaf.C
34
octreeDataTriSurfaceTreeLeaf.H (specialization for triSurface)
35
octreeDataTriSurfaceTreeLeaf.C
36
37
\*---------------------------------------------------------------------------*/
38
39
#ifndef treeLeaf_H
40
#define treeLeaf_H
41
42
#include <
OpenFOAM/labelList.H
>
43
#include "
treeElem.H
"
44
#include <
OpenFOAM/boolList.H
>
45
#include <
OpenFOAM/linePointRef.H
>
46
#include <
OpenFOAM/HashSet.H
>
47
48
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50
namespace
Foam
51
{
52
53
class
treeBoundBox;
54
class
Ostream;
55
56
template
<
class
Type>
class
octree;
57
template
<
class
Type>
class
treeLeaf;
58
59
// Forward declaration of friend functions and operators
60
61
template
<
class
Type> Istream&
operator>>
(Istream&, treeLeaf<Type>&);
62
template
<
class
Type> Ostream& operator<<(Ostream&, const treeLeaf<Type>&);
63
64
65
/*---------------------------------------------------------------------------*\
66
Class treeLeafName Declaration
67
\*---------------------------------------------------------------------------*/
68
69
TemplateName
(treeLeaf);
70
71
72
/*---------------------------------------------------------------------------*\
73
Class treeLeaf Declaration
74
\*---------------------------------------------------------------------------*/
75
76
template
<
class
Type>
77
class
treeLeaf
78
:
79
public
treeElem
<Type>,
80
public
treeLeafName
81
{
82
// Private data
83
84
// Keeps real size (at construction time indices_ might be untrimmed)
85
label size_;
86
87
// Indices of 'things' whose bb overlaps leaf bb.
88
labelList
indices_;
89
90
91
// Private Member Functions
92
93
static
void
space(
Ostream
&,
const
label);
94
95
//- Disallow default bitwise copy construct
96
treeLeaf
(
const
treeLeaf
&);
97
98
//- Disallow default bitwise assignment
99
void
operator=(
const
treeLeaf
&);
100
101
102
public
:
103
104
// Constructors
105
106
//- Construct with size
107
treeLeaf
(
const
treeBoundBox
&
bb
,
const
label
size
);
108
109
//- Construct from list
110
treeLeaf
(
const
treeBoundBox
& bb,
const
labelList
&
indices
);
111
112
//- Construct from Istream
113
treeLeaf
(
Istream
&);
114
115
116
// Destructor
117
118
~treeLeaf
();
119
120
121
// Member Functions
122
123
// Access
124
125
label
size
()
const
126
{
127
return
size_;
128
}
129
130
const
labelList
&
indices
()
const
131
{
132
return
indices_;
133
}
134
135
// Edit
136
137
void
insert
(
const
label index)
138
{
139
if
(size_ >= indices_.
size
())
140
{
141
FatalErrorIn
142
(
143
"treeLeaf<Type>::insert(index)"
144
)
145
<<
"overflow"
146
<<
" size_ :"
<< size_
147
<<
" size():"
<< indices_.
size
()
148
<<
abort
(
FatalError
);
149
}
150
indices_[size_++] = index;
151
}
152
153
void
trim
()
154
{
155
if
(size_ == 0)
156
{
157
FatalErrorIn
158
(
159
"treeLeaf<Type>::trim()"
160
)
161
<<
"Trying to trim empty leaf: "
<<
endl
162
<<
" size_ :"
<< size_
163
<<
" size():"
<< indices_.
size
()
164
<<
abort
(
FatalError
);
165
}
166
indices_.
setSize
(size_);
167
}
168
169
//- Take indices at refineLevel and distribute them to lower levels
170
treeLeaf<Type>
*
redistribute
171
(
172
const
label,
173
octree<Type>
&,
174
const
Type&
175
);
176
177
label
setSubNodeType
178
(
179
const
label level,
180
octree<Type>
& top,
181
const
Type& shapes
182
)
const
;
183
184
// Search
185
186
//- Get type of sample
187
label
getSampleType
188
(
189
const
label level,
190
const
octree<Type>
& top,
191
const
Type& shapes,
192
const
point
& sample
193
)
const
;
194
195
//- Find index of shape containing sample
196
label
find
197
(
198
const
Type& shapes,
199
const
point
& sample
200
)
const
;
201
202
//- Find tightest fitting bounding box in leaf
203
bool
findTightest
204
(
205
const
Type& shapes,
206
const
point
& sample,
207
treeBoundBox
& tightest
208
)
const
;
209
210
//- Find nearest point.
211
bool
findNearest
212
(
213
const
Type& shapes,
214
const
point
& sample,
215
treeBoundBox
& tightest,
216
label& tightestI,
217
scalar& tightestDist
218
)
const
;
219
220
//- Find nearest shape to line
221
// Returns true if found nearer shape and updates nearest and
222
// tightest
223
bool
findNearest
224
(
225
const
Type& shapes,
226
const
linePointRef
&
ln
,
227
treeBoundBox
& tightest,
228
label& tightestI,
// index of nearest shape
229
point
& linePoint,
// nearest point on line
230
point
& shapePoint
// nearest point on shape
231
)
const
;
232
233
//- Find shapes not outside box. Return true if anything found.
234
bool
findBox
235
(
236
const
Type& shapes,
237
const
boundBox
& bb,
238
labelHashSet
& elements
239
)
const
;
240
241
// Write
242
243
//- Debug: print a leaf
244
void
printLeaf
(
Ostream
&,
const
label)
const
;
245
246
//- Debug: Write bb in OBJ format
247
void
writeOBJ
248
(
249
Ostream
& os,
250
const
label level,
251
label& vertNo
252
)
const
;
253
254
//- debug:
255
label
countLeaf
(
Ostream
&,
const
label)
const
;
256
257
258
// IOstream Operators
259
260
friend
Istream
&
operator
>> <Type>(
Istream
&,
treeLeaf<Type>
&);
261
friend
Ostream
& operator<< <Type>(
Ostream
&,
const
treeLeaf<Type>
&);
262
};
263
264
265
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266
267
}
// End namespace Foam
268
269
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270
271
#ifdef NoRepository
272
# include <
meshTools/treeLeaf.C
>
273
#endif
274
275
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276
277
#include "
octreeDataPointTreeLeaf.H
"
278
#include <
meshTools/octreeDataTriSurfaceTreeLeaf.H
>
279
280
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281
282
#endif
283
284
// ************************ vim: set sw=4 sts=4 et: ************************ //