|
| 1 | +#include <pybind11/pybind11.h> |
| 2 | +#include <pybind11/stl.h> |
| 3 | +#include <pybind11/iostream.h> |
| 4 | +#include <pybind11/operators.h> |
| 5 | + |
| 6 | +#include <ipc/broad_phase/bvh.hpp> |
| 7 | + |
| 8 | +namespace py = pybind11; |
| 9 | +using namespace ipc; |
| 10 | + |
| 11 | +void define_bvh(py::module_& m) |
| 12 | +{ |
| 13 | + py::class_<BVH, BroadPhase>(m, "BVH") |
| 14 | + .def( |
| 15 | + "build", |
| 16 | + py::overload_cast< |
| 17 | + const Eigen::MatrixXd&, const Eigen::MatrixXi&, |
| 18 | + const Eigen::MatrixXi&, const double>(&BVH::build), |
| 19 | + R"ipc_Qu8mg5v7( |
| 20 | + Build the broad phase for static collision detection. |
| 21 | +
|
| 22 | + Parameters: |
| 23 | + V0: Positions of the vertices. |
| 24 | + E: Edges of the mesh. |
| 25 | + F: Faces of the mesh. |
| 26 | + inflation_radius: Radius of inflation around all elements. |
| 27 | + )ipc_Qu8mg5v7", |
| 28 | + py::arg("V"), py::arg("E"), py::arg("F"), |
| 29 | + py::arg("inflation_radius") = 0) |
| 30 | + .def( |
| 31 | + "build", |
| 32 | + py::overload_cast< |
| 33 | + const Eigen::MatrixXd&, const Eigen::MatrixXd&, |
| 34 | + const Eigen::MatrixXi&, const Eigen::MatrixXi&, const double>( |
| 35 | + &BVH::build), |
| 36 | + R"ipc_Qu8mg5v7( |
| 37 | + Build the broad phase for continuous collision detection. |
| 38 | +
|
| 39 | + Parameters: |
| 40 | + V0: Starting positions of the vertices. |
| 41 | + V1: Ending positions of the vertices. |
| 42 | + E: Edges of the mesh. |
| 43 | + F: Faces of the mesh. |
| 44 | + inflation_radius: Radius of inflation around all elements. |
| 45 | + )ipc_Qu8mg5v7", |
| 46 | + py::arg("V0"), py::arg("V1"), py::arg("E"), py::arg("F"), |
| 47 | + py::arg("inflation_radius") = 0) |
| 48 | + .def("clear", &BVH::clear, "Clear any built data.") |
| 49 | + .def( |
| 50 | + "detect_vertex_vertex_candidates", |
| 51 | + [](BVH& self) { |
| 52 | + std::vector<VertexVertexCandidate> candidates; |
| 53 | + self.detect_vertex_vertex_candidates(candidates); |
| 54 | + return candidates; |
| 55 | + }, |
| 56 | + R"ipc_Qu8mg5v7( |
| 57 | + Find the candidate vertex-vertex collisions. |
| 58 | +
|
| 59 | + Returns: |
| 60 | + The candidate vertex-vertex collisions. |
| 61 | + )ipc_Qu8mg5v7") |
| 62 | + .def( |
| 63 | + "detect_edge_vertex_candidates", |
| 64 | + [](BVH& self) { |
| 65 | + std::vector<EdgeVertexCandidate> candidates; |
| 66 | + self.detect_edge_vertex_candidates(candidates); |
| 67 | + return candidates; |
| 68 | + }, |
| 69 | + R"ipc_Qu8mg5v7( |
| 70 | + Find the candidate edge-vertex collisions. |
| 71 | +
|
| 72 | + Returns: |
| 73 | + The candidate edge-vertex collisions. |
| 74 | + )ipc_Qu8mg5v7") |
| 75 | + .def( |
| 76 | + "detect_edge_edge_candidates", |
| 77 | + [](BVH& self) { |
| 78 | + std::vector<EdgeEdgeCandidate> candidates; |
| 79 | + self.detect_edge_edge_candidates(candidates); |
| 80 | + return candidates; |
| 81 | + }, |
| 82 | + R"ipc_Qu8mg5v7( |
| 83 | + Find the candidate edge-edge collisions. |
| 84 | +
|
| 85 | + Returns: |
| 86 | + The candidate edge-edge collisions. |
| 87 | + )ipc_Qu8mg5v7") |
| 88 | + .def( |
| 89 | + "detect_face_vertex_candidates", |
| 90 | + [](BVH& self) { |
| 91 | + std::vector<FaceVertexCandidate> candidates; |
| 92 | + self.detect_face_vertex_candidates(candidates); |
| 93 | + return candidates; |
| 94 | + }, |
| 95 | + R"ipc_Qu8mg5v7( |
| 96 | + Find the candidate face-vertex collisions. |
| 97 | +
|
| 98 | + Returns: |
| 99 | + The candidate face-vertex collisions. |
| 100 | + )ipc_Qu8mg5v7") |
| 101 | + .def( |
| 102 | + "detect_edge_face_candidates", |
| 103 | + [](BVH& self) { |
| 104 | + std::vector<EdgeFaceCandidate> candidates; |
| 105 | + self.detect_edge_face_candidates(candidates); |
| 106 | + return candidates; |
| 107 | + }, |
| 108 | + R"ipc_Qu8mg5v7( |
| 109 | + Find the candidate edge-face intersections. |
| 110 | +
|
| 111 | + Returns: |
| 112 | + The candidate edge-face intersections. |
| 113 | + )ipc_Qu8mg5v7"); |
| 114 | +} |
0 commit comments