Free-form Deformation [CAD]

Utilities for performing Free Form Deformation (FFD) to CAD geometries.

Theoretical Insight

Free Form Deformation is a technique for the efficient, smooth and accurate geometrical parametrization. It has been proposed the first time in Sederberg, Thomas W., and Scott R. Parry. “Free-form deformation of solid geometric models.” ACM SIGGRAPH computer graphics 20.4 (1986): 151-160. It consists in three different step:

  • Mapping the physical domain to the reference one with map \boldsymbol{\psi}. In the code it is named transformation.

  • Moving some control points to deform the lattice with \hat{T}. The movement of the control points is basically the weight (or displacement) \boldsymbol{\mu} we set in the parameters file.

  • Mapping back to the physical domain with map \boldsymbol{\psi}^{-1}. In the code it is named inverse_transformation.

FFD map (T) is the composition of the three maps, that is

T(\cdot, \boldsymbol{\mu}) = (\Psi^{-1} \circ \hat{T} \circ \Psi) (\cdot, \boldsymbol{\mu})

In this way, every point inside the FFD box changes it position according to

\boldsymbol{P} = \boldsymbol{\psi}^{-1} \left( \sum_{l=0}^L \sum_{m=0}^M \sum_{n=0}^N \mathsf{b}_{lmn}(\boldsymbol{\psi}(\boldsymbol{P}_0)) \boldsymbol{\mu}_{lmn} \right)

where \mathsf{b}_{lmn} are Bernstein polynomials. We improve the traditional version by allowing a rotation of the FFD lattice in order to give more flexibility to the tool.

You can try to add more shapes to the lattice to allow more and more involved transformations.

class FFD(n_control_points=None, u_knots_to_add=0, v_knots_to_add=0, t_knots_to_add=0, tolerance=0.0001)[source]

Bases: pygem.cad.cad_deformation.CADDeformation, pygem.ffd.FFD

Class that handles the Free Form Deformation on CAD geometries.

Parameters
  • n_control_points (list) – number of control points in the x, y, and z direction. If not provided it is set to [2, 2, 2].

  • u_knots_to_add (int) – the number of knots to add to the NURBS surfaces along u direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.

  • v_knots_to_add (int) – the number of knots to add to the NURBS surfaces along v direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.

  • t_knots_to_add (int) – the number of knots to add to the NURBS curves before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.

  • tolerance (float) – the tolerance involved in several internal operations of the procedure (joining wires in a single curve before deformation and placing new poles on curves and surfaces). Change the default value only if the input file scale is significantly different form mm, making some of the aforementioned operations fail. Default is 0.0001.

Variables
  • box_length (numpy.ndarray) – dimension of the FFD bounding box, in the x, y and z direction (local coordinate system).

  • box_origin (numpy.ndarray) – the x, y and z coordinates of the origin of the FFD bounding box.

  • rot_angle (numpy.ndarray) – rotation angle around x, y and z axis of the FFD bounding box.

  • n_control_points (numpy.ndarray) – the number of control points in the x, y, and z direction.

  • array_mu_x (numpy.ndarray) – collects the displacements (weights) along x, normalized with the box length x.

  • array_mu_y (numpy.ndarray) – collects the displacements (weights) along y, normalized with the box length y.

  • array_mu_z (numpy.ndarray) – collects the displacements (weights) along z, normalized with the box length z.

  • u_knots_to_add (int) – the number of knots to add to the NURBS surfaces along u direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.

  • v_knots_to_add (int) – the number of knots to add to the NURBS surfaces along v direction before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.

  • t_knots_to_add (int) – the number of knots to add to the NURBS curves before the deformation. This parameter is useful whenever the gradient of the imposed deformation present spatial scales that are smaller than the local distance among the original poles of the surface/curve. Enriching the poles will allow for a more accurate application of the deformation, and might also reduce possible mismatches between bordering faces. On the orther hand, it might result in higher computational cost and bigger output files. Default is 0.

  • tolerance (float) – the tolerance involved in several internal operations of the procedure (joining wires in a single curve before deformation and placing new poles on curves and surfaces). Change the default value only if the input file scale is significantly different form mm, making some of the aforementioned operations fail. Default is 0.0001.

Example
>>> from pygem.cad import FFD
>>> from pygem.cad import CADDeformation
>>> ffd = FFD()
>>> ffd.read_parameters('parameters_test_ffd_iges.prm')
>>> input_cad_file_name = "input.iges"
>>> modified_cad_file_name = "output.iges"
>>> ffd(input_cad_file_name, modified_cad_file_name)
>>> # is equivalent to
>>> new_shape = ffd(CADDeformation.read_shape(input_cad_file_name))