From 707fa19e39bd7d7d6efd2f487b01113da0524df0 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Mon, 10 Jun 2013 11:22:24 +0100
Subject: [PATCH] ENH: treeDataPrimitivePatch: exposed findIntersection

---
 .../indexedOctree/treeDataPrimitivePatch.C    | 140 +++++++++---------
 .../indexedOctree/treeDataPrimitivePatch.H    |  20 +--
 2 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C
index 7f2c7f93279..51e5252121a 100644
--- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C
+++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C
@@ -66,76 +66,6 @@ void Foam::treeDataPrimitivePatch<PatchType>::update()
 }
 
 
-template<class PatchType>
-bool Foam::treeDataPrimitivePatch<PatchType>::findIntersection
-(
-    const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
-    const label index,
-    const point& start,
-    const point& end,
-    point& intersectionPoint
-)
-{
-    const treeDataPrimitivePatch<PatchType>& shape = tree.shapes();
-    const PatchType& patch = shape.patch();
-
-    const pointField& points = patch.points();
-    const typename PatchType::FaceType& f = patch[index];
-
-    // Do quick rejection test
-    if (shape.cacheBb_)
-    {
-        const treeBoundBox& faceBb = shape.bbs_[index];
-
-        if ((faceBb.posBits(start) & faceBb.posBits(end)) != 0)
-        {
-            // start and end in same block outside of faceBb.
-            return false;
-        }
-    }
-
-    const vector dir(end - start);
-    pointHit inter;
-
-    if (f.size() == 3)
-    {
-        inter = triPointRef
-        (
-            points[f[0]],
-            points[f[1]],
-            points[f[2]]
-        ).intersection(start, dir, intersection::HALF_RAY, shape.planarTol_);
-    }
-    else
-    {
-        const pointField& faceCentres = patch.faceCentres();
-
-        inter = f.intersection
-        (
-            start,
-            dir,
-            faceCentres[index],
-            points,
-            intersection::HALF_RAY,
-            shape.planarTol_
-        );
-    }
-
-    if (inter.hit() && inter.distance() <= 1)
-    {
-        // Note: no extra test on whether intersection is in front of us
-        // since using half_ray
-        intersectionPoint = inter.hitPoint();
-
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
-
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 // Construct from components
@@ -700,4 +630,74 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findSelfIntersectOp::operator()
 }
 
 
+template<class PatchType>
+bool Foam::treeDataPrimitivePatch<PatchType>::findIntersection
+(
+    const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
+    const label index,
+    const point& start,
+    const point& end,
+    point& intersectionPoint
+)
+{
+    const treeDataPrimitivePatch<PatchType>& shape = tree.shapes();
+    const PatchType& patch = shape.patch();
+
+    const pointField& points = patch.points();
+    const typename PatchType::FaceType& f = patch[index];
+
+    // Do quick rejection test
+    if (shape.cacheBb_)
+    {
+        const treeBoundBox& faceBb = shape.bbs_[index];
+
+        if ((faceBb.posBits(start) & faceBb.posBits(end)) != 0)
+        {
+            // start and end in same block outside of faceBb.
+            return false;
+        }
+    }
+
+    const vector dir(end - start);
+    pointHit inter;
+
+    if (f.size() == 3)
+    {
+        inter = triPointRef
+        (
+            points[f[0]],
+            points[f[1]],
+            points[f[2]]
+        ).intersection(start, dir, intersection::HALF_RAY, shape.planarTol_);
+    }
+    else
+    {
+        const pointField& faceCentres = patch.faceCentres();
+
+        inter = f.intersection
+        (
+            start,
+            dir,
+            faceCentres[index],
+            points,
+            intersection::HALF_RAY,
+            shape.planarTol_
+        );
+    }
+
+    if (inter.hit() && inter.distance() <= 1)
+    {
+        // Note: no extra test on whether intersection is in front of us
+        // since using half_ray
+        intersectionPoint = inter.hitPoint();
+
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+
 // ************************************************************************* //
diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H
index 6cce11c7965..18c901244e5 100644
--- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H
+++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H
@@ -86,16 +86,6 @@ class treeDataPrimitivePatch
         //- Initialise all member data
         void update();
 
-        //- Find intersection of line with shapes
-        static bool findIntersection
-        (
-            const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
-            const label index,
-            const point& start,
-            const point& end,
-            point& intersectionPoint
-        );
-
 
 public:
 
@@ -260,6 +250,16 @@ public:
                 const point& centre,
                 const scalar radiusSqr
             ) const;
+
+            //- Helper: find intersection of line with shapes
+            static bool findIntersection
+            (
+                const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
+                const label index,
+                const point& start,
+                const point& end,
+                point& intersectionPoint
+            );
 };
 
 
-- 
GitLab