Esempio n. 1
0
def getJitteredLoop( jitterDistance, jitterLoop ):
	'Get a jittered loop path.'
	loopLength = euclidean.getLoopLength( jitterLoop )
	lastLength = 0.0
	pointIndex = 0
	totalLength = 0.0
	jitterPosition = ( jitterDistance + 256.0 * loopLength ) % loopLength
	while totalLength < jitterPosition and pointIndex < len( jitterLoop ):
		firstPoint = jitterLoop[pointIndex]
		secondPoint  = jitterLoop[ (pointIndex + 1) % len( jitterLoop ) ]
		pointIndex += 1
		lastLength = totalLength
		totalLength += abs(firstPoint - secondPoint)
	remainingLength = jitterPosition - lastLength
	pointIndex = pointIndex % len( jitterLoop )
	ultimateJitteredPoint = jitterLoop[pointIndex]
	penultimateJitteredPointIndex = ( pointIndex + len( jitterLoop ) - 1 ) % len( jitterLoop )
	penultimateJitteredPoint = jitterLoop[ penultimateJitteredPointIndex ]
	segment = ultimateJitteredPoint - penultimateJitteredPoint
	segmentLength = abs(segment)
	originalOffsetLoop = euclidean.getAroundLoop( pointIndex, pointIndex, jitterLoop )
	if segmentLength <= 0.0:
		return originalOffsetLoop
	newUltimatePoint = penultimateJitteredPoint + segment * remainingLength / segmentLength
	return [newUltimatePoint] + originalOffsetLoop
Esempio n. 2
0
def addOrbits( distanceFeedRate, loop, orbitalFeedRatePerSecond, temperatureChangeTime, z ):
	'Add orbits with the extruder off.'
	timeInOrbit = 0.0
	while timeInOrbit < temperatureChangeTime:
		for point in loop:
			distanceFeedRate.addGcodeMovementZWithFeedRate( 60.0 * orbitalFeedRatePerSecond, point, z )
		timeInOrbit += euclidean.getLoopLength(loop) / orbitalFeedRatePerSecond
Esempio n. 3
0
def getJitteredLoop(jitterDistance, jitterLoop):
    'Get a jittered loop path.'
    loopLength = euclidean.getLoopLength(jitterLoop)
    lastLength = 0.0
    pointIndex = 0
    totalLength = 0.0
    jitterPosition = (jitterDistance + 256.0 * loopLength) % loopLength
    while totalLength < jitterPosition and pointIndex < len(jitterLoop):
        firstPoint = jitterLoop[pointIndex]
        secondPoint = jitterLoop[(pointIndex + 1) % len(jitterLoop)]
        pointIndex += 1
        lastLength = totalLength
        totalLength += abs(firstPoint - secondPoint)
    remainingLength = jitterPosition - lastLength
    pointIndex = pointIndex % len(jitterLoop)
    ultimateJitteredPoint = jitterLoop[pointIndex]
    penultimateJitteredPointIndex = (pointIndex + len(jitterLoop) -
                                     1) % len(jitterLoop)
    penultimateJitteredPoint = jitterLoop[penultimateJitteredPointIndex]
    segment = ultimateJitteredPoint - penultimateJitteredPoint
    segmentLength = abs(segment)
    originalOffsetLoop = euclidean.getAroundLoop(pointIndex, pointIndex,
                                                 jitterLoop)
    if segmentLength <= 0.0:
        return originalOffsetLoop
    newUltimatePoint = penultimateJitteredPoint + segment * remainingLength / segmentLength
    return [newUltimatePoint] + originalOffsetLoop
    def cool(self, layer):
        '''Apply the cooling by moving the nozzle around the print.'''

        if layer.index == 0:
            # We don't have to slow down on the first layer
            return

        (layerDistance, layerDuration) = layer.getDistanceAndDuration()
        remainingOrbitTime = max(self.minimumLayerTime - layerDuration, 0.0)

        boundaryLayerLoops = []
        for nestedRing in layer.nestedRings:
            boundaryLayerLoops.append(nestedRing.getXYBoundaries())

        if remainingOrbitTime > 0.0 and boundaryLayerLoops != None:
            if len(boundaryLayerLoops) < 1:
                return

            largestLoop = euclidean.getLargestLoop(boundaryLayerLoops)
            cornerMinimum = euclidean.getMinimumByComplexPath(largestLoop) - self.oribitalMargin
            cornerMaximum = euclidean.getMaximumByComplexPath(largestLoop) + self.oribitalMargin

            largestLoop = euclidean.getSquareLoopWiddershins(cornerMaximum, cornerMinimum)

            if len(largestLoop) > 1 and remainingOrbitTime > 1.5 :
                timeInOrbit = 0.0

                while timeInOrbit < remainingOrbitTime:
                    for point in largestLoop:
                        gcodeArgs = [('X', round(point.real, self.decimalPlaces)),
                                     ('Y', round(point.imag, self.decimalPlaces)),
                                     ('Z', round(layer.z, self.decimalPlaces)),
                                     ('F', round(self.orbitalFeedRateMinute, self.decimalPlaces))]
                        layer.preLayerGcodeCommands.append(GcodeCommand(gcodes.LINEAR_GCODE_MOVEMENT, gcodeArgs))
                    timeInOrbit += euclidean.getLoopLength(largestLoop) / self.orbitalFeedRateSecond
Esempio n. 5
0
def getJitteredLoop( jitterDistance, jitterLoop ):
	'Get a jittered loop path.'
	loopLength = euclidean.getLoopLength( jitterLoop )
	lastLength = 0.0
	pointIndex = 0
	totalLength = 0.0
	idx = 0
	mina = 180
	startidx = 0
	newLoop = []
#	print('jitterloop')
	for point in jitterLoop:
		nidx = idx + 1
		if nidx > len(jitterLoop)-1:
		   nidx = 0
		pidx = idx - 1
		if pidx < 0:
		   pidx = len(jitterLoop)-1

		ppoint = jitterLoop[pidx]
		npoint = jitterLoop[nidx]

		la = ppoint - point
		lb = npoint - point
		sk = la.real*lb.real + la.imag*lb.imag
		lnab = math.sqrt((abs(la.real*la.real) + abs(la.imag*la.imag)) * (abs(lb.real*lb.real) + abs(lb.imag*lb.imag)) )
		dv = sk / lnab
#		print(sk, lnab, dv)
		if dv > 1:
			dv = 1
		if dv < -1:
			dv = -1
		if lnab != 0:
			a = math.degrees(math.acos(dv) )
		else:
			a = 180
		if a < mina:
			mina = a
			startidx = idx

#		print(pidx, idx, nidx, a, mina, startidx)
                idx += 1

        for point in jitterLoop:
		newLoop.append(jitterLoop[startidx])
		startidx += 1
		if startidx > len(jitterLoop)-1:
			startidx = 0
	return newLoop
Esempio n. 6
0
 def addCoilToThread(self, beginLocation, endZ, loop, thread):
     "Add a coil to the thread."
     if len(loop) < 1:
         return
     loop = euclidean.getLoopStartingNearest(self.halfPerimeterWidth, self.oldLocationComplex, loop)
     length = euclidean.getLoopLength(loop)
     if length <= 0.0:
         return
     oldPoint = loop[0]
     pathLength = 0.0
     for point in loop[1:]:
         pathLength += abs(point - oldPoint)
         along = pathLength / length
         z = (1.0 - along) * beginLocation.z + along * endZ
         location = Vector3(point.real, point.imag, z)
         thread.append(location)
         oldPoint = point
     self.oldLocationComplex = loop[-1]
Esempio n. 7
0
 def __init__(self, loop, sideAngle=None, sideLength=None):
     "Initialize."
     if sideAngle == None:
         if len(loop) > 0:
             sideAngle = 2.0 * math.pi / float(len(loop))
         else:
             sideAngle = 1.0
             print('Warning, loop has no sides in SideLoop in lineation.')
     if sideLength == None:
         if len(loop) > 0:
             sideLength = euclidean.getLoopLength(loop) / float(len(loop))
         else:
             sideLength = 1.0
             print('Warning, loop has no length in SideLoop in lineation.')
     self.loop = loop
     self.sideAngle = abs(sideAngle)
     self.sideLength = sideLength
     self.close = 0.001 * sideLength
Esempio n. 8
0
	def __init__(self, loop, sideAngle=None, sideLength=None):
		'Initialize.'
		if sideAngle == None:
			if len(loop) > 0:
				sideAngle = 2.0 * math.pi / float(len(loop))
			else:
				sideAngle = 1.0
				print('Warning, loop has no sides in SideLoop in lineation.')
		if sideLength == None:
			if len(loop) > 0:
				sideLength = euclidean.getLoopLength(loop) / float(len(loop))
			else:
				sideLength = 1.0
				print('Warning, loop has no length in SideLoop in lineation.')
		self.loop = loop
		self.sideAngle = abs(sideAngle)
		self.sideLength = abs(sideLength)
		self.close = 0.001 * sideLength
Esempio n. 9
0
	def addCoilToThread(self, beginLocation, endZ, loop, thread):
		"Add a coil to the thread."
		if len(loop) < 1:
			return
		loop = euclidean.getLoopStartingClosest(self.halfEdgeWidth, self.oldLocationComplex, loop)
		length = euclidean.getLoopLength(loop)
		if length <= 0.0:
			return
		oldPoint = loop[0]
		pathLength = 0.0
		for point in loop[1 :]:
			pathLength += abs(point - oldPoint)
			along = pathLength / length
			z = (1.0 - along) * beginLocation.z + along * endZ
			location = Vector3(point.real, point.imag, z)
			thread.append(location)
			oldPoint = point
		self.oldLocationComplex = loop[-1]