Exemple #1
0
	def parseLine(self, line):
		"Parse a gcode line and add it to the mill skein."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
		if len(splitLine) < 1:
			return
		firstWord = splitLine[0]
		if firstWord == 'G1':
			location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
			if self.isExtruderActive:
				self.average.addValue(location.z)
				if self.oldLocation != None:
					euclidean.addValueSegmentToPixelTable( self.oldLocation.dropAxis(), location.dropAxis(), self.aroundPixelTable, None, self.aroundWidth )
			self.oldLocation = location
		elif firstWord == 'M101':
			self.isExtruderActive = True
		elif firstWord == 'M103':
			self.isExtruderActive = False
		elif firstWord == '(<layer>':
			self.layerCount.printProgressIncrement('mill')
			self.aroundPixelTable = {}
			self.average.reset()
		elif firstWord == '(</layer>)':
			if len( self.boundaryLayers ) > self.layerIndex:
				self.addMillThreads()
			self.layerIndex += 1
		self.distanceFeedRate.addLine(line)
def isAddedPointOnPathFree(path, pixelTable, point, pointIndex, width):
    'Determine if the point added to a path is intersecting the pixel table or the path.'
    if pointIndex > 0 and pointIndex < len(path):
        if isSharpCorner((path[pointIndex - 1]), point, (path[pointIndex])):
            return False
    pointIndexMinusOne = pointIndex - 1
    if pointIndexMinusOne >= 0:
        maskTable = {}
        begin = path[ pointIndexMinusOne ]
        if pointIndex < len(path):
            end = path[pointIndex]
            euclidean.addValueSegmentToPixelTable(begin, end, maskTable, None, width)
        segmentTable = {}
        euclidean.addSegmentToPixelTable(point, begin, segmentTable, 0.0, 2.0, width)
        if euclidean.isPixelTableIntersecting(pixelTable, segmentTable, maskTable):
            return False
        if isAddedPointOnPathIntersectingPath(begin, path, point, pointIndexMinusOne):
            return False
    if pointIndex < len(path):
        maskTable = {}
        begin = path[pointIndex]
        if pointIndexMinusOne >= 0:
            end = path[ pointIndexMinusOne ]
            euclidean.addValueSegmentToPixelTable(begin, end, maskTable, None, width)
        segmentTable = {}
        euclidean.addSegmentToPixelTable(point, begin, segmentTable, 0.0, 2.0, width)
        if euclidean.isPixelTableIntersecting(pixelTable, segmentTable, maskTable):
            return False
        if isAddedPointOnPathIntersectingPath(begin, path, point, pointIndex):
            return False
    return True
Exemple #3
0
 def parseLine(self, line):
     'Parse a gcode line and add it to the mill skein.'
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if firstWord == 'G1':
         location = gcodec.getLocationFromSplitLine(self.oldLocation,
                                                    splitLine)
         if self.isExtruderActive:
             self.average.addValue(location.z)
             if self.oldLocation != None:
                 euclidean.addValueSegmentToPixelTable(
                     self.oldLocation.dropAxis(), location.dropAxis(),
                     self.aroundPixelTable, None, self.aroundWidth)
         self.oldLocation = location
     elif firstWord == 'M101':
         self.isExtruderActive = True
     elif firstWord == 'M103':
         self.isExtruderActive = False
     elif firstWord == '(<layer>':
         settings.printProgress(self.layerIndex, 'mill')
         self.aroundPixelTable = {}
         self.average.reset()
     elif firstWord == '(</layer>)':
         if len(self.boundaryLayers) > self.layerIndex:
             self.addMillThreads()
         self.layerIndex += 1
     self.distanceFeedRate.addLine(line)
Exemple #4
0
 def addSegmentToPixelTables(self, location, maskPixelTable, oldLocation):
     "Add the segment to the layer and mask table."
     #		segmentTable = {}
     euclidean.addValueSegmentToPixelTable(oldLocation.dropAxis(2),
                                           location.dropAxis(2),
                                           self.layerPixelTable, None,
                                           self.layerPixelWidth)
Exemple #5
0
	def getConnectionIsCloseWithoutOverlap( self, location, path ):
		"Determine if the connection is close enough and does not overlap another thread."
		if len( path ) < 1:
			return False
		locationComplex = location.dropAxis( 2 )
		segment = locationComplex - path[ - 1 ]
		segmentLength = abs( segment )
		if segmentLength <= 0.0:
			return True
		segment /= segmentLength
		distance = self.connectingStepLength
		segmentEndLength = segmentLength - self.connectingStepLength
		while distance < segmentEndLength:
			alongPoint = distance * segment + path[ - 1 ]
			if not euclidean.isPointInsideLoops( self.boundaryLoops, alongPoint ):
				return False
			distance += self.connectingStepLength
#		removedLayerPixelTable = self.layerPixelTable.copy()
#		if self.oldLocation in self.maskPixelTableTable:
#			euclidean.removePixelTableFromPixelTable( self.maskPixelTableTable[ self.oldLocation ], removedLayerPixelTable )
#		euclidean.addPathToPixelTable( path[ : - 2 ], removedLayerPixelTable, None, self.layerPixelWidth )
		segmentTable = {}
		euclidean.addSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, 2.0, 2.0, self.layerPixelWidth )
#		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth )
#		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, segmentTable, None, self.layerPixelWidth )
#		maskPixelTable = {}
#		if location in self.maskPixelTableTable:
#			maskPixelTable = self.maskPixelTableTable[ location ]
		if euclidean.isPixelTableIntersecting( self.layerPixelTable, segmentTable, {} ):
#		if euclidean.isPixelTableIntersecting( removedLayerPixelTable, segmentTable, {} ):
			return False
		euclidean.addValueSegmentToPixelTable( path[ - 1 ], locationComplex, self.layerPixelTable, None, self.layerPixelWidth )
#		euclidean.addPixelTableToPixelTable( segmentTable, self.layerPixelTable )
		return True
Exemple #6
0
	def getConnectionIsCloseWithoutOverlap( self, location, path ):
		"Determine if the connection is close enough and does not overlap another thread."
		if len(path) < 1:
			return False
		locationComplex = location.dropAxis()
		segment = locationComplex - path[-1]
		segmentLength = abs(segment)
		if segmentLength <= 0.0:
			return True
		if segmentLength > self.maximumConnectionDistance:
			return False
		segmentTable = {}
		euclidean.addSegmentToPixelTable( path[-1], locationComplex, segmentTable, 2.0, 2.0, self.layerPixelWidth )
		if euclidean.isPixelTableIntersecting( self.layerPixelTable, segmentTable, {} ):
			return False
		euclidean.addValueSegmentToPixelTable( path[-1], locationComplex, self.layerPixelTable, None, self.layerPixelWidth )
		return True
Exemple #7
0
	def getConnectionIsCloseWithoutOverlap( self, location, path ):
		"Determine if the connection is close enough and does not overlap another thread."
		if len(path) < 1:
			return False
		locationComplex = location.dropAxis()
		segment = locationComplex - path[-1]
		segmentLength = abs(segment)
		if segmentLength <= 0.0:
			return True
		if segmentLength > self.maximumConnectionDistance:
			return False
		segmentTable = {}
		euclidean.addSegmentToPixelTable( path[-1], locationComplex, segmentTable, 2.0, 2.0, self.layerPixelWidth )
		if euclidean.isPixelTableIntersecting( self.layerPixelTable, segmentTable, {} ):
			return False
		euclidean.addValueSegmentToPixelTable( path[-1], locationComplex, self.layerPixelTable, None, self.layerPixelWidth )
		return True
Exemple #8
0
    def getConnectionIsCloseWithoutOverlap(self, location, path):
        "Determine if the connection is close enough and does not overlap another thread."
        if len(path) < 1:
            return False
        locationComplex = location.dropAxis(2)
        segment = locationComplex - path[-1]
        segmentLength = abs(segment)
        if segmentLength <= 0.0:
            return True
        if segmentLength > self.maximumConnectionDistance:
            return False
        segment /= segmentLength
        distance = self.connectingStepLength
        segmentEndLength = segmentLength - self.connectingStepLength
        while distance < segmentEndLength:
            alongPoint = distance * segment + path[-1]
            if not euclidean.getIsInFilledRegion(self.boundaryLoops,
                                                 alongPoint):
                return False
            distance += self.connectingStepLength


#		removedLayerPixelTable = self.layerPixelTable.copy()
#		if self.oldLocation in self.maskPixelTableTable:
#			euclidean.removePixelTableFromPixelTable( self.maskPixelTableTable[ self.oldLocation ], removedLayerPixelTable )
#		euclidean.addPathToPixelTable( path[ : - 2 ], removedLayerPixelTable, None, self.layerPixelWidth )
        segmentTable = {}
        euclidean.addSegmentToPixelTable(path[-1], locationComplex,
                                         segmentTable, 2.0, 2.0,
                                         self.layerPixelWidth)
        #		euclidean.addValueSegmentToPixelTable( path[-1], locationComplex, segmentTable, None, self.layerPixelWidth )
        #		euclidean.addValueSegmentToPixelTable( path[-1], locationComplex, segmentTable, None, self.layerPixelWidth )
        #		maskPixelTable = {}
        #		if location in self.maskPixelTableTable:
        #			maskPixelTable = self.maskPixelTableTable[ location ]
        if euclidean.isPixelTableIntersecting(self.layerPixelTable,
                                              segmentTable, {}):
            #		if euclidean.isPixelTableIntersecting( removedLayerPixelTable, segmentTable, {} ):
            return False
        euclidean.addValueSegmentToPixelTable(path[-1], locationComplex,
                                              self.layerPixelTable, None,
                                              self.layerPixelWidth)
        #		euclidean.addPixelTableToPixelTable( segmentTable, self.layerPixelTable )
        return True
def isSidePointAdded(pixelTable, closestPath, closestPathIndex, closestPointIndex, layerExtrusionWidth, removedEndpointPoint, width):
    'Add side point along with the closest removed endpoint to the path, with minimal twisting.'
    if closestPointIndex <= 0 or closestPointIndex >= len(closestPath):
        return False
    pointBegin = closestPath[ closestPointIndex - 1 ]
    pointEnd = closestPath[ closestPointIndex ]
    removedEndpointPoint = removedEndpointPoint
    closest = pointBegin
    farthest = pointEnd
    removedMinusClosest = removedEndpointPoint - pointBegin
    removedMinusClosestLength = abs(removedMinusClosest)
    if removedMinusClosestLength <= 0.0:
        return False
    removedMinusOther = removedEndpointPoint - pointEnd
    removedMinusOtherLength = abs(removedMinusOther)
    if removedMinusOtherLength <= 0.0:
        return False
    insertPointAfter = None
    insertPointBefore = None
    if removedMinusOtherLength < removedMinusClosestLength:
        closest = pointEnd
        farthest = pointBegin
        removedMinusClosest = removedMinusOther
        removedMinusClosestLength = removedMinusOtherLength
        insertPointBefore = removedEndpointPoint
    else:
        insertPointAfter = removedEndpointPoint
    removedMinusClosestNormalized = removedMinusClosest / removedMinusClosestLength
    perpendicular = removedMinusClosestNormalized * complex(0.0, layerExtrusionWidth)
    sidePoint = removedEndpointPoint + perpendicular
    #extra check in case the line to the side point somehow slips by the line to the perpendicular
    sidePointOther = removedEndpointPoint - perpendicular
    if abs(sidePoint - farthest) > abs(sidePointOther - farthest):
        perpendicular = -perpendicular
        sidePoint = sidePointOther
    maskTable = {}
    closestSegmentTable = {}
    toPerpendicularTable = {}
    euclidean.addValueSegmentToPixelTable(pointBegin, pointEnd, maskTable, None, width)
    euclidean.addValueSegmentToPixelTable(closest, removedEndpointPoint, closestSegmentTable, None, width)
    euclidean.addValueSegmentToPixelTable(sidePoint, farthest, toPerpendicularTable, None, width)
    if euclidean.isPixelTableIntersecting(pixelTable, toPerpendicularTable, maskTable) or euclidean.isPixelTableIntersecting(closestSegmentTable, toPerpendicularTable, maskTable):
        sidePoint = removedEndpointPoint - perpendicular
        toPerpendicularTable = {}
        euclidean.addValueSegmentToPixelTable(sidePoint, farthest, toPerpendicularTable, None, width)
        if euclidean.isPixelTableIntersecting(pixelTable, toPerpendicularTable, maskTable) or euclidean.isPixelTableIntersecting(closestSegmentTable, toPerpendicularTable, maskTable):
            return False
    if insertPointBefore != None:
        addPointOnPathIfFree(closestPath, closestPathIndex, pixelTable, insertPointBefore, closestPointIndex, width)
    addPointOnPathIfFree(closestPath, closestPathIndex, pixelTable, sidePoint, closestPointIndex, width)
    if insertPointAfter != None:
        addPointOnPathIfFree(closestPath, closestPathIndex, pixelTable, insertPointAfter, closestPointIndex, width)
    return True
def isAddedPointOnPathFree(path, pixelTable, point, pointIndex, width):
    'Determine if the point added to a path is intersecting the pixel table or the path.'
    if pointIndex > 0 and pointIndex < len(path):
        if isSharpCorner((path[pointIndex - 1]), point, (path[pointIndex])):
            return False
    pointIndexMinusOne = pointIndex - 1
    if pointIndexMinusOne >= 0:
        maskTable = {}
        begin = path[pointIndexMinusOne]
        if pointIndex < len(path):
            end = path[pointIndex]
            euclidean.addValueSegmentToPixelTable(begin, end, maskTable, None,
                                                  width)
        segmentTable = {}
        euclidean.addSegmentToPixelTable(point, begin, segmentTable, 0.0, 2.0,
                                         width)
        if euclidean.isPixelTableIntersecting(pixelTable, segmentTable,
                                              maskTable):
            return False
        if isAddedPointOnPathIntersectingPath(begin, path, point,
                                              pointIndexMinusOne):
            return False
    if pointIndex < len(path):
        maskTable = {}
        begin = path[pointIndex]
        if pointIndexMinusOne >= 0:
            end = path[pointIndexMinusOne]
            euclidean.addValueSegmentToPixelTable(begin, end, maskTable, None,
                                                  width)
        segmentTable = {}
        euclidean.addSegmentToPixelTable(point, begin, segmentTable, 0.0, 2.0,
                                         width)
        if euclidean.isPixelTableIntersecting(pixelTable, segmentTable,
                                              maskTable):
            return False
        if isAddedPointOnPathIntersectingPath(begin, path, point, pointIndex):
            return False
    return True
def addPointOnPath(path, pathIndex, pixelTable, point, pointIndex, width):
    'Add a point to a path and the pixel table.'
    pointIndexMinusOne = pointIndex - 1
    if pointIndex < len(path) and pointIndexMinusOne >= 0:
        segmentTable = {}
        begin = path[ pointIndexMinusOne ]
        end = path[pointIndex]
        euclidean.addValueSegmentToPixelTable(begin, end, segmentTable, pathIndex, width)
        euclidean.removePixelTableFromPixelTable(segmentTable, pixelTable)
    if pointIndexMinusOne >= 0:
        begin = path[ pointIndexMinusOne ]
        euclidean.addValueSegmentToPixelTable(begin, point, pixelTable, pathIndex, width)
    if pointIndex < len(path):
        end = path[pointIndex]
        euclidean.addValueSegmentToPixelTable(point, end, pixelTable, pathIndex, width)
    path.insert(pointIndex, point)
def addPointOnPath(path, pathIndex, pixelTable, point, pointIndex, width):
    'Add a point to a path and the pixel table.'
    pointIndexMinusOne = pointIndex - 1
    if pointIndex < len(path) and pointIndexMinusOne >= 0:
        segmentTable = {}
        begin = path[pointIndexMinusOne]
        end = path[pointIndex]
        euclidean.addValueSegmentToPixelTable(begin, end, segmentTable,
                                              pathIndex, width)
        euclidean.removePixelTableFromPixelTable(segmentTable, pixelTable)
    if pointIndexMinusOne >= 0:
        begin = path[pointIndexMinusOne]
        euclidean.addValueSegmentToPixelTable(begin, point, pixelTable,
                                              pathIndex, width)
    if pointIndex < len(path):
        end = path[pointIndex]
        euclidean.addValueSegmentToPixelTable(point, end, pixelTable,
                                              pathIndex, width)
    path.insert(pointIndex, point)
Exemple #13
0
	def addSegmentToPixelTables(self, location, oldLocation):
		"Add the segment to the layer and mask table."
		euclidean.addValueSegmentToPixelTable(oldLocation, location, self.layerPixelTable, None, self.layerPixelWidth)
Exemple #14
0
 def addSegmentToPixelTables(self, location, oldLocation):
     "Add the segment to the layer and mask table."
     euclidean.addValueSegmentToPixelTable(oldLocation, location,
                                           self.layerPixelTable, None,
                                           self.layerPixelWidth)
Exemple #15
0
	def addSegmentToPixelTables( self, location, maskPixelTable, oldLocation ):
		"Add the segment to the layer and mask table."
#		segmentTable = {}
		euclidean.addValueSegmentToPixelTable( oldLocation.dropAxis( 2 ), location.dropAxis( 2 ), self.layerPixelTable, None, self.layerPixelWidth )
def isSidePointAdded(pixelTable, closestPath, closestPathIndex,
                     closestPointIndex, layerExtrusionWidth,
                     removedEndpointPoint, width):
    'Add side point along with the closest removed endpoint to the path, with minimal twisting.'
    if closestPointIndex <= 0 or closestPointIndex >= len(closestPath):
        return False
    pointBegin = closestPath[closestPointIndex - 1]
    pointEnd = closestPath[closestPointIndex]
    removedEndpointPoint = removedEndpointPoint
    closest = pointBegin
    farthest = pointEnd
    removedMinusClosest = removedEndpointPoint - pointBegin
    removedMinusClosestLength = abs(removedMinusClosest)
    if removedMinusClosestLength <= 0.0:
        return False
    removedMinusOther = removedEndpointPoint - pointEnd
    removedMinusOtherLength = abs(removedMinusOther)
    if removedMinusOtherLength <= 0.0:
        return False
    insertPointAfter = None
    insertPointBefore = None
    if removedMinusOtherLength < removedMinusClosestLength:
        closest = pointEnd
        farthest = pointBegin
        removedMinusClosest = removedMinusOther
        removedMinusClosestLength = removedMinusOtherLength
        insertPointBefore = removedEndpointPoint
    else:
        insertPointAfter = removedEndpointPoint
    removedMinusClosestNormalized = removedMinusClosest / removedMinusClosestLength
    perpendicular = removedMinusClosestNormalized * complex(
        0.0, layerExtrusionWidth)
    sidePoint = removedEndpointPoint + perpendicular
    #extra check in case the line to the side point somehow slips by the line to the perpendicular
    sidePointOther = removedEndpointPoint - perpendicular
    if abs(sidePoint - farthest) > abs(sidePointOther - farthest):
        perpendicular = -perpendicular
        sidePoint = sidePointOther
    maskTable = {}
    closestSegmentTable = {}
    toPerpendicularTable = {}
    euclidean.addValueSegmentToPixelTable(pointBegin, pointEnd, maskTable,
                                          None, width)
    euclidean.addValueSegmentToPixelTable(closest, removedEndpointPoint,
                                          closestSegmentTable, None, width)
    euclidean.addValueSegmentToPixelTable(sidePoint, farthest,
                                          toPerpendicularTable, None, width)
    if euclidean.isPixelTableIntersecting(
            pixelTable, toPerpendicularTable,
            maskTable) or euclidean.isPixelTableIntersecting(
                closestSegmentTable, toPerpendicularTable, maskTable):
        sidePoint = removedEndpointPoint - perpendicular
        toPerpendicularTable = {}
        euclidean.addValueSegmentToPixelTable(sidePoint, farthest,
                                              toPerpendicularTable, None,
                                              width)
        if euclidean.isPixelTableIntersecting(
                pixelTable, toPerpendicularTable,
                maskTable) or euclidean.isPixelTableIntersecting(
                    closestSegmentTable, toPerpendicularTable, maskTable):
            return False
    if insertPointBefore != None:
        addPointOnPathIfFree(closestPath, closestPathIndex, pixelTable,
                             insertPointBefore, closestPointIndex, width)
    addPointOnPathIfFree(closestPath, closestPathIndex, pixelTable, sidePoint,
                         closestPointIndex, width)
    if insertPointAfter != None:
        addPointOnPathIfFree(closestPath, closestPathIndex, pixelTable,
                             insertPointAfter, closestPointIndex, width)
    return True