Skip to content

Commit dcae4e9

Browse files
fixing other init files
1 parent 481a6e5 commit dcae4e9

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

pygem/bffd.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class BFFD(CFFD):
1616
'''
1717
Class that handles the Barycenter Free Form Deformation on the mesh points.
1818
19+
:param list n_control_points: number of control points in the x, y, and z
20+
direction. Default is [2, 2, 2].
21+
1922
:param list n_control_points: number of control points in the x, y, and z
2023
direction. Default is [2, 2, 2].
2124
@@ -33,12 +36,16 @@ class BFFD(CFFD):
3336
y, normalized with the box length y.
3437
:cvar numpy.ndarray array_mu_z: collects the displacements (weights) along
3538
z, normalized with the box length z.
36-
:cvar callable linconstraint: it defines the F of the constraint F(x)=c.
37-
:cvar numpy.ndarray valconstraint: it defines the c of the constraint F(x)=c.
38-
:cvar list indices: it defines the indices of the control points
39-
that are moved to enforce the constraint. The control index is obtained by doing:
40-
all_indices=np.arange(n_x*n_y*n_z*3).reshape(n_x,n_y,n_z,3).tolist().
41-
:cvar numpy.ndarray M: a SDP weigth matrix. It must be of size len(indices) x len(indices).
39+
:cvar callable fun: it defines the F of the constraint F(x)=c. Default is the constant 1 function.
40+
:cvar numpy.ndarray fixval: it defines the c of the constraint F(x)=c. Default is 1.
41+
:cvar numpy.ndarray mask: a boolean tensor that tells to the class
42+
which control points can be moved, and in what direction, to enforce the constraint.
43+
The tensor has shape (n_x,n_y,n_z,3), where the last dimension indicates movement
44+
on x,y,z respectively. Default is all true.
45+
:cvar numpy.ndarray weight_matrix: a symmetric positive definite weigth matrix.
46+
It must be of row and column size the number of trues in the mask.
47+
It weights the movemement of the control points which have a true flag in the mask.
48+
Default is identity.
4249
4350
:Example:
4451
@@ -54,8 +61,8 @@ class BFFD(CFFD):
5461
>>> new_mesh_points = bffd(original_mesh_points)
5562
>>> assert np.isclose(np.linalg.norm(bffd.linconstraint(new_mesh_points)-b),np.array([0.]))
5663
'''
57-
def __init__(self, n_control_points=None):
58-
super().__init__(n_control_points)
64+
def __init__(self, n_control_points=None, fun=None, fixval=None, weight_matrix=None, mask=None):
65+
super().__init__(n_control_points,fun,fixval,weight_matrix,mask)
5966

6067
def linfun(x):
6168
return np.mean(x.reshape(-1, 3), axis=0)

pygem/cffd.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ def __init__(self, n_control_points=None, fun=None, fixval=None, weight_matrix=N
8282
self.weight_matrix=np.eye(np.sum(self.mask.astype(int)))
8383

8484
def adjust_control_points(self,src_pts):
85+
'''
86+
Adjust the FFD control points such that F(ffd(src_pts))=c
87+
88+
:param np.ndarray src_pts: the points whose deformation we want to be
89+
constrained.
90+
:rtype: None.
91+
'''
92+
8593
saved_parameters = self._save_parameters()
8694
indices=np.arange(np.prod(self.n_control_points)*3)[self.mask.reshape(-1)]
8795
A, b = self._compute_linear_map(src_pts, saved_parameters.copy(),indices)

pygem/vffd.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class VFFD(CFFD):
1717
'''
1818
Class that handles the Volumetric Free Form Deformation on the mesh points.
1919
20+
:param list n_control_points: number of control points in the x, y, and z
21+
direction. Default is [2, 2, 2].
22+
2023
:param list n_control_points: number of control points in the x, y, and z
2124
direction. Default is [2, 2, 2].
2225
@@ -34,12 +37,16 @@ class VFFD(CFFD):
3437
y, normalized with the box length y.
3538
:cvar numpy.ndarray array_mu_z: collects the displacements (weights) along
3639
z, normalized with the box length z.
37-
:cvar callable linconstraint: it defines the F of the constraint F(x)=c.
38-
:cvar numpy.ndarray valconstraint: it defines the c of the constraint F(x)=c.
39-
:cvar list indices: it defines the indices of the control points
40-
that are moved to enforce the constraint. The control index is obtained by doing:
41-
all_indices=np.arange(n_x*n_y*n_z*3).reshape(n_x,n_y,n_z,3).tolist().
42-
:cvar numpy.ndarray M: a SDP weigth matrix. It must be of size len(indices) x len(indices).
40+
:cvar callable fun: it defines the F of the constraint F(x)=c. Default is the constant 1 function.
41+
:cvar numpy.ndarray fixval: it defines the c of the constraint F(x)=c. Default is 1.
42+
:cvar numpy.ndarray mask: a boolean tensor that tells to the class
43+
which control points can be moved, and in what direction, to enforce the constraint.
44+
The tensor has shape (n_x,n_y,n_z,3), where the last dimension indicates movement
45+
on x,y,z respectively. Default is all true.
46+
:cvar numpy.ndarray weight_matrix: a symmetric positive definite weigth matrix.
47+
It must be of row and column size the number of trues in the mask.
48+
It weights the movemement of the control points which have a true flag in the mask.
49+
Default is identity.
4350
:cvar np.ndarray vweight: specifies the weight of every step of the volume enforcement.
4451
4552
:Example:
@@ -59,8 +66,8 @@ class VFFD(CFFD):
5966
>>> new_mesh_points = vffd(original_mesh_points)
6067
>>> assert np.isclose(np.linalg.norm(vffd.linconstraint(new_mesh_points)-b),np.array([0.]))
6168
'''
62-
def __init__(self, triangles, n_control_points=None):
63-
super().__init__(n_control_points)
69+
def __init__(self, triangles, n_control_points=None, fun=None, fixval=None, weight_matrix=None, mask=None ):
70+
super().__init__(n_control_points,fun,fixval,weight_matrix,mask)
6471
self.triangles = triangles
6572
self.vweight = [1 / 3, 1 / 3, 1 / 3]
6673

0 commit comments

Comments
 (0)