diff --git a/src/meshTools/indexedOctree/indexedOctree.C b/src/meshTools/indexedOctree/indexedOctree.C index 128e6bf60022d87775e783f483f33df792d445e4..1d444eff3dae4fe208ff2159ec1d0e5772395979 100644 --- a/src/meshTools/indexedOctree/indexedOctree.C +++ b/src/meshTools/indexedOctree/indexedOctree.C @@ -957,6 +957,7 @@ Foam::point Foam::indexedOctree<Type>::pushPointIntoFace } else if (nFaces == 1) { + // Point is on a single face keepFaceID = faceIndices[0]; } else @@ -1782,16 +1783,6 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findLine label i = 0; for (; i < 100000; i++) { - if (verbose) - { - Pout<< "iter:" << i - << " at startPoint:" << hitInfo.rawPoint() << endl - << " node:" << nodeI - << " octant:" << octant - << " bb:" << subBbox(nodeI, octant) << endl; - } - - // Ray-trace to end of current node. Updates point (either on triangle // in case of hit or on node bounding box in case of miss) @@ -1808,6 +1799,19 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findLine ) ); + if (verbose) + { + Pout<< "iter:" << i + << " at current:" << hitInfo.rawPoint() + << " (perturbed:" << startPoint << ")" << endl + << " node:" << nodeI + << " octant:" << octant + << " bb:" << subBbox(nodeI, octant) << endl; + } + + + + // Faces of current bounding box current point is on direction hitFaceID = 0; @@ -1833,12 +1837,23 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findLine break; } - if (hitFaceID == 0) + if (hitFaceID == 0 || hitInfo.rawPoint() == treeEnd) { // endpoint inside the tree. Return miss. break; } + // Create a point on other side of face. + point perturbedPoint + ( + pushPoint + ( + octantBb, + hitFaceID, + hitInfo.rawPoint(), + false // push outside of octantBb + ) + ); if (verbose) { @@ -1848,14 +1863,7 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findLine << " node:" << nodeI << " octant:" << octant << " bb:" << subBbox(nodeI, octant) << nl - << " walking to neighbour containing:" - << pushPoint - ( - octantBb, - hitFaceID, - hitInfo.rawPoint(), - false // push outside of octantBb - ) + << " walking to neighbour containing:" << perturbedPoint << endl; } @@ -1866,13 +1874,7 @@ Foam::pointIndexHit Foam::indexedOctree<Type>::findLine bool ok = walkToNeighbour ( - pushPoint - ( - octantBb, - hitFaceID, - hitInfo.rawPoint(), - false // push outside of octantBb - ), + perturbedPoint, hitFaceID, // face(s) that hitInfo is on nodeI,