def _updateMeshInfoThreadFunction(self): transformedMin = numpy.array([999999999999,999999999999,999999999999], numpy.float64) transformedMax = numpy.array([-999999999999,-999999999999,-999999999999], numpy.float64) boundarySphere = 0.0 hull = numpy.zeros((0, 2), numpy.int) for v in self._mesh.getVolumes(): vertexData = (numpy.matrix(v.vertexData[::, 0:3], copy = False) * numpy.matrix(self._matrix, numpy.float32)).getA() hull = polygon.convexHull(numpy.concatenate((numpy.rint(vertexData[:,0:2]).astype(int), hull), 0)) vertexMin = vertexData.min(0) vertexMax = vertexData.max(0) for n in xrange(0, 3): transformedMin[n] = min(transformedMin[n], vertexMin[n]) transformedMax[n] = max(transformedMax[n], vertexMax[n]) center = (transformedMin + transformedMax) / 2.0 for v in self._mesh.getVolumes(): vertexData = v.vertexData[::,0:3] centeredData = vertexData - center sphere = math.sqrt(numpy.max(centeredData[:, 0] ** 2 + centeredData[:, 1] ** 2 + centeredData[:, 2] ** 2)) boundarySphere = max(boundarySphere, sphere) self._vMin = transformedMin self._vMax = transformedMax size = transformedMax - transformedMin self._boundarySphere = boundarySphere self._drawOffset = numpy.array([-center[0], -center[1], -transformedMin[2]]) self._convex2dBoundary = polygon.minkowskiHull((hull.astype(numpy.float32) + self._drawOffset[0:2]), numpy.array([[-1,-1],[-1,1],[1,1],[1,-1]],numpy.float32)) head_shape = self._scene.getMachine().getHeadShape() head_min_x, head_min_y = self._scene.getMachine().getHeadSizeMin() nozzle_active_map = 0 for volume in self.getMesh().getVolumes(): nozzle_active_map |= 1 << (volume.getMetaData('setting_extruder_nr', self.getMesh().getMetaData('setting_extruder_nr', 0))) head_hit_shape = None for n in xrange(0, self._scene.getMachine().getMaxNozzles()): if nozzle_active_map & (1 << n): offset = self._scene.getMachine().getNozzleOffset(n) if head_hit_shape is None: head_hit_shape = polygon.minkowskiHull(self._convex2dBoundary, head_shape - offset) else: head_hit_shape = polygon.convexHull(numpy.concatenate((head_hit_shape, polygon.minkowskiHull(self._convex2dBoundary, head_shape - offset)))) self._head_hit_shape = head_hit_shape square_x = head_min_x + size[0] / 2.0 + 1 square_y = head_min_y + size[1] / 2.0 + 1 square = [] for n in xrange(0, self._scene.getMachine().getMaxNozzles()): if nozzle_active_map & (1 << n): offset = self._scene.getMachine().getNozzleOffset(n) square += [[square_x - offset[0], square_y - offset[1]], [square_x - offset[0], -square_y - offset[1]], [-square_x - offset[0], -square_y - offset[1]], [-square_x - offset[0], square_y - offset[1]]] square = polygon.convexHull(square) self._head_hit_shape_min_no_extension = polygon.clipConvex(self._head_hit_shape, square) self.updatePrintExtension() self._updated()
def _updateMeshInfo(self): transformedMin = numpy.array([999999999999,999999999999,999999999999], numpy.float64) transformedMax = numpy.array([-999999999999,-999999999999,-999999999999], numpy.float64) boundarySphere = 0.0 hull = numpy.zeros((0, 2), numpy.int) for v in self._mesh.getVolumes(): vertexData = (numpy.matrix(v.vertexData[::, 0:3], copy = False) * numpy.matrix(self._matrix, numpy.float32)).getA() hull = polygon.convexHull(numpy.concatenate((numpy.rint(vertexData[:,0:2]).astype(int), hull), 0)) vertexMin = vertexData.min(0) vertexMax = vertexData.max(0) for n in xrange(0, 3): transformedMin[n] = min(transformedMin[n], vertexMin[n]) transformedMax[n] = max(transformedMax[n], vertexMax[n]) center = (transformedMin + transformedMax) / 2.0 for v in self._mesh.getVolumes(): vertexData = v.vertexData[::,0:3] centeredData = vertexData - center sphere = math.sqrt(numpy.max(centeredData[:, 0] ** 2 + centeredData[:, 1] ** 2 + centeredData[:, 2] ** 2)) boundarySphere = max(boundarySphere, sphere) self._vMin = transformedMin self._vMax = transformedMax size = transformedMax - transformedMin self._boundarySphere = boundarySphere self._drawOffset = numpy.array([-center[0], -center[1], -transformedMin[2]]) self._convex2dBoundary = polygon.minkowskiHull((hull.astype(numpy.float32) + self._drawOffset[0:2]), numpy.array([[-1,-1],[-1,1],[1,1],[1,-1]],numpy.float32)) head_shape = self._scene.getMachine().getHeadShape() head_min_x, head_min_y = self._scene.getMachine().getHeadSizeMin() self._head_hit_shape = polygon.minkowskiHull(self._convex2dBoundary, head_shape) square_x = head_min_x + size[0] / 2.0 + 1 square_y = head_min_y + size[1] / 2.0 + 1 square = numpy.array([[square_x, square_y], [square_x, -square_y], [-square_x, -square_y], [-square_x, square_y]]) self._head_hit_shape_min_no_extension = polygon.clipConvex(self._head_hit_shape, square) self.updatePrintExtension() self._updated()