Skip to content
Snippets Groups Projects
Commit e6b5b528 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

GModel : getElementByCoord for a given dim (this fix dgFunctionevaluator when...

GModel : getElementByCoord for a given dim (this fix dgFunctionevaluator when the point is on the boundary)
parent cfdac4cf
No related branches found
No related tags found
No related merge requests found
......@@ -625,13 +625,13 @@ int GModel::getNumMeshElements(unsigned c[5])
return 0;
}
MElement *GModel::getMeshElementByCoord(SPoint3 &p)
MElement *GModel::getMeshElementByCoord(SPoint3 &p, int dim)
{
if(!_octree){
Msg::Debug("Rebuilding mesh element octree");
_octree = new MElementOctree(this);
}
return _octree->find(p.x(), p.y(), p.z());
return _octree->find(p.x(), p.y(), p.z(), dim);
}
MVertex *GModel::getMeshVertexByTag(int n)
......
......@@ -296,7 +296,7 @@ class GModel
int getNumMeshElements(unsigned c[5]);
// access a mesh element by coordinates (using an octree search)
MElement *getMeshElementByCoord(SPoint3 &p);
MElement *getMeshElementByCoord(SPoint3 &p, int dim = -1);
// access a mesh element by tag, using the element cache
MElement *getMeshElementByTag(int n);
......
......@@ -110,9 +110,19 @@ MElementOctree::~MElementOctree()
Octree_Delete(_octree);
}
MElement *MElementOctree::find(double x, double y, double z)
MElement *MElementOctree::find(double x, double y, double z, int dim)
{
double P[3] = {x, y, z};
return (MElement*)Octree_Search(P, _octree);
MElement *e = (MElement*)Octree_Search(P, _octree);
if (dim == -1 || !e || e->getDim() == dim)
return e;
std::list<void*> l;
Octree_SearchAll (P, _octree, &l);
for (std::list<void*>::iterator it = l.begin(); it != l.end(); it++) {
MElement *el = (MElement*) *it;
if (el->getDim() == dim)
return el;
}
return NULL;
}
......@@ -19,7 +19,7 @@ class MElementOctree{
MElementOctree(GModel *);
MElementOctree(std::vector<MElement*> &);
~MElementOctree();
MElement *find(double x, double y, double z);
MElement *find(double x, double y, double z, int dim = -1);
Octree *getInternalOctree(){ return _octree; }
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment