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 typename PatchType::FaceType& 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.rawPoint();
56 }
57 }
58 }
59 }
60};
61
62} // End namespace Foam
Minimal example by using system/controlDict.functions:
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
Definition: PointHit.H:54
const point_type & rawPoint() const noexcept
The point, no checks.
Definition: PointHit.H:172
scalar distance() const noexcept
Return distance to hit.
Definition: PointHit.H:139
bool found(const T &val, label pos=0) const
True if the value if found in the list.
Definition: UListI.H:265
findNearestMaskedOp(const indexedOctree< treeDataPrimitivePatch< PatchType > > &tree, const labelUList &excludeIndices)
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:74
const Type & shapes() const
Reference to shape.
Encapsulation of data needed to search on PrimitivePatches.
const PatchType & patch() const
Return access to the underlying patch.
const pointField & points
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333