21 template <
typename Container,
typename Predicate>
22 std::vector<std::size_t>
filter(Container
const& container, Predicate
const& p)
24 std::vector<std::size_t> matchedIDs;
26 for (
auto value : container)
30 matchedIDs.push_back(i);
40 { return e->getGeomType() == eleType; });
43 return matchedIDs.size();
49 { return e->getContent() < eps; });
52 return matchedIDs.size();
61 std::size_t const nElemNodes(e->getNumberOfBaseNodes());
62 for (std::size_t n = 0; n < nElemNodes; ++n)
64 if (aabb.containsPoint(*e->getNode(n), 0))
72 this->updateUnion(matchedIDs);
73 return matchedIDs.size();
76 std::size_t ElementSearch::searchByNodeIDs(
77 const std::vector<std::size_t>& nodes)
79 std::vector<std::size_t> connected_elements;
80 for (std::size_t node_id : nodes)
82 auto const& elements = _mesh.getElementsConnectedToNode(node_id);
83 std::transform(begin(elements), end(elements),
84 back_inserter(connected_elements),
90 this->updateUnion(connected_elements);
91 return connected_elements.size();
94 void ElementSearch::updateUnion(
const std::vector<std::size_t>& vec)
96 std::vector<std::size_t> vec_temp(vec.size() + _marked_elements.size());
97 auto it = std::set_union(vec.begin(), vec.end(), _marked_elements.begin(),
98 _marked_elements.end(), vec_temp.begin());
99 vec_temp.resize(it - vec_temp.begin());
100 _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 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)
std::size_t searchByBoundingBox(GeoLib::AABB const &aabb)
Marks all elements with at least one node outside the bounding box spanned by x1 and x2;.
const MeshLib::Mesh & _mesh
The mesh from which elements should be removed.
virtual std::size_t getID() const final
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)
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.