mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
REVERT: Remove findNearestOpSubset from treeDataEdge and add to the application
This commit is contained in:
@ -105,17 +105,6 @@ Foam::treeDataEdge::findNearestOp::findNearestOp
|
||||
{}
|
||||
|
||||
|
||||
Foam::treeDataEdge::findNearestOpSubset::findNearestOpSubset
|
||||
(
|
||||
const indexedOctree<treeDataEdge>& tree,
|
||||
DynamicList<label>& shapeMask
|
||||
)
|
||||
:
|
||||
tree_(tree),
|
||||
shapeMask_(shapeMask)
|
||||
{}
|
||||
|
||||
|
||||
Foam::treeDataEdge::findIntersectOp::findIntersectOp
|
||||
(
|
||||
const indexedOctree<treeDataEdge>& tree
|
||||
@ -281,105 +270,6 @@ void Foam::treeDataEdge::findNearestOp::operator()
|
||||
}
|
||||
|
||||
|
||||
void Foam::treeDataEdge::findNearestOpSubset::operator()
|
||||
(
|
||||
const labelUList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
label& minIndex,
|
||||
point& nearestPoint
|
||||
) const
|
||||
{
|
||||
const treeDataEdge& shape = tree_.shapes();
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
const label index = indices[i];
|
||||
const label edgeIndex = shape.edgeLabels()[index];
|
||||
|
||||
if (!shapeMask_.empty() && findIndex(shapeMask_, edgeIndex) != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const edge& e = shape.edges()[edgeIndex];
|
||||
|
||||
pointHit nearHit = e.line(shape.points()).nearestDist(sample);
|
||||
|
||||
scalar distSqr = sqr(nearHit.distance());
|
||||
|
||||
if (distSqr < nearestDistSqr)
|
||||
{
|
||||
nearestDistSqr = distSqr;
|
||||
minIndex = index;
|
||||
nearestPoint = nearHit.rawPoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::treeDataEdge::findNearestOpSubset::operator()
|
||||
(
|
||||
const labelUList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
label& minIndex,
|
||||
point& linePoint,
|
||||
point& nearestPoint
|
||||
) const
|
||||
{
|
||||
const treeDataEdge& shape = tree_.shapes();
|
||||
|
||||
// Best so far
|
||||
scalar nearestDistSqr = magSqr(linePoint - nearestPoint);
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
const label index = indices[i];
|
||||
const label edgeIndex = shape.edgeLabels()[index];
|
||||
|
||||
if (!shapeMask_.empty() && findIndex(shapeMask_, edgeIndex) != -1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const edge& e = shape.edges()[edgeIndex];
|
||||
|
||||
// Note: could do bb test ? Worthwhile?
|
||||
|
||||
// Nearest point on line
|
||||
point ePoint, lnPt;
|
||||
scalar dist = e.line(shape.points()).nearestDist(ln, ePoint, lnPt);
|
||||
scalar distSqr = sqr(dist);
|
||||
|
||||
if (distSqr < nearestDistSqr)
|
||||
{
|
||||
nearestDistSqr = distSqr;
|
||||
minIndex = index;
|
||||
linePoint = lnPt;
|
||||
nearestPoint = ePoint;
|
||||
|
||||
{
|
||||
point& minPt = tightest.min();
|
||||
minPt = min(ln.start(), ln.end());
|
||||
minPt.x() -= dist;
|
||||
minPt.y() -= dist;
|
||||
minPt.z() -= dist;
|
||||
}
|
||||
{
|
||||
point& maxPt = tightest.max();
|
||||
maxPt = max(ln.start(), ln.end());
|
||||
maxPt.x() += dist;
|
||||
maxPt.y() += dist;
|
||||
maxPt.z() += dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::treeDataEdge::findIntersectOp::operator()
|
||||
(
|
||||
const label index,
|
||||
|
||||
@ -118,43 +118,6 @@ public:
|
||||
) const;
|
||||
};
|
||||
|
||||
class findNearestOpSubset
|
||||
{
|
||||
const indexedOctree<treeDataEdge>& tree_;
|
||||
|
||||
DynamicList<label>& shapeMask_;
|
||||
|
||||
public:
|
||||
|
||||
findNearestOpSubset
|
||||
(
|
||||
const indexedOctree<treeDataEdge>& tree,
|
||||
DynamicList<label>& shapeMask
|
||||
);
|
||||
|
||||
void operator()
|
||||
(
|
||||
const labelUList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
label& minIndex,
|
||||
point& nearestPoint
|
||||
) const;
|
||||
|
||||
//- Calculates nearest (to line) point in shape.
|
||||
// Returns point and distance (squared)
|
||||
void operator()
|
||||
(
|
||||
const labelUList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
label& minIndex,
|
||||
point& linePoint,
|
||||
point& nearestPoint
|
||||
) const;
|
||||
};
|
||||
|
||||
class findIntersectOp
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user