fdtdx.export_stl

Contents

fdtdx.export_stl#

fdtdx.export_stl(matrix, stl_filename=None, voxel_grid_size=(1, 1, 1))[source]#

Export a 3D boolean matrix to an STL file.

Converts a 3D boolean matrix into a mesh representation and saves it as an STL file. True values in the matrix are converted to solid voxels in the output mesh.

Parameters:
  • matrix (np.ndarray) – 3D boolean numpy array representing the voxel grid.

  • stl_filename (Path | str | None, optional) – Output STL file path. If given, save the stl to this path. Defaults to None.

  • voxel_grid_size (tuple[int, int, int], optional) – Physical size of each voxel as (x, y, z) integers. Defaults to (1, 1, 1).

Returns:

STL mesh.

Return type:

trimesh.Trimesh

Raises:

Exception – If input matrix is not 3-dimensional.