Merge remote-tracking branch 'upstream/master'

Former-commit-id: 231b465472
This commit is contained in:
Guillermo Lomas Rodríguez
2016-10-20 11:40:26 +02:00
94 changed files with 4115 additions and 234 deletions
+18
View File
@@ -0,0 +1,18 @@
//#include <Eigen/Geometry>
//#include <Eigen/Dense>
//#include <Eigen/Sparse>
#include "../python_shared.h"
#include <igl/bbw/bbw.h>
void python_export_igl_bbw(py::module &me) {
py::module m = me.def_submodule(
"bbw", "Wrappers for libigl functions that use bbw");
#include "../py_igl/bbw/py_bbw.cpp"
}
+13 -7
View File
@@ -188,9 +188,15 @@ py::class_<igl::viewer::ViewerCore> viewercore_class(me, "ViewerCore");
})
.def_readwrite("lighting_factor",&igl::viewer::ViewerCore::lighting_factor)
.def_readwrite("model_zoom",&igl::viewer::ViewerCore::model_zoom)
.def_property("trackball_angle",
[](const igl::viewer::ViewerCore& core) {return Eigen::Quaterniond(core.trackball_angle.cast<double>());},
[](igl::viewer::ViewerCore& core, const Eigen::Quaterniond& q)
{
core.trackball_angle = Eigen::Quaternionf(q.cast<float>());
})
.def_property("model_translation",
[](const igl::viewer::ViewerCore& core) {return Eigen::MatrixXd(core.model_translation.cast<double>());},
[](igl::viewer::ViewerCore& core, const Eigen::MatrixXd& v)
@@ -316,13 +322,13 @@ py::class_<igl::viewer::ViewerCore> viewercore_class(me, "ViewerCore");
// UI Enumerations
py::class_<igl::viewer::Viewer> viewer_class(me, "Viewer");
#ifdef IGL_VIEWER_WITH_NANOGUI
py::object fh = (py::object) py::module::import("nanogui").attr("FormHelper");
py::class_<nanogui::FormHelper> form_helper_class(me, "FormHelper", fh);
// #ifdef IGL_VIEWER_WITH_NANOGUI
// py::object fh = (py::object) py::module::import("nanogui").attr("FormHelper");
// py::class_<nanogui::FormHelper> form_helper_class(me, "FormHelper", fh);
py::object screen = (py::object) py::module::import("nanogui").attr("Screen");
py::class_<nanogui::Screen> screen_class(me, "Screen", screen);
#endif
// py::object screen = (py::object) py::module::import("nanogui").attr("Screen");
// py::class_<nanogui::Screen> screen_class(me, "Screen", screen);
// #endif
py::enum_<igl::viewer::Viewer::MouseButton>(viewer_class, "MouseButton")
.value("Left", igl::viewer::Viewer::MouseButton::Left)
+13
View File
@@ -0,0 +1,13 @@
py::class_<RotationList>(m, "RotationList")
.def(py::init<>())
.def(py::init<size_t>())
.def("pop_back", &RotationList::pop_back)
/* There are multiple versions of push_back(), etc. Select the right ones. */
.def("append", (void (RotationList::*)(const Eigen::Quaterniond &)) &RotationList::push_back)
.def("back", (Eigen::Quaterniond &(RotationList::*)()) &RotationList::back)
.def("__len__", [](const RotationList &v) { return v.size(); })
.def("__getitem__", [](const RotationList &v, int b) { return v.at(b); })
.def("__setitem__", [](RotationList &v, int b, Eigen::Quaterniond &c) { return v.at(b) = c; })
.def("__iter__", [](RotationList &v) {
return py::make_iterator(v.begin(), v.end());
}, py::keep_alive<0, 1>());
+5
View File
@@ -0,0 +1,5 @@
typedef std::vector<Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> > RotationList;
PYBIND11_MAKE_OPAQUE(RotationList);
//typedef std::vector<Eigen::Vector3d> TranslationList;
//PYBIND11_MAKE_OPAQUE(TranslationList);
+52 -9
View File
@@ -68,7 +68,7 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
})
.def("__init__", [](Type &m, py::buffer b) {
py::buffer_info info = b.request();
if (info.format != py::format_descriptor<Scalar>::value())
if (info.format != py::format_descriptor<Scalar>::value)
throw std::runtime_error("Incompatible buffer format!");
if (info.ndim == 1) {
new (&m) Type(info.shape[0], 1);
@@ -319,7 +319,7 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
m.data(), /* Pointer to buffer */
sizeof(Scalar), /* Size of one scalar */
/* Python struct-style format descriptor */
py::format_descriptor<Scalar>::value(),
py::format_descriptor<Scalar>::value,
2, /* Number of dimensions */
{ (size_t) m.rows(), /* Buffer dimensions */
(size_t) m.cols() },
@@ -692,10 +692,12 @@ void python_export_vector(py::module &m) {
.def("solve",[](const Eigen::SimplicialLLT<Eigen::SparseMatrix<double > >& s, const Eigen::MatrixXd& rhs) { return Eigen::MatrixXd(s.solve(rhs)); })
;
// Bindings for Affine3d
py::class_<Eigen::Affine3d > affine3d(me, "Affine3d");
affine3d
.def(py::init<>())
.def_static("Identity", []() { return Eigen::Affine3d::Identity(); })
.def("setIdentity",[](Eigen::Affine3d& a){
return a.setIdentity();
})
@@ -703,6 +705,9 @@ void python_export_vector(py::module &m) {
assert_is_Vector3("axis", axis);
return a.rotate(Eigen::AngleAxisd(angle, Eigen::Vector3d(axis)));
})
.def("rotate",[](Eigen::Affine3d& a, Eigen::Quaterniond quat) {
return a.rotate(quat);
})
.def("translate",[](Eigen::Affine3d& a, Eigen::MatrixXd offset) {
assert_is_Vector3("offset", offset);
return a.translate(Eigen::Vector3d(offset));
@@ -711,13 +716,51 @@ void python_export_vector(py::module &m) {
return Eigen::MatrixXd(a.matrix());
})
;
/* Bindings for Quaterniond*/
//py::class_<Eigen::Quaterniond > quaterniond(me, "Quaterniond");
//
// quaterniond
// .def(py::init<>())
// .def(py::init<double, double, double, double>())
// ;
// Bindings for Quaterniond
py::class_<Eigen::Quaterniond > quaterniond(me, "Quaterniond");
quaterniond
.def(py::init<>())
.def(py::init<double, double, double, double>())
.def("__init__", [](Eigen::Quaterniond &q, double angle, Eigen::MatrixXd axis) {
assert_is_Vector3("axis", axis);
new (&q) Eigen::Quaterniond(Eigen::AngleAxisd(angle, Eigen::Vector3d(axis)));
})
.def_static("Identity", []() { return Eigen::Quaterniond::Identity(); })
.def("__repr__", [](const Eigen::Quaterniond &v) {
std::ostringstream oss;
oss << "(" << v.w() << ", " << v.x() << ", " << v.y() << ", " << v.z() << ")";
return oss.str();
})
.def("conjugate",[](Eigen::Quaterniond& q) {
return q.conjugate();
})
.def("normalize",[](Eigen::Quaterniond& q) {
return q.normalize();
})
.def("slerp",[](Eigen::Quaterniond& q, double & t, Eigen::Quaterniond other) {
return q.slerp(t, other);
})
// .def_cast(-py::self)
// .def_cast(py::self + py::self)
// .def_cast(py::self - py::self)
.def_cast(py::self * py::self)
// .def_cast(py::self - Scalar())
// .def_cast(py::self * Scalar())
// .def_cast(py::self / Scalar())
// .def("__mul__", []
// (const Type &a, const Scalar& b)
// {
// return Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>(a * b);
// })
// .def("__rmul__", [](const Type& a, const Scalar& b)
// {
// return Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic>(b * a);
// })
;