diff --git a/python/401_BiharmonicDeformation.py b/python/401_BiharmonicDeformation.py index 3ec66d235..790fd185c 100755 --- a/python/401_BiharmonicDeformation.py +++ b/python/401_BiharmonicDeformation.py @@ -1,6 +1,6 @@ import igl - +global bc_frac, bc_dir,deformation_field, V, U, V_bc, U_bc, F, b bc_frac = 1.0 bc_dir = -0.03 deformation_field = False @@ -15,7 +15,7 @@ F = igl.eigen.MatrixXi() b = igl.eigen.MatrixXi() def pre_draw(viewer): - global V, bc_frac, bc_dir, U, U_bc, V_bc, b, deformation_field + global bc_frac, bc_dir,deformation_field, V, U, V_bc, U_bc, F, b # Determine boundary conditions if (viewer.core.is_animating): bc_frac += bc_dir @@ -27,20 +27,16 @@ def pre_draw(viewer): D = igl.eigen.MatrixXd() D_bc = U_bc_anim - V_bc igl.harmonic(V,F,b,D_bc,2,D) - U = V+D; + U = V+D else: - D = igl.eigen.MatrixXd() - igl.harmonic(V,F,b,U_bc_anim,2,D) - U = D - # global U - # igl.harmonic(V,F,b,U_bc_anim,2,U) + igl.harmonic(V,F,b,U_bc_anim,2,U) viewer.data.set_vertices(U) viewer.data.compute_normals() return False def key_down(viewer, key, mods): - global deformation_field + global bc_frac, bc_dir,deformation_field, V, U, V_bc, U_bc, F, b if key == ord(' '): viewer.core.is_animating = not viewer.core.is_animating @@ -52,7 +48,7 @@ def key_down(viewer, key, mods): igl.readOBJ("../tutorial/shared/decimated-max.obj",V,F) -U=V +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() diff --git a/python/402_PolyharmonicDeformation.py b/python/402_PolyharmonicDeformation.py index eb5cab842..aa92bf367 100755 --- a/python/402_PolyharmonicDeformation.py +++ b/python/402_PolyharmonicDeformation.py @@ -1,6 +1,6 @@ import igl -global resolve, z_max, z_dir, k, Z, V, F, b, bc, U +global z_max, z_dir, k, resolve, V, U, Z, F, b, bc z_max = 1.0 z_dir = -0.03 @@ -19,13 +19,10 @@ b = igl.eigen.MatrixXi() bc = igl.eigen.MatrixXd() def pre_draw(viewer): - global resolve, z_max, z_dir, k, Z, V, F, b, bc + global z_max, z_dir, k, resolve, V, U, Z, F, b, bc if resolve: - print k - # T = igl.eigen.MatrixXd() igl.harmonic(V,F,b,bc,k,Z) - # Z = T # FIXME resolve = False U.setCol(2,z_max*Z) @@ -39,34 +36,28 @@ def pre_draw(viewer): return False def key_down(viewer, key, mods): - global k, resolve + global z_max, z_dir, k, resolve, V, U, Z, F, b, bc if key == ord(' '): viewer.core.is_animating = not viewer.core.is_animating 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) -U=V +U = igl.eigen.MatrixXd(V) # Find boundary vertices outside annulus -# is_outer = (V.rowwise().norm().array()-1.0)>-1e-15 -# is_inner = (V.rowwise().norm().array()-0.15)<1e-15 -# in_b = is_outer.array() || is_inner.array() -# -# igl.colon_int(0,V.rows()-1,b) -# b.conservativeResize(stable_partition( b.data(), b.data()+b.size(), -# [&in_b](int i)->bool{return in_b(i);})-b.data()) - Vrn = V.rowwiseNorm() is_outer = [Vrn[i]-1.00 > -1e-15 for i in range(0,V.rows())] is_inner = [Vrn[i]-0.15 < 1e-15 for i in range(0,V.rows())]