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! igl.arap_solve(bc,arap_data,V_uv) # Scale UV to make the texture more clear V_uv *= 20 # 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
return False igl.readOFF("../../tutorial/shared/decimated-knight.off",V,F) U = igl.eigen.MatrixXd(V) igl.readDMAT("../../tutorial/shared/decimated-knight-selection.dmat",S) # Vertices in selection b = igl.eigen.MatrixXi([[t[0] for t in [(i,S[i]) for i in range(0,V.rows())] if t[1] >= 0]]).transpose() # Centroid mid = 0.5*(V.colwiseMaxCoeff() + V.colwiseMinCoeff()) # Precomputation arap_data.max_iter = 100 igl.arap_precomputation(V,F,V.cols(),b,arap_data) # Set color based on selection C = igl.eigen.MatrixXd(F.rows(),3) purple = igl.eigen.MatrixXd([[80.0/255.0,64.0/255.0,255.0/255.0]]) gold = igl.eigen.MatrixXd([[255.0/255.0,228.0/255.0,58.0/255.0]]) for f in range(0,F.rows()): if S[F[f,0]]>=0 and S[F[f,1]]>=0 and S[F[f,2]]>=0: C.setRow(f,purple) else: C.setRow(f,gold) # Plot the mesh with pseudocolors viewer = igl.viewer.Viewer() viewer.data.set_mesh(U, F)
igl.readOFF("../../tutorial/shared/decimated-knight.off", V, F) U = igl.eigen.MatrixXd(V) igl.readDMAT("../../tutorial/shared/decimated-knight-selection.dmat", S) # Vertices in selection b = igl.eigen.MatrixXi([[ t[0] for t in [(i, S[i]) for i in range(0, V.rows())] if t[1] >= 0 ]]).transpose() # Centroid mid = 0.5 * (V.colwiseMaxCoeff() + V.colwiseMinCoeff()) # Precomputation arap_data.max_iter = 100 igl.arap_precomputation(V, F, V.cols(), b, arap_data) # Set color based on selection C = igl.eigen.MatrixXd(F.rows(), 3) purple = igl.eigen.MatrixXd([[80.0 / 255.0, 64.0 / 255.0, 255.0 / 255.0]]) gold = igl.eigen.MatrixXd([[255.0 / 255.0, 228.0 / 255.0, 58.0 / 255.0]]) for f in range(0, F.rows()): if S[F[f, 0]] >= 0 and S[F[f, 1]] >= 0 and S[F[f, 2]] >= 0: C.setRow(f, purple) else: C.setRow(f, gold) # Plot the mesh with pseudocolors viewer = igl.viewer.Viewer() viewer.data.set_mesh(U, F)