OGS
PartitionNodesByCoordinateMatch.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include "GeoLib/AABB.h"
7#include "GeoLib/OctTree.h"
8#include "MeshLib/Node.h"
9
10namespace MeshToolsLib
11{
13 std::vector<MeshLib::Node*> const& node_vector,
14 std::vector<MeshLib::Node*> const& tool_node_vector,
15 GeoLib::AABB const& aabb,
16 bool const return_non_paired_nodes)
17{
18 auto oct_tree = std::unique_ptr<GeoLib::OctTree<MeshLib::Node, 16>>(
20 aabb.getMinPoint(), aabb.getMaxPoint(), 1e-16));
21
22 // Push all tool nodes into oct_tree:
23 for (auto const node : tool_node_vector)
24 {
25 MeshLib::Node* node_ptr = nullptr;
26 oct_tree->addPoint(node, node_ptr);
27 }
28
29 // Find the paired nodes in the node_vector
30 std::vector<MeshLib::Node*> paired_nodes;
31 std::vector<MeshLib::Node*> other_nodes;
32 std::vector<std::size_t> ip_mapping;
33 for (auto node : node_vector)
34 {
35 MeshLib::Node* node_ptr = nullptr;
36 if (oct_tree->addPoint(node, node_ptr))
37 {
38 if (return_non_paired_nodes)
39 {
40 other_nodes.push_back(node);
41 }
42 continue;
43 }
44 paired_nodes.push_back(node);
45 ip_mapping.push_back(node_ptr->getID());
46 }
47
48 if (return_non_paired_nodes)
49 {
50 return {paired_nodes, ip_mapping, other_nodes};
51 }
52
53 return {paired_nodes, std::nullopt, std::nullopt};
54}
55} // namespace MeshToolsLib
Class AABB is an axis aligned bounding box around a given set of geometric points of (template) type ...
Definition AABB.h:45
Eigen::Vector3d const & getMaxPoint() const
Definition AABB.h:176
Eigen::Vector3d const & getMinPoint() const
Definition AABB.h:169
static OctTree< POINT, MAX_POINTS > * createOctTree(Eigen::Vector3d ll, Eigen::Vector3d ur, double eps=std::numeric_limits< double >::epsilon())
Definition OctTree-impl.h:7
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)