Barycenter Free-form Deformation

class BFFD(fixval=None, n_control_points=None, ffd_mask=None)[source]

Bases: CFFD

Class that handles the Barycenter Free Form Deformation on the mesh points.

Parameters:

n_control_points (list) – number of control points in the x, y, and z direction. Default is [2, 2, 2].

Variables:
  • box_length (numpy.ndarray) – dimension of the FFD bounding box, in the x, y and z direction (local coordinate system).

  • box_origin (numpy.ndarray) – the x, y and z coordinates of the origin of the FFD bounding box.

  • n_control_points (numpy.ndarray) – the number of control points in the x, y, and z direction.

  • array_mu_x (numpy.ndarray) – collects the displacements (weights) along x, normalized with the box length x.

  • array_mu_y (numpy.ndarray) – collects the displacements (weights) along y, normalized with the box length y.

  • array_mu_z (numpy.ndarray) – collects the displacements (weights) along z, normalized with the box length z.

  • fun (callable) – it defines the F of the constraint F(x)=c. Default is the constant 1 function.

  • fixval (numpy.ndarray) – it defines the c of the constraint F(x)=c. Default is 1.

  • mask (numpy.ndarray) – a boolean tensor that tells to the class which control points can be moved, and in what direction, to enforce the constraint. The tensor has shape (n_x,n_y,n_z,3), where the last dimension indicates movement on x,y,z respectively. Default is all true.

Example:
>>> from pygem import BFFD
>>> b = np.random.rand(3)
>>> bffd = BFFD(b, [2, 2, 2])
>>> bffd.read_parameters('tests/test_datasets/parameters_test_cffd')
>>> original_mesh_points = np.load("tests/test_datasets/test_sphere_cffd.npy")
>>> bffd.adjust_control_points(original_mesh_points[:-4])
>>> assert np.isclose(np.linalg.norm(bffd.fun(bffd.ffd(original_mesh_points[:-4])) - b), np.array([0.]))
>>> new_mesh_points = bffd.ffd(original_mesh_points)