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 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
const PatchType & patch() const noexcept
The underlying patch.
const Type & shapes() const noexcept
Reference to shape.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
bool found(const T &val, label pos=0) const
Same as contains()
Definition: UList.H:879
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
const pointField & points
findNearestMaskedOp(const indexedOctree< treeDataPrimitivePatch< PatchType >> &tree, const labelUList &excludeIndices)
Encapsulation of data needed to search on PrimitivePatches.
Tree tree(triangles.begin(), triangles.end())
Describes the interaction of a object and a (templated) point. It carries the info of a successful hi...
Definition: pointHit.H:43
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
labelList f(nPoints)
Non-pointer based hierarchical recursive searching.
scalar distance() const noexcept
Return distance to hit.
Definition: pointHit.H:169
const std::string patch
OpenFOAM patch number as a std::string.
const point_type & point() const noexcept
Return the point, no checks.
Definition: pointHit.H:161
Namespace for OpenFOAM.