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 "createTime.H"
|
||||||
# include "createMesh.H"
|
# include "createMesh.H"
|
||||||
|
|
||||||
fileName sFeatFileName("unit_cube.extendedFeatureEdgeMesh");
|
fileName sFeatFileName("unit_cube_rotated.extendedFeatureEdgeMesh");
|
||||||
|
|
||||||
extendedFeatureEdgeMesh efem
|
extendedFeatureEdgeMesh efem
|
||||||
(
|
(
|
||||||
@ -87,21 +87,44 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< "Points: " << efem.points() << nl << endl;
|
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<< "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;
|
<< edgeTree.findSphere(point(0, 0, 0), 0) << endl;
|
||||||
|
|
||||||
Info<< " Radius = 0.5 : "
|
Info<< " Radius = 1 : "
|
||||||
<< edgeTree.findSphere(point(0, 0, 0), 0.5) << endl;
|
|
||||||
|
|
||||||
Info<< " Radius = 1 : "
|
|
||||||
<< edgeTree.findSphere(point(0, 0, 0), 1) << endl;
|
<< 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;
|
<< 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;
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -128,14 +128,14 @@ bool Foam::treeDataEdge::overlaps
|
|||||||
const treeBoundBox& cubeBb
|
const treeBoundBox& cubeBb
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (cacheBb_)
|
const edge& e = edges_[edgeLabels_[index]];
|
||||||
{
|
|
||||||
return cubeBb.overlaps(bbs_[index]);
|
const point& start = points_[e.start()];
|
||||||
}
|
const point& end = points_[e.end()];
|
||||||
else
|
|
||||||
{
|
point intersect;
|
||||||
return cubeBb.overlaps(calcBb(edgeLabels_[index]));
|
|
||||||
}
|
return cubeBb.intersects(start, end, intersect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -147,14 +147,18 @@ bool Foam::treeDataEdge::overlaps
|
|||||||
const scalar radiusSqr
|
const scalar radiusSqr
|
||||||
) const
|
) 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);
|
return true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return calcBb(edgeLabels_[index]).overlaps(centre, radiusSqr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user