From ebdfb05cdbfb322e01c98c29e338ba2e97a42869 Mon Sep 17 00:00:00 2001 From: fsalmoir Date: Thu, 28 Jul 2016 10:40:08 +0200 Subject: [PATCH 1/2] changed the order of the points in the plot of bounding box cause it was definitely wrong --- pygem/utils.py | 18 +++++++++++++++++- .../box_modified_test_sphere_true_version5.vtk | 8 ++++---- .../box_modified_test_sphere_true_version6.vtk | 8 ++++---- .../box_test_sphere_true_version5.vtk | 8 ++++---- .../box_test_sphere_true_version6.vtk | 8 ++++---- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/pygem/utils.py b/pygem/utils.py index 35b36b62..816683bc 100644 --- a/pygem/utils.py +++ b/pygem/utils.py @@ -43,8 +43,19 @@ def write_bounding_box(parameters, outfile, write_deformed=True): box_points = np.dot(parameters.rotation_matrix, box_points) + \ np.transpose(np.tile(parameters.origin_box, (n_rows, 1))) + + # step necessary to set the correct order to the box points for vtkStructuredGrid: + # Data in vtkStructuredGrid are ordered with x increasing fastest, then y, then z + dims = lattice_y_coords.shape + aux_xx = box_points[0,:].reshape(dims) + aux_xxx = aux_xx.ravel(order='f') + aux_yy = box_points[1,:].reshape(dims) + aux_yyy = aux_yy.ravel(order='f') + aux_zz = box_points[2,:].reshape(dims) + aux_zzz = aux_zz.ravel(order='f') + reordered_box_points = np.array((aux_xxx, aux_yyy, aux_zzz)) - _write_vtk_box(box_points, outfile, parameters.n_control_points) + _write_vtk_box(reordered_box_points, outfile, parameters.n_control_points) def _write_vtk_box(box_points, filename, dimensions): @@ -54,6 +65,11 @@ def _write_vtk_box(box_points, filename, dimensions): :param numpy.ndarray box_points: coordinates of the FFD control points. :param string filename: name of the output file. :param list dimensions: dimension of the lattice in (x, y, z) directions. + + .. warning:: + If you want to visualize in paraview the inner points, + you have to slice the lattice because paraview does not visualize them automatically + even in the wireframe visualization. """ # setup points and vertices points = vtk.vtkPoints() diff --git a/tests/test_datasets/box_modified_test_sphere_true_version5.vtk b/tests/test_datasets/box_modified_test_sphere_true_version5.vtk index dc8287a1..7d1d12c5 100644 --- a/tests/test_datasets/box_modified_test_sphere_true_version5.vtk +++ b/tests/test_datasets/box_modified_test_sphere_true_version5.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479 --4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 --42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 29.9531 9.431 -145.196 --27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297 +-20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 +-27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 +17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 +29.9531 9.431 -145.196 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 diff --git a/tests/test_datasets/box_modified_test_sphere_true_version6.vtk b/tests/test_datasets/box_modified_test_sphere_true_version6.vtk index 2266eaf6..5eecf59a 100644 --- a/tests/test_datasets/box_modified_test_sphere_true_version6.vtk +++ b/tests/test_datasets/box_modified_test_sphere_true_version6.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479 --4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 --42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 29.9531 9.431 -145.196 --27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297 +-20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 +-27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 +17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 +29.9531 9.431 -145.196 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 diff --git a/tests/test_datasets/box_test_sphere_true_version5.vtk b/tests/test_datasets/box_test_sphere_true_version5.vtk index 1955b341..96832744 100644 --- a/tests/test_datasets/box_test_sphere_true_version5.vtk +++ b/tests/test_datasets/box_test_sphere_true_version5.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479 --4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 --42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503 --27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297 +-20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 +-27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 +17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 +-0.133524 43.5802 -48.503 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 diff --git a/tests/test_datasets/box_test_sphere_true_version6.vtk b/tests/test_datasets/box_test_sphere_true_version6.vtk index 99f838b7..1aea594e 100644 --- a/tests/test_datasets/box_test_sphere_true_version6.vtk +++ b/tests/test_datasets/box_test_sphere_true_version6.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479 --4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 --42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503 --27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297 +-20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 +-27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 +17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 +-0.133524 43.5802 -48.503 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 From 6e08ea8cb56b0fb8e978185c3ef68abbb1819b4e Mon Sep 17 00:00:00 2001 From: fsalmoir Date: Thu, 28 Jul 2016 10:52:05 +0200 Subject: [PATCH 2/2] missed a swap in the order of x, y, z points --- pygem/utils.py | 13 +++++-------- .../box_modified_test_sphere_true_version5.vtk | 8 ++++---- .../box_modified_test_sphere_true_version6.vtk | 8 ++++---- .../test_datasets/box_test_sphere_true_version5.vtk | 8 ++++---- .../test_datasets/box_test_sphere_true_version6.vtk | 8 ++++---- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/pygem/utils.py b/pygem/utils.py index 816683bc..61105ebd 100644 --- a/pygem/utils.py +++ b/pygem/utils.py @@ -29,7 +29,7 @@ def write_bounding_box(parameters, outfile, write_deformed=True): aux_x = np.linspace(0, parameters.lenght_box_x, parameters.n_control_points[0]) aux_y = np.linspace(0, parameters.lenght_box_y, parameters.n_control_points[1]) aux_z = np.linspace(0, parameters.lenght_box_z, parameters.n_control_points[2]) - lattice_z_coords, lattice_y_coords, lattice_x_coords = np.meshgrid(aux_z, aux_y, aux_x) + lattice_y_coords, lattice_x_coords, lattice_z_coords = np.meshgrid(aux_y, aux_x, aux_z) if write_deformed: box_points = np.array([lattice_x_coords.ravel() + parameters.array_mu_x.ravel() * parameters.lenght_box_x,\ @@ -47,13 +47,10 @@ def write_bounding_box(parameters, outfile, write_deformed=True): # step necessary to set the correct order to the box points for vtkStructuredGrid: # Data in vtkStructuredGrid are ordered with x increasing fastest, then y, then z dims = lattice_y_coords.shape - aux_xx = box_points[0,:].reshape(dims) - aux_xxx = aux_xx.ravel(order='f') - aux_yy = box_points[1,:].reshape(dims) - aux_yyy = aux_yy.ravel(order='f') - aux_zz = box_points[2,:].reshape(dims) - aux_zzz = aux_zz.ravel(order='f') - reordered_box_points = np.array((aux_xxx, aux_yyy, aux_zzz)) + aux_xx = box_points[0,:].reshape(dims).ravel(order='f') + aux_yy = box_points[1,:].reshape(dims).ravel(order='f') + aux_zz = box_points[2,:].reshape(dims).ravel(order='f') + reordered_box_points = np.array((aux_xx, aux_yy, aux_zz)) _write_vtk_box(reordered_box_points, outfile, parameters.n_control_points) diff --git a/tests/test_datasets/box_modified_test_sphere_true_version5.vtk b/tests/test_datasets/box_modified_test_sphere_true_version5.vtk index 7d1d12c5..9adec964 100644 --- a/tests/test_datasets/box_modified_test_sphere_true_version5.vtk +++ b/tests/test_datasets/box_modified_test_sphere_true_version5.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 --27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 -17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 -29.9531 9.431 -145.196 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 +-20 -55 -45 1.40315 -49.1766 -48.774 52.8929 -77.5023 -149.241 +-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503 +-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 +-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297 diff --git a/tests/test_datasets/box_modified_test_sphere_true_version6.vtk b/tests/test_datasets/box_modified_test_sphere_true_version6.vtk index 5eecf59a..f00bad67 100644 --- a/tests/test_datasets/box_modified_test_sphere_true_version6.vtk +++ b/tests/test_datasets/box_modified_test_sphere_true_version6.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 --27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 -17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 -29.9531 9.431 -145.196 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 +-20 -55 -45 1.40315 -49.1766 -48.774 52.8929 -77.5023 -149.241 +-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503 +-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 +-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297 diff --git a/tests/test_datasets/box_test_sphere_true_version5.vtk b/tests/test_datasets/box_test_sphere_true_version5.vtk index 96832744..38bc3b44 100644 --- a/tests/test_datasets/box_test_sphere_true_version5.vtk +++ b/tests/test_datasets/box_test_sphere_true_version5.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 --27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 -17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 --0.133524 43.5802 -48.503 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 +-20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479 +-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503 +-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 +-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297 diff --git a/tests/test_datasets/box_test_sphere_true_version6.vtk b/tests/test_datasets/box_test_sphere_true_version6.vtk index 1aea594e..4d9f0e1c 100644 --- a/tests/test_datasets/box_test_sphere_true_version6.vtk +++ b/tests/test_datasets/box_test_sphere_true_version6.vtk @@ -4,8 +4,8 @@ ASCII DATASET STRUCTURED_GRID DIMENSIONS 3 2 2 POINTS 12 float --20 -55 -45 -42.9398 31.9333 -40.9551 -4.37166 -55 43.6327 --27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 -21.5367 37.7568 -44.729 -17.0315 -49.1766 39.8587 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479 --0.133524 43.5802 -48.503 38.4346 -43.3531 36.0848 15.4948 43.5802 40.1297 +-20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479 +-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503 +-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848 +-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297