findNearestMaskedOp.H
Go to the documentation of this file.
1 #include "indexedOctree.H"
3 
4 namespace Foam
5 {
6 
7 template<class PatchType>
9 {
11  const labelUList& excludeIndices_;
12 
13 public:
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
Foam::treeDataPrimitivePatch::patch
const PatchType & patch() const
Return access to the underlying patch.
Definition: treeDataPrimitivePatch.H:221
Foam::PointHit
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
Definition: PointHit.H:53
indexedOctree.H
Foam::PointHit::distance
scalar distance() const noexcept
Return distance to hit.
Definition: PointHit.H:139
Foam::indexedOctree::shapes
const Type & shapes() const
Reference to shape.
Definition: indexedOctree.H:444
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::findNearestMaskedOp::findNearestMaskedOp
findNearestMaskedOp(const indexedOctree< treeDataPrimitivePatch< PatchType >> &tree, const labelUList &excludeIndices)
Definition: findNearestMaskedOp.H:16
Foam::Field< vector >
Foam::PointHit::rawPoint
const point_type & rawPoint() const noexcept
The point, no checks.
Definition: PointHit.H:172
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:50
treeDataPrimitivePatch.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
f
labelList f(nPoints)
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::Vector< scalar >
Foam::treeDataPrimitivePatch
Encapsulation of data needed to search on PrimitivePatches.
Definition: treeDataPrimitivePatch.H:63
Foam::UList< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::UList::found
bool found(const T &val, label pos=0) const
True if the value if found in the list.
Definition: UListI.H:265
Foam::findNearestMaskedOp
Definition: findNearestMaskedOp.H:8
sample
Minimal example by using system/controlDict.functions: