44#include < nanobind/operators.h>
55#include < nanobind/stl/tuple.h>
66#include < nanobind/stl/vector.h>
7+ #include < tuple>
78
89#include " core/blender.cuh"
910#include " core/camera.cuh"
1011#include " core/confidence.cuh"
1112#include " core/fmb.cuh"
1213#include " core/geometry.cuh"
1314#include " core/image.cuh"
15+ #include " core/intersector.cuh"
1416#include " core/utils.cuh"
1517
1618namespace nb = nanobind;
@@ -24,6 +26,28 @@ void bind_image_view(nb::module_& m, const char* name);
2426
2527NB_MODULE (_genmetaballs_bindings, m) {
2628
29+ /*
30+ * Confidence module bindings
31+ */
32+
33+ nb::module_ confidence = m.def_submodule (" confidence" );
34+ nb::class_<ZeroParameterConfidence>(confidence, " ZeroParameterConfidence" )
35+ .def (nb::init<>())
36+ .def (" get_confidence" , &ZeroParameterConfidence::get_confidence, nb::arg (" sumexpd" ),
37+ " Get the confidence value for a given sumexpd" )
38+ .def (" __repr__" ,
39+ [](const ZeroParameterConfidence& c) { return nb::str (" ZeroParameterConfidence()" ); });
40+
41+ nb::class_<TwoParameterConfidence>(confidence, " TwoParameterConfidence" )
42+ .def (nb::init<float , float >())
43+ .def_ro (" beta4" , &TwoParameterConfidence::beta4)
44+ .def_ro (" beta5" , &TwoParameterConfidence::beta5)
45+ .def (" get_confidence" , &TwoParameterConfidence::get_confidence, nb::arg (" sumexpd" ),
46+ " Get the confidence value for a given sumexpd" )
47+ .def (" __repr__" , [](const TwoParameterConfidence& c) {
48+ return nb::str (" TwoParameterConfidence(beta4={}, beta5={})" ).format (c.beta4 , c.beta5 );
49+ });
50+
2751 /*
2852 * FMB module bindings
2953 */
@@ -38,6 +62,8 @@ NB_MODULE(_genmetaballs_bindings, m) {
3862 auto extent = self.get_extent ();
3963 return std::tuple{extent.x , extent.y , extent.z };
4064 })
65+ .def (" cov_inv_apply" , &FMB::cov_inv_apply,
66+ " apply the inverse covariance matrix to the given vector" , nb::arg (" vec" ))
4167 .def (" quadratic_form" , &FMB::quadratic_form,
4268 " Evaluate the associated quadratic form at the given vector" , nb::arg (" vec" ));
4369
@@ -85,9 +111,9 @@ NB_MODULE(_genmetaballs_bindings, m) {
85111 .def (" inv" , &Pose::inv, " Inverse pose" );
86112
87113 nb::class_<Ray>(geometry, " Ray" )
88- .def (nb::init<>())
89- .def_rw (" start" , &Ray::start)
90- .def_rw (" direction" , &Ray::direction);
114+ .def (nb::init<Vec3D, Vec3D >())
115+ .def_ro (" start" , &Ray::start)
116+ .def_ro (" direction" , &Ray::direction);
91117
92118 /*
93119 * Camera module bindings
@@ -116,26 +142,17 @@ NB_MODULE(_genmetaballs_bindings, m) {
116142 bind_image<MemoryLocation::DEVICE>(image, " GPUImage" );
117143
118144 /*
119- * Confidence module bindings
145+ * Intersector module bindings
120146 */
121147
122- nb::module_ confidence = m.def_submodule (" confidence" );
123- nb::class_<ZeroParameterConfidence>(confidence, " ZeroParameterConfidence" )
124- .def (nb::init<>())
125- .def (" get_confidence" , &ZeroParameterConfidence::get_confidence, nb::arg (" sumexpd" ),
126- " Get the confidence value for a given sumexpd" )
127- .def (" __repr__" ,
128- [](const ZeroParameterConfidence& c) { return nb::str (" ZeroParameterConfidence()" ); });
129-
130- nb::class_<TwoParameterConfidence>(confidence, " TwoParameterConfidence" )
131- .def (nb::init<float , float >())
132- .def_ro (" beta4" , &TwoParameterConfidence::beta4)
133- .def_ro (" beta5" , &TwoParameterConfidence::beta5)
134- .def (" get_confidence" , &TwoParameterConfidence::get_confidence, nb::arg (" sumexpd" ),
135- " Get the confidence value for a given sumexpd" )
136- .def (" __repr__" , [](const TwoParameterConfidence& c) {
137- return nb::str (" TwoParameterConfidence(beta4={}, beta5={})" ).format (c.beta4 , c.beta5 );
138- });
148+ nb::module_ intersector = m.def_submodule (" intersector" );
149+ intersector.def (
150+ " linear_intersect" ,
151+ [](const FMB& fmb, const Ray& ray, const Pose& cam_pose) {
152+ auto [t, d] = LinearIntersector::intersect (fmb, ray, cam_pose);
153+ return std::make_tuple (t, d);
154+ },
155+ " Linear intersection of ray and FMB." , nb::arg (" fmb" ), nb::arg (" ray" ), nb::arg (" cam_pose" ));
139156
140157 /*
141158 * Utils module bindings
0 commit comments