47 label& nearestTriangle,
55 const label cLabel = findLeafContainingVertex(
p);
59 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() = searchRange_;
63 const scalar
s = 0.75 * leaves_[cLabel]->size(rootBox_);
64 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() =
s;
79 findLeavesContainedInBox(bb, neighbours);
84 if( !neighbours[neiI]->hasContainedElements() )
88 neighbours[neiI]->slotPtr()->containedTriangles_;
89 const constRow el = ct[neighbours[neiI]->containedElements()];
100 nearestTriangle = el[tI];
101 region = surface_[el[tI]].region();
110 }
while( !
found && (iterationI++ < 100) );
117 if( distSq -
magSqr(pp -
p) > SMALL )
118 Pout <<
"Point " <<
p <<
" current nearest " << nearest
119 <<
" closer point " << pp <<
endl;
125 Warning <<
"Could not find a boundary region for vertex " <<
p <<
endl;
134 label& nearestTriangle,
143 "void meshOctree::findNearestSurfacePointInRegion(point&, scalar&,"
144 "label&, const label, const point&) const"
145 ) <<
"Region " << region <<
" is not valid!" <<
endl;
149 const label cLabel = findLeafContainingVertex(
p);
153 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() = searchRange_;
157 const scalar
s = 0.75 * leaves_[cLabel]->size(rootBox_);
158 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() =
s;
165 nearestTriangle = -1;
174 findLeavesContainedInBox(bb, neighbours);
179 if( !neighbours[neiI]->hasContainedElements() )
183 neighbours[neiI]->slotPtr()->containedTriangles_;
185 ct[neighbours[neiI]->containedElements()];
188 if( surface_[el[tI]].region() != region )
199 nearestTriangle = el[tI];
208 }
while( !
found && (iterationI++ < 5) );
211 Warning <<
"Could not find a boundary region for vertex " <<
p <<
endl;
224 const label cLabel = findLeafContainingVertex(
p);
228 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() = searchRange_;
232 const scalar
s = 0.75 * leaves_[cLabel]->size(rootBox_);
233 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() =
s;
238 const pointField& sPoints = surface_.points();
240 const VRWGraph& edgeFaces = surface_.edgeFacets();
243 bool foundAnEdge(
false);
256 findLeavesContainedInBox(bb, neighbours);
263 if( !neighbours[neiI]->hasContainedEdges() )
267 neighbours[neiI]->slotPtr()->containedEdges_;
269 containedEdges[neighbours[neiI]->containedEdges()];
277 const label edgeI = ce[eI];
280 bool correctPatches(
true);
284 const label facetI = edgeFaces(edgeI, efI);
286 if( !regions.
contains(surface_[facetI].region()) )
288 correctPatches =
false;
293 if( !correctPatches )
296 const edge&
e = edges[edgeI];
297 const point& sp = sPoints[
e.start()];
298 const point& ep = sPoints[
e.end()];
306 nearestEdge = ce[eI];
315 }
while( !foundAnEdge && (++iterationI < 3) );
329 const point c = 0.5 * (edgePoints[0] + edgePoints[1]);
330 const scalar dst =
mag(edgePoints[0] - edgePoints[1]);
331 vector sizeVec(dst, dst, dst);
333 boundBox bb(
c - 0.75 * sizeVec,
c + 0.75 * sizeVec);
336 findLeavesContainedInBox(bb, leavesInBox);
338 const VRWGraph& edgeFaces = surface_.edgeFacets();
347 forAll(leavesInBox, leafI)
349 if( !leavesInBox[leafI]->hasContainedEdges() )
353 leavesInBox[leafI]->slotPtr()->containedEdges_;
355 containedEdges[leavesInBox[leafI]->containedEdges()];
359 const constRow ef = edgeFaces[edges[eI]];
365 (surface_[ef[0]].region() == edgePointRegions[0]) &&
366 (surface_[ef[1]].region() == edgePointRegions[1])
369 (surface_[ef[1]].region() == edgePointRegions[0]) &&
370 (surface_[ef[0]].region() == edgePointRegions[1])
374 const edge& edg = surfaceEdges[edges[eI]];
376 point nearestOnEdge, nearestOnLine;
389 if(
magSqr(nearestOnEdge - nearestOnLine) < distSq )
391 nearest = nearestOnEdge;
392 nearestEdge = edges[eI];
393 distSq =
magSqr(nearestOnEdge - nearestOnLine);
415 const label cLabel = findLeafContainingVertex(
p);
419 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() = searchRange_;
423 const scalar
s = 0.75 * leaves_[cLabel]->size(rootBox_);
424 sizeVec.
x() = sizeVec.
y() = sizeVec.
z() =
s;
433 const VRWGraph& pEdges = surface_.pointEdges();
434 const VRWGraph& eFacets = surface_.edgeFacets();
444 findLeavesContainedInBox(bb, neighbours);
450 if( !neighbours[neiI]->hasContainedElements() )
454 neighbours[neiI]->slotPtr()->containedTriangles_;
455 const constRow el = ct[neighbours[neiI]->containedElements()];
462 const label spI = tri[pI];
464 if( checkedPoint.
found(spI) )
474 const label eI = pEdges(spI, i);
480 surface_[eFacets(eI, 0)].region() !=
481 surface_[eFacets(eI, 1)].region()
488 surface_[eFacets(eI, 0)].region()
492 surface_[eFacets(eI, 1)].region()
529 }
while( !
found && (iterationI++ < 3) );
556 this->findNearestSurfacePointInRegion