Browse Source

moved python tutorials in a folder, doing a pass to make them python 3 compatible

Former-commit-id: 3ae8d0c1a97f0dd8363bee3824261e92a05c968b
Daniele Panozzo 9 years ago
parent
commit
64136b0b0c

+ 0 - 0
python/001_BasicTypes.py → python/tutorial/001_BasicTypes.py


+ 5 - 1
python/101_FileIO.py → python/tutorial/101_FileIO.py

@@ -1,10 +1,14 @@
 from __future__ import print_function
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 # Load a mesh in OFF format
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
-igl.readOFF("../tutorial/shared/cube.off", V, F)
+igl.readOFF("../../tutorial/shared/cube.off", V, F)
 
 # Print the vertices and faces matrices
 print("Vertices: \n", V, sep='')

+ 5 - 1
python/102_DrawMesh.py → python/tutorial/102_DrawMesh.py

@@ -1,9 +1,13 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 # Load a mesh in OFF format
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
-igl.readOFF("../tutorial/shared/beetle.off", V, F)
+igl.readOFF("../../tutorial/shared/beetle.off", V, F)
 
 # Plot the mesh
 viewer = igl.viewer.Viewer();

+ 0 - 0
python/102_DrawMeshTCP.py → python/tutorial/102_DrawMeshTCP.py


+ 6 - 2
python/103_Events.py → python/tutorial/103_Events.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V1 = igl.eigen.MatrixXd()
@@ -25,8 +29,8 @@ def key_pressed(viewer, key, modifier):
 
 
 #  Load two meshes
-igl.readOFF("../tutorial/shared/bumpy.off", V1, F1);
-igl.readOFF("../tutorial/shared/fertility.off", V2, F2);
+igl.readOFF("../../tutorial/shared/bumpy.off", V1, F1);
+igl.readOFF("../../tutorial/shared/fertility.off", V2, F2);
 
 print("1 Switch to bump mesh")
 print("2 Switch to fertility mesh")

+ 5 - 1
python/104_Colors.py → python/tutorial/104_Colors.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
@@ -5,7 +9,7 @@ F = igl.eigen.MatrixXi()
 C = igl.eigen.MatrixXd()
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/screwdriver.off", V, F)
+igl.readOFF("../../tutorial/shared/screwdriver.off", V, F)
 
 # Plot the mesh
 viewer = igl.viewer.Viewer()

+ 5 - 1
python/105_Overlays.py → python/tutorial/105_Overlays.py

@@ -1,10 +1,14 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/bunny.off", V, F)
+igl.readOFF("../../tutorial/shared/bunny.off", V, F)
 
 # Find the bounding box
 m = V.colwiseMinCoeff()

+ 5 - 2
python/201_Normals.py → python/tutorial/201_Normals.py

@@ -1,5 +1,8 @@
-import igl
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
 
+import igl
 
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
@@ -22,7 +25,7 @@ def key_pressed(viewer, key, modifier):
     return False
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/fandisk.off", V, F);
+igl.readOFF("../../tutorial/shared/fandisk.off", V, F);
 
 # Compute per-face normals
 N_faces = igl.eigen.MatrixXd()

+ 5 - 1
python/202_GaussianCurvature.py → python/tutorial/202_GaussianCurvature.py

@@ -1,9 +1,13 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 # Load mesh
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
-igl.readOFF("../tutorial/shared/bumpy.off",V,F);
+igl.readOFF("../../tutorial/shared/bumpy.off",V,F);
 
 # Compute Gaussian curvature
 K = igl.eigen.MatrixXd();

+ 5 - 1
python/203_CurvatureDirections.py → python/tutorial/203_CurvatureDirections.py

@@ -1,8 +1,12 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd();
 F = igl.eigen.MatrixXi();
-igl.read_triangle_mesh("../tutorial/shared/fertility.off", V, F);
+igl.read_triangle_mesh("../../tutorial/shared/fertility.off", V, F);
 
 # Alternative discrete mean curvature
 HN = igl.eigen.MatrixXd()

+ 6 - 2
python/204_Gradient.py → python/tutorial/204_Gradient.py

@@ -1,14 +1,18 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/cheburashka.off", V, F)
+igl.readOFF("../../tutorial/shared/cheburashka.off", V, F)
 
 # Read scalar function values from a file, U: #V by 1
 U = igl.eigen.MatrixXd()
-igl.readDMAT("../tutorial/shared/cheburashka-scalar.dmat",U)
+igl.readDMAT("../../tutorial/shared/cheburashka-scalar.dmat",U)
 U = U.col(0)
 
 # Compute gradient operator: #F*3 by #V

+ 6 - 1
python/205_Laplacian.py → python/tutorial/205_Laplacian.py

@@ -1,4 +1,9 @@
 from __future__ import print_function
+
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 import math
 
@@ -15,7 +20,7 @@ L = igl.eigen.SparseMatrixd()
 viewer = igl.viewer.Viewer()
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/cow.off", V, F)
+igl.readOFF("../../tutorial/shared/cow.off", V, F)
 
 # Compute Laplace-Beltrami operator: #V by #V
 igl.cotmatrix(V,F,L)

+ 6 - 1
python/301_Slice.py → python/tutorial/301_Slice.py

@@ -1,10 +1,15 @@
 from __future__ import print_function
+
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
 
-igl.readOFF("../tutorial/shared/decimated-knight.off",V,F)
+igl.readOFF("../../tutorial/shared/decimated-knight.off",V,F)
 
 # 100 random indicies into rows of F
 I = igl.eigen.MatrixXi()

+ 5 - 1
python/302_Sort.py → python/tutorial/302_Sort.py

@@ -1,9 +1,13 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
 
-igl.readOFF("../tutorial/shared/decimated-knight.off",V,F)
+igl.readOFF("../../tutorial/shared/decimated-knight.off",V,F)
 
 # Sort barycenters lexicographically
 BC = igl.eigen.MatrixXd()

+ 5 - 1
python/303_LaplaceEquation.py → python/tutorial/303_LaplaceEquation.py

@@ -1,9 +1,13 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
 
-igl.readOFF("../tutorial/shared/camelhead.off",V,F)
+igl.readOFF("../../tutorial/shared/camelhead.off",V,F)
 
 # Find boundary edges
 E = igl.eigen.MatrixXi()

+ 5 - 1
python/304_LinearEqualityConstraints.py → python/tutorial/304_LinearEqualityConstraints.py

@@ -1,9 +1,13 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
 
-igl.readOFF("../tutorial/shared/cheburashka.off",V,F)
+igl.readOFF("../../tutorial/shared/cheburashka.off",V,F)
 
 # Two fixed points
 # Left hand, left foot

+ 5 - 1
python/305_QuadraticProgramming.py → python/tutorial/305_QuadraticProgramming.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 b = igl.eigen.MatrixXi()
@@ -43,7 +47,7 @@ def key_down(viewer, key, mod):
 V = igl.eigen.MatrixXd()
 F = igl.eigen.MatrixXi()
 
-igl.readOFF("../tutorial/shared/cheburashka.off",V,F)
+igl.readOFF("../../tutorial/shared/cheburashka.off",V,F)
 
 # Plot the mesh
 viewer = igl.viewer.Viewer()

+ 6 - 2
python/306_EigenDecomposition.py → python/tutorial/306_EigenDecomposition.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
@@ -8,7 +12,7 @@ c = 0
 bbd = 1.0
 twod = False
 
-if not igl.read_triangle_mesh("../tutorial/shared/beetle.off",V,F):
+if not igl.read_triangle_mesh("../../tutorial/shared/beetle.off",V,F):
     print("failed to load mesh")
 
 twod = V.col(2).minCoeff() == V.col(2).maxCoeff()
@@ -32,7 +36,7 @@ viewer = igl.viewer.Viewer()
 
 def key_down(viewer,key,mod):
     global U, c
-    
+
     if key == ord(' '):
         U = U.rightCols(k)
 

+ 6 - 2
python/401_BiharmonicDeformation.py → python/tutorial/401_BiharmonicDeformation.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 global bc_frac, bc_dir,deformation_field, V, U, V_bc, U_bc, F, b
@@ -47,12 +51,12 @@ def key_down(viewer, key, mods):
     return False
 
 
-igl.readOBJ("../tutorial/shared/decimated-max.obj",V,F)
+igl.readOBJ("../../tutorial/shared/decimated-max.obj",V,F)
 U = igl.eigen.MatrixXd(V)
 
 # S(i) = j: j<0 (vertex i not in handle), j >= 0 (vertex i in handle j)
 S = igl.eigen.MatrixXd()
-igl.readDMAT("../tutorial/shared/decimated-max-selection.dmat",S)
+igl.readDMAT("../../tutorial/shared/decimated-max-selection.dmat",S)
 
 S = S.castint()
 

+ 5 - 3
python/402_PolyharmonicDeformation.py → python/tutorial/402_PolyharmonicDeformation.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 global z_max, z_dir, k, resolve, V, U, Z, F, b, bc
@@ -43,17 +47,15 @@ def key_down(viewer, key, mods):
     elif key == ord('.'):
         k = k + 1
         k = (4 if k>4 else k)
-        print k
         resolve = True
     elif key == ord(','):
         k = k - 1
         k = (1 if k<1 else k)
-        print k
         resolve = True
     return True
 
 
-igl.readOBJ("../tutorial/shared/bump-domain.obj",V,F)
+igl.readOBJ("../../tutorial/shared/bump-domain.obj",V,F)
 U = igl.eigen.MatrixXd(V)
 
 # Find boundary vertices outside annulus

+ 6 - 2
python/405_AsRigidAsPossible.py → python/tutorial/405_AsRigidAsPossible.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 from math import sin,cos,pi
 
@@ -51,9 +55,9 @@ def key_down(viewer, key, mods):
         return True
     return False
 
-igl.readOFF("../tutorial/shared/decimated-knight.off",V,F)
+igl.readOFF("../../tutorial/shared/decimated-knight.off",V,F)
 U = igl.eigen.MatrixXd(V)
-igl.readDMAT("../tutorial/shared/decimated-knight-selection.dmat",S)
+igl.readDMAT("../../tutorial/shared/decimated-knight-selection.dmat",S)
 
 # Vertices in selection
 

+ 5 - 1
python/501_HarmonicParam.py → python/tutorial/501_HarmonicParam.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
@@ -17,7 +21,7 @@ def key_down(viewer, key, modifier):
     return False
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/camelhead.off", V, F)
+igl.readOFF("../../tutorial/shared/camelhead.off", V, F)
 
 # Find the open boundary
 bnd = igl.eigen.MatrixXi()

+ 5 - 1
python/502_LSCMParam.py → python/tutorial/502_LSCMParam.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
@@ -17,7 +21,7 @@ def key_down(viewer, key, modifier):
     return False
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/camelhead.off", V, F);
+igl.readOFF("../../tutorial/shared/camelhead.off", V, F);
 
 # Fix two points on the boundary
 bnd = igl.eigen.MatrixXi()

+ 5 - 1
python/503_ARAPParam.py → python/tutorial/503_ARAPParam.py

@@ -1,3 +1,7 @@
+# Add the igl library to the modules search path
+import sys, os
+sys.path.insert(0, os.getcwd() + "/../")
+
 import igl
 
 V = igl.eigen.MatrixXd()
@@ -27,7 +31,7 @@ def key_down(viewer, key, modifier):
     return False
 
 # Load a mesh in OFF format
-igl.readOFF("../tutorial/shared/camelhead.off", V, F)
+igl.readOFF("../../tutorial/shared/camelhead.off", V, F)
 
 # Compute the initial solution for ARAP (harmonic parametrization)
 bnd = igl.eigen.MatrixXi()

+ 0 - 0
python/504_NRosyDesign.py → python/tutorial/504_NRosyDesign.py


+ 0 - 0
python/505_MIQ.py → python/tutorial/505_MIQ.py


+ 0 - 0
python/507_PolyVectorField.py → python/tutorial/507_PolyVectorField.py