Skip to content

Commit 3516430

Browse files
authored
Merge pull request #151 from mtezzele/doc
fix documentation and tests for save_points
2 parents eb9f35d + a9ec79a commit 3516430

File tree

13 files changed

+160
-84
lines changed

13 files changed

+160
-84
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ install:
5050
fi
5151
- source activate test
5252
- pip install numpy scipy matplotlib vtk nose
53-
- conda install --yes -c https://conda.anaconda.org/dlr-sc pythonocc-core==0.17
53+
- conda install --yes -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core==0.17.3 python=2
5454
- pip install setuptools
5555
- pip install coveralls
5656
- pip install coverage

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ See the [**Examples**](#examples) section below and the [**Tutorials**](tutorial
4848

4949

5050
## Dependencies and installation
51-
**PyGeM** requires `numpy`, `scipy`, `matplotlib`, `vtk`, `sphinx` (for the documentation) and `nose` (for local test). They can be easily installed via `pip`.
51+
**PyGeM** requires `numpy`, `scipy`, `matplotlib`, `vtk`, `numpy-stl`, `sphinx` (for the documentation) and `nose` (for local test). They can be easily installed via `pip`. The code is compatible with Python 2.7.
5252
Moreover **PyGeM** depends on `OCC`. These requirements cannot be satisfied through `pip`.
5353
Please see the table below for instructions on how to satisfy the requirements.
5454

55-
| Package | Version | Comment |
56-
|---------|----------|----------------------------------------------------------------------------|
57-
| 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` |
55+
| Package | Version | Comment |
56+
|---------|-------------|----------------------------------------------------------------------------|
57+
| OCC | ==0.17.3 | See pythonocc.org or github.com.tpaviot/pythonocc-core for instructions or `conda install -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core==0.17.3 python=2` |
5858

5959

6060
The official distribution is on GitHub, and you can clone the repository using

pygem/freeform.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@
1010
consists in three different step:
1111
1212
- Mapping the physical domain to the reference one with map
13-
:math:`\\boldsymbol{\psi}`. In the code it is named *transformation*.
14-
13+
:math:`\\boldsymbol{\\psi}`. In the code it is named *transformation*.
14+
1515
- Moving some control points to deform the lattice with :math:`\\hat{T}`.
16-
The movement of the control points is basically the weight (or displacement)
17-
:math:`\\boldsymbol{\mu}` we set in the *parameters file*.
18-
16+
The movement of the control points is basically the weight (or displacement)
17+
:math:`\\boldsymbol{\\mu}` we set in the *parameters file*.
18+
1919
- Mapping back to the physical domain with map
20-
:math:`\\boldsymbol{\psi}^-1`. In the code it is named
21-
*inverse_transformation*.
22-
20+
:math:`\\boldsymbol{\\psi}^{-1}`. In the code it is named
21+
*inverse_transformation*.
22+
2323
FFD map (:math:`T`) is the composition of the three maps, that is
24-
24+
2525
.. math:: T(\\cdot, \\boldsymbol{\\mu}) = (\\Psi^{-1} \\circ \\hat{T} \\circ
2626
\\Psi) (\\cdot, \\boldsymbol{\\mu})
27-
27+
2828
In this way, every point inside the FFD box changes it position according to
29-
30-
.. math:: \\boldsymbol{P} = \\boldsymbol{\psi}^-1 \\left( \\sum_{l=0} ^L
31-
\\sum_{m=0} ^M \\sum_{n=0} ^N
29+
30+
.. math:: \\boldsymbol{P} = \\boldsymbol{\\psi}^{-1} \\left( \\sum_{l=0}^L
31+
\\sum_{m=0}^M \\sum_{n=0}^N
3232
\\mathsf{b}_{lmn}(\\boldsymbol{\\psi}(\\boldsymbol{P}_0))
3333
\\boldsymbol{\\mu}_{lmn} \\right)
34-
34+
3535
where :math:`\\mathsf{b}_{lmn}` are Bernstein polynomials. We improve the
3636
traditional version by allowing a rotation of the FFD lattice in order to
3737
give more flexibility to the tool.
@@ -56,21 +56,21 @@ class FFD(object):
5656
5757
:cvar FFDParameters parameters: parameters of the Free Form Deformation.
5858
:cvar numpy.ndarray original_mesh_points: coordinates of the original points
59-
of the mesh. The shape is `n_points`-by-3.
59+
of the mesh. The shape is `n_points`-by-3.
6060
:cvar numpy.ndarray modified_mesh_points: coordinates of the points of the
61-
deformed mesh. The shape is `n_points`-by-3.
61+
deformed mesh. The shape is `n_points`-by-3.
6262
6363
:Example:
6464
65-
>>> import pygem.freeform as ffd
66-
>>> import pygem.params as ffdp
67-
>>> import numpy as np
68-
>>> ffd_parameters = ffdp.FFDParameters()
69-
>>> ffd_parameters.read_parameters('tests/test_datasets/parameters_test_ffd_sphere.prm')
70-
>>> original_mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
71-
>>> free_form = ffd.FFD(ffd_parameters, original_mesh_points)
72-
>>> free_form.perform()
73-
>>> new_mesh_points = free_form.modified_mesh_points
65+
>>> import pygem.freeform as ffd
66+
>>> import pygem.params as ffdp
67+
>>> import numpy as np
68+
>>> ffd_params = ffdp.FFDParameters()
69+
>>> ffd_params.read_parameters('tests/test_datasets/parameters_test_ffd_sphere.prm')
70+
>>> original_mesh_points = np.load('tests/test_datasets/meshpoints_sphere_orig.npy')
71+
>>> free_form = ffd.FFD(ffd_params, original_mesh_points)
72+
>>> free_form.perform()
73+
>>> new_mesh_points = free_form.modified_mesh_points
7474
"""
7575

7676
def __init__(self, ffd_parameters, original_mesh_points):

pygem/idw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
The interpolation value :math:`u` of a given point :math:`\\mathrm{x}`
1919
from a set of samples :math:`u_k = u(\\mathrm{x}_k)`, with
20-
:math:`k = 1,2,\dotsc,\\mathcal{N}`, is given by:
20+
:math:`k = 1,2,\\dotsc,\\mathcal{N}`, is given by:
2121
2222
.. math::
2323
u(\\mathrm{x}) = \\displaystyle\\sum_{k=1}^\\mathcal{N}

pygem/params/ffdparams.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,33 @@ class FFDParameters(object):
4040
4141
:Example: from file
4242
43-
>>> import pygem.params as ffdp
44-
>>>
45-
>>> # Reading an existing file
46-
>>> params1 = ffdp.FFDParameters()
47-
>>> params1.read_parameters(
48-
>>> filename='tests/test_datasets/parameters_test_ffd_identity.prm')
49-
>>>
50-
>>> # Creating a default parameters file with the right dimensions (if the
51-
>>> # file does not exists it is created with that name). So it is possible
52-
>>> # to manually edit it and read it again.
53-
>>> params2 = ffdp.FFDParameters(n_control_points=[2, 3, 2])
54-
>>> params2.read_parameters(filename='parameters_test.prm')
55-
>>>
56-
>>> # Creating bounding box of the given shape
57-
>>> from OCC.IGESControl import IGESControl_Reader
58-
>>> params3 = ffdp.FFDParameters()
59-
>>> reader = IGESControl_Reader()
60-
>>> reader.ReadFile('tests/test_datasets/test_pipe.igs')
61-
>>> reader.TransferRoots()
62-
>>> shape = reader.Shape()
63-
>>> params3.build_bounding_box(shape)
43+
>>> import pygem.params as ffdp
44+
>>>
45+
>>> # Reading an existing file
46+
>>> params1 = ffdp.FFDParameters()
47+
>>> params1.read_parameters(
48+
>>> filename='tests/test_datasets/parameters_test_ffd_identity.prm')
49+
>>>
50+
>>> # Creating a default parameters file with the right dimensions (if the
51+
>>> # file does not exists it is created with that name). So it is possible
52+
>>> # to manually edit it and read it again.
53+
>>> params2 = ffdp.FFDParameters(n_control_points=[2, 3, 2])
54+
>>> params2.read_parameters(filename='parameters_test.prm')
55+
>>>
56+
>>> # Creating bounding box of the given shape
57+
>>> from OCC.IGESControl import IGESControl_Reader
58+
>>> params3 = ffdp.FFDParameters()
59+
>>> reader = IGESControl_Reader()
60+
>>> reader.ReadFile('tests/test_datasets/test_pipe.igs')
61+
>>> reader.TransferRoots()
62+
>>> shape = reader.Shape()
63+
>>> params3.build_bounding_box(shape)
6464
6565
.. note::
6666
Four vertex (non coplanar) are sufficient to uniquely identify a
6767
parallelepiped.
6868
If the four vertex are coplanar, an assert is thrown when
69-
affine_points_fit is used.
69+
`affine_points_fit is used.
7070
7171
"""
7272

@@ -339,21 +339,21 @@ def save_points(self, filename, write_deformed=True):
339339
Method that writes a vtk file containing the FFD lattice. This method
340340
allows to visualize where the FFD control points are located before the
341341
geometrical morphing. If the `write_deformed` flag is set to True the
342-
method writes out the deformed lattice, otherwise it writes one the
342+
method writes out the deformed lattice, otherwise it writes the
343343
original undeformed lattice.
344344
345345
:param str filename: name of the output file.
346346
:param bool write_deformed: flag to write the original or modified FFD
347-
control lattice. The default is set to True.
347+
control lattice. The default is True.
348348
349349
:Example:
350350
351-
>>> from pygem.params import FFDParameters
352-
>>>
353-
>>> params = FFDParameters()
354-
>>> params.read_parameters(
355-
>>> filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
356-
>>> params.save('tests/test_datasets/box_test_sphere.vtk')
351+
>>> from pygem.params import FFDParameters
352+
>>>
353+
>>> params = FFDParameters()
354+
>>> params.read_parameters(
355+
>>> filename='tests/test_datasets/parameters_test_ffd_sphere.prm')
356+
>>> params.save_points('tests/test_datasets/box_test_sphere.vtk')
357357
358358
.. note::
359359
In order to visualize the points in Paraview, please select the

pygem/params/rbfparams.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ def save_points(self, filename, write_deformed=True):
208208
209209
:Example:
210210
211-
>>> from pygem.params import RBFParameters
212-
>>>
213-
>>> params = RBFParameters()
214-
>>> params.read_parameters(
215-
>>> filename='tests/test_datasets/parameters_rbf_cube.prm')
216-
>>> params.save_points('tests/test_datasets/box_cube.vtk')
211+
>>> from pygem.params import RBFParameters
212+
>>>
213+
>>> params = RBFParameters()
214+
>>> params.read_parameters(
215+
>>> filename='tests/test_datasets/parameters_rbf_cube.prm')
216+
>>> params.save_points('tests/test_datasets/box_cube.vtk')
217217
218218
.. note::
219219
In order to visualize the points in Paraview, please select the

pygem/radial.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,23 @@ class RBF(object):
8383
8484
:Example:
8585
86-
>>> import pygem.radial as rbf
87-
>>> import pygem.params as rbfp
88-
>>> import numpy as np
89-
>>> rbf_parameters = rbfp.RBFParameters()
90-
>>> fname = 'tests/test_datasets/parameters_rbf_cube.prm'
91-
>>> rbf_parameters.read_parameters(fname)
92-
>>> nx, ny, nz = (20, 20, 20)
93-
>>> mesh = np.zeros((nx * ny * nz, 3))
94-
>>> xv = np.linspace(0, 1, nx)
95-
>>> yv = np.linspace(0, 1, ny)
96-
>>> zv = np.linspace(0, 1, nz)
97-
>>> z, y, x = np.meshgrid(zv, yv, xv)
98-
>>> mesh = np.array([x.ravel(), y.ravel(), z.ravel()])
99-
>>> original_mesh_points = mesh.T
100-
>>> radial_trans = rbf.RBF(rbf_parameters, original_mesh_points)
101-
>>> radial_trans.perform()
102-
>>> new_mesh_points = radial_trans.modified_mesh_points
86+
>>> import pygem.radial as rbf
87+
>>> import pygem.params as rbfp
88+
>>> import numpy as np
89+
>>> rbf_parameters = rbfp.RBFParameters()
90+
>>> fname = 'tests/test_datasets/parameters_rbf_cube.prm'
91+
>>> rbf_parameters.read_parameters(fname)
92+
>>> nx, ny, nz = (20, 20, 20)
93+
>>> mesh = np.zeros((nx * ny * nz, 3))
94+
>>> xv = np.linspace(0, 1, nx)
95+
>>> yv = np.linspace(0, 1, ny)
96+
>>> zv = np.linspace(0, 1, nz)
97+
>>> z, y, x = np.meshgrid(zv, yv, xv)
98+
>>> mesh = np.array([x.ravel(), y.ravel(), z.ravel()])
99+
>>> original_mesh_points = mesh.T
100+
>>> radial_trans = rbf.RBF(rbf_parameters, original_mesh_points)
101+
>>> radial_trans.perform()
102+
>>> new_mesh_points = radial_trans.modified_mesh_points
103103
"""
104104

105105
def __init__(self, rbf_parameters, original_mesh_points):
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# vtk DataFile Version 4.2
2+
vtk output
3+
ASCII
4+
DATASET POLYDATA
5+
POINTS 8 float
6+
-0.1 0 0 0 0 1 0 1 0
7+
1 0 0 0 1 1 1 0 1
8+
1 1 0 1 1 1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# vtk DataFile Version 4.2
2+
vtk output
3+
ASCII
4+
DATASET POLYDATA
5+
POINTS 8 float
6+
0.1 0.2 0.3 0 0 1 0 1 0
7+
1 0 0 0 0.8 1 1 0 1
8+
1 1 0 1.2 1.2 1.2
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# vtk DataFile Version 4.2
2+
vtk output
3+
ASCII
4+
DATASET POLYDATA
5+
POINTS 12 float
6+
-20 -55 -45 -4.37166 -55 43.6327 -42.9398 31.9333 -40.9551
7+
-27.3115 31.9333 47.6776 1.40315 -49.1766 -48.774 17.0315 -49.1766 39.8587
8+
-21.5367 37.7568 -44.729 -5.90834 37.7568 43.9037 22.8063 -43.3531 -52.5479
9+
38.4346 -43.3531 36.0848 -0.133524 43.5802 -48.503 15.4948 43.5802 40.1297
10+

0 commit comments

Comments
 (0)