OGS
getMeshElementsForMaterialIDs.cpp
Go to the documentation of this file.
1
13
14#include <range/v3/algorithm/contains.hpp>
15
17#include "MeshLib/Mesh.h"
18
19namespace MeshLib
20{
21std::vector<MeshLib::Element*> getMeshElementsForMaterialIDs(
22 MeshLib::Mesh const& mesh, std::vector<int> const& selected_material_ids)
23{
24 auto const material_ids = *materialIDs(mesh);
25 auto const& elements = mesh.getElements();
26 std::vector<MeshLib::Element*> selected_elements;
27
28 for (std::size_t i = 0; i < material_ids.size(); ++i)
29 {
30 if (ranges::contains(selected_material_ids, material_ids[i]))
31 {
32 selected_elements.push_back(elements[i]);
33 }
34 }
35 return selected_elements;
36}
37} // namespace MeshLib
Definition of the Element class.
Definition of the Mesh class.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
std::vector< MeshLib::Element * > getMeshElementsForMaterialIDs(MeshLib::Mesh const &mesh, std::vector< int > const &selected_material_ids)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:268