From 0afbee8a0e2ad09b1c865e4edbe6e96b4bc14cac Mon Sep 17 00:00:00 2001 From: Yang Hongbo Date: Fri, 29 Nov 2024 20:36:19 +0800 Subject: [PATCH] fix compabilitiy to newer version of numpy --- pyslm/core.py | 10 +++++----- pyslm/hatching/hatching.py | 4 ++-- pyslm/visualise.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pyslm/core.py b/pyslm/core.py index b9264b6..d5d684c 100644 --- a/pyslm/core.py +++ b/pyslm/core.py @@ -599,7 +599,7 @@ def getBitmapSlice(self, z: float, resolution: float, origin: Optional = None) # Construct a merged grid for this layer (fixed layer) gridSize = (self.geometry.extents[:2] / resolution) + 1 # Padded to prevent rounding issues - sliceImg = np.zeros(gridSize.astype(dtype=np.int), dtype=np.bool) + sliceImg = np.zeros(gridSize.astype(dtype=int), dtype=np.bool) # ToDO for now assume an empty slice -> should be a None Type if z < self.boundingBox[2] and z > self.boundingBox[4]: @@ -608,15 +608,15 @@ def getBitmapSlice(self, z: float, resolution: float, origin: Optional = None) polys = self.getVectorSlice(z) gridSize = (self.geometry.extents[:2] / resolution) + 1 # Padded to prevent rounding issues - sliceImg = np.zeros(gridSize.astype(dtype=np.int), dtype=np.bool) + sliceImg = np.zeros(gridSize.astype(dtype=int), dtype=np.bool) for poly in polys: bounds = self._geometry.bounds localOffset, grid, gridPoints = trimesh.path.raster.rasterize_polygon(poly, resolution) - startPos = np.floor((localOffset - bounds[0, :2]) / resolution).astype(np.int) - endPos = (startPos + grid.shape).astype(np.int) + startPos = np.floor((localOffset - bounds[0, :2]) / resolution).astype(int) + endPos = (startPos + grid.shape).astype(int) sliceImg[startPos[0]:endPos[0], startPos[1]:endPos[1]] += grid - return sliceImg \ No newline at end of file + return sliceImg diff --git a/pyslm/hatching/hatching.py b/pyslm/hatching/hatching.py index 154682e..cb82dbe 100755 --- a/pyslm/hatching/hatching.py +++ b/pyslm/hatching/hatching.py @@ -58,7 +58,7 @@ def getExposurePoints(layer: Layer, models: List[Model], includePowerDeposited: dir = -1.0 * delta / lineDist # Calculate the number of exposure points across the hatch vector based on its length - numPoints = np.ceil(lineDist / pointDistance).astype(np.int) + numPoints = np.ceil(lineDist / pointDistance).astype(int) # Pre-populate some arrays to extrapolate the exposure points from totalPoints = int(np.sum(numPoints)) @@ -102,7 +102,7 @@ def getExposurePoints(layer: Layer, models: List[Model], includePowerDeposited: dir = 1.0 * delta / lineDist # Calculate the number of exposure points across the hatch vector based on its length - numPoints = np.ceil(lineDist / pointDistance).astype(np.int) + numPoints = np.ceil(lineDist / pointDistance).astype(int) # Pre-populate some arrays to extrapolate the exposure points from totalPoints = int(np.sum(numPoints)) diff --git a/pyslm/visualise.py b/pyslm/visualise.py index 8316add..7a59391 100644 --- a/pyslm/visualise.py +++ b/pyslm/visualise.py @@ -424,10 +424,10 @@ def plotHeatMap(part: Part, z: float, exposurePoints: np.ndarray, resolution: fl # Offset the coordinates based on the resolution and the bounding box of the part exposurePoints[:, :2] -= part.boundingBox[:2] + resolution / 2 - expPointTrans = np.floor(exposurePoints[:, :2] / resolution).astype(np.int) + expPointTrans = np.floor(exposurePoints[:, :2] / resolution).astype(int) # Get a bitmap object to work on - bitmapSlice = part.getBitmapSlice(z, resolution).astype(np.int) + bitmapSlice = part.getBitmapSlice(z, resolution).astype(int) slice = np.zeros(bitmapSlice.shape) for i in range(len(expPointTrans)):