Skip to content

Commit

Permalink
Added conversion
Browse files Browse the repository at this point in the history
Added helper functions to convert stl.Mesh's to triangle arrays
  • Loading branch information
JoeBell committed Mar 5, 2025
1 parent 13a589f commit 968cbac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ShipGen/Generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion ShipGen/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from .Generate import generate_hulls, ShipCharacteristics
from .Generate import (
generate_hulls,
ShipCharacteristics,
mesh_to_triangles,
mesh_list_to_triangles,
)

0 comments on commit 968cbac

Please sign in to comment.