From 87ccdb104c85fc45540559898d57d896e8bcf9c7 Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Tue, 20 Mar 2018 09:26:00 +0100
Subject: [PATCH 1/9] Clean params classes
---
pygem/__init__.py | 8 +-
pygem/{params.py => params_ffd.py} | 283 ++++++-----------------------
pygem/params_rbf.py | 197 ++++++++++++++++++++
tests/test_ffdparams.py | 121 ++++++------
tests/test_rbfparams.py | 74 ++++----
5 files changed, 342 insertions(+), 341 deletions(-)
rename pygem/{params.py => params_ffd.py} (62%)
create mode 100644 pygem/params_rbf.py
diff --git a/pygem/__init__.py b/pygem/__init__.py
index 74c5446..b47c15c 100644
--- a/pygem/__init__.py
+++ b/pygem/__init__.py
@@ -1,9 +1,10 @@
"""
"""
__all__ = [
- 'affine', 'filehandler', 'freeform', 'radial', 'openfhandler', 'params',
+ 'affine', 'filehandler', 'freeform', 'radial', 'openfhandler',
'stlhandler', 'unvhandler', 'vtkhandler', 'nurbshandler', 'stephandler',
- 'igeshandler', 'utils', 'gui', 'khandler', 'idw', 'params_idw'
+ 'igeshandler', 'utils', 'gui', 'khandler', 'idw', 'params_idw',
+ 'params_rbf', 'params_ffd'
]
from . import affine
@@ -11,7 +12,6 @@
from . import freeform
from . import radial
from . import openfhandler
-from . import params
from . import stlhandler
from . import unvhandler
from . import vtkhandler
@@ -23,3 +23,5 @@
from . import khandler
from . import idw
from . import params_idw
+from . import params_rbf
+from . import params_ffd
diff --git a/pygem/params.py b/pygem/params_ffd.py
similarity index 62%
rename from pygem/params.py
rename to pygem/params_ffd.py
index d4c718d..d85f8ec 100644
--- a/pygem/params.py
+++ b/pygem/params_ffd.py
@@ -25,27 +25,14 @@ class FFDParameters(object):
:param list n_control_points: number of control points in the x, y, and z
direction. If not provided it is set to [2, 2, 2].
- :cvar float length_box_x: length of the FFD bounding box in the x direction
- (local coordinate system).
- :cvar float length_box_y: length of the FFD bounding box in the y direction
- (local coordinate system).
- :cvar float length_box_z: length of the FFD bounding box in the z direction
- (local coordinate system).
-
- :cvar numpy.ndarray origin_box: a 3-by-1 vector of float numbers
- representing the x, y and z coordinates of the origin of the FFD
- bounding box.
-
- :cvar float rot_angle_x: rotation angle around x axis of the FFD bounding
- box.
- :cvar float rot_angle_y: rotation angle around y axis of the FFD bounding
- box.
- :cvar float rot_angle_z: rotation angle around z axis of the FFD bounding
- box.
-
- :cvar list n_control_points: list of 3 int representing the number of
- control points in the x, y, and z direction.
-
+ :cvar numpy.ndarray length_box: dimension of the FFD bounding box, in the
+ x, y and z direction (local coordinate system).
+ :cvar numpy.ndarray origin_box: the x, y and z coordinates of the origin of
+ the FFD bounding box.
+ :cvar numpy.ndarray rot_angle: rotation angle around x, y and z axis of the
+ FFD bounding box.
+ :cvar numpy.ndarray n_control_points: the number of control points in the
+ x, y, and z direction.
:cvar numpy.ndarray array_mu_x: collects the displacements (weights) along
x, normalized with the box lenght x.
:cvar numpy.ndarray array_mu_y: collects the displacements (weights) along
@@ -73,16 +60,18 @@ class FFDParameters(object):
:Example: from file
>>> import pygem.params as ffdp
-
+ >>>
>>> # Reading an existing file
>>> params1 = ffdp.FFDParameters()
- >>> params1.read_parameters(filename='tests/test_datasets/parameters_test_ffd_identity.prm')
-
- >>> # Creating a default parameters file with the right dimensions (if the file does not exists
- >>> # it is created with that name). So it is possible to manually edit it and read it again.
+ >>> params1.read_parameters(
+ >>> filename='tests/test_datasets/parameters_test_ffd_identity.prm')
+ >>>
+ >>> # Creating a default parameters file with the right dimensions (if the
+ >>> # file does not exists it is created with that name). So it is possible
+ >>> # to manually edit it and read it again.
>>> params2 = ffdp.FFDParameters(n_control_points=[2, 3, 2])
>>> params2.read_parameters(filename='parameters_test.prm')
-
+ >>>
>>> # Creating bounding box of the given shape
>>> from OCC.IGESControl import IGESControl_Reader
>>> params3 = ffdp.FFDParameters()
@@ -115,15 +104,42 @@ def __init__(self, n_control_points=None):
self.array_mu_y = np.zeros(self.n_control_points)
self.array_mu_z = np.zeros(self.n_control_points)
- self.psi_mapping = np.diag(1. / self.lenght_box)
- self.inv_psi_mapping = np.diag(self.lenght_box)
-
- self.rotation_matrix = np.eye(3)
self.position_vertex_0 = self.origin_box
self.position_vertex_1 = np.array([1., 0., 0.])
self.position_vertex_2 = np.array([0., 1., 0.])
self.position_vertex_3 = np.array([0., 0., 1.])
+ @property
+ def psi_mapping(self):
+ """
+ Map from the physical domain to the reference domain.
+
+ :return: map from the pysical domain to the reference domain.
+ :rtype: numpy.ndarray
+ """
+ return np.diag(np.reciprocal(self.lenght_box))
+
+ @property
+ def inv_psi_mapping(self):
+ """
+ Map from the reference domain to the physical domain.
+
+ :return: map from the reference domain to domain.
+ :rtype: numpy.ndarray
+ """
+ return np.diag(self.lenght_box)
+
+ @property
+ def rotation_matrix(self):
+ """
+ :cvar numpy.ndarray rotation_matrix: rotation matrix (according to
+ rot_angle_x, rot_angle_y, rot_angle_z).
+ """
+ return at.angles2matrix(
+ radians(self.rot_angle[2]), radians(self.rot_angle[1]),
+ radians(self.rot_angle[0]))
+
+
def read_parameters(self, filename='parameters.prm'):
"""
Reads in the parameters file and fill the self structure.
@@ -181,10 +197,6 @@ def read_parameters(self, filename='parameters.prm'):
values = line.split()
self.array_mu_z[tuple(map(int, values[0:3]))] = float(values[3])
- self.rotation_matrix = at.angles2matrix(
- radians(self.rot_angle[2]), radians(self.rot_angle[1]),
- radians(self.rot_angle[0]))
-
self.position_vertex_0 = self.origin_box
self.position_vertex_1 = self.position_vertex_0 + \
np.dot(self.rotation_matrix, [self.lenght_box[0], 0, 0])
@@ -193,9 +205,6 @@ def read_parameters(self, filename='parameters.prm'):
self.position_vertex_3 = self.position_vertex_0 + \
np.dot(self.rotation_matrix, [0, 0, self.lenght_box[2]])
- self.psi_mapping = np.diag(1. / self.lenght_box)
- self.inv_psi_mapping = np.diag(self.lenght_box)
-
def write_parameters(self, filename='parameters.prm'):
"""
This method writes a parameters file (.prm) called `filename` and fills
@@ -343,24 +352,10 @@ def build_bounding_box(self,
min_xyz, max_xyz = self._calculate_bb_dimension(shape, tol, triangulate,
triangulate_tol)
self.origin_box = min_xyz
- self._set_box_dimensions(min_xyz, max_xyz)
+ self.lenght_box = max_xyz - min_xyz
self._set_position_of_vertices()
- self._set_mapping()
self._set_transformation_params_to_zero()
- def _set_box_dimensions(self, min_xyz, max_xyz):
- """
- Dimensions of the cage are set as distance from the origin (minimum) of
- the cage to the maximal point in each dimension.
-
- :param iterable min_xyz: three values representing the minimal values of
- the bounding box in XYZ respectively
- :param iterable max_xyz: three values representing the maximal values of
- the bounding box in XYZ respectively
- """
- dims = [max_xyz[i] - min_xyz[i] for i in range(3)]
- self.lenght_box = np.asarray(dims)
-
def _set_position_of_vertices(self):
"""
Vertices of the control box around the object are set in this method.
@@ -376,24 +371,15 @@ def _set_position_of_vertices(self):
self.position_vertex_3 = self.origin_box + np.array(
[.0, .0, self.lenght_box[2]])
- def _set_mapping(self):
- """
- This method sets mapping from physcial domain to the reference domain
- (``psi_mapping``) as well as inverse mapping (``inv_psi_mapping``).
- """
- self.psi_mapping = np.diag([1. / self.lenght_box[i] for i in range(3)])
- self.inv_psi_mapping = np.diag(self.lenght_box)
-
def _set_transformation_params_to_zero(self):
"""
Sets transfomration parameters (``array_mu_x, array_mu_y, array_mu_z``)
to arrays of zeros (``numpy.zeros``). The shape of arrays corresponds to
the number of control points in each dimension.
"""
- ctrl_pnts = self.n_control_points
- self.array_mu_x = np.zeros(ctrl_pnts)
- self.array_mu_y = np.zeros(ctrl_pnts)
- self.array_mu_z = np.zeros(ctrl_pnts)
+ self.array_mu_x.fill(0.0)
+ self.array_mu_y.fill(0.0)
+ self.array_mu_z.fill(0.0)
@staticmethod
def _calculate_bb_dimension(shape,
@@ -428,170 +414,3 @@ def _calculate_bb_dimension(shape,
xyz_min = np.array([xmin, ymin, zmin])
xyz_max = np.array([xmax, ymax, zmax])
return xyz_min, xyz_max
-
-
-class RBFParameters(object):
- """
- Class that handles the Radial Basis Functions parameters in terms of RBF
- control points and basis functions.
-
- :cvar string basis: name of the basis functions to use in the
- transformation. The functions implemented so far are: gaussian spline,
- multi quadratic biharmonic spline, inv multi quadratic biharmonic
- spline, thin plate spline, beckert wendland c2 basis, polyharmonic
- splines. For a comprehensive list with details see the class
- :class:`~pygem.radialbasis.RBF`. The default value is None.
- :cvar float radius: is the scaling parameter r that affects the shape of the
- basis functions. For details see the class
- :class:`~pygem.radialbasis.RBF`. The default value is None.
- :cvar int n_control_points: total number of control points.
- :cvar numpy.ndarray original_control_points: it is an
- `n_control_points`-by-3 array with the coordinates of the original
- interpolation control points before the deformation. The default value
- is None.
- :cvar numpy.ndarray deformed_control_points: it is an
- `n_control_points`-by-3 array with the coordinates of the
- interpolation control points after the deformation. The default value is
- None.
- """
-
- def __init__(self):
- self.basis = None
- self.radius = None
- self.power = 2
- self.n_control_points = None
- self.original_control_points = None
- self.deformed_control_points = None
-
- def read_parameters(self, filename='parameters_rbf.prm'):
- """
- Reads in the parameters file and fill the self structure.
-
- :param string filename: parameters file to be read in. Default value is
- parameters_rbf.prm.
- """
- if not isinstance(filename, str):
- raise TypeError('filename must be a string')
-
- # Checks if the parameters file exists. If not it writes the default
- # class into filename. It consists in the vetices of a cube of side one
- # with a vertex in (0, 0, 0) and opposite one in (1, 1, 1).
- if not os.path.isfile(filename):
- self.basis = 'gaussian_spline'
- self.radius = 0.5
- self.n_control_points = 8
- self.original_control_points = np.array([0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 0., 0., \
- 0., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 1.]).reshape((8, 3))
- self.deformed_control_points = np.array([0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 0., 0., \
- 0., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 1.]).reshape((8, 3))
- self.write_parameters(filename)
- return
-
- config = configparser.RawConfigParser()
- config.read(filename)
-
- self.basis = config.get('Radial Basis Functions', 'basis function')
- self.radius = config.getfloat('Radial Basis Functions', 'radius')
- self.power = config.getint('Radial Basis Functions', 'power')
-
- ctrl_points = config.get('Control points', 'original control points')
- lines = ctrl_points.split('\n')
- self.n_control_points = len(lines)
- self.original_control_points = np.zeros((self.n_control_points, 3))
- for line, i in zip(lines, list(range(0, self.n_control_points))):
- values = line.split()
- self.original_control_points[i] = np.array(
- [float(values[0]),
- float(values[1]),
- float(values[2])])
-
- mod_points = config.get('Control points', 'deformed control points')
- lines = mod_points.split('\n')
-
- if len(lines) != self.n_control_points:
- raise TypeError("The number of control points must be equal both in the 'original control points'" + \
- " and in the 'deformed control points' section of the parameters file ({0!s})".format(filename))
-
- self.deformed_control_points = np.zeros((self.n_control_points, 3))
- for line, i in zip(lines, list(range(0, self.n_control_points))):
- values = line.split()
- self.deformed_control_points[i] = np.array(
- [float(values[0]),
- float(values[1]),
- float(values[2])])
-
- def write_parameters(self, filename='parameters_rbf.prm'):
- """
- This method writes a parameters file (.prm) called `filename` and fills
- it with all the parameters class members. Default value is
- parameters_rbf.prm.
-
- :param string filename: parameters file to be written out.
- """
- if not isinstance(filename, str):
- raise TypeError("filename must be a string")
-
- with open(filename, 'w') as output_file:
- output_file.write('\n[Radial Basis Functions]\n')
- output_file.write(
- '# This section describes the radial basis functions shape.\n')
-
- output_file.write('\n# basis funtion is the name of the basis functions to use in the transformation. ' + \
- 'The functions\n')
- output_file.write(
- '# implemented so far are: gaussian_spline, multi_quadratic_biharmonic_spline,\n'
- )
- output_file.write(
- '# inv_multi_quadratic_biharmonic_spline, thin_plate_spline, beckert_wendland_c2_basis, polyharmonic_spline.\n'
- )
- output_file.write(
- '# For a comprehensive list with details see the class RBF.\n')
- output_file.write('basis function: ' + str(self.basis) + '\n')
-
- output_file.write('\n# radius is the scaling parameter r that affects the shape of the basis functions. ' + \
- 'See the documentation\n')
- output_file.write('# of the class RBF for details.\n')
- output_file.write('radius: ' + str(self.radius) + '\n')
- output_file.write(
- '\n# The power parameter k for polyharmonic spline')
- output_file.write('\n# See the documentation for details\n')
- output_file.write('power: ' + str(self.power) + '\n')
-
- output_file.write('\n\n[Control points]\n')
- output_file.write(
- '# This section describes the RBF control points.\n')
-
- output_file.write('\n# original control points collects the coordinates of the interpolation ' + \
- 'control points before the deformation.\n')
- output_file.write('original control points:')
- offset = 1
- for i in range(0, self.n_control_points):
- output_file.write(offset * ' ' + str(self.original_control_points[i][0]) + ' ' + \
- str(self.original_control_points[i][1]) + ' ' + \
- str(self.original_control_points[i][2]) + '\n')
- offset = 25
-
- output_file.write('\n# deformed control points collects the coordinates of the interpolation ' + \
- 'control points after the deformation.\n')
- output_file.write('deformed control points:')
- offset = 1
- for i in range(0, self.n_control_points):
- output_file.write(offset * ' ' + str(self.deformed_control_points[i][0]) + ' ' + \
- str(self.deformed_control_points[i][1]) + ' ' + \
- str(self.deformed_control_points[i][2]) + '\n')
- offset = 25
-
- def __str__(self):
- """
- This method prints all the RBF parameters on the screen. Its purpose is
- for debugging.
- """
- string = ''
- string += 'basis function = {}\n'.format(self.basis)
- string += 'radius = {}\n'.format(self.radius)
- string += 'power = {}\n'.format(self.power)
- string += '\noriginal control points =\n'
- string += '{}\n'.format(self.original_control_points)
- string += '\ndeformed control points =\n'
- string += '{}\n'.format(self.deformed_control_points)
- return string
diff --git a/pygem/params_rbf.py b/pygem/params_rbf.py
new file mode 100644
index 0000000..1013926
--- /dev/null
+++ b/pygem/params_rbf.py
@@ -0,0 +1,197 @@
+"""
+Utilities for reading and writing parameters files to perform the desired
+geometrical morphing.
+"""
+try:
+ import configparser as configparser
+except ImportError:
+ import ConfigParser as configparser
+import os
+
+import numpy as np
+
+class RBFParameters(object):
+ """
+ Class that handles the Radial Basis Functions parameters in terms of RBF
+ control points and basis functions.
+
+ :cvar string basis: name of the basis functions to use in the
+ transformation. The functions implemented so far are: gaussian spline,
+ multi quadratic biharmonic spline, inv multi quadratic biharmonic
+ spline, thin plate spline, beckert wendland c2 basis, polyharmonic
+ splines. For a comprehensive list with details see the class
+ :class:`~pygem.radialbasis.RBF`. The default value is 'gaussian_spline'.
+ :cvar float radius: the scaling parameter r that affects the shape of the
+ basis functions. For details see the class
+ :class:`~pygem.radialbasis.RBF`. The default value is 0.5.
+ :cvar int power: the power parameter that affects the shape of the basis
+ functions. For details see the class :class:`~pygem.radialbasis.RBF`.
+ The default value is 0.5.
+ :cvar numpy.ndarray original_control_points: *n_control_points*-by-3 array
+ with the coordinates of the original interpolation control points
+ before the deformation. The default values are the coordinates of unit
+ cube vertices.
+ :cvar numpy.ndarray deformed_control_points: it is an
+ `n_control_points`-by-3 array with the coordinates of the
+ interpolation control points after the deformation. The default values
+ are the coordinates of the unit cube vertices.
+ """
+
+ def __init__(self):
+ self.basis = 'gaussian_spline'
+ self.radius = 0.5
+ self.power = 2
+ self.original_control_points = np.array([
+ [0., 0., 0.],
+ [0., 0., 1.],
+ [0., 1., 0.],
+ [1., 0., 0.],
+ [0., 1., 1.],
+ [1., 0., 1.],
+ [1., 1., 0.],
+ [1., 1., 1.]])
+ self.deformed_control_points = np.array([
+ [0., 0., 0.],
+ [0., 0., 1.],
+ [0., 1., 0.],
+ [1., 0., 0.],
+ [0., 1., 1.],
+ [1., 0., 1.],
+ [1., 1., 0.],
+ [1., 1., 1.]])
+
+ @property
+ def n_control_points(self):
+ """
+ Total number of control points.
+
+ :rtype: int
+ """
+ return self.original_control_points.shape[0]
+
+ def read_parameters(self, filename='parameters_rbf.prm'):
+ """
+ Reads in the parameters file and fill the self structure.
+
+ :param string filename: parameters file to be read in. Default value is
+ parameters_rbf.prm.
+ """
+ if not isinstance(filename, str):
+ raise TypeError('filename must be a string')
+
+ # Checks if the parameters file exists. If not it writes the default
+ # class into filename. It consists in the vetices of a cube of side one
+ # with a vertex in (0, 0, 0) and opposite one in (1, 1, 1).
+ if not os.path.isfile(filename):
+ self.write_parameters(filename)
+ return
+
+ config = configparser.RawConfigParser()
+ config.read(filename)
+
+ self.basis = config.get('Radial Basis Functions', 'basis function')
+ self.radius = config.getfloat('Radial Basis Functions', 'radius')
+ self.power = config.getint('Radial Basis Functions', 'power')
+
+ ctrl_points = config.get('Control points', 'original control points')
+ lines = ctrl_points.split('\n')
+ self.original_control_points = np.zeros((self.n_control_points, 3))
+ for line, i in zip(lines, list(range(0, self.n_control_points))):
+ values = line.split()
+ self.original_control_points[i] = np.array(
+ [float(values[0]),
+ float(values[1]),
+ float(values[2])])
+
+ mod_points = config.get('Control points', 'deformed control points')
+ lines = mod_points.split('\n')
+
+ if len(lines) != self.n_control_points:
+ raise TypeError("The number of control points must be equal both in"
+ "the 'original control points' and in the 'deformed"
+ "control points' section of the parameters file"
+ "({0!s})".format(filename))
+
+ self.deformed_control_points = np.zeros((self.n_control_points, 3))
+ for line, i in zip(lines, list(range(0, self.n_control_points))):
+ values = line.split()
+ self.deformed_control_points[i] = np.array(
+ [float(values[0]),
+ float(values[1]),
+ float(values[2])])
+
+ def write_parameters(self, filename='parameters_rbf.prm'):
+ """
+ This method writes a parameters file (.prm) called `filename` and fills
+ it with all the parameters class members. Default value is
+ parameters_rbf.prm.
+
+ :param string filename: parameters file to be written out.
+ """
+ if not isinstance(filename, str):
+ raise TypeError("filename must be a string")
+
+ with open(filename, 'w') as output_file:
+ output_file.write('\n[Radial Basis Functions]\n')
+ output_file.write(
+ '# This section describes the radial basis functions shape.\n')
+
+ output_file.write('\n# basis funtion is the name of the basis functions to use in the transformation. ' + \
+ 'The functions\n')
+ output_file.write(
+ '# implemented so far are: gaussian_spline, multi_quadratic_biharmonic_spline,\n'
+ )
+ output_file.write(
+ '# inv_multi_quadratic_biharmonic_spline, thin_plate_spline, beckert_wendland_c2_basis, polyharmonic_spline.\n'
+ )
+ output_file.write(
+ '# For a comprehensive list with details see the class RBF.\n')
+ output_file.write('basis function: ' + str(self.basis) + '\n')
+
+ output_file.write('\n# radius is the scaling parameter r that affects the shape of the basis functions. ' + \
+ 'See the documentation\n')
+ output_file.write('# of the class RBF for details.\n')
+ output_file.write('radius: ' + str(self.radius) + '\n')
+ output_file.write(
+ '\n# The power parameter k for polyharmonic spline')
+ output_file.write('\n# See the documentation for details\n')
+ output_file.write('power: ' + str(self.power) + '\n')
+
+ output_file.write('\n\n[Control points]\n')
+ output_file.write(
+ '# This section describes the RBF control points.\n')
+
+ output_file.write('\n# original control points collects the coordinates of the interpolation ' + \
+ 'control points before the deformation.\n')
+ output_file.write('original control points:')
+ offset = 1
+ for i in range(0, self.n_control_points):
+ output_file.write(offset * ' ' + str(self.original_control_points[i][0]) + ' ' + \
+ str(self.original_control_points[i][1]) + ' ' + \
+ str(self.original_control_points[i][2]) + '\n')
+ offset = 25
+
+ output_file.write('\n# deformed control points collects the coordinates of the interpolation ' + \
+ 'control points after the deformation.\n')
+ output_file.write('deformed control points:')
+ offset = 1
+ for i in range(0, self.n_control_points):
+ output_file.write(offset * ' ' + str(self.deformed_control_points[i][0]) + ' ' + \
+ str(self.deformed_control_points[i][1]) + ' ' + \
+ str(self.deformed_control_points[i][2]) + '\n')
+ offset = 25
+
+ def __str__(self):
+ """
+ This method prints all the RBF parameters on the screen. Its purpose is
+ for debugging.
+ """
+ string = ''
+ string += 'basis function = {}\n'.format(self.basis)
+ string += 'radius = {}\n'.format(self.radius)
+ string += 'power = {}\n'.format(self.power)
+ string += '\noriginal control points =\n'
+ string += '{}\n'.format(self.original_control_points)
+ string += '\ndeformed control points =\n'
+ string += '{}\n'.format(self.deformed_control_points)
+ return string
diff --git a/tests/test_ffdparams.py b/tests/test_ffdparams.py
index 37c3332..42704c1 100644
--- a/tests/test_ffdparams.py
+++ b/tests/test_ffdparams.py
@@ -7,127 +7,127 @@
from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere, BRepPrimAPI_MakeBox
from OCC.gp import gp_Pnt
-import pygem.params as ffdp
+from pygem.params_ffd import FFDParameters
class TestFFDParameters(TestCase):
def test_class_members_default_n_control_points(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
assert np.array_equal(params.n_control_points, [2, 2, 2])
def test_class_members_default_conversion_unit(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
assert params.conversion_unit == 1.
def test_class_members_default_lenght_box(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
assert np.array_equal(params.lenght_box, np.ones(3))
def test_class_members_default_origin_box(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
assert np.array_equal(params.origin_box, np.zeros(3))
def test_class_members_default_rot_angle(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
assert np.array_equal(params.rot_angle, np.zeros(3))
def test_class_members_default_array_mu_x(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.array_mu_x,
np.zeros((2, 2, 2)))
def test_class_members_default_array_mu_y(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.array_mu_y,
np.zeros((2, 2, 2)))
def test_class_members_default_array_mu_z(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.array_mu_z,
np.zeros((2, 2, 2)))
def test_class_members_default_psi_mapping(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.psi_mapping,
np.diag([1, 1, 1]))
def test_class_members_default_inv_psi_mapping(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.inv_psi_mapping,
np.diag([1, 1, 1]))
def test_class_members_default_rotation_matrix(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.rotation_matrix, np.eye(3))
def test_class_members_default_position_vertex_0(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.position_vertex_0,
np.zeros(3))
def test_class_members_default_position_vertex_1(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.position_vertex_1,
np.array([1., 0., 0.]))
def test_class_members_default_position_vertex_2(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.position_vertex_2,
np.array([0., 1., 0.]))
def test_class_members_default_position_vertex_3(self):
- params = ffdp.FFDParameters()
+ params = FFDParameters()
np.testing.assert_array_almost_equal(params.position_vertex_3,
np.array([0., 0., 1.]))
def test_class_members_generic_n_control_points(self):
- params = ffdp.FFDParameters([2, 3, 5])
+ params = FFDParameters([2, 3, 5])
assert np.array_equal(params.n_control_points, [2, 3, 5])
def test_class_members_generic_array_mu_x(self):
- params = ffdp.FFDParameters([2, 3, 5])
+ params = FFDParameters([2, 3, 5])
np.testing.assert_array_almost_equal(params.array_mu_x,
np.zeros((2, 3, 5)))
def test_class_members_generic_array_mu_y(self):
- params = ffdp.FFDParameters([2, 3, 5])
+ params = FFDParameters([2, 3, 5])
np.testing.assert_array_almost_equal(params.array_mu_y,
np.zeros((2, 3, 5)))
def test_class_members_generic_array_mu_z(self):
- params = ffdp.FFDParameters([2, 3, 5])
+ params = FFDParameters([2, 3, 5])
np.testing.assert_array_almost_equal(params.array_mu_z,
np.zeros((2, 3, 5)))
def test_read_parameters_conversion_unit(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
assert params.conversion_unit == 1.
def test_read_parameters_n_control_points(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
assert np.array_equal(params.n_control_points, [3, 2, 2])
def test_read_parameters_lenght_box_x(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
assert np.array_equal(params.lenght_box, [45.0, 90.0, 90.0])
def test_read_parameters_origin_box(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
origin_box_exact = np.array([-20.0, -55.0, -45.0])
np.testing.assert_array_almost_equal(params.origin_box,
origin_box_exact)
def test_read_parameters_rot_angle_x(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
assert np.array_equal(params.rot_angle, [20.3, 11.0, 0.])
def test_read_parameters_array_mu_x(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
array_mu_x_exact = np.array(
[0.2, 0., 0., 0., 0.5, 0., 0., 0., 1., 0., 0., 0.]).reshape((3, 2,
@@ -137,7 +137,7 @@ def test_read_parameters_array_mu_x(self):
array_mu_x_exact)
def test_read_parameters_array_mu_y(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
array_mu_y_exact = np.array(
[0., 0., 0.5555555555, 0., 0., 0., 0., 0., -1., 0., 0.,
@@ -146,7 +146,7 @@ def test_read_parameters_array_mu_y(self):
array_mu_y_exact)
def test_read_parameters_array_mu_z(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
array_mu_z_exact = np.array(
[0., -0.2, 0., -0.45622985, 0., 0., 0., 0., -1.22, 0., -1.,
@@ -155,21 +155,21 @@ def test_read_parameters_array_mu_z(self):
array_mu_z_exact)
def test_read_parameters_psi_mapping(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
psi_mapping_exact = np.diag([0.02222222, 0.01111111, 0.01111111])
np.testing.assert_array_almost_equal(params.psi_mapping,
psi_mapping_exact)
def test_read_parameters_inv_psi_mapping(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
inv_psi_mapping_exact = np.diag([45., 90., 90.])
np.testing.assert_array_almost_equal(params.inv_psi_mapping,
inv_psi_mapping_exact)
def test_read_parameters_rotation_matrix(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
rotation_matrix_exact = np.array(
[[0.98162718, 0., 0.190809], [0.06619844, 0.93788893, -0.34056147],
@@ -178,20 +178,20 @@ def test_read_parameters_rotation_matrix(self):
rotation_matrix_exact)
def test_read_parameters_position_vertex_0_origin(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
np.testing.assert_array_almost_equal(params.position_vertex_0,
params.origin_box)
def test_read_parameters_position_vertex_0(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
position_vertex_0_exact = np.array([-20.0, -55.0, -45.0])
np.testing.assert_array_almost_equal(params.position_vertex_0,
position_vertex_0_exact)
def test_read_parameters_position_vertex_1(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
position_vertex_1_exact = np.array(
[24.17322326, -52.02107006, -53.05309404])
@@ -199,14 +199,14 @@ def test_read_parameters_position_vertex_1(self):
position_vertex_1_exact)
def test_read_parameters_position_vertex_2(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
position_vertex_2_exact = np.array([-20., 29.41000412, -13.77579136])
np.testing.assert_array_almost_equal(params.position_vertex_2,
position_vertex_2_exact)
def test_read_parameters_position_vertex_3(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
position_vertex_3_exact = np.array(
[-2.82719042, -85.65053198, 37.85915459])
@@ -214,19 +214,19 @@ def test_read_parameters_position_vertex_3(self):
position_vertex_3_exact)
def test_read_parameters_failing_filename_type(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
with self.assertRaises(TypeError):
params.read_parameters(3)
def test_read_parameters_filename_default_existance(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters()
outfilename = 'parameters.prm'
assert os.path.isfile(outfilename)
os.remove(outfilename)
def test_read_parameters_filename_default(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters()
outfilename = 'parameters.prm'
outfilename_expected = 'tests/test_datasets/parameters_default.prm'
@@ -235,19 +235,19 @@ def test_read_parameters_filename_default(self):
os.remove(outfilename)
def test_write_parameters_failing_filename_type(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
with self.assertRaises(TypeError):
params.write_parameters(5)
def test_write_parameters_filename_default_existance(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.write_parameters()
outfilename = 'parameters.prm'
assert os.path.isfile(outfilename)
os.remove(outfilename)
def test_write_parameters_filename_default(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.write_parameters()
outfilename = 'parameters.prm'
outfilename_expected = 'tests/test_datasets/parameters_default.prm'
@@ -256,7 +256,7 @@ def test_write_parameters_filename_default(self):
os.remove(outfilename)
def test_write_parameters(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
outfilename = 'tests/test_datasets/parameters_sphere_out.prm'
@@ -267,14 +267,14 @@ def test_write_parameters(self):
os.remove(outfilename)
def test_print(self):
- params = ffdp.FFDParameters(n_control_points=[3, 2, 2])
+ params = FFDParameters(n_control_points=[3, 2, 2])
print(params)
def test_build_bounding_box_1(self):
origin = np.array([0., 0., 0.])
tops = np.array([1., 1., 1.])
cube = BRepPrimAPI_MakeBox(*tops).Shape()
- params = ffdp.FFDParameters()
+ params = FFDParameters()
params.build_bounding_box(cube)
np.testing.assert_array_almost_equal(params.lenght_box, tops, decimal=5)
@@ -283,7 +283,7 @@ def test_build_bounding_box_2(self):
origin = np.array([0., 0., 0.])
tops = np.array([1., 1., 1.])
cube = BRepPrimAPI_MakeBox(*tops).Shape()
- params = ffdp.FFDParameters()
+ params = FFDParameters()
params.build_bounding_box(cube)
np.testing.assert_almost_equal(
@@ -295,42 +295,23 @@ def test_build_bounding_box_2(self):
np.testing.assert_almost_equal(
params.position_vertex_3, [0., 0., 1.], decimal=5)
- def test_set_box_dimension(self):
- origin = np.array([0., 0., 0.])
- tops = np.array([10., 10., 10.])
- params = ffdp.FFDParameters()
- params.origin_box = origin
- params._set_box_dimensions(origin, tops)
- np.testing.assert_array_almost_equal(params.lenght_box, tops)
-
def test_set_position_of_vertices(self):
vertex_0 = [0., 0., 0.]
vertex_1 = [1., 0., 0.]
vertex_2 = [0., 1., 0.]
vertex_3 = [0., 0., 1.]
tops = np.array([1., 1., 1.])
- params = ffdp.FFDParameters()
+ params = FFDParameters()
params.origin_box = vertex_0
- params._set_box_dimensions(vertex_0, tops)
+ params.lenght_box = tops - vertex_0
params._set_position_of_vertices()
np.testing.assert_equal(params.position_vertex_0, vertex_0)
np.testing.assert_equal(params.position_vertex_1, vertex_1)
np.testing.assert_equal(params.position_vertex_2, vertex_2)
np.testing.assert_equal(params.position_vertex_3, vertex_3)
- def test_set_mapping(self):
- origin = np.array([0., 0., 0.])
- tops = np.array([10., 10., 10.])
- params = ffdp.FFDParameters()
- params.origin_box = origin
- params._set_box_dimensions(origin, tops)
- params._set_mapping()
- for i in range(3):
- self.assertEqual(params.psi_mapping[i][i], 1. / tops[i])
- self.assertEqual(params.inv_psi_mapping[i][i], tops[i])
-
def test_set_modification_parameters_to_zero(self):
- params = ffdp.FFDParameters([5, 5, 5])
+ params = FFDParameters([5, 5, 5])
params._set_transformation_params_to_zero()
np.testing.assert_almost_equal(
params.array_mu_x, np.zeros(shape=(5, 5, 5)))
@@ -343,7 +324,7 @@ def test_calculate_bb_dimensions(self):
min_vals = np.zeros(3)
max_vals = np.ones(3)
cube = BRepPrimAPI_MakeBox(1, 1, 1).Shape()
- params = ffdp.FFDParameters()
+ params = FFDParameters()
xyz_min, xyz_max = params._calculate_bb_dimension(cube)
np.testing.assert_almost_equal(xyz_min, min_vals, decimal=5)
np.testing.assert_almost_equal(xyz_max, max_vals, decimal=5)
@@ -355,7 +336,7 @@ def test_calculate_bb_dimensions_triangulate(self):
box = BRepPrimAPI_MakeBox(a, b).Shape()
sphere = BRepPrimAPI_MakeSphere(3).Shape()
section = BRepAlgoAPI_Cut(box, sphere).Shape()
- params = ffdp.FFDParameters()
+ params = FFDParameters()
xyz_min, xyz_max = params._calculate_bb_dimension(
section, triangulate=True)
correct_min = -1 * np.ones(3)
diff --git a/tests/test_rbfparams.py b/tests/test_rbfparams.py
index e5acb52..fe260de 100644
--- a/tests/test_rbfparams.py
+++ b/tests/test_rbfparams.py
@@ -1,84 +1,89 @@
from unittest import TestCase
import unittest
-import pygem.params as rbfp
import numpy as np
import filecmp
import os
+from pygem.params_rbf import RBFParameters
+
+unit_cube = np.array([
+ [0., 0., 0.],
+ [0., 0., 1.],
+ [0., 1., 0.],
+ [1., 0., 0.],
+ [0., 1., 1.],
+ [1., 0., 1.],
+ [1., 1., 0.],
+ [1., 1., 1.]])
class TestRBFParameters(TestCase):
def test_class_members_default_basis(self):
- params = rbfp.RBFParameters()
- assert params.basis == None
+ params = RBFParameters()
+ assert params.basis == 'gaussian_spline'
def test_class_members_default_radius(self):
- params = rbfp.RBFParameters()
- assert params.radius == None
+ params = RBFParameters()
+ assert params.radius == 0.5
def test_class_members_default_n_control_points(self):
- params = rbfp.RBFParameters()
- assert params.n_control_points == None
+ params = RBFParameters()
+ assert params.n_control_points == 8
def test_class_members_default_original_control_points(self):
- params = rbfp.RBFParameters()
- assert params.original_control_points == None
+ params = RBFParameters()
+ np.testing.assert_array_equal(params.original_control_points, unit_cube)
def test_class_members_default_deformed_control_points(self):
- params = rbfp.RBFParameters()
- assert params.deformed_control_points == None
+ params = RBFParameters()
+ np.testing.assert_array_equal(params.deformed_control_points, unit_cube)
def test_read_parameters_basis(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
assert params.basis == 'gaussian_spline'
def test_read_parameters_radius(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
assert params.radius == 0.5
def test_read_parameters_n_control_points(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
assert params.n_control_points == 8
def test_read_parameters_original_control_points(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
- original_control_points_exact = np.array([0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 0., 0., \
- 0., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 1.]).reshape((8, 3))
np.testing.assert_array_almost_equal(params.original_control_points,
- original_control_points_exact)
+ unit_cube)
def test_read_parameters_deformed_control_points(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.read_parameters('tests/test_datasets/parameters_rbf_default.prm')
- deformed_control_points_exact = np.array([0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 0., 0., \
- 0., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 1.]).reshape((8, 3))
np.testing.assert_array_almost_equal(params.deformed_control_points,
- deformed_control_points_exact)
+ unit_cube)
def test_read_parameters_failing_filename_type(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
with self.assertRaises(TypeError):
params.read_parameters(3)
def test_read_parameters_failing_number_deformed_control_points(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
with self.assertRaises(TypeError):
params.read_parameters(
'tests/test_datasets/parameters_rbf_bugged_01.prm')
def test_write_parameters_failing_filename_type(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
with self.assertRaises(TypeError):
params.write_parameters(5)
def test_write_parameters_filename_default_existance(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.basis = 'inv_multi_quadratic_biharmonic_spline'
params.radius = 0.1
- params.n_control_points = 3
params.original_control_points = np.array(
[0., 0., 0., 0., 0., 1., 0., 1., 0.]).reshape((3, 3))
params.deformed_control_points = np.array(
@@ -89,15 +94,12 @@ def test_write_parameters_filename_default_existance(self):
os.remove(outfilename)
def test_write_parameters_filename_default(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.basis = 'gaussian_spline'
params.radius = 0.5
- params.n_control_points = 8
params.power = 2
- params.original_control_points = np.array([0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 0., 0., \
- 0., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 1.]).reshape((8, 3))
- params.deformed_control_points = np.array([0., 0., 0., 0., 0., 1., 0., 1., 0., 1., 0., 0., \
- 0., 1., 1., 1., 0., 1., 1., 1., 0., 1., 1., 1.]).reshape((8, 3))
+ params.original_control_points = unit_cube
+ params.deformed_control_points = unit_cube
outfilename = 'test.prm'
params.write_parameters(outfilename)
outfilename_expected = 'tests/test_datasets/parameters_rbf_default.prm'
@@ -107,7 +109,7 @@ def test_write_parameters_filename_default(self):
os.remove(outfilename)
def test_write_parameters(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.read_parameters('tests/test_datasets/parameters_rbf_cube.prm')
outfilename = 'tests/test_datasets/parameters_rbf_cube_out.prm'
@@ -118,7 +120,7 @@ def test_write_parameters(self):
os.remove(outfilename)
def test_read_parameters_filename_default(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
params.read_parameters()
outfilename = 'parameters_rbf.prm'
outfilename_expected = 'tests/test_datasets/parameters_rbf_default.prm'
@@ -127,5 +129,5 @@ def test_read_parameters_filename_default(self):
os.remove(outfilename)
def test_print_info(self):
- params = rbfp.RBFParameters()
+ params = RBFParameters()
print(params)
From b33b46c9943c4edd79a3e524c21ea46cc789099e Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Tue, 20 Mar 2018 15:54:19 +0100
Subject: [PATCH 2/9] Reorganize package
- move params classes to submodule
- edit the init for implicit import
- move functions for save FFD/RBF points to respective classes
---
pygem/__init__.py | 42 +++++------
pygem/params/__init__.py | 3 +
pygem/{params_ffd.py => params/ffdparams.py} | 75 ++++++++++++++++++--
pygem/{params_idw.py => params/idwparams.py} | 0
pygem/{params_rbf.py => params/rbfparams.py} | 41 ++++++++++-
pygem/utils.py | 2 +-
tests/test_ffdparams.py | 2 +-
tests/test_idw.py | 4 +-
tests/test_idwparams.py | 2 +-
tests/test_package.py | 2 +
tests/test_rbfparams.py | 2 +-
11 files changed, 140 insertions(+), 35 deletions(-)
create mode 100644 pygem/params/__init__.py
rename pygem/{params_ffd.py => params/ffdparams.py} (87%)
rename pygem/{params_idw.py => params/idwparams.py} (100%)
rename pygem/{params_rbf.py => params/rbfparams.py} (85%)
diff --git a/pygem/__init__.py b/pygem/__init__.py
index b47c15c..3debeae 100644
--- a/pygem/__init__.py
+++ b/pygem/__init__.py
@@ -1,27 +1,23 @@
"""
"""
-__all__ = [
- 'affine', 'filehandler', 'freeform', 'radial', 'openfhandler',
- 'stlhandler', 'unvhandler', 'vtkhandler', 'nurbshandler', 'stephandler',
- 'igeshandler', 'utils', 'gui', 'khandler', 'idw', 'params_idw',
- 'params_rbf', 'params_ffd'
-]
+# __all__ = [
+# 'affine', 'filehandler', 'freeform', 'radial', 'openfhandler',
+# 'stlhandler', 'unvhandler', 'vtkhandler', 'nurbshandler', 'stephandler',
+# 'igeshandler', 'utils', 'gui', 'khandler', 'idw'
+# ]
-from . import affine
-from . import filehandler
-from . import freeform
-from . import radial
-from . import openfhandler
-from . import stlhandler
-from . import unvhandler
-from . import vtkhandler
-from . import nurbshandler
-from . import stephandler
-from . import igeshandler
-from . import utils
+from .affine import *
+from .freeform import FFD
+from .radial import RBF
+from .idw import IDW
+from .filehandler import FileHandler
+from .openfhandler import OpenFoamHandler
+from .stlhandler import StlHandler
+from .unvhandler import UnvHandler
+from .vtkhandler import VtkHandler
+from .nurbshandler import NurbsHandler
+from .stephandler import StepHandler
+from .igeshandler import IgesHandler
+from .khandler import KHandler
from . import gui
-from . import khandler
-from . import idw
-from . import params_idw
-from . import params_rbf
-from . import params_ffd
+from .params import *
diff --git a/pygem/params/__init__.py b/pygem/params/__init__.py
new file mode 100644
index 0000000..97ce823
--- /dev/null
+++ b/pygem/params/__init__.py
@@ -0,0 +1,3 @@
+from .rbfparams import RBFParameters
+from .ffdparams import FFDParameters
+from .idwparams import IDWParameters
diff --git a/pygem/params_ffd.py b/pygem/params/ffdparams.py
similarity index 87%
rename from pygem/params_ffd.py
rename to pygem/params/ffdparams.py
index d85f8ec..f2cc6f2 100644
--- a/pygem/params_ffd.py
+++ b/pygem/params/ffdparams.py
@@ -13,6 +13,7 @@
from OCC.BRepMesh import BRepMesh_IncrementalMesh
from OCC.Bnd import Bnd_Box
+import vtk
import pygem.affine as at
from math import radians
@@ -23,7 +24,7 @@ class FFDParameters(object):
bounding box and weight of the FFD control points.
:param list n_control_points: number of control points in the x, y, and z
- direction. If not provided it is set to [2, 2, 2].
+ direction. If not provided it is set to [2, 2, 2].
:cvar numpy.ndarray length_box: dimension of the FFD bounding box, in the
x, y and z direction (local coordinate system).
@@ -114,7 +115,6 @@ def psi_mapping(self):
"""
Map from the physical domain to the reference domain.
- :return: map from the pysical domain to the reference domain.
:rtype: numpy.ndarray
"""
return np.diag(np.reciprocal(self.lenght_box))
@@ -124,7 +124,6 @@ def inv_psi_mapping(self):
"""
Map from the reference domain to the physical domain.
- :return: map from the reference domain to domain.
:rtype: numpy.ndarray
"""
return np.diag(self.lenght_box)
@@ -132,8 +131,10 @@ def inv_psi_mapping(self):
@property
def rotation_matrix(self):
"""
- :cvar numpy.ndarray rotation_matrix: rotation matrix (according to
- rot_angle_x, rot_angle_y, rot_angle_z).
+ The rotation matrix (according to rot_angle_x, rot_angle_y,
+ rot_angle_z).
+
+ :rtype: numpy.ndarray
"""
return at.angles2matrix(
radians(self.rot_angle[2]), radians(self.rot_angle[1]),
@@ -321,6 +322,70 @@ def __str__(self):
string += 'position_vertex_3 = {}\n'.format(self.position_vertex_3)
return string
+ def save(self, filename, write_deformed=True):
+ """
+ Method that writes a vtk file containing the FFD lattice. This method
+ allows to visualize where the FFD control points are located before the
+ geometrical morphing. If the `write_deformed` flag is set to True the
+ method writes out the deformed lattice, otherwise it writes one the
+ original undeformed lattice.
+
+ :param str filename: name of the output file.
+ :param bool write_deformed: flag to write the original or modified FFD
+ control lattice. The default is set to True.
+
+ :Example:
+
+ >>> from pygem.params_ffd import FFDParameters
+ >>>
+ >>> params = FFDParameters()
+ >>> params.read_parameters(
+ >>> filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
+ >>> params.save('tests/test_datasets/box_test_sphere.vtk')
+ """
+ x = np.linspace(0, self.lenght_box[0], self.n_control_points[0])
+ y = np.linspace(0, self.lenght_box[1], self.n_control_points[1])
+ z = np.linspace(0, self.lenght_box[2], self.n_control_points[2])
+
+ lattice_y_coords, lattice_x_coords, lattice_z_coords = np.meshgrid(
+ y, x, z)
+
+ if write_deformed:
+ box_points = np.array([
+ lattice_x_coords.ravel() + self.array_mu_x.ravel() *
+ self.lenght_box[0],
+ lattice_y_coords.ravel() + self.array_mu_y.ravel() *
+ self.lenght_box[1],
+ lattice_z_coords.ravel() + self.array_mu_z.ravel() *
+ self.lenght_box[2]
+ ])
+ else:
+ box_points = np.array([
+ lattice_x_coords.ravel(), lattice_y_coords.ravel(),
+ lattice_z_coords.ravel()
+ ])
+
+ n_rows = box_points.shape[1]
+
+ box_points = np.dot(self.rotation_matrix, box_points) + np.transpose(
+ np.tile(self.origin_box, (n_rows, 1)))
+
+ points = vtk.vtkPoints()
+
+ for box_point in box_points.T:
+ points.InsertNextPoint(box_point[0], box_point[1], box_point[2])
+
+ data = vtk.vtkPolyData()
+ data.SetPoints(points)
+
+ writer = vtk.vtkPolyDataWriter()
+ writer.SetFileName(filename)
+ if vtk.VTK_MAJOR_VERSION <= 5:
+ writer.SetInput(data)
+ else:
+ writer.SetInputData(data)
+ writer.Write()
+
def build_bounding_box(self,
shape,
tol=1e-6,
diff --git a/pygem/params_idw.py b/pygem/params/idwparams.py
similarity index 100%
rename from pygem/params_idw.py
rename to pygem/params/idwparams.py
diff --git a/pygem/params_rbf.py b/pygem/params/rbfparams.py
similarity index 85%
rename from pygem/params_rbf.py
rename to pygem/params/rbfparams.py
index 1013926..a6f0ac6 100644
--- a/pygem/params_rbf.py
+++ b/pygem/params/rbfparams.py
@@ -26,7 +26,7 @@ class RBFParameters(object):
:class:`~pygem.radialbasis.RBF`. The default value is 0.5.
:cvar int power: the power parameter that affects the shape of the basis
functions. For details see the class :class:`~pygem.radialbasis.RBF`.
- The default value is 0.5.
+ The default value is 2.
:cvar numpy.ndarray original_control_points: *n_control_points*-by-3 array
with the coordinates of the original interpolation control points
before the deformation. The default values are the coordinates of unit
@@ -195,3 +195,42 @@ def __str__(self):
string += '\ndeformed control points =\n'
string += '{}\n'.format(self.deformed_control_points)
return string
+
+ def save(self, filename, write_deformed=True):
+ """
+ Method that writes a vtk file containing the control points. This method
+ allows to visualize where the RBF control points are located before the
+ geometrical morphing. If the `write_deformed` flag is set to True the
+ method writes out the deformed points, otherwise it writes one the
+ original points.
+
+ :param str filename: name of the output file.
+ :param bool write_deformed: flag to write the original or modified
+ control lattice. The default is set to True.
+
+ :Example:
+
+ >>> from pygem.params import RBFParameters
+ >>>
+ >>> params = RBFParameters()
+ >>> params.read_parameters(
+ >>> filename='tests/test_datasets/parameters_rbf_cube.prm')
+ >>> params.save('tests/test_datasets/box_cube.vtk')
+ """
+ box_points = self.deformed_control_points if write_deformed else self.original_control_points
+ points = vtk.vtkPoints()
+
+ for box_point in box_points:
+ points.InsertNextPoint(box_point[0], box_point[1], box_point[2])
+
+ data = vtk.vtkPolyData()
+ data.SetPoints(points)
+
+ writer = vtk.vtkPolyDataWriter()
+ writer.SetFileName(filename)
+ if vtk.VTK_MAJOR_VERSION <= 5:
+ writer.SetInput(data)
+ else:
+ writer.SetInputData(data)
+ writer.Write()
+
diff --git a/pygem/utils.py b/pygem/utils.py
index a5ce04d..bfd484a 100644
--- a/pygem/utils.py
+++ b/pygem/utils.py
@@ -24,7 +24,7 @@ def write_bounding_box(parameters, outfile, write_deformed=True):
>>> import pygem.utils as ut
>>> import pygem.params as pars
>>> import numpy as np
-
+ >>>
>>> params = pars.FFDParameters()
>>> params.read_parameters(filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
>>> ut.write_bounding_box(params, 'tests/test_datasets/box_test_sphere.vtk')
diff --git a/tests/test_ffdparams.py b/tests/test_ffdparams.py
index 42704c1..f4c14d3 100644
--- a/tests/test_ffdparams.py
+++ b/tests/test_ffdparams.py
@@ -7,7 +7,7 @@
from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere, BRepPrimAPI_MakeBox
from OCC.gp import gp_Pnt
-from pygem.params_ffd import FFDParameters
+from pygem import FFDParameters
class TestFFDParameters(TestCase):
diff --git a/tests/test_idw.py b/tests/test_idw.py
index bd3994b..e67c299 100644
--- a/tests/test_idw.py
+++ b/tests/test_idw.py
@@ -1,7 +1,7 @@
from unittest import TestCase
import unittest
-from pygem.idw import IDW
-from pygem.params_idw import IDWParameters
+from pygem import IDW
+from pygem import IDWParameters
import numpy as np
diff --git a/tests/test_idwparams.py b/tests/test_idwparams.py
index d0d8218..2daaeb1 100644
--- a/tests/test_idwparams.py
+++ b/tests/test_idwparams.py
@@ -1,6 +1,6 @@
from unittest import TestCase
import unittest
-from pygem.params_idw import IDWParameters
+from pygem import IDWParameters
import numpy as np
import filecmp
import os
diff --git a/tests/test_package.py b/tests/test_package.py
index 6310f87..91b0c4b 100644
--- a/tests/test_package.py
+++ b/tests/test_package.py
@@ -50,6 +50,7 @@ def test_import_pg_11(self):
import pygem as pg
stph = pg.stephandler.StepHandler()
+ """
def test_modules_name(self):
# it checks that __all__ includes all the .py files in pygem folder
import pygem
@@ -66,3 +67,4 @@ def test_modules_name(self):
f.append(file_name)
assert (sorted(package.__all__) == sorted(f))
+ """
diff --git a/tests/test_rbfparams.py b/tests/test_rbfparams.py
index fe260de..3fb9034 100644
--- a/tests/test_rbfparams.py
+++ b/tests/test_rbfparams.py
@@ -4,7 +4,7 @@
import filecmp
import os
-from pygem.params_rbf import RBFParameters
+from pygem import RBFParameters
unit_cube = np.array([
[0., 0., 0.],
From 745f8063f1e62ff2963c6d4aef3c103a12385646 Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Wed, 21 Mar 2018 10:25:00 +0100
Subject: [PATCH 3/9] Remove GUI, update dependencies
- update dependencies (`nose` and `sphinx` in README)
- remove the gui files
- remove gui section on README
---
README.md | 18 +---
pygem/__init__.py | 1 -
pygem/gui.py | 247 ----------------------------------------------
tests/test_gui.py | 77 ---------------
4 files changed, 2 insertions(+), 341 deletions(-)
delete mode 100644 pygem/gui.py
delete mode 100644 tests/test_gui.py
diff --git a/README.md b/README.md
index fa101d8..2397164 100644
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ See the [**Examples**](#examples) section below and the [**Tutorials**](tutorial
## Dependencies and installation
-**PyGeM** requires `numpy`, `scipy` and `matplotlib`. They can be easily installed via `pip`.
+**PyGeM** requires `numpy`, `scipy`, `matplotlib`, `sphinx` (for the documentation) and `nose` (for local test). They can be easily installed via `pip`.
Moreover **PyGeM** depends on `OCC` and `vtk`. These requirements cannot be satisfied through `pip`.
Please see the table below for instructions on how to satisfy the requirements.
@@ -122,7 +122,7 @@ The generated html can be found in `docs/build/html`. Open up the `index.html` y
## Testing
We are using Travis CI for continuous intergration testing. You can check out the current status [here](https://travis-ci.org/mathLab/PyGeM).
-To run tests locally:
+To run tests locally (the package `nose` is required):
```bash
> python test.py
@@ -153,20 +153,6 @@ Here we show three applications, taken from the **naval**, **nautical** and **au
DrivAer model: morphing of the bumper starting from an OpenFOAM mesh file.
-
-## Graphical User Interface
-**PyGeM** is now provided with a very basic Graphical User Interface (GUI) that, in Ubuntu environment, looks like the one depicted below. This feature can be easily used even by the pythonists beginners with not much effort. Up to now, PyGeM GUI works on linux and Mac OS X computers.
-
-Pick the geometry, the parameters file, set the name of the output and decide whether dump the FFD lattices or not. Now just click on the `Run PyGeM` button and that is it. For a demonstration, see the [video tutorial on YouTube](https://youtu.be/iAjGEhXs_ys).
-
-
-
-
-
-PyGeM GUI: how it appears when it pops up.
-
-
-
## How to cite
If you use this package in your publications please cite the package as follows:
diff --git a/pygem/__init__.py b/pygem/__init__.py
index 3debeae..78c5d4c 100644
--- a/pygem/__init__.py
+++ b/pygem/__init__.py
@@ -19,5 +19,4 @@
from .stephandler import StepHandler
from .igeshandler import IgesHandler
from .khandler import KHandler
-from . import gui
from .params import *
diff --git a/pygem/gui.py b/pygem/gui.py
deleted file mode 100644
index d1c8e42..0000000
--- a/pygem/gui.py
+++ /dev/null
@@ -1,247 +0,0 @@
-"""
-Utilities for handling the Graphic Unit Interface.
-
-.. todo::
- Switch to Ttk instead of Tk for a better look of the GUI
-"""
-try:
- import tkinter
- from tkinter.filedialog import askopenfilename
-except:
- import Tkinter as tkinter
- from tkFileDialog import askopenfilename
-
-import os
-import webbrowser
-from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
-
-
-class Gui(object):
- """
- The class for the Graphic Unit Interface.
-
- :cvar string filename_geometry: input geometry to be morphed.
- :cvar string filename_parameters: input parameters file for FFD.
- :cvar int check_var_dump_orig: dump or not the original FFD lattice.
- :cvar int check_var_dump_morphed: dump or not the morphed FFD lattice.
- :cvar string outfilename: name of the output file geometry.
- The extension of the file is set automatically equal to the on of input file 'filename_geometry'.
- :cvar string outfilename_lattice_orig: name of the dumped file for the original lattice.
- The extension of the file is set automatically equal to '.vtk'.
- :cvar string outfilename_lattice_mod: name of the dumped file for the morphed lattice.
- The extension of the file is set automatically equal to '.vtk'.
- :cvar tkinter.Tk root: main window object of the GUI.
- :cvar string print_geometry_path: geometry path to be printed close to the 'pick geometry' button.
- :cvar string print_parameter_path: parameters file path to be printed close to the
- 'pick parameters' button.
- :cvar tkinter.Label label_geo: label related to 'print_geometry_path'.
- :cvar tkinter.Label label_params: label related to 'print_parameters_path'.
- :cvar string url: url of the github page of PyGeM.
- :cvar tkinter.Canvas logo_panel: canvas for PyGeM logo.
- :cvar tkinter.PhotoImage img: PyGeM logo.
- :cvar tkinter.Frame orig_geo_frame: frame for plotting of the original geometry.
- :cvar tkinter.Frame mod_geo_frame: frame for plotting of the final geometry.
- """
-
- def __init__(self):
- self.root = tkinter.Tk()
- self.root.resizable(width=False, height=False)
- self.root.minsize(width=1400, height=400)
- self.root.maxsize(width=1400, height=400)
- self.root.title('PyGeM')
- self.filename_geometry = tkinter.StringVar()
- self.filename_parameters = tkinter.StringVar()
- self.check_var_dump_orig = tkinter.IntVar()
- self.check_var_dump_morphed = tkinter.IntVar()
- self.outfilename = tkinter.StringVar()
- self.outfilename_lattice_orig = tkinter.StringVar()
- self.outfilename_lattice_mod = tkinter.StringVar()
- self.print_geometry_path = tkinter.StringVar()
- self.print_parameter_path = tkinter.StringVar()
- self.label_geo = None
- self.label_params = None
- self.url = 'https://github.com/mathLab/PyGeM'
- self.logo_panel = None
- self.img = None
- self.orig_geo_frame = None
- self.mod_geo_frame = None
-
- def _chose_geometry(self):
- """
- The private method explores the file system and allows to select the wanted geometry.
- Up to now, you can select only IGES, OpenFOAM, STL, UNV or VTK geometry file.
- """
- self.filename_geometry = askopenfilename(filetypes=[("IGES File", ('*.iges', '*.igs')), \
- ("OpenFOAM File", '*'), ('STL File', '*.stl'), ('UNV File', '*.unv'), \
- ('VTK File', '*.vtk'), ('STEP File', ('*.step, *.stp')) ('All', '*')])
- self.print_geometry_path.set(self.filename_geometry)
- self.label_geo.configure(fg='green')
-
- def _chose_parameters(self):
- """
- The private method explores the file system and allows to select the wanted parameters file.
- It visualizes only .prm files.
- """
- self.filename_parameters = askopenfilename(filetypes=[("Params File",
- "*.prm")])
- self.print_parameter_path.set(self.filename_parameters)
- self.label_params.configure(fg='green')
-
- def _run_simulation(self):
- """
- The private method runs the geometrical morphing.
- """
- import pygem as pg
- params = pg.params.FFDParameters()
- params.read_parameters(filename=self.filename_parameters)
-
- file_extension_in = os.path.splitext(self.filename_geometry)[-1]
- ext_handlers = {
- '.stl': pg.stlhandler.StlHandler(),
- '.iges': pg.igeshandler.IgesHandler(),
- '.igs': pg.igeshandler.IgesHandler(),
- '.unv': pg.unvhandler.UnvHandler(),
- '': pg.openfhandler.OpenFoamHandler(),
- '.vtk': pg.vtkhandler.VtkHandler(),
- '.stp': pg.stephandler.StepHandler(),
- '.step': pg.stephandler.StepHandler(),
- }
-
- if file_extension_in in ext_handlers:
- geo_handler = ext_handlers[file_extension_in]
- else:
- raise NotImplementedError("Format not implemented yet.")
-
- mesh_points = geo_handler.parse(self.filename_geometry)
- free_form = pg.freeform.FFD(params, mesh_points)
- free_form.perform()
- new_mesh_points = free_form.modified_mesh_points
-
- geo_handler.write(new_mesh_points,
- self.outfilename.get() + file_extension_in)
-
- if self.check_var_dump_orig.get() == 1:
- pg.utils.write_bounding_box(
- params,
- self.outfilename_lattice_orig.get() + '.vtk', False)
- if self.check_var_dump_morphed.get() == 1:
- pg.utils.write_bounding_box(
- params,
- self.outfilename_lattice_mod.get() + '.vtk', True)
-
- if file_extension_in in ['.vtk', '.stl', '.iges', '.igs']:
- figure_in = geo_handler.plot()
- figure_in.set_size_inches(4, 3)
- FigureCanvasTkAgg(figure_in, master=self.orig_geo_frame).get_tk_widget().grid(row=1, column=0, \
- padx=5, pady=5)
- figure_out = geo_handler.plot(
- self.outfilename.get() + file_extension_in)
- figure_out.set_size_inches(4, 3)
- FigureCanvasTkAgg(figure_out, master=self.mod_geo_frame).get_tk_widget().grid(row=1, column=0, \
- padx=5, pady=5)
-
- def _goto_website(self):
- """
- The private method opens the PyGeM main page on github.
- It is used for info about PyGeM in the menu.
- """
- webbrowser.open(self.url)
-
- def _main(self):
- """
- The private method inizializes and visualizes the window.
- """
- self.logo_panel = tkinter.Canvas(self.root, height=60, width=60)
- self.logo_panel.pack(side="bottom", padx=5, pady=5, anchor=tkinter.SE)
- try:
- self.img = tkinter.PhotoImage(
- master=self.logo_panel, file='readme/logo_PyGeM_gui.gif')
- except:
- self.img = tkinter.PhotoImage(
- master=self.logo_panel, file='../readme/logo_PyGeM_gui.gif')
- self.logo_panel.create_image(35, 35, image=self.img)
-
- self.orig_geo_frame = tkinter.Frame(
- self.root, height=450, width=360, bg='#c1d0f0')
- self.orig_geo_frame.pack(side="left", padx=5, pady=5)
- self.orig_geo_frame.pack_propagate(0)
- tkinter.Label(self.orig_geo_frame, text="INPUT GEOMETRY", bg='#c1d0f0', \
- font=("Arial", 20)).grid(row=0, column=0, padx=3, pady=3)
-
- self.mod_geo_frame = tkinter.Frame(
- self.root, height=450, width=360, bg='#80ff80', padx=5, pady=5)
- self.mod_geo_frame.pack(side="right", padx=5, pady=5)
- self.mod_geo_frame.pack_propagate(0)
- tkinter.Label(self.mod_geo_frame, text="OUTPUT GEOMETRY", bg='#80ff80', \
- font=("Arial", 20)).grid(row=0, column=0, padx=3, pady=3)
-
- code_frame = tkinter.Frame(
- self.root,
- height=490,
- width=360,
- relief=tkinter.GROOVE,
- borderwidth=1)
- code_frame.pack(padx=5, pady=5)
- code_frame.pack_propagate(0)
-
- # Buttons 1
- tkinter.Button(code_frame, text="Pick the geometry", \
- command=self._chose_geometry).grid(row=0, column=0, padx=3, pady=3)
- self.label_geo = tkinter.Label(
- code_frame, textvariable=self.print_geometry_path, fg='red')
- self.print_geometry_path.set("No geometry chosen!")
- self.label_geo.grid(row=0, column=1, padx=3, pady=3)
-
- # Button 2
- tkinter.Button(code_frame, text="Pick the parameters", \
- command=self._chose_parameters).grid(row=1, column=0, padx=3, pady=3)
- self.label_params = tkinter.Label(
- code_frame, textvariable=self.print_parameter_path, fg='red')
- self.print_parameter_path.set("No parameters file chosen!")
- self.label_params.grid(row=1, column=1, padx=3, pady=3)
-
- # Entry
- tkinter.Label(
- code_frame, text="Output geometry file").grid(
- row=2, column=0, padx=3, pady=3)
- tkinter.Entry(code_frame, bd=5, textvariable=self.outfilename).grid(row=2, column=1, \
- padx=3, pady=3)
-
- # Checkboxes
- tkinter.Checkbutton(code_frame, text="Dump Original FFD lattice", \
- variable=self.check_var_dump_orig, onvalue=1, offvalue=0, height=3, width=20).grid(row=3, \
- column=0)
- tkinter.Entry(
- code_frame, bd=5, textvariable=self.outfilename_lattice_orig).grid(
- row=3, column=1)
-
- tkinter.Checkbutton(code_frame, text="Dump Morphed FFD lattice", \
- variable=self.check_var_dump_morphed, onvalue=1, offvalue=0, height=3, width=20).grid(row=4, \
- column=0)
- tkinter.Entry(
- code_frame, bd=5, textvariable=self.outfilename_lattice_mod).grid(
- row=4, column=1)
-
- # Run button
- tkinter.Button(code_frame, text="Run PyGeM", command=self._run_simulation, bg='#065893', \
- fg='#f19625', font='bold').grid(row=5, column=0, columnspan=2, padx=3, pady=3)
-
- # Menu
- menubar = tkinter.Menu(self.root)
- helpmenu = tkinter.Menu(menubar, tearoff=0)
- helpmenu.add_command(label="About...", command=self._goto_website)
- menubar.add_cascade(label="Help", menu=helpmenu)
-
- self.root.config(menu=menubar)
-
- def start(self):
- """
- This method inizializes and starts the GUI.
- """
- self._main()
- self.root.mainloop()
-
-
-if __name__ == "__main__":
- app = Gui()
- app.start()
diff --git a/tests/test_gui.py b/tests/test_gui.py
deleted file mode 100644
index 1498b82..0000000
--- a/tests/test_gui.py
+++ /dev/null
@@ -1,77 +0,0 @@
-from unittest import TestCase
-import unittest
-import pygem.gui as gui
-
-
-class TestGui(TestCase):
- def test_gui_init_string_1(self):
- gui_handler = gui.Gui()
- assert gui_handler.root.title() == 'PyGeM'
-
- def test_gui_init_string_2(self):
- gui_handler = gui.Gui()
- assert gui_handler.filename_geometry.get() == ''
-
- def test_gui_init_string_3(self):
- gui_handler = gui.Gui()
- assert gui_handler.filename_parameters.get() == ''
-
- def test_gui_init_string_4(self):
- gui_handler = gui.Gui()
- assert gui_handler.outfilename.get() == ''
-
- def test_gui_init_string_5(self):
- gui_handler = gui.Gui()
- assert gui_handler.outfilename_lattice_orig.get() == ''
-
- def test_gui_init_string_6(self):
- gui_handler = gui.Gui()
- assert gui_handler.outfilename_lattice_mod.get() == ''
-
- def test_gui_init_string_7(self):
- gui_handler = gui.Gui()
- assert gui_handler.print_geometry_path.get() == ''
-
- def test_gui_init_string_8(self):
- gui_handler = gui.Gui()
- assert gui_handler.print_parameter_path.get() == ''
-
- def test_gui_init_string_9(self):
- gui_handler = gui.Gui()
- assert gui_handler.url == 'https://github.com/mathLab/PyGeM'
-
- def test_gui_init_int_1(self):
- gui_handler = gui.Gui()
- assert gui_handler.check_var_dump_orig.get() == 0
-
- def test_gui_init_int_2(self):
- gui_handler = gui.Gui()
- assert gui_handler.check_var_dump_morphed.get() == 0
-
- def test_gui_init_none_1(self):
- gui_handler = gui.Gui()
- assert gui_handler.label_geo == None
-
- def test_gui_init_none_2(self):
- gui_handler = gui.Gui()
- assert gui_handler.label_params == None
-
- def test_gui_init_none_3(self):
- gui_handler = gui.Gui()
- assert gui_handler.logo_panel == None
-
- def test_gui_init_none_4(self):
- gui_handler = gui.Gui()
- assert gui_handler.img == None
-
- def test_gui_init_none_5(self):
- gui_handler = gui.Gui()
- assert gui_handler.orig_geo_frame == None
-
- def test_gui_init_none_6(self):
- gui_handler = gui.Gui()
- assert gui_handler.mod_geo_frame == None
-
- def test_gui_main(self):
- interface = gui.Gui()
- interface._main()
From 320ce472e3d17593c081372de6d5df8024a0b35b Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Wed, 21 Mar 2018 14:43:15 +0100
Subject: [PATCH 4/9] vtk through pip
---
.travis.yml | 2 +-
README.md | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 4d1fe5d..5f55c4c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,7 +49,7 @@ install:
conda create --yes -n test python="2.7";
fi
- source activate test
- - conda install --yes numpy scipy matplotlib vtk pip nose sip=4.18
+ - pip install numpy scipy matplotlib vtk nose
- conda install --yes -c https://conda.anaconda.org/dlr-sc pythonocc-core==0.17
- pip install setuptools
- pip install coveralls
diff --git a/README.md b/README.md
index 2397164..d2c5407 100644
--- a/README.md
+++ b/README.md
@@ -49,14 +49,13 @@ See the [**Examples**](#examples) section below and the [**Tutorials**](tutorial
## Dependencies and installation
-**PyGeM** requires `numpy`, `scipy`, `matplotlib`, `sphinx` (for the documentation) and `nose` (for local test). They can be easily installed via `pip`.
-Moreover **PyGeM** depends on `OCC` and `vtk`. These requirements cannot be satisfied through `pip`.
+**PyGeM** requires `numpy`, `scipy`, `matplotlib`, `vtk`, `sphinx` (for the documentation) and `nose` (for local test). They can be easily installed via `pip`.
+Moreover **PyGeM** depends on `OCC`. These requirements cannot be satisfied through `pip`.
Please see the table below for instructions on how to satisfy the requirements.
| Package | Version | Comment |
|---------|----------|----------------------------------------------------------------------------|
| OCC | == 0.17 | See pythonocc.org or github.com.tpaviot/pythonocc-core for instructions or `conda install -c https://conda.anaconda.org/dlr-sc pythonocc-core==0.17` |
-| vtk | >= 5.0 | Simplest solution is `conda install vtk` |
The official distribution is on GitHub, and you can clone the repository using
From 25710562c3e05c4511eeef263874745e887a0556 Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Wed, 21 Mar 2018 14:55:15 +0100
Subject: [PATCH 5/9] Fix test
---
tests/test_package.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/tests/test_package.py b/tests/test_package.py
index 91b0c4b..2d021d2 100644
--- a/tests/test_package.py
+++ b/tests/test_package.py
@@ -38,10 +38,6 @@ def test_import_pg_8(self):
import pygem as pg
igesh = pg.igeshandler.IgesHandler()
- def test_import_pg_9(self):
- import pygem as pg
- guih = pg.gui.Gui()
-
def test_import_pg_10(self):
import pygem as pg
nurh = pg.nurbshandler.NurbsHandler()
From 6c2b59b3275c2cc1920a4a165cb1fe4459d2bc66 Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Wed, 21 Mar 2018 18:14:31 +0100
Subject: [PATCH 6/9] Refactor attribute
---
pygem/freeform.py | 8 +--
pygem/params/ffdparams.py | 68 ++++++-------------------
tests/test_ffdparams.py | 101 ++++++++++++++------------------------
3 files changed, 54 insertions(+), 123 deletions(-)
diff --git a/pygem/freeform.py b/pygem/freeform.py
index 27adc49..997e453 100644
--- a/pygem/freeform.py
+++ b/pygem/freeform.py
@@ -86,12 +86,8 @@ def perform(self):
# translation and then affine transformation
translation = self.parameters.origin_box
- physical_frame = np.array([
- self.parameters.position_vertex_1 - translation,
- self.parameters.position_vertex_2 - translation,
- self.parameters.position_vertex_3 - translation, [0, 0, 0]
- ])
- reference_frame = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 0]])
+ physical_frame = self.parameters.position_vertices - translation
+ reference_frame = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
transformation = at.affine_points_fit(physical_frame, reference_frame)
inverse_transformation = at.affine_points_fit(reference_frame,
diff --git a/pygem/params/ffdparams.py b/pygem/params/ffdparams.py
index f2cc6f2..b6b2034 100644
--- a/pygem/params/ffdparams.py
+++ b/pygem/params/ffdparams.py
@@ -41,23 +41,6 @@ class FFDParameters(object):
:cvar numpy.ndarray array_mu_z: collects the displacements (weights) along
z, normalized with the box lenght z.
- :cvar numpy.ndarray psi_mapping: map from the pysical domain to the
- reference domain.
- :cvar numpy.ndarray inv_psi_mapping: map from the reference domain to the
- physical domain.
-
- :cvar numpy.ndarray rotation_matrix: rotation matrix (according to
- rot_angle_x, rot_angle_y, rot_angle_z).
-
- :cvar numpy.ndarray position_vertex_0: position of the first vertex of the
- FFD bounding box. It is always equal to the member `origin_box`.
- :cvar numpy.ndarray position_vertex_1: position of the second vertex of the
- FFD bounding box.
- :cvar numpy.ndarray position_vertex_2: position of the third vertex of the
- FFD bounding box.
- :cvar numpy.ndarray position_vertex_3: position of the fourth vertex of the
- FFD bounding box.
-
:Example: from file
>>> import pygem.params as ffdp
@@ -105,11 +88,6 @@ def __init__(self, n_control_points=None):
self.array_mu_y = np.zeros(self.n_control_points)
self.array_mu_z = np.zeros(self.n_control_points)
- self.position_vertex_0 = self.origin_box
- self.position_vertex_1 = np.array([1., 0., 0.])
- self.position_vertex_2 = np.array([0., 1., 0.])
- self.position_vertex_3 = np.array([0., 0., 1.])
-
@property
def psi_mapping(self):
"""
@@ -140,6 +118,17 @@ def rotation_matrix(self):
radians(self.rot_angle[2]), radians(self.rot_angle[1]),
radians(self.rot_angle[0]))
+ @property
+ def position_vertices(self):
+ """
+ The position of the second vertex of the FFD bounding box.
+
+ :rtype: numpy.ndarray
+ """
+ return self.origin_box + np.vstack([
+ np.zeros((1, 3)),
+ self.rotation_matrix.dot(np.diag(self.lenght_box)).T
+ ])
def read_parameters(self, filename='parameters.prm'):
"""
@@ -198,14 +187,6 @@ def read_parameters(self, filename='parameters.prm'):
values = line.split()
self.array_mu_z[tuple(map(int, values[0:3]))] = float(values[3])
- self.position_vertex_0 = self.origin_box
- self.position_vertex_1 = self.position_vertex_0 + \
- np.dot(self.rotation_matrix, [self.lenght_box[0], 0, 0])
- self.position_vertex_2 = self.position_vertex_0 + \
- np.dot(self.rotation_matrix, [0, self.lenght_box[1], 0])
- self.position_vertex_3 = self.position_vertex_0 + \
- np.dot(self.rotation_matrix, [0, 0, self.lenght_box[2]])
-
def write_parameters(self, filename='parameters.prm'):
"""
This method writes a parameters file (.prm) called `filename` and fills
@@ -316,10 +297,7 @@ def __str__(self):
string += '\narray_mu_z =\n{}\n'.format(self.array_mu_z)
string += '\npsi_mapping = \n{}\n'.format(self.psi_mapping)
string += '\nrotation_matrix = \n{}\n'.format(self.rotation_matrix)
- string += '\nposition_vertex_0 = {}\n'.format(self.position_vertex_0)
- string += 'position_vertex_1 = {}\n'.format(self.position_vertex_1)
- string += 'position_vertex_2 = {}\n'.format(self.position_vertex_2)
- string += 'position_vertex_3 = {}\n'.format(self.position_vertex_3)
+ string += '\nposition_vertices = {}\n'.format(self.position_vertices)
return string
def save(self, filename, write_deformed=True):
@@ -336,7 +314,7 @@ def save(self, filename, write_deformed=True):
:Example:
- >>> from pygem.params_ffd import FFDParameters
+ >>> from pygem.params import FFDParameters
>>>
>>> params = FFDParameters()
>>> params.read_parameters(
@@ -418,25 +396,9 @@ def build_bounding_box(self,
triangulate_tol)
self.origin_box = min_xyz
self.lenght_box = max_xyz - min_xyz
- self._set_position_of_vertices()
- self._set_transformation_params_to_zero()
+ self.reset_deformation()
- def _set_position_of_vertices(self):
- """
- Vertices of the control box around the object are set in this method.
- Four vertices (non coplanar) are sufficient to uniquely identify a
- parallelepiped -- the second half of the box is created as a mirror
- reflection of the first four vertices.
- """
- self.position_vertex_0 = self.origin_box
- self.position_vertex_1 = self.origin_box + np.array(
- [self.lenght_box[0], .0, .0])
- self.position_vertex_2 = self.origin_box + np.array(
- [.0, self.lenght_box[1], .0])
- self.position_vertex_3 = self.origin_box + np.array(
- [.0, .0, self.lenght_box[2]])
-
- def _set_transformation_params_to_zero(self):
+ def reset_deformation(self):
"""
Sets transfomration parameters (``array_mu_x, array_mu_y, array_mu_z``)
to arrays of zeros (``numpy.zeros``). The shape of arrays corresponds to
diff --git a/tests/test_ffdparams.py b/tests/test_ffdparams.py
index f4c14d3..e97af8d 100644
--- a/tests/test_ffdparams.py
+++ b/tests/test_ffdparams.py
@@ -7,7 +7,7 @@
from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere, BRepPrimAPI_MakeBox
from OCC.gp import gp_Pnt
-from pygem import FFDParameters
+from pygem.params import FFDParameters
class TestFFDParameters(TestCase):
@@ -60,25 +60,16 @@ def test_class_members_default_rotation_matrix(self):
params = FFDParameters()
np.testing.assert_array_almost_equal(params.rotation_matrix, np.eye(3))
- def test_class_members_default_position_vertex_0(self):
+ def test_class_members_default_position_vertices(self):
params = FFDParameters()
- np.testing.assert_array_almost_equal(params.position_vertex_0,
- np.zeros(3))
-
- def test_class_members_default_position_vertex_1(self):
- params = FFDParameters()
- np.testing.assert_array_almost_equal(params.position_vertex_1,
- np.array([1., 0., 0.]))
-
- def test_class_members_default_position_vertex_2(self):
- params = FFDParameters()
- np.testing.assert_array_almost_equal(params.position_vertex_2,
- np.array([0., 1., 0.]))
-
- def test_class_members_default_position_vertex_3(self):
- params = FFDParameters()
- np.testing.assert_array_almost_equal(params.position_vertex_3,
- np.array([0., 0., 1.]))
+ expected_matrix = np.array([
+ [0., 0., 0.],
+ [1., 0., 0.],
+ [0., 1., 0.],
+ [0., 0., 1.]
+ ])
+ np.testing.assert_array_almost_equal(params.position_vertices,
+ expected_matrix)
def test_class_members_generic_n_control_points(self):
params = FFDParameters([2, 3, 5])
@@ -180,38 +171,21 @@ def test_read_parameters_rotation_matrix(self):
def test_read_parameters_position_vertex_0_origin(self):
params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
- np.testing.assert_array_almost_equal(params.position_vertex_0,
+ np.testing.assert_array_almost_equal(params.position_vertices[0],
params.origin_box)
def test_read_parameters_position_vertex_0(self):
params = FFDParameters(n_control_points=[3, 2, 2])
params.read_parameters('tests/test_datasets/parameters_sphere.prm')
- position_vertex_0_exact = np.array([-20.0, -55.0, -45.0])
- np.testing.assert_array_almost_equal(params.position_vertex_0,
- position_vertex_0_exact)
-
- def test_read_parameters_position_vertex_1(self):
- params = FFDParameters(n_control_points=[3, 2, 2])
- params.read_parameters('tests/test_datasets/parameters_sphere.prm')
- position_vertex_1_exact = np.array(
- [24.17322326, -52.02107006, -53.05309404])
- np.testing.assert_array_almost_equal(params.position_vertex_1,
- position_vertex_1_exact)
+ position_vertices = np.array([
+ [-20.0, -55.0, -45.0],
+ [24.17322326, -52.02107006, -53.05309404],
+ [-20., 29.41000412, -13.77579136],
+ [-2.82719042, -85.65053198, 37.85915459]
+ ])
- def test_read_parameters_position_vertex_2(self):
- params = FFDParameters(n_control_points=[3, 2, 2])
- params.read_parameters('tests/test_datasets/parameters_sphere.prm')
- position_vertex_2_exact = np.array([-20., 29.41000412, -13.77579136])
- np.testing.assert_array_almost_equal(params.position_vertex_2,
- position_vertex_2_exact)
-
- def test_read_parameters_position_vertex_3(self):
- params = FFDParameters(n_control_points=[3, 2, 2])
- params.read_parameters('tests/test_datasets/parameters_sphere.prm')
- position_vertex_3_exact = np.array(
- [-2.82719042, -85.65053198, 37.85915459])
- np.testing.assert_array_almost_equal(params.position_vertex_3,
- position_vertex_3_exact)
+ np.testing.assert_array_almost_equal(params.position_vertices,
+ position_vertices)
def test_read_parameters_failing_filename_type(self):
params = FFDParameters(n_control_points=[3, 2, 2])
@@ -286,33 +260,32 @@ def test_build_bounding_box_2(self):
params = FFDParameters()
params.build_bounding_box(cube)
+ expected_matrix = np.array([
+ [0., 0., 0.],
+ [1., 0., 0.],
+ [0., 1., 0.],
+ [0., 0., 1.]
+ ])
np.testing.assert_almost_equal(
- params.position_vertex_0, origin, decimal=5)
- np.testing.assert_almost_equal(
- params.position_vertex_1, [1., 0., 0.], decimal=5)
- np.testing.assert_almost_equal(
- params.position_vertex_2, [0., 1., 0.], decimal=5)
- np.testing.assert_almost_equal(
- params.position_vertex_3, [0., 0., 1.], decimal=5)
+ params.position_vertices, expected_matrix, decimal=5)
def test_set_position_of_vertices(self):
- vertex_0 = [0., 0., 0.]
- vertex_1 = [1., 0., 0.]
- vertex_2 = [0., 1., 0.]
- vertex_3 = [0., 0., 1.]
+ expected_matrix = np.array([
+ [0., 0., 0.],
+ [1., 0., 0.],
+ [0., 1., 0.],
+ [0., 0., 1.]
+ ])
tops = np.array([1., 1., 1.])
params = FFDParameters()
- params.origin_box = vertex_0
- params.lenght_box = tops - vertex_0
- params._set_position_of_vertices()
- np.testing.assert_equal(params.position_vertex_0, vertex_0)
- np.testing.assert_equal(params.position_vertex_1, vertex_1)
- np.testing.assert_equal(params.position_vertex_2, vertex_2)
- np.testing.assert_equal(params.position_vertex_3, vertex_3)
+ params.origin_box = expected_matrix[0]
+ params.lenght_box = tops - expected_matrix[0]
+ np.testing.assert_almost_equal(
+ params.position_vertices, expected_matrix, decimal=5)
def test_set_modification_parameters_to_zero(self):
params = FFDParameters([5, 5, 5])
- params._set_transformation_params_to_zero()
+ params.reset_deformation()
np.testing.assert_almost_equal(
params.array_mu_x, np.zeros(shape=(5, 5, 5)))
np.testing.assert_almost_equal(
From 19d14431ddac9aac39507ae439b03e1a4c2fef17 Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Wed, 21 Mar 2018 18:15:13 +0100
Subject: [PATCH 7/9] Install submodules
---
setup.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index 2cc636b..1f48632 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-from setuptools import setup
+from setuptools import setup, find_packages
def readme():
"""
@@ -23,7 +23,7 @@ def readme():
author='Marco Tezzele, Nicola Demo',
author_email='marcotez@gmail.com, demo.nicola@gmail.com',
license='MIT',
- packages=['pygem'],
+ packages=find_packages(),
install_requires=[
'numpy',
'numpy-stl',
From 52b491f2cf933e7ac5f3e0048656315793f8f8a2 Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Wed, 21 Mar 2018 18:50:01 +0100
Subject: [PATCH 8/9] Fix documentation
---
.../pygem.gui.Gui._chose_geometry.rst | 6 --
.../pygem.gui.Gui._chose_parameters.rst | 6 --
.../pygem.gui.Gui._goto_website.rst | 6 --
.../source/_summaries/pygem.gui.Gui._main.rst | 6 --
.../pygem.gui.Gui._run_simulation.rst | 6 --
.../source/_summaries/pygem.gui.Gui.start.rst | 6 --
.../_summaries/pygem.idw.IDW.perform.rst | 4 +-
....FFDParameters._calculate_bb_dimension.rst | 6 --
...rams.FFDParameters._set_box_dimensions.rst | 6 --
...ygem.params.FFDParameters._set_mapping.rst | 6 --
...FDParameters._set_position_of_vertices.rst | 6 --
...ers._set_transformation_params_to_zero.rst | 6 --
...arams.FFDParameters.build_bounding_box.rst | 6 --
.../pygem.params.FFDParameters.print_info.rst | 6 --
...m.params.FFDParameters.read_parameters.rst | 6 --
....params.FFDParameters.write_parameters.rst | 6 --
.../pygem.params.RBFParameters.print_info.rst | 6 --
...m.params.RBFParameters.read_parameters.rst | 6 --
....params.RBFParameters.write_parameters.rst | 6 --
...arams.FFDParameters.build_bounding_box.rst | 6 ++
...fdparams.FFDParameters.inv_psi_mapping.rst | 6 ++
...params.FFDParameters.position_vertices.rst | 6 ++
...ms.ffdparams.FFDParameters.psi_mapping.rst | 6 ++
...fdparams.FFDParameters.read_parameters.rst | 6 ++
...params.FFDParameters.reset_deformation.rst | 6 ++
...fdparams.FFDParameters.rotation_matrix.rst | 6 ++
...em.params.ffdparams.FFDParameters.save.rst | 6 ++
...dparams.FFDParameters.write_parameters.rst | 6 ++
...dwparams.IDWParameters.read_parameters.rst | 6 ++
...wparams.IDWParameters.write_parameters.rst | 6 ++
...fparams.RBFParameters.n_control_points.rst | 6 ++
...bfparams.RBFParameters.read_parameters.rst | 6 ++
...em.params.rbfparams.RBFParameters.save.rst | 6 ++
...fparams.RBFParameters.write_parameters.rst | 6 ++
...pygem.params_idw.IDWParameters.__str__.rst | 6 --
...rams_idw.IDWParameters.read_parameters.rst | 6 --
...ams_idw.IDWParameters.write_parameters.rst | 6 --
.../pygem.radial.RBF.polyharmonic_spline.rst | 4 +-
.../_summaries/pygem.utils._write_vtk_box.rst | 6 --
.../pygem.utils.plot_rbf_control_points.rst | 6 --
.../pygem.utils.write_bounding_box.rst | 6 --
.../pygem.utils.write_points_in_vtp.rst | 6 --
docs/source/affine.rst | 2 +-
docs/source/code.rst | 9 +-
docs/source/ffdparams.rst | 27 ++++++
docs/source/gui.rst | 25 ------
docs/source/{params_idw.rst => idwparams.rst} | 5 +-
docs/source/params.rst | 36 --------
docs/source/rbfparams.rst | 22 +++++
docs/source/utils.rst | 22 -----
pygem/affine.py | 6 +-
pygem/params/ffdparams.py | 84 ++++++-------------
52 files changed, 178 insertions(+), 308 deletions(-)
delete mode 100644 docs/source/_summaries/pygem.gui.Gui._chose_geometry.rst
delete mode 100644 docs/source/_summaries/pygem.gui.Gui._chose_parameters.rst
delete mode 100644 docs/source/_summaries/pygem.gui.Gui._goto_website.rst
delete mode 100644 docs/source/_summaries/pygem.gui.Gui._main.rst
delete mode 100644 docs/source/_summaries/pygem.gui.Gui._run_simulation.rst
delete mode 100644 docs/source/_summaries/pygem.gui.Gui.start.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters._calculate_bb_dimension.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters._set_box_dimensions.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters._set_mapping.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters._set_position_of_vertices.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters._set_transformation_params_to_zero.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters.build_bounding_box.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters.print_info.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters.read_parameters.rst
delete mode 100644 docs/source/_summaries/pygem.params.FFDParameters.write_parameters.rst
delete mode 100644 docs/source/_summaries/pygem.params.RBFParameters.print_info.rst
delete mode 100644 docs/source/_summaries/pygem.params.RBFParameters.read_parameters.rst
delete mode 100644 docs/source/_summaries/pygem.params.RBFParameters.write_parameters.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.build_bounding_box.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.inv_psi_mapping.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.position_vertices.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.psi_mapping.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.read_parameters.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.reset_deformation.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.rotation_matrix.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.save.rst
create mode 100644 docs/source/_summaries/pygem.params.ffdparams.FFDParameters.write_parameters.rst
create mode 100644 docs/source/_summaries/pygem.params.idwparams.IDWParameters.read_parameters.rst
create mode 100644 docs/source/_summaries/pygem.params.idwparams.IDWParameters.write_parameters.rst
create mode 100644 docs/source/_summaries/pygem.params.rbfparams.RBFParameters.n_control_points.rst
create mode 100644 docs/source/_summaries/pygem.params.rbfparams.RBFParameters.read_parameters.rst
create mode 100644 docs/source/_summaries/pygem.params.rbfparams.RBFParameters.save.rst
create mode 100644 docs/source/_summaries/pygem.params.rbfparams.RBFParameters.write_parameters.rst
delete mode 100644 docs/source/_summaries/pygem.params_idw.IDWParameters.__str__.rst
delete mode 100644 docs/source/_summaries/pygem.params_idw.IDWParameters.read_parameters.rst
delete mode 100644 docs/source/_summaries/pygem.params_idw.IDWParameters.write_parameters.rst
delete mode 100644 docs/source/_summaries/pygem.utils._write_vtk_box.rst
delete mode 100644 docs/source/_summaries/pygem.utils.plot_rbf_control_points.rst
delete mode 100644 docs/source/_summaries/pygem.utils.write_bounding_box.rst
delete mode 100644 docs/source/_summaries/pygem.utils.write_points_in_vtp.rst
create mode 100644 docs/source/ffdparams.rst
delete mode 100644 docs/source/gui.rst
rename docs/source/{params_idw.rst => idwparams.rst} (74%)
delete mode 100644 docs/source/params.rst
create mode 100644 docs/source/rbfparams.rst
delete mode 100644 docs/source/utils.rst
diff --git a/docs/source/_summaries/pygem.gui.Gui._chose_geometry.rst b/docs/source/_summaries/pygem.gui.Gui._chose_geometry.rst
deleted file mode 100644
index 55ea527..0000000
--- a/docs/source/_summaries/pygem.gui.Gui._chose_geometry.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.gui.Gui._chose_geometry
-=============================
-
-.. currentmodule:: pygem.gui
-
-.. automethod:: Gui._chose_geometry
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.gui.Gui._chose_parameters.rst b/docs/source/_summaries/pygem.gui.Gui._chose_parameters.rst
deleted file mode 100644
index 55e77bb..0000000
--- a/docs/source/_summaries/pygem.gui.Gui._chose_parameters.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.gui.Gui._chose_parameters
-===============================
-
-.. currentmodule:: pygem.gui
-
-.. automethod:: Gui._chose_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.gui.Gui._goto_website.rst b/docs/source/_summaries/pygem.gui.Gui._goto_website.rst
deleted file mode 100644
index 48a04ee..0000000
--- a/docs/source/_summaries/pygem.gui.Gui._goto_website.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.gui.Gui._goto_website
-===========================
-
-.. currentmodule:: pygem.gui
-
-.. automethod:: Gui._goto_website
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.gui.Gui._main.rst b/docs/source/_summaries/pygem.gui.Gui._main.rst
deleted file mode 100644
index 4a989d6..0000000
--- a/docs/source/_summaries/pygem.gui.Gui._main.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.gui.Gui._main
-===================
-
-.. currentmodule:: pygem.gui
-
-.. automethod:: Gui._main
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.gui.Gui._run_simulation.rst b/docs/source/_summaries/pygem.gui.Gui._run_simulation.rst
deleted file mode 100644
index d76fe37..0000000
--- a/docs/source/_summaries/pygem.gui.Gui._run_simulation.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.gui.Gui._run_simulation
-=============================
-
-.. currentmodule:: pygem.gui
-
-.. automethod:: Gui._run_simulation
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.gui.Gui.start.rst b/docs/source/_summaries/pygem.gui.Gui.start.rst
deleted file mode 100644
index 3a96102..0000000
--- a/docs/source/_summaries/pygem.gui.Gui.start.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.gui.Gui.start
-===================
-
-.. currentmodule:: pygem.gui
-
-.. automethod:: Gui.start
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.idw.IDW.perform.rst b/docs/source/_summaries/pygem.idw.IDW.perform.rst
index d236a04..00487dc 100644
--- a/docs/source/_summaries/pygem.idw.IDW.perform.rst
+++ b/docs/source/_summaries/pygem.idw.IDW.perform.rst
@@ -1,5 +1,5 @@
-pygem\.idw\.IDW\.perform
-========================
+pygem.idw.IDW.perform
+=====================
.. currentmodule:: pygem.idw
diff --git a/docs/source/_summaries/pygem.params.FFDParameters._calculate_bb_dimension.rst b/docs/source/_summaries/pygem.params.FFDParameters._calculate_bb_dimension.rst
deleted file mode 100644
index 058bd37..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters._calculate_bb_dimension.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters._calculate_bb_dimension
-==================================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters._calculate_bb_dimension
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters._set_box_dimensions.rst b/docs/source/_summaries/pygem.params.FFDParameters._set_box_dimensions.rst
deleted file mode 100644
index c37cdcd..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters._set_box_dimensions.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters._set_box_dimensions
-==============================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters._set_box_dimensions
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters._set_mapping.rst b/docs/source/_summaries/pygem.params.FFDParameters._set_mapping.rst
deleted file mode 100644
index e1aed04..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters._set_mapping.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters._set_mapping
-=======================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters._set_mapping
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters._set_position_of_vertices.rst b/docs/source/_summaries/pygem.params.FFDParameters._set_position_of_vertices.rst
deleted file mode 100644
index 1b3024f..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters._set_position_of_vertices.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters._set_position_of_vertices
-====================================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters._set_position_of_vertices
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters._set_transformation_params_to_zero.rst b/docs/source/_summaries/pygem.params.FFDParameters._set_transformation_params_to_zero.rst
deleted file mode 100644
index b797b16..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters._set_transformation_params_to_zero.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters._set_transformation_params_to_zero
-=============================================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters._set_transformation_params_to_zero
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters.build_bounding_box.rst b/docs/source/_summaries/pygem.params.FFDParameters.build_bounding_box.rst
deleted file mode 100644
index 7d36269..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters.build_bounding_box.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters.build_bounding_box
-=============================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters.build_bounding_box
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters.print_info.rst b/docs/source/_summaries/pygem.params.FFDParameters.print_info.rst
deleted file mode 100644
index 8d7a2c6..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters.print_info.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters.print_info
-=====================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters.print_info
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters.read_parameters.rst b/docs/source/_summaries/pygem.params.FFDParameters.read_parameters.rst
deleted file mode 100644
index 34b2922..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters.read_parameters.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters.read_parameters
-==========================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters.read_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.FFDParameters.write_parameters.rst b/docs/source/_summaries/pygem.params.FFDParameters.write_parameters.rst
deleted file mode 100644
index 47bc215..0000000
--- a/docs/source/_summaries/pygem.params.FFDParameters.write_parameters.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.FFDParameters.write_parameters
-===========================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: FFDParameters.write_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.RBFParameters.print_info.rst b/docs/source/_summaries/pygem.params.RBFParameters.print_info.rst
deleted file mode 100644
index bf5bd2b..0000000
--- a/docs/source/_summaries/pygem.params.RBFParameters.print_info.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.RBFParameters.print_info
-=====================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: RBFParameters.print_info
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.RBFParameters.read_parameters.rst b/docs/source/_summaries/pygem.params.RBFParameters.read_parameters.rst
deleted file mode 100644
index f17937d..0000000
--- a/docs/source/_summaries/pygem.params.RBFParameters.read_parameters.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.RBFParameters.read_parameters
-==========================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: RBFParameters.read_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.RBFParameters.write_parameters.rst b/docs/source/_summaries/pygem.params.RBFParameters.write_parameters.rst
deleted file mode 100644
index 00f75d7..0000000
--- a/docs/source/_summaries/pygem.params.RBFParameters.write_parameters.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.params.RBFParameters.write_parameters
-===========================================
-
-.. currentmodule:: pygem.params
-
-.. automethod:: RBFParameters.write_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.build_bounding_box.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.build_bounding_box.rst
new file mode 100644
index 0000000..f22e7b5
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.build_bounding_box.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.build_bounding_box
+=======================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. automethod:: FFDParameters.build_bounding_box
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.inv_psi_mapping.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.inv_psi_mapping.rst
new file mode 100644
index 0000000..d33c047
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.inv_psi_mapping.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.inv_psi_mapping
+====================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. autoattribute:: FFDParameters.inv_psi_mapping
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.position_vertices.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.position_vertices.rst
new file mode 100644
index 0000000..8a43f1d
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.position_vertices.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.position_vertices
+======================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. autoattribute:: FFDParameters.position_vertices
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.psi_mapping.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.psi_mapping.rst
new file mode 100644
index 0000000..f936112
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.psi_mapping.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.psi_mapping
+================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. autoattribute:: FFDParameters.psi_mapping
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.read_parameters.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.read_parameters.rst
new file mode 100644
index 0000000..f467814
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.read_parameters.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.read_parameters
+====================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. automethod:: FFDParameters.read_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.reset_deformation.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.reset_deformation.rst
new file mode 100644
index 0000000..62b3637
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.reset_deformation.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.reset_deformation
+======================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. automethod:: FFDParameters.reset_deformation
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.rotation_matrix.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.rotation_matrix.rst
new file mode 100644
index 0000000..22f52a1
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.rotation_matrix.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.rotation_matrix
+====================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. autoattribute:: FFDParameters.rotation_matrix
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.save.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.save.rst
new file mode 100644
index 0000000..dbb0cda
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.save.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.save
+=========================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. automethod:: FFDParameters.save
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.write_parameters.rst b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.write_parameters.rst
new file mode 100644
index 0000000..f74bd85
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.ffdparams.FFDParameters.write_parameters.rst
@@ -0,0 +1,6 @@
+pygem.params.ffdparams.FFDParameters.write_parameters
+=====================================================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. automethod:: FFDParameters.write_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.idwparams.IDWParameters.read_parameters.rst b/docs/source/_summaries/pygem.params.idwparams.IDWParameters.read_parameters.rst
new file mode 100644
index 0000000..73a3695
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.idwparams.IDWParameters.read_parameters.rst
@@ -0,0 +1,6 @@
+pygem.params.idwparams.IDWParameters.read_parameters
+====================================================
+
+.. currentmodule:: pygem.params.idwparams
+
+.. automethod:: IDWParameters.read_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.idwparams.IDWParameters.write_parameters.rst b/docs/source/_summaries/pygem.params.idwparams.IDWParameters.write_parameters.rst
new file mode 100644
index 0000000..d787184
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.idwparams.IDWParameters.write_parameters.rst
@@ -0,0 +1,6 @@
+pygem.params.idwparams.IDWParameters.write_parameters
+=====================================================
+
+.. currentmodule:: pygem.params.idwparams
+
+.. automethod:: IDWParameters.write_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.n_control_points.rst b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.n_control_points.rst
new file mode 100644
index 0000000..0308f79
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.n_control_points.rst
@@ -0,0 +1,6 @@
+pygem.params.rbfparams.RBFParameters.n_control_points
+=====================================================
+
+.. currentmodule:: pygem.params.rbfparams
+
+.. autoattribute:: RBFParameters.n_control_points
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.read_parameters.rst b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.read_parameters.rst
new file mode 100644
index 0000000..0902d96
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.read_parameters.rst
@@ -0,0 +1,6 @@
+pygem.params.rbfparams.RBFParameters.read_parameters
+====================================================
+
+.. currentmodule:: pygem.params.rbfparams
+
+.. automethod:: RBFParameters.read_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.save.rst b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.save.rst
new file mode 100644
index 0000000..94557ce
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.save.rst
@@ -0,0 +1,6 @@
+pygem.params.rbfparams.RBFParameters.save
+=========================================
+
+.. currentmodule:: pygem.params.rbfparams
+
+.. automethod:: RBFParameters.save
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.write_parameters.rst b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.write_parameters.rst
new file mode 100644
index 0000000..191c535
--- /dev/null
+++ b/docs/source/_summaries/pygem.params.rbfparams.RBFParameters.write_parameters.rst
@@ -0,0 +1,6 @@
+pygem.params.rbfparams.RBFParameters.write_parameters
+=====================================================
+
+.. currentmodule:: pygem.params.rbfparams
+
+.. automethod:: RBFParameters.write_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params_idw.IDWParameters.__str__.rst b/docs/source/_summaries/pygem.params_idw.IDWParameters.__str__.rst
deleted file mode 100644
index 13fc07e..0000000
--- a/docs/source/_summaries/pygem.params_idw.IDWParameters.__str__.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem\.params\_idw\.IDWParameters\.\_\_str\_\_
-==============================================
-
-.. currentmodule:: pygem.params_idw
-
-.. automethod:: IDWParameters.__str__
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params_idw.IDWParameters.read_parameters.rst b/docs/source/_summaries/pygem.params_idw.IDWParameters.read_parameters.rst
deleted file mode 100644
index 324ba5f..0000000
--- a/docs/source/_summaries/pygem.params_idw.IDWParameters.read_parameters.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem\.params\_idw\.IDWParameters\.read\_parameters
-===================================================
-
-.. currentmodule:: pygem.params_idw
-
-.. automethod:: IDWParameters.read_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.params_idw.IDWParameters.write_parameters.rst b/docs/source/_summaries/pygem.params_idw.IDWParameters.write_parameters.rst
deleted file mode 100644
index 07291c9..0000000
--- a/docs/source/_summaries/pygem.params_idw.IDWParameters.write_parameters.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem\.params\_idw\.IDWParameters\.write\_parameters
-====================================================
-
-.. currentmodule:: pygem.params_idw
-
-.. automethod:: IDWParameters.write_parameters
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.radial.RBF.polyharmonic_spline.rst b/docs/source/_summaries/pygem.radial.RBF.polyharmonic_spline.rst
index 4866883..fea2cdd 100644
--- a/docs/source/_summaries/pygem.radial.RBF.polyharmonic_spline.rst
+++ b/docs/source/_summaries/pygem.radial.RBF.polyharmonic_spline.rst
@@ -1,6 +1,6 @@
pygem.radial.RBF.polyharmonic_spline
-==================================
+====================================
.. currentmodule:: pygem.radial
-.. automethod:: RBF.polyharmonic_spline
+.. automethod:: RBF.polyharmonic_spline
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.utils._write_vtk_box.rst b/docs/source/_summaries/pygem.utils._write_vtk_box.rst
deleted file mode 100644
index 6b0e5ef..0000000
--- a/docs/source/_summaries/pygem.utils._write_vtk_box.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.utils._write_vtk_box
-==========================
-
-.. currentmodule:: pygem.utils
-
-.. autofunction:: _write_vtk_box
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.utils.plot_rbf_control_points.rst b/docs/source/_summaries/pygem.utils.plot_rbf_control_points.rst
deleted file mode 100644
index d722742..0000000
--- a/docs/source/_summaries/pygem.utils.plot_rbf_control_points.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.utils.plot_rbf_control_points
-===================================
-
-.. currentmodule:: pygem.utils
-
-.. autofunction:: plot_rbf_control_points
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.utils.write_bounding_box.rst b/docs/source/_summaries/pygem.utils.write_bounding_box.rst
deleted file mode 100644
index bd2167a..0000000
--- a/docs/source/_summaries/pygem.utils.write_bounding_box.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.utils.write_bounding_box
-==============================
-
-.. currentmodule:: pygem.utils
-
-.. autofunction:: write_bounding_box
\ No newline at end of file
diff --git a/docs/source/_summaries/pygem.utils.write_points_in_vtp.rst b/docs/source/_summaries/pygem.utils.write_points_in_vtp.rst
deleted file mode 100644
index 20b95a4..0000000
--- a/docs/source/_summaries/pygem.utils.write_points_in_vtp.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-pygem.utils.write_points_in_vtp
-===============================
-
-.. currentmodule:: pygem.utils
-
-.. autofunction:: write_points_in_vtp
\ No newline at end of file
diff --git a/docs/source/affine.rst b/docs/source/affine.rst
index dfe415a..c9ba728 100644
--- a/docs/source/affine.rst
+++ b/docs/source/affine.rst
@@ -15,4 +15,4 @@ Affine
.. automodule:: pygem.affine
:members:
-
+ :noindex:
diff --git a/docs/source/code.rst b/docs/source/code.rst
index 8b0310c..9f2f9fd 100644
--- a/docs/source/code.rst
+++ b/docs/source/code.rst
@@ -9,7 +9,10 @@ Code Documentation
affine
freeform
radial
- params
+ idw
+ ffdparams
+ rbfparams
+ idwparams
filehandler
openfhandler
stlhandler
@@ -18,7 +21,3 @@ Code Documentation
nurbshandler
igeshandler
stephandler
- utils
- gui
- idw
- params_idw
diff --git a/docs/source/ffdparams.rst b/docs/source/ffdparams.rst
new file mode 100644
index 0000000..52919cc
--- /dev/null
+++ b/docs/source/ffdparams.rst
@@ -0,0 +1,27 @@
+FFDParameters
+=================
+
+.. currentmodule:: pygem.params.ffdparams
+
+.. automodule:: pygem.params.ffdparams
+
+.. autosummary::
+ :toctree: _summaries
+ :nosignatures:
+
+ FFDParameters.psi_mapping
+ FFDParameters.inv_psi_mapping
+ FFDParameters.rotation_matrix
+ FFDParameters.position_vertices
+ FFDParameters.read_parameters
+ FFDParameters.write_parameters
+ FFDParameters.save
+ FFDParameters.build_bounding_box
+ FFDParameters.reset_deformation
+
+.. autoclass:: FFDParameters
+ :members:
+ :private-members:
+ :undoc-members:
+ :show-inheritance:
+ :noindex:
diff --git a/docs/source/gui.rst b/docs/source/gui.rst
deleted file mode 100644
index 0c03805..0000000
--- a/docs/source/gui.rst
+++ /dev/null
@@ -1,25 +0,0 @@
-Gui
-=================
-
-.. currentmodule:: pygem.gui
-
-.. automodule:: pygem.gui
-
-.. autosummary::
- :toctree: _summaries
- :nosignatures:
-
- Gui._chose_geometry
- Gui._chose_parameters
- Gui._goto_website
- Gui._main
- Gui._run_simulation
- Gui.start
-
-.. autoclass:: Gui
- :members:
- :private-members:
- :undoc-members:
- :show-inheritance:
- :noindex:
-
diff --git a/docs/source/params_idw.rst b/docs/source/idwparams.rst
similarity index 74%
rename from docs/source/params_idw.rst
rename to docs/source/idwparams.rst
index 489b34e..c176a69 100644
--- a/docs/source/params_idw.rst
+++ b/docs/source/idwparams.rst
@@ -1,15 +1,14 @@
IDWParameters
=================
-.. currentmodule:: pygem.params_idw
+.. currentmodule:: pygem.params.idwparams
-.. automodule:: pygem.params_idw
+.. automodule:: pygem.params.idwparams
.. autosummary::
:toctree: _summaries
:nosignatures:
- IDWParameters.__str__
IDWParameters.read_parameters
IDWParameters.write_parameters
diff --git a/docs/source/params.rst b/docs/source/params.rst
deleted file mode 100644
index 9e8e7c7..0000000
--- a/docs/source/params.rst
+++ /dev/null
@@ -1,36 +0,0 @@
-Params
-=================
-
-.. currentmodule:: pygem.params
-
-.. automodule:: pygem.params
-
-.. autosummary::
- :toctree: _summaries
- :nosignatures:
-
- FFDParameters._calculate_bb_dimension
- FFDParameters._set_box_dimensions
- FFDParameters._set_mapping
- FFDParameters._set_position_of_vertices
- FFDParameters._set_transformation_params_to_zero
- FFDParameters.build_bounding_box
- FFDParameters.read_parameters
- FFDParameters.write_parameters
- RBFParameters.read_parameters
- RBFParameters.write_parameters
-
-.. autoclass:: FFDParameters
- :members:
- :private-members:
- :undoc-members:
- :show-inheritance:
- :noindex:
-
-
-.. autoclass:: RBFParameters
- :members:
- :private-members:
- :undoc-members:
- :show-inheritance:
- :noindex:
diff --git a/docs/source/rbfparams.rst b/docs/source/rbfparams.rst
new file mode 100644
index 0000000..cbffdcd
--- /dev/null
+++ b/docs/source/rbfparams.rst
@@ -0,0 +1,22 @@
+RBFParameters
+=================
+
+.. currentmodule:: pygem.params.rbfparams
+
+.. automodule:: pygem.params.rbfparams
+
+.. autosummary::
+ :toctree: _summaries
+ :nosignatures:
+
+ RBFParameters.n_control_points
+ RBFParameters.read_parameters
+ RBFParameters.write_parameters
+ RBFParameters.save
+
+.. autoclass:: RBFParameters
+ :members:
+ :private-members:
+ :undoc-members:
+ :show-inheritance:
+ :noindex:
diff --git a/docs/source/utils.rst b/docs/source/utils.rst
deleted file mode 100644
index d3a961e..0000000
--- a/docs/source/utils.rst
+++ /dev/null
@@ -1,22 +0,0 @@
-Utils
-=====================
-
-.. currentmodule:: pygem.utils
-
-.. automodule:: pygem.utils
-
-.. autosummary::
- :toctree: _summaries
- :nosignatures:
-
- _write_vtk_box
- plot_rbf_control_points
- write_bounding_box
- write_points_in_vtp
-
-.. automodule:: pygem.utils
- :members:
- :private-members:
- :undoc-members:
- :show-inheritance:
- :noindex:
\ No newline at end of file
diff --git a/pygem/affine.py b/pygem/affine.py
index 58dfcd6..26011e5 100644
--- a/pygem/affine.py
+++ b/pygem/affine.py
@@ -64,9 +64,9 @@ def angles2matrix(rot_z=0, rot_y=0, rot_x=0):
def to_reduced_row_echelon_form(matrix):
"""
This method computes the reduced row echelon form (a.k.a. row canonical
- form) of a matrix. The code is taken from
- https://rosettacode.org/wiki/Reduced_row_echelon_form#Python and edited with
- minor changes.
+ form) of a matrix. The code is taken from
+ https://rosettacode.org/wiki/Reduced_row_echelon_form#Python and edited
+ with minor changes.
:param matrix matrix: matrix to be reduced.
diff --git a/pygem/params/ffdparams.py b/pygem/params/ffdparams.py
index b6b2034..7ebab1f 100644
--- a/pygem/params/ffdparams.py
+++ b/pygem/params/ffdparams.py
@@ -121,7 +121,7 @@ def rotation_matrix(self):
@property
def position_vertices(self):
"""
- The position of the second vertex of the FFD bounding box.
+ The position of the vertices of the FFD bounding box.
:rtype: numpy.ndarray
"""
@@ -370,74 +370,40 @@ def build_bounding_box(self,
triangulate=False,
triangulate_tol=1e-1):
"""
- Builds a bounding box around the given shape. ALl parameters (with the
- exception of array_mu_x/y/z) are set to match the computed box.
-
- :param TopoDS_Shape shape: or a subclass such as TopoDS_Face the shape
- to compute the bounding box from
- :param float tol: tolerance of the computed bounding box
- :param bool triangulate: Should shape be triangulated before the
- boudning box is created.
-
- If ``True`` only the dimensions of the bb will take into account
- every part of the shape (also not *visible*)
-
- If ``False`` only the *visible* part is taken into account
+ Builds a bounding box around the given shape. All parameters are set to
+ match the computed box, the deformed FFD points are reset.
+
+ :param shape: the shape to compute the bounding box.
+ :type shape: TopoDS_Shape or its subclass
+ :param float tol: tolerance of the computed bounding box.
+ :param bool triangulate: if True, shape is triangulated before the
+ bouning box creation.
+ :param float triangulate_tol: tolerance of triangulation (size of
+ created triangles).
- *Explanation:* every UV-Surface has to be rectangular. When a solid
- is created surfaces are trimmed. the trimmed part, however, is
- still saved inside a file. It is just *invisible* when drawn in a
- program
+ .. note::
- :param float triangulate_tol: tolerance of triangulation (size of
- created triangles)
+ Every UV-Surface has to be rectangular. When a solid is created
+ surfaces are trimmed. The trimmed part, however, is still saved
+ inside a file. It is just *invisible* when drawn in a program.
"""
- min_xyz, max_xyz = self._calculate_bb_dimension(shape, tol, triangulate,
- triangulate_tol)
+ bbox = Bnd_Box()
+ bbox.SetGap(tol)
+ if triangulate:
+ BRepMesh_IncrementalMesh(shape, triangulate_tol)
+ brepbndlib_Add(shape, bbox, triangulate)
+ xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
+ min_xyz = np.array([xmin, ymin, zmin])
+ max_xyz = np.array([xmax, ymax, zmax])
+
self.origin_box = min_xyz
self.lenght_box = max_xyz - min_xyz
self.reset_deformation()
def reset_deformation(self):
"""
- Sets transfomration parameters (``array_mu_x, array_mu_y, array_mu_z``)
- to arrays of zeros (``numpy.zeros``). The shape of arrays corresponds to
- the number of control points in each dimension.
+ Set transformation parameters to arrays of zeros.
"""
self.array_mu_x.fill(0.0)
self.array_mu_y.fill(0.0)
self.array_mu_z.fill(0.0)
-
- @staticmethod
- def _calculate_bb_dimension(shape,
- tol=1e-6,
- triangulate=False,
- triangulate_tol=1e-1):
- """ Calculate dimensions (minima and maxima) of a box bounding the
-
- :param TopoDS_Shape shape: or a subclass such as TopoDS_Face the shape
- to compute the bounding box from
- :param float tol: tolerance of the computed bounding box
- :param bool triangulate: Should shape be triangulated before the
- boudning box is created.
-
- If ``True`` only the dimensions of the bb will take into account
- every part of the shape (also not *visible*)
-
- If ``False`` only the *visible* part is taken into account
-
- \*See :meth:`~params.FFDParameters.build_bounding_box`
- :param float triangulate_tol: tolerance of triangulation (size of
- created triangles)
- :return: coordinates of minima and maxima along XYZ
- :rtype: tuple
- """
- bbox = Bnd_Box()
- bbox.SetGap(tol)
- if triangulate:
- BRepMesh_IncrementalMesh(shape, triangulate_tol)
- brepbndlib_Add(shape, bbox, triangulate)
- xmin, ymin, zmin, xmax, ymax, zmax = bbox.Get()
- xyz_min = np.array([xmin, ymin, zmin])
- xyz_max = np.array([xmax, ymax, zmax])
- return xyz_min, xyz_max
From 6221372008603bbf95f1e84a2c3be57a92cfc113 Mon Sep 17 00:00:00 2001
From: Nicola Demo
Date: Thu, 22 Mar 2018 08:53:39 +0100
Subject: [PATCH 9/9] Remove old tests
---
tests/test_ffdparams.py | 24 ------------------------
1 file changed, 24 deletions(-)
diff --git a/tests/test_ffdparams.py b/tests/test_ffdparams.py
index e97af8d..92bd762 100644
--- a/tests/test_ffdparams.py
+++ b/tests/test_ffdparams.py
@@ -292,27 +292,3 @@ def test_set_modification_parameters_to_zero(self):
params.array_mu_y, np.zeros(shape=(5, 5, 5)))
np.testing.assert_almost_equal(
params.array_mu_z, np.zeros(shape=(5, 5, 5)))
-
- def test_calculate_bb_dimensions(self):
- min_vals = np.zeros(3)
- max_vals = np.ones(3)
- cube = BRepPrimAPI_MakeBox(1, 1, 1).Shape()
- params = FFDParameters()
- xyz_min, xyz_max = params._calculate_bb_dimension(cube)
- np.testing.assert_almost_equal(xyz_min, min_vals, decimal=5)
- np.testing.assert_almost_equal(xyz_max, max_vals, decimal=5)
-
- def test_calculate_bb_dimensions_triangulate(self):
- a = gp_Pnt(-1, -1, -1)
- b = gp_Pnt(3, 3, 3)
-
- box = BRepPrimAPI_MakeBox(a, b).Shape()
- sphere = BRepPrimAPI_MakeSphere(3).Shape()
- section = BRepAlgoAPI_Cut(box, sphere).Shape()
- params = FFDParameters()
- xyz_min, xyz_max = params._calculate_bb_dimension(
- section, triangulate=True)
- correct_min = -1 * np.ones(3)
- correct_max = 3 * np.ones(3)
- np.testing.assert_almost_equal(xyz_min, correct_min, decimal=1)
- np.testing.assert_almost_equal(xyz_max, correct_max, decimal=1)