Пример #1
0
	def getRelativeStretch( self, location, lineIndexRange ):
		"Get relative stretch for a location minus a point."
		locationComplex = location.dropAxis( 2 )
		lastLocationComplex = locationComplex
		oldTotalLength = 0.0
		pointComplex = locationComplex
		stretchRatio = 1.0
		totalLength = 0.0
		if not self.extruderActive:
			stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value
		for lineIndex in lineIndexRange:
			line = self.lines[ lineIndex ]
			splitLine = line.split( ' ' )
			firstWord = ''
			if len( splitLine ) > 0:
				firstWord = splitLine[ 0 ]
			if firstWord == 'G1':
				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 stretchRatio * locationMinusTotalPoint / self.stretchFromDistance
				lastLocationComplex = pointComplex
				oldTotalLength = totalLength
			elif firstWord == 'M103':
				stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value
		locationMinusPoint = locationComplex - pointComplex
		locationMinusPointLength = abs( locationMinusPoint )
		if locationMinusPointLength > 0.0:
			return stretchRatio * locationMinusPoint / locationMinusPointLength
		return complex()
Пример #2
0
 def addIfTravel(self, splitLine):
     "Add travel move around loops if this the extruder is off."
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     if not self.extruderActive and self.oldLocation != None:
         self.insertPathsBetween(self.getOutloopLocation(location),
                                 self.getOutloopLocation(self.oldLocation))
     self.oldLocation = location
Пример #3
0
	def linearCorner( self, splitLine ):
		"Update the bounding corners."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		if self.extruderActive:
			self.cornerHigh = euclidean.getPointMaximum( self.cornerHigh, location )
			self.cornerLow = euclidean.getPointMinimum( self.cornerLow, location )
		self.oldLocation = location
Пример #4
0
 def getLocationSetFeedrateToSplitLine(self, splitLine):
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     indexOfF = gcodec.indexOfStartingWithSecond("F", splitLine)
     if indexOfF > 0:
         self.feedrateMinute = gcodec.getDoubleAfterFirstLetter(
             splitLine[indexOfF])
     return location
Пример #5
0
	def setHelicalMoveEndpoint( self, splitLine ):
		"Get the endpoint of a helical move."
		if self.oldLocation == None:
			print >> sys.stderr, ( "A helical move must not be the first move of a gcode file." )
			return
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		location.add( self.oldLocation )
		self.oldLocation = location
Пример #6
0
	def linearMove( self, splitLine ):
		"Add a linear move to the loop."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		self.feedrateMinute  = gcodec.getFeedrateMinute( self.feedrateMinute, splitLine )
		self.feedrateTable[ location ] = self.feedrateMinute
		if self.extruderActive:
			self.addToExtrusion( location )
		self.oldLocation = location
Пример #7
0
	def getStretchedLine( self, splitLine ):
		"Get stretched gcode line."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		self.feedrateMinute = gcodec.getFeedrateMinute( self.feedrateMinute, splitLine )
		if self.oldLocation != None:
			self.addStretchesBeforePoint( location )
		self.oldLocation = location
		return self.getStretchedLineFromIndexLocation( self.lineIndex - 1, self.lineIndex + 1, location )
Пример #8
0
 def setHelicalMoveEndpoint(self, splitLine):
     "Get the endpoint of a helical move."
     if self.oldLocation == None:
         print >> sys.stderr, (
             "A helical move must not be the first move of a gcode file.")
         return
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     location.add(self.oldLocation)
     self.oldLocation = location
Пример #9
0
 def linearMove(self, splitLine):
     "Add a linear move to the loop."
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     self.feedrateMinute = gcodec.getFeedrateMinute(self.feedrateMinute,
                                                    splitLine)
     self.feedrateTable[location] = self.feedrateMinute
     if self.extruderActive:
         self.addToExtrusion(location)
     self.oldLocation = location
Пример #10
0
 def getStretchedLine(self, splitLine):
     "Get stretched gcode line."
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     self.feedrateMinute = gcodec.getFeedrateMinute(self.feedrateMinute,
                                                    splitLine)
     if self.oldLocation != None:
         self.addStretchesBeforePoint(location)
     self.oldLocation = location
     return self.getStretchedLineFromIndexLocation(self.lineIndex - 1,
                                                   self.lineIndex + 1,
                                                   location)
Пример #11
0
	def linearMove( self, splitLine ):
		"Bevel a linear move."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		self.feedrateMinute = gcodec.getFeedrateMinute( self.feedrateMinute, splitLine )
		if not self.extruderActive:
			return
		if self.oldActiveLocation != None:
			nextActive = self.getNextActive()
			if nextActive != None:
				self.shouldAddLine = False
				location = self.splitPointGetAfter( location, nextActive, self.oldActiveLocation )
		self.oldActiveLocation = location
Пример #12
0
 def linearMove(self, splitLine):
     "Bevel a linear move."
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     self.feedrateMinute = gcodec.getFeedrateMinute(self.feedrateMinute,
                                                    splitLine)
     if not self.extruderActive:
         return
     if self.oldActiveLocation != None:
         nextActive = self.getNextActive()
         if nextActive != None:
             self.shouldAddLine = False
             location = self.splitPointGetAfter(location, nextActive,
                                                self.oldActiveLocation)
     self.oldActiveLocation = location
Пример #13
0
	def getNextActive( self ):
		"Get the next linear move where the extruder is still active.  Return none is none is found."
		for afterIndex in range( self.lineIndex + 1, len( self.lines ) ):
			line = self.lines[ afterIndex ]
			splitLine = line.split( ' ' )
			firstWord = "";
			if len( splitLine ) > 0:
				firstWord = splitLine[ 0 ]
			if firstWord == 'G1':
				nextActive = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
				return nextActive
			if firstWord == 'M103':
				return None
		return None
Пример #14
0
 def getNextActive(self):
     "Get the next linear move where the extruder is still active.  Return none is none is found."
     for afterIndex in range(self.lineIndex + 1, len(self.lines)):
         line = self.lines[afterIndex]
         splitLine = line.split(' ')
         firstWord = ""
         if len(splitLine) > 0:
             firstWord = splitLine[0]
         if firstWord == 'G1':
             nextActive = gcodec.getLocationFromSplitLine(
                 self.oldLocation, splitLine)
             return nextActive
         if firstWord == 'M103':
             return None
     return None
Пример #15
0
 def getRelativeStretch(self, location, lineIndexRange):
     "Get relative stretch for a location minus a point."
     locationComplex = location.dropAxis(2)
     lastLocationComplex = locationComplex
     oldTotalLength = 0.0
     pointComplex = locationComplex
     stretchRatio = 1.0
     totalLength = 0.0
     if not self.extruderActive:
         stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value
     for lineIndex in lineIndexRange:
         line = self.lines[lineIndex]
         splitLine = line.split(' ')
         firstWord = ''
         if len(splitLine) > 0:
             firstWord = splitLine[0]
         if firstWord == 'G1':
             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 stretchRatio * locationMinusTotalPoint / self.stretchFromDistance
             lastLocationComplex = pointComplex
             oldTotalLength = totalLength
         elif firstWord == 'M103':
             stretchRatio = self.stretchPreferences.travelOverExtrusionStretch.value
     locationMinusPoint = locationComplex - pointComplex
     locationMinusPointLength = abs(locationMinusPoint)
     if locationMinusPointLength > 0.0:
         return stretchRatio * locationMinusPoint / locationMinusPointLength
     return complex()
Пример #16
0
	def linearMove( self, splitLine ):
		"Add a linear move to the loop."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		if self.extruderActive:
			self.addToLoop( location )
		self.oldLocation = location
Пример #17
0
	def addIfTravel( self, splitLine ):
		"Add travel move around loops if this the extruder is off."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		if not self.extruderActive and self.oldLocation != None:
			self.insertPathsBetween( self.getOutloopLocation( location ), self.getOutloopLocation( self.oldLocation ) )
		self.oldLocation = location
Пример #18
0
	def addIfTravel( self, splitLine ):
		"Add travel move around loops if this the extruder is off."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		self.oldLocation = location
Пример #19
0
	def linearMove( self, splitLine, nextLine ):
		"Get statistics for a linear move."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		self.addToPath( location, nextLine )
		self.oldLocation = location
Пример #20
0
 def addIfTravel(self, splitLine):
     "Add travel move around loops if this the extruder is off."
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     self.oldLocation = location
Пример #21
0
	def getLocationSetFeedrateToSplitLine( self, splitLine ):
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		indexOfF = gcodec.indexOfStartingWithSecond( "F", splitLine )
		if indexOfF > 0:
			self.feedrateMinute = gcodec.getDoubleAfterFirstLetter( splitLine[ indexOfF ] )
		return location
Пример #22
0
	def linearMove( self, splitLine ):
		"Comment a linear move."
		location = gcodec.getLocationFromSplitLine( self.oldLocation, splitLine )
		self.addComment( "Linear move to " + str( location ) + "." );
		self.oldLocation = location
Пример #23
0
 def linearMove(self, splitLine):
     "Add a linear move to the loop."
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     if self.extruderActive:
         self.addToLoop(location)
     self.oldLocation = location
Пример #24
0
 def linearMove(self, splitLine):
     "Comment a linear move."
     location = gcodec.getLocationFromSplitLine(self.oldLocation, splitLine)
     self.addComment("Linear move to " + str(location) + ".")
     self.oldLocation = location