172 lines
4.4 KiB
Plaintext
172 lines
4.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import numpy as np\n",
|
|
"from meshplot import plot"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import sys\n",
|
|
"sys.path.append('../src')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import importlib, tracer_helper, tracer_utils\n",
|
|
"importlib.reload(tracer_helper)\n",
|
|
"importlib.reload(tracer_utils)\n",
|
|
"from tracer_utils import asymptotic_path\n",
|
|
"from tracer_helper import Mesh"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Example\n",
|
|
"Build mesh from file"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "f19ce42be2f6405796de381ba4b89b42",
|
|
"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": [
|
|
"mesh = Mesh(\"../data/Model01.obj\")\n",
|
|
"p = plot(mesh.V, mesh.F, shading={\"wireframe\": True,\"width\": 900, \"height\": 600}, return_plot=True, c=np.array([0,0.7,1]))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Trace first asymptotic curve\n",
|
|
"Use principal directions V1"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Set tracing parameters\n",
|
|
"num_steps = 1000\n",
|
|
"step_size = 1e-6\n",
|
|
"num_neighbors = 4\n",
|
|
"first_principal_direction = False\n",
|
|
"\n",
|
|
"# Pre-selection of vertices\n",
|
|
"idxA = [167,173,178,146,159,291,49,40,254,57,15,65,268,341,283]\n",
|
|
"# Tracing\n",
|
|
"for idx in idxA:\n",
|
|
" P, A, PP = asymptotic_path(idx, mesh, num_steps, step_size, first_principal_direction, num_neighbors)\n",
|
|
"\n",
|
|
" # Plot starting vertex\n",
|
|
" p.add_points(np.array([mesh.V[idx]]), shading={\"point_size\": 0.7, \"point_color\": \"black\"})\n",
|
|
" # Plot edge-points shaping the asymptotic path\n",
|
|
" p.add_points(P, shading={\"point_size\": 0.2,\"point_color\": \"white\"})\n",
|
|
" # Plot asymptotic curve\n",
|
|
" if(len(P)>1): \n",
|
|
" p.add_lines(P[:-1], P[1:], shading={\"line_color\": \"white\"})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Trace second asymptotic curve\n",
|
|
"Use principal directions V2"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Set tracing parameters\n",
|
|
"num_steps = 1000\n",
|
|
"step_size = 1e-6\n",
|
|
"num_neighbors = 4\n",
|
|
"first_principal_direction = True\n",
|
|
"\n",
|
|
"# Pre-selection of vertices\n",
|
|
"idxB = [119,203,188,129,95,66,308,298,290,282,335,143,81,73,33]\n",
|
|
"# Tracing\n",
|
|
"for idx in idxB:\n",
|
|
" P, A, PP = asymptotic_path(idx, mesh, num_steps, step_size, first_principal_direction, num_neighbors)\n",
|
|
" \n",
|
|
" # Plot starting vertex\n",
|
|
" p.add_points(np.array([mesh.V[idx]]), shading={\"point_size\": 0.7, \"point_color\": \"black\"})\n",
|
|
" # Plot edge-points shaping the asymptotic path\n",
|
|
" p.add_points(P, shading={\"point_size\": 0.2,\"point_color\": \"yellow\"})\n",
|
|
" # Plot asymptotic curve\n",
|
|
" if(len(P)>1): \n",
|
|
" p.add_lines(P[:-1], P[1:], shading={\"line_color\": \"yellow\"})"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"interpreter": {
|
|
"hash": "d74ce2d711eca57e47550fdd427f707c5faa08517318f0967f4aae699c902c0e"
|
|
},
|
|
"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": 4
|
|
}
|