9.7 KiB
9.7 KiB
In [1]:
import numpy as np
import meshplot as mpIn [2]:
import igl
import scipy as sp
import numpy as np
from meshplot import plot, subplot, interact
import time
import copy
import matplotlib.pyplot as pltIn [3]:
import sys
sys.path.append('../src')In [4]:
import importlib, utils, laplacian_utils, mean_curvature_flow, remesher_helper
importlib.reload(utils)
importlib.reload(laplacian_utils)
importlib.reload(mean_curvature_flow)
importlib.reload(remesher_helper)
from utils import parse_input_mesh, normalize_area, get_diverging_colors, plot_directions
from mean_curvature_flow import MCF
import smooth_surfacesIn [5]:
from fitting import compute_mesh_principal_curvaturesIn [6]:
v, f, num_bdry_vx, num_intr_vx = parse_input_mesh("../data/bob_tri.obj")
curr_mcf = MCF(num_bdry_vx, num_intr_vx)Warning: readOBJ() ignored non-comment line 3: o Mesh
In [7]:
k1, k2, d1, d2 = compute_mesh_principal_curvatures(v, f)In [8]:
gaussian_curvature = k1+k2
gaussian_curvature[:num_bdry_vx] *= 0
gp = mp.plot(v, f, get_diverging_colors(gaussian_curvature))[0;31m---------------------------------------------------------------------------[0m [0;31mTypeError[0m Traceback (most recent call last) [0;32m/tmp/ipykernel_12120/1640637150.py[0m in [0;36m<module>[0;34m[0m [0;32m----> 1[0;31m [0mgaussian_curvature[0m [0;34m=[0m [0mk1[0m[0;34m+[0m[0mk2[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 2[0m [0mgaussian_curvature[0m[0;34m[[0m[0;34m:[0m[0mnum_bdry_vx[0m[0;34m][0m [0;34m*=[0m [0;36m0[0m[0;34m[0m[0;34m[0m[0m [1;32m 3[0m [0mgp[0m [0;34m=[0m [0mmp[0m[0;34m.[0m[0mplot[0m[0;34m([0m[0mv[0m[0;34m,[0m [0mf[0m[0;34m,[0m [0mget_diverging_colors[0m[0;34m([0m[0mgaussian_curvature[0m[0;34m)[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;31mTypeError[0m: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
In [ ]:
mean_curvature = (k1+k2)/2
mean_curvature[:num_bdry_vx] *= 0
gp = mp.plot(v, f, get_diverging_colors(mean_curvature))In [ ]:
plot_directions(v, f, d1, d2, scale=0.08)In [ ]:
a1, a2 = smooth_surfaces.compute_asymptotic_directions(k1, k2, d1, d2)In [ ]:
plot_directions(v, f, a1, a2, scale=0.08)In [ ]:
epsilon1 = 5e-2
epsilon2 = 1e-3In [ ]:
v2, f2, num_bdry_vx, num_intr_vx = parse_input_mesh("../data/two_rings_remesh.obj")
curr_mcf = MCF(num_bdry_vx, num_intr_vx)In [ ]:
start = time.time()
vs, average_mean_curvature_list1 = curr_mcf.run_mean_curvature_flow(v2, f2, 1000, epsilon1, epsilon2)
print("Run {} iterations of unstable mean curvature flow".format(len(average_mean_curvature_list1)))
print("took {} seconds".format(time.time() - start))In [ ]:
k1, k2, d1, d2 = compute_mesh_principal_curvatures(vs[-1], f2)In [ ]:
gaussian_curvature = k1+k2
gaussian_curvature[:num_bdry_vx] *= 0
gp = mp.plot(vs[-1], f2, get_diverging_colors(gaussian_curvature, percentile=80))In [ ]:
mean_curvature = (k1+k2)/2
mean_curvature[:num_bdry_vx] *= 0
gp = mp.plot(vs[-1], f2, get_diverging_colors(mean_curvature))In [ ]:
plot_directions(vs[-1], f2, d1, d2, scale=0.08)In [ ]:
a1, a2 = smooth_surfaces.compute_asymptotic_directions(k1, k2, d1, d2)In [ ]:
plot_directions(v2, f2, a1, a2, scale=0.08)In [ ]: