45 const scalar nearestDistSqr
50 const vector n(sample-centre_);
53 if (nearestDistSqr >
sqr(magN-radius_))
55 if (magN < ROOTVSMALL)
57 info.rawPoint() = centre_ +
vector(1,0,0)/magN*radius_;
61 info.rawPoint() = centre_ + n/magN*radius_;
72 void Foam::searchableSphere::findLineAll
84 scalar magSqrDir =
magSqr(dir);
86 if (magSqrDir > ROOTVSMALL)
88 const vector toCentre(centre_-start);
89 scalar magSqrToCentre =
magSqr(toCentre);
93 scalar v = (toCentre & dir);
95 scalar disc =
sqr(radius_) - (magSqrToCentre -
sqr(v));
101 scalar nearParam = v-
d;
103 if (nearParam >= 0 &&
sqr(nearParam) <= magSqrDir)
106 near.setPoint(start + nearParam*dir);
110 scalar farParam = v+
d;
112 if (farParam >= 0 &&
sqr(farParam) <= magSqrDir)
115 far.setPoint(start + farParam*dir);
125 Foam::searchableSphere::searchableSphere
138 Foam::searchableSphere::searchableSphere
145 centre_(dict.
lookup(
"centre")),
160 if (regions_.empty())
163 regions_[0] =
"region0";
170 void Foam::searchableSphere::findNearest
181 info[i] = findNearest(samples[i], nearestDistSqr[i]);
200 findLineAll(start[i], end[i], info[i], b);
201 if (!info[i].hit() && b.
hit())
223 findLineAll(start[i], end[i], info[i], b);
224 if (!info[i].hit() && b.
hit())
232 void Foam::searchableSphere::findLineAll
244 findLineAll(start[i], end[i], near, far);
300 normal[i] = info[i].hitPoint() - centre_;
302 normal[i] /=
mag(normal[i])+VSMALL;
323 const point& pt = points[pointI];
325 if (
magSqr(pt - centre_) <=
sqr(radius_))
327 volType[pointI] = INSIDE;
331 volType[pointI] = OUTSIDE;