6#include <range/v3/algorithm/any_of.hpp>
7#include <range/v3/range/conversion.hpp>
8#include <range/v3/view/filter.hpp>
9#include <range/v3/view/take.hpp>
19template <
typename Container,
typename Predicate>
20std::vector<std::size_t>
filter(Container
const& container, Predicate
const& p)
22 return ranges::views::filter(container, p) |
views::ids |
23 ranges::to<std::vector>;
29 { return e->getGeomType() == eleType; });
32 return matchedIDs.size();
39 { return e->getContent() < eps; });
42 return matchedIDs.size();
53 return ranges::any_of(
54 e->nodes() | ranges::views::take(e->getNumberOfBaseNodes()),
55 [&aabb, invert](auto const* n)
56 { return (aabb.containsPoint(*n, 0) != invert); });
59 this->updateUnion(matchedIDs);
60 return matchedIDs.size();
64 const std::vector<std::size_t>& nodes)
66 std::vector<std::size_t> connected_elements;
67 for (std::size_t node_id : nodes)
69 auto const& elements =
_mesh.getElementsConnectedToNode(node_id);
70 std::transform(begin(elements), end(elements),
71 back_inserter(connected_elements),
78 return connected_elements.size();
86 vec_temp.resize(it - vec_temp.begin());
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
void updateUnion(const std::vector< std::size_t > &vec)
Updates the vector of marked elements with values from vec.
std::size_t searchByBoundingBox(GeoLib::AABB const &aabb, bool const invert=false)
std::size_t searchByElementType(MeshElemType eleType)
Marks all elements of the given element type.
std::size_t searchByNodeIDs(const std::vector< std::size_t > &nodes)
Marks all elements connecting to any of the given nodes.
std::size_t searchByContent(double eps=std::numeric_limits< double >::epsilon())
Marks all elements with a volume smaller than eps.
ElementSearch(const MeshLib::Mesh &mesh)
const MeshLib::Mesh & _mesh
The mesh from which elements should be removed.
std::vector< std::size_t > _marked_elements
The vector of element indices that should be removed.
std::size_t getID() const
Returns the ID of the element.
void makeVectorUnique(std::vector< T > &v)
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
std::vector< std::size_t > filter(Container const &container, Predicate const &p)
MeshElemType
Types of mesh elements supported by OpenGeoSys. Values are from VTKCellType enum.