Files
epfl-archive/cs457-gc/assignment_3_3/notebook/tracing_test.ipynb
T
2022-04-07 18:46:57 +02:00

4.4 KiB

In [1]:
import numpy as np
from meshplot import plot
In [2]:
import sys
sys.path.append('../src')
In [3]:
import importlib, tracer_helper, tracer_utils
importlib.reload(tracer_helper)
importlib.reload(tracer_utils)
from tracer_utils import asymptotic_path
from tracer_helper import Mesh

Example

Build mesh from file

In [4]:
mesh = Mesh("../data/Model01.obj")
p = plot(mesh.V, mesh.F, shading={"wireframe": True,"width": 900, "height": 600}, return_plot=True, c=np.array([0,0.7,1]))
Renderer(camera=PerspectiveCamera(aspect=1.5, children=(DirectionalLight(color='white', intensity=0.6, positio…

Trace first asymptotic curve

Use principal directions V1

In [7]:
# Set tracing parameters
num_steps = 1000
step_size = 1e-6
num_neighbors = 4
first_principal_direction = False

# Pre-selection of vertices
idxA = [167,173,178,146,159,291,49,40,254,57,15,65,268,341,283]
# Tracing
for idx in idxA:
    P, A, PP = asymptotic_path(idx, mesh, num_steps, step_size, first_principal_direction, num_neighbors)

    # Plot starting vertex
    p.add_points(np.array([mesh.V[idx]]), shading={"point_size": 0.7, "point_color": "black"})
    # Plot edge-points shaping the asymptotic path
    p.add_points(P, shading={"point_size": 0.2,"point_color": "white"})
    # Plot asymptotic curve
    if(len(P)>1): 
        p.add_lines(P[:-1], P[1:], shading={"line_color": "white"})

Trace second asymptotic curve

Use principal directions V2

In [8]:
# Set tracing parameters
num_steps = 1000
step_size = 1e-6
num_neighbors = 4
first_principal_direction = True

# Pre-selection of vertices
idxB = [119,203,188,129,95,66,308,298,290,282,335,143,81,73,33]
# Tracing
for idx in idxB:
    P, A, PP = asymptotic_path(idx, mesh, num_steps, step_size, first_principal_direction, num_neighbors)
    
    # Plot starting vertex
    p.add_points(np.array([mesh.V[idx]]), shading={"point_size": 0.7, "point_color": "black"})
    # Plot edge-points shaping the asymptotic path
    p.add_points(P, shading={"point_size": 0.2,"point_color": "yellow"})
    # Plot asymptotic curve
    if(len(P)>1): 
        p.add_lines(P[:-1], P[1:], shading={"line_color": "yellow"})
In [ ]: