Loading...
Searching...
No Matches
treeDataPrimitivePatch.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-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::treeDataPrimitivePatch
28
29Description
30 Encapsulation of data needed to search on PrimitivePatches
31
32SourceFiles
33 treeDataPrimitivePatch.C
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef Foam_treeDataPrimitivePatch_H
38#define Foam_treeDataPrimitivePatch_H
39
40#include "treeBoundBoxList.H"
41#include "volumeType.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// Forward Declarations
49template<class Type> class indexedOctree;
50
52/*---------------------------------------------------------------------------*\
53 Class treeDataPrimitivePatchName Declaration
54\*---------------------------------------------------------------------------*/
55
57
58
59/*---------------------------------------------------------------------------*\
60 Class treeDataPrimitivePatch Declaration
61\*---------------------------------------------------------------------------*/
62
63template<class PatchType>
65:
66 public treeDataPrimitivePatchName
67{
68 // Private Data
69
70 //- Underlying geometry
71 const PatchType& patch_;
72
73 //- Whether to precalculate and store face bounding box
74 const bool cacheBb_;
75
76 //- Tolerance to use for intersection tests
77 const scalar planarTol_;
78
79 //- Face bounding boxes (valid only if cacheBb_)
81
82
83 // Private Member Functions
84
85 //- Get face bounding box
86 inline treeBoundBox getBounds(const label patchFacei) const;
87
88 //- Initialise all member data
89 void update();
90
91
92public:
93
94
95 class findNearestOp
96 {
98
99 public:
100
103 void operator()
104 (
105 const labelUList& indices,
106 const point& sample,
107
108 scalar& nearestDistSqr,
109 label& minIndex,
110 point& nearestPoint
111 ) const;
112
113 //- Calculates nearest (to line) point in shape.
114 // Returns point and distance (squared)
115 void operator()
116 (
117 const labelUList& indices,
118 const linePointRef& ln,
119
120 treeBoundBox& tightest,
121 label& minIndex,
122 point& linePoint,
123 point& nearestPoint
124 ) const;
125 };
126
127
128 class findIntersectOp
129 {
131
132 public:
133
135
136 //- Calculate intersection of any face with ray.
137 // Sets result accordingly. Used to find first intersection.
138 bool operator()
139 (
140 const label index,
141 const point& start,
142 const point& end,
143 point& intersectionPoint
144 ) const;
145 };
146
147
149 {
151
152 DynamicList<label>& shapeMask_;
153
154 public:
155
157 (
159 DynamicList<label>& shapeMask
160 );
162 //- Calculate intersection of unique face with ray.
163 // Sets result accordingly. Used to find all faces.
164 bool operator()
165 (
166 const label index,
167 const point& start,
168 const point& end,
169 point& intersectionPoint
170 ) const;
171 };
172
173
175 {
177
178 const label edgeID_;
179
180 public:
181
183 (
185 const label edgeID
186 );
187
188 //- Calculate intersection of face with edge of patch.
189 // Excludes faces that use edgeID. Used to find self intersection.
190 bool operator()
191 (
192 const label index,
193 const point& start,
194 const point& end,
195 point& intersectionPoint
196 ) const;
197 };
198
199
200
201 // Constructors (cachable versions)
202
203 //- Construct from patch.
205 (
206 const bool cacheBb,
207 const PatchType& patch,
208 const scalar planarTol
209 );
210
211
212 // Constructors (non-caching)
213
214 //- Construct from patch.
215 treeDataPrimitivePatch(const PatchType& patch, const scalar planarTol)
216 :
217 treeDataPrimitivePatch(false, patch, planarTol)
218 {}
219
220
221 // Static Functions
222
223 //- Calculate and return bounding boxes for each patch face
224 static treeBoundBoxList boxes(const PatchType& patch);
226
227 // Member Functions
228
229 //- Object dimension == 2 (face element)
230 int nDim() const noexcept { return 2; }
231
232 //- Return bounding box for the specified face indices
233 treeBoundBox bounds(const labelUList& indices) const;
234
235
236 // Access
237
238 //- The underlying patch
239 const PatchType& patch() const noexcept { return patch_; }
240
241 //TDB //- The subset of face ids to use
242
243
244 //- Use a subset of the patch
245 bool useSubset() const noexcept { return false; }
246
247 //- Is the patch empty (no faces)?
248 bool empty() const { return !patch_.size(); }
250 //- The patch size
251 label size() const { return patch_.size(); }
252
253 //- Map from shape index to original (non-subset) face label
254 label objectIndex(const label index) const noexcept { return index; }
255
256 //TBD //- Face at specified shape index
259
260 //- Representative point (face centre) at shape index
261 const point& centre(const label index) const
263 return patch_.faceCentres()[index];
264 }
265
266 //- Representative point cloud for contained shapes.
267 //- One point per shape, corresponding to the face centres.
269 {
270 return patch_.faceCentres();
271 }
272
273
274 // Search
275
276 //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
277 // Only makes sense for closed surfaces.
279 (
281 const point&
282 ) const;
284 //- Does shape at index overlap searchBox
285 bool overlaps
286 (
287 const label index,
288 const treeBoundBox& searchBox
289 ) const;
290
291 //- Does shape at index overlap sphere
292 bool overlaps
294 const label index,
295 const point& centre,
296 const scalar radiusSqr
297 ) const;
298
299 //- Helper: find intersection of line with shapes
300 static bool findIntersection
301 (
303 const label index,
304 const point& start,
305 const point& end,
306 point& intersectionPoint
307 );
308
309 //- Calculates nearest (to sample) point in shape.
310 // Returns actual point and distance (squared)
312 (
313 const labelUList& indices,
314 const point& sample,
315
316 scalar& nearestDistSqr,
317 label& nearestIndex,
318 point& nearestPoint
319 ) const;
320};
321
322
323// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325} // End namespace Foam
326
327// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328
329#ifdef NoRepository
330 #include "treeDataPrimitivePatch.C"
331#endif
332
333// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334
335#endif
336
337// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Minimal example by using system/controlDict.functions:
Non-pointer based hierarchical recursive searching.
A class for managing temporary objects.
Definition tmp.H:75
Standard boundBox with extra functionality for use in octree.
findAllIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, DynamicList< label > &shapeMask)
findIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree)
findNearestOp(const indexedOctree< treeDataPrimitivePatch > &tree)
findSelfIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, const label edgeID)
Encapsulation of data needed to search on PrimitivePatches.
bool useSubset() const noexcept
const labelList& faceLabels() const noexcept { labelList::null(); }
volumeType getVolumeType(const indexedOctree< treeDataPrimitivePatch< PatchType > > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
static bool findIntersection(const indexedOctree< treeDataPrimitivePatch< PatchType > > &tree, const label index, const point &start, const point &end, point &intersectionPoint)
Helper: find intersection of line with shapes.
void findNearest(const labelUList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
int nDim() const noexcept
Object dimension == 2 (face element).
treeDataPrimitivePatch(const bool cacheBb, const PatchType &patch, const scalar planarTol)
Construct from patch.
bool overlaps(const label index, const point &centre, const scalar radiusSqr) const
Does shape at index overlap sphere.
bool empty() const
Is the patch empty (no faces)?
treeDataPrimitivePatch(const PatchType &patch, const scalar planarTol)
Construct from patch.
treeBoundBox bounds(const labelUList &indices) const
Return bounding box for the specified face indices.
const point & centre(const label index) const
Representative point (face centre) at shape index.
const primitivePatch & patch() const noexcept
static treeBoundBoxList boxes(const PatchType &patch)
Calculate and return bounding boxes for each patch face.
label size() const
The patch size.
tmp< pointField > centres() const
Representative point cloud for contained shapes. One point per shape, corresponding to the face centr...
label objectIndex(const label index) const noexcept
Map from shape index to original (non-subset) face label.
bool overlaps(const label index, const treeBoundBox &searchBox) const
Does shape at index overlap searchBox.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
Definition volumeType.H:56
#define TemplateName(TemplateNameString)
Add typeName information from argument TypeNameString to a.
Definition className.H:92
mesh update()
Namespace for bounding specifications. At the moment, mostly for tables.
Namespace for OpenFOAM.
List< treeBoundBox > treeBoundBoxList
A List of treeBoundBox.
line< point, const point & > linePointRef
A line using referred points.
Definition line.H:66
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition POSIX.C:1239
Tree tree(triangles.begin(), triangles.end())