Commit e72d3202 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: use boundBox contains(), containsAny() methods

parent 24a96a21
......@@ -190,6 +190,7 @@ public:
vector normal(const pointField&) const;
//- Return face with reverse direction
// The starting points of the original and reverse face are identical.
face reverseFace() const;
//- Navigation through face vertices
......
......@@ -124,6 +124,7 @@ public:
inline label nTriangles() const;
//- Return face with reverse direction
// The starting points of the original and reverse face are identical.
inline triFace reverseFace() const;
//- Return swept-volume
......
......@@ -446,13 +446,9 @@ bool Foam::treeDataFace::overlaps
label faceI = faceLabels_[index];
const face& f = mesh_.faces()[faceI];
forAll(f, fp)
if (cubeBb.containsAny(points, f))
{
if (cubeBb.contains(points[f[fp]]))
{
return true;
}
return true;
}
// 3. Difficult case: all points are outside but connecting edges might
......
......@@ -433,12 +433,9 @@ overlaps
const pointField& points = patch_.points();
const face& f = patch_[index];
forAll(f, fp)
if (cubeBb.containsAny(points, f))
{
if (cubeBb.contains(points[f[fp]]))
{
return true;
}
return true;
}
// 3. Difficult case: all points are outside but connecting edges might
......
......@@ -268,17 +268,7 @@ bool Foam::treeDataTriSurface::overlaps
const pointField& points = surface_.points();
const labelledTri& f = surface_[index];
// Triangle points
const point& p0 = points[f[0]];
const point& p1 = points[f[1]];
const point& p2 = points[f[2]];
treeBoundBox triBb(p0, p0);
triBb.min() = min(triBb.min(), p1);
triBb.min() = min(triBb.min(), p2);
triBb.max() = max(triBb.max(), p1);
triBb.max() = max(triBb.max(), p2);
treeBoundBox triBb(points, surface_[index]);
//- For testing: robust one
//return cubeBb.overlaps(triBb);
......@@ -293,12 +283,17 @@ bool Foam::treeDataTriSurface::overlaps
}
// Check if one or more triangle point inside
if (cubeBb.contains(p0) || cubeBb.contains(p1) || cubeBb.contains(p2))
if (cubeBb.containsAny(points, f))
{
// One or more points inside
return true;
}
// Triangle points
const point& p0 = points[f[0]];
const point& p1 = points[f[1]];
const point& p2 = points[f[2]];
// Now we have the difficult case: all points are outside but connecting
// edges might go through cube. Use fast intersection of bounding box.
......@@ -422,13 +417,7 @@ bool Foam::treeDataTriSurface::intersects
const triSurface::FaceType& f = surface_[index];
// Do quick rejection test
treeBoundBox triBb(points[f[0]], points[f[0]]);
for (label ptI=1; ptI < f.size(); ++ptI)
{
triBb.min() = ::Foam::min(triBb.min(), points[f[ptI]]);
triBb.max() = ::Foam::max(triBb.max(), points[f[ptI]]);
}
treeBoundBox triBb(points, f);
const direction startBits(triBb.posBits(start));
const direction endBits(triBb.posBits(end));
......
......@@ -514,13 +514,9 @@ bool Foam::octreeDataFace::overlaps
const face& f = mesh_.faces()[faceI];
const pointField& points = mesh_.points();
forAll(f, fp)
if (sampleBb.containsAny(points, f))
{
if (sampleBb.contains(points[f[fp]]))
{
return true;
}
return true;
}
// 3. Difficult case: all points are outside but connecting edges might
......
......@@ -379,17 +379,16 @@ bool Foam::octreeDataTriSurface::overlaps
// Triangle points
const pointField& points = surface_.points();
const labelledTri& f = surface_[index];
const point& p0 = points[f[0]];
const point& p1 = points[f[1]];
const point& p2 = points[f[2]];
// Check if one or more triangle point inside
if (cubeBb.contains(p0) || cubeBb.contains(p1) || cubeBb.contains(p2))
if (cubeBb.containsAny(points, f))
{
// One or more points inside
return true;
}
const point& p0 = points[f[0]];
const point& p1 = points[f[1]];
const point& p2 = points[f[2]];
// Now we have the difficult case: all points are outside but connecting
// edges might go through cube. Use fast intersection of bounding box.
......
......@@ -31,20 +31,15 @@ License
#include "line.H"
#include "cpuTime.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const point triSurfaceSearch::greatPoint(GREAT, GREAT, GREAT);
const Foam::point Foam::triSurfaceSearch::greatPoint(GREAT, GREAT, GREAT);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from surface. Holds reference!
triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
Foam::triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
:
surface_(surface),
treePtr_(NULL)
......@@ -82,7 +77,10 @@ triSurfaceSearch::triSurfaceSearch(const triSurface& surface)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Determine inside/outside for samples
boolList triSurfaceSearch::calcInside(const pointField& samples) const
Foam::boolList Foam::triSurfaceSearch::calcInside
(
const pointField& samples
) const
{
boolList inside(samples.size());
......@@ -111,7 +109,7 @@ boolList triSurfaceSearch::calcInside(const pointField& samples) const
}
labelList triSurfaceSearch::calcNearestTri
Foam::labelList Foam::triSurfaceSearch::calcNearestTri
(
const pointField& samples,
const vector& span
......@@ -142,7 +140,7 @@ labelList triSurfaceSearch::calcNearestTri
// Nearest point on surface
tmp<pointField> triSurfaceSearch::calcNearest
Foam::tmp<Foam::pointField> Foam::triSurfaceSearch::calcNearest
(
const pointField& samples,
const vector& span
......@@ -173,8 +171,12 @@ tmp<pointField> triSurfaceSearch::calcNearest
}
pointIndexHit triSurfaceSearch::nearest(const point& pt, const vector& span)
const
Foam::pointIndexHit Foam::triSurfaceSearch::nearest
(
const point& pt,
const vector& span
)
const
{
const scalar nearestDistSqr = 0.25*magSqr(span);
......@@ -182,8 +184,4 @@ pointIndexHit triSurfaceSearch::nearest(const point& pt, const vector& span)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment