Commit 86602b15 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

trimesh repairing fixed

parent 3183b979
......@@ -12,26 +12,18 @@ class Slicer:
def __init__(self, model, settings, repair_first=True):
if repair_first:
if isinstance(model, str):
try:
temp_mesh = tm.load_mesh(model)
print(temp_mesh)
except FileNotFoundError:
raise Exception("Please provide a valid path to a valid stl/obj etc.")
temp_mesh.process(validate=True)
temp_mesh = pf.MeshFix(temp_mesh.vertices, temp_mesh.faces)
self.model_mesh = temp_mesh.mesh
elif isinstance(model, pv.core.pointset.PolyData):
temp_mesh = tm.base.Trimesh(vertices=model.points, faces=model.faces)
else:
if isinstance(model, str):
# Assume String is file location
try:
self.model_mesh = pv.read(model)
except FileNotFoundError:
raise Exception("Please provide a valid path to a valid stl/obj etc.")
elif isinstance(model, pv.core.pointset.PolyData):
# instance of pyvista mesh
self.model_mesh = model
if repair_first: # repair in trimesh
tm.repair.fix_inversion(temp_mesh)
tm.repair.fix_winding(temp_mesh)
self.model_mesh = pv.wrap(temp_mesh) # convert trimesh to pyvista
self.bed_centre = settings.bed_centre
tu.transform_to_bed_centre(self.model_mesh, self.bed_centre)
......@@ -83,10 +75,10 @@ class Slicer:
"""
Generate sliced layers
"""
surfs = self.gen_surfs()
self.surfs = self.gen_surfs()
s = time.time()
print('\033[93m' + "Generating slices..." + '\033[0m')
for layer_i, surf in enumerate(surfs):
for layer_i, surf in enumerate(self.surfs):
sliced_surf = surf.clip_surface(self.model_mesh, invert=self.invert)
self.slices[layer_i] = sliced_surf.clean(inplace=False)
print("Sliced mesh", layer_i, "added. At Z", self.heights[layer_i], "of", self.heights[len(self.heights)-1])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment