Skip to content
Snippets Groups Projects
Commit e6304e56 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MeL] Move selectNodes to MeshSearcher.h.

parent 8ac12692
No related branches found
No related tags found
No related merge requests found
/**
* \copyright
* Copyright (c) 2012-2015, 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_COMPONENTSELECTOR_H_
#define MESHLIB_COMPONENTSELECTOR_H_
namespace MeshLib
{
/// Create a vector of unique nodes used by given elements.
inline
std::vector<MeshLib::Node*>
selectNodes(std::vector<MeshLib::Element*> const& elements)
{
std::set<MeshLib::Node*> nodes_set;
for (auto e : elements)
{
MeshLib::Node* const* nodes = e->getNodes();
unsigned const nnodes = e->getNNodes();
nodes_set.insert(nodes, nodes + nnodes);
}
std::vector<MeshLib::Node*> nodes;
nodes.reserve(nodes_set.size());
std::move(nodes_set.cbegin(), nodes_set.cend(),
std::back_inserter(nodes));
return nodes;
}
} // namespace MeshLib
#endif // MESHLIB_COMPONENTSELECTOR_H_
......@@ -49,5 +49,25 @@ std::vector<std::size_t> getConnectedNodeIDs(const std::vector<MeshLib::Element*
return connected_nodes;
}
std::vector<Node*>
selectNodes(std::vector<Element*> const& elements)
{
std::set<Node*> nodes_set;
for (auto e : elements)
{
Node* const* nodes = e->getNodes();
unsigned const nnodes = e->getNNodes();
nodes_set.insert(nodes, nodes + nnodes);
}
std::vector<Node*> nodes;
nodes.reserve(nodes_set.size());
std::move(nodes_set.cbegin(), nodes_set.cend(),
std::back_inserter(nodes));
return nodes;
}
} // end namespace MeshLib
......@@ -18,6 +18,7 @@ namespace MeshLib
// forward declarations
class Mesh;
class Element;
class Node;
/**
* get a vector of elements connected to given nodes
......@@ -34,6 +35,9 @@ std::vector<std::size_t> getConnectedElementIDs(MeshLib::Mesh const& msh, const
*/
std::vector<std::size_t> getConnectedNodeIDs(const std::vector<MeshLib::Element*> &elements);
/// Create a vector of unique nodes used by given elements.
std::vector<Node*> selectNodes(std::vector<Element*> const& elements);
} // end namespace MeshLib
#endif //MESHSEARCHER_H_
......@@ -14,7 +14,7 @@
#include "AssemblerLib/LocalToGlobalIndexMap.h"
#include "MeshLib/MeshGenerators/MeshGenerator.h"
#include "MeshLib/ComponentSelector.h"
#include "MeshLib/MeshSearcher.h"
#include "MeshLib/MeshSubsets.h"
#include "MeshLib/Mesh.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment