Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/harmonic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Examples

)igl_Qu8mg5v7";

npe_function(harmonic_weights)
npe_function(harmonic)
npe_doc(ds_harmonic_w)
npe_arg(v, dense_float, dense_double)
npe_arg(f, dense_int, dense_long, dense_longlong)
Expand Down Expand Up @@ -78,7 +78,7 @@ Examples

)igl_Qu8mg5v7";

npe_function(harmonic_weights_uniform_laplacian)
npe_function(harmonic_uniform_laplacian)
npe_doc(ds_harmonic_ul)

npe_arg(f, dense_int, dense_long, dense_longlong)
Expand Down Expand Up @@ -134,7 +134,7 @@ Examples

)igl_Qu8mg5v7";

npe_function(harmonic_weights_from_laplacian_and_mass)
npe_function(harmonic_from_laplacian_and_mass)
npe_doc(ds_harmonic)
//TODO: l and bc need to have same type, matching missing
npe_arg(l, sparse_float, sparse_double)
Expand Down Expand Up @@ -187,7 +187,7 @@ Examples

)igl_Qu8mg5v7";

npe_function(harmonic_weights_integrated_from_laplacian_and_mass)
npe_function(harmonic_integrated_from_laplacian_and_mass)
npe_doc(ds_harmonic_int_lapl)

npe_arg(l, sparse_float, sparse_double)
Expand Down Expand Up @@ -231,7 +231,7 @@ Examples

)igl_Qu8mg5v7";

npe_function(harmonic_weights_integrated)
npe_function(harmonic_integrated)
npe_doc(ds_harmonic_int)

npe_arg(v, dense_float, dense_double)
Expand Down
30 changes: 15 additions & 15 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ def test_arap1(self):
thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis]
bc = np.concatenate([np.cos(thetas), np.sin(
thetas), np.zeros_like(thetas)], axis=1)
uv_initial_guess = igl.harmonic_weights(v, f, b, bc, 1)
uv_initial_guess = igl.harmonic(v, f, b, bc, 1)

v2d = v[:, :2].copy()
arap1 = igl.ARAP(v2d, f, 2, b)
Expand Down Expand Up @@ -965,7 +965,7 @@ def test_arap2(self):
circle_b = np.concatenate(
[np.cos(thetas), np.sin(thetas), np.zeros([len(b), 1])], axis=1)

v0 = igl.harmonic_weights(v, f, b, circle_b, 1)
v0 = igl.harmonic(v, f, b, circle_b, 1)
arap = igl.ARAP(v, f, 2, b)

v2 = arap.solve(circle_b[:, :2], v0[:, :2])
Expand All @@ -983,7 +983,7 @@ def test_arap3(self):
bnd_uv = igl.map_vertices_to_circle(v, bnd)

# Harmonic parametrization for the internal vertices
uv = igl.harmonic_weights(v, f, bnd, bnd_uv, 1)
uv = igl.harmonic(v, f, bnd, bnd_uv, 1)

arap = igl.ARAP(v, f, 2, np.zeros((0)))
uva = arap.solve(np.zeros((0, 0)), uv)
Expand All @@ -995,7 +995,7 @@ def test_arap4(self):
thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis]
bc = np.concatenate([np.cos(thetas), np.sin(
thetas), np.zeros_like(thetas)], axis=1)
uv_initial_guess = igl.harmonic_weights(v, f, b, bc, 1)
uv_initial_guess = igl.harmonic(v, f, b, bc, 1)

arap = igl.ARAP(v, f, 3, b, igl.ARAP_ENERGY_TYPE_SPOKES)
uva = arap.solve(bc, uv_initial_guess)
Expand All @@ -1006,7 +1006,7 @@ def test_slim(self):
thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis]
bc = np.concatenate([np.cos(thetas), np.sin(
thetas), np.zeros_like(thetas)], axis=1)
uv_initial_guess = igl.harmonic_weights(v, f, b, bc, 1)
uv_initial_guess = igl.harmonic(v, f, b, bc, 1)

slim = igl.SLIM(
v, f, uv_initial_guess[:, :2], b, bc[:, :2], igl.SLIM_ENERGY_TYPE_ARAP, 0.0)
Expand Down Expand Up @@ -1060,28 +1060,28 @@ def test_boundary_conditions(self):
# tested in test bbw
pass

def test_harmonic_weights(self):
def test_harmonic(self):
# tested in test_slim, test_arap2, and test_arap1
pass

def test_harmonic_weights_integrated(self):
Q = igl.harmonic_weights_integrated(self.v1, self.f1, 1)
def test_harmonic_integrated(self):
Q = igl.harmonic_integrated(self.v1, self.f1, 1)
self.assertTrue(Q.dtype == self.v1.dtype)

def test_harmonic_weights_uniform_laplacian(self):
def test_harmonic_uniform_laplacian(self):
b = np.array([0, 10])
bc = np.array([
[0, 0], [10., 10.]])
W = igl.harmonic_weights_uniform_laplacian(self.f1, b, bc, 1)
W = igl.harmonic_uniform_laplacian(self.f1, b, bc, 1)

self.assertTrue(W.dtype == self.v1.dtype)
self.assertTrue(W.flags.c_contiguous)

def test_harmonic_weights_integrated_from_laplacian_and_mass(self):
def test_harmonic_integrated_from_laplacian_and_mass(self):
l = igl.cotmatrix(self.v1, self.f1)
m = igl.massmatrix(self.v1, self.f1, igl.MASSMATRIX_TYPE_VORONOI)

Q = igl.harmonic_weights_integrated_from_laplacian_and_mass(l, m, 1)
Q = igl.harmonic_integrated_from_laplacian_and_mass(l, m, 1)
self.assertTrue(Q.dtype == self.v1.dtype)

# deal with igl::PerEdgeNormalsWeightingType
Expand Down Expand Up @@ -1112,10 +1112,10 @@ def test_harmonic(self):
b = np.array([1, 2, 10, 7])
bc = self.v1[b, :]
k = 1
w = igl.harmonic_weights_from_laplacian_and_mass(l, m, b, bc, k)
w = igl.harmonic_from_laplacian_and_mass(l, m, b, bc, k)
self.assertTrue(w.flags.c_contiguous)

def test_harmonic_weights_from_laplacian_and_mass(self):
def test_harmonic_from_laplacian_and_mass(self):
# tested in test_harmonic
pass

Expand Down Expand Up @@ -2246,7 +2246,7 @@ def test_bijective_composite_harmonic_mapping(self):
b = igl.boundary_loop(f)
thetas = np.linspace(0, 2 * np.pi, len(b))[:, np.newaxis]
bc = np.concatenate([np.cos(thetas), np.sin(thetas)], axis=1)
v2d = igl.harmonic_weights(v, f, b, bc, 1)[:, :2]
v2d = igl.harmonic(v, f, b, bc, 1)[:, :2]
ret0, mapping0 = igl.bijective_composite_harmonic_mapping(
v2d, f, b, bc)
self.assertTrue(ret0)
Expand Down
20 changes: 10 additions & 10 deletions tutorial/igl_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1280,8 +1280,8 @@ GRAD_INTRINSIC Construct an intrinsic gradient operator.
|Returns| G \#F*2 by \#V gradient matrix: G=[Gx;Gy] where x runs along the 23 edge and</br>y runs in the counter-clockwise 90° rotation. |


### harmonic_weights
**`harmonic_weights(v: array, f: array, b: array, bc: array, k: int)`**
### harmonic
**`harmonic(v: array, f: array, b: array, bc: array, k: int)`**

Compute k-harmonic weight functions "coordinates".

Expand All @@ -1291,8 +1291,8 @@ Compute k-harmonic weight functions "coordinates".
|Returns| W \#V by \#W list of weights |


### harmonic_weights_from_laplacian_and_mass
**`harmonic_weights_from_laplacian_and_mass(l: sparse_matrix, m: sparse_matrix, b: array, bc: array, k: int)`**
### harmonic_from_laplacian_and_mass
**`harmonic_from_laplacian_and_mass(l: sparse_matrix, m: sparse_matrix, b: array, bc: array, k: int)`**

Compute a harmonic map using a given Laplacian and mass matrix

Expand All @@ -1302,8 +1302,8 @@ Compute a harmonic map using a given Laplacian and mass matrix
|Returns| W \#V by \#V list of weights |


### harmonic_weights_integrated
**`harmonic_weights_integrated(v: array, f: array, k: int)`**
### harmonic_integrated
**`harmonic_integrated(v: array, f: array, k: int)`**


| | |
Expand All @@ -1312,8 +1312,8 @@ Compute a harmonic map using a given Laplacian and mass matrix
|Returns| Q \#V by \#V discrete (integrated) k-Laplacian |


### harmonic_weights_integrated_from_laplacian_and_mass
**`harmonic_weights_integrated_from_laplacian_and_mass(l: sparse_matrix, m: sparse_matrix, k: int)`**
### harmonic_integrated_from_laplacian_and_mass
**`harmonic_integrated_from_laplacian_and_mass(l: sparse_matrix, m: sparse_matrix, k: int)`**

Build the discrete k-harmonic operator (computing integrated quantities).
That is, if the k-harmonic PDE is Q x = 0, then this minimizes x' Q x
Expand All @@ -1324,8 +1324,8 @@ That is, if the k-harmonic PDE is Q x = 0, then this minimizes x' Q x
|Returns| Q \#V by \#V discrete (integrated) k-Laplacian |


### harmonic_weights_uniform_laplacian
**`harmonic_weights_uniform_laplacian(f: array, b: array, bc: array, k: int)`**
### harmonic_uniform_laplacian
**`harmonic_uniform_laplacian(f: array, b: array, bc: array, k: int)`**

Compute harmonic map using uniform laplacian operator

Expand Down
14 changes: 7 additions & 7 deletions tutorial/tut-chapter3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"are asking that the bi-Laplacian of each of spatial coordinate function to be\n",
"zero.\n",
"\n",
"In libigl, one can solve a biharmonic problem with `harmonic_weights`\n",
"In libigl, one can solve a biharmonic problem with `harmonic`\n",
"and setting $k=2$ (_bi_-harmonic).\n",
"\n",
"This produces a smooth surface that interpolates the handle constraints, but all\n",
Expand Down Expand Up @@ -109,7 +109,7 @@
"\n",
" $\\mathbf{d}_b = \\mathbf{x}_{bc} - \\mathbf{x}_b.$\n",
"\n",
"Again we can use `harmonic_weights` with $k=2$, but this time solve for the\n",
"Again we can use `harmonic` with $k=2$, but this time solve for the\n",
"deformation field and then recover the deformed positions:"
]
},
Expand Down Expand Up @@ -144,7 +144,7 @@
"for i in range(3):\n",
" u_bc_anim = v_bc + i*0.6 * (u_bc - v_bc)\n",
" d_bc = u_bc_anim - v_bc\n",
" d = igl.harmonic_weights(v, f, b, d_bc, 2)\n",
" d = igl.harmonic(v, f, b, d_bc, 2)\n",
" u = v + d\n",
" subplot(u, f, s, shading={\"wireframe\": False, \"colormap\": \"tab10\"}, s=[1, 4, i+1], data=p)\n",
"p\n",
Expand All @@ -156,10 +156,10 @@
"\n",
"# if deformation_field:\n",
"# d_bc = u_bc_anim - v_bc\n",
"# d = igl.harmonic_weights(v, f, b, d_bc, 2)\n",
"# d = igl.harmonic(v, f, b, d_bc, 2)\n",
"# u = v + d\n",
"# else:\n",
"# u = igl.harmonic_weights(v, f, b, u_bc_anim, 2)\n",
"# u = igl.harmonic(v, f, b, u_bc_anim, 2)\n",
"# p.update_object(vertices=u)"
]
},
Expand Down Expand Up @@ -231,7 +231,7 @@
"c = np.array(is_outer)\n",
"\n",
"for i in range(1,5):\n",
" z = igl.harmonic_weights(v, f, b, bc, int(i))\n",
" z = igl.harmonic(v, f, b, bc, int(i))\n",
" u[:, 2] = z\n",
" if i == 1:\n",
" p = subplot(u, f, c, shading={\"wire_width\": 0.01, \"colormap\": \"tab10\"}, s=[1, 4, i-1])\n",
Expand All @@ -243,7 +243,7 @@
"# @interact(z_max=(0.0, 1.0), k=(1, 4))\n",
"# def update(z_max, k):\n",
"# print(k)\n",
"# z = igl.harmonic_weights(v, f, b, bc, int(k))\n",
"# z = igl.harmonic(v, f, b, bc, int(k))\n",
"# u[:, 2] = z_max * z\n",
"# p.update_object(vertices=u)"
]
Expand Down
4 changes: 2 additions & 2 deletions tutorial/tut-chapter4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"bnd_uv = igl.map_vertices_to_circle(v, bnd)\n",
"\n",
"## Harmonic parametrization for the internal vertices\n",
"uv = igl.harmonic_weights(v, f, bnd, bnd_uv, 1)\n",
"uv = igl.harmonic(v, f, bnd, bnd_uv, 1)\n",
"v_p = np.hstack([uv, np.zeros((uv.shape[0],1))])\n",
"\n",
"p = subplot(v, f, uv=uv, shading={\"wireframe\": False, \"flat\": False}, s=[1, 2, 0])\n",
Expand Down Expand Up @@ -204,7 +204,7 @@
"bnd_uv = igl.map_vertices_to_circle(v, bnd)\n",
"\n",
"## Harmonic parametrization for the internal vertices\n",
"uv = igl.harmonic_weights(v, f, bnd, bnd_uv, 1)\n",
"uv = igl.harmonic(v, f, bnd, bnd_uv, 1)\n",
"\n",
"arap = igl.ARAP(v, f, 2, np.zeros(0))\n",
"uva = arap.solve(np.zeros((0, 0)), uv)\n",
Expand Down
14 changes: 7 additions & 7 deletions tutorial/tutorials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@
"are asking that the bi-Laplacian of each of spatial coordinate function to be\n",
"zero.\n",
"\n",
"In libigl, one can solve a biharmonic problem with `harmonic_weights`\n",
"In libigl, one can solve a biharmonic problem with `harmonic`\n",
"and setting $k=2$ (_bi_-harmonic).\n",
"\n",
"This produces a smooth surface that interpolates the handle constraints, but all\n",
Expand Down Expand Up @@ -1117,7 +1117,7 @@
"\n",
" $\\mathbf{d}_b = \\mathbf{x}_{bc} - \\mathbf{x}_b.$\n",
"\n",
"Again we can use `harmonic_weights` with $k=2$, but this time solve for the\n",
"Again we can use `harmonic` with $k=2$, but this time solve for the\n",
"deformation field and then recover the deformed positions:"
]
},
Expand Down Expand Up @@ -1157,10 +1157,10 @@
"\n",
" if deformation_field:\n",
" d_bc = u_bc_anim - v_bc\n",
" d = igl.harmonic_weights(v, f, b, d_bc, 2)\n",
" d = igl.harmonic(v, f, b, d_bc, 2)\n",
" u = v + d\n",
" else:\n",
" u = igl.harmonic_weights(v, f, b, u_bc_anim, 2)\n",
" u = igl.harmonic(v, f, b, u_bc_anim, 2)\n",
" p.update_object(vertices=u)"
]
},
Expand Down Expand Up @@ -1235,7 +1235,7 @@
"\n",
"@interact(z_max=(0.0, 1.0), k=(1, 4))\n",
"def update(z_max, k):\n",
" z = igl.harmonic_weights(v, f, b, bc, int(k))\n",
" z = igl.harmonic(v, f, b, bc, int(k))\n",
" u[:, 2] = z_max * z\n",
" p.update_object(vertices=u)"
]
Expand Down Expand Up @@ -1457,7 +1457,7 @@
"bnd_uv = igl.map_vertices_to_circle(v, bnd)\n",
"\n",
"## Harmonic parametrization for the internal vertices\n",
"uv = igl.harmonic_weights(v, f, bnd, bnd_uv, 1)\n",
"uv = igl.harmonic(v, f, bnd, bnd_uv, 1)\n",
"v_p = np.hstack([uv, np.zeros((uv.shape[0],1))])\n",
"\n",
"p = plot(v, f, uv=uv, shading={\"wireframe\": False, \"flat\": False}, return_plot=True)\n",
Expand Down Expand Up @@ -1568,7 +1568,7 @@
"bnd_uv = igl.map_vertices_to_circle(v, bnd)\n",
"\n",
"## Harmonic parametrization for the internal vertices\n",
"uv = igl.harmonic_weights(v, f, bnd, bnd_uv, 1)\n",
"uv = igl.harmonic(v, f, bnd, bnd_uv, 1)\n",
"\n",
"arap = igl.ARAP(v, f, 2, np.zeros(0))\n",
"uva = arap.solve(np.zeros((0, 0)), uv)\n",
Expand Down