diff --git a/MeshLib/MeshSubset.h b/MeshLib/MeshSubset.h index a7e79ae3d6d9981cb06d6662495a7a8292230936..6af8e35bdcea24b93d3adfa5c4615e2fceb386d0 100644 --- a/MeshLib/MeshSubset.h +++ b/MeshLib/MeshSubset.h @@ -91,6 +91,25 @@ public: return _msh.getElements().cend(); } + MeshSubset* + setIntersectionByNodes(std::vector<Node*> const& nodes) const + { + std::vector<Node*>* active_nodes = new std::vector<Node*>; + + if (_nodes == nullptr || _nodes->empty()) + return new MeshSubset(_msh, *active_nodes); // Empty mesh subset + + for (auto n : nodes) + { + auto it = std::find(_nodes->cbegin(), _nodes->cend(), n); + if (it == _nodes->cend()) + continue; + active_nodes->push_back(n); + } + + return new MeshSubset(_msh, *active_nodes); + } + private: const Mesh& _msh; std::vector<Node*> const* _nodes;