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());
151 template<
class PatchType>
172 if (info.
index() == -1)
176 "treeDataPrimitivePatch::getSampleType" 177 "(indexedOctree<treeDataPrimitivePatch>&, const point&)" 178 ) <<
"Could not find " << sample <<
" in octree." 187 Pout<<
"getSampleType : sample:" << sample
188 <<
" nearest face:" << faceI;
191 const pointField& points = patch_.localPoints();
192 const typename PatchType::FaceType& f = patch_.localFaces()[faceI];
197 pointHit curHit = f.nearestPoint(sample, points);
198 const vector area = f.normal(points);
211 Pout<<
" -> face hit:" << curPt
212 <<
" comparing to face normal " << area <<
endl;
223 Pout<<
" -> face miss:" << curPt;
231 const scalar typDimSqr =
mag(area) + VSMALL;
236 if ((
magSqr(points[f[fp]] - curPt)/typDimSqr) < planarTol_)
245 patch_.pointNormals()[f[fp]],
251 const point fc(f.centre(points));
253 if ((
magSqr(fc - curPt)/typDimSqr) < planarTol_)
260 Pout<<
" -> centre hit:" << fc
261 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
277 const labelList& fEdges = patch_.faceEdges()[faceI];
281 label edgeI = fEdges[fEdgeI];
282 const edge&
e = patch_.edges()[edgeI];
292 const labelList& eFaces = patch_.edgeFaces()[edgeI];
294 vector edgeNormal(vector::zero);
298 edgeNormal += patch_.faceNormals()[eFaces[i]];
304 <<
" comparing to edge normal:" << edgeNormal
329 ).nearestDist(sample);
337 vector ePrev = points[f[f.rcIndex(fp)]] - fc;
338 vector eNext = points[f[f.fcIndex(fp)]] - fc;
341 nLeft /=
mag(nLeft) + VSMALL;
343 vector nRight = e ^ eNext;
344 nRight /=
mag(nRight) + VSMALL;
348 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
349 <<
" comparing to edge normal " 350 << 0.5*(nLeft + nRight)
358 0.5*(nLeft + nRight),
366 Pout<<
"Did not find sample " << sample
367 <<
" anywhere related to nearest face " << faceI <<
endl 372 Pout<<
" vertex:" << f[fp] <<
" coord:" << points[f[fp]]
382 return volumeType::UNKNOWN;
387 template<
class PatchType>
404 if (!cubeBb.
overlaps(calcBb(patch_.points(), patch_[index])))
414 const typename PatchType::FaceType& f = patch_[index];
427 return triangleFuncs::intersectBb
439 bool triIntersects = triangleFuncs::intersectBb
442 points[f[f.fcIndex(fp)]],
459 template<
class PatchType>
464 const scalar radiusSqr
470 if (!bbs_[index].overlaps(centre, radiusSqr))
477 if (!calcBb(patch_.points(), patch_[index]).overlaps(centre, radiusSqr))
484 const face& f = patch_[index];
499 template<
class PatchType>
505 scalar& nearestDistSqr,
511 const PatchType& patch = shape.
patch();
517 const label index = indices[i];
518 const typename PatchType::FaceType& f = patch[index];
520 pointHit nearHit = f.nearestPoint(sample, points);
523 if (distSqr < nearestDistSqr)
525 nearestDistSqr = distSqr;
533 template<
class PatchType>
547 "treeDataPrimitivePatch<PatchType>::findNearestOp::operator()" 549 " const labelUList&," 550 " const linePointRef&," 560 template<
class PatchType>
566 point& intersectionPoint
569 return findIntersection(tree_, index, start, end, intersectionPoint);
573 template<
class PatchType>
579 point& intersectionPoint
582 if (!shapeMask_.empty() &&
findIndex(shapeMask_, index) != -1)
587 return findIntersection(tree_, index, start, end, intersectionPoint);
591 template<
class PatchType>
597 point& intersectionPoint
604 "findSelfIntersectOp::operator()\n" 606 " const label index,\n" 607 " const point& start,\n" 608 " const point& end,\n" 609 " point& intersectionPoint\n" 611 ) <<
"EdgeID not set. Please set edgeID to the index of" 612 <<
" the edge you are testing" 617 const PatchType& patch = shape.
patch();
619 const typename PatchType::FaceType& f = patch.localFaces()[index];
620 const edge&
e = patch.edges()[edgeID_];
624 return findIntersection(tree_, index, start, end, intersectionPoint);
633 template<
class PatchType>
640 point& intersectionPoint
644 const PatchType& patch = shape.
patch();
647 const typename PatchType::FaceType& f = patch[index];
661 const vector dir(end - start);
671 ).intersection(start, dir, intersection::HALF_RAY, shape.planarTol_);
675 const pointField& faceCentres = patch.faceCentres();
677 inter = f.intersection
683 intersection::HALF_RAY,
692 intersectionPoint = inter.
hitPoint();
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
const Point & rawPoint() const
Return point with no checking.
findAllIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, DynamicList< label > &shapeMask)
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
vector point
Point is a vector.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
dimensioned< scalar > mag(const dimensioned< Type > &)
const PatchType & patch() const
Return access to the underlying patch.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const Point & hitPoint() const
Return hit point.
findNearestOp(const indexedOctree< treeDataPrimitivePatch > &tree)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool containsAny(const UList< point > &) const
Contains any of the points? (inside or on edge)
Standard boundBox + extra functionality for use in octree.
errorManipArg< error, int > exit(error &err, const int errNo=1)
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label index() const
Return index.
vectorField pointField
pointField is a vectorField.
triangle< point, const point & > triPointRef
A face is a list of labels corresponding to mesh vertices.
bool overlaps(const label index, const treeBoundBox &sampleBb) const
Does shape at index overlap bb.
Ostream & endl(Ostream &os)
Add newline and flush stream.
findSelfIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree, const label edgeID)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
linePointRef line(const pointField &) const
Return edge line.
const dimensionedScalar e
Elementary charge.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
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.
findIntersectOp(const indexedOctree< treeDataPrimitivePatch > &tree)
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.
errorManip< error > abort(error &err)
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>.
treeDataPrimitivePatch(const bool cacheBb, const PatchType &, const scalar planarTol)
Construct from patch.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Non-pointer based hierarchical recursive searching.
scalar distance() const
Return distance to hit.
pointHit nearestPoint(const point &p, const pointField &) const
Return nearest point to face.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool hit() const
Is there a hit.
pointField shapePoints() const
Get representative point cloud for all shapes inside.
line< point, const point & > linePointRef
Line using referred points.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
bool overlaps(const boundBox &) const
Overlaps/touches boundingBox?
prefixOSstream Pout(cout,"Pout")