Browse Source

Merge branch 's-koch-python_bindings'

Former-commit-id: 5e78d29b534fd2b06e51723a4aa048d3ab4326aa
Daniele Panozzo 9 years ago
parent
commit
00beaad9b0

+ 1 - 0
.gitignore

@@ -93,3 +93,4 @@ tests/bin
 python/build3
 *.pyc
 python/build4
+python/scripts/generated

+ 1 - 0
include/igl/ambient_occlusion.cpp

@@ -147,4 +147,5 @@ template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, E
 template void igl::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 // generated by autoexplicit.sh
 template void igl::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 #endif

+ 1 - 0
include/igl/embree/ambient_occlusion.cpp

@@ -58,4 +58,5 @@ template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1
 template void igl::embree::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 #endif

+ 1 - 1
include/igl/embree/ambient_occlusion.h

@@ -7,7 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_EMBREE_AMBIENT_OCCLUSION_H
 #define IGL_EMBREE_AMBIENT_OCCLUSION_H
-#include <igl/igl_inline.h>
+#include "../igl_inline.h"
 #include <Eigen/Core>
 namespace igl
 {

+ 6 - 6
include/igl/random_dir.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "random_dir.h"
 #include <igl/PI.h>
@@ -18,14 +18,14 @@ IGL_INLINE Eigen::Vector3d igl::random_dir()
   double r = sqrt(1.0-z*z);
   double x = r * cos(t);
   double y = r * sin(t);
-  return Vector3d(x,y,z); 
+  return Vector3d(x,y,z);
 }
 
 IGL_INLINE Eigen::MatrixXd igl::random_dir_stratified(const int n)
 {
   using namespace Eigen;
   using namespace std;
-  const double m = floor(sqrt(double(n)));
+  const double m = std::floor(sqrt(double(n)));
   MatrixXd N(n,3);
   int row = 0;
   for(int i = 0;i<m;i++)

+ 1 - 0
include/igl/slice.cpp

@@ -279,4 +279,5 @@ template Eigen::Matrix<double, -1, -1, 0, -1, -1> igl::slice<Eigen::Matrix<doubl
 template void igl::slice<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template void igl::slice<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 template void igl::slice<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::slice<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
 #endif

+ 1 - 1
include/igl/triangle/triangulate.h

@@ -7,7 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_TRIANGLE_TRIANGULATE_H
 #define IGL_TRIANGLE_TRIANGULATE_H
-#include <igl/igl_inline.h>
+#include "../igl_inline.h"
 #include <string>
 #include <Eigen/Core>
 

+ 1 - 0
include/igl/unproject_onto_mesh.cpp

@@ -73,5 +73,6 @@ IGL_INLINE bool igl::unproject_onto_mesh(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 template bool igl::unproject_onto_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<float, 3, 1, 0, 3, 1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<float, 3, 1, 0, 3, 1> >&);
+template bool igl::unproject_onto_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 #endif
 

+ 3 - 3
python/CMakeLists.txt

@@ -57,7 +57,7 @@ option(LIBIGL_WITH_NANOGUI          "Use Nanogui menu"   OFF)
 option(LIBIGL_WITH_CGAL             "Use CGAL"           OFF)
 option(LIBIGL_WITH_BOOLEAN          "Use Cork boolean"   OFF)
 option(LIBIGL_WITH_COMISO           "Use CoMiso"         ON)
-option(LIBIGL_WITH_EMBREE           "Use Embree"         OFF)
+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)
@@ -142,10 +142,10 @@ elseif (UNIX)
   #Enable flag if undefined symbols appear on pyigl module import to get notified about the missing symbols at link time
   option(CHECK_UNDEFINED        "Check for undefined symbols"    OFF)
 
-  # Strip unnecessary sections of the binary on Linux/Mac OS 
+  # Strip unnecessary sections of the binary on Linux/Mac OS
   if(APPLE)
     set_target_properties(pyigl PROPERTIES MACOSX_RPATH ".")
-    
+
     if (NOT CHECK_UNDEFINED)
       set_target_properties(pyigl PROPERTIES LINK_FLAGS "-undefined dynamic_lookup -dead_strip")
     endif()

+ 72 - 0
python/py_doc.cpp

@@ -66,6 +66,29 @@ const char *__doc_igl_signed_distance_winding_number = R"igl_Qu8mg5v7(// Inputs:
   //   hier  Winding number evaluation hierarchy
   //   q  Query point
   // Returns signed distance to mesh)igl_Qu8mg5v7";
+const char *__doc_igl_triangle_triangulate = R"igl_Qu8mg5v7(// Triangulate the interior of a polygon using the triangle library.
+    //
+    // Inputs:
+    //   V #V by 2 list of 2D vertex positions
+    //   E #E by 2 list of vertex ids forming unoriented edges of the boundary of the polygon
+    //   H #H by 2 coordinates of points contained inside holes of the polygon
+    //   flags  string of options pass to triangle (see triangle documentation)
+    // Outputs:
+    //   V2  #V2 by 2  coordinates of the vertives of the generated triangulation
+    //   F2  #F2 by 3  list of indices forming the faces of the generated triangulation
+    //
+    // TODO: expose the option to prevent Steiner points on the boundary
+    //)igl_Qu8mg5v7";
+const char *__doc_igl_embree_ambient_occlusion = R"igl_Qu8mg5v7(// Compute ambient occlusion per given point
+    //
+    // Inputs:
+    //    ei  EmbreeIntersector containing (V,F)
+    //    P  #P by 3 list of origin points
+    //    N  #P by 3 list of origin normals
+    // Outputs:
+    //    S  #P list of ambient occlusion values between 1 (fully occluded) and
+    //      0 (not occluded)
+    //)igl_Qu8mg5v7";
 const char *__doc_igl_cotmatrix = R"igl_Qu8mg5v7(// Constructs the cotangent stiffness matrix (discrete laplacian) for a given
   // mesh (V,F).
   //
@@ -120,6 +143,13 @@ const char *__doc_igl_per_face_normals = R"igl_Qu8mg5v7(// Compute face normals
   //   per_face_normals(V,F,Vector3d(1,1,1).normalized(),N);)igl_Qu8mg5v7";
 const char *__doc_igl_per_face_normals_stable = R"igl_Qu8mg5v7(// Special version where order of face indices is guaranteed not to effect
   // output.)igl_Qu8mg5v7";
+const char *__doc_igl_quad_planarity = R"igl_Qu8mg5v7(// Compute planarity of the faces of a quad mesh
+  // Inputs:
+  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
+  //   F  #F by 4 eigen Matrix of face (quad) indices
+  // Output:
+  //   P  #F by 1 eigen Matrix of mesh face (quad) planarities
+  //)igl_Qu8mg5v7";
 const char *__doc_igl_readOFF = R"igl_Qu8mg5v7(// Read a mesh from an ascii obj file, filling in vertex positions, normals
   // and texture coordinates. Mesh may have faces of any number of degree
   //
@@ -228,6 +258,21 @@ const char *__doc_igl_massmatrix = R"igl_Qu8mg5v7(// Constructs the mass (area)
   //
   // See also: adjacency_matrix
   //)igl_Qu8mg5v7";
+const char *__doc_igl_unproject_onto_mesh = R"igl_Qu8mg5v7(// Unproject a screen location (using current opengl viewport, projection, and
+  // model view) to a 3D position _onto_ a given mesh, if the ray through the
+  // given screen location (x,y) _hits_ the mesh.
+  //
+  // Inputs:
+  //    pos        screen space coordinates
+  //    model      model matrix
+  //    proj       projection matrix
+  //    viewport   vieweport vector
+  //    V   #V by 3 list of mesh vertex positions
+  //    F   #F by 3 list of mesh triangle indices into V
+  // Outputs:
+  //    fid  id of the first face hit
+  //    bc  barycentric coordinates of hit
+  // Returns true if there's a hit)igl_Qu8mg5v7";
 const char *__doc_igl_colon = R"igl_Qu8mg5v7(// Colon operator like matlab's colon operator. Enumerats values between low
   // and hi with step step.
   // Templates:
@@ -305,6 +350,14 @@ const char *__doc_igl_gaussian_curvature = R"igl_Qu8mg5v7(// Compute discrete lo
   // Output:
   //   K  #V by 1 eigen Matrix of discrete gaussian curvature values
   //)igl_Qu8mg5v7";
+const char *__doc_igl_planarize_quad_mesh = R"igl_Qu8mg5v7(// Inputs:
+  //   Vin        #V by 3 eigen Matrix of mesh vertex 3D positions
+  //   F          #F by 4 eigen Matrix of face (quad) indices
+  //   maxIter    maximum numbers of iterations
+  //   threshold  minimum allowed threshold for non-planarity
+  // Output:
+  //   Vout       #V by 3 eigen Matrix of planar mesh vertex 3D positions
+  //)igl_Qu8mg5v7";
 const char *__doc_igl_avg_edge_length = R"igl_Qu8mg5v7(// Compute the average edge length for the given triangle mesh
   // Templates:
   //   DerivedV derived from vertex positions matrix type: i.e. MatrixXd
@@ -427,6 +480,25 @@ const char *__doc_igl_setdiff = R"igl_Qu8mg5v7(// Set difference of elements of
   //   C  (k<=m)-long vector of unique elements appearing in A but not in B
   //   IA  (k<=m)-long list of indices into A so that C = A(IA)
   //)igl_Qu8mg5v7";
+const char *__doc_igl_copyleft_tetgen_tetrahedralize = R"igl_Qu8mg5v7(// Mesh the interior of a surface mesh (V,F) using tetgen
+      //
+      // Inputs:
+      //   V  #V by 3 vertex position list
+      //   F  #F list of polygon face indices into V (0-indexed)
+      //   switches  string of tetgen options (See tetgen documentation) e.g.
+      //     "pq1.414a0.01" tries to mesh the interior of a given surface with
+      //       quality and area constraints
+      //     "" will mesh the convex hull constrained to pass through V (ignores F)
+      // Outputs:
+      //   TV  #V by 3 vertex position list
+      //   TT  #T by 4 list of tet face indices
+      //   TF  #F by 3 list of triangle face indices
+      // Returns status:
+      //   0 success
+      //   1 tetgen threw exception
+      //   2 tetgen did not crash but could not create any tets (probably there are
+      //     holes, duplicate faces etc.)
+      //   -1 other error)igl_Qu8mg5v7";
 const char *__doc_igl_comb_frame_field = R"igl_Qu8mg5v7(// Inputs:
   //   V            #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F            #F by 4 eigen Matrix of face (quad) indices

+ 6 - 0
python/py_doc.h

@@ -3,11 +3,14 @@ extern const char *__doc_igl_local_basis;
 extern const char *__doc_igl_signed_distance;
 extern const char *__doc_igl_signed_distance_pseudonormal;
 extern const char *__doc_igl_signed_distance_winding_number;
+extern const char *__doc_igl_triangle_triangulate;
+extern const char *__doc_igl_embree_ambient_occlusion;
 extern const char *__doc_igl_cotmatrix;
 extern const char *__doc_igl_floor;
 extern const char *__doc_igl_slice;
 extern const char *__doc_igl_per_face_normals;
 extern const char *__doc_igl_per_face_normals_stable;
+extern const char *__doc_igl_quad_planarity;
 extern const char *__doc_igl_readOFF;
 extern const char *__doc_igl_per_vertex_normals;
 extern const char *__doc_igl_sortrows;
@@ -17,6 +20,7 @@ extern const char *__doc_igl_cat;
 extern const char *__doc_igl_eigs;
 extern const char *__doc_igl_per_corner_normals;
 extern const char *__doc_igl_massmatrix;
+extern const char *__doc_igl_unproject_onto_mesh;
 extern const char *__doc_igl_colon;
 extern const char *__doc_igl_fit_rotations;
 extern const char *__doc_igl_fit_rotations_planar;
@@ -24,6 +28,7 @@ extern const char *__doc_igl_fit_rotations_SSE;
 extern const char *__doc_igl_rotate_vectors;
 extern const char *__doc_igl_read_triangle_mesh;
 extern const char *__doc_igl_gaussian_curvature;
+extern const char *__doc_igl_planarize_quad_mesh;
 extern const char *__doc_igl_avg_edge_length;
 extern const char *__doc_igl_barycentric_coordinates;
 extern const char *__doc_igl_lscm;
@@ -33,6 +38,7 @@ extern const char *__doc_igl_slice_mask;
 extern const char *__doc_igl_point_mesh_squared_distance;
 extern const char *__doc_igl_parula;
 extern const char *__doc_igl_setdiff;
+extern const char *__doc_igl_copyleft_tetgen_tetrahedralize;
 extern const char *__doc_igl_comb_frame_field;
 extern const char *__doc_igl_map_vertices_to_circle;
 extern const char *__doc_igl_writeOBJ;

+ 12 - 1
python/py_igl.cpp

@@ -64,6 +64,12 @@
 #include <igl/covariance_scatter_matrix.h>
 #include <igl/slice_mask.h>
 #include <igl/signed_distance.h>
+#include <igl/quad_planarity.h>
+#include <igl/planarize_quad_mesh.h>
+#include <igl/triangle/triangulate.h>
+#include <igl/copyleft/tetgen/tetrahedralize.h>
+#include <igl/embree/ambient_occlusion.h>
+#include <igl/unproject_onto_mesh.h>
 //#include <igl/.h>
 
 
@@ -131,7 +137,12 @@ void python_export_igl(py::module &m)
 #include "py_igl/py_covariance_scatter_matrix.cpp"
 #include "py_igl/py_slice_mask.cpp"
 #include "py_igl/py_signed_distance.cpp"
-
+#include "py_igl/py_quad_planarity.cpp"
+#include "py_igl/py_planarize_quad_mesh.cpp"
+#include "py_igl/py_triangle_triangulate.cpp"
+#include "py_igl/py_copyleft_tetgen_tetrahedralize.cpp"
+#include "py_igl/py_embree_ambient_occlusion.cpp"
+#include "py_igl/py_unproject_onto_mesh.cpp"
 //#include "py_igl/py_.cpp"
 
 }

+ 16 - 0
python/py_igl/py_copyleft_tetgen_tetrahedralize.cpp

@@ -0,0 +1,16 @@
+
+m.def("copyleft_tetgen_tetrahedralize", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  const std::string switches,
+  Eigen::MatrixXd& TV,
+  Eigen::MatrixXi& TT,
+  Eigen::MatrixXi& TF
+)
+{
+  return igl::copyleft::tetgen::tetrahedralize(V, F, switches, TV, TT, TF);
+}, __doc_igl_copyleft_tetgen_tetrahedralize,
+py::arg("V"), py::arg("F"), py::arg("switches"), py::arg("TV"), py::arg("TT"), py::arg("TF"));
+
+

+ 16 - 0
python/py_igl/py_embree_ambient_occlusion.cpp

@@ -0,0 +1,16 @@
+
+
+m.def("embree_ambient_occlusion", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  const Eigen::MatrixXd& P,
+  const Eigen::MatrixXd& N,
+  const int num_samples,
+  Eigen::MatrixXd& S
+)
+{
+  return igl::embree::ambient_occlusion(V, F, P, N, num_samples, S);
+}, __doc_igl_embree_ambient_occlusion,
+py::arg("V"), py::arg("F"), py::arg("P"), py::arg("N"), py::arg("num_samples"), py::arg("S"));
+

+ 14 - 0
python/py_igl/py_planarize_quad_mesh.cpp

@@ -0,0 +1,14 @@
+
+m.def("planarize_quad_mesh", []
+(
+  const Eigen::MatrixXd& Vin,
+  const Eigen::MatrixXi& F,
+  const int maxIter,
+  const double & threshold,
+  Eigen::MatrixXd& Vout
+)
+{
+  return igl::planarize_quad_mesh(Vin, F, maxIter, threshold, Vout);
+}, __doc_igl_planarize_quad_mesh,
+py::arg("Vin"), py::arg("F"), py::arg("maxIter"), py::arg("threshold"), py::arg("Vout"));
+

+ 15 - 0
python/py_igl/py_quad_planarity.cpp

@@ -0,0 +1,15 @@
+
+
+m.def("quad_planarity", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  Eigen::MatrixXd& P
+)
+{
+  Eigen::VectorXd Pv;
+  igl::quad_planarity(V, F, Pv);
+  P = Pv;
+}, __doc_igl_quad_planarity,
+py::arg("V"), py::arg("F"), py::arg("P"));
+

+ 13 - 0
python/py_igl/py_slice.cpp

@@ -41,6 +41,19 @@ m.def("slice", []
 }, __doc_igl_slice,
 py::arg("X"), py::arg("R"), py::arg("C"), py::arg("Y"));
 
+m.def("slice", []
+(
+  const Eigen::MatrixXd& X,
+  const Eigen::MatrixXi& R,
+  const int dim,
+  Eigen::MatrixXd& Y
+)
+{
+  assert_is_VectorX("R",R);
+  return igl::slice(X,R,dim,Y);
+}, __doc_igl_slice,
+py::arg("X"), py::arg("R"), py::arg("dim"), py::arg("Y"));
+
 m.def("slice", []
 (
   const Eigen::MatrixXd& X,

+ 16 - 0
python/py_igl/py_triangle_triangulate.cpp

@@ -0,0 +1,16 @@
+
+
+m.def("triangle_triangulate", []
+(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& E,
+  const Eigen::MatrixXd& H,
+  const std::string flags,
+  Eigen::MatrixXd& V2,
+  Eigen::MatrixXi& F2
+)
+{
+  return igl::triangle::triangulate(V, E, H, flags, V2, F2);
+}, __doc_igl_triangle_triangulate,
+py::arg("V"), py::arg("E"), py::arg("H"), py::arg("flags"), py::arg("V2"), py::arg("F2"));
+

+ 57 - 0
python/py_igl/py_unproject_onto_mesh.cpp

@@ -0,0 +1,57 @@
+// COMPLETE BINDINGS ========================
+
+m.def("unproject_onto_mesh", []
+(
+  const Eigen::MatrixXd & pos,
+  const Eigen::MatrixXd & model,
+  const Eigen::MatrixXd & proj,
+  const Eigen::MatrixXd & viewport,
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  Eigen::MatrixXi& fid, // TODO: Can we replace this with integer object reference?
+  Eigen::MatrixXd& bc
+)
+{
+  assert_is_Vector2("pos", pos);
+  Eigen::Vector2f posv;
+  if (pos.size() != 0)
+    posv = Eigen::Vector2f(pos.cast<float>());
+  assert_is_Matrix4("model", model);
+  Eigen::Matrix4f modelm;
+  if (model.size() != 0)
+    modelm = model.cast<float>();
+  assert_is_Matrix4("proj", proj);
+  Eigen::Matrix4f projm;
+  if (proj.size() != 0)
+    projm = proj.cast<float>();
+  assert_is_Vector4("viewport", viewport);
+  Eigen::Vector4f viewportv;
+  if (viewport.size() != 0)
+    viewportv = Eigen::Vector4f(viewport.cast<float>());
+
+  Eigen::VectorXd bcv;
+  int fidi;
+  bool ret = igl::unproject_onto_mesh(posv, modelm, projm, viewportv, V, F, fidi, bcv);
+  fid(0, 0) = fidi;
+  bc = bcv;
+  return ret;
+}, __doc_igl_unproject_onto_mesh,
+py::arg("pos"), py::arg("model"), py::arg("proj"), py::arg("viewport"), py::arg("V"), py::arg("F"), py::arg("fid"), py::arg("bc"));
+
+// INCOMPLETE BINDINGS ========================
+
+//m.def("unproject_onto_mesh", []
+//(
+//  Eigen::Vector2f & pos,
+//  Eigen::Matrix4f & model,
+//  Eigen::Matrix4f & proj,
+//  Eigen::Vector4f & viewport,
+//  std::function<bool (const Eigen::Vector3f &, const Eigen::Vector3f &, igl::Hit &)> & shoot_ray,
+//  int & fid,
+//  Eigen::MatrixXd& bc
+//)
+//{
+//  return igl::unproject_onto_mesh(pos, model, proj, viewport, shoot_ray, fid, bc);
+//}, __doc_igl_unproject_onto_mesh,
+//py::arg("pos"), py::arg("model"), py::arg("proj"), py::arg("viewport"), py::arg("shoot_ray"), py::arg("fid"), py::arg("bc"));
+

+ 4 - 0
python/py_igl_viewer.cpp

@@ -356,6 +356,10 @@ py::class_<igl::viewer::ViewerCore> viewercore_class(me, "ViewerCore");
     .def("open_dialog_load_mesh", &igl::viewer::Viewer::open_dialog_load_mesh)
     .def("open_dialog_save_mesh", &igl::viewer::Viewer::open_dialog_save_mesh)
 
+    // Input handling
+    .def_readwrite("current_mouse_x", &igl::viewer::Viewer::current_mouse_x)
+    .def_readwrite("current_mouse_y", &igl::viewer::Viewer::current_mouse_y)
+
     // Callbacks
     .def_readwrite("callback_init", &igl::viewer::Viewer::callback_init)
     .def_readwrite("callback_pre_draw", &igl::viewer::Viewer::callback_pre_draw)

+ 5 - 0
python/py_vector.cpp

@@ -126,6 +126,9 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
         .def("rightCols", [](Type &m, const int& k) { return Type(m.rightCols(k)); })
         .def("leftCols", [](Type &m, const int& k) { return Type(m.leftCols(k)); })
 
+        .def("setLeftCols", [](Type &m, const int& k, const Type& v) { return Type(m.leftCols(k) = v); })
+        .def("setRightCols", [](Type &m, const int& k, const Type& v) { return Type(m.rightCols(k) = v); })
+
         .def("topRows", [](Type &m, const int& k) { return Type(m.topRows(k)); })
         .def("bottomRows", [](Type &m, const int& k) { return Type(m.bottomRows(k)); })
 
@@ -170,6 +173,7 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
         .def("cwiseQuotient", [](const Type &m1, const Type &m2) -> Type { return m1.cwiseQuotient(m2); })
 
         /* Row and column-wise operations */
+        .def("rowwiseSet", [](Type &m, const Type &m2) {return Type(m.rowwise() = Eigen::Matrix<Scalar, 1, Eigen::Dynamic>(m2));} )
         .def("rowwiseSum", [](const Type &m) {return Type(m.rowwise().sum());} )
         .def("rowwiseProd", [](const Type &m) {return Type(m.rowwise().prod());} )
         .def("rowwiseMean", [](const Type &m) {return Type(m.rowwise().mean());} )
@@ -178,6 +182,7 @@ py::class_<Type> bind_eigen_2(py::module &m, const char *name,
         .def("rowwiseMinCoeff", [](const Type &m) {return Type(m.rowwise().minCoeff());} )
         .def("rowwiseMaxCoeff", [](const Type &m) {return Type(m.rowwise().maxCoeff());} )
 
+        .def("colwiseSet", [](Type &m, const Type &m2) {return Type(m.colwise() = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>(m2));} )
         .def("colwiseSum", [](const Type &m) {return Type(m.colwise().sum());} )
         .def("colwiseProd", [](const Type &m) {return Type(m.colwise().prod());} )
         .def("colwiseMean", [](const Type &m) {return Type(m.colwise().mean());} )

+ 1 - 0
python/python_shared.cpp

@@ -24,6 +24,7 @@ PYBIND11_PLUGIN(pyigl) {
         .. autosummary::
            :toctree: _generate
 
+
     )pyigldoc");
 
     python_export_vector(m);

+ 20 - 0
python/python_shared.h

@@ -31,6 +31,26 @@ void assert_is_RowVectorX(const std::string name, const Eigen::PlainObjectBase<S
     throw std::runtime_error(name + " must be a row vector.");
 }
 
+template<typename Scalar>
+void assert_is_Vector2(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
+{
+  if (v.size() == 0)
+    return;
+
+  if ((v.cols() != 1) || (v.rows() != 2))
+    throw std::runtime_error(name + " must be a column vector with 2 entries.");
+}
+
+template<typename Scalar>
+void assert_is_RowVector2(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
+{
+  if (v.size() == 0)
+    return;
+
+  if ((v.cols() != 2) || (v.rows() != 1))
+    throw std::runtime_error(name + " must be a row vector with 2 entries.");
+}
+
 template<typename Scalar>
 void assert_is_Vector3(const std::string name, const Eigen::PlainObjectBase<Scalar>& v)
 {

+ 2 - 2
python/tutorial/105_Overlays.py

@@ -65,7 +65,7 @@ l1 = 'x: ' + str(m[0,0]) + ' y: ' + str(m[0,1]) + ' z: ' + str(m[0,2])
 viewer.data.add_label(m.transpose(),l1)
 
 l2 = 'x: ' + str(M[0,0]) + ' y: ' + str(M[0,1]) + ' z: ' + str(M[0,2])
-viewer.data.add_label(M.transpose(),l2);
+viewer.data.add_label(M.transpose(),l2)
 
 # Launch the viewer
-viewer.launch();
+viewer.launch()

+ 117 - 0
python/tutorial/509_Planarization.py

@@ -0,0 +1,117 @@
+# Add the igl library to the modules search path
+import sys, os
+
+sys.path.insert(0, os.getcwd() + "/../")
+
+import pyigl as igl
+import random
+from math import cos, sin, pi
+
+TUTORIAL_SHARED_PATH = "../../tutorial/shared/"
+
+viewer = igl.viewer.Viewer()
+
+# Quad mesh generated from conjugate field
+VQC = igl.eigen.MatrixXd()
+FQC = igl.eigen.MatrixXi()
+FQCtri = igl.eigen.MatrixXi()
+PQC0 = igl.eigen.MatrixXd()
+PQC1 = igl.eigen.MatrixXd()
+PQC2 = igl.eigen.MatrixXd()
+PQC3 = igl.eigen.MatrixXd()
+
+# Planarized quad mesh
+VQCplan = igl.eigen.MatrixXd()
+FQCtriplan = igl.eigen.MatrixXi()
+PQC0plan = igl.eigen.MatrixXd()
+PQC1plan = igl.eigen.MatrixXd()
+PQC2plan = igl.eigen.MatrixXd()
+PQC3plan = igl.eigen.MatrixXd()
+
+
+def key_down(viewer, key, modifier):
+    if key == ord('1'):
+        # Draw the triangulated quad mesh
+        viewer.data.set_mesh(VQC, FQCtri)
+
+        # Assign a color to each quad that corresponds to its planarity
+        planarity = igl.eigen.MatrixXd()
+        igl.quad_planarity(VQC, FQC, planarity)
+        Ct = igl.eigen.MatrixXd()
+        igl.jet(planarity, 0, 0.01, Ct)
+        C = igl.eigen.MatrixXd(FQCtri.rows(), 3)
+        C.setTopRows(Ct.rows(), Ct)
+        C.setBottomRows(Ct.rows(), Ct)
+        viewer.data.set_colors(C)
+
+        # Plot a line for each edge of the quad mesh
+        viewer.data.add_edges(PQC0, PQC1, igl.eigen.MatrixXd([[0, 0, 0]]))
+        viewer.data.add_edges(PQC1, PQC2, igl.eigen.MatrixXd([[0, 0, 0]]))
+        viewer.data.add_edges(PQC2, PQC3, igl.eigen.MatrixXd([[0, 0, 0]]))
+        viewer.data.add_edges(PQC3, PQC0, igl.eigen.MatrixXd([[0, 0, 0]]))
+
+    elif key == ord('2'):
+        # Draw the planar quad mesh
+        viewer.data.set_mesh(VQCplan, FQCtri)
+
+        # Assign a color to each quad that corresponds to its planarity
+        planarity = igl.eigen.MatrixXd()
+        igl.quad_planarity(VQCplan, FQC, planarity)
+        Ct = igl.eigen.MatrixXd()
+        igl.jet(planarity, 0, 0.01, Ct)
+        C = igl.eigen.MatrixXd(FQCtri.rows(), 3)
+        C.setTopRows(Ct.rows(), Ct)
+        C.setBottomRows(Ct.rows(), Ct)
+        viewer.data.set_colors(C)
+
+        # Plot a line for each edge of the quad mesh
+        viewer.data.add_edges(PQC0plan, PQC1plan, igl.eigen.MatrixXd([[0, 0, 0]]))
+        viewer.data.add_edges(PQC1plan, PQC2plan, igl.eigen.MatrixXd([[0, 0, 0]]))
+        viewer.data.add_edges(PQC2plan, PQC3plan, igl.eigen.MatrixXd([[0, 0, 0]]))
+        viewer.data.add_edges(PQC3plan, PQC0plan, igl.eigen.MatrixXd([[0, 0, 0]]))
+
+    else:
+        return False
+
+    return True
+
+
+# Load a quad mesh generated by a conjugate field
+igl.readOFF(TUTORIAL_SHARED_PATH + "inspired_mesh_quads_Conjugate.off", VQC, FQC)
+
+# Convert it to a triangle mesh
+FQCtri.resize(2 * FQC.rows(), 3)
+
+FQCtriUpper = igl.eigen.MatrixXi(FQC.rows(), 3)
+FQCtriLower = igl.eigen.MatrixXi(FQC.rows(), 3)
+
+FQCtriUpper.setCol(0, FQC.col(0))
+FQCtriUpper.setCol(1, FQC.col(1))
+FQCtriUpper.setCol(2, FQC.col(2))
+FQCtriLower.setCol(0, FQC.col(2))
+FQCtriLower.setCol(1, FQC.col(3))
+FQCtriLower.setCol(2, FQC.col(0))
+
+FQCtri.setTopRows(FQCtriUpper.rows(), FQCtriUpper)
+FQCtri.setBottomRows(FQCtriLower.rows(), FQCtriLower)
+
+igl.slice(VQC, FQC.col(0), 1, PQC0)
+igl.slice(VQC, FQC.col(1), 1, PQC1)
+igl.slice(VQC, FQC.col(2), 1, PQC2)
+igl.slice(VQC, FQC.col(3), 1, PQC3)
+
+# Planarize it
+igl.planarize_quad_mesh(VQC, FQC, 100, 0.005, VQCplan)
+
+# Convert the planarized mesh to triangles
+igl.slice(VQCplan, FQC.col(0), 1, PQC0plan)
+igl.slice(VQCplan, FQC.col(1), 1, PQC1plan)
+igl.slice(VQCplan, FQC.col(2), 1, PQC2plan)
+igl.slice(VQCplan, FQC.col(3), 1, PQC3plan)
+
+# Launch the viewer
+key_down(viewer, ord('2'), 0)
+viewer.core.invert_normals = True
+viewer.core.show_lines = False
+viewer.callback_key_down = key_down
+viewer.launch()

+ 21 - 0
python/tutorial/604_Triangle.py

@@ -0,0 +1,21 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
+import pyigl as igl
+
+# Input polygon
+V = igl.eigen.MatrixXd([[-1, -1], [1, -1], [1, 1], [-1, 1], [-2, -2], [2, -2], [2, 2], [-2, 2]])
+E = igl.eigen.MatrixXi([[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6,7], [7,4]])
+H = igl.eigen.MatrixXd([[0, 0]])
+
+# Triangulated Interior
+V2 = igl.eigen.MatrixXd()
+F2 = igl.eigen.MatrixXi()
+
+igl.triangle_triangulate(V, E, H, "a0.005q", V2, F2)
+
+# Plot the mesh
+viewer = igl.viewer.Viewer()
+viewer.data.set_mesh(V2, F2)
+viewer.launch()

+ 71 - 0
python/tutorial/605_Tetgen.py

@@ -0,0 +1,71 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
+import pyigl as igl
+
+TUTORIAL_SHARED_PATH = "../../tutorial/shared/"
+
+
+# Input polygon
+V = igl.eigen.MatrixXd()
+F = igl.eigen.MatrixXi()
+B = igl.eigen.MatrixXd()
+
+# Tetrahedralized interior
+TV = igl.eigen.MatrixXd()
+TT = igl.eigen.MatrixXi()
+TF = igl.eigen.MatrixXi()
+
+viewer = igl.viewer.Viewer()
+
+
+def key_down(viewer, key, modifier):
+    if key >= ord('1') and key <= ord('9'):
+        t = float((key - ord('1')) + 1) / 9.0
+        v = igl.eigen.MatrixXd()
+        v = B.col(2) - B.col(2).minCoeff()
+        v /= v.col(0).maxCoeff()
+
+        s = []
+        for i in range(v.size()):
+            if v[i, 0] < t:
+                s.append(i)
+
+        V_temp = igl.eigen.MatrixXd(len(s) * 4, 3)
+        F_temp = igl.eigen.MatrixXi(len(s) * 4, 3)
+
+        for i in range(len(s)):
+            V_temp.setRow(i * 4 + 0, TV.row(TT[s[i], 0]))
+            V_temp.setRow(i * 4 + 1, TV.row(TT[s[i], 1]))
+            V_temp.setRow(i * 4 + 2, TV.row(TT[s[i], 2]))
+            V_temp.setRow(i * 4 + 3, TV.row(TT[s[i], 3]))
+
+            F_temp.setRow(i * 4 + 0, igl.eigen.MatrixXi([[(i*4)+0, (i*4)+1, (i*4)+3]]))
+            F_temp.setRow(i * 4 + 1, igl.eigen.MatrixXi([[(i*4)+0, (i*4)+2, (i*4)+1]]))
+            F_temp.setRow(i * 4 + 2, igl.eigen.MatrixXi([[(i*4)+3, (i*4)+2, (i*4)+0]]))
+            F_temp.setRow(i * 4 + 3, igl.eigen.MatrixXi([[(i*4)+1, (i*4)+2, (i*4)+3]]))
+
+        viewer.data.clear()
+        viewer.data.set_mesh(V_temp, F_temp)
+        viewer.data.set_face_based(True)
+
+    else:
+        return False
+
+    return True
+
+
+# Load a surface mesh
+igl.readOFF(TUTORIAL_SHARED_PATH + "fertility.off", V, F)
+
+# Tetrahedralize the interior
+igl.copyleft_tetgen_tetrahedralize(V, F, "pq1.414Y", TV, TT, TF)
+
+# Compute barycenters
+igl.barycenter(TV, TT, B)
+
+# Plot the generated mesh
+key_down(viewer, ord('5'), 0)
+viewer.callback_key_down = key_down
+viewer.launch()

+ 65 - 0
python/tutorial/606_AmbientOcclusion.py

@@ -0,0 +1,65 @@
+# Add the igl library to the modules search path
+import sys, os
+
+import math
+
+sys.path.insert(0, os.getcwd() + "/../")
+
+import pyigl as igl
+
+TUTORIAL_SHARED_PATH = "../../tutorial/shared/"
+
+
+# Mesh + AO values + Normals
+V = igl.eigen.MatrixXd()
+F = igl.eigen.MatrixXi()
+AO = igl.eigen.MatrixXd()
+N = igl.eigen.MatrixXd()
+
+
+viewer = igl.viewer.Viewer()
+
+
+def key_down(viewer, key, modifier):
+
+    color = igl.eigen.MatrixXd([[0.9, 0.85, 0.9]])
+
+    if key == ord('1'):
+        # Show the mesh without the ambient occlusion factor
+        viewer.data.set_colors(color)
+    elif key == ord('2'):
+        # Show the mesh with the ambient occlusion factor
+        C = color.replicate(V.rows(), 1)
+        for i in range(C.rows()):
+            C.setRow(i, C.row(i) * AO[i, 0])
+        viewer.data.set_colors(C)
+    elif key == ord('.'):
+        viewer.core.lighting_factor += 0.1
+    elif key == ord(','):
+        viewer.core.lighting_factor -= 0.1
+    else:
+        return False
+
+    viewer.core.lighting_factor = min(max(viewer.core.lighting_factor, 0.0), 1.0)
+    return True
+
+
+print("Press 1 to turn off Ambient Occlusion\nPress 2 to turn on Ambient Occlusion\nPress . to turn up lighting\nPress , to turn down lighting")
+
+# Load a surface mesh
+igl.readOFF(TUTORIAL_SHARED_PATH + "fertility.off", V, F)
+
+# Calculate vertex normals
+igl.per_vertex_normals(V, F, N)
+
+# Compute ambient occlusion factor using embree
+igl.embree_ambient_occlusion(V, F, V, N, 500, AO)
+AO = 1.0 - AO
+
+# Plot the generated mesh
+viewer.data.set_mesh(V, F)
+key_down(viewer, ord('2'), 0)
+viewer.callback_key_down = key_down
+viewer.core.show_lines = False
+viewer.core.lighting_factor = 0.0
+viewer.launch()

+ 45 - 0
python/tutorial/607_Picking.py

@@ -0,0 +1,45 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
+import pyigl as igl
+
+TUTORIAL_SHARED_PATH = "../../tutorial/shared/"
+
+
+# Mesh with per-face color
+V = igl.eigen.MatrixXd()
+F = igl.eigen.MatrixXi()
+C = igl.eigen.MatrixXd()
+
+viewer = igl.viewer.Viewer()
+
+def mouse_down(viewer, a, b):
+    bc = igl.eigen.MatrixXd()
+
+    # Cast a ray in the view direction starting from the mouse position
+    fid = igl.eigen.MatrixXi([-1])
+    coord = igl.eigen.MatrixXd([viewer.current_mouse_x, viewer.core.viewport[3] - viewer.current_mouse_y])
+    hit = igl.unproject_onto_mesh(coord, viewer.core.view * viewer.core.model,
+      viewer.core.proj, viewer.core.viewport, V, F, fid, bc)
+    if hit:
+        C.setRow(fid[0, 0], igl.eigen.MatrixXd([[1, 0, 0]]))
+        viewer.data.set_colors(C)
+        return True
+
+    return False
+
+
+print("Usage: [LeftMouseClick] to select a face")
+
+# Load a mesh in OFF format
+igl.readOFF(TUTORIAL_SHARED_PATH + "fertility.off", V, F)
+
+# Initialize white
+C.setConstant(F.rows(), 3, 1.0)
+
+viewer.data.set_mesh(V, F)
+viewer.data.set_colors(C)
+viewer.core.show_lines = False
+viewer.callback_mouse_down = mouse_down
+viewer.launch()

+ 8 - 5
python/tutorial/704_SignedDistance.py

@@ -2,6 +2,7 @@ from __future__ import print_function
 
 # Add the igl library to the modules search path
 import sys, os
+
 sys.path.insert(0, os.getcwd() + "/../")
 
 import pyigl as igl
@@ -31,11 +32,13 @@ viewer = igl.viewer.Viewer()
 
 def append_mesh(C_vis, F_vis, V_vis, V, F, color):
     F_vis.conservativeResize(F_vis.rows() + F.rows(), 3)
-    # F_vis.setBottomRows(F.rows(), F + V_vis.rows())
+    F_vis.setBottomRows(F.rows(), F + V_vis.rows())
     V_vis.conservativeResize(V_vis.rows() + V.rows(), 3)
-    # V_vis.setBottomRows(V.rows(), V)
+    V_vis.setBottomRows(V.rows(), V)
     C_vis.conservativeResize(C_vis.rows() + V.rows(), 3)
-    # C_vis.setBottomRows(V.rows(), color)
+    colorM = igl.eigen.MatrixXd(V.rows(), C_vis.cols())
+    colorM.rowwiseSet(color)
+    C_vis.setBottomRows(V.rows(), colorM)
 
 
 def update_visualization(viewer):
@@ -82,7 +85,7 @@ def update_visualization(viewer):
     igl.parula(S_vis, False, C_vis)
 
     if overlay:
-        append_mesh(C_vis, F_vis, V_vis, V, F, igl.eigen.MatrixXd([0.8, 0.8, 0.8]))
+        append_mesh(C_vis, F_vis, V_vis, V, F, igl.eigen.MatrixXd([[0.8, 0.8, 0.8]]))
 
     viewer.data.clear()
     viewer.data.set_mesh(V_vis, F_vis)
@@ -110,7 +113,7 @@ print("Press [space] to toggle showing surface.")
 print("Press '.'/',' to push back/pull forward slicing plane.")
 
 # Load mesh: (V,T) tet-mesh of convex hull, F contains original surface triangles
-igl.readMESH(TUTORIAL_SHARED_PATH + "bunny.mesh", V, T, F);
+igl.readMESH(TUTORIAL_SHARED_PATH + "bunny.mesh", V, T, F)
 
 # Call to point_mesh_squared_distance to determine bounds
 sqrD = igl.eigen.MatrixXd()

+ 1 - 1
tutorial/509_Planarization/main.cpp

@@ -25,7 +25,7 @@ Eigen::MatrixXd PQC0plan, PQC1plan, PQC2plan, PQC3plan;
 
 
 // Scale for visualizing the fields
-double global_scale;
+double global_scale; //TODO: not used
 
 
 bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)

+ 4 - 9
tutorial/607_Picking/main.cpp

@@ -9,8 +9,10 @@ int main(int argc, char *argv[])
   // Mesh with per-face color
   Eigen::MatrixXd V, C;
   Eigen::MatrixXi F;
+
   // Load a mesh in OFF format
   igl::readOFF(TUTORIAL_SHARED_PATH "/fertility.off", V, F);
+
   // Initialize white
   C = Eigen::MatrixXd::Constant(F.rows(),3,1);
   igl::viewer::Viewer viewer;
@@ -22,15 +24,8 @@ int main(int argc, char *argv[])
     // Cast a ray in the view direction starting from the mouse position
     double x = viewer.current_mouse_x;
     double y = viewer.core.viewport(3) - viewer.current_mouse_y;
-    if(igl::unproject_onto_mesh(
-      Eigen::Vector2f(x,y),
-      viewer.core.view * viewer.core.model,
-      viewer.core.proj,
-      viewer.core.viewport,
-      V,
-      F,
-      fid,
-      bc))
+    if(igl::unproject_onto_mesh(Eigen::Vector2f(x,y), viewer.core.view * viewer.core.model,
+      viewer.core.proj, viewer.core.viewport, V, F, fid, bc))
     {
       // paint hit red
       C.row(fid)<<1,0,0;