Skip to content

Commit defcf36

Browse files
authored
Merge pull request #164 from mtezzele/box_length
refactor code: lenght_box -> box_length, origin_box -> box_origin
2 parents eb8fcf8 + 554866e commit defcf36

12 files changed

+137
-137
lines changed

pygem/freeform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def perform(self):
8484
execution it sets `self.modified_mesh_points`.
8585
"""
8686
# translation and then affine transformation
87-
translation = self.parameters.origin_box
87+
translation = self.parameters.box_origin
8888

8989
physical_frame = self.parameters.position_vertices - translation
9090
reference_frame = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])

pygem/params/ffdparams.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ class FFDParameters(object):
2323
:param list n_control_points: number of control points in the x, y, and z
2424
direction. If not provided it is set to [2, 2, 2].
2525
26-
:cvar numpy.ndarray length_box: dimension of the FFD bounding box, in the
26+
:cvar numpy.ndarray box_length: dimension of the FFD bounding box, in the
2727
x, y and z direction (local coordinate system).
28-
:cvar numpy.ndarray origin_box: the x, y and z coordinates of the origin of
28+
:cvar numpy.ndarray box_origin: the x, y and z coordinates of the origin of
2929
the FFD bounding box.
3030
:cvar numpy.ndarray rot_angle: rotation angle around x, y and z axis of the
3131
FFD bounding box.
3232
:cvar numpy.ndarray n_control_points: the number of control points in the
3333
x, y, and z direction.
3434
:cvar numpy.ndarray array_mu_x: collects the displacements (weights) along
35-
x, normalized with the box lenght x.
35+
x, normalized with the box length x.
3636
:cvar numpy.ndarray array_mu_y: collects the displacements (weights) along
37-
y, normalized with the box lenght y.
37+
y, normalized with the box length y.
3838
:cvar numpy.ndarray array_mu_z: collects the displacements (weights) along
39-
z, normalized with the box lenght z.
39+
z, normalized with the box length z.
4040
4141
:Example: from file
4242
@@ -73,8 +73,8 @@ class FFDParameters(object):
7373
def __init__(self, n_control_points=None):
7474
self.conversion_unit = 1.
7575

76-
self.lenght_box = np.array([1., 1., 1.])
77-
self.origin_box = np.array([0., 0., 0.])
76+
self.box_length = np.array([1., 1., 1.])
77+
self.box_origin = np.array([0., 0., 0.])
7878
self.rot_angle = np.array([0., 0., 0.])
7979

8080
if n_control_points is None:
@@ -92,7 +92,7 @@ def psi_mapping(self):
9292
9393
:rtype: numpy.ndarray
9494
"""
95-
return np.diag(np.reciprocal(self.lenght_box))
95+
return np.diag(np.reciprocal(self.box_length))
9696

9797
@property
9898
def inv_psi_mapping(self):
@@ -101,7 +101,7 @@ def inv_psi_mapping(self):
101101
102102
:rtype: numpy.ndarray
103103
"""
104-
return np.diag(self.lenght_box)
104+
return np.diag(self.box_length)
105105

106106
@property
107107
def rotation_matrix(self):
@@ -122,9 +122,9 @@ def position_vertices(self):
122122
123123
:rtype: numpy.ndarray
124124
"""
125-
return self.origin_box + np.vstack([
125+
return self.box_origin + np.vstack([
126126
np.zeros(
127-
(1, 3)), self.rotation_matrix.dot(np.diag(self.lenght_box)).T
127+
(1, 3)), self.rotation_matrix.dot(np.diag(self.box_length)).T
128128
])
129129

130130
def reflect(self, axis=0):
@@ -161,7 +161,7 @@ def reflect(self, axis=0):
161161
# double the control points in the given axis -1 (the symmetry plane)
162162
self.n_control_points[axis] = 2 * self.n_control_points[axis] - 1
163163
# double the box length
164-
self.lenght_box[axis] *= 2
164+
self.box_length[axis] *= 2
165165

166166
# we have to reflect the dispacements only along the correct axis
167167
reflection = np.ones(3)
@@ -209,13 +209,13 @@ def read_parameters(self, filename='parameters.prm'):
209209
self.n_control_points[2] = config.getint('Box info',
210210
'n control points z')
211211

212-
self.lenght_box[0] = config.getfloat('Box info', 'box lenght x')
213-
self.lenght_box[1] = config.getfloat('Box info', 'box lenght y')
214-
self.lenght_box[2] = config.getfloat('Box info', 'box lenght z')
212+
self.box_length[0] = config.getfloat('Box info', 'box length x')
213+
self.box_length[1] = config.getfloat('Box info', 'box length y')
214+
self.box_length[2] = config.getfloat('Box info', 'box length z')
215215

216-
self.origin_box[0] = config.getfloat('Box info', 'box origin x')
217-
self.origin_box[1] = config.getfloat('Box info', 'box origin y')
218-
self.origin_box[2] = config.getfloat('Box info', 'box origin z')
216+
self.box_origin[0] = config.getfloat('Box info', 'box origin x')
217+
self.box_origin[1] = config.getfloat('Box info', 'box origin y')
218+
self.box_origin[2] = config.getfloat('Box info', 'box origin z')
219219

220220
self.rot_angle[0] = config.getfloat('Box info', 'rotation angle x')
221221
self.rot_angle[1] = config.getfloat('Box info', 'rotation angle y')
@@ -267,17 +267,17 @@ def write_parameters(self, filename='parameters.prm'):
267267
output_string += 'n control points z: ' + str(self.n_control_points[
268268
2]) + '\n'
269269

270-
output_string += '\n# box lenght indicates the length of the FFD '
270+
output_string += '\n# box length indicates the length of the FFD '
271271
output_string += 'bounding box along the three canonical directions '
272272
output_string += '(x, y, z).\n'
273273

274274
output_string += '# It uses the local coordinate system.\n'
275275
output_string += '# For example to create a 2 x 1.5 x 3 meters box '
276-
output_string += 'use the following: lenght box: 2.0, 1.5, 3.0\n'
276+
output_string += 'use the following: box length: 2.0, 1.5, 3.0\n'
277277

278-
output_string += 'box lenght x: ' + str(self.lenght_box[0]) + '\n'
279-
output_string += 'box lenght y: ' + str(self.lenght_box[1]) + '\n'
280-
output_string += 'box lenght z: ' + str(self.lenght_box[2]) + '\n'
278+
output_string += 'box length x: ' + str(self.box_length[0]) + '\n'
279+
output_string += 'box length y: ' + str(self.box_length[1]) + '\n'
280+
output_string += 'box length z: ' + str(self.box_length[2]) + '\n'
281281

282282
output_string += '\n# box origin indicates the x, y, and z coordinates '
283283
output_string += 'of the origin of the FFD bounding box. That is '
@@ -289,11 +289,11 @@ def write_parameters(self, filename='parameters.prm'):
289289
output_string += '# See section "Parameters weights" for more '
290290
output_string += 'details.\n'
291291
output_string += '# For example, if the origin is equal to 0., 0., 0., '
292-
output_string += 'use the following: origin box: 0., 0., 0.\n'
292+
output_string += 'use the following: box origin: 0., 0., 0.\n'
293293

294-
output_string += 'box origin x: ' + str(self.origin_box[0]) + '\n'
295-
output_string += 'box origin y: ' + str(self.origin_box[1]) + '\n'
296-
output_string += 'box origin z: ' + str(self.origin_box[2]) + '\n'
294+
output_string += 'box origin x: ' + str(self.box_origin[0]) + '\n'
295+
output_string += 'box origin y: ' + str(self.box_origin[1]) + '\n'
296+
output_string += 'box origin z: ' + str(self.box_origin[2]) + '\n'
297297

298298
output_string += '\n# rotation angle indicates the rotation angle '
299299
output_string += 'around the x, y, and z axis of the FFD bounding box '
@@ -331,7 +331,7 @@ def write_parameters(self, filename='parameters.prm'):
331331
output_string += '# | 0 | 0 | 1 | 3.4 |\n'
332332

333333
output_string += '\n# parameter x collects the displacements along x, '
334-
output_string += 'normalized with the box lenght x.'
334+
output_string += 'normalized with the box length x.'
335335

336336
output_string += '\nparameter x:'
337337
offset = 1
@@ -344,7 +344,7 @@ def write_parameters(self, filename='parameters.prm'):
344344
offset = 13
345345

346346
output_string += '\n# parameter y collects the displacements along y, '
347-
output_string += 'normalized with the box lenght y.'
347+
output_string += 'normalized with the box length y.'
348348

349349
output_string += '\nparameter y:'
350350
offset = 1
@@ -357,7 +357,7 @@ def write_parameters(self, filename='parameters.prm'):
357357
offset = 13
358358

359359
output_string += '\n# parameter z collects the displacements along z, '
360-
output_string += 'normalized with the box lenght z.'
360+
output_string += 'normalized with the box length z.'
361361

362362
output_string += '\nparameter z:'
363363
offset = 1
@@ -380,8 +380,8 @@ def __str__(self):
380380
string = ""
381381
string += 'conversion_unit = {}\n'.format(self.conversion_unit)
382382
string += 'n_control_points = {}\n\n'.format(self.n_control_points)
383-
string += 'lenght_box = {}\n'.format(self.lenght_box)
384-
string += 'origin_box = {}\n'.format(self.origin_box)
383+
string += 'box_length = {}\n'.format(self.box_length)
384+
string += 'box_origin = {}\n'.format(self.box_origin)
385385
string += 'rot_angle = {}\n'.format(self.rot_angle)
386386
string += '\narray_mu_x =\n{}\n'.format(self.array_mu_x)
387387
string += '\narray_mu_y =\n{}\n'.format(self.array_mu_y)
@@ -417,20 +417,20 @@ def save_points(self, filename, write_deformed=True):
417417
**Point Gaussian** representation.
418418
419419
"""
420-
x = np.linspace(0, self.lenght_box[0], self.n_control_points[0])
421-
y = np.linspace(0, self.lenght_box[1], self.n_control_points[1])
422-
z = np.linspace(0, self.lenght_box[2], self.n_control_points[2])
420+
x = np.linspace(0, self.box_length[0], self.n_control_points[0])
421+
y = np.linspace(0, self.box_length[1], self.n_control_points[1])
422+
z = np.linspace(0, self.box_length[2], self.n_control_points[2])
423423

424424
lattice_y_coords, lattice_x_coords, lattice_z_coords = np.meshgrid(y, x,
425425
z)
426426

427427
if write_deformed:
428428
box_points = np.array([
429429
lattice_x_coords.ravel() + self.array_mu_x.ravel() *
430-
self.lenght_box[0], lattice_y_coords.ravel() +
431-
self.array_mu_y.ravel() * self.lenght_box[1],
430+
self.box_length[0], lattice_y_coords.ravel() +
431+
self.array_mu_y.ravel() * self.box_length[1],
432432
lattice_z_coords.ravel() + self.array_mu_z.ravel() *
433-
self.lenght_box[2]
433+
self.box_length[2]
434434
])
435435
else:
436436
box_points = np.array([
@@ -442,7 +442,7 @@ def save_points(self, filename, write_deformed=True):
442442

443443
box_points = np.dot(
444444
self.rotation_matrix,
445-
box_points) + np.transpose(np.tile(self.origin_box, (n_rows, 1)))
445+
box_points) + np.transpose(np.tile(self.box_origin, (n_rows, 1)))
446446

447447
points = vtk.vtkPoints()
448448

@@ -489,8 +489,8 @@ def build_bounding_box(self,
489489
min_xyz = np.array([xmin, ymin, zmin])
490490
max_xyz = np.array([xmax, ymax, zmax])
491491

492-
self.origin_box = min_xyz
493-
self.lenght_box = max_xyz - min_xyz
492+
self.box_origin = min_xyz
493+
self.box_length = max_xyz - min_xyz
494494
self.reset_deformation()
495495

496496
def reset_deformation(self):

tests/test_datasets/parameters_default.prm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ n control points x: 3
88
n control points y: 2
99
n control points z: 2
1010

11-
# box lenght indicates the length of the FFD bounding box along the three canonical directions (x, y, z).
11+
# box length indicates the length of the FFD bounding box along the three canonical directions (x, y, z).
1212
# It uses the local coordinate system.
13-
# For example to create a 2 x 1.5 x 3 meters box use the following: lenght box: 2.0, 1.5, 3.0
14-
box lenght x: 1.0
15-
box lenght y: 1.0
16-
box lenght z: 1.0
13+
# For example to create a 2 x 1.5 x 3 meters box use the following: box length: 2.0, 1.5, 3.0
14+
box length x: 1.0
15+
box length y: 1.0
16+
box length z: 1.0
1717

1818
# box origin indicates the x, y, and z coordinates of the origin of the FFD bounding box. That is center of
1919
# rotation of the bounding box. It corresponds to the point coordinates with position [0][0][0].
2020
# See section "Parameters weights" for more details.
21-
# For example, if the origin is equal to 0., 0., 0., use the following: origin box: 0., 0., 0.
21+
# For example, if the origin is equal to 0., 0., 0., use the following: box origin: 0., 0., 0.
2222
box origin x: 0.0
2323
box origin y: 0.0
2424
box origin z: 0.0
@@ -44,7 +44,7 @@ rotation angle z: 0.0
4444
# | 0 | 1 | 0 | -2.1 |
4545
# | 0 | 0 | 1 | 3.4 |
4646

47-
# parameter x collects the displacements along x, normalized with the box lenght x.
47+
# parameter x collects the displacements along x, normalized with the box length x.
4848
parameter x: 0 0 0 0.0
4949
0 0 1 0.0
5050
0 1 0 0.0
@@ -58,7 +58,7 @@ parameter x: 0 0 0 0.0
5858
2 1 0 0.0
5959
2 1 1 0.0
6060

61-
# parameter y collects the displacements along y, normalized with the box lenght y.
61+
# parameter y collects the displacements along y, normalized with the box length y.
6262
parameter y: 0 0 0 0.0
6363
0 0 1 0.0
6464
0 1 0 0.0
@@ -72,7 +72,7 @@ parameter y: 0 0 0 0.0
7272
2 1 0 0.0
7373
2 1 1 0.0
7474

75-
# parameter z collects the displacements along z, normalized with the box lenght z.
75+
# parameter z collects the displacements along z, normalized with the box length z.
7676
parameter z: 0 0 0 0.0
7777
0 0 1 0.0
7878
0 1 0 0.0

tests/test_datasets/parameters_sphere.prm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ n control points x: 3
88
n control points y: 2
99
n control points z: 2
1010

11-
# box lenght indicates the length of the FFD bounding box along the three canonical directions (x, y, z).
11+
# box length indicates the length of the FFD bounding box along the three canonical directions (x, y, z).
1212
# It uses the local coordinate system.
13-
# For example to create a 2 x 1.5 x 3 meters box use the following: lenght box: 2.0, 1.5, 3.0
14-
box lenght x: 45.0
15-
box lenght y: 90.0
16-
box lenght z: 90.0
13+
# For example to create a 2 x 1.5 x 3 meters box use the following: box length: 2.0, 1.5, 3.0
14+
box length x: 45.0
15+
box length y: 90.0
16+
box length z: 90.0
1717

1818
# box origin indicates the x, y, and z coordinates of the origin of the FFD bounding box. That is center of
1919
# rotation of the bounding box. It corresponds to the point coordinates with position [0][0][0].
2020
# See section "Parameters weights" for more details.
21-
# For example, if the origin is equal to 0., 0., 0., use the following: origin box: 0., 0., 0.
21+
# For example, if the origin is equal to 0., 0., 0., use the following: box origin: 0., 0., 0.
2222
box origin x: -20.0
2323
box origin y: -55.0
2424
box origin z: -45.0
@@ -44,7 +44,7 @@ rotation angle z: 0
4444
# | 0 | 1 | 0 | -2.1 |
4545
# | 0 | 0 | 1 | 3.4 |
4646

47-
# parameter x collects the displacements along x, normalized with the box lenght x.
47+
# parameter x collects the displacements along x, normalized with the box length x.
4848
parameter x: 0 0 0 .2
4949
0 0 1 0.0
5050
0 1 0 0.0
@@ -58,7 +58,7 @@ parameter x: 0 0 0 .2
5858
2 1 0 0.0
5959
2 1 1 0.0
6060

61-
# parameter y collects the displacements along y, normalized with the box lenght y.
61+
# parameter y collects the displacements along y, normalized with the box length y.
6262
parameter y: 0 0 0 0.0
6363
0 0 1 0.0
6464
0 1 0 0.5555555555
@@ -72,7 +72,7 @@ parameter y: 0 0 0 0.0
7272
2 1 0 0.0
7373
2 1 1 0.0
7474

75-
# parameter z collects the displacements along z, normalized with the box lenght z.
75+
# parameter z collects the displacements along z, normalized with the box length z.
7676
parameter z: 0 0 0 0.0
7777
0 0 1 -.2
7878
0 1 0 0.0

tests/test_datasets/parameters_sphere_out_true.prm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ n control points x: 3
88
n control points y: 2
99
n control points z: 2
1010

11-
# box lenght indicates the length of the FFD bounding box along the three canonical directions (x, y, z).
11+
# box length indicates the length of the FFD bounding box along the three canonical directions (x, y, z).
1212
# It uses the local coordinate system.
13-
# For example to create a 2 x 1.5 x 3 meters box use the following: lenght box: 2.0, 1.5, 3.0
14-
box lenght x: 45.0
15-
box lenght y: 90.0
16-
box lenght z: 90.0
13+
# For example to create a 2 x 1.5 x 3 meters box use the following: box length: 2.0, 1.5, 3.0
14+
box length x: 45.0
15+
box length y: 90.0
16+
box length z: 90.0
1717

1818
# box origin indicates the x, y, and z coordinates of the origin of the FFD bounding box. That is center of
1919
# rotation of the bounding box. It corresponds to the point coordinates with position [0][0][0].
2020
# See section "Parameters weights" for more details.
21-
# For example, if the origin is equal to 0., 0., 0., use the following: origin box: 0., 0., 0.
21+
# For example, if the origin is equal to 0., 0., 0., use the following: box origin: 0., 0., 0.
2222
box origin x: -20.0
2323
box origin y: -55.0
2424
box origin z: -45.0
@@ -44,7 +44,7 @@ rotation angle z: 0.0
4444
# | 0 | 1 | 0 | -2.1 |
4545
# | 0 | 0 | 1 | 3.4 |
4646

47-
# parameter x collects the displacements along x, normalized with the box lenght x.
47+
# parameter x collects the displacements along x, normalized with the box length x.
4848
parameter x: 0 0 0 0.2
4949
0 0 1 0.0
5050
0 1 0 0.0
@@ -58,7 +58,7 @@ parameter x: 0 0 0 0.2
5858
2 1 0 0.0
5959
2 1 1 0.0
6060

61-
# parameter y collects the displacements along y, normalized with the box lenght y.
61+
# parameter y collects the displacements along y, normalized with the box length y.
6262
parameter y: 0 0 0 0.0
6363
0 0 1 0.0
6464
0 1 0 0.5555555555
@@ -72,7 +72,7 @@ parameter y: 0 0 0 0.0
7272
2 1 0 0.0
7373
2 1 1 0.0
7474

75-
# parameter z collects the displacements along z, normalized with the box lenght z.
75+
# parameter z collects the displacements along z, normalized with the box length z.
7676
parameter z: 0 0 0 0.0
7777
0 0 1 -0.2
7878
0 1 0 0.0

0 commit comments

Comments
 (0)