Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pygem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,\
Expand All @@ -43,8 +43,16 @@ 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).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(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):
Expand All @@ -54,6 +62,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
-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
-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

Original file line number Diff line number Diff line change
Expand Up @@ -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
-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
-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

2 changes: 1 addition & 1 deletion tests/test_datasets/box_test_sphere_true_version5.vtk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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
-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

2 changes: 1 addition & 1 deletion tests/test_datasets/box_test_sphere_true_version6.vtk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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
-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