35 template<
class>
class FaceList,
49 template<
class>
class FaceList,
61 treeBoundBox bb(points[f[0]], points[f[0]]);
63 for (label fp = 1; fp < f.size(); fp++)
65 const point&
p = points[f[fp]];
67 bb.min() =
min(bb.min(),
p);
68 bb.max() =
max(bb.max(),
p);
77 template<
class>
class FaceList,
86 bbs_.setSize(patch_.size());
90 bbs_[i] = calcBb(patch_.points(), patch_[i]);
102 template<
class>
class FaceList,
110 const PrimitivePatch<Face, FaceList, PointField, PointType>& patch
125 template<
class>
class FaceList,
137 cc[i] = patch_[i].centre(patch_.points());
149 template<
class>
class FaceList,
159 treeDataPrimitivePatch
184 if (info.index() == -1)
188 "treeDataPrimitivePatch::getSampleType"
189 "(indexedOctree<treeDataPrimitivePatch>&, const point&)"
190 ) <<
"Could not find " << sample <<
" in octree."
196 label faceI = info.index();
200 Pout<<
"getSampleType : sample:" << sample
201 <<
" nearest face:" << faceI;
204 const pointField& points = patch_.localPoints();
205 const face& f = patch_.localFaces()[faceI];
210 pointHit curHit = f.nearestPoint(sample, points);
211 const vector area = f.normal(points);
212 const point& curPt = curHit.rawPoint();
224 Pout<<
" -> face hit:" << curPt
225 <<
" comparing to face normal " << area <<
endl;
227 return indexedOctree<treeDataPrimitivePatch>::getSide
236 Pout<<
" -> face miss:" << curPt;
244 const scalar typDimSqr =
mag(area) + VSMALL;
248 if ((
magSqr(points[f[fp]] - curPt)/typDimSqr) < tolSqr)
255 return indexedOctree<treeDataPrimitivePatch>::getSide
257 patch_.pointNormals()[f[fp]],
263 const point fc(f.centre(points));
265 if ((
magSqr(fc - curPt)/typDimSqr) < tolSqr)
272 Pout<<
" -> centre hit:" << fc
273 <<
" distance:" <<
magSqr(fc - curPt)/typDimSqr <<
endl;
276 return indexedOctree<treeDataPrimitivePatch>::getSide
289 const labelList& fEdges = patch_.faceEdges()[faceI];
293 label edgeI = fEdges[fEdgeI];
294 const edge&
e = patch_.edges()[edgeI];
296 pointHit edgeHit = e.line(points).nearestDist(sample);
298 if ((
magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < tolSqr)
304 const labelList& eFaces = patch_.edgeFaces()[edgeI];
306 vector edgeNormal(vector::zero);
310 edgeNormal += patch_.faceNormal()[eFaces[i]];
315 Pout<<
" -> real edge hit point:" << edgeHit.rawPoint()
316 <<
" comparing to edge normal:" << edgeNormal
322 return indexedOctree<treeDataPrimitivePatch>::getSide
341 ).nearestDist(sample);
343 if ((
magSqr(edgeHit.rawPoint() - curPt)/typDimSqr) < tolSqr)
348 vector e = points[f[fp]] - fc;
349 vector ePrev = points[f[f.rcIndex(fp)]] - fc;
350 vector eNext = points[f[f.fcIndex(fp)]] - fc;
353 nLeft /=
mag(nLeft) + VSMALL;
355 vector nRight = e ^ eNext;
356 nRight /=
mag(nRight) + VSMALL;
360 Pout<<
" -> internal edge hit point:" << edgeHit.rawPoint()
361 <<
" comparing to edge normal "
362 << 0.5*(nLeft + nRight)
368 return indexedOctree<treeDataPrimitivePatch>::getSide
370 0.5*(nLeft + nRight),
378 Pout<<
"Did not find sample " << sample
379 <<
" anywhere related to nearest face " << faceI <<
endl
384 Pout<<
" vertex:" << f[fp] <<
" coord:" << points[f[fp]]
394 return indexedOctree<treeDataPrimitivePatch>::UNKNOWN;
402 template<
class>
class FaceList,
411 const treeBoundBox& cubeBb
417 if (!cubeBb.overlaps(bbs_[index]))
424 if (!cubeBb.overlaps(calcBb(patch_.points(), patch_[index])))
434 const face& f = patch_[index];
438 if (cubeBb.contains(points[f[fp]]))
450 bool triIntersects = triangleFuncs::intersectBb
453 points[f[f.fcIndex(fp)]],
472 template<
class>
class FaceList,
483 scalar& nearestDistSqr,
492 label index = indices[i];
494 const face& f = patch_[index];
496 pointHit nearHit = f.nearestPoint(sample, points);
497 scalar distSqr =
sqr(nearHit.distance());
499 if (distSqr < nearestDistSqr)
501 nearestDistSqr = distSqr;
503 nearestPoint = nearHit.rawPoint();
512 template<
class>
class FaceList,
523 point& intersectionPoint
529 const treeBoundBox& faceBb = bbs_[index];
531 if ((faceBb.posBits(start) & faceBb.posBits(end)) != 0)
539 const face& f = patch_[index];
541 const vector dir(end - start);
543 pointHit inter = patch_[index].intersection
549 intersection::HALF_RAY
552 if (inter.hit() && inter.distance() <= 1)
556 intersectionPoint = inter.
hitPoint();