ENH: Add extra octree functionality

+ Make intersection and nearest functions functors. This makes adding
  different intersection and nearest routines easier.
+ treeDataPrimitivePatch takes its tolerance as a constructor argument
+ Make treeDataTriSurface a typedef of treeDataPrimitivePatch

Conflicts:
	src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C
	src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
	src/meshTools/indexedOctree/treeDataTriSurface.C
This commit is contained in:
laurence
2013-03-15 12:38:57 +00:00
parent 24e36ddf3f
commit 8ed95d4750
22 changed files with 968 additions and 967 deletions

View File

@ -57,6 +57,24 @@ Foam::treeDataPoint::treeDataPoint
{}
Foam::treeDataPoint::findNearestOp::findNearestOp
(
const indexedOctree<treeDataPoint>& tree
)
:
tree_(tree)
{}
Foam::treeDataPoint::findIntersectOp::findIntersectOp
(
const indexedOctree<treeDataPoint>& tree
)
:
tree_(tree)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::pointField Foam::treeDataPoint::shapePoints() const
@ -115,9 +133,7 @@ bool Foam::treeDataPoint::overlaps
}
// Calculate nearest point to sample. Updates (if any) nearestDistSqr, minIndex,
// nearestPoint.
void Foam::treeDataPoint::findNearest
void Foam::treeDataPoint::findNearestOp::operator()
(
const labelUList& indices,
const point& sample,
@ -127,12 +143,19 @@ void Foam::treeDataPoint::findNearest
point& nearestPoint
) const
{
const treeDataPoint& shape = tree_.shapes();
forAll(indices, i)
{
const label index = indices[i];
label pointI = (useSubset_ ? pointLabels_[index] : index);
label pointI =
(
shape.useSubset()
? shape.pointLabels()[index]
: index
);
const point& pt = points_[pointI];
const point& pt = shape.points()[pointI];
scalar distSqr = magSqr(pt - sample);
@ -146,9 +169,7 @@ void Foam::treeDataPoint::findNearest
}
//- Calculates nearest (to line) point in shape.
// Returns point and distance (squared)
void Foam::treeDataPoint::findNearest
void Foam::treeDataPoint::findNearestOp::operator()
(
const labelUList& indices,
const linePointRef& ln,
@ -159,6 +180,8 @@ void Foam::treeDataPoint::findNearest
point& nearestPoint
) const
{
const treeDataPoint& shape = tree_.shapes();
// Best so far
scalar nearestDistSqr = GREAT;
if (minIndex >= 0)
@ -169,9 +192,14 @@ void Foam::treeDataPoint::findNearest
forAll(indices, i)
{
const label index = indices[i];
label pointI = (useSubset_ ? pointLabels_[index] : index);
label pointI =
(
shape.useSubset()
? shape.pointLabels()[index]
: index
);
const point& shapePt = points_[pointI];
const point& shapePt = shape.points()[pointI];
if (tightest.contains(shapePt))
{
@ -206,4 +234,21 @@ void Foam::treeDataPoint::findNearest
}
bool Foam::treeDataPoint::findIntersectOp::operator()
(
const label index,
const point& start,
const point& end,
point& result
) const
{
notImplemented
(
"treeDataPoint::intersects(const label, const point&,"
"const point&, point&)"
);
return false;
}
// ************************************************************************* //