fixed examples

master
Ugo Finnendahl 3 years ago
parent 8732beba6c
commit b32b00113b
  1. 8
      examples/main.py
  2. 191
      examples/test.ipynb

@ -1,7 +1,4 @@
import pybindmagic
import os
os.environ["PATH"] = "/home/ugo/anaconda3/bin" + os.pathsep + os.environ["PATH"]
#%%
%%cpp -f generateMesh
#include <pybind11/eigen.h>
@ -85,13 +82,13 @@ defs
printMesh(*generateMesh())
#%%
%%cpp -c pathtocmake -f viewMesh
%%cpp -c pathtocmake -f viewMeshh
#include <igl/opengl/glfw/Viewer.h>
#include <pybind11/eigen.h>
void viewMesh(Eigen::Matrix<double, Eigen::Dynamic, 3> V, Eigen::Matrix<int, Eigen::Dynamic, 3> F)
void viewMeshh(Eigen::Matrix<double, Eigen::Dynamic, 3> V, Eigen::Matrix<int, Eigen::Dynamic, 3> F)
{
// Plot the mesh
igl::opengl::glfw::Viewer viewer;
@ -100,7 +97,6 @@ void viewMesh(Eigen::Matrix<double, Eigen::Dynamic, 3> V, Eigen::Matrix<int, Eig
viewer.launch();
}
#%%
import numpy as np
V = np.array([

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -11,14 +11,13 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%cpp -f generateMesh\n",
"#include <pybind11/eigen.h>\n",
"\n",
"\n",
"std::tuple<Eigen::MatrixXd,Eigen::MatrixXi> generateMesh()\n",
"{\n",
" // Inline mesh of a cube\n",
@ -50,38 +49,11 @@
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Vertices:\n",
" [[0. 0. 0.]\n",
" [0. 0. 1.]\n",
" [0. 1. 0.]\n",
" [0. 1. 1.]\n",
" [1. 0. 0.]\n",
" [1. 0. 1.]\n",
" [1. 1. 0.]\n",
" [1. 1. 1.]]\n",
"Faces:\n",
" [[0 6 4]\n",
" [0 2 6]\n",
" [0 3 2]\n",
" [0 1 3]\n",
" [2 7 6]\n",
" [2 3 7]\n",
" [4 6 7]\n",
" [4 7 5]\n",
" [0 4 5]\n",
" [0 5 1]\n",
" [1 5 7]\n",
" [1 7 3]]\n"
]
}
],
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"V,F = generateMesh()\n",
"print(\"Vertices:\\n\",V)\n",
@ -90,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@ -139,38 +111,9 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Vertices:\n",
" [[0. 0. 0.]\n",
" [0. 0. 1.]\n",
" [0. 1. 0.]\n",
" [0. 1. 1.]\n",
" [1. 0. 0.]\n",
" [1. 0. 1.]\n",
" [1. 1. 0.]\n",
" [1. 1. 1.]]\n",
"Faces:\n",
" [[0 6 4]\n",
" [0 2 6]\n",
" [0 3 2]\n",
" [0 1 3]\n",
" [2 7 6]\n",
" [2 3 7]\n",
" [4 6 7]\n",
" [4 7 5]\n",
" [0 4 5]\n",
" [0 5 1]\n",
" [1 5 7]\n",
" [1 7 3]]\n"
]
}
],
"outputs": [],
"source": [
"printMesh(*generateMesh())"
]
@ -198,95 +141,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cmake:\n",
"-- The CXX compiler identification is GNU 9.3.0\n",
"-- Check for working CXX compiler: /usr/bin/c++\n",
"-- Check for working CXX compiler: /usr/bin/c++ -- works\n",
"-- Detecting CXX compiler ABI info\n",
"-- Detecting CXX compiler ABI info - done\n",
"-- Detecting CXX compile features\n",
"-- Detecting CXX compile features - done\n",
"-- Found Python: /home/ugo/anaconda3/bin/python3.7 (found version \"3.7.6\") found components: Interpreter Development \n",
"-- pybind11 v2.6.3 dev1\n",
"-- Performing Test HAS_FLTO\n",
"-- Performing Test HAS_FLTO - Success\n",
"-- Looking for C++ include pthread.h\n",
"-- Looking for C++ include pthread.h - found\n",
"-- Performing Test CMAKE_HAVE_LIBC_PTHREAD\n",
"-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed\n",
"-- Looking for pthread_create in pthreads\n",
"-- Looking for pthread_create in pthreads - not found\n",
"-- Looking for pthread_create in pthread\n",
"-- Looking for pthread_create in pthread - found\n",
"-- Found Threads: TRUE \n",
"-- Creating target: igl::core (igl)\n",
"-- Creating target: igl::opengl (igl_opengl)\n",
"-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so found components: OpenGL \n",
"-- The C compiler identification is GNU 9.3.0\n",
"-- Check for working C compiler: /usr/bin/cc\n",
"-- Check for working C compiler: /usr/bin/cc -- works\n",
"-- Detecting C compiler ABI info\n",
"-- Detecting C compiler ABI info - done\n",
"-- Detecting C compile features\n",
"-- Detecting C compile features - done\n",
"-- Creating target: igl::opengl_glfw (igl_opengl_glfw)\n",
"-- Using X11 for window creation\n",
"-- Found X11: /usr/include \n",
"-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so\n",
"-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found\n",
"-- Looking for gethostbyname\n",
"-- Looking for gethostbyname - found\n",
"-- Looking for connect\n",
"-- Looking for connect - found\n",
"-- Looking for remove\n",
"-- Looking for remove - found\n",
"-- Looking for shmat\n",
"-- Looking for shmat - found\n",
"-- Looking for IceConnectionNumber in ICE\n",
"-- Looking for IceConnectionNumber in ICE - found\n",
"-- Configuring done\n",
"-- Generating done\n",
"-- Build files have been written to: /home/ugo/work/pybindipynb/examples/pathtocmake/build\n",
"\n",
"make:\n",
"Scanning dependencies of target glad\n",
"[ 4%] Building C object glad/CMakeFiles/glad.dir/src/glad.c.o\n",
"[ 9%] Linking C static library libglad.a\n",
"[ 9%] Built target glad\n",
"Scanning dependencies of target glfw\n",
"[ 14%] Building C object glfw/src/CMakeFiles/glfw.dir/context.c.o\n",
"[ 19%] Building C object glfw/src/CMakeFiles/glfw.dir/init.c.o\n",
"[ 23%] Building C object glfw/src/CMakeFiles/glfw.dir/input.c.o\n",
"[ 28%] Building C object glfw/src/CMakeFiles/glfw.dir/monitor.c.o\n",
"[ 33%] Building C object glfw/src/CMakeFiles/glfw.dir/vulkan.c.o\n",
"[ 38%] Building C object glfw/src/CMakeFiles/glfw.dir/window.c.o\n",
"[ 42%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_init.c.o\n",
"[ 47%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_monitor.c.o\n",
"[ 52%] Building C object glfw/src/CMakeFiles/glfw.dir/x11_window.c.o\n",
"[ 57%] Building C object glfw/src/CMakeFiles/glfw.dir/xkb_unicode.c.o\n",
"[ 61%] Building C object glfw/src/CMakeFiles/glfw.dir/posix_time.c.o\n",
"[ 66%] Building C object glfw/src/CMakeFiles/glfw.dir/posix_thread.c.o\n",
"[ 71%] Building C object glfw/src/CMakeFiles/glfw.dir/glx_context.c.o\n",
"[ 76%] Building C object glfw/src/CMakeFiles/glfw.dir/egl_context.c.o\n",
"[ 80%] Building C object glfw/src/CMakeFiles/glfw.dir/osmesa_context.c.o\n",
"[ 85%] Building C object glfw/src/CMakeFiles/glfw.dir/linux_joystick.c.o\n",
"[ 90%] Linking C static library libglfw3.a\n",
"[ 90%] Built target glfw\n",
"Scanning dependencies of target cpp_magic_5329071abe\n",
"[ 95%] Building CXX object CMakeFiles/cpp_magic_5329071abe.dir/cpp_magic_5329071abe.cpp.o\n",
"[100%] Linking CXX shared module cpp_magic_5329071abe.cpython-37m-x86_64-linux-gnu.so\n",
"[100%] Built target cpp_magic_5329071abe\n",
"\n"
]
}
],
"outputs": [],
"source": [
"%%cpp -c pathtocmake -f viewMesh -rebuild\n",
"\n",
@ -306,29 +163,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"ename": "ImportError",
"evalue": "dynamic module does not define module export function (PyInit_cpp_magic_f96b7fce74)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-5-d51271ddbf06>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mcpp_magic_f96b7fce74\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m#viewMesh(V,F)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mImportError\u001b[0m: dynamic module does not define module export function (PyInit_cpp_magic_f96b7fce74)"
]
}
],
"source": [
"import cpp_magic_f96b7fce74\n",
"#viewMesh(V,F)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [

Loading…
Cancel
Save