37 template<
class PatchType>
49 auto iter = bbs.
begin();
51 for (
const auto&
f :
pp)
64 template<
class PatchType>
68 return treeBoundBox(patch_.points(), patch_[patchFacei]);
72 template<
class PatchType>
77 bbs_ = treeDataPrimitivePatch<PatchType>::boxes(patch_);
84 template<
class PatchType>
88 const PatchType&
patch,
89 const scalar planarTol
100 template<
class PatchType>
110 template<
class PatchType>
120 template<
class PatchType>
128 shapeMask_(shapeMask)
132 template<
class PatchType>
147 template<
class PatchType>
156 for (
const label patchFacei : indices)
158 bb.
add(patch_.points(), patch_[patchFacei]);
165 template<
class PatchType>
186 if (info.
index() == -1)
189 <<
"Could not find " << sample <<
" in octree." 194 label facei = info.
index();
198 Pout<<
"getSampleType : sample:" << sample
199 <<
" nearest face:" << facei;
202 const auto& localF = patch_.localFaces()[facei];
203 const auto&
f = patch_[facei];
204 const auto&
points = patch_.points();
211 const point& curPt = curHit.point();
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]
394 template<
class PatchType>
406 : !searchBox.
overlaps(getBounds(index))
415 const auto&
points = patch_.points();
416 const auto&
f = patch_[index];
453 template<
class PatchType>
458 const scalar radiusSqr
472 const auto&
points = patch_.points();
473 const auto&
f = patch_[index];
479 if (
sqr(nearHit.distance()) < radiusSqr)
490 template<
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;
514 nearestPoint = nearHit.
point();
520 template<
class PatchType>
526 scalar& nearestDistSqr,
542 template<
class PatchType>
558 template<
class PatchType>
564 point& intersectionPoint
571 template<
class PatchType>
577 point& intersectionPoint
580 if (shapeMask_.found(index))
589 template<
class PatchType>
595 point& intersectionPoint
601 <<
"EdgeID not set. Please set edgeID to the index of" 602 <<
" the edge you are testing" 609 const auto&
f =
patch.localFaces()[index];
612 if (!
f.found(
e[0]) && !
f.found(
e[1]))
621 template<
class PatchType>
628 point& intersectionPoint
635 const auto&
f =
patch[index];
665 inter =
f.intersection
676 if (inter.hit() && inter.distance() <= 1)
680 intersectionPoint = inter.point();
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.
bool overlaps(const label index, const treeBoundBox &searchBox) const
Does shape at index overlap searchBox.
const point & centre(const label index) const
Representative point (face centre) at shape index.
const PatchType & patch() const noexcept
The underlying patch.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
volumeType getVolumeType(const indexedOctree< treeDataPrimitivePatch< PatchType >> &, const point &) const
Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool overlaps(const boundBox &bb) const
Overlaps with other bounding box, sphere etc?
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void findNearest(const labelUList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
Ostream & endl(Ostream &os)
Add newline and flush stream.
This class describes the interaction of an object (often a face) and a point. It carries the info of ...
static volumeType getSide(const vector &outsideNormal, const vector &vec)
Helper function to return the side. Returns outside if.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
An enumeration wrapper for classification of a location as being inside/outside of a volume...
UList< label > labelUList
A UList of labels.
#define forAll(list, i)
Loop across all elements in list.
direction posBits(const point &pt) const
Position of point relative to bounding box.
void add(const boundBox &bb)
Extend to include the second box.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
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,.
line< point, const point & > linePointRef
A line using referred points.
findNearestOp(const indexedOctree< treeDataPrimitivePatch > &tree)
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
const wordList area
Standard area field types (scalar, vector, tensor, etc)
Encapsulation of data needed to search on PrimitivePatches.
treeBoundBox bounds(const labelUList &indices) const
Return bounding box for the specified face indices.
Tree tree(triangles.begin(), triangles.end())
Describes the interaction of a object and a (templated) point. It carries the info of a successful hi...
label index() const noexcept
Return the hit index.
errorManip< error > abort(error &err)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
findSelfIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, const label edgeID)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
bool containsAny(const UList< point > &points) const
Contains any of the points? (inside or on edge)
static treeBoundBoxList boxes(const PatchType &patch)
Calculate and return bounding boxes for each patch face.
vector point
Point is a vector.
Non-pointer based hierarchical recursive searching.
findAllIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, DynamicList< label > &shapeMask)
scalar distance() const noexcept
Return distance to hit.
const std::string patch
OpenFOAM patch number as a std::string.
triangle< point, const point & > triPointRef
A triangle using referred points.
const point_type & point() const noexcept
Return the point, no checks.
Standard boundBox with extra functionality for use in octree.
treeDataPrimitivePatch(const bool cacheBb, const PatchType &patch, const scalar planarTol)
Construct from patch.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
PointHit< point > pointHit
A PointHit with a 3D point.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
findIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree)
static constexpr const zero Zero
Global zero (0)