Cesar L. Pastrana, 2022
Meshgen is Python module that uses Ctypes to wrap the Advancing Front Surface Reconstruction algorithm from the C++-based library CGAL to obtain a triangulated surface from a 3D set of points. The algorithm is valid for both convex and non-convex surfaces, as well as for open and closed surfaces. Importantly, the resulting triangulation is oriented.
Import the module, for instance via from meshgen import gentrimesh
. For a set of N points defining the surface and organised as a numpy array r
of Nx3 (with x, y and z in columns), the triangulation is obtained as:
tri, n_tri = gentrimesh(r)
Here tri
is an int
array of n_tri
x3, where the three columns indicate the indices in r
defining a triangle.
The libary is included as a Linux-based pre-compiled shared libary meshgen.so
in the folder clib
. For other Unix-based operative systems, the libary can be recompiled using the Makefile
included in the folder, simply run make
(MinGW can be used in Windows). It is necessary, both for compilation and execution of the module, to have CGAL and its dependencies installed on the system.