Browse Source

python module compilation fixes

Former-commit-id: 08f7f8cb6b39bc77f1794f50ca5e97acfa30e9a6
Daniele Panozzo 7 năm trước cách đây
mục cha
commit
6dbfe3861a
4 tập tin đã thay đổi với 22 bổ sung11 xóa
  1. 3 0
      .gitmodules
  2. 1 1
      python/CMakeLists.txt
  3. 11 3
      python/modules/py_igl_opengl_glfw.cpp
  4. 7 7
      python/tutorial/103_Events.py

+ 3 - 0
.gitmodules

@@ -28,3 +28,6 @@
 [submodule "external/eigen"]
 	path = external/eigen
 	url = https://github.com/eigenteam/eigen-git-mirror.git
+[submodule "external/pybind11"]
+	path = external/pybind11
+	url = https://github.com/pybind/pybind11

+ 1 - 1
python/CMakeLists.txt

@@ -23,7 +23,7 @@ if(UNIX)
 endif()
 
 ## include pybind
-set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/../external/nanogui/ext/pybind11 CACHE PATH "Path to pybind11")
+set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/../external/pybind11 CACHE PATH "Path to pybind11")
 add_subdirectory(${PYBIND11_DIR} pybind11)
 
 ## include libigl

+ 11 - 3
python/modules/py_igl_opengl_glfw.cpp

@@ -146,7 +146,7 @@ py::enum_<igl::opengl::MeshGL::DirtyFlags>(viewerdata_class, "DirtyFlags")
     .def_readwrite("points", &igl::opengl::ViewerData::points)
     .def_readwrite("labels_positions", &igl::opengl::ViewerData::labels_positions)
     .def_readwrite("labels_strings", &igl::opengl::ViewerData::labels_strings)
-    .def_readwrite("dirty", &igl::opengl::MeshGL::dirty)
+    // .def_readwrite("dirty", &igl::opengl::MeshGL::dirty)
     .def_readwrite("face_based", &igl::opengl::ViewerData::face_based)
     .def("serialize", [](igl::opengl::ViewerData& data)
     {
@@ -388,7 +388,7 @@ py::class_<igl::opengl::ViewerCore> viewercore_class(me, "ViewerCore");
     //   viewer.data() = data;
     // })
 
-    .def("data", &igl::opengl::glfw::Viewer::data)
+    .def("data", &igl::opengl::glfw::Viewer::data,pybind11::return_value_policy::reference)
 
     .def_readwrite("core", &igl::opengl::glfw::Viewer::core)
     //.def_readwrite("opengl", &igl::opengl::glfw::Viewer::opengl)
@@ -430,7 +430,15 @@ py::class_<igl::opengl::ViewerCore> viewercore_class(me, "ViewerCore");
       viewer.load_scene(str);
     })
 
-    .def("save_scene", &igl::opengl::glfw::Viewer::save_scene)
+    .def("save_scene", [](igl::opengl::glfw::Viewer& viewer)
+    {
+      viewer.save_scene();
+    })
+
+    .def("save_scene", [](igl::opengl::glfw::Viewer& viewer, std::string str)
+    {
+      viewer.save_scene(str);
+    })
 
     // Draw everything
     .def("draw", &igl::opengl::glfw::Viewer::draw)

+ 7 - 7
python/tutorial/103_Events.py

@@ -13,7 +13,7 @@ import pyigl as igl
 
 from shared import TUTORIAL_SHARED_PATH, check_dependencies
 
-dependencies = ["viewer"]
+dependencies = ["glfw"]
 check_dependencies(dependencies)
 
 
@@ -28,15 +28,15 @@ def key_pressed(viewer, key, modifier):
 
     if key == ord('1'):
         # # Clear should be called before drawing the mesh
-        viewer.data.clear()
+        viewer.data().clear()
         # # Draw_mesh creates or updates the vertices and faces of the displayed mesh.
         # # If a mesh is already displayed, draw_mesh returns an error if the given V and
         # # F have size different than the current ones
-        viewer.data.set_mesh(V1, F1)
+        viewer.data().set_mesh(V1, F1)
         viewer.core.align_camera_center(V1,F1)
     elif key == ord('2'):
-        viewer.data.clear()
-        viewer.data.set_mesh(V2, F2)
+        viewer.data().clear()
+        viewer.data().set_mesh(V2, F2)
         viewer.core.align_camera_center(V2,F2)
     return False
 
@@ -48,10 +48,10 @@ igl.readOFF(TUTORIAL_SHARED_PATH + "fertility.off", V2, F2)
 print("1 Switch to bump mesh")
 print("2 Switch to fertility mesh")
 
-viewer = igl.viewer.Viewer()
+viewer = igl.glfw.Viewer()
 
 # Register a keyboard callback that allows to switch between
 # the two loaded meshes
 viewer.callback_key_pressed = key_pressed
-viewer.data.set_mesh(V1, F1)
+viewer.data().set_mesh(V1, F1)
 viewer.launch()