Lagrange
Loading...
Searching...
No Matches
PyEdgeAABBTree.h
1/*
2 * Copyright 2020 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/bvh/EdgeAABBTree.h>
15
16namespace lagrange::bvh {
17
21template <typename Scalar, typename Index, int Dim>
22class PyEdgeAABBTree
23{
24public:
25 using VertexArray = Eigen::Matrix<Scalar, Eigen::Dynamic, Dim, Eigen::RowMajor>;
26 using EdgeArray = Eigen::Matrix<Index, Eigen::Dynamic, 2, Eigen::RowMajor>;
28
29public:
30 PyEdgeAABBTree(const VertexArray& V, const EdgeArray& E)
31 : m_vertices(V)
32 , m_edges(E)
33 , m_tree(m_vertices, m_edges) {};
34
35 bool empty() const { return m_tree.empty(); }
36
37 void get_element_closest_point(
38 const typename Tree::RowVectorType& p,
39 typename Tree::Index element_id,
40 typename Tree::RowVectorType& closest_point,
41 typename Tree::Scalar& closest_sq_dist) const
42 {
43 m_tree.get_element_closest_point(p, element_id, closest_point, closest_sq_dist);
44 }
45
46 void foreach_element_in_radius(
47 const typename Tree::RowVectorType& p,
48 typename Tree::Scalar sq_dist,
49 typename Tree::ActionCallback func) const
50 {
51 m_tree.foreach_element_in_radius(p, sq_dist, func);
52 }
53
54 void foreach_element_containing(
55 const typename Tree::RowVectorType& p,
56 typename Tree::ActionCallback func) const
57 {
58 m_tree.foreach_element_containing(p, func);
59 }
60
61 void get_closest_point(
62 const typename Tree::RowVectorType& p,
63 typename Tree::Index& element_id,
64 typename Tree::RowVectorType& closest_point,
65 typename Tree::Scalar& closest_sq_dist) const
66 {
67 m_tree.get_closest_point(p, element_id, closest_point, closest_sq_dist);
68 }
69
70private:
71 VertexArray m_vertices;
72 EdgeArray m_edges;
73 Tree m_tree;
74};
75
76} // namespace lagrange::bvh
function_ref< void(Scalar, Index, const RowVectorType &)> ActionCallback
Definition EdgeAABBTree.h:45
Definition EdgeAABBTree.h:30