コード例 #1
0
    ]).T


mesh = mesh_points()
plt.figure(figsize=(8, 8)).add_subplot(111, projection='3d').scatter(*mesh.T)
plt.show()

ffd = FFD([2, 2, 2])
print(ffd)

print('Movements of point[{}, {}, {}] along x: {}'.format(
    1, 1, 1, ffd.array_mu_x[1, 1, 1]))
print('Movements of point[{}, {}, {}] along z: {}'.format(
    1, 1, 1, ffd.array_mu_z[1, 1, 1]))

ffd.array_mu_x[1, 1, 1] = 2
ffd.array_mu_z[1, 1, 1] = 0.8
print()
print('Movements of point[{}, {}, {}] along x: {}'.format(
    1, 1, 1, ffd.array_mu_x[1, 1, 1]))
print('Movements of point[{}, {}, {}] along z: {}'.format(
    1, 1, 1, ffd.array_mu_z[1, 1, 1]))

new_mesh = ffd(mesh)
print(type(new_mesh), new_mesh.shape)

ax = plt.figure(figsize=(8, 8)).add_subplot(111, projection='3d')
ax.scatter(*new_mesh.T)
ax.scatter(*ffd.control_points().T, s=50, c='red')
plt.show()
コード例 #2
0
        # FFD オブジェクトの内容
        # conversion_unit = 1.0
        # n_control_points = [2 2 2]
        # box_length = [1. 1. 1.]
        # rot_angle  = [0. 0. 0.]
        # array_mu_x = [ [ [0. 0.] [0. 0.] ] [ [0. 0.] [0. 0.] ] ] / shape = (2, 2, 2)
        # array_mu_y = [ [ [0. 0.] [0. 0.] ] [ [0. 0.] [0. 0.] ] ] / shape = (2, 2, 2)
        # array_mu_z = [ [ [0. 0.] [0. 0.] ] [ [0. 0.] [0. 0.] ] ] / shape = (2, 2, 2)
        # デフォルト設定 : 格子の長さ1、原点 $(0, 0, 0)$、回転なし
        print("ffd : \n",
              ffd)  # conversion_unit = 1.0, n_control_points, box_length, ...
        print("ffd.array_mu_x.shape : \n", ffd.array_mu_x.shape)
        print("ffd.array_mu_y.shape : \n", ffd.array_mu_y.shape)
        print("ffd.array_mu_z.shape : \n", ffd.array_mu_z.shape)
        print("ffd.control_points().shape : \n",
              ffd.control_points().shape)  # (8, 3)

    # __call__(src_pts) を呼び出すことで、指定された頂点の FFD 変形を実行
    # src_pts (numpy.ndarray) : the array of dimensions (n_points, 3) containing the points to deform. The points have to be arranged by row.
    mesh_verts_ffd = ffd(mesh.verts_packed().clone().cpu().numpy())

    # ffd.perform() でも実行可能
    #ffd.perform()
    #mesh_verts_ffd = ffd.modified_mesh_points
    if (args.debug):
        #print( "mesh_verts_ffd : ", mesh_verts_ffd )    # [[ 0.348799  -0.334989  -0.0832331], ...
        print("mesh_verts_ffd.shape : ", mesh_verts_ffd.shape)

    # FDD で変形した頂点からメッシュを再構成
    mesh_ffd = Meshes([torch.from_numpy(mesh_verts_ffd).float().to(device)],
                      [mesh.faces_packed()]).to(device)