mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
String access of listofshape using regexp
This commit is contained in:
parent
43182c80cc
commit
c8939fa6d8
@ -1,6 +1,8 @@
|
|||||||
#ifdef NG_PYTHON
|
#ifdef NG_PYTHON
|
||||||
#ifdef OCCGEOMETRY
|
#ifdef OCCGEOMETRY
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include <../general/ngpython.hpp>
|
#include <../general/ngpython.hpp>
|
||||||
#include <core/python_ngcore.hpp>
|
#include <core/python_ngcore.hpp>
|
||||||
#include "../meshing/python_mesh.hpp"
|
#include "../meshing/python_mesh.hpp"
|
||||||
@ -1551,9 +1553,10 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
.def("__getitem__",[](const ListOfShapes & self, string name)
|
.def("__getitem__",[](const ListOfShapes & self, string name)
|
||||||
{
|
{
|
||||||
ListOfShapes selected;
|
ListOfShapes selected;
|
||||||
|
std::regex pattern(name);
|
||||||
for (auto s : self)
|
for (auto s : self)
|
||||||
if (auto sname = OCCGeometry::global_shape_properties[s.TShape()].name)
|
if (auto sname = OCCGeometry::global_shape_properties[s.TShape()].name)
|
||||||
if (sname == name)
|
if (std::regex_match(*sname, pattern))
|
||||||
selected.push_back(s);
|
selected.push_back(s);
|
||||||
return selected;
|
return selected;
|
||||||
}, "returns list of all shapes named 'name'")
|
}, "returns list of all shapes named 'name'")
|
||||||
|
Loading…
Reference in New Issue
Block a user