mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user