Skip to content

Commit

Permalink
Allow retrieval of normal_and_curvature in python
Browse files Browse the repository at this point in the history
  • Loading branch information
aothms committed Jan 23, 2024
1 parent 3d15982 commit 97b9f95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions voxec.h
Original file line number Diff line number Diff line change
Expand Up @@ -2471,6 +2471,9 @@ class op_normal_estimate : public voxel_operation {

Eigen::MatrixXf points = Eigen::Map<Eigen::MatrixXf>(coords.data(), 3, coords.size() / 3).transpose();

// Eigen::RowVector3f it_as_vec((*it).get(0), (*it).get(1), (*it).get(2));
// Eigen::MatrixXf centered = points.rowwise() - it_as_vec;

Eigen::MatrixXf centered = points.rowwise() - points.colwise().mean();
Eigen::MatrixXf cov = centered.adjoint() * centered;
Eigen::SelfAdjointEigenSolver<Eigen::MatrixXf> eig(cov);
Expand Down
13 changes: 13 additions & 0 deletions wrap/wrapper.i
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@
uint32_t v;
$self->Get(ijk, &v);
return PyLong_FromLong(v);
} else if ($self->value_bits() == sizeof(normal_and_curvature<int16_t>) * 8) {
normal_and_curvature_t::storage_type v;
$self->Get(ijk, &v);
if (!v) {
return SWIG_Py_Void();
} else {
auto vf = v.convert<float>();
auto tup = PyTuple_New(4);
for (size_t i = 0; i < 4; ++i) {
PyTuple_SetItem(tup, i, PyFloat_FromDouble(vf.nxyz_curv[i]));
}
return tup;
}
} else {
throw std::runtime_error("Unsupported");
}
Expand Down

0 comments on commit 97b9f95

Please sign in to comment.