From d9c203b959c65dfca294f4e1b0e9baeb62e3d456 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 9 Sep 2008 17:13:33 +0100 Subject: [PATCH] extent also ensures 3Dness --- src/meshTools/octree/treeBoundBox.H | 1 + src/meshTools/octree/treeBoundBoxI.H | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/meshTools/octree/treeBoundBox.H b/src/meshTools/octree/treeBoundBox.H index 02dbac38af..1805d88b76 100644 --- a/src/meshTools/octree/treeBoundBox.H +++ b/src/meshTools/octree/treeBoundBox.H @@ -314,6 +314,7 @@ public: //- Return slightly wider bounding box // Extends all dimensions with s*span*Random::scalar01() + // and guarantees in any direction s*mag(span) minimum width inline treeBoundBox extend(Random&, const scalar s) const; // Friend Operators diff --git a/src/meshTools/octree/treeBoundBoxI.H b/src/meshTools/octree/treeBoundBoxI.H index c444b2808a..36143fedf1 100644 --- a/src/meshTools/octree/treeBoundBoxI.H +++ b/src/meshTools/octree/treeBoundBoxI.H @@ -437,7 +437,15 @@ inline treeBoundBox treeBoundBox::extend(Random& rndGen, const scalar s) const { treeBoundBox bb(*this); - const vector span(bb.max() - bb.min()); + vector span(bb.max() - bb.min()); + + // Make 3D + scalar magSpan = Foam::mag(span); + + for (direction dir = 0; dir < vector::nComponents; dir++) + { + span[dir] = Foam::max(s*magSpan, span[dir]); + } bb.min() -= cmptMultiply(s*rndGen.vector01(), span); bb.max() += cmptMultiply(s*rndGen.vector01(), span);