Loading...
Searching...
No Matches
findNearestMaskedOp.H
Go to the documentation of this file.
1#include "indexedOctree.H"
3
4namespace Foam
5{
6
7template<class PatchType>
9{
11 const labelUList& excludeIndices_;
12
13public:
14
16 (
18 const labelUList& excludeIndices
19 )
20 :
21 tree_(tree),
22 excludeIndices_(excludeIndices)
23 {}
24
25 void operator()
26 (
27 const labelUList& indices,
28 const point& sample,
29
30 scalar& nearestDistSqr,
31 label& minIndex,
32 point& nearestPoint
33 ) const
34 {
35 const treeDataPrimitivePatch<PatchType>& shape = tree_.shapes();
36 const PatchType& patch = shape.patch();
37
38 const pointField& points = patch.points();
39
40 forAll(indices, i)
41 {
42 const label index = indices[i];
43
44 if (!excludeIndices_.found(index))
45 {
46 const auto& f = patch[index];
47
48 pointHit nearHit = f.nearestPoint(sample, points);
49 scalar distSqr = sqr(nearHit.distance());
50
51 if (distSqr < nearestDistSqr)
52 {
53 nearestDistSqr = distSqr;
54 minIndex = index;
55 nearestPoint = nearHit.point();
56 }
57 }
58 }
59 }
60};
61
62} // End namespace Foam
Minimal example by using system/controlDict.functions:
scalar distance() const noexcept
Return distance to hit.
Definition pointHit.H:169
const point_type & point() const noexcept
Return the point, no checks.
Definition pointHit.H:161
findNearestMaskedOp(const indexedOctree< treeDataPrimitivePatch< PatchType > > &tree, const labelUList &excludeIndices)
Non-pointer based hierarchical recursive searching.
Encapsulation of data needed to search on PrimitivePatches.
const PatchType & patch() const noexcept
The underlying patch.
const pointField & points
Namespace for OpenFOAM.
PointHit< point > pointHit
A PointHit with a 3D point.
Definition pointHit.H:51
dimensionedSymmTensor sqr(const dimensionedVector &dv)
vector point
Point is a vector.
Definition point.H:37
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
labelList f(nPoints)
Tree tree(triangles.begin(), triangles.end())
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299