35 Foam::scalar Foam::octreeDataFaceList::tol = 1
E-6;
40 void Foam::octreeDataFaceList::calcBb()
45 vector(GREAT, GREAT, GREAT),
46 vector(-GREAT, -GREAT, -GREAT)
49 forAll (faceLabels_, faceLabelI)
51 label faceI = faceLabels_[faceLabelI];
54 treeBoundBox& myBb = allBb_[faceLabelI];
62 myBb.min() =
min(myBb.min(), coord);
63 myBb.max() =
max(myBb.max(), coord);
74 faceLabels_(mesh_.size()),
79 faceLabels_[faceI] = faceI;
95 faceLabels_(faceLabels),
96 allBb_(faceLabels.
size())
107 mesh_(shapes.mesh()),
108 faceLabels_(shapes.faceLabels()),
109 allBb_(shapes.allBb())
142 scalar tightestDist = GREAT;
144 label index = oc.
findNearest(sample, tightest, tightestDist);
150 "octreeDataFaceList::getSampleType"
151 "(octree<octreeDataFaceList>&, const point&)"
152 ) <<
"Could not find " << sample <<
" in octree."
156 label faceI = faceLabels_[index];
162 Pout<<
"getSampleType : sample:" << sample
163 <<
" nearest face:" << faceI;
166 const face& f = mesh_.localFaces()[faceI];
183 <<
" comparing to face normal " << mesh_.faceNormals()[faceI]
188 mesh_.faceNormals()[faceI],
208 if ((
mag(points[f[fp]] - curHit.
missPoint())/typDim) < tol)
214 Pout<<
" -> face point hit :" << points[f[fp]]
215 <<
" point normal:" << mesh_.pointNormals()[f[fp]]
222 mesh_.pointNormals()[f[fp]],
238 Pout<<
" -> centre hit:" << ctr
246 mesh_.faceNormals()[faceI],
256 const labelList& myEdges = mesh_.faceEdges()[faceI];
260 const edge&
e = mesh_.edges()[myEdges[myEdgeI]];
267 ).nearestDist(sample);
286 const labelList& myFaces = mesh_.edgeFaces()[myEdges[myEdgeI]];
292 edgeNormal += mesh_.faceNormals()[myFaces[myFaceI]];
297 Pout<<
" -> real edge hit point:" << edgePoint
298 <<
" comparing to edge normal:" << edgeNormal
325 ).nearestDist(sample);
342 label fpPrev = f.rcIndex(fp);
343 label fpNext = f.fcIndex(fp);
345 vector e = points[f[fp]] - ctr;
346 vector ePrev = points[f[fpPrev]] - ctr;
347 vector eNext = points[f[fpNext]] - ctr;
350 nLeft /=
mag(nLeft) + VSMALL;
352 vector nRight = e ^ eNext;
353 nRight /=
mag(nRight) + VSMALL;
357 Pout<<
" -> internal edge hit point:" << edgePoint
358 <<
" comparing to edge normal "
359 << 0.5*(nLeft + nRight)
367 0.5*(nLeft + nRight),
375 Pout<<
"Did not find sample " << sample
376 <<
" anywhere related to nearest face " << faceI <<
endl
381 Pout<<
" vertex:" << f[fp] <<
" coord:" << points[f[fp]]
401 return sampleBb.
overlaps(allBb_[index]);
413 "octreeDataFaceList::contains(const label, const point&)"
424 point& intersectionPoint
427 label faceI = faceLabels_[index];
429 const face& f = mesh_.localFaces()[faceI];
431 const vector dir(end - start);
450 intersectionPoint = inter.
hitPoint();
470 allBb_[index].calcExtremities(sample, myNear, myFar);
473 scalar myFarDist =
mag(dist);
475 point tightestNear, tightestFar;
478 scalar tightestFarDist =
mag(tightestFar - sample);
480 if (tightestFarDist < myFarDist)
488 const point dist2(fabs(dist.
x()), fabs(dist.
y()), fabs(dist.
z()));
490 tightest.
min() = sample - dist2;
491 tightest.
max() = sample + dist2;
506 label faceI = faceLabels_[index];
508 const face& f = mesh_.localFaces()[faceI];
512 vector vec = sample - ctr;
514 vec /=
mag(vec) + VSMALL;
516 return mesh_.faceNormals()[faceI] & vec;
528 label faceI = faceLabels_[index];
530 const face& f = mesh_.localFaces()[faceI];
547 scalar
sign = mesh_.faceNormals()[faceI] & (sample - nearest);
549 Pout<<
"octreeDataFaceList::calcNearest : "
550 <<
"sample:" << sample
551 <<
" faceI:" << faceI
554 <<
" nearest point:" << nearest
555 <<
" distance to face:" << nearHit.
distance()
568 os << faceLabels_[index] <<
" " << allBb_[index];