Bläddra i källkod

attempt to convince python to use bbw from main lib

Former-commit-id: 5c602c66bdfd75c28f6d80729979138030b47c3c
Alec Jacobson 8 år sedan
förälder
incheckning
7b92189fb8

+ 0 - 6
python/CMakeLists.txt

@@ -61,7 +61,6 @@ option(LIBIGL_WITH_EMBREE           "Use Embree"         ON)
 option(LIBIGL_WITH_LIM              "Use LIM"            ON)
 option(LIBIGL_WITH_MATLAB           "Use Matlab"         OFF)
 option(LIBIGL_WITH_MOSEK            "Use MOSEK"          OFF)
-option(LIBIGL_WITH_BBW              "Use BBW"            ON)
 option(LIBIGL_WITH_PNG              "Use PNG"            ON)
 option(LIBIGL_WITH_TETGEN           "Use Tetgen"         ON)
 option(LIBIGL_WITH_TRIANGLE         "Use Triangle"       ON)
@@ -120,11 +119,6 @@ if (LIBIGL_WITH_COPYLEFT)
   list(APPEND SHARED_SOURCES "modules/copyleft/py_igl_copyleft.cpp")
 endif ()
 
-if (LIBIGL_WITH_BBW)
-  add_definitions(-DPY_BBW)
-  list(APPEND SHARED_SOURCES "modules/py_igl_bbw.cpp")
-endif ()
-
 if (LIBIGL_WITH_PNG)
   add_definitions(-DPY_PNG)
   list(APPEND SHARED_SOURCES "modules/py_igl_png.cpp")

+ 2 - 2
python/modules/py_igl_bbw.cpp

@@ -5,7 +5,7 @@
 
 #include "../python_shared.h"
 
-#include <igl/bbw/bbw.h>
+#include <igl/bbw.h>
 
 
 void python_export_igl_bbw(py::module &me) {
@@ -13,6 +13,6 @@ 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"
+  #include "../py_igl/py_bbw.cpp"
 
 }

+ 1 - 1
python/py_doc.cpp

@@ -90,7 +90,7 @@ const char *__doc_igl_barycentric_to_global = R"igl_Qu8mg5v7(// Converts barycen
   // Output:
   // #X: #Xx3 3D coordinates of all points in bc
   //   )igl_Qu8mg5v7";
-const char *__doc_igl_bbw_bbw = R"igl_Qu8mg5v7(// Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
+const char *__doc_igl_bbw = R"igl_Qu8mg5v7(// Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
     // set of boundary conditions
     //
     // Templates

+ 1 - 1
python/py_doc.h

@@ -5,7 +5,7 @@ extern const char *__doc_igl_avg_edge_length;
 extern const char *__doc_igl_barycenter;
 extern const char *__doc_igl_barycentric_coordinates;
 extern const char *__doc_igl_barycentric_to_global;
-extern const char *__doc_igl_bbw_bbw;
+extern const char *__doc_igl_bbw;
 extern const char *__doc_igl_boundary_conditions;
 extern const char *__doc_igl_boundary_facets;
 extern const char *__doc_igl_boundary_loop;

+ 0 - 42
python/py_igl/bbw/py_bbw.cpp

@@ -1,42 +0,0 @@
-py::enum_<igl::bbw::QPSolver>(m, "QPSolver")
-    .value("QP_SOLVER_IGL_ACTIVE_SET", igl::bbw::QP_SOLVER_IGL_ACTIVE_SET)
-    .value("QP_SOLVER_MOSEK", igl::bbw::QP_SOLVER_MOSEK)
-    .value("NUM_QP_SOLVERS", igl::bbw::NUM_QP_SOLVERS)
-    .export_values();
-
-// Wrap the BBWData class
-py::class_<igl::bbw::BBWData > BBWData(m, "BBWData");
-
-BBWData
-.def(py::init<>())
-.def_readwrite("partition_unity", &igl::bbw::BBWData::partition_unity)
-.def_readwrite("W0", &igl::bbw::BBWData::W0)
-.def_readwrite("active_set_params", &igl::bbw::BBWData::active_set_params)
-.def_readwrite("qp_solver", &igl::bbw::BBWData::qp_solver)
-.def_readwrite("verbosity", &igl::bbw::BBWData::verbosity)
-#ifndef IGL_NO_MOSEK
-.def_readwrite("mosek_data", &igl::bbw::BBWData::mosek_data)
-#endif
-.def("print", [](igl::bbw::BBWData& data)
-{
-    return data.print();
-})
-;
-
-m.def("bbw", []
-(
-  const Eigen::MatrixXd& V,
-  const Eigen::MatrixXi& Ele,
-  const Eigen::MatrixXi& b,
-  const Eigen::MatrixXd& bc,
-  igl::bbw::BBWData& data,
-  Eigen::MatrixXd& W
-)
-{
-  assert_is_VectorX("b",b);
-  Eigen::VectorXi bv;
-  if (b.size() != 0)
-    bv = b;
-  return igl::bbw::bbw(V, Ele, bv, bc, data, W);
-}, __doc_igl_bbw_bbw,
-py::arg("V"), py::arg("Ele"), py::arg("b"), py::arg("bc"), py::arg("data"), py::arg("W"));

+ 32 - 0
python/py_igl/py_bbw.cpp

@@ -0,0 +1,32 @@
+// Wrap the BBWData class
+py::class_<iglData > BBWData(m, "BBWData");
+
+BBWData
+.def(py::init<>())
+.def_readwrite("partition_unity", &iglData::partition_unity)
+.def_readwrite("W0", &iglData::W0)
+.def_readwrite("active_set_params", &iglData::active_set_params)
+.def_readwrite("verbosity", &iglData::verbosity)
+.def("print", [](iglData& data)
+{
+    return data.print();
+})
+;
+
+m.def("bbw", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& Ele,
+  const Eigen::MatrixXi& b,
+  const Eigen::MatrixXd& bc,
+  iglData& data,
+  Eigen::MatrixXd& W
+)
+{
+  assert_is_VectorX("b",b);
+  Eigen::VectorXi bv;
+  if (b.size() != 0)
+    bv = b;
+  return igl(V, Ele, bv, bc, data, W);
+}, __doc_igl_bbw,
+py::arg("V"), py::arg("Ele"), py::arg("b"), py::arg("bc"), py::arg("data"), py::arg("W"));

+ 1 - 9
python/python_shared.cpp

@@ -38,10 +38,6 @@ extern void python_export_igl_copyleft(py::module &);
 extern void python_export_igl_png(py::module &);
 #endif
 
-#ifdef PY_BBW
-extern void python_export_igl_bbw(py::module &);
-#endif
-
 PYBIND11_PLUGIN(pyigl) {
     py::module m("pyigl", R"pyigldoc(
         Python wrappers for libigl
@@ -62,7 +58,7 @@ PYBIND11_PLUGIN(pyigl) {
            barycenter
            barycentric_coordinates
            barycentric_to_global
-           bbw_bbw
+           bbw
            boundary_conditions
            boundary_facets
            boundary_loop
@@ -193,9 +189,5 @@ PYBIND11_PLUGIN(pyigl) {
     python_export_igl_png(m);
     #endif
 
-    #ifdef PY_BBW
-    python_export_igl_bbw(m);
-    #endif
-
     return m.ptr();
 }

+ 0 - 8
python/scripts/python_shared.mako

@@ -38,10 +38,6 @@ extern void python_export_igl_copyleft(py::module &);
 extern void python_export_igl_png(py::module &);
 #endif
 
-#ifdef PY_BBW
-extern void python_export_igl_bbw(py::module &);
-#endif
-
 PYBIND11_PLUGIN(pyigl) {
     py::module m("pyigl", R"pyigldoc(
         Python wrappers for libigl
@@ -94,9 +90,5 @@ PYBIND11_PLUGIN(pyigl) {
     python_export_igl_png(m);
     #endif
 
-    #ifdef PY_BBW
-    python_export_igl_bbw(m);
-    #endif
-
     return m.ptr();
 }

+ 3 - 3
python/tutorial/403_BoundedBiharmonicWeights.py

@@ -6,7 +6,7 @@ import pyigl as igl
 
 from shared import TUTORIAL_SHARED_PATH, check_dependencies, print_usage
 
-dependencies = ["viewer", "bbw"]
+dependencies = ["viewer"]
 check_dependencies(dependencies)
 
 
@@ -117,11 +117,11 @@ if __name__ == "__main__":
     igl.boundary_conditions(V, T, C, igl.eigen.MatrixXi(), BE, igl.eigen.MatrixXi(), b, bc)
 
     # compute BBW weights matrix
-    bbw_data = igl.bbw.BBWData()
+    bbw_data = igl.BBWData()
     # only a few iterations for sake of demo
     bbw_data.active_set_params.max_iter = 8
     bbw_data.verbosity = 2
-    if not igl.bbw.bbw(V, T, b, bc, bbw_data, W):
+    if not igl.bbw(V, T, b, bc, bbw_data, W):
         exit(-1)
 
     # Normalize weights to sum to one