示例#1
0
	def getDistanceToThreadBeginningAfterThreadEnd( self, remainingDistance ):
		"Get the distance to the thread beginning after the end of this thread."
		extruderOnReached = False
		line = self.lines[ self.lineIndex ]
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		lastThreadLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		threadEndReached = False
		totalDistance = 0.0
		for afterIndex in xrange( self.lineIndex + 1, len( self.lines ) ):
			line = self.lines[ afterIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'G1':
				location = gcodec.getLocationFromSplitLine( lastThreadLocation, splitLine )
				if threadEndReached:
					totalDistance += location.distance( lastThreadLocation )
					if totalDistance >= remainingDistance:
						return None
					if extruderOnReached:
						return totalDistance
				lastThreadLocation = location
			elif firstWord == 'M101':
				extruderOnReached = True
			elif firstWord == 'M103':
				threadEndReached = True
		return None
示例#2
0
	def isNextExtruderOn( self ):
		"Determine if there is an extruder on command before a move command."
		line = self.lines[ self.lineIndex ]
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		for afterIndex in xrange( self.lineIndex + 1, len( self.lines ) ):
			line = self.lines[ afterIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'G1' or firstWord == 'M103':
				return False
			elif firstWord == 'M101':
				return True
		return False
示例#3
0
文件: jitter.py 项目: jmil/SkeinFox
 def isNextExtruderOn(self):
     "Determine if there is an extruder on command before a move command."
     line = self.lines[self.lineIndex]
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     for afterIndex in xrange(self.lineIndex + 1, len(self.lines)):
         line = self.lines[afterIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if firstWord == "G1" or firstWord == "M103":
             return False
         elif firstWord == "M101":
             return True
     return False
示例#4
0
	def parseBoundaries( self ):
		"Parse the boundaries and add them to the boundary layers."
		boundaryLoop = None
		boundaryLayer = None
		for line in self.lines[ self.lineIndex : ]:
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if len( self.shutdownLines ) > 0:
				self.shutdownLines.append( line )
			if firstWord == '(</boundaryPerimeter>)':
				boundaryLoop = None
			elif firstWord == '(<boundaryPoint>':
				location = gcodec.getLocationFromSplitLine( None, splitLine )
				if boundaryLoop == None:
					boundaryLoop = []
					boundaryLayer.loops.append( boundaryLoop )
				boundaryLoop.append( location.dropAxis( 2 ) )
			elif firstWord == '(<layer>':
				boundaryLayer = euclidean.LoopLayer( float( splitLine[ 1 ] ) )
				self.boundaryLayers.append( boundaryLayer )
			elif firstWord == '(</extrusion>)':
				self.shutdownLines = [ line ]
		for boundaryLayer in self.boundaryLayers:
			if not euclidean.isWiddershins( boundaryLayer.loops[ 0 ] ):
				boundaryLayer.loops[ 0 ].reverse()
		self.boundaryReverseLayers = self.boundaryLayers[ : ]
		self.boundaryReverseLayers.reverse()
示例#5
0
 def parseInitialization(self):
     "Parse gcode initialization and store the parameters."
     for self.lineIndex in xrange(len(self.lines)):
         line = self.lines[self.lineIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         self.distanceFeedRate.parseSplitLine(firstWord, splitLine)
         if firstWord == '(</extruderInitialization>)':
             self.distanceFeedRate.addLine(
                 '(<procedureDone> feed </procedureDone>)')
             return
         elif firstWord == '(<perimeterWidth>':
             self.absolutePerimeterWidth = abs(float(splitLine[1]))
             self.distanceFeedRate.addTagBracketedLine(
                 'maximumZDrillFeedRatePerSecond',
                 self.distanceFeedRate.maximumZDrillFeedRatePerSecond)
             self.distanceFeedRate.addTagBracketedLine(
                 'maximumZTravelFeedRatePerSecond',
                 self.distanceFeedRate.maximumZTravelFeedRatePerSecond)
             self.distanceFeedRate.addTagBracketedLine(
                 'operatingFeedRatePerSecond', self.feedRatePerSecond)
             self.distanceFeedRate.addTagBracketedLine(
                 'travelFeedRatePerSecond',
                 self.feedRepository.travelFeedRatePerSecond.value)
         self.distanceFeedRate.addLine(line)
示例#6
0
	def getTransferClosestSurroundingLoopLines( self, oldOrderedLocation, remainingSurroundingLoops ):
		"Get and transfer the closest remaining surrounding loop."
		if len( remainingSurroundingLoops ) > 0:
			oldOrderedLocation.z = remainingSurroundingLoops[ 0 ].z
		closestDistance = 999999999999999999.0
		closestSurroundingLoop = None
		for remainingSurroundingLoop in remainingSurroundingLoops:
			distance = euclidean.getNearestDistanceIndex( oldOrderedLocation.dropAxis( 2 ), remainingSurroundingLoop.boundary ).distance
			if distance < closestDistance:
				closestDistance = distance
				closestSurroundingLoop = remainingSurroundingLoop
		remainingSurroundingLoops.remove( closestSurroundingLoop )
		hasTravelledHighRoad = False
		for line in closestSurroundingLoop.lines:
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'G1':
				location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
				if not hasTravelledHighRoad:
					hasTravelledHighRoad = True
					self.addHighThread( location )
				if location.z > self.highestZ:
					self.highestZ = location.z
				self.oldLocation = location
			self.distanceFeedRate.addLine( line )
		return closestSurroundingLoop
示例#7
0
	def setLayerPixelTable( self ):
		"Parse a gcode line and add it to the clip skein."
		boundaryLoop = None
		extruderActive = False
		maskPixelTable = {}
		self.boundaryLoops = []
		self.maskPixelTableTable = {}
		self.layerPixelTable = {}
		oldLocation = self.oldLocation
		for afterIndex in xrange( self.lineIndex + 1, len( self.lines ) ):
			line = self.lines[ afterIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'G1':
				location = gcodec.getLocationFromSplitLine( oldLocation, splitLine )
				if extruderActive and oldLocation != None:
					self.addSegmentToPixelTables( location, maskPixelTable, oldLocation )
				oldLocation = location
			elif firstWord == 'M101':
				extruderActive = True
			elif firstWord == 'M103':
				extruderActive = False
				maskPixelTable = {}
			elif firstWord == '(</boundaryPerimeter>)':
				boundaryLoop = None
			elif firstWord == '(<boundaryPoint>':
				if boundaryLoop == None:
					boundaryLoop = []
					self.boundaryLoops.append( boundaryLoop )
				location = gcodec.getLocationFromSplitLine( None, splitLine )
				boundaryLoop.append( location.dropAxis( 2 ) )
			elif firstWord == '(</layer>)':
				return
示例#8
0
 def getTransferClosestSurroundingLoopLines(self, oldOrderedLocation,
                                            remainingSurroundingLoops):
     "Get and transfer the closest remaining surrounding loop."
     if len(remainingSurroundingLoops) > 0:
         oldOrderedLocation.z = remainingSurroundingLoops[0].z
     closestDistance = 999999999999999999.0
     closestSurroundingLoop = None
     for remainingSurroundingLoop in remainingSurroundingLoops:
         distance = euclidean.getNearestDistanceIndex(
             oldOrderedLocation.dropAxis(2),
             remainingSurroundingLoop.boundary).distance
         if distance < closestDistance:
             closestDistance = distance
             closestSurroundingLoop = remainingSurroundingLoop
     remainingSurroundingLoops.remove(closestSurroundingLoop)
     hasTravelledHighRoad = False
     for line in closestSurroundingLoop.lines:
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if firstWord == 'G1':
             location = gcodec.getLocationFromSplitLine(
                 self.oldLocation, splitLine)
             if not hasTravelledHighRoad:
                 hasTravelledHighRoad = True
                 self.addHighThread(location)
             if location.z > self.highestZ:
                 self.highestZ = location.z
             self.oldLocation = location
         self.distanceFeedRate.addLine(line)
     return closestSurroundingLoop
示例#9
0
	def parseLine( self, line ):
		"Parse a gcode line."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		firstWord = gcodec.getFirstWord( splitLine )
		if len( firstWord ) < 1:
			return
		firstLetter = firstWord[ 0 ]
		if firstLetter == '(':
			return
		if firstWord != 'G1' and firstWord != 'G2' and firstWord != 'G3':
			self.addLine( line )
			return
		lineStringIO = cStringIO.StringIO()
		lineStringIO.write( firstWord )
		self.addCharacterInteger( 'I', lineStringIO, 0.0, splitLine, self.gcodeStepRepository.xStepLength.value )
		self.addCharacterInteger( 'J', lineStringIO, 0.0, splitLine, self.gcodeStepRepository.yStepLength.value )
		self.addCharacterInteger( 'R', lineStringIO, 0.0, splitLine, self.gcodeStepRepository.radiusStepLength.value )
		self.addCharacterInteger( 'X', lineStringIO, self.gcodeStepRepository.xOffset.value, splitLine, self.gcodeStepRepository.xStepLength.value )
		self.addCharacterInteger( 'Y', lineStringIO, self.gcodeStepRepository.yOffset.value, splitLine, self.gcodeStepRepository.yStepLength.value )
		zString = getCharacterIntegerString( 'Z', self.gcodeStepRepository.zOffset.value, splitLine, self.gcodeStepRepository.zStepLength.value )
		feedRateString = getCharacterIntegerString( 'F', 0.0, splitLine, self.gcodeStepRepository.feedRateStepLength.value )
		if zString != None:
			if zString != self.oldZString or self.gcodeStepRepository.addZEvenWhenUnchanging.value:
				self.addStringToLine( lineStringIO, zString )
		if feedRateString != None:
			if feedRateString != self.oldFeedRateString or self.gcodeStepRepository.addFeedRateEvenWhenUnchanging.value:
				self.addStringToLine( lineStringIO, feedRateString )
		self.addLine( lineStringIO.getvalue() )
		self.oldFeedRateString = feedRateString
		self.oldZString = zString
示例#10
0
文件: speed.py 项目: jmil/SkeinFox
 def parseInitialization(self):
     "Parse gcode initialization and store the parameters."
     for self.lineIndex in xrange(len(self.lines)):
         line = self.lines[self.lineIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         self.distanceFeedRate.parseSplitLine(firstWord, splitLine)
         if firstWord == "(<layerThickness>":
             self.layerThickness = float(splitLine[1])
         elif firstWord == "(</extruderInitialization>)":
             self.distanceFeedRate.addLine("(<procedureDone> speed </procedureDone>)")
             return
         elif firstWord == "(<perimeterWidth>":
             self.absolutePerimeterWidth = abs(float(splitLine[1]))
             self.distanceFeedRate.addTagBracketedLine(
                 "maximumZDrillFeedRatePerSecond", self.distanceFeedRate.maximumZDrillFeedRatePerSecond
             )
             self.distanceFeedRate.addTagBracketedLine(
                 "maximumZTravelFeedRatePerSecond", self.distanceFeedRate.maximumZTravelFeedRatePerSecond
             )
             self.distanceFeedRate.addTagBracketedLine("operatingFeedRatePerSecond", self.feedRatePerSecond)
             if self.speedRepository.addFlowRate.value:
                 self.distanceFeedRate.addTagBracketedLine(
                     "operatingFlowRate", self.speedRepository.flowRateSetting.value
                 )
             orbitalFeedRatePerSecond = (
                 self.feedRatePerSecond * self.speedRepository.orbitalFeedRateOverOperatingFeedRate.value
             )
             self.distanceFeedRate.addTagBracketedLine("orbitalFeedRatePerSecond", orbitalFeedRatePerSecond)
             self.distanceFeedRate.addTagBracketedLine(
                 "travelFeedRatePerSecond", self.speedRepository.travelFeedRatePerSecond.value
             )
         self.distanceFeedRate.addLine(line)
示例#11
0
	def getNext( self ):
		"Get next line going backward or raise exception."
		while self.lineIndex > 3:
			if self.lineIndex == self.firstLineIndex:
				raise StopIteration, "You've reached the end of the line."
			if self.firstLineIndex == None:
				self.firstLineIndex = self.lineIndex
			nextLineIndex = self.lineIndex - 1
			line = self.lines[ self.lineIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'M103':
				if self.isLoop:
					nextLineIndex = self.getIndexBeforeNextDeactivate()
				else:
					raise StopIteration, "You've reached the end of the line."
			if firstWord == 'G1':
				if self.isBeforeExtrusion():
					if self.isLoop:
						nextLineIndex = self.getIndexBeforeNextDeactivate()
					else:
						raise StopIteration, "You've reached the end of the line."
				else:
					self.lineIndex = nextLineIndex
					return line
			self.lineIndex = nextLineIndex
		raise StopIteration, "You've reached the end of the line."
示例#12
0
	def getSplodgeLineGivenDistance( self, feedRateMinute, line, liftOverExtraThickness, location, startupDistance ):
		"Add the splodge line."
		locationComplex = location.dropAxis( 2 )
		relativeStartComplex = None
		nextLocationComplex = self.getNextActiveLocationComplex()
		if nextLocationComplex != None:
			if nextLocationComplex != locationComplex:
				relativeStartComplex = locationComplex - nextLocationComplex
		if relativeStartComplex == None:
			relativeStartComplex = complex( 19.9, 9.9 )
			if self.oldLocation != None:
				oldLocationComplex = self.oldLocation.dropAxis( 2 )
				if oldLocationComplex != locationComplex:
					relativeStartComplex = oldLocationComplex - locationComplex
		relativeStartComplex *= startupDistance / abs( relativeStartComplex )
		startComplex = self.getStartInsideBoundingRectangle( locationComplex, relativeStartComplex )
		feedRateMultiplier = feedRateMinute / self.operatingFeedRatePerSecond / 60.0
		splodgeLayerThickness = self.layerThickness / math.sqrt( feedRateMultiplier )
		extraLayerThickness = splodgeLayerThickness - self.layerThickness
		lift = extraLayerThickness * liftOverExtraThickness
		startLine = self.distanceFeedRate.getLinearGcodeMovementWithFeedRate( self.feedRateMinute, startComplex, location.z + lift )
		self.addLineUnlessIdenticalReactivate( startLine )
		self.addLineUnlessIdenticalReactivate( 'M101' )
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		lineLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		self.distanceFeedRate.addGcodeMovementZWithFeedRate( feedRateMinute, locationComplex, lineLocation.z + lift )
		return ''
示例#13
0
	def parseLine( self, line ):
		"Parse a gcode line."
		binary16ByteRepository = self.binary16ByteRepository
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		firstWord = gcodec.getFirstWord( splitLine )
		if len( firstWord ) < 1:
			return
		firstLetter = firstWord[ 0 ]
		if firstLetter == '(':
			return
		feedRateInteger = getIntegerFromCharacterLengthLineOffset( 'F', 0.0, splitLine, binary16ByteRepository.feedRateStepLength.value )
		iInteger = getIntegerFromCharacterLengthLineOffset( 'I', 0.0, splitLine, binary16ByteRepository.xStepLength.value )
		jInteger = getIntegerFromCharacterLengthLineOffset( 'J', 0.0, splitLine, binary16ByteRepository.yStepLength.value )
		xInteger = getIntegerFromCharacterLengthLineOffset( 'X', binary16ByteRepository.xOffset.value, splitLine, binary16ByteRepository.xStepLength.value )
		yInteger = getIntegerFromCharacterLengthLineOffset( 'Y', binary16ByteRepository.yOffset.value, splitLine, binary16ByteRepository.yStepLength.value )
		zInteger = getIntegerFromCharacterLengthLineOffset( 'Z', binary16ByteRepository.zOffset.value, splitLine, binary16ByteRepository.zStepLength.value )
		sixteenByteStruct = Struct( 'cBhhhhhhBc' )
#		print( 'xInteger' )
#		print( xInteger )
		flagInteger = getIntegerFlagFromCharacterSplitLine( 'X', splitLine )
		flagInteger += 2 * getIntegerFlagFromCharacterSplitLine( 'Y', splitLine )
		flagInteger += 4 * getIntegerFlagFromCharacterSplitLine( 'Z', splitLine )
		flagInteger += 8 * getIntegerFlagFromCharacterSplitLine( 'I', splitLine )
		flagInteger += 16 * getIntegerFlagFromCharacterSplitLine( 'J', splitLine )
		flagInteger += 32 * getIntegerFlagFromCharacterSplitLine( 'F', splitLine )
		packedString = sixteenByteStruct.pack( firstLetter, int( firstWord[ 1 : ] ), xInteger, yInteger, zInteger, iInteger, jInteger, feedRateInteger, flagInteger, '#' )
		self.output.write( packedString )
示例#14
0
文件: mill.py 项目: yazici/skeinforge
 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(2), location.dropAxis(2),
                     self.aroundPixelTable, None, self.aroundWidth)
         self.oldLocation = location
     elif firstWord == 'M101':
         self.isExtruderActive = True
     elif firstWord == 'M103':
         self.isExtruderActive = False
     elif firstWord == '(<layer>':
         self.aroundPixelTable = {}
         self.average.reset()
     elif firstWord == '(</layer>)':
         if len(self.boundaryLayers) > self.layerIndex:
             self.addMillThreads()
         self.layerIndex += 1
     self.distanceFeedRate.addLine(line)
示例#15
0
 def parseLine(self, line):
     "Parse a gcode line and add it to the statistics."
     self.characters += len(line)
     self.numberOfLines += 1
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if firstWord == 'G1':
         self.linearMove(splitLine)
     elif firstWord == 'G2':
         self.helicalMove(False, splitLine)
     elif firstWord == 'G3':
         self.helicalMove(True, splitLine)
     elif firstWord == 'M101':
         self.extruderSet(True)
     elif firstWord == 'M102':
         self.extruderSet(False)
     elif firstWord == 'M103':
         self.extruderSet(False)
     elif firstWord == 'M108':
         self.extruderSpeed = gcodec.getDoubleAfterFirstLetter(splitLine[1])
     elif firstWord == '(<layerThickness>':
         self.layerThickness = float(splitLine[1])
         self.extrusionDiameter = self.repository.extrusionDiameterOverThickness.value * self.layerThickness
     elif firstWord == '(<operatingFeedRatePerSecond>':
         self.operatingFeedRatePerSecond = float(splitLine[1])
     elif firstWord == '(<perimeterWidth>':
         self.absolutePerimeterWidth = abs(float(splitLine[1]))
     elif firstWord == '(<procedureDone>':
         self.procedures.append(splitLine[1])
     elif firstWord == '(<version>':
         self.version = splitLine[1]
示例#16
0
 def parseLine(self, line):
     "Parse a gcode line and add it to the vector output."
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if self.isLayerStart(firstWord, splitLine):
         self.extrusionNumber = 0
         self.skeinPane = []
         self.skeinPanes.append(self.skeinPane)
     if firstWord == 'G1':
         location = gcodec.getLocationFromSplitLine(self.oldLocation,
                                                    splitLine)
         self.linearMove(line, location)
         self.oldLocation = location
     elif firstWord == 'M101':
         self.extruderActive = True
         self.extrusionNumber += 1
     elif firstWord == 'M103':
         self.extruderActive = False
     if firstWord == 'G2' or firstWord == 'G3':
         relativeLocation = gcodec.getLocationFromSplitLine(
             self.oldLocation, splitLine)
         relativeLocation.z = 0.0
         location = self.oldLocation + relativeLocation
         self.linearMove(line, location)
         self.oldLocation = location
示例#17
0
	def parseStretch( self, line ):
		"Parse a gcode line and add it to the stretch skein."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		if len( splitLine ) < 1:
			return
		firstWord = splitLine[ 0 ]
		if firstWord == 'G1':
			line = self.getStretchedLine( splitLine )
		elif firstWord == 'M101':
			self.extruderActive = True
		elif firstWord == 'M103':
			self.extruderActive = False
			self.setStretchToPath()
		elif firstWord == '(<loop>':
			self.isLoop = True
			self.threadMaximumAbsoluteStretch = self.loopMaximumAbsoluteStretch
		elif firstWord == '(</loop>)':
			self.setStretchToPath()
		elif firstWord == '(<perimeter>':
			self.isLoop = True
			self.threadMaximumAbsoluteStretch = self.perimeterInsideAbsoluteStretch
			if splitLine[ 1 ] == 'outer':
				self.threadMaximumAbsoluteStretch = self.perimeterOutsideAbsoluteStretch
		elif firstWord == '(</perimeter>)':
			self.setStretchToPath()
		self.distanceFeedRate.addLine( line )
示例#18
0
 def getRelativeStretch(self, locationComplex, lineIterator):
     "Get relative stretch for a location."
     lastLocationComplex = locationComplex
     oldTotalLength = 0.0
     pointComplex = locationComplex
     totalLength = 0.0
     while 1:
         try:
             line = lineIterator.getNext()
         except StopIteration:
             locationMinusPoint = locationComplex - pointComplex
             locationMinusPointLength = abs(locationMinusPoint)
             if locationMinusPointLength > 0.0:
                 return locationMinusPoint / locationMinusPointLength
             return complex()
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = splitLine[0]
         pointComplex = gcodec.getLocationFromSplitLine(
             self.oldLocation, splitLine).dropAxis(2)
         locationMinusPoint = lastLocationComplex - pointComplex
         locationMinusPointLength = abs(locationMinusPoint)
         totalLength += locationMinusPointLength
         if totalLength >= self.stretchFromDistance:
             distanceFromRatio = (self.stretchFromDistance -
                                  oldTotalLength) / locationMinusPointLength
             totalPoint = distanceFromRatio * pointComplex + (
                 1.0 - distanceFromRatio) * lastLocationComplex
             locationMinusTotalPoint = locationComplex - totalPoint
             return locationMinusTotalPoint / self.stretchFromDistance
         lastLocationComplex = pointComplex
         oldTotalLength = totalLength
示例#19
0
 def parseStretch(self, line):
     "Parse a gcode line and add it to the stretch skein."
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if firstWord == 'G1':
         line = self.getStretchedLine(splitLine)
     elif firstWord == 'M101':
         self.extruderActive = True
     elif firstWord == 'M103':
         self.extruderActive = False
         self.setStretchToPath()
     elif firstWord == '(<loop>':
         self.isLoop = True
         self.threadMaximumAbsoluteStretch = self.loopMaximumAbsoluteStretch
     elif firstWord == '(</loop>)':
         self.setStretchToPath()
     elif firstWord == '(<perimeter>':
         self.isLoop = True
         self.threadMaximumAbsoluteStretch = self.perimeterInsideAbsoluteStretch
         if splitLine[1] == 'outer':
             self.threadMaximumAbsoluteStretch = self.perimeterOutsideAbsoluteStretch
     elif firstWord == '(</perimeter>)':
         self.setStretchToPath()
     self.distanceFeedRate.addLine(line)
示例#20
0
 def getCrossLimitedStretch(self, crossLimitedStretch, crossLineIterator,
                            locationComplex):
     "Get cross limited relative stretch for a location."
     try:
         line = crossLineIterator.getNext()
     except StopIteration:
         return crossLimitedStretch
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     pointComplex = gcodec.getLocationFromSplitLine(self.oldLocation,
                                                    splitLine).dropAxis(2)
     pointMinusLocation = locationComplex - pointComplex
     pointMinusLocationLength = abs(pointMinusLocation)
     if pointMinusLocationLength <= self.crossLimitDistanceFraction:
         return crossLimitedStretch
     parallelNormal = pointMinusLocation / pointMinusLocationLength
     parallelStretch = euclidean.getDotProduct(
         parallelNormal, crossLimitedStretch) * parallelNormal
     if pointMinusLocationLength > self.crossLimitDistance:
         return parallelStretch
     crossNormal = complex(parallelNormal.imag, -parallelNormal.real)
     crossStretch = euclidean.getDotProduct(
         crossNormal, crossLimitedStretch) * crossNormal
     crossPortion = (self.crossLimitDistance - pointMinusLocationLength
                     ) / self.crossLimitDistanceRemainder
     return parallelStretch + crossStretch * crossPortion
示例#21
0
 def getNext(self):
     "Get next line going backward or raise exception."
     while self.lineIndex > 3:
         if self.lineIndex == self.firstLineIndex:
             raise StopIteration, "You've reached the end of the line."
         if self.firstLineIndex == None:
             self.firstLineIndex = self.lineIndex
         nextLineIndex = self.lineIndex - 1
         line = self.lines[self.lineIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if firstWord == 'M103':
             if self.isLoop:
                 nextLineIndex = self.getIndexBeforeNextDeactivate()
             else:
                 raise StopIteration, "You've reached the end of the line."
         if firstWord == 'G1':
             if self.isBeforeExtrusion():
                 if self.isLoop:
                     nextLineIndex = self.getIndexBeforeNextDeactivate()
                 else:
                     raise StopIteration, "You've reached the end of the line."
             else:
                 self.lineIndex = nextLineIndex
                 return line
         self.lineIndex = nextLineIndex
     raise StopIteration, "You've reached the end of the line."
示例#22
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( 2 ), location.dropAxis( 2 ), self.aroundPixelTable, None, self.aroundWidth )
			self.oldLocation = location
		elif firstWord == 'M101':
			self.isExtruderActive = True
		elif firstWord == 'M103':
			self.isExtruderActive = False
		elif firstWord == '(<layer>':
			self.aroundPixelTable = {}
			self.average.reset()
		elif firstWord == '(</layer>)':
			if len( self.boundaryLayers ) > self.layerIndex:
				self.addMillThreads()
			self.layerIndex += 1
		self.distanceFeedRate.addLine( line )
示例#23
0
 def parseBoundaries(self):
     "Parse the boundaries and add them to the boundary layers."
     boundaryLoop = None
     boundaryLayer = None
     for line in self.lines[self.lineIndex:]:
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if len(self.shutdownLines) > 0:
             self.shutdownLines.append(line)
         if firstWord == '(</boundaryPerimeter>)':
             boundaryLoop = None
         elif firstWord == '(<boundaryPoint>':
             location = gcodec.getLocationFromSplitLine(None, splitLine)
             if boundaryLoop == None:
                 boundaryLoop = []
                 boundaryLayer.loops.append(boundaryLoop)
             boundaryLoop.append(location.dropAxis(2))
         elif firstWord == '(<layer>':
             boundaryLayer = euclidean.LoopLayer(float(splitLine[1]))
             self.boundaryLayers.append(boundaryLayer)
         elif firstWord == '(</extrusion>)':
             self.shutdownLines = [line]
     for boundaryLayer in self.boundaryLayers:
         if not euclidean.isWiddershins(boundaryLayer.loops[0]):
             boundaryLayer.loops[0].reverse()
     self.boundaryReverseLayers = self.boundaryLayers[:]
     self.boundaryReverseLayers.reverse()
示例#24
0
 def parseSurroundingLoop(self, line):
     "Parse a surrounding loop."
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if firstWord == 'G1':
         self.linearMove(splitLine)
     if firstWord == 'M101':
         self.extruderActive = True
     elif firstWord == 'M103':
         self.extruderActive = False
     elif firstWord == '(<boundaryPoint>':
         location = gcodec.getLocationFromSplitLine(None, splitLine)
         if self.boundary == None:
             self.boundary = []
         self.boundary.append(location.dropAxis(2))
     elif firstWord == '(<layer>':
         self.layerZ = float(splitLine[1])
         self.threadLayer = None
     elif firstWord == '(<boundaryPerimeter>)':
         self.addThreadLayerIfNone()
     elif firstWord == '(</boundaryPerimeter>)':
         if self.boundary != None:
             self.threadLayer.points.append(getPolygonCenter(self.boundary))
             self.boundary = None
示例#25
0
	def getHopLine( self, line ):
		"Get hopped gcode line."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		self.feedRateMinute = gcodec.getFeedRateMinute( self.feedRateMinute, splitLine )
		if self.extruderActive:
			return line
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		highestZ = location.z
		if self.oldLocation != None:
			highestZ = max( highestZ, self.oldLocation.z )
		highestZHop = highestZ + self.hopHeight
		locationComplex = location.dropAxis( 2 )
		if self.justDeactivated:
			oldLocationComplex = self.oldLocation.dropAxis( 2 )
			distance = abs( locationComplex - oldLocationComplex )
			if distance < self.minimumDistance:
				if self.isNextTravel():
					return self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop )
			alongRatio = min( 0.41666666, self.hopDistance / distance )
			oneMinusAlong = 1.0 - alongRatio
			closeLocation = oldLocationComplex * oneMinusAlong + locationComplex * alongRatio
			self.distanceFeedRate.addLine( self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop ) )
			if self.isNextTravel():
				return self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop )
			farLocation = oldLocationComplex * alongRatio + locationComplex * oneMinusAlong
			self.distanceFeedRate.addGcodeMovementZWithFeedRate( self.feedRateMinute, farLocation, highestZHop )
			return line
		if self.isNextTravel():
			return self.distanceFeedRate.getLineWithZ( line, splitLine, highestZHop )
		return line
示例#26
0
 def setLayerPixelTable(self):
     "Parse a gcode line and add it to the clip skein."
     boundaryLoop = None
     extruderActive = False
     maskPixelTable = {}
     self.boundaryLoops = []
     self.maskPixelTableTable = {}
     self.layerPixelTable = {}
     oldLocation = self.oldLocation
     for afterIndex in xrange(self.lineIndex + 1, len(self.lines)):
         line = self.lines[afterIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if firstWord == 'G1':
             location = gcodec.getLocationFromSplitLine(
                 oldLocation, splitLine)
             if extruderActive and oldLocation != None:
                 self.addSegmentToPixelTables(location, maskPixelTable,
                                              oldLocation)
             oldLocation = location
         elif firstWord == 'M101':
             extruderActive = True
         elif firstWord == 'M103':
             extruderActive = False
             maskPixelTable = {}
         elif firstWord == '(</boundaryPerimeter>)':
             boundaryLoop = None
         elif firstWord == '(<boundaryPoint>':
             if boundaryLoop == None:
                 boundaryLoop = []
                 self.boundaryLoops.append(boundaryLoop)
             location = gcodec.getLocationFromSplitLine(None, splitLine)
             boundaryLoop.append(location.dropAxis(2))
         elif firstWord == '(</layer>)':
             return
示例#27
0
	def getRelativeStretch( self, locationComplex, lineIterator ):
		"Get relative stretch for a location."
		lastLocationComplex = locationComplex
		oldTotalLength = 0.0
		pointComplex = locationComplex
		totalLength = 0.0
		while 1:
			try:
				line = lineIterator.getNext()
			except StopIteration:
				locationMinusPoint = locationComplex - pointComplex
				locationMinusPointLength = abs( locationMinusPoint )
				if locationMinusPointLength > 0.0:
					return locationMinusPoint / locationMinusPointLength
				return complex()
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = splitLine[ 0 ]
			pointComplex = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine ).dropAxis( 2 )
			locationMinusPoint = lastLocationComplex - pointComplex
			locationMinusPointLength = abs( locationMinusPoint )
			totalLength += locationMinusPointLength
			if totalLength >= self.stretchFromDistance:
				distanceFromRatio = ( self.stretchFromDistance - oldTotalLength ) / locationMinusPointLength
				totalPoint = distanceFromRatio * pointComplex + ( 1.0 - distanceFromRatio ) * lastLocationComplex
				locationMinusTotalPoint = locationComplex - totalPoint
				return locationMinusTotalPoint / self.stretchFromDistance
			lastLocationComplex = pointComplex
			oldTotalLength = totalLength
示例#28
0
	def parseLine( self, line ):
		"Parse a gcode line and add it to the vector output."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		if len( splitLine ) < 1:
			return
		firstWord = splitLine[ 0 ]
		if self.isLayerStart( firstWord, splitLine ):
			self.extrusionNumber = 0
			self.skeinPane = []
			self.skeinPanes.append( self.skeinPane )
		if firstWord == 'G1':
			location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
			self.linearMove( line, location )
			self.oldLocation = location
		elif firstWord == 'M101':
			self.extruderActive = True
			self.extrusionNumber += 1
		elif firstWord == 'M103':
			self.extruderActive = False
		if firstWord == 'G2' or firstWord == 'G3':
			relativeLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
			relativeLocation.z = 0.0
			location = self.oldLocation + relativeLocation
			self.linearMove( line, location )
			self.oldLocation = location
示例#29
0
	def parseLine( self, line ):
		"Parse a gcode line and add it to the inset skein."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		if len( splitLine ) < 1:
			return
		firstWord = splitLine[ 0 ]
		if firstWord == '(<boundaryPoint>':
			location = gcodec.getLocationFromSplitLine( None, splitLine )
			self.boundary.append( location.dropAxis( 2 ) )
		elif ( firstWord == '(<bridgeRotation>' or firstWord == '<!--bridgeRotation-->' ):
			secondWordWithoutBrackets = splitLine[ 1 ].replace( '(', '' ).replace( ')', '' )
			self.rotatedBoundaryLayer.rotation = complex( secondWordWithoutBrackets )
		elif firstWord == '(</extrusion>)':
				self.distanceFeedRate.addLine( line )
				if self.repository.turnExtruderHeaterOffAtShutDown.value:
					self.distanceFeedRate.addLine( 'M104 S0' ) # Turn extruder heater off.
				return
		elif firstWord == '(<layer>':
			self.rotatedBoundaryLayer = euclidean.RotatedLoopLayer( float( splitLine[ 1 ] ) )
			self.distanceFeedRate.addLine( line )
		elif firstWord == '(</layer>)':
			self.addInset( self.rotatedBoundaryLayer )
			self.rotatedBoundaryLayer = None
		elif firstWord == '(<surroundingLoop>)':
			self.boundary = []
			self.rotatedBoundaryLayer.loops.append( self.boundary )
		if self.rotatedBoundaryLayer == None:
			self.distanceFeedRate.addLine( line )
示例#30
0
 def parseLine(self, line):
     "Parse a gcode line and add it to the inset skein."
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if firstWord == '(<boundaryPoint>':
         location = gcodec.getLocationFromSplitLine(None, splitLine)
         self.boundary.append(location.dropAxis(2))
     elif (firstWord == '(<bridgeRotation>'
           or firstWord == '<!--bridgeRotation-->'):
         secondWordWithoutBrackets = splitLine[1].replace('(', '').replace(
             ')', '')
         self.rotatedBoundaryLayer.rotation = complex(
             secondWordWithoutBrackets)
     elif firstWord == '(</extrusion>)':
         self.distanceFeedRate.addLine(line)
         if self.repository.turnExtruderHeaterOffAtShutDown.value:
             self.distanceFeedRate.addLine(
                 'M104 S0')  # Turn extruder heater off.
         return
     elif firstWord == '(<layer>':
         self.rotatedBoundaryLayer = euclidean.RotatedLoopLayer(
             float(splitLine[1]))
         self.distanceFeedRate.addLine(line)
     elif firstWord == '(</layer>)':
         self.addInset(self.rotatedBoundaryLayer)
         self.rotatedBoundaryLayer = None
     elif firstWord == '(<surroundingLoop>)':
         self.boundary = []
         self.rotatedBoundaryLayer.loops.append(self.boundary)
     if self.rotatedBoundaryLayer == None:
         self.distanceFeedRate.addLine(line)
示例#31
0
	def getAddShutSlowDownLine( self, line ):
		"Add the shutdown and slowdown lines."
		if self.shutdownStepIndex >= len( self.earlyShutdownDistances ):
			self.shutdownStepIndex = len( self.earlyShutdownDistances ) + 99999999
			return False
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		distanceThreadEnd = self.getDistanceToExtruderOffCommand( self.earlyShutdownDistances[ self.shutdownStepIndex ] )
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		if distanceThreadEnd == None:
			distanceThreadEnd = self.getDistanceToExtruderOffCommand( self.earlyShutdownDistances[ 0 ] )
			if distanceThreadEnd != None:
				shutdownFlowRateMultiplier = self.getShutdownFlowRateMultiplier( 1.0 - distanceThreadEnd / self.earlyShutdownDistance, len( self.earlyShutdownDistances ) )
				line = self.getLinearMoveWithFeedRate( self.feedRateMinute * shutdownFlowRateMultiplier, location )
			self.distanceFeedRate.addLine( line )
			return False
		segment = self.oldLocation - location
		segmentLength = segment.magnitude()
		distanceBack = self.earlyShutdownDistances[ self.shutdownStepIndex ] - distanceThreadEnd
		locationBack = location
		if segmentLength > 0.0:
			locationBack = location + segment * distanceBack / segmentLength
		if self.shutdownStepIndex == 0:
			if not self.isCloseToEither( locationBack, location, self.oldLocation ):
				line = self.getLinearMoveWithFeedRate( self.feedRateMinute, locationBack )
			self.distanceFeedRate.addLine( line )
			self.addLineSetShutdowns( 'M103' )
			return True
		if self.isClose( locationBack, self.oldLocation ):
			return True
		feedRate = self.feedRateMinute * self.earlyShutdownFlowRates[ self.shutdownStepIndex ]
		line = self.getLinearMoveWithFeedRate( feedRate, locationBack )
		if self.isClose( locationBack, location ):
			line = self.getLinearMoveWithFeedRate( feedRate, location )
		self.distanceFeedRate.addLine( line )
		return True
示例#32
0
	def parseSurroundingLoop( self, line ):
		"Parse a surrounding loop."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		if len( splitLine ) < 1:
			return
		firstWord = splitLine[ 0 ]
		if firstWord == 'G1':
			self.linearMove( splitLine )
		if firstWord == 'M101':
			self.extruderActive = True
		elif firstWord == 'M103':
			self.extruderActive = False
		elif firstWord == '(<boundaryPoint>':
			location = gcodec.getLocationFromSplitLine( None, splitLine )
			if self.boundary == None:
				self.boundary = []
			self.boundary.append( location.dropAxis( 2 ) )
		elif firstWord == '(<layer>':
			self.layerZ = float( splitLine[ 1 ] )
			self.threadLayer = None
		elif firstWord == '(<boundaryPerimeter>)':
			self.addThreadLayerIfNone()
		elif firstWord == '(</boundaryPerimeter>)':
			if self.boundary != None:
				self.threadLayer.points.append( getPolygonCenter( self.boundary ) )
				self.boundary = None
示例#33
0
 def getAnimationLineDelay(self, coloredLine):
     "Get the animation line delay in milliseconds."
     #		maybe later, add animation along line
     #		nextLayerIndex = self.repository.layer.value
     #		nextLineIndex = self.repository.line.value + 1
     #		coloredLinesLength = len( self.getColoredLines() )
     #		self.skein.feedRateMinute
     #		if nextLineIndex >= coloredLinesLength:
     #			if nextLayerIndex + 1 < len( self.skeinPanes ):
     #				nextLayerIndex += 1
     #				nextLineIndex = 0
     #			else:
     #				nextLineIndex = self.repository.line.value
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(
         coloredLine.displayString)
     self.skein.feedRateMinute = gcodec.getFeedRateMinute(
         self.skein.feedRateMinute, splitLine)
     feedRateSecond = self.skein.feedRateMinute / 60.0
     coloredLineLength = abs(
         coloredLine.end - coloredLine.begin) / self.repository.scale.value
     duration = coloredLineLength / feedRateSecond
     animationLineDelay = int(
         round(1000.0 * duration /
               self.repository.animationLineQuickening.value))
     return max(animationLineDelay, 1)
示例#34
0
	def parseLine( self, line ):
		"Parse a gcode line and add it to the statistics."
		self.characters += len( line )
		self.numberOfLines += 1
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		if len( splitLine ) < 1:
			return
		firstWord = splitLine[ 0 ]
		if firstWord == 'G1':
			self.linearMove( splitLine )
		elif firstWord == 'G2':
			self.helicalMove( False, splitLine )
		elif firstWord == 'G3':
			self.helicalMove( True, splitLine )
		elif firstWord == 'M101':
			self.extruderSet( True )
		elif firstWord == 'M102':
			self.extruderSet( False )
		elif firstWord == 'M103':
			self.extruderSet( False )
		elif firstWord == 'M108':
			self.extruderSpeed = gcodec.getDoubleAfterFirstLetter( splitLine[ 1 ] )
		elif firstWord == '(<layerThickness>':
			self.layerThickness = float( splitLine[ 1 ] )
			self.extrusionDiameter = self.repository.extrusionDiameterOverThickness.value * self.layerThickness
		elif firstWord == '(<operatingFeedRatePerSecond>':
			self.operatingFeedRatePerSecond = float( splitLine[ 1 ] )
		elif firstWord == '(<perimeterWidth>':
			self.absolutePerimeterWidth = abs( float( splitLine[ 1 ] ) )
		elif firstWord == '(<procedureDone>':
			self.procedures.append( splitLine[ 1 ] )
		elif firstWord == '(<version>':
			self.version = splitLine[ 1 ]
示例#35
0
文件: flow.py 项目: jmil/SkeinFox
 def parseLine(self, line):
     "Parse a gcode line and add it to the flow skein."
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if firstWord == "G1" or firstWord == "(<layer>":
         self.addFlowRateLineIfNecessary()
     self.distanceFeedRate.addLine(line)
示例#36
0
文件: flow.py 项目: yazici/skeinforge
 def parseLine(self, line):
     "Parse a gcode line and add it to the flow skein."
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     if firstWord == 'G1' or firstWord == '(<layer>':
         self.addFlowRateLineIfNecessary()
     self.distanceFeedRate.addLine(line)
示例#37
0
	def getNextLocation( self ):
		"Get the next linear move.  Return none is none is found."
		for afterIndex in xrange( self.lineIndex + 1, len( self.lines ) ):
			line = self.lines[ afterIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			if gcodec.getFirstWord( splitLine ) == 'G1':
				nextLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
				return nextLocation
		return None
示例#38
0
	def addRemoveThroughLayer( self ):
		"Parse gcode initialization and store the parameters."
		for layerLineIndex in xrange( len( self.layerLines ) ):
			line = self.layerLines[ layerLineIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			self.distanceFeedRate.addLine( line )
			if firstWord == '(<layer>':
				self.layerLines = self.layerLines[ layerLineIndex + 1 : ]
				return
示例#39
0
	def setMaximumZ( self ):
		"Set maximum  z."
		localOldLocation = None
		for line in self.lines[ self.lineIndex : ]:
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'G1':
				location = gcodec.getLocationFromSplitLine( localOldLocation, splitLine )
				self.maximumZ = max( self.maximumZ, location.z )
				localOldLocation = location
示例#40
0
	def getDistanceToExtruderOffCommand( self, remainingDistance ):
		"Get the distance to the word."
		line = self.lines[ self.lineIndex ]
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		lastThreadLocation = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		totalDistance = 0.0
		for afterIndex in xrange( self.lineIndex + 1, len( self.lines ) ):
			line = self.lines[ afterIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'G1':
				location = gcodec.getLocationFromSplitLine( lastThreadLocation, splitLine )
				totalDistance += location.distance( lastThreadLocation )
				lastThreadLocation = location
				if totalDistance >= remainingDistance:
					return None
			elif firstWord == 'M103':
				return totalDistance
		return None
示例#41
0
 def parseInitialization(self):
     "Parse gcode initialization and store the parameters."
     for self.lineIndex in xrange(len(self.lines)):
         line = self.lines[self.lineIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if firstWord == '(</extruderInitialization>)':
             return
         elif firstWord == '(<operatingFeedRatePerSecond>':
             self.feedRateMinute = 60.0 * float(splitLine[1])
示例#42
0
	def parseInitialization( self ):
		"Parse gcode initialization and store the parameters."
		for self.lineIndex in xrange( len( self.lines ) ):
			line = self.lines[ self.lineIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == '(</extruderInitialization>)':
				return
			elif firstWord == '(<operatingFeedRatePerSecond>':
				self.feedRateMinute = 60.0 * float( splitLine[ 1 ] )
示例#43
0
	def getIndexBeforeNextDeactivate( self ):
		"Get index two lines before the deactivate command."
		for lineIndex in xrange( self.lineIndex + 1, len( self.lines ) ):
			line = self.lines[ lineIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'M103':
				return lineIndex - 2
		print( 'This should never happen in stretch, no deactivate command was found for this thread.' )
		raise StopIteration, "You've reached the end of the line."
示例#44
0
	def getAddAfterStartupLines( self, line ):
		"Get and / or add after the startup lines."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		while self.isDistanceAfterThreadBeginningGreater():
			self.addAfterStartupLine( splitLine )
		if self.startupStepIndex >= len( self.afterStartupDistances ):
			self.startupStepIndex = len( self.afterStartupDistances ) + 999999999999
			return self.getLinearMoveWithFeedRateSplitLine( self.operatingFeedRateMinute, splitLine )
		feedRate = self.operatingFeedRateMinute * self.getStartupFlowRateMultiplier( self.getDistanceAfterThreadBeginning() / self.afterStartupDistance, len( self.afterStartupDistances ) )
		return self.getLinearMoveWithFeedRateSplitLine( feedRate, splitLine )
示例#45
0
	def getIndexJustAfterActivate( self ):
		"Get index just after the activate command."
		for lineIndex in xrange( self.lineIndex - 1, 3, - 1 ):
			line = self.lines[ lineIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			if firstWord == 'M101':
				return lineIndex + 1
		print( 'This should never happen in stretch, no activate command was found for this thread.' )
		raise StopIteration, "You've reached the end of the line."
示例#46
0
 def getNextLocation(self):
     "Get the next linear move.  Return none is none is found."
     for afterIndex in xrange(self.lineIndex + 1, len(self.lines)):
         line = self.lines[afterIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         if gcodec.getFirstWord(splitLine) == 'G1':
             nextLocation = gcodec.getLocationFromSplitLine(
                 self.oldLocation, splitLine)
             return nextLocation
     return None
示例#47
0
 def parseUntilLayer(self):
     "Parse until the layer line and add it to the coil skein."
     for self.lineIndex in xrange(self.lineIndex, len(self.lines)):
         line = self.lines[self.lineIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         self.distanceFeedRate.parseSplitLine(firstWord, splitLine)
         if firstWord == '(<layer>':
             return
         self.distanceFeedRate.addLine(line)
示例#48
0
	def parseUntilLayer( self ):
		"Parse until the layer line and add it to the coil skein."
		for self.lineIndex in xrange( self.lineIndex, len( self.lines ) ):
			line = self.lines[ self.lineIndex ]
			splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
			firstWord = gcodec.getFirstWord( splitLine )
			self.distanceFeedRate.parseSplitLine( firstWord, splitLine )
			if firstWord == '(<layer>':
				return
			self.distanceFeedRate.addLine( line )
示例#49
0
	def parseLine( self, line ):
		"Parse a gcode line."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		if len( splitLine ) < 1:
			return
		firstWord = splitLine[ 0 ]
		self.distanceFeedRate.addLine( line )
		if firstWord == '(<layer>':
			if not self.isDrilled:
				self.addDrillHoles()
示例#50
0
 def addRemoveThroughLayer(self):
     "Parse gcode initialization and store the parameters."
     for layerLineIndex in xrange(len(self.layerLines)):
         line = self.layerLines[layerLineIndex]
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         self.distanceFeedRate.addLine(line)
         if firstWord == '(<layer>':
             self.layerLines = self.layerLines[layerLineIndex + 1:]
             return
示例#51
0
 def parseLine(self, line):
     "Parse a gcode line."
     splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
     if len(splitLine) < 1:
         return
     firstWord = splitLine[0]
     self.distanceFeedRate.addLine(line)
     if firstWord == '(<layer>':
         if not self.isDrilled:
             self.addDrillHoles()
示例#52
0
文件: mill.py 项目: yazici/skeinforge
 def parseBoundaries(self):
     "Parse the boundaries and add them to the boundary layers."
     boundaryLoop = None
     boundaryLayer = None
     for line in self.lines[self.lineIndex:]:
         splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line)
         firstWord = gcodec.getFirstWord(splitLine)
         if firstWord == '(</boundaryPerimeter>)':
             boundaryLoop = None
         elif firstWord == '(<boundaryPoint>':
             location = gcodec.getLocationFromSplitLine(None, splitLine)
             if boundaryLoop == None:
                 boundaryLoop = []
                 boundaryLayer.loops.append(boundaryLoop)
             boundaryLoop.append(location.dropAxis(2))
         elif firstWord == '(<layer>':
             boundaryLayer = euclidean.LoopLayer(float(splitLine[1]))
             self.boundaryLayers.append(boundaryLayer)
     if len(self.boundaryLayers) < 2:
         return
     for boundaryLayer in self.boundaryLayers:
         boundaryLayer.innerOutsetLoops = intercircle.getInsetSeparateLoopsFromLoops(
             -self.loopInnerOutset, boundaryLayer.loops)
         boundaryLayer.outerOutsetLoops = intercircle.getInsetSeparateLoopsFromLoops(
             -self.loopOuterOutset, boundaryLayer.loops)
         boundaryLayer.innerHorizontalTable = self.getHorizontalXIntersectionsTable(
             boundaryLayer.innerOutsetLoops)
         boundaryLayer.outerHorizontalTable = self.getHorizontalXIntersectionsTable(
             boundaryLayer.outerOutsetLoops)
         boundaryLayer.innerVerticalTable = self.getHorizontalXIntersectionsTable(
             euclidean.getDiagonalFlippedLoops(
                 boundaryLayer.innerOutsetLoops))
         boundaryLayer.outerVerticalTable = self.getHorizontalXIntersectionsTable(
             euclidean.getDiagonalFlippedLoops(
                 boundaryLayer.outerOutsetLoops))
     for boundaryLayerIndex in xrange(len(self.boundaryLayers) - 2, -1, -1):
         boundaryLayer = self.boundaryLayers[boundaryLayerIndex]
         boundaryLayerBelow = self.boundaryLayers[boundaryLayerIndex + 1]
         euclidean.joinXIntersectionsTables(
             boundaryLayerBelow.outerHorizontalTable,
             boundaryLayer.outerHorizontalTable)
         euclidean.joinXIntersectionsTables(
             boundaryLayerBelow.outerVerticalTable,
             boundaryLayer.outerVerticalTable)
     for boundaryLayerIndex in xrange(1, len(self.boundaryLayers)):
         boundaryLayer = self.boundaryLayers[boundaryLayerIndex]
         boundaryLayerAbove = self.boundaryLayers[boundaryLayerIndex - 1]
         euclidean.joinXIntersectionsTables(
             boundaryLayerAbove.innerHorizontalTable,
             boundaryLayer.innerHorizontalTable)
         euclidean.joinXIntersectionsTables(
             boundaryLayerAbove.innerVerticalTable,
             boundaryLayer.innerVerticalTable)
     for boundaryLayerIndex in xrange(len(self.boundaryLayers)):
         self.addSegmentTableLoops(boundaryLayerIndex)
示例#53
0
文件: lash.py 项目: yazici/skeinforge
	def parseLash( self, line ):
		"Parse a gcode line and add it to the lash skein."
		splitLine = gcodec.getSplitLineBeforeBracketSemicolon( line )
		if len( splitLine ) < 1:
			return
		firstWord = splitLine[ 0 ]
		if firstWord == 'G1':
			location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
			line = self.getLashedLine( line, location, splitLine )
			self.oldLocation = location
		self.distanceFeedRate.addLine( line )