https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: d270e8cb9b7ceccfa3083210e05739b2c88d8c27 authored by Christoph Lehmann on 13 October 2023, 09:04:02 UTC
Merge branch 'vtkdiff-field-data' into 'master'
Tip revision: d270e8c
getMeshElementsForMaterialIDs.cpp
/**
 * \file
 *
 * \copyright
 * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#include "getMeshElementsForMaterialIDs.h"

#include <range/v3/algorithm/contains.hpp>

#include "MeshLib/Elements/Element.h"
#include "MeshLib/Mesh.h"

namespace MeshLib
{
std::vector<MeshLib::Element*> getMeshElementsForMaterialIDs(
    MeshLib::Mesh const& mesh, std::vector<int> const& selected_material_ids)
{
    auto const material_ids = *materialIDs(mesh);
    auto const& elements = mesh.getElements();
    std::vector<MeshLib::Element*> selected_elements;

    for (std::size_t i = 0; i < material_ids.size(); ++i)
    {
        if (ranges::contains(selected_material_ids, material_ids[i]))
        {
            selected_elements.push_back(elements[i]);
        }
    }
    return selected_elements;
}
}  // namespace MeshLib
back to top