33
44:Theoretical Insight:
55
6- Free Form Deformation is a technique for the efficient, smooth and accurate geometrical
7- parametrization. It has been proposed the first time in *Sederberg, Thomas W., and Scott
8- R. Parry. "Free-form deformation of solid geometric models." ACM SIGGRAPH computer
9- graphics 20.4 (1986): 151-160*. It consists in three different step:
6+ Free Form Deformation is a technique for the efficient, smooth and accurate
7+ geometrical parametrization. It has been proposed the first time in
8+ *Sederberg, Thomas W., and Scott R. Parry. "Free-form deformation of solid
9+ geometric models." ACM SIGGRAPH computer graphics 20.4 (1986): 151-160*. It
10+ consists in three different step:
1011
11- - Mapping the physical domain to the reference one with map :math:` \\ boldsymbol{\psi}`.
12- In the code it is named *transformation*.
12+ - Mapping the physical domain to the reference one with map
13+ :math:` \\ boldsymbol{\psi}`. In the code it is named *transformation*.
1314
1415 - Moving some control points to deform the lattice with :math:`\\ hat{T}`.
15- The movement of the control points is basically the weight (or displacement)
16- :math:`\\ boldsymbol{\mu}` we set in the *parameters file*.
16+ The movement of the control points is basically the weight (or displacement)
17+ :math:`\\ boldsymbol{\mu}` we set in the *parameters file*.
1718
18- - Mapping back to the physical domain with map :math:`\\ boldsymbol{\psi}^-1`.
19- In the code it is named *inverse_transformation*.
19+ - Mapping back to the physical domain with map
20+ :math:`\\ boldsymbol{\psi}^-1`. In the code it is named
21+ *inverse_transformation*.
2022
2123 FFD map (:math:`T`) is the composition of the three maps, that is
2224
23- .. math::
24- T(\\ cdot, \\ boldsymbol{\\ mu}) = (\\ Psi^{-1} \\ circ \\ hat{T} \\ circ \\ Psi)
25- (\\ cdot, \\ boldsymbol{\\ mu})
25+ .. math:: T(\\ cdot, \\ boldsymbol{\\ mu}) = (\\ Psi^{-1} \\ circ \\ hat{T} \\ circ
26+ \\ Psi) (\\ cdot, \\ boldsymbol{\\ mu})
2627
2728 In this way, every point inside the FFD box changes it position according to
2829
29- .. math::
30- \\ boldsymbol{P} = \\ boldsymbol{\psi}^-1 \\ left( \\ sum_{l =0} ^L \\ sum_{m =0} ^M
31- \\ sum_{n=0} ^N \\ mathsf{b}_{lmn}(\\ boldsymbol{\\ psi}(\\ boldsymbol{P}_0))
32- \\ boldsymbol{\\ mu}_{lmn} \\ right)
30+ .. math:: \\ boldsymbol{P} = \\ boldsymbol{\psi}^-1 \\ left( \\ sum_{l=0} ^L
31+ \\ sum_{m =0} ^M \\ sum_{n =0} ^N
32+ \\ mathsf{b}_{lmn}(\\ boldsymbol{\\ psi}(\\ boldsymbol{P}_0))
33+ \\ boldsymbol{\\ mu}_{lmn} \\ right)
3334
34- where :math:`\\ mathsf{b}_{lmn}` are Bernstein polynomials.
35- We improve the traditional version by allowing a rotation of the FFD lattice in order
36- to give more flexibility to the tool.
35+ where :math:`\\ mathsf{b}_{lmn}` are Bernstein polynomials. We improve the
36+ traditional version by allowing a rotation of the FFD lattice in order to
37+ give more flexibility to the tool.
3738
38- You can try to add more shapes to the lattice to allow more and more involved transformations.
39+ You can try to add more shapes to the lattice to allow more and more
40+ involved transformations.
3941
4042"""
4143import numpy as np
4244from scipy import special
4345import pygem .affine as at
4446
45-
4647class FFD (object ):
4748 """
4849 Class that handles the Free Form Deformation on the mesh points.
4950
50- :param FFDParameters ffd_parameters: parameters of the Free Form Deformation.
51- :param numpy.ndarray original_mesh_points: coordinates of the original points of the mesh.
51+ :param FFDParameters ffd_parameters: parameters of the Free Form
52+ Deformation.
53+ :param numpy.ndarray original_mesh_points: coordinates of the original
54+ points of the mesh.
5255
5356 :cvar FFDParameters parameters: parameters of the Free Form Deformation.
54- :cvar numpy.ndarray original_mesh_points: coordinates of the original points of the mesh.
55- The shape is `n_points`-by-3.
56- :cvar numpy.ndarray modified_mesh_points: coordinates of the points of the deformed mesh.
57- The shape is `n_points`-by-3.
57+ :cvar numpy.ndarray original_mesh_points: coordinates of the original points
58+ of the mesh. The shape is `n_points`-by-3.
59+ :cvar numpy.ndarray modified_mesh_points: coordinates of the points of the
60+ deformed mesh. The shape is `n_points`-by-3.
5861
5962 :Example:
6063
6164 >>> import pygem.freeform as ffd
6265 >>> import pygem.params as ffdp
6366 >>> import numpy as np
64-
6567 >>> ffd_parameters = ffdp.FFDParameters()
6668 >>> ffd_parameters.read_parameters('tests/test_datasets/parameters_test_ffd_sphere.prm')
6769 >>> original_mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
@@ -77,11 +79,8 @@ def __init__(self, ffd_parameters, original_mesh_points):
7779
7880 def perform (self ):
7981 """
80- This method performs the deformation on the mesh points. After the execution
81- it sets `self.modified_mesh_points`.
82-
83- .. todo::
84-
82+ This method performs the deformation on the mesh points. After the
83+ execution it sets `self.modified_mesh_points`.
8584 """
8685 # translation and then affine transformation
8786 translation = self .parameters .origin_box
@@ -113,7 +112,8 @@ def perform(self):
113112 ) & (reference_frame_mesh_points [:, 2 ] <= 1. )]
114113 (n_rows_mesh , n_cols_mesh ) = mesh_points .shape
115114
116- # Initialization. In order to exploit the contiguity in memory the following are transposed
115+ # Initialization. In order to exploit the contiguity in memory the
116+ # following are transposed
117117 (dim_n_mu , dim_m_mu , dim_t_mu ) = self .parameters .array_mu_x .shape
118118 bernstein_x = np .zeros ((dim_n_mu , n_rows_mesh ))
119119 bernstein_y = np .zeros ((dim_m_mu , n_rows_mesh ))
@@ -172,19 +172,15 @@ def perform(self):
172172 @staticmethod
173173 def _transform_points (original_points , transformation ):
174174 """
175- This private static method transforms the points according to the affine transformation taken from
176- affine_points_fit method.
175+ This private static method transforms the points according to the affine
176+ transformation taken from affine_points_fit method.
177177
178- :param numpy.ndarray original_points: coordinates of the original points.
179- :param function transformation: affine transformation taken from affine_points_fit method.
178+ :param numpy.ndarray original_points: coordinates of the original
179+ points.
180+ :param function transformation: affine transformation taken from
181+ affine_points_fit method.
180182
181183 :return: modified_points: coordinates of the modified points.
182184 :rtype: numpy.ndarray
183185 """
184- n_rows_mesh , n_cols_mesh = original_points .shape
185- modified_points = np .zeros ((n_rows_mesh , n_cols_mesh ))
186-
187- for i in range (0 , n_rows_mesh ):
188- modified_points [i , :] = transformation (original_points [i ])
189-
190- return modified_points
186+ return transformation (original_points )
0 commit comments