34 template<
class PatchType>
41 treeBoundBox bb(points[f[0]], points[f[0]]);
43 for (
label fp = 1; fp < f.size(); fp++)
45 const point& p = points[f[fp]];
48 bb.max() =
max(bb.max(),
p);
54 template<
class PatchType>
59 bbs_.setSize(patch_.size());
63 bbs_[i] = calcBb(patch_.points(), patch_[i]);
72 template<
class PatchType>
76 const PatchType& patch,
77 const scalar planarTol
88 template<
class PatchType>
98 template<
class PatchType>
108 template<
class PatchType>
116 shapeMask_(shapeMask)
120 template<
class PatchType>
135 template<
class PatchType>
142 cc[i] = patch_[i].centre(patch_.points());
149 template<
class PatchType>
170 if (info.
index() == -1)
173 <<
"Could not find " << sample <<
" in octree." 182 Pout<<
"getSampleType : sample:" << sample
183 <<
" nearest face:" << facei;
186 const pointField& points = patch_.localPoints();
187 const typename PatchType::FaceType& f = patch_.localFaces()[facei];
192 pointHit curHit = f.nearestPoint(sample, points);
193 const vector area = f.area(points);
206 Pout<<
" -> face hit:" << curPt
207 <<
" comparing to face normal " << area <<
endl;
218 Pout<<
" -> face miss:" << curPt;
226 const scalar typDimSqr =
mag(area) + vSmall;
231 if ((
magSqr(points[f[fp]] - curPt)/typDimSqr) < planarTol_)
240 patch_.pointNormals()[f[fp]],
246 const point fc(f.centre(points));
248 if ((
magSqr(fc - curPt)/typDimSqr) < planarTol_)
255 Pout<<
" -> centre hit:" << fc
256 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
272 const labelList& fEdges = patch_.faceEdges()[facei];
276 label edgeI = fEdges[fEdgeI];
277 const edge&
e = patch_.edges()[edgeI];
287 const labelList& eFaces = patch_.edgeFaces()[edgeI];
293 edgeNormal += patch_.faceNormals()[eFaces[i]];
299 <<
" comparing to edge normal:" << edgeNormal
324 ).nearestDist(sample);
332 vector ePrev = points[f[f.rcIndex(fp)]] - fc;
333 vector eNext = points[f[f.fcIndex(fp)]] - fc;
336 nLeft /=
mag(nLeft) + vSmall;
338 vector nRight = e ^ eNext;
339 nRight /=
mag(nRight) + vSmall;
343 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
344 <<
" comparing to edge normal " 345 << 0.5*(nLeft + nRight)
353 0.5*(nLeft + nRight),
361 Pout<<
"Did not find sample " << sample
362 <<
" anywhere related to nearest face " << facei <<
endl 367 Pout<<
" vertex:" << f[fp] <<
" coord:" << points[f[fp]]
377 return volumeType::unknown;
382 template<
class PatchType>
399 if (!cubeBb.
overlaps(calcBb(patch_.points(), patch_[index])))
409 const typename PatchType::FaceType& f = patch_[index];
422 return triangleFuncs::intersectBb
434 bool triIntersects = triangleFuncs::intersectBb
437 points[f[f.fcIndex(fp)]],
454 template<
class PatchType>
459 const scalar radiusSqr
465 if (!bbs_[index].overlaps(centre, radiusSqr))
472 if (!calcBb(patch_.points(), patch_[index]).overlaps(centre, radiusSqr))
479 const face& f = patch_[index];
494 template<
class PatchType>
500 scalar& nearestDistSqr,
506 const PatchType& patch = shape.
patch();
512 const label index = indices[i];
513 const typename PatchType::FaceType& f = patch[index];
515 pointHit nearHit = f.nearestPoint(sample, points);
518 if (distSqr < nearestDistSqr)
520 nearestDistSqr = distSqr;
528 template<
class PatchType>
544 template<
class PatchType>
550 point& intersectionPoint
553 return findIntersection(tree_, index, start, end, intersectionPoint);
557 template<
class PatchType>
563 point& intersectionPoint
566 if (!shapeMask_.empty() &&
findIndex(shapeMask_, index) != -1)
571 return findIntersection(tree_, index, start, end, intersectionPoint);
575 template<
class PatchType>
581 point& intersectionPoint
587 <<
"EdgeID not set. Please set edgeID to the index of" 588 <<
" the edge you are testing" 593 const PatchType& patch = shape.
patch();
595 const typename PatchType::FaceType& f = patch.localFaces()[index];
596 const edge&
e = patch.edges()[edgeID_];
600 return findIntersection(tree_, index, start, end, intersectionPoint);
609 template<
class PatchType>
616 point& intersectionPoint
620 const PatchType& patch = shape.
patch();
623 const typename PatchType::FaceType& f = patch[index];
637 const vector dir(end - start);
652 intersection::algorithm::halfRay,
658 const pointField& faceCentres = patch.faceCentres();
660 inter = f.intersection
666 intersection::algorithm::halfRay,
675 intersectionPoint = inter.
hitPoint();
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 boundBox &) const
Overlaps/touches boundingBox?
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
direction posBits(const point &) const
Position of point relative to bounding box.
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Return *this (used for point which is a typedef to Vector<scalar>.
linePointRef line(const pointField &) const
Return edge line.
vectorField pointField
pointField is a vectorField.
findNearestOp(const indexedOctree< treeDataPrimitivePatch > &tree)
line< point, const point & > linePointRef
Line using referred points.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const Point & hitPoint() const
Return hit point.
Encapsulation of data needed to search on PrimitivePatches.
bool hit() const
Is there a hit.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
pointField shapePoints() const
Get representative point cloud for all shapes inside.
findSelfIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, const label edgeID)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const Point & rawPoint() const
Return point with no checking.
const PatchType & patch() const
Return access to the underlying patch.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does shape at index overlap bb.
vector point
Point is a vector.
Non-pointer based hierarchical recursive searching.
pointHit nearestPoint(const point &p, const pointField &) const
Return nearest point to face.
prefixOSstream Pout(cout, "Pout")
treeDataPrimitivePatch(const bool cacheBb, const PatchType &, const scalar planarTol)
Construct from patch.
findAllIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, DynamicList< label > &shapeMask)
triangle< point, const point & > triPointRef
Standard boundBox + extra functionality for use in octree.
dimensioned< scalar > mag(const dimensioned< Type > &)
scalar distance() const
Return distance to hit.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
label index() const
Return index.
const dimensionedScalar e
Elementary charge.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
findIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree)
bool containsAny(const UList< point > &) const
Contains any of the points? (inside or on edge)