From cba9a30d3d88ea10c24e507a1a28c323898f1fe5 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Fri, 27 Apr 2012 11:41:36 +0100
Subject: [PATCH] ENH: autoSnapDriverFeature: make bounding box 3D

---
 .../autoHexMeshDriver/autoSnapDriverFeature.C   | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C
index 2ebf0b140d2..6347d5dd16e 100644
--- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C
+++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -1202,10 +1202,23 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges
     // Reverse lookup : go through all edgeAttractors and find the
     // nearest point on pp
 
+    // Get search domain and extend it a bit
+    treeBoundBox bb(pp.localPoints());
+    {
+        // Random number generator. Bit dodgy since not exactly random ;-)
+        Random rndGen(65431);
+
+        // Slightly extended bb. Slightly off-centred just so on symmetric
+        // geometry there are less face/edge aligned items.
+        bb = bb.extend(rndGen, 1e-4);
+        bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
+        bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
+    }
+
     indexedOctree<treeDataPoint> ppTree
     (
         treeDataPoint(pp.localPoints()),
-        treeBoundBox(pp.localPoints()), // overall search domain
+        bb,                             // overall search domain
         8,                              // maxLevel
         10,                             // leafsize
         3.0                             // duplicity
-- 
GitLab