37template<
class PatchType>
49 auto iter = bbs.
begin();
51 for (
const auto&
f :
pp)
64template<
class PatchType>
66Foam::treeDataPrimitivePatch<PatchType>::getBounds(
const label patchFacei)
const
68 return treeBoundBox(patch_.points(), patch_[patchFacei]);
72template<
class PatchType>
73void Foam::treeDataPrimitivePatch<PatchType>::update()
77 bbs_ = treeDataPrimitivePatch<PatchType>::boxes(patch_);
84template<
class PatchType>
88 const PatchType& patch,
89 const scalar planarTol
100template<
class PatchType>
110template<
class PatchType>
120template<
class PatchType>
128 shapeMask_(shapeMask)
132template<
class PatchType>
147template<
class PatchType>
156 for (
const label patchFacei : indices)
158 bb.
add(patch_.points(), patch_[patchFacei]);
165template<
class PatchType>
186 if (info.
index() == -1)
189 <<
"Could not find " <<
sample <<
" in octree."
194 label facei = info.
index();
199 <<
" nearest face:" << facei;
202 const auto& localF = patch_.localFaces()[facei];
203 const auto&
f = patch_[facei];
204 const auto&
points = patch_.points();
223 Pout<<
" -> face hit:" << curPt
224 <<
" comparing to face normal " << area <<
endl;
235 Pout<<
" -> face miss:" << curPt;
243 const scalar typDimSqr =
mag(area) + VSMALL;
248 const scalar relDistSqr = (
magSqr(
points[
f[fp]] - curPt)/typDimSqr);
250 if (relDistSqr < planarTol_)
259 patch_.pointNormals()[localF[fp]],
267 const scalar relDistSqr = (
magSqr(fc - curPt)/typDimSqr);
269 if (relDistSqr < planarTol_)
276 Pout<<
" -> centre hit:" << fc
277 <<
" distance:" << relDistSqr <<
endl;
292 for (
const label edgei : patch_.faceEdges()[facei])
295 patch_.meshEdge(edgei).line(
points).nearestDist(sample);
297 const scalar relDistSqr = (edgeHit.point().distSqr(curPt)/typDimSqr);
299 if (relDistSqr < planarTol_)
307 for (
const label eFacei : patch_.edgeFaces()[edgei])
309 edgeNormal += patch_.faceNormals()[eFacei];
314 Pout<<
" -> real edge hit point:" << edgeHit.point()
315 <<
" comparing to edge normal:" << edgeNormal
338 const scalar relDistSqr = (edgeHit.point().distSqr(curPt)/typDimSqr);
340 if (relDistSqr < planarTol_)
354 Pout<<
" -> internal edge hit point:" << edgeHit.point()
355 <<
" comparing to edge normal "
356 << 0.5*(nLeft + nRight)
364 0.5*(nLeft + nRight),
372 Pout<<
"Did not find sample " << sample
373 <<
" anywhere related to nearest face " << facei <<
endl
378 Pout<<
" vertex:" <<
f[fp]
394template<
class PatchType>
406 : !searchBox.
overlaps(getBounds(index))
415 const auto&
points = patch_.points();
416 const auto&
f = patch_[index];
453template<
class PatchType>
458 const scalar radiusSqr
472 const auto&
points = patch_.points();
473 const auto&
f = patch_[index];
479 if (
sqr(nearHit.distance()) < radiusSqr)
490template<
class PatchType>
496 scalar& nearestDistSqr,
501 const auto&
points = patch_.points();
503 for (
const label index : indices)
505 const auto&
f = patch_[index];
510 if (distSqr < nearestDistSqr)
512 nearestDistSqr = distSqr;
520template<
class PatchType>
526 scalar& nearestDistSqr,
531 tree_.shapes().findNearest
542template<
class PatchType>
558template<
class PatchType>
564 point& intersectionPoint
571template<
class PatchType>
577 point& intersectionPoint
580 if (shapeMask_.found(index))
589template<
class PatchType>
595 point& intersectionPoint
601 <<
"EdgeID not set. Please set edgeID to the index of"
602 <<
" the edge you are testing"
607 const PatchType&
patch = shape.patch();
609 const auto&
f =
patch.localFaces()[index];
610 const edge&
e =
patch.edges()[edgeID_];
612 if (!
f.found(
e[0]) && !
f.found(
e[1]))
621template<
class PatchType>
628 point& intersectionPoint
632 const PatchType&
patch = shape.patch();
635 const auto&
f =
patch[index];
640 const treeBoundBox& faceBb = shape.bbs_[index];
642 if ((faceBb.posBits(start) & faceBb.posBits(end)) != 0)
649 const vector dir(end - start);
665 inter =
f.intersection
676 if (inter.hit() && inter.distance() <= 1)
680 intersectionPoint = inter.point();
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Minimal example by using system/controlDict.functions:
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
const point_type & point() const noexcept
Return the point, no checks.
label index() const noexcept
Return the hit index.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
const Vector< Cmpt > & centre(const Foam::UList< Vector< Cmpt > > &) const noexcept
Return this (for point which is a typedef to Vector<scalar>).
void add(const boundBox &bb)
Extend to include the second box.
bool containsAny(const UList< point > &points) const
Contains any of the points? (inside or on edge).
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Non-pointer based hierarchical recursive searching.
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
Standard boundBox with extra functionality for use in octree.
bool overlaps(const boundBox &bb) const
Overlaps with other bounding box, sphere etc?
bool intersects(const point &overallStart, const vector &overallVec, const point &start, const point &end, point &pt, direction &ptBits) const
Intersects segment; set point to intersection position and face,.
direction posBits(const point &pt) const
Position of point relative to bounding box.
findAllIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, DynamicList< label > &shapeMask)
findIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree)
findNearestOp(const indexedOctree< treeDataPrimitivePatch > &tree)
findSelfIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, const label edgeID)
Encapsulation of data needed to search on PrimitivePatches.
volumeType getVolumeType(const indexedOctree< treeDataPrimitivePatch< PatchType > > &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
static bool findIntersection(const indexedOctree< treeDataPrimitivePatch< PatchType > > &tree, const label index, const point &start, const point &end, point &intersectionPoint)
Helper: find intersection of line with shapes.
void findNearest(const labelUList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
treeDataPrimitivePatch(const bool cacheBb, const PatchType &patch, const scalar planarTol)
Construct from patch.
treeBoundBox bounds(const labelUList &indices) const
Return bounding box for the specified face indices.
const point & centre(const label index) const
Representative point (face centre) at shape index.
const PatchType & patch() const noexcept
The underlying patch.
static treeBoundBoxList boxes(const PatchType &patch)
Calculate and return bounding boxes for each patch face.
bool overlaps(const label index, const treeBoundBox &searchBox) const
Does shape at index overlap searchBox.
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
An enumeration wrapper for classification of a location as being inside/outside of a volume.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
PointHit< point > pointHit
A PointHit with a 3D point.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
List< treeBoundBox > treeBoundBoxList
A List of treeBoundBox.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
line< point, const point & > linePointRef
A line using referred points.
errorManip< error > abort(error &err)
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
triangle< point, const point & > triPointRef
A triangle using referred points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Tree tree(triangles.begin(), triangles.end())
#define forAll(list, i)
Loop across all elements in list.