41 void Foam::searchableBox::projectOntoCoordPlane
49 info.rawPoint()[dir] = planePt[dir];
51 if (planePt[dir] ==
min()[dir])
55 else if (planePt[dir] ==
max()[dir])
57 info.setIndex(dir*2+1);
62 <<
"Point on plane " << planePt
63 <<
" is not on coordinate " <<
min()[dir]
74 const scalar nearestDistSqr
97 if (info.rawPoint()[dir] <
min()[dir])
99 projectOntoCoordPlane(dir,
min(), info);
102 else if (info.rawPoint()[dir] >
max()[dir])
104 projectOntoCoordPlane(dir,
max(), info);
107 else if (info.rawPoint()[dir] > bbMid[dir])
109 near[dir] =
max()[dir];
113 near[dir] =
min()[dir];
129 projectOntoCoordPlane(
vector::X, near, info);
133 projectOntoCoordPlane(
vector::Z, near, info);
140 projectOntoCoordPlane(
vector::Y, near, info);
144 projectOntoCoordPlane(
vector::Z, near, info);
152 if (
magSqr(info.rawPoint() - sample) > nearestDistSqr)
164 Foam::searchableBox::searchableBox
173 if (!contains(midpoint()))
177 "Foam::searchableBox::searchableBox\n"
179 " const IOobject& io,\n"
180 " const treeBoundBox& bb\n"
182 ) <<
"Illegal bounding box specification : "
188 Foam::searchableBox::searchableBox
197 if (!contains(midpoint()))
201 "Foam::searchableBox::searchableBox\n"
203 " const IOobject& io,\n"
204 " const treeBoundBox& bb\n"
206 ) <<
"Illegal bounding box specification : "
222 if (regions_.empty())
225 regions_[0] =
"region0";
240 ctrs[i] = fcs[i].centre(pts);
249 const scalar nearestDistSqr
252 return findNearest(midpoint(), sample, nearestDistSqr);
259 const scalar nearestDistSqr
262 const point bbMid(midpoint());
266 bool outside =
false;
275 projectOntoCoordPlane(dir,
min(), info);
280 projectOntoCoordPlane(dir,
max(), info);
283 else if (info.
rawPoint()[dir] > bbMid[dir])
285 near[dir] =
max()[dir];
289 near[dir] =
min()[dir];
302 sortedDist[0] = dist[0];
303 sortedDist[1] = dist[1];
304 sortedDist[2] = dist[2];
308 projectOntoCoordPlane(sortedDist.
indices()[0], near, info);
310 projectOntoCoordPlane(sortedDist.
indices()[1], near, info);
335 "searchableBox::findNearest"
336 "(const linePointRef&, treeBoundBox&, point&)"
352 if (posBits(start) == 0)
354 if (posBits(end) == 0)
362 foundInter = intersects(end, start, info.
rawPoint());
368 foundInter = intersects(start, end, info.
rawPoint());
391 if (info.
index() == -1)
393 FatalErrorIn(
"searchableBox::findLine(const point&, const point&)")
395 <<
" on segment " << start << end
396 <<
" should be on face of " << *
this
411 return findLine(start, end);
415 void Foam::searchableBox::findNearest
424 const point bbMid(midpoint());
428 info[i] = findNearest(bbMid, samples[i], nearestDistSqr[i]);
444 info[i] = findLine(start[i], end[i]);
460 info[i] = findLineAny(start[i], end[i]);
488 +
vector(ROOTVSMALL,ROOTVSMALL,ROOTVSMALL)
503 while (((pt-start[pointI])&dirVec[pointI]) <= magSqrDirVec[pointI])
513 || (inter.
index() == hits[hits.
size()-1].index())
520 pt = inter.
hitPoint() + smallVec[pointI];
527 info[pointI].
clear();
578 const point& pt = points[pointI];
582 if (pt[dir] <
min()[dir] || pt[dir] >
max()[dir])
584 volType[pointI] = OUTSIDE;