47 void Foam::searchableSurfacesQueries::mergeHits
52 const List<pointIndexHit>& surfHits,
55 List<pointIndexHit>& allInfo,
66 surfDistSqr[i] =
magSqr(surfHits[i].hitPoint() - start);
71 label index =
findLower(allDistSqr, surfDistSqr[i]);
85 label next = index + 1;
87 if (next < allDistSqr.size())
97 label sz = allSurfaces.size();
98 allSurfaces.setSize(sz+1);
99 allInfo.setSize(allSurfaces.size());
100 allDistSqr.setSize(allSurfaces.size());
102 for (label j = sz-1; j > index; --j)
104 allSurfaces[j+1] = allSurfaces[j];
105 allInfo[j+1] = allInfo[j];
106 allDistSqr[j+1] = allDistSqr[j];
109 allSurfaces[index+1] = testI;
110 allInfo[index+1] = surfHits[i];
111 allDistSqr[index+1] = surfDistSqr[i];
131 hitSurfaces.
setSize(start.size());
141 forAll(surfacesToTest, testI)
144 allSurfaces[surfacesToTest[testI]].findLineAny(
p0, p1, intersectInfo);
150 if (intersectInfo[i].hit())
152 hitInfo[hitMap[i]] = intersectInfo[i];
153 hitSurfaces[hitMap[i]] = testI;
159 hitMap[newI] = hitMap[i];
177 intersectInfo.setSize(newI);
199 hitSurfaces.
setSize(start.size());
202 if (surfacesToTest.empty())
208 allSurfaces[surfacesToTest[0]].findLineAll(start,
end, hitInfo);
216 labelList& pSurfaces = hitSurfaces[pointi];
217 pSurfaces.
setSize(pHits.size());
221 pDistSqr.
setSize(pHits.size());
224 pDistSqr[i] =
magSqr(pHits[i].hitPoint() - start[pointi]);
229 if (surfacesToTest.size() > 1)
232 for (label testI = 1; testI < surfacesToTest.size(); testI++)
235 allSurfaces[surfacesToTest[testI]].findLineAll
277 surface1.
setSize(start.size());
286 forAll(surfacesToTest, testI)
289 allSurfaces[surfacesToTest[testI]].findLine
296 forAll(nearestInfo, pointi)
298 if (nearestInfo[pointi].hit())
300 hit1[pointi] = nearestInfo[pointi];
301 surface1[pointi] = testI;
302 nearest[pointi] = hit1[pointi].hitPoint();
319 if (hit1[pointi].hit())
321 nearest[pointi] = hit1[pointi].hitPoint();
326 nearest[pointi] =
end[pointi];
330 forAll(surfacesToTest, testI)
333 allSurfaces[surfacesToTest[testI]].findLine(
end, nearest, nearestInfo);
335 forAll(nearestInfo, pointi)
337 if (nearestInfo[pointi].hit())
339 hit2[pointi] = nearestInfo[pointi];
340 surface2[pointi] = testI;
341 nearest[pointi] = hit2[pointi].hitPoint();
360 if (
samples.size() != nearestDistSqr.size())
363 <<
" search-radius:" << nearestDistSqr.size()
369 nearestSurfaces = -1;
376 forAll(surfacesToTest, testI)
378 allSurfaces[surfacesToTest[testI]].findNearest
388 if (hitInfo[pointi].hit())
390 minDistSqr[pointi] =
magSqr
392 hitInfo[pointi].hitPoint()
395 nearestInfo[pointi] = hitInfo[pointi];
396 nearestSurfaces[pointi] = testI;
418 if (
samples.size() != nearestDistSqr.size())
421 <<
" search-radius:" << nearestDistSqr.size()
426 if (regionIndices.empty())
441 nearestSurfaces = -1;
448 forAll(surfacesToTest, testI)
450 allSurfaces[surfacesToTest[testI]].findNearest
454 regionIndices[testI],
461 if (hitInfo[pointi].hit())
463 minDistSqr[pointi] =
magSqr
465 hitInfo[pointi].hitPoint()
468 nearestInfo[pointi] = hitInfo[pointi];
469 nearestSurfaces[pointi] = testI;
490 if (start.size() != distSqr.size())
493 <<
" search-radius:" << distSqr.size()
501 allSurfaces[surfacesToTest[0]].findNearest(start, distSqr, info);
502 allSurfaces[surfacesToTest[0]].getNormal(info, normal);
510 near[i] = info[i].hitPoint();
515 constraint.
setSize(near.size());
521 constraint[i].applyConstraint(normal[i]);
525 if (surfacesToTest.size() >= 2)
532 for (label iter = 0; iter < nIter; iter++)
538 s.findNearest(near, distSqr, info);
539 s.getNormal(info, normal1);
551 if (
mag(normal[i]&normal1[i]) < 1.0-1
e-6)
553 plane pl0(near[i], normal[i],
false);
554 plane pl1(info[i].hitPoint(), normal1[i],
false);
560 vector d(r.refPoint()-near[i]);
564 scalar magD =
mag(d);
576 normal[i] = normal1[i];
577 constraint[i].applyConstraint(normal1[i]);
584 near[i] = info[i].hitPoint();
585 normal[i] = normal1[i];
586 constraint[i].applyConstraint(normal1[i]);
592 surfi = surfacesToTest.fcIndex(surfi);
629 forAll(surfacesToTest, testI)
634 forAll(nearestSurfaces, i)
636 if (nearestSurfaces[i] == testI)
639 surfIndices.append(i);
645 allSurfaces[surfacesToTest[testI]].getVolumeType(surfPoints, volType);
650 label pointi = surfIndices[i];
651 scalar dist =
mag(
samples[pointi] - nearestInfo[pointi].hitPoint());
665 switch (illegalHandling)
680 <<
"getVolumeType failure,"
681 <<
" neither INSIDE or OUTSIDE."
682 <<
" point:" << surfPoints[i]
684 << allSurfaces[surfacesToTest[testI]].name()
685 <<
" volType:" << vT.
str()
704 for (
const label surfi : surfacesToTest)
706 bb.
add(allSurfaces[surfi].bounds());