This commit is contained in:
Sgr A* VMT
2024-01-31 22:35:26 +08:00
parent f0febcf92f
commit 40ea0e117f

39
idm.py
View File

@@ -885,9 +885,9 @@ class IDMProbe:
old_offset = self.model.offset old_offset = self.model.offset
self.model.offset += offset self.model.offset += offset
self.model.save(self, False) self.model.save(self, False)
gcmd.respond_info("IDM model offset has been updated to {}.\n" gcmd.respond_info(f"IDM model offset has been updated to {self.model.offset}.\n"
"You must run the SAVE_CONFIG command now to update the\n" "You must run the SAVE_CONFIG command now to update the\n"
"printer config file and restart the printer.".format(self.model.offset)) "printer config file and restart the printer.")
self.model.offset = old_offset self.model.offset = old_offset
class IDMModel: class IDMModel:
@@ -1833,29 +1833,22 @@ class IDMMeshHelper:
def _interpolate_faulty(self, clusters): def _interpolate_faulty(self, clusters):
faulty_indexes = [] faulty_indexes = []
xi_max = 0 position = np.array(list(clusters.keys()))
yi_max = 0 (xi_max,yi_max) = position.T.max(axis = 1)
for (xi, yi), points in clusters.items(): pos_temp = (position.T*[[self.step_x],[self.step_y]]+[[self.min_x],[self.min_y]]).T
if xi > xi_max: for i in range(len(pos_temp)):
xi_max = xi if self._is_faulty_coordinate(pos_temp[i][0], pos_temp[i][1]):
if yi > yi_max: clusters[tuple(position[i])] = None
yi_max = yi faulty_indexes.append(tuple(position[i]))
xc = xi * self.step_x + self.min_x del pos_temp
yc = yi * self.step_y + self.min_y
if self._is_faulty_coordinate(xc, yc):
clusters[(xi, yi)] = None
faulty_indexes.append((xi, yi))
def get_nearest(start, dx, dy): def get_nearest(start, dx, dy):
(x, y) = start inputs = np.array(start)
x += dx inputs += [dx,dy]
y += dy while ((inputs >= 0).all() and (inputs <= [xi_max,yi_max]).all()):
while (x >= 0 and x <= xi_max and if clusters[tuple(inputs)] is not None:
y >= 0 and y <= yi_max): return (abs(inputs-start[0]).sum(), median(clusters[tuple(inputs)]))
if clusters[(x, y)] is not None: inputs += [dx,dy]
return (abs(x-start[0])+abs(y-start[0]), median(clusters[(x,y)]))
x += dx
y += dy
return None return None
def interp_weighted(lower, higher): def interp_weighted(lower, higher):