Exemplo n.º 1
0
    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()
Exemplo n.º 2
0
    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
        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))
        self._updated()
Exemplo n.º 3
0
    def _updateMeshInfoThreadFunction(self):
        transformedMin = numpy.array([999999999999,999999999999,999999999999], numpy.float32)
        transformedMax = numpy.array([-999999999999,-999999999999,-999999999999], numpy.float32)
        boundarySphere = 0.0
        hull = numpy.zeros((0, 2), numpy.int)
        if self._mesh is not None:
            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)
        elif self._vector is not None:
            matrix2d = numpy.matrix(self._matrix.getA()[0:2,0:2], numpy.float32)
            for p in self._vector.getPaths():
                v = p.getPoints()
                vertexData = (numpy.matrix(v, copy = False) * matrix2d).getA()
                hull = polygon.convexHull(numpy.concatenate((numpy.rint(vertexData).astype(int), hull), 0))
                vertexMin = vertexData.min(0)
                vertexMax = vertexData.max(0)
                for n in xrange(0, 2):
                    transformedMin[n] = min(transformedMin[n], vertexMin[n])
                    transformedMax[n] = max(transformedMax[n], vertexMax[n])
                transformedMin[2] = -1.0
                transformedMax[2] = -1.0
            center = (transformedMin[0:2] + transformedMax[0:2]) / 2.0
            for p in self._vector.getPaths():
                vertexData = p.getPoints()
                centeredData = vertexData - center
                sphere = math.sqrt(numpy.max(centeredData[:, 0] ** 2 + centeredData[:, 1] ** 2))
                boundarySphere = max(boundarySphere, sphere)

        self._vMin = transformedMin
        self._vMax = transformedMax
        self._boundarySphere = boundarySphere
        self._drawOffset = numpy.array([-center[0], -center[1], -transformedMin[2]])

        self._updated()
Exemplo n.º 4
0
    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()