From b3b7d823cebb1bad92434b90ebdefefafea591d1 Mon Sep 17 00:00:00 2001 From: Dmitrij Naumov <dmitrij@naumov.de> Date: Fri, 16 Sep 2016 16:45:45 +0200 Subject: [PATCH] [MeL] Add getBaseNodes() collecting nodes from elements. The vector is filled with pointers to base nodes. --- MeshLib/Elements/Utils.h | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 MeshLib/Elements/Utils.h diff --git a/MeshLib/Elements/Utils.h b/MeshLib/Elements/Utils.h new file mode 100644 index 00000000000..388a1d8bb01 --- /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_ -- GitLab