Loading [MathJax]/extensions/tex2jax.js
OGS
PartitionNodesByCoordinateMatch.cpp
Go to the documentation of this file.
1
13
14#include "GeoLib/AABB.h"
15#include "GeoLib/OctTree.h"
16#include "MeshLib/Node.h"
17
18namespace MeshToolsLib
19{
21 std::vector<MeshLib::Node*> const& node_vector,
22 std::vector<MeshLib::Node*> const& tool_node_vector,
23 GeoLib::AABB const& aabb,
24 bool const return_non_paired_nodes)
25{
26 auto oct_tree = std::unique_ptr<GeoLib::OctTree<MeshLib::Node, 16>>(
28 aabb.getMinPoint(), aabb.getMaxPoint(), 1e-16));
29
30 // Push all tool nodes into oct_tree:
31 for (auto const node : tool_node_vector)
32 {
33 MeshLib::Node* node_ptr = nullptr;
34 oct_tree->addPoint(node, node_ptr);
35 }
36
37 // Find the paired nodes in the node_vector
38 std::vector<MeshLib::Node*> paired_nodes;
39 std::vector<MeshLib::Node*> other_nodes;
40 std::vector<std::size_t> ip_mapping;
41 for (auto node : node_vector)
42 {
43 MeshLib::Node* node_ptr = nullptr;
44 if (oct_tree->addPoint(node, node_ptr))
45 {
46 if (return_non_paired_nodes)
47 {
48 other_nodes.push_back(node);
49 }
50 continue;
51 }
52 paired_nodes.push_back(node);
53 ip_mapping.push_back(node_ptr->getID());
54 }
55
56 if (return_non_paired_nodes)
57 {
58 return {paired_nodes, ip_mapping, other_nodes};
59 }
60
61 return {paired_nodes, std::nullopt, std::nullopt};
62}
63} // namespace MeshToolsLib
Definition of the AABB class.
Definition of the Node class.
Implementation of the OctTree class.
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition AABB.h:56
Eigen::Vector3d const & getMaxPoint() const
Definition AABB.h:187
Eigen::Vector3d const & getMinPoint() const
Definition AABB.h:180
static OctTree< POINT, MAX_POINTS > * createOctTree(Eigen::Vector3d ll, Eigen::Vector3d ur, double eps=std::numeric_limits< double >::epsilon())
std::size_t getID() const
NodesPartitionResult partitionNodesByCoordinateMatch(std::vector< MeshLib::Node * > const &node_vector, std::vector< MeshLib::Node * > const &tool_node_vector, GeoLib::AABB const &aabb, bool const return_non_paired_nodes)