38 Foam::scalar Foam::octreeDataFace::tol(1
E-6);
43 void Foam::octreeDataFace::calcBb()
51 treeBoundBox& myBb = allBb_[i];
53 const face&
f = mesh_.
faces()[meshFaces_[i]];
57 const point& coord = mesh_.
points()[f[faceVertexI]];
59 myBb.min() =
min(myBb.min(), coord);
60 myBb.max() =
max(myBb.max(), coord);
77 meshFaces_(meshFaces),
90 meshFaces_(meshFaces),
91 allBb_(meshFaces_.size())
112 forAll(meshFaceListPtrs, listI)
114 faceI += meshFaceListPtrs[listI]->
size();
117 meshFaces_.setSize(faceI);
118 allBb_.setSize(faceI);
122 forAll(meshFaceListPtrs, listI)
124 const labelList& meshFaces = *meshFaceListPtrs[listI];
127 forAll(meshFaces, meshFaceI)
129 meshFaces_[faceI] = meshFaces[meshFaceI];
130 allBb_[faceI] = allBb[meshFaceI];
149 forAll(meshFaceListPtrs, listI)
151 faceI += meshFaceListPtrs[listI]->
size();
154 meshFaces_.setSize(faceI);
158 forAll(meshFaceListPtrs, listI)
160 const labelList& meshFaces = *meshFaceListPtrs[listI];
162 forAll(meshFaces, meshFaceI)
164 meshFaces_[faceI++] = meshFaces[meshFaceI];
177 meshFaces_(patch.size())
181 meshFaces_[patchFaceI] = patch.
start() + patchFaceI;
200 label boundaryFaceI = 0;
204 meshFaces_[boundaryFaceI++] = faceI;
215 mesh_(shapes.mesh()),
216 meshFaces_(shapes.meshFaces()),
217 allBb_(shapes.allBb())
248 label index = oc.
findNearest(sample, tightest, tightestDist);
254 "octreeDataFace::getSampleType"
255 "(octree<octreeDataFace>&, const point&)"
256 ) <<
"Could not find " << sample <<
" in octree."
262 label faceI = meshFaces_[index];
266 Pout<<
"getSampleType : sample:" << sample
267 <<
" nearest face:" << faceI;
270 const face& f = mesh_.faces()[faceI];
287 <<
" comparing to face normal " << mesh_.faceAreas()[faceI]
292 mesh_.faceAreas()[faceI],
307 scalar typDim =
sqrt(
mag(mesh_.faceAreas()[faceI])) + VSMALL;
311 if ((
mag(points[f[fp]] - curHit.
missPoint())/typDim) < tol)
317 const labelList& myFaces = mesh_.pointFaces()[f[fp]];
323 if (myFaces[myFaceI] >= mesh_.nInternalFaces())
325 vector n = mesh_.faceAreas()[myFaces[myFaceI]];
326 n /=
mag(n) + VSMALL;
334 Pout<<
" -> face point hit :" << points[f[fp]]
335 <<
" point normal:" << pointNormal
347 if ((
mag(mesh_.faceCentres()[faceI] - curHit.
missPoint())/typDim) < tol)
354 Pout<<
" -> centre hit:" << mesh_.faceCentres()[faceI]
356 <<
mag(mesh_.faceCentres()[faceI] - curHit.
missPoint())/typDim
362 mesh_.faceAreas()[faceI],
372 const labelList& myEdges = mesh_.faceEdges()[faceI];
376 const edge&
e = mesh_.edges()[myEdges[myEdgeI]];
382 ).nearestDist(sample);
391 const labelList& myFaces = mesh_.edgeFaces()[myEdges[myEdgeI]];
397 if (myFaces[myFaceI] >= mesh_.nInternalFaces())
399 vector n = mesh_.faceAreas()[myFaces[myFaceI]];
400 n /=
mag(n) + VSMALL;
409 <<
" comparing to edge normal:" << edgeNormal
434 mesh_.faceCentres()[faceI]
435 ).nearestDist(sample);
442 const label fpPrev = f.rcIndex(fp);
443 const label fpNext = f.fcIndex(fp);
445 vector e = points[f[fp]] - mesh_.faceCentres()[faceI];
446 vector ePrev = points[f[fpPrev]] - mesh_.faceCentres()[faceI];
447 vector eNext = points[f[fpNext]] - mesh_.faceCentres()[faceI];
450 nLeft /=
mag(nLeft) + VSMALL;
452 vector nRight = e ^ eNext;
453 nRight /=
mag(nRight) + VSMALL;
457 Pout<<
" -> internal edge hit point:" << edgeHit.
rawPoint()
458 <<
" comparing to edge normal "
459 << 0.5*(nLeft + nRight)
467 0.5*(nLeft + nRight),
475 Pout<<
"Did not find sample " << sample
476 <<
" anywhere related to nearest face " << faceI <<
endl
481 Pout<<
" vertex:" << f[fp] <<
" coord:" << points[f[fp]]
506 if (!sampleBb.
overlaps(allBb_[index]))
512 label faceI = meshFaces_[index];
514 const face& f = mesh_.faces()[faceI];
520 if (sampleBb.
contains(points[f[fp]]))
528 const point& fc = mesh_.faceCentres()[faceI];
532 const label fp1 = f.
fcIndex(fp);
555 "octreeDataFace::contains(const label, const point&)"
566 point& intersectionPoint
569 label faceI = meshFaces_[index];
571 const face& f = mesh_.faces()[faceI];
573 const vector dir(end - start);
591 intersectionPoint = inter.
hitPoint();
611 allBb_[index].calcExtremities(sample, myNear, myFar);
614 scalar myFarDist =
mag(dist);
616 point tightestNear, tightestFar;
619 scalar tightestFarDist =
mag(tightestFar - sample);
621 if (tightestFarDist < myFarDist)
629 const point dist2(fabs(dist.
x()), fabs(dist.
y()), fabs(dist.
z()));
631 tightest.
min() = sample - dist2;
632 tightest.
max() = sample + dist2;
647 label faceI = meshFaces_[index];
649 n = mesh_.faceAreas()[faceI];
651 n /=
mag(n) + VSMALL;
653 vector vec = sample - mesh_.faceCentres()[faceI];
655 vec /=
mag(vec) + VSMALL;
669 label faceI = meshFaces_[index];
671 const face& f = mesh_.faces()[faceI];
679 const point& ctr = mesh_.faceCentres()[faceI];
681 scalar
sign = mesh_.faceAreas()[faceI] & (sample - nearest);
683 Pout<<
"octreeDataFace::calcNearest : "
684 <<
"sample:" << sample
685 <<
" index:" << index
686 <<
" faceI:" << faceI
689 <<
" nearest point:" << nearest
690 <<
" distance to face:" << nearHit.
distance()
708 "octreeDataFace::calcNearest(const label, const linePointRef&"
717 os << meshFaces_[index] <<
" " << allBb_[index];