GMAC
A fast mesh manipulation and creation library made in rust, with a convenient python interface, and very few dependencies. Primary features include:
- Deform meshes using RBF and FFD
- Transform meshes (or selection just a selection of nodes)
- Large range of selection and transformation tools
- Import/export stl, obj and vtk-type files
- Convenient python interface
- Create primitives
- Great performance
Here's a demonstration of a plane tail deformed using the Free Form deformer (FFD):
| Variation 1 | Variation 2 |
|---|---|
Add to your rust project
Add the following to your Cargo.toml:
[]
= "^0.2.0"
This includes rayon by default, for those who want a lightweight dependency free version use default-features = false
For Rbf specifically, if you still need more performance try adding features openblas or intel-mkl.
Make sure you have the required dependencies installed for the features you choose. For openblas openssl is required.
Examples in Rust
Deforming with Free Form Deformer (FFD)
Heres a demonstration of deformation using the FreeFormDeformer:
use ;
| Original mesh & control points | Deformed mesh & control points |
|---|---|
Note: There are many ways to achieve the same result with all the tools provided, this is just one of them.
Deforming with Radial Basis Functions (RBF)
Using the RbfDeformer is very similar to using the FFD, but instead of using a design block (control lattice), you use a set of control points:
use ;
use RbfDeformer;
Here you can see the original control points and mesh, as well as the deformed control points and mesh:
| Original mesh & control points | Deformed mesh & control points |
|---|---|
Examples in Python
Using GMAC to deform a box
Heres a simple demonstration of using the Free Form Deformer (FFD) to deform a generated box (or an imported STL file).
# Create a simple primitive geometry or import something
=
# Alternative: mesh = gm.Mesh.from_stl("path_to_stl") or obj
# Create a design block (control lattice) for FFD
=
# Select which control points will be free to move
=
# Transform only the free control points using transformation matrix
=
=
# Save the deformed control points for visualisation
# Create a Free-Form Deformer with the original design block
=
# Apply the deformation to the original geometry
=
# Save the deformed geometry as STL/OBJ/VTK file
# binary default
For Radial Basis Function (RBF) deformation, see the RbfDeformer example in examples.
Build python from source
These instructions assume that Python3 and Cargo are installed on your system. To set up this project, follow these steps:
- Clone the repository:
- Create a virtual environment and install build system:
- Build the release binary:
- Build the python wheel:
- Running examples:
)>
References
The gmac_morph is heavily influenced by PyGEM (https://github.com/mathLab/PyGeM), and the following
Sieger, Menzel, Botsch. On Shape Deformation Techniques for Simulation-based Design Optimization. SEMA SIMAI Springer Series, 2015.
Lombardi, Parolini, Quarteroni, Rozza. Numerical Simulation of Sailing Boats: Dynamics, FSI, and Shape Optimization. Springer Optimization and Its Applications, 2012.
License
MIT License - See LICENSE for details.
Support
If you'd like to support the project consider:
- Identifying the features you'd like to see implemented or bugs you'd like to fix and open an issue.
- Contributing to the code by resolving existing issues, I'm happy to have you.
- Donating to help me continue development, Buy Me a Coffee