750 lines
61 KiB
Plaintext
750 lines
61 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "47a1752b-1db4-4004-9991-164388c0fd5d",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import numpy as np\n",
|
||
|
"import meshplot as mp"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"id": "0f4900fe-ce65-410a-b8d3-088e7e0804a5",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import igl\n",
|
||
|
"import scipy as sp\n",
|
||
|
"import numpy as np\n",
|
||
|
"from meshplot import plot, subplot, interact\n",
|
||
|
"import time\n",
|
||
|
"import copy\n",
|
||
|
"import matplotlib.pyplot as plt"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "9c83b851-d0aa-4fb0-9030-a285ca6b2b64",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import sys\n",
|
||
|
"sys.path.append('../src')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "43cb9cef-4959-4c9b-98ef-3a603f57bcb2",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import importlib, utils, laplacian_utils, mean_curvature_flow, remesher_helper\n",
|
||
|
"importlib.reload(utils)\n",
|
||
|
"importlib.reload(laplacian_utils)\n",
|
||
|
"importlib.reload(mean_curvature_flow)\n",
|
||
|
"importlib.reload(remesher_helper)\n",
|
||
|
"from utils import parse_input_mesh, normalize_area, get_diverging_colors, remesh\n",
|
||
|
"from mean_curvature_flow import MCF"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"id": "2570faf5-9582-42ac-ace4-ca82c781a806",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"epsilon1 = 5e-2\n",
|
||
|
"epsilon2 = 1e-3\n",
|
||
|
"mesh_color = np.array([0,0.7,1])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "e8d2f669-864f-4c8e-8519-5672862cc024",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Example 1"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"id": "7a65d5c7-d774-4d5a-946c-69d730f19519",
|
||
|
"metadata": {
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Warning: readOBJ() ignored non-comment line 3:\n",
|
||
|
" o BezierCircle.002_Mesh.002\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"v1, f1, num_bdry_vx, num_intr_vx = parse_input_mesh(\"../data/mesh.obj\")\n",
|
||
|
"curr_mcf = MCF(num_bdry_vx, num_intr_vx)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "a82f1487-56e3-4ecb-b71c-b3f59d4070be",
|
||
|
"metadata": {
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/opt/notebooks/assignment_3_2/notebook/../src/laplacian_utils.py:83: RuntimeWarning: divide by zero encountered in true_divide\n",
|
||
|
" cotan = np.sum(a*b,axis=1) / np.sqrt(np.sum(np.cross(a, b)**2, axis=-1))\n",
|
||
|
"/opt/notebooks/assignment_3_2/notebook/../src/mean_curvature_flow.py:35: RuntimeWarning: divide by zero encountered in true_divide\n",
|
||
|
" Minv = sp.sparse.diags(1/self.M.diagonal())\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"0 True False\n",
|
||
|
"Run 1001 iterations of unstable mean curvature flow\n",
|
||
|
"took 4.51453971862793 seconds\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"start = time.time()\n",
|
||
|
"vs1, average_mean_curvature_list1 = curr_mcf.run_mean_curvature_flow(v1, f1, 1000, 5e-2, 1e-3)\n",
|
||
|
"print(\"Run {} iterations of unstable mean curvature flow\".format(len(average_mean_curvature_list1)))\n",
|
||
|
"print(\"took {} seconds\".format(time.time() - start))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"id": "652d1fa7-ad74-4c50-85c1-6a9e622b7ec8",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7fde6cf98820>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAOHUlEQVR4nO3c34tc533H8fenUkQJSbFdybYsyV011UXVUogYhCG9CPUPJMVYvuiFDYmFcyEMNTi0wVXqf8CJoTGmxkakBpm4mEASIoyCYru5VeqVY8uoiuONSKqNFHuTCyfgCyHy7cUetevNSDu7Z1a76+f9gmHmnPOcmedhwG/NmVmnqpAkteuPVnoCkqSVZQgkqX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qLgEPA8eBM8C3qup0z9eVJI3JgpeGrqaqfgPcPmT/eWDfnO1jwLEFnmuiz1wkSUvjXxZLUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1zhBIUuMMgSQ1LlW10nNYtCQzwC9Weh5LsBH49UpP4hpqbb3gmluxVtf8Z1W1af7ONRmCtSrJZFUNVnoe10pr6wXX3IqP2pq9NCRJjTMEktQ4Q3BtHV7pCVxjra0XXHMrPlJr9jsCSWqcnwgkqXGGQJIaZwjGKMkNSV5O8k53f/0Vxu1J8naSqSSHhhz/cpJKsnH5Z91P3zUneSLJT5KcSvLdJNdds8kv0gjvW5I81R0/lWTXqOeuVktdc5JtSX6Y5EyS00keufazX5o+73N3fF2SHyd56drNuqeq8jamG/A14FD3+BDw1SFj1gE/A/4c2AC8Ceycc3wbcJz
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.plot(average_mean_curvature_list1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"id": "14411752-e879-40f4-a3ce-928cfa2e888e",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "c0cdcc78349b4af19da435cb31d9a177",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"Renderer(camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(color='white', intensity=0.6, positio…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "c064b33d7a5140f48dd8ebc45c4a1898",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"interactive(children=(IntSlider(value=0, description='level', max=1000), Output()), _dom_classes=('widget-inte…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"p1 = mp.plot(vs1[0], f1, shading={\"wireframe\": False,\"width\": 900, \"height\": 600}, return_plot=True, c=mesh_color)\n",
|
||
|
"\n",
|
||
|
"@interact(level=(0, len(vs1)-1))\n",
|
||
|
"def mcf(level=0):\n",
|
||
|
" p1.update_object(vertices=vs1[level])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "baf4bc95-68df-4a4b-967f-a2b555d4947c",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Example 2"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"id": "147b044e-4491-4e45-bf91-df58f870429f",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"v2, f2, num_bdry_vx, num_intr_vx = parse_input_mesh(\"../data/half_cube_remesh.obj\")\n",
|
||
|
"curr_mcf = MCF(num_bdry_vx, num_intr_vx)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "dbc8d3df-ac70-4c75-a6e7-d624595d5a59",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"0 False False\n",
|
||
|
"Insufficient improvement from the previous iteration!\n",
|
||
|
"Run 2 iterations of unstable mean curvature flow\n",
|
||
|
"took 0.16465258598327637 seconds\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"start = time.time()\n",
|
||
|
"vs2, average_mean_curvature_list2 = curr_mcf.run_mean_curvature_flow(v2, f2, 1000, epsilon1, epsilon2)\n",
|
||
|
"print(\"Run {} iterations of unstable mean curvature flow\".format(len(average_mean_curvature_list2)))\n",
|
||
|
"print(\"took {} seconds\".format(time.time() - start))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "87c6c46b-36e4-4206-96da-b3f10d897387",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7fde649cd100>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD6CAYAAACoCZCsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAnM0lEQVR4nO3dd3RUZf7H8fc3DQgdCYgU6b0T6SS6EJol4loAV1gbIiIlW9TtbnXdNRRFELBhARFREGlBdxM6hN4h9N6lKqE8vz8y7C/GKBNIMpmZz+ucOZN773Mz3+fAmc/cZ2a+MeccIiISfEJ8XYCIiPiGAkBEJEgpAEREgpQCQEQkSCkARESClAJARCRIeRUAZtbVzLaYWZqZPZ/NcTOzkZ7ja82seaZjg81svZltMLMhmfaXMbMkM9vmuS+dKzMSERGv2LW+B2BmocBWIA7YBywHejnnNmYa0x14FugOtAJGOOdamVlDYBLQEkgHZgNPO+e2mdnLwAnn3Eue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5Su6GhAJVAoA+Z+QEOORNlWZMzSG26qW4cXPN/LgG4tJO3LG16WJSB5QAMj3VCodyTuP3kbig03YfvQs3Ucs4LWvtqm5nEiAUQBItsyM+5pXImloLHENyvPvuVu55zU1lxMJJAoA+VFRxQsxqndz3nikBcfOZjSXe2mWmsuJBAIFgHilS4ObmTc0lvubV2JM8na6j5jPsp1qLifizxQA4rWSkeH88/7GvP94K9IvX+HBNxbz+8/Wc+bbi74uTUSugwJAcqx9rbLMHRrDY+2q8f7S3XQZlsJ/thzxdVkikkMKALkukRFh/OH
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.plot(average_mean_curvature_list2)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"id": "db07878e-9438-413d-9eb5-a2ffb8f02118",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "7151634c238b430d8c5ef8e8302a82bc",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.0, -0.0…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "3cd498374b2e4f5f8889891bfed74ffa",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"interactive(children=(IntSlider(value=0, description='level', max=0), Output()), _dom_classes=('widget-interac…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"p2 = mp.plot(vs2[0], f2, shading={\"wireframe\": False, \"flat\": True}, c=mesh_color)\n",
|
||
|
"\n",
|
||
|
"@interact(level=(0, len(vs2)-2))\n",
|
||
|
"def mcf(level=0):\n",
|
||
|
" p2.update_object(vertices=vs2[level])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "613b0257-40c3-4f8f-8840-ea9dccccefa9",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Example 3"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"id": "ddd60020-bc75-4984-937f-ab30359b559c",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"v3, f3, num_bdry_vx, num_intr_vx = parse_input_mesh(\"../data/cube_remesh.obj\")\n",
|
||
|
"curr_mcf = MCF(num_bdry_vx, num_intr_vx)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"id": "661c1cfb-3ac6-434a-b385-a94be86f2802",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"0 False False\n",
|
||
|
"Insufficient improvement from the previous iteration!\n",
|
||
|
"Run 3 iterations of unstable mean curvature flow\n",
|
||
|
"took 0.43959999084472656 seconds\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"start = time.time()\n",
|
||
|
"vs3, average_mean_curvature_list3 = curr_mcf.run_mean_curvature_flow(v3, f3, 1000, epsilon1, epsilon2)\n",
|
||
|
"print(\"Run {} iterations of unstable mean curvature flow\".format(len(average_mean_curvature_list3)))\n",
|
||
|
"print(\"took {} seconds\".format(time.time() - start))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 22,
|
||
|
"id": "06d71f4a-214a-4fbc-84ee-aad174ac104f",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7ff33eae6910>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 22,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAirUlEQVR4nO3deXxU9b3/8dcnOzsCYZGAICKbsiQptmpdunhBa1FrFQR6l/4eiBWXn7VXbXvV1tva29reuiDLtd7foyAi1qVY97Zaq1YlgbDJYgSECEIACXvWz++PDDqEhJyEzJzJ5P18PHhk5pzvmbwzj8P7nDlnZo65OyIikrxSwg4gIiKxpaIXEUlyKnoRkSSnohcRSXIqehGRJJcWdoD69OjRwwcMGBB2DBGRVqOwsHCnu2fXNy8hi37AgAEUFBSEHUNEpNUws48amqdDNyIiSU5FLyKS5FT0IiJJTkUvIpLkVPQiIklORS8ikuRU9CIiSS5pir6mxpn5WjGrPi4LO4qISEJJmqLfd7iKx975iGvnFbL7QEXYcUREEkbSFH2X9unMnppH6f5ybnx8GdU1uqCKiAgkUdEDjMzpyn9OOIM3i3fyq5fXhR1HRCQhJFXRA1z1hX5MPqs/s//2IS+s3BZ2HBGR0CVd0QPceelwxvTvyq1PLueD7fvCjiMiEqqkLPrMtFRmTc6jfUYa0+YVsvdwZdiRRERCk5RFD9C7SxYPT85ly+6D3PLEcmp0clZE2qikLXqAsQO78eNLhvHnNdt56LXisOOI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fQHXjYzACqIu+w6QU8E5mWBixw95di8pckuR9
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.plot(average_mean_curvature_list3)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"id": "4e3faeb6-3f38-43d1-a4a0-047b62e11bf3",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "784a5819fbab4817aa5a7c1f69d24287",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.0, 0.0,…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "006a6c74d2cf4e1e9d435ab4425e62ea",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"interactive(children=(IntSlider(value=0, description='level', max=1), Output()), _dom_classes=('widget-interac…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"p3 = mp.plot(vs3[0], f3, shading={\"wireframe\": False, \"flat\": True}, c=mesh_color)\n",
|
||
|
"\n",
|
||
|
"@interact(level=(0, len(vs3)-2))\n",
|
||
|
"def mcf(level=0):\n",
|
||
|
" p3.update_object(vertices=vs3[level])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "d92f7eea-e7f0-4a92-b557-21637eb7f939",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Your Own Minimal Surface!"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "242feed4-775d-4c68-aadb-707382dde2f5",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Visualize your blender output\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "105532b3-69ab-4835-9768-5a03df5051af",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"blender_input_filename = \"../data/mesh.obj\"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"id": "c9e2c901-d3f9-4a2f-bb3b-27a8be7b2311",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Warning: readOBJ() ignored non-comment line 3:\n",
|
||
|
" o BezierCircle.002_Mesh.002\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "41947aa5491d4b5e9dc8aa2664d32471",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"Renderer(camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(color='white', intensity=0.6, positio…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"v,f = igl.read_triangle_mesh(blender_input_filename)\n",
|
||
|
"\n",
|
||
|
"p1 = plot(v, f, shading={\"wireframe\": True,\"width\": 900, \"height\": 600}, return_plot=True, c=mesh_color)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "264e0ee7-8a7d-44b0-8221-fc15b38ce77e",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Remesh"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "b6905f01-bc8b-4421-b2fb-5fa2b0b79a90",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"The input should be a triangle mesh or a quad mesh. This might takes a while depends on your design. You can adjust the `mesh_size` parameter in the `remesh` function."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"id": "4ba2345b-dac3-45e6-a28e-123929f70b93",
|
||
|
"metadata": {
|
||
|
"scrolled": true,
|
||
|
"tags": []
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Info : Classifying surfaces (angle: 180)...\n",
|
||
|
"Info : Splitting triangulations to make them parametrizable:\n",
|
||
|
"Info : Model has 0 non manifold mesh edges and 3784 boundary mesh edges\n",
|
||
|
"Info : Found 1 model surfaces\n",
|
||
|
"Info : Found 1 model curves\n",
|
||
|
"Info : Done classifying surfaces (Wall 0.0727004s, CPU 0.072207s)\n",
|
||
|
"Info : Creating geometry of discrete curves...\n",
|
||
|
"Info : Done creating geometry of discrete curves (Wall 0.000467486s, CPU 0.000622s)\n",
|
||
|
"Info : Creating geometry of discrete surfaces...\n",
|
||
|
"Info : [ 0%] Creating geometry \r",
|
||
|
"Info : Done creating geometry of discrete surfaces (Wall 0.0390655s, CPU 0.038785s)\n",
|
||
|
"Info : Meshing 1D...\n",
|
||
|
"Info : Meshing curve 3 (Discrete curve)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Warning : Poor input mesh quality (min gamma = 0.000204069) for computing parametrization\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Info : Done meshing 1D (Wall 0.314341s, CPU 0.311509s)\n",
|
||
|
"Info : Meshing 2D...\n",
|
||
|
"Info : Meshing surface 2 (Discrete surface, Frontal-Delaunay)\n",
|
||
|
"Info : Meshing surface 2 (Discrete surface, MeshAdapt)\n",
|
||
|
"Info : Done meshing 2D (Wall 40.6868s, CPU 40.2294s)\n",
|
||
|
"Info : 12169 nodes 24337 elements\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"blender_input_filename = \"../data/mesh.obj\"\n",
|
||
|
"remesh_output_name = \"../data/remesh.obj\"\n",
|
||
|
"remesh(blender_input_filename, remesh_output_name)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"id": "245e2f45-c1ee-4f9f-86cd-e7fd9a0404de",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "94aa5a02f7f84de09ccca26a5f783181",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"Renderer(camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(color='white', intensity=0.6, positio…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# v,f = igl.read_triangle_mesh(remesh_output_name)\n",
|
||
|
"v, f, num_bdry_vx, num_intr_vx = parse_input_mesh(remesh_output_name)\n",
|
||
|
"curr_mcf = MCF(num_bdry_vx, num_intr_vx)\n",
|
||
|
"\n",
|
||
|
"p2 = plot(v, f, shading={\"wireframe\": True,\"width\": 900, \"height\": 600}, return_plot=True, c=mesh_color)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "117e73d7-f291-4aa1-b783-cf8e2ae70a21",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Run optimization"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"id": "632ea182-feb9-46b0-b2b5-83b32e65f9b7",
|
||
|
"metadata": {
|
||
|
"scrolled": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"0 False False\n",
|
||
|
"Insufficient improvement from the previous iteration!\n",
|
||
|
"Run 3 iterations of unstable mean curvature flow\n",
|
||
|
"took 0.14172720909118652 seconds\n",
|
||
|
"607 11562\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "38a95bd1258a4e3d8c9693b2458cb87b",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"Renderer(camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(color='white', intensity=0.6, positio…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAh2klEQVR4nO3deXhU9dn/8fednWws2VAWQVYjOwPWXdta0S5oaxVEwD4sorW11tpa28fuy6+bW1UU6XNBK7XaSktbt1a7W1smyCpCAqJEIAlrEiAJge/vjxlkDAk5gUzOLJ/XdXElc873m9wZj5+z3Tkx5xwiIpK4UvwuQEREoktBLyKS4BT0IiIJTkEvIpLg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dXfaPfJYlIHFHQx4nTundjwYwANXWNzPtFGY3Nh/0uSUTihII+jozu14MfXzua5Vv28JWl6sQREW90MzbOfGTU6ZRX1XP/S+UMKc7lposH+V2SiMQ4BX0cuu0DQ6ioqef7z7/BoKJcPliqThwRaZsu3cShlBTjR9eMZmSf7tz25Gus317rd0kiEsMU9HGqW0YqC2YEyM1KY/aiIDV16sQRkdYp6ONYSX4Wj8+YwK79oU6chkPqxBGR4yno49zIvt35ybVjKHtrD3c/s0adOCJyHAV9Arhy5Gl8/rKhPPPaOzzyt01+lyMiMUZdNwniM+8fTHl1PT98YQODinK5/OzefpckIjFCR/QJwsz44TWjGNW3B7f/aiXrtu3zuyQRiREK+gSSlZ7Kgunj6d4tnTmLglTXNfhdkojEAE9Bb2aTzGyDmVWY2V2trJ9mZqvD/14xs9Fe50rnKs7PYsGMAHsOHGLuYnXiiIiHoDe
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "8ad4b5e8dcab47cf9a267b363204b3f8",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"interactive(children=(IntSlider(value=0, description='level', max=2), Output()), _dom_classes=('widget-interac…"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"start = time.time()\n",
|
||
|
"vs, average_mean_curvature_list = curr_mcf.run_mean_curvature_flow(v, f, 1000, 5e-2, 1e-3)\n",
|
||
|
"print(\"Run {} iterations of unstable mean curvature flow\".format(len(average_mean_curvature_list)))\n",
|
||
|
"print(\"took {} seconds\".format(time.time() - start))\n",
|
||
|
"print(num_bdry_vx, num_intr_vx)\n",
|
||
|
"plt.plot(average_mean_curvature_list)\n",
|
||
|
"p = mp.plot(vs[0], f, shading={\"wireframe\": False,\"width\": 900, \"height\": 600}, return_plot=True, c=mesh_color)\n",
|
||
|
"\n",
|
||
|
"@interact(level=(0, len(vs)-1))\n",
|
||
|
"def mcf(level=0):\n",
|
||
|
" p.update_object(vertices=vs[level])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"id": "b5f784cc",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"True"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"igl.write_obj(\"../data/final.obj\", vs[-1], f.astype('int64'))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "36712dd0",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "81477473",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.9.7"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|