Disabled external gits
This commit is contained in:
5316 files changed
+4563444
-6
No files matched your search
@@ -0,0 +1,155 @@
|
||||
import time
|
||||
import pytest
|
||||
import json
|
||||
import sys
|
||||
import igl
|
||||
import numpy as np
|
||||
sys.path.append('../')
|
||||
sys.path.append('../src')
|
||||
|
||||
|
||||
import utils, laplacian_utils, mean_curvature_flow, remesher_helper
|
||||
from utils import parse_input_mesh, normalize_area, get_diverging_colors, remesh
|
||||
from mean_curvature_flow import MCF
|
||||
|
||||
import copy
|
||||
import numpy.linalg as la
|
||||
|
||||
import fitting
|
||||
|
||||
epsilon1 = 5e-2
|
||||
epsilon2 = 1e-3
|
||||
|
||||
eps = 1E-6
|
||||
|
||||
with open('test_data.json', 'r') as infile:
|
||||
homework_data = json.load(infile)
|
||||
|
||||
v = np.array(homework_data[0], dtype=float)
|
||||
f = np.array(homework_data[1], dtype=int)
|
||||
num_bdry_vx, num_intr_vx = int(homework_data[2]), int(homework_data[3])
|
||||
curr_mcf = MCF(num_bdry_vx, num_intr_vx)
|
||||
curr_mcf.bbox_diagonal = igl.bounding_box_diagonal(v)
|
||||
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_mass_matrix():
|
||||
student_mass_matrix = laplacian_utils.compute_mass_matrix(v, f).toarray()
|
||||
assert np.linalg.norm(student_mass_matrix - np.array(homework_data[4], dtype=float)) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_cotan():
|
||||
cotan, a, b, c, A = homework_data[5]
|
||||
student_cotan = laplacian_utils.compute_cotangent(a, b, c, A)
|
||||
assert np.linalg.norm(student_cotan - cotan) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_laplacian_matrix():
|
||||
student_laplacian_matrix = laplacian_utils.compute_laplacian_matrix(v, f).toarray()
|
||||
assert np.linalg.norm(student_laplacian_matrix - np.array(homework_data[6], dtype=float)) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_average_mean_curvature():
|
||||
data = homework_data[7]
|
||||
laplace_v = copy.deepcopy(v)
|
||||
curr_mcf.update_system(laplace_v, f)
|
||||
assert np.linalg.norm(curr_mcf.average_mean_curvature - data) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_laplace_solution():
|
||||
data = homework_data[8]
|
||||
laplace_v = copy.deepcopy(v)
|
||||
curr_mcf.solve_laplace_equation(laplace_v, f)
|
||||
assert np.linalg.norm(laplace_v - np.array(data, dtype=float)) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_meet_sc():
|
||||
data = homework_data[9]
|
||||
student_sc = [curr_mcf.meet_stopping_criteria([0.001, 0.001], epsilon1, epsilon2), curr_mcf.meet_stopping_criteria([1, 0.5], epsilon1, epsilon2)]
|
||||
|
||||
assert student_sc == data
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_mean_curvature_flow():
|
||||
data = np.array(homework_data[10], dtype=float)
|
||||
_, student_mean_curvature_flow = curr_mcf.run_mean_curvature_flow(v, f, 100, epsilon1, epsilon2)
|
||||
|
||||
assert np.linalg.norm(student_mean_curvature_flow - data) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_average_mean_curvature():
|
||||
data = homework_data[7]
|
||||
laplace_v = copy.deepcopy(v)
|
||||
curr_mcf.update_system(laplace_v, f)
|
||||
assert np.linalg.norm(curr_mcf.average_mean_curvature - data) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_laplace_solution():
|
||||
data = homework_data[8]
|
||||
laplace_v = copy.deepcopy(v)
|
||||
curr_mcf.solve_laplace_equation(laplace_v, f)
|
||||
assert np.linalg.norm(laplace_v - np.array(data, dtype=float)) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_meet_sc():
|
||||
data = homework_data[9]
|
||||
student_sc = [curr_mcf.meet_stopping_criteria([0.001, 0.001], epsilon1, epsilon2), curr_mcf.meet_stopping_criteria([1, 0.5], epsilon1, epsilon2)]
|
||||
|
||||
assert student_sc == data
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_mean_curvature_flow():
|
||||
data = np.array(homework_data[10], dtype=float)
|
||||
_, student_mean_curvature_flow = curr_mcf.run_mean_curvature_flow(v, f, 100, epsilon1, epsilon2)
|
||||
|
||||
assert np.linalg.norm(student_mean_curvature_flow - data) < eps
|
||||
|
||||
|
||||
fitting_v = np.array(homework_data[11], dtype=float)
|
||||
fitting_f = np.array(homework_data[12], dtype=int)
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_osculating_paraboloids():
|
||||
[paraboloids_parameters, e1, e2, e3] = homework_data[13]
|
||||
paraboloids_parameters = np.array(paraboloids_parameters)
|
||||
e1 = np.array(e1)
|
||||
e2 = np.array(e2)
|
||||
e3 = np.array(e3)
|
||||
student_paraboloids_parameters = fitting.compute_osculating_paraboloids(fitting_v, fitting_f, e1, e2, e3)
|
||||
assert np.linalg.norm(student_paraboloids_parameters - paraboloids_parameters) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_osculating_paraboloid_first_derivatives():
|
||||
[op_fd_x, op_fd_y, paraboloids_parameters] = homework_data[14]
|
||||
op_fd_x = np.array(op_fd_x)
|
||||
op_fd_y = np.array(op_fd_y)
|
||||
paraboloids_parameters = np.array(paraboloids_parameters)
|
||||
student_fd_x, student_fd_y = fitting.compute_osculating_paraboloid_first_derivatives(paraboloids_parameters)
|
||||
assert np.linalg.norm(student_fd_x - op_fd_x) < eps
|
||||
assert np.linalg.norm(student_fd_y - op_fd_y) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_osculating_paraboloid_second_derivatives():
|
||||
[op_sd_xx, op_sd_xy, op_sd_yy, paraboloids_parameters] = homework_data[15]
|
||||
op_sd_xx = np.array(op_sd_xx)
|
||||
op_sd_xy = np.array(op_sd_xy)
|
||||
op_sd_yy = np.array(op_sd_yy)
|
||||
paraboloids_parameters = np.array(paraboloids_parameters)
|
||||
student_sd_xx, student_sd_xy, student_sd_yy = fitting.compute_osculating_paraboloid_second_derivatives(paraboloids_parameters)
|
||||
|
||||
assert np.linalg.norm(student_sd_xx - op_sd_xx) < eps
|
||||
assert np.linalg.norm(student_sd_xy - op_sd_xy) < eps
|
||||
assert np.linalg.norm(student_sd_yy - op_sd_yy) < eps
|
||||
|
||||
@pytest.mark.timeout(0.5)
|
||||
def test_mesh_principal_curvatures():
|
||||
k1, k2, d1, d2 = homework_data[16]
|
||||
k1 = np.array(k1)
|
||||
k2 = np.array(k2)
|
||||
d1 = np.array(d1)
|
||||
d2 = np.array(d2)
|
||||
student_k1, student_k2, student_d1, student_d2 = fitting.compute_mesh_principal_curvatures(fitting_v, fitting_f)
|
||||
assert np.linalg.norm(k1 - student_k1) < eps
|
||||
assert np.linalg.norm(k2 - student_k2) < eps
|
||||
assert np.linalg.norm(d1 - student_d1) < eps
|
||||
assert np.linalg.norm(d2 - student_d2) < eps
|
||||
@@ -0,0 +1 @@
|
||||
[[[-1.0, 0.0, 1.0], [1.0, 0.0, 1.0], [-1.0, 0.0, -1.0], [1.0, 0.0, -1.0], [-1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [0.0, 1.0, 0.0]], [[1, 8, 5], [1, 6, 8], [8, 7, 2], [6, 7, 8], [6, 3, 7], [5, 4, 0], [5, 8, 4], [8, 2, 4]], 8, 1, [[0.16666666666666666, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.47140452079103173, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.47140452079103173, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.16666666666666666, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.6910440616569954, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.6910440616569954, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6910440616569954, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.6910440616569954, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.520159310771689]], [0.577350269189626, 1.4142135623730951, 1.4142135623730951, 1.4142135623730951, 0.8660254037844386], [[-1.0000000000000002, 0.0, 0.0, 0.0, 0.5000000000000001, 0.5000000000000001, 0.0, 0.0, 0.0], [0.0, -1.4142135623730951, 0.0, 0.0, 0.0, 0.7071067811865475, 0.7071067811865475, 0.0, 3.14018491736755e-16], [0.0, 0.0, -1.4142135623730951, 0.0, 0.7071067811865475, 0.0, 0.0, 0.7071067811865475, 3.14018491736755e-16], [0.0, 0.0, 0.0, -1.0000000000000002, 0.0, 0.0, 0.5000000000000001, 0.5000000000000001, 0.0], [0.5000000000000001, 0.0, 0.7071067811865475, 0.0, -2.138010440969447, 0.28867513459481287, 0.0, 0.0, 0.6422285251880866], [0.5000000000000001, 0.7071067811865475, 0.0, 0.0, 0.28867513459481287, -2.138010440969447, 0.0, 0.0, 0.6422285251880866], [0.0, 0.7071067811865475, 0.0, 0.5000000000000001, 0.0, 0.0, -2.1380104409694467, 0.28867513459481287, 0.6422285251880866], [0.0, 0.0, 0.7071067811865475, 0.5000000000000001, 0.0, 0.0, 0.28867513459481287, -2.138010440969447, 0.6422285251880866], [0.0, 3.14018491736755e-16, 3.14018491736755e-16, 0.0, 0.6422285251880866, 0.6422285251880866, 0.6422285251880866, 0.6422285251880866, -2.568914100752347]], 0.2816496580927726, [[-1.0, 0.0, 1.0], [1.0, 0.0, 1.0], [-1.0, 0.0, -1.0], [1.0, 0.0, -1.0], [-1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [-0.0, -0.0, -0.0]], [true, false], [0.2816496580927726, 0.0], [[0.276388, 0.44722, 0.850649], [-0.723607, 0.44722, 0.525725], [-0.723607, 0.44722, -0.525725], [0.276388, 0.44722, -0.850649], [0.894426, 0.447216, 0.0], [0.688189, 0.525736, 0.499997], [-0.262869, 0.525738, 0.809012], [-0.850648, 0.525736, 0.0], [-0.262869, 0.525738, -0.809012], [0.688189, 0.525736, -0.499997], [0.0, 1.0, 0.0], [0.162456, 0.850654, 0.499995], [0.52573, 0.850652, 0.0], [-0.425323, 0.850654, 0.309011], [-0.425323, 0.850654, -0.309011], [0.162456, 0.850654, -0.499995]], [[8, 2, 14], [0, 5, 11], [15, 8, 14], [13, 6, 11], [6, 0, 11], [12, 9, 15], [2, 7, 14], [11, 5, 12], [11, 12, 10], [9, 3, 15], [14, 13, 10], [15, 14, 10], [4, 9, 12], [7, 1, 13], [13, 11, 10], [14, 7, 13], [12, 15, 10], [1, 6, 13], [3, 8, 15], [5, 4, 12]], [[[-0.6831148489909354, -0.674723891553982, -0.010519301894530007, 0.1732319619904244, -0.3596813241769664], [-0.6747979128924075, -0.6830384546994573, 0.010634465447438162, -0.3584800668595869, -0.1757012126221275], [-0.674797912892408, -0.6830384546994567, -0.010634465447438573, -0.358480066859587, 0.17570121262212707], [-0.6831148489909388, -0.6747238915539883, 0.010519301894526809, 0.17323196199042695, 0.35968132417697235], [-0.6721943791572939, -0.6856494054804964, 0.0, 0.39922447394010757, -0.0], [-0.7034204758887591, -0.6749547540752635, 0.041584991709803, 0.34504498544145984, -0.18194692747630212], [-0.6724037404688081, -0.7059646643524279, -0.03758451893048138, -0.15938627440829387, -0.35602485130252565], [-0.7143814413490718, -0.6639885613014465, -1.9295889125679988e-17, -0.39007597350872786, 3.005683558067793e-17], [-0.6724037404688095, -0.7059646643524311, 0.03758451893048308, -0.15938627440829511, 0.35602485130252876], [-0.7034204758887593, -0.6749547540752627, -0.041584991709802455, 0.34504498544146, 0.18194692747630167], [-0.6666858608956988, -0.6666845734992874, 3.7306394193624996e-18, 2.1338844264326254e-07, 2.574068913920107e-19], [-0.6802429578098679, -0.6117558705031778, -0.06125745984521047, -0.020121957048326176, 0.05267670839521008], [-0.600060764280164, -0.6919433622978192, -1.220893769710376e-16, -0.05638494019149861, 4.2239719793343604e-17], [-0.6254556477996414, -0.6665436227188374, 0.08218593722947694, 0.04796726700560509, 0.029647097575992803], [-0.625455647799642, -0.6665436227188375, -0.0821859372294765, 0.04796726700560454, -0.029647097575992758], [-0.6802429578098679, -0.6117558705031776, 0.06125745984521049, -0.0201219570483262, -0.052676708395210034]], [[-0.9473118999225608, 0.32031260397478634, 0.0], [-0.7487645999911324, -0.6628360082253524, 0.0], [-0.7487645999911324, -0.6628360082253524, 0.0], [-0.9473118999225608, 0.3203126039747864, 0.0], [-0.674609951942796, 0.7381743782736829, 0.0], [-0.7935576486047644, 0.608495076677599, 0.0], [-0.9596832856460411, -0.28108360189029Line truncated
|
||||
Reference in new issue
Block a user