13#include <range/v3/algorithm/any_of.hpp>
14#include <range/v3/range/conversion.hpp>
15#include <range/v3/view/filter.hpp>
16#include <range/v3/view/take.hpp>
26template <
typename Container,
typename Predicate>
27std::vector<std::size_t>
filter(Container
const& container, Predicate
const& p)
29 return ranges::views::filter(container, p) |
views::ids |
30 ranges::to<std::vector>;
36 { return e->getGeomType() == eleType; });
39 return matchedIDs.size();
46 { return e->getContent() < eps; });
49 return matchedIDs.size();
60 return ranges::any_of(
61 e->nodes() | ranges::views::take(e->getNumberOfBaseNodes()),
62 [&aabb, invert](auto const* n)
63 { return (aabb.containsPoint(*n, 0) != invert); });
66 this->updateUnion(matchedIDs);
67 return matchedIDs.size();
70std::size_t ElementSearch::searchByNodeIDs(
71 const std::vector<std::size_t>& nodes)
73 std::vector<std::size_t> connected_elements;
74 for (std::size_t node_id : nodes)
76 auto const& elements = _mesh.getElementsConnectedToNode(node_id);
77 std::transform(begin(elements), end(elements),
78 back_inserter(connected_elements),
84 this->updateUnion(connected_elements);
85 return connected_elements.size();
88void ElementSearch::updateUnion(
const std::vector<std::size_t>& vec)
90 std::vector<std::size_t> vec_temp(vec.size() + _marked_elements.size());
91 auto it = std::set_union(vec.begin(), vec.end(), _marked_elements.begin(),
92 _marked_elements.end(), vec_temp.begin());
93 vec_temp.resize(it - vec_temp.begin());
94 _marked_elements.assign(vec_temp.begin(), vec_temp.end());
Definition of the Element class.
Definition of the Node class.
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 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::size_t getID() const
Returns the ID of the element.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
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.