From ade949110f94575006792646e0de00755fdc67b3 Mon Sep 17 00:00:00 2001
From: Matti Pellika <matti.pellikka@tut.fi>
Date: Tue, 13 Dec 2011 15:22:01 +0000
Subject: [PATCH] Added a function to find all mesh elements by coordinates.

---
 Geo/GModel.cpp | 8 ++++++++
 Geo/GModel.h   | 1 +
 2 files changed, 9 insertions(+)

diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index 18245e2c76..42625d1f57 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -697,6 +697,14 @@ MElement *GModel::getMeshElementByCoord(SPoint3 &p, int dim)
   }
   return _octree->find(p.x(), p.y(), p.z(), dim);
 }
+std::vector<MElement*> GModel::getMeshElementsByCoord(SPoint3 &p, int dim)
+{
+  if(!_octree){
+    Msg::Debug("Rebuilding mesh element octree");
+    _octree = new MElementOctree(this);
+  }
+  return _octree->findAll(p.x(), p.y(), p.z(), dim);
+}
 
 MVertex *GModel::getMeshVertexByTag(int n)
 {
diff --git a/Geo/GModel.h b/Geo/GModel.h
index e345f19f02..adf35614b3 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -297,6 +297,7 @@ class GModel
 
   // access a mesh element by coordinates (using an octree search)
   MElement *getMeshElementByCoord(SPoint3 &p, int dim = -1);
+  std::vector<MElement*> getMeshElementsByCoord(SPoint3 &p, int dim = -1);
 
   // access a mesh element by tag, using the element cache
   MElement *getMeshElementByTag(int n);
-- 
GitLab