36 bool Foam::triSurfaceSearch::checkUniqueHit
39 const UList<pointIndexHit>& hits,
47 const labelledTri&
f =
surface()[currHit.index()];
49 f.nearestPointClassify
61 const label nearPointi =
f[nearLabel];
68 const label pointFacei = pointFaces[pI];
70 if (pointFacei != currHit.index())
76 if (hit.index() == pointFacei)
91 const label edgeI = fEdges[nearLabel];
97 const label edgeFacei = edgeFaces[fI];
99 if (edgeFacei != currHit.index())
105 if (hit.index() == edgeFacei)
108 const vector currHitNormal =
111 const vector existingHitNormal =
114 const label signCurrHit =
115 pos0(currHitNormal & lineVec);
117 const label signExistingHit =
118 pos0(existingHitNormal & lineVec);
120 if (signCurrHit == signExistingHit)
145 Foam::triSurfaceSearch::triSurfaceSearch
157 if (
dict.readIfPresent(
"tolerance", tolerance_) && tolerance_ > 0)
159 Info<<
" using intersection tolerance " << tolerance_ <<
endl;
163 if (
dict.readIfPresent(
"maxTreeDepth", maxTreeDepth_) && maxTreeDepth_ > 0)
165 Info<<
" using maximum tree depth " << maxTreeDepth_ <<
endl;
170 Foam::triSurfaceSearch::triSurfaceSearch
173 const scalar tolerance,
174 const label maxTreeDepth
178 tolerance_(tolerance),
179 maxTreeDepth_(maxTreeDepth),
221 <<
"Surface does not have compact point numbering." 224 <<
" are used. This might give problems in some routines." 236 const scalar oldTol =
270 if (!
tree().bb().contains(sample))
272 inside[sampleI] =
false;
276 inside[sampleI] =
true;
280 inside[sampleI] =
false;
291 List<pointIndexHit>& info
294 const scalar oldTol =
297 const indexedOctree<treeDataTriSurface>& octree =
tree();
299 const treeDataTriSurface::findNearestOp fOp(octree);
305 info[i] = octree.findNearest
324 const scalar nearestDistSqr = 0.25*
magSqr(span);
326 return tree().findNearest(pt, nearestDistSqr);
341 const scalar oldTol =
346 info[i] = octree.findLine(start[i],
end[i]);
357 List<pointIndexHit>& info
360 const indexedOctree<treeDataTriSurface>& octree =
tree();
362 info.setSize(start.size());
364 const scalar oldTol =
369 info[i] = octree.findLineAny(start[i],
end[i]);
380 List<List<pointIndexHit>>& info
383 const indexedOctree<treeDataTriSurface>& octree =
tree();
385 info.setSize(start.size());
387 const scalar oldTol =
391 DynamicList<pointIndexHit> hits;
393 DynamicList<label> shapeMask;
395 treeDataTriSurface::findAllIntersectOp allIntersectOp(octree, shapeMask);
429 shapeMask.append(inter.index());
437 info[pointi].transfer(hits);
static scalar & perturbTol() noexcept
Get the perturbation tolerance.
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
scalarField samples(nIntervals, Zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
treeDataPrimitivePatch< triSurface > treeDataTriSurface
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
#define forAll(list, i)
Loop across all elements in list.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
~triSurfaceSearch()
Destructor.
const Map< label > & meshPointMap() const
Mesh point map.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
boolList calcInside(const pointField &searchPoints) const
Calculate for each searchPoint inside/outside status.
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &info) const
Calculate all intersections from start to end.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void clearOut()
Clear storage.
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
Tree tree(triangles.begin(), triangles.end())
const labelListList & edgeFaces() const
Return edge-face addressing.
const Field< point_type > & points() const noexcept
Return reference to global points.
A location inside the volume.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
const labelListList & pointFaces() const
Return point-face addressing.
dimensionedScalar pos0(const dimensionedScalar &ds)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Encapsulates data for (indexedOc)tree searches on a triSurface.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
const triSurface & surface() const
Return reference to the surface.
vector point
Point is a vector.
Non-pointer based hierarchical recursive searching.
#define WarningInFunction
Report a warning using Foam::Warning.
Standard boundBox with extra functionality for use in octree.
messageStream Info
Information stream (stdout output on master, null elsewhere)
const labelListList & faceEdges() const
Return face-edge addressing.
pointIndexHit nearest(const point &pt, const vector &span) const
Calculate nearest point on surface for single searchPoint. Returns.
List< label > labelList
A List of labels.
Triangulated surface description with patch information.
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)