diff --git a/MeshLib/Elements/Utils.h b/MeshLib/Elements/Utils.h new file mode 100644 index 0000000000000000000000000000000000000000..388a1d8bb01e999a97d22ba4ccab39e1e63aad57 --- /dev/null +++ b/MeshLib/Elements/Utils.h @@ -0,0 +1,43 @@ +/** + * \copyright + * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef MESHLIB_ELEMENTS_UTILS_H_ +#define MESHLIB_ELEMENTS_UTILS_H_ + +#include <algorithm> +#include <vector> + +#include "BaseLib/makeVectorUnique.h" +#include "MeshLib/Node.h" + +#include "Element.h" + +namespace MeshLib +{ +/// Returns a vector of node pointers containing the base nodes of the elements +/// input vector. +inline std::vector<Node*> getBaseNodes(std::vector<Element*> const& elements) +{ + std::vector<Node*> base_nodes; + base_nodes.reserve(elements.size() * 2); // Save some of the realloctions. + + for (auto* const e : elements) + { + std::copy(e->getNodes(), e->getNodes() + e->getNumberOfBaseNodes(), + std::back_inserter(base_nodes)); + } + + BaseLib::makeVectorUnique(base_nodes); + + return base_nodes; +} + +} // namespace MeshLib + +#endif // MESHLIB_ELEMENTS_UTILS_H_