-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathhash_grid.cpp
More file actions
33 lines (29 loc) · 1.15 KB
/
hash_grid.cpp
File metadata and controls
33 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <common.hpp>
#include <ipc/broad_phase/hash_grid.hpp>
namespace py = pybind11;
using namespace ipc;
void define_hash_grid(py::module_& m)
{
py::class_<HashItem>(m, "HashItem")
.def(
py::init<int, int>(),
"Construct a hash item as a (key, value) pair.", py::arg("key"),
py::arg("id"))
.def(
"__lt__", &HashItem::operator<,
"Compare HashItems by their keys for sorting.", py::arg("other"))
.def_readwrite("key", &HashItem::key, "The key of the item.")
.def_readwrite("id", &HashItem::id, "The value of the item.");
py::class_<HashGrid, BroadPhase, std::shared_ptr<HashGrid>>(m, "HashGrid")
.def(py::init())
.def_property_readonly("cell_size", &HashGrid::cell_size)
.def_property_readonly(
"grid_size", &HashGrid::grid_size,
py::return_value_policy::reference)
.def_property_readonly(
"domain_min", &HashGrid::domain_min,
py::return_value_policy::reference)
.def_property_readonly(
"domain_max", &HashGrid::domain_max,
py::return_value_policy::reference);
}