mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: treeDataEdge: Improved overlap accuracy of box and sphere.
Overlap of an edge with a boundBox is now evaluated using boundbox.intersect
This commit is contained in:
@ -44,7 +44,7 @@ int main(int argc, char *argv[])
|
||||
# include "createTime.H"
|
||||
# include "createMesh.H"
|
||||
|
||||
fileName sFeatFileName("unit_cube.extendedFeatureEdgeMesh");
|
||||
fileName sFeatFileName("unit_cube_rotated.extendedFeatureEdgeMesh");
|
||||
|
||||
extendedFeatureEdgeMesh efem
|
||||
(
|
||||
@ -87,21 +87,44 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
Info<< "Points: " << efem.points() << nl << endl;
|
||||
Info<< "Edges: " << efem.edges() << nl << endl;
|
||||
|
||||
Info<< "Find edge labels within sphere from point (0, 0, 0):" << endl;
|
||||
|
||||
Info<< " Radius = 0 : "
|
||||
Info<< " Radius = 0 : "
|
||||
<< edgeTree.findSphere(point(0, 0, 0), 0) << endl;
|
||||
|
||||
Info<< " Radius = 0.5 : "
|
||||
<< edgeTree.findSphere(point(0, 0, 0), 0.5) << endl;
|
||||
|
||||
Info<< " Radius = 1 : "
|
||||
Info<< " Radius = 1 : "
|
||||
<< edgeTree.findSphere(point(0, 0, 0), 1) << endl;
|
||||
|
||||
Info<< " Radius = 2 : "
|
||||
Info<< " Radius = root(1.5) : "
|
||||
<< edgeTree.findSphere(point(0, 0, 0), 1.5) << endl;
|
||||
|
||||
Info<< " Radius = root(2) : "
|
||||
<< edgeTree.findSphere(point(0, 0, 0), 2) << endl;
|
||||
|
||||
Info<< " Radius = root(0.5) : "
|
||||
<< edgeTree.findSphere(point(1, 0, 0), 0.5) << endl;
|
||||
|
||||
Info<< " Radius = root(0.25) : "
|
||||
<< edgeTree.findSphere(point(0, 0, 0.5), 0.25) << endl;
|
||||
|
||||
treeBoundBox tbb(point(0,0,0), point(0.1,0.1,0.1));
|
||||
Info<< " Box = " << tbb << " : "
|
||||
<< edgeTree.findBox(tbb) << endl;
|
||||
|
||||
treeBoundBox tbb1(point(0,0,0), point(1,1,0.1));
|
||||
Info<< " Box = " << tbb1 << " : "
|
||||
<< edgeTree.findBox(tbb1) << endl;
|
||||
|
||||
treeBoundBox tbb2(point(0.3,0,0), point(1,0.3,1));
|
||||
Info<< " Box = " << tbb2 << " : "
|
||||
<< edgeTree.findBox(tbb2) << endl;
|
||||
|
||||
treeBoundBox tbb3(point(-0.2,0.5,0), point(0.3,0.9,1));
|
||||
Info<< " Box = " << tbb3 << " : "
|
||||
<< edgeTree.findBox(tbb3) << endl;
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -128,14 +128,14 @@ bool Foam::treeDataEdge::overlaps
|
||||
const treeBoundBox& cubeBb
|
||||
) const
|
||||
{
|
||||
if (cacheBb_)
|
||||
{
|
||||
return cubeBb.overlaps(bbs_[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return cubeBb.overlaps(calcBb(edgeLabels_[index]));
|
||||
}
|
||||
const edge& e = edges_[edgeLabels_[index]];
|
||||
|
||||
const point& start = points_[e.start()];
|
||||
const point& end = points_[e.end()];
|
||||
|
||||
point intersect;
|
||||
|
||||
return cubeBb.intersects(start, end, intersect);
|
||||
}
|
||||
|
||||
|
||||
@ -147,14 +147,18 @@ bool Foam::treeDataEdge::overlaps
|
||||
const scalar radiusSqr
|
||||
) const
|
||||
{
|
||||
if (cacheBb_)
|
||||
const edge& e = edges_[edgeLabels_[index]];
|
||||
|
||||
const pointHit nearHit = e.line(points_).nearestDist(centre);
|
||||
|
||||
const scalar distSqr = sqr(nearHit.distance());
|
||||
|
||||
if (distSqr <= radiusSqr)
|
||||
{
|
||||
return bbs_[index].overlaps(centre, radiusSqr);
|
||||
}
|
||||
else
|
||||
{
|
||||
return calcBb(edgeLabels_[index]).overlaps(centre, radiusSqr);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user