From 968cbac735d178b7db360740d575fa06fcd8a224 Mon Sep 17 00:00:00 2001 From: JoeBell Date: Tue, 4 Mar 2025 20:58:29 -0500 Subject: [PATCH] Added conversion Added helper functions to convert stl.Mesh's to triangle arrays --- ShipGen/Generate.py | 4 ++++ ShipGen/__init__.py | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ShipGen/Generate.py b/ShipGen/Generate.py index c966ebf..bd067e7 100644 --- a/ShipGen/Generate.py +++ b/ShipGen/Generate.py @@ -77,6 +77,10 @@ def generate_hulls(find_best:int, print('Error at hull {}'.format(valid_idx[idxs[i]])) return meshs +def mesh_to_triangles(mesh:Mesh) -> np.ndarray: + return np.array([mesh.v0, mesh.v1, mesh.v2]).swapaxes(0, 1) +def mesh_list_to_triangles(mesh_list:list[Mesh]) -> list[np.ndarray]: + return list(map(mesh_to_triangles, mesh_list)) def load_data(): # Load in the Data: diff --git a/ShipGen/__init__.py b/ShipGen/__init__.py index 936643b..46692fc 100644 --- a/ShipGen/__init__.py +++ b/ShipGen/__init__.py @@ -1 +1,6 @@ -from .Generate import generate_hulls, ShipCharacteristics \ No newline at end of file +from .Generate import ( + generate_hulls, + ShipCharacteristics, + mesh_to_triangles, + mesh_list_to_triangles, +) \ No newline at end of file