Skip to content

Commit e83979b

Browse files
fsalmoirmtezzele
authored andcommitted
changed the order of the points in the plot of bounding box cause it … (#87)
changed the order of the points in the plot of bounding box
1 parent 0c1c483 commit e83979b

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

pygem/utils.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def write_bounding_box(parameters, outfile, write_deformed=True):
2929
aux_x = np.linspace(0, parameters.lenght_box_x, parameters.n_control_points[0])
3030
aux_y = np.linspace(0, parameters.lenght_box_y, parameters.n_control_points[1])
3131
aux_z = np.linspace(0, parameters.lenght_box_z, parameters.n_control_points[2])
32-
lattice_z_coords, lattice_y_coords, lattice_x_coords = np.meshgrid(aux_z, aux_y, aux_x)
32+
lattice_y_coords, lattice_x_coords, lattice_z_coords = np.meshgrid(aux_y, aux_x, aux_z)
3333

3434
if write_deformed:
3535
box_points = np.array([lattice_x_coords.ravel() + parameters.array_mu_x.ravel() * parameters.lenght_box_x,\
@@ -43,8 +43,16 @@ def write_bounding_box(parameters, outfile, write_deformed=True):
4343

4444
box_points = np.dot(parameters.rotation_matrix, box_points) + \
4545
np.transpose(np.tile(parameters.origin_box, (n_rows, 1)))
46+
47+
# step necessary to set the correct order to the box points for vtkStructuredGrid:
48+
# Data in vtkStructuredGrid are ordered with x increasing fastest, then y, then z
49+
dims = lattice_y_coords.shape
50+
aux_xx = box_points[0,:].reshape(dims).ravel(order='f')
51+
aux_yy = box_points[1,:].reshape(dims).ravel(order='f')
52+
aux_zz = box_points[2,:].reshape(dims).ravel(order='f')
53+
reordered_box_points = np.array((aux_xx, aux_yy, aux_zz))
4654

47-
_write_vtk_box(box_points, outfile, parameters.n_control_points)
55+
_write_vtk_box(reordered_box_points, outfile, parameters.n_control_points)
4856

4957

5058
def _write_vtk_box(box_points, filename, dimensions):
@@ -54,6 +62,11 @@ def _write_vtk_box(box_points, filename, dimensions):
5462
:param numpy.ndarray box_points: coordinates of the FFD control points.
5563
:param string filename: name of the output file.
5664
:param list dimensions: dimension of the lattice in (x, y, z) directions.
65+
66+
.. warning::
67+
If you want to visualize in paraview the inner points,
68+
you have to slice the lattice because paraview does not visualize them automatically
69+
even in the wireframe visualization.
5770
"""
5871
# setup points and vertices
5972
points = vtk.vtkPoints()

tests/test_datasets/box_modified_test_sphere_true_version5.vtk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ASCII
44
DATASET STRUCTURED_GRID
55
DIMENSIONS 3 2 2
66
POINTS 12 float
7-
-20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479
7+
-20 -55 -45 1.40315 -49.1766 -48.774 52.8929 -77.5023 -149.241
8+
-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503
89
-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848
9-
-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 29.9531 9.431 -145.196
1010
-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297
1111

tests/test_datasets/box_modified_test_sphere_true_version6.vtk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ASCII
44
DATASET STRUCTURED_GRID
55
DIMENSIONS 3 2 2
66
POINTS 12 float
7-
-20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479
7+
-20 -55 -45 1.40315 -49.1766 -48.774 52.8929 -77.5023 -149.241
8+
-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503
89
-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848
9-
-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 29.9531 9.431 -145.196
1010
-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297
1111

tests/test_datasets/box_test_sphere_true_version5.vtk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DATASET STRUCTURED_GRID
55
DIMENSIONS 3 2 2
66
POINTS 12 float
77
-20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479
8-
-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848
98
-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503
9+
-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848
1010
-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297
1111

tests/test_datasets/box_test_sphere_true_version6.vtk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DATASET STRUCTURED_GRID
55
DIMENSIONS 3 2 2
66
POINTS 12 float
77
-20 -55 -45 1.40315 -49.1766 -48.774 22.8063 -43.3531 -52.5479
8-
-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848
98
-42.9398 31.9333 -40.9551 -21.5367 37.7568 -44.729 -0.133524 43.5802 -48.503
9+
-4.37166 -55 43.6327 17.0315 -49.1766 39.8587 38.4346 -43.3531 36.0848
1010
-27.3115 31.9333 47.6776 -5.90834 37.7568 43.9037 15.4948 43.5802 40.1297
1111

0 commit comments

Comments
 (0)