Skip to content

Commit

Permalink
Merge pull request #37 from lorycontixd/fix/meshbuilder
Browse files Browse the repository at this point in the history
Improved meshbuilder's mesh handling
  • Loading branch information
diegoferigo authored Jun 10, 2024
2 parents 1964e85 + e1a70b0 commit 75d7649
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/rod/builder/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,17 @@ def __post_init__(self) -> None:
TypeError: If the mesh_path is not a str or pathlib.Path.
"""

if isinstance(self.mesh_path, str):
extension = pathlib.Path(self.mesh_path).suffix
elif isinstance(self.mesh_path, pathlib.Path):
extension = self.mesh_path.suffix
else:
raise TypeError(
f"Expected str or pathlib.Path for mesh_path, got {type(self.mesh_path)}"
)

self.mesh: trimesh.base.Trimesh = trimesh.load(
str(self.mesh_path),
force="mesh",
file_type=extension,
mesh_path = (
self.mesh_path
if isinstance(self.mesh_path, pathlib.Path)
else pathlib.Path(self.mesh_path)
)

if not mesh_path.is_file():
raise FileNotFoundError(f"Mesh file not found at {self.mesh_path}")

self.mesh: trimesh.base.Trimesh = trimesh.load_mesh(
file_obj=mesh_path,
)

assert self.scale.shape == (
Expand Down

0 comments on commit 75d7649

Please sign in to comment.