| 6 | using namespace PyMesh; |
| 7 | |
| 8 | void PyMesh::_CGAL::AABBTree::build() { |
| 9 | m_triangles.clear(); |
| 10 | assert(m_faces.cols() == 3); |
| 11 | |
| 12 | const size_t num_faces = m_faces.rows(); |
| 13 | for (size_t i=0; i<num_faces; i++) { |
| 14 | const auto& f = m_faces.row(i); |
| 15 | const auto& v0 = m_vertices.row(f[0]); |
| 16 | const auto& v1 = m_vertices.row(f[1]); |
| 17 | const auto& v2 = m_vertices.row(f[2]); |
| 18 | m_triangles.emplace_back( |
| 19 | Point(v0[0], v0[1], v0[2]), |
| 20 | Point(v1[0], v1[1], v1[2]), |
| 21 | Point(v2[0], v2[1], v2[2])); |
| 22 | } |
| 23 | |
| 24 | m_tree = std::make_shared<Tree>(m_triangles.begin(), m_triangles.end()); |
| 25 | m_tree->accelerate_distance_queries(); |
| 26 | } |
| 27 | |
| 28 | void PyMesh::_CGAL::AABBTree::lookup(const MatrixFr& points, |
| 29 | VectorF& squared_distances, |