예제 #1
0
def pre_draw(viewer):
    global z_max, z_dir, k, resolve, V, U, Z, F, b, bc

    if resolve:
        igl.harmonic(V, F, b, bc, k, Z)
        resolve = False

    U.setCol(2, z_max * Z)
    viewer.data.set_vertices(U)
    viewer.data.compute_normals()

    if viewer.core.is_animating:
        z_max += z_dir
        z_dir *= (-1.0 if z_max >= 1.0 or z_max <= 0.0 else 1.0)

    return False
def pre_draw(viewer):
    global z_max, z_dir, k, resolve, V, U, Z, F, b, bc

    if resolve:
        igl.harmonic(V,F,b,bc,k,Z)
        resolve = False

    U.setCol(2,z_max*Z)
    viewer.data.set_vertices(U)
    viewer.data.compute_normals()

    if viewer.core.is_animating:
        z_max += z_dir
        z_dir *= (-1.0 if z_max>=1.0 or z_max<=0.0 else 1.0)

    return False
def pre_draw(viewer):
    global bc_frac, bc_dir,deformation_field, V, U, V_bc, U_bc, F, b
    # Determine boundary conditions
    if (viewer.core.is_animating):
        bc_frac += bc_dir
        bc_dir *= (-1.0 if bc_frac>=1.0 or bc_frac <= 0.0 else 1.0)

    U_bc_anim = V_bc+bc_frac*(U_bc-V_bc)

    if (deformation_field):
        D = igl.eigen.MatrixXd()
        D_bc = U_bc_anim - V_bc
        igl.harmonic(V,F,b,D_bc,2,D)
        U = V+D
    else:
        igl.harmonic(V,F,b,U_bc_anim,2,U)

    viewer.data.set_vertices(U)
    viewer.data.compute_normals()
    return False
예제 #4
0
def pre_draw(viewer):
    global bc_frac, bc_dir, deformation_field, V, U, V_bc, U_bc, F, b
    # Determine boundary conditions
    if (viewer.core.is_animating):
        bc_frac += bc_dir
        bc_dir *= (-1.0 if bc_frac >= 1.0 or bc_frac <= 0.0 else 1.0)

    U_bc_anim = V_bc + bc_frac * (U_bc - V_bc)

    if (deformation_field):
        D = igl.eigen.MatrixXd()
        D_bc = U_bc_anim - V_bc
        igl.harmonic(V, F, b, D_bc, 2, D)
        U = V + D
    else:
        igl.harmonic(V, F, b, U_bc_anim, 2, U)

    viewer.data.set_vertices(U)
    viewer.data.compute_normals()
    return False
    viewer.data.compute_normals()
    return False

# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/camelhead.off", V, F)

# Find the open boundary
bnd = igl.eigen.MatrixXi()
igl.boundary_loop(F,bnd)

# Map the boundary to a circle, preserving edge proportions
bnd_uv = igl.eigen.MatrixXd()
igl.map_vertices_to_circle(V,bnd,bnd_uv)

# Harmonic parametrization for the internal vertices
igl.harmonic(V,F,bnd,bnd_uv,1,V_uv)

# Scale UV to make the texture more clear
V_uv *= 5;

# Plot the mesh
viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)
viewer.data.set_uv(V_uv)
viewer.callback_key_down = key_down

# Disable wireframe
viewer.core.show_lines = False

# Draw checkerboard texture
viewer.core.show_texture = True
    return False


# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/camelhead.off", V, F)

# Find the open boundary
bnd = igl.eigen.MatrixXi()
igl.boundary_loop(F, bnd)

# Map the boundary to a circle, preserving edge proportions
bnd_uv = igl.eigen.MatrixXd()
igl.map_vertices_to_circle(V, bnd, bnd_uv)

# Harmonic parametrization for the internal vertices
igl.harmonic(V, F, bnd, bnd_uv, 1, V_uv)

# Scale UV to make the texture more clear
V_uv *= 5

# Plot the mesh
viewer = igl.viewer.Viewer()
viewer.data.set_mesh(V, F)
viewer.data.set_uv(V_uv)
viewer.callback_key_down = key_down

# Disable wireframe
viewer.core.show_lines = False

# Draw checkerboard texture
viewer.core.show_texture = True
        viewer.data.set_mesh(V,F)
        viewer.core.align_camera_center(V,F)

    viewer.data.compute_normals()
    return False

# Load a mesh in OFF format
igl.readOFF("../../tutorial/shared/camelhead.off", V, F)

# Compute the initial solution for ARAP (harmonic parametrization)
bnd = igl.eigen.MatrixXi()
igl.boundary_loop(F,bnd)
bnd_uv = igl.eigen.MatrixXd()
igl.map_vertices_to_circle(V,bnd,bnd_uv)

igl.harmonic(V,F,bnd,bnd_uv,1,initial_guess)

# Add dynamic regularization to avoid to specify boundary conditions
arap_data = igl.ARAPData()
arap_data.with_dynamics = True
b  = igl.eigen.MatrixXi.Zero(0,0);
bc = igl.eigen.MatrixXd.Zero(0,0);

# Initialize ARAP
arap_data.max_iter = 100

# 2 means that we're going to *solve* in 2d
igl.arap_precomputation(V,F,2,b,arap_data)

# Solve arap using the harmonic map as initial guess
V_uv = igl.eigen.MatrixXd(initial_guess) # important, make a copy of it!