The get_mesh function is the primary entry point for creating a 3D printable STL mesh from a height map. It automates the entire pipeline: calculating required triangles, generating vertices from the height map, tessellating the main surface, creating a frame, and stitching the back to ensure the mesh is a solid, 3D printable object.
Parameters:
cols (int): Number of columns in the grid.rows (int): Number of rows in the grid.width (float): The physical width of the mesh.height (float): The physical height of the mesh.height_map (list/array): A 2D array representing pixel intensities used for Z-axis displacement.
Returns:
surface (numpy-based mesh object): A complete stl.mesh.Mesh object ready for saving.
from src.utils.mesh_processing import get_mesh, save_stl
# Example usage
height_map = [[0.1, 0.5], [0.8, 0.2]] # Example 2x2 height map
mesh_obj = get_mesh(cols=2, rows=2, width=100, height=100, height_map=height_map)
save_stl(mesh_obj, "output.stl")