|
7 | 7 | from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere, BRepPrimAPI_MakeBox |
8 | 8 | from OCC.gp import gp_Pnt |
9 | 9 |
|
10 | | -from pygem import FFDParameters |
| 10 | +from pygem.params import FFDParameters |
11 | 11 |
|
12 | 12 |
|
13 | 13 | class TestFFDParameters(TestCase): |
@@ -60,25 +60,16 @@ def test_class_members_default_rotation_matrix(self): |
60 | 60 | params = FFDParameters() |
61 | 61 | np.testing.assert_array_almost_equal(params.rotation_matrix, np.eye(3)) |
62 | 62 |
|
63 | | - def test_class_members_default_position_vertex_0(self): |
| 63 | + def test_class_members_default_position_vertices(self): |
64 | 64 | params = FFDParameters() |
65 | | - np.testing.assert_array_almost_equal(params.position_vertex_0, |
66 | | - np.zeros(3)) |
67 | | - |
68 | | - def test_class_members_default_position_vertex_1(self): |
69 | | - params = FFDParameters() |
70 | | - np.testing.assert_array_almost_equal(params.position_vertex_1, |
71 | | - np.array([1., 0., 0.])) |
72 | | - |
73 | | - def test_class_members_default_position_vertex_2(self): |
74 | | - params = FFDParameters() |
75 | | - np.testing.assert_array_almost_equal(params.position_vertex_2, |
76 | | - np.array([0., 1., 0.])) |
77 | | - |
78 | | - def test_class_members_default_position_vertex_3(self): |
79 | | - params = FFDParameters() |
80 | | - np.testing.assert_array_almost_equal(params.position_vertex_3, |
81 | | - np.array([0., 0., 1.])) |
| 65 | + expected_matrix = np.array([ |
| 66 | + [0., 0., 0.], |
| 67 | + [1., 0., 0.], |
| 68 | + [0., 1., 0.], |
| 69 | + [0., 0., 1.] |
| 70 | + ]) |
| 71 | + np.testing.assert_array_almost_equal(params.position_vertices, |
| 72 | + expected_matrix) |
82 | 73 |
|
83 | 74 | def test_class_members_generic_n_control_points(self): |
84 | 75 | params = FFDParameters([2, 3, 5]) |
@@ -180,38 +171,21 @@ def test_read_parameters_rotation_matrix(self): |
180 | 171 | def test_read_parameters_position_vertex_0_origin(self): |
181 | 172 | params = FFDParameters(n_control_points=[3, 2, 2]) |
182 | 173 | params.read_parameters('tests/test_datasets/parameters_sphere.prm') |
183 | | - np.testing.assert_array_almost_equal(params.position_vertex_0, |
| 174 | + np.testing.assert_array_almost_equal(params.position_vertices[0], |
184 | 175 | params.origin_box) |
185 | 176 |
|
186 | 177 | def test_read_parameters_position_vertex_0(self): |
187 | 178 | params = FFDParameters(n_control_points=[3, 2, 2]) |
188 | 179 | params.read_parameters('tests/test_datasets/parameters_sphere.prm') |
189 | | - position_vertex_0_exact = np.array([-20.0, -55.0, -45.0]) |
190 | | - np.testing.assert_array_almost_equal(params.position_vertex_0, |
191 | | - position_vertex_0_exact) |
192 | | - |
193 | | - def test_read_parameters_position_vertex_1(self): |
194 | | - params = FFDParameters(n_control_points=[3, 2, 2]) |
195 | | - params.read_parameters('tests/test_datasets/parameters_sphere.prm') |
196 | | - position_vertex_1_exact = np.array( |
197 | | - [24.17322326, -52.02107006, -53.05309404]) |
198 | | - np.testing.assert_array_almost_equal(params.position_vertex_1, |
199 | | - position_vertex_1_exact) |
| 180 | + position_vertices = np.array([ |
| 181 | + [-20.0, -55.0, -45.0], |
| 182 | + [24.17322326, -52.02107006, -53.05309404], |
| 183 | + [-20., 29.41000412, -13.77579136], |
| 184 | + [-2.82719042, -85.65053198, 37.85915459] |
| 185 | + ]) |
200 | 186 |
|
201 | | - def test_read_parameters_position_vertex_2(self): |
202 | | - params = FFDParameters(n_control_points=[3, 2, 2]) |
203 | | - params.read_parameters('tests/test_datasets/parameters_sphere.prm') |
204 | | - position_vertex_2_exact = np.array([-20., 29.41000412, -13.77579136]) |
205 | | - np.testing.assert_array_almost_equal(params.position_vertex_2, |
206 | | - position_vertex_2_exact) |
207 | | - |
208 | | - def test_read_parameters_position_vertex_3(self): |
209 | | - params = FFDParameters(n_control_points=[3, 2, 2]) |
210 | | - params.read_parameters('tests/test_datasets/parameters_sphere.prm') |
211 | | - position_vertex_3_exact = np.array( |
212 | | - [-2.82719042, -85.65053198, 37.85915459]) |
213 | | - np.testing.assert_array_almost_equal(params.position_vertex_3, |
214 | | - position_vertex_3_exact) |
| 187 | + np.testing.assert_array_almost_equal(params.position_vertices, |
| 188 | + position_vertices) |
215 | 189 |
|
216 | 190 | def test_read_parameters_failing_filename_type(self): |
217 | 191 | params = FFDParameters(n_control_points=[3, 2, 2]) |
@@ -286,33 +260,32 @@ def test_build_bounding_box_2(self): |
286 | 260 | params = FFDParameters() |
287 | 261 | params.build_bounding_box(cube) |
288 | 262 |
|
| 263 | + expected_matrix = np.array([ |
| 264 | + [0., 0., 0.], |
| 265 | + [1., 0., 0.], |
| 266 | + [0., 1., 0.], |
| 267 | + [0., 0., 1.] |
| 268 | + ]) |
289 | 269 | np.testing.assert_almost_equal( |
290 | | - params.position_vertex_0, origin, decimal=5) |
291 | | - np.testing.assert_almost_equal( |
292 | | - params.position_vertex_1, [1., 0., 0.], decimal=5) |
293 | | - np.testing.assert_almost_equal( |
294 | | - params.position_vertex_2, [0., 1., 0.], decimal=5) |
295 | | - np.testing.assert_almost_equal( |
296 | | - params.position_vertex_3, [0., 0., 1.], decimal=5) |
| 270 | + params.position_vertices, expected_matrix, decimal=5) |
297 | 271 |
|
298 | 272 | def test_set_position_of_vertices(self): |
299 | | - vertex_0 = [0., 0., 0.] |
300 | | - vertex_1 = [1., 0., 0.] |
301 | | - vertex_2 = [0., 1., 0.] |
302 | | - vertex_3 = [0., 0., 1.] |
| 273 | + expected_matrix = np.array([ |
| 274 | + [0., 0., 0.], |
| 275 | + [1., 0., 0.], |
| 276 | + [0., 1., 0.], |
| 277 | + [0., 0., 1.] |
| 278 | + ]) |
303 | 279 | tops = np.array([1., 1., 1.]) |
304 | 280 | params = FFDParameters() |
305 | | - params.origin_box = vertex_0 |
306 | | - params.lenght_box = tops - vertex_0 |
307 | | - params._set_position_of_vertices() |
308 | | - np.testing.assert_equal(params.position_vertex_0, vertex_0) |
309 | | - np.testing.assert_equal(params.position_vertex_1, vertex_1) |
310 | | - np.testing.assert_equal(params.position_vertex_2, vertex_2) |
311 | | - np.testing.assert_equal(params.position_vertex_3, vertex_3) |
| 281 | + params.origin_box = expected_matrix[0] |
| 282 | + params.lenght_box = tops - expected_matrix[0] |
| 283 | + np.testing.assert_almost_equal( |
| 284 | + params.position_vertices, expected_matrix, decimal=5) |
312 | 285 |
|
313 | 286 | def test_set_modification_parameters_to_zero(self): |
314 | 287 | params = FFDParameters([5, 5, 5]) |
315 | | - params._set_transformation_params_to_zero() |
| 288 | + params.reset_deformation() |
316 | 289 | np.testing.assert_almost_equal( |
317 | 290 | params.array_mu_x, np.zeros(shape=(5, 5, 5))) |
318 | 291 | np.testing.assert_almost_equal( |
|
0 commit comments