1- import numpy as np
2-
31from pygem .cffd import CFFD
4-
5-
2+ import numpy as np
63class BFFD (CFFD ):
7- """Class that handles the Barycenter Free Form Deformation on the mesh
8- points.
9-
4+ '''
5+ Class that handles the Barycenter Free Form Deformation on the mesh points.
6+
107 :param list n_control_points: number of control points in the x, y, and z
118 direction. Default is [2, 2, 2].
12-
9+
1310 :cvar numpy.ndarray box_length: dimension of the FFD bounding box, in the
1411 x, y and z direction (local coordinate system).
1512 :cvar numpy.ndarray box_origin: the x, y and z coordinates of the origin of
@@ -22,15 +19,11 @@ class BFFD(CFFD):
2219 y, normalized with the box length y.
2320 :cvar numpy.ndarray array_mu_z: collects the displacements (weights) along
2421 z, normalized with the box length z.
25- :cvar callable fun: it defines the F of the constraint F(x)=c.
26- Default is the constant 1 function.
27- :cvar numpy.ndarray fixval: it defines the c of the constraint
28- F(x)=c. Default is 1.
29- :cvar numpy.ndarray mask: a boolean tensor that tells to the class
30- which control points can be moved, and in what direction,
31- to enforce the constraint.
32- The tensor has shape (n_x,n_y,n_z,3), where the last
33- dimension indicates movement
22+ :cvar callable fun: it defines the F of the constraint F(x)=c. Default is the constant 1 function.
23+ :cvar numpy.ndarray fixval: it defines the c of the constraint F(x)=c. Default is 1.
24+ :cvar numpy.ndarray mask: a boolean tensor that tells to the class
25+ which control points can be moved, and in what direction, to enforce the constraint.
26+ The tensor has shape (n_x,n_y,n_z,3), where the last dimension indicates movement
3427 on x,y,z respectively. Default is all true.
3528
3629 :Example:
@@ -39,13 +32,11 @@ class BFFD(CFFD):
3932 >>> b = np.random.rand(3)
4033 >>> bffd = BFFD(b, [2, 2, 2])
4134 >>> bffd.read_parameters('tests/test_datasets/parameters_test_cffd')
42- >>> original_mesh_points =
43- np.load("tests/test_datasets/test_sphere_cffd.npy")
35+ >>> original_mesh_points = np.load("tests/test_datasets/test_sphere_cffd.npy")
4436 >>> bffd.adjust_control_points(original_mesh_points[:-4])
45- >>> assert np.isclose(np.linalg.norm(bffd.fun(bffd.ffd(
46- ... original_mesh_points[:-4])) - b), np.array([0.]))
37+ >>> assert np.isclose(np.linalg.norm(bffd.fun(bffd.ffd(original_mesh_points[:-4])) - b), np.array([0.]))
4738 >>> new_mesh_points = bffd.ffd(original_mesh_points)
48- """
39+ '''
4940
5041 def __init__ (self , fixval = None , n_control_points = None , ffd_mask = None ):
5142 super ().__init__ (fixval , None , n_control_points , ffd_mask , None )
@@ -55,6 +46,7 @@ def linfun(x):
5546
5647 self .fun = linfun
5748 self .fixval = fixval
58- self .fun_mask = np .array (
59- [[True , False , False ], [False , True , False ], [False , False , True ]]
60- )
49+ self .fun_mask = np .array ([[True , False , False ], [False , True , False ],
50+ [False , False , True ]])
51+
52+
0 commit comments