diff --git a/wrappers/gmshpy/gmshGeo.i b/wrappers/gmshpy/gmshGeo.i index 6390afe4355942a9e2431f7538357c49ceddb10e..eaf5b4c9106a8b26e002805fd74430a1d9da3d97 100644 --- a/wrappers/gmshpy/gmshGeo.i +++ b/wrappers/gmshpy/gmshGeo.i @@ -97,4 +97,21 @@ namespace std { %include "gmshLevelset.h" %include "GeomMeshMatcher.h" - +%extend GModel { + %apply std::vector<double> &OUTPUT {std::vector<double> ¶mCoord} + std::vector<MElement*> getMeshElementsByCoords(const std::vector<double> &p, std::vector<double> ¶mCoord, int dim = -1, bool strict_ = true) + { + std::vector<MElement*> elements; + for (unsigned int i = 0; i < p.size()/3; i++){ + SPoint3 P(p[i * 3], p[i * 3 + 1], p[i * 3 + 2]); + MElement *e = $self->getMeshElementByCoord(P, dim, strict_); + double xyz[3] = {P.x(), P.y(), P.z()}, uvw[3] = {0., 0., 0.}; + e->xyz2uvw(xyz, uvw); + elements.push_back(e); + paramCoord.push_back(uvw[0]); + paramCoord.push_back(uvw[1]); + paramCoord.push_back(uvw[2]); + } + return elements; + } +}