diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 3a85610fef..c3aebfac3e 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -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 diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index 7c47d887be..a9878d714c 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -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 diff --git a/src/meshTools/indexedOctree/treeDataFace.C b/src/meshTools/indexedOctree/treeDataFace.C index 7114781de7..7082af6049 100644 --- a/src/meshTools/indexedOctree/treeDataFace.C +++ b/src/meshTools/indexedOctree/treeDataFace.C @@ -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 diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C index 1267b1342f..9d214f3789 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C @@ -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 diff --git a/src/meshTools/indexedOctree/treeDataTriSurface.C b/src/meshTools/indexedOctree/treeDataTriSurface.C index 1bae779e5e..cdc995446c 100644 --- a/src/meshTools/indexedOctree/treeDataTriSurface.C +++ b/src/meshTools/indexedOctree/treeDataTriSurface.C @@ -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)); diff --git a/src/meshTools/octree/octreeDataFace.C b/src/meshTools/octree/octreeDataFace.C index b7b35c743d..6e7b6a7582 100644 --- a/src/meshTools/octree/octreeDataFace.C +++ b/src/meshTools/octree/octreeDataFace.C @@ -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 diff --git a/src/meshTools/triSurface/octreeData/octreeDataTriSurface.C b/src/meshTools/triSurface/octreeData/octreeDataTriSurface.C index 7f78f4c2a0..3fb046c55c 100644 --- a/src/meshTools/triSurface/octreeData/octreeDataTriSurface.C +++ b/src/meshTools/triSurface/octreeData/octreeDataTriSurface.C @@ -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. diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index 2555c75f82..1b4d7938ed 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -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 triSurfaceSearch::calcNearest +Foam::tmp Foam::triSurfaceSearch::calcNearest ( const pointField& samples, const vector& span @@ -173,8 +171,12 @@ tmp 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 - // ************************************************************************* //