def splitPointGetAfter(self, location, nextLocation): "Bevel a point and return the end of the bevel. should get complex for radius" if self.filletRadius < 2.0 * self.minimumRadius: return location afterSegment = nextLocation - location afterSegmentComplex = afterSegment.dropAxis(2) afterSegmentComplexLength = abs(afterSegmentComplex) thirdAfterSegmentLength = 0.333 * afterSegmentComplexLength if thirdAfterSegmentLength < self.minimumRadius: return location beforeSegment = self.oldLocation - location beforeSegmentComplex = beforeSegment.dropAxis(2) beforeSegmentComplexLength = abs(beforeSegmentComplex) thirdBeforeSegmentLength = 0.333 * beforeSegmentComplexLength if thirdBeforeSegmentLength < self.minimumRadius: return location extruderOffReversalPoint = self.getExtruderOffReversalPoint( afterSegment, afterSegmentComplex, beforeSegment, beforeSegmentComplex, location) if extruderOffReversalPoint != None: return extruderOffReversalPoint bevelRadius = min(thirdAfterSegmentLength, self.filletRadius) bevelRadius = min(thirdBeforeSegmentLength, bevelRadius) self.shouldAddLine = False beforePoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs(beforeSegment) / beforeSegmentComplexLength, location, beforeSegment) self.addLinearMovePoint(self.feedRateMinute, beforePoint) afterPoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs(afterSegment) / afterSegmentComplexLength, location, afterSegment) self.addLinearMovePoint(self.getCornerFeedRate(), afterPoint) return afterPoint
def getExtruderOffReversalPoint(self, afterSegment, afterSegmentComplex, beforeSegment, beforeSegmentComplex, location): "If the extruder is off and the path is reversing, add intermediate slow points." if self.filletRepository.reversalSlowdownDistanceOverPerimeterWidth.value < 0.1: return None if self.extruderActive: return None reversalBufferSlowdownDistance = self.reversalSlowdownDistance * 2.0 afterSegmentComplexLength = abs(afterSegmentComplex) if afterSegmentComplexLength < reversalBufferSlowdownDistance: return None beforeSegmentComplexLength = abs(beforeSegmentComplex) if beforeSegmentComplexLength < reversalBufferSlowdownDistance: return None afterSegmentComplexNormalized = afterSegmentComplex / afterSegmentComplexLength beforeSegmentComplexNormalized = beforeSegmentComplex / beforeSegmentComplexLength if euclidean.getDotProduct(afterSegmentComplexNormalized, beforeSegmentComplexNormalized) < 0.95: return None slowdownFeedRate = self.feedRateMinute * 0.5 self.shouldAddLine = False beforePoint = euclidean.getPointPlusSegmentWithLength( self.reversalSlowdownDistance * abs(beforeSegment) / beforeSegmentComplexLength, location, beforeSegment) self.addLinearMovePoint(self.feedRateMinute, beforePoint) self.addLinearMovePoint(slowdownFeedRate, location) afterPoint = euclidean.getPointPlusSegmentWithLength( self.reversalSlowdownDistance * abs(afterSegment) / afterSegmentComplexLength, location, afterSegment) self.addLinearMovePoint(slowdownFeedRate, afterPoint) return afterPoint
def splitPointGetAfter( self, location, nextLocation ): "Bevel a point and return the end of the bevel. should get complex for radius" if self.filletRadius < 2.0 * self.minimumRadius: return location afterSegment = nextLocation - location afterSegmentComplex = afterSegment.dropAxis() afterSegmentComplexLength = abs( afterSegmentComplex ) thirdAfterSegmentLength = 0.333 * afterSegmentComplexLength if thirdAfterSegmentLength < self.minimumRadius: return location beforeSegment = self.oldLocation - location beforeSegmentComplex = beforeSegment.dropAxis() beforeSegmentComplexLength = abs( beforeSegmentComplex ) thirdBeforeSegmentLength = 0.333 * beforeSegmentComplexLength if thirdBeforeSegmentLength < self.minimumRadius: return location extruderOffReversalPoint = self.getExtruderOffReversalPoint( afterSegment, afterSegmentComplex, beforeSegment, beforeSegmentComplex, location ) if extruderOffReversalPoint != None: return extruderOffReversalPoint bevelRadius = min( thirdAfterSegmentLength, self.filletRadius ) bevelRadius = min( thirdBeforeSegmentLength, bevelRadius ) self.shouldAddLine = False beforePoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs( beforeSegment ) / beforeSegmentComplexLength, location, beforeSegment ) self.addLinearMovePoint( self.feedRateMinute, beforePoint ) afterPoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs( afterSegment ) / afterSegmentComplexLength, location, afterSegment ) self.addLinearMovePoint( self.getCornerFeedRate(), afterPoint ) return afterPoint
def getExtruderOffReversalPoint( self, afterSegment, afterSegmentComplex, beforeSegment, beforeSegmentComplex, location ): "If the extruder is off and the path is reversing, add intermediate slow points." if self.repository.reversalSlowdownDistanceOverEdgeWidth.value < 0.1: return None if self.extruderActive: return None reversalBufferSlowdownDistance = self.reversalSlowdownDistance * 2.0 afterSegmentComplexLength = abs( afterSegmentComplex ) if afterSegmentComplexLength < reversalBufferSlowdownDistance: return None beforeSegmentComplexLength = abs( beforeSegmentComplex ) if beforeSegmentComplexLength < reversalBufferSlowdownDistance: return None afterSegmentComplexNormalized = afterSegmentComplex / afterSegmentComplexLength beforeSegmentComplexNormalized = beforeSegmentComplex / beforeSegmentComplexLength if euclidean.getDotProduct( afterSegmentComplexNormalized, beforeSegmentComplexNormalized ) < 0.95: return None slowdownFeedRate = self.feedRateMinute * 0.5 self.shouldAddLine = False beforePoint = euclidean.getPointPlusSegmentWithLength( self.reversalSlowdownDistance * abs( beforeSegment ) / beforeSegmentComplexLength, location, beforeSegment ) self.addLinearMovePoint( self.feedRateMinute, beforePoint ) self.addLinearMovePoint( slowdownFeedRate, location ) afterPoint = euclidean.getPointPlusSegmentWithLength( self.reversalSlowdownDistance * abs( afterSegment ) / afterSegmentComplexLength, location, afterSegment ) self.addLinearMovePoint( slowdownFeedRate, afterPoint ) return afterPoint
def splitPointGetAfter(self, location, nextLocation): "Fillet a point into arc segments and return the end of the last segment." if self.filletRadius < 2.0 * self.minimumRadius: return location afterSegment = nextLocation - location afterSegmentComplex = afterSegment.dropAxis(2) thirdAfterSegmentLength = 0.333 * abs(afterSegmentComplex) if thirdAfterSegmentLength < self.minimumRadius: return location beforeSegment = self.oldLocation - location beforeSegmentComplex = beforeSegment.dropAxis(2) thirdBeforeSegmentLength = 0.333 * abs(beforeSegmentComplex) if thirdBeforeSegmentLength < self.minimumRadius: return location extruderOffReversalPoint = self.getExtruderOffReversalPoint( afterSegment, afterSegmentComplex, beforeSegment, beforeSegmentComplex, location) if extruderOffReversalPoint != None: return extruderOffReversalPoint bevelRadius = min(thirdAfterSegmentLength, self.filletRadius) bevelRadius = min(thirdBeforeSegmentLength, bevelRadius) self.shouldAddLine = False beforePoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs(beforeSegment) / abs(beforeSegmentComplex), location, beforeSegment) self.addLinearMovePoint(self.feedRateMinute, beforePoint) afterPoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs(afterSegment) / abs(afterSegmentComplex), location, afterSegment) afterPointComplex = afterPoint.dropAxis(2) beforePointComplex = beforePoint.dropAxis(2) locationComplex = location.dropAxis(2) midPoint = 0.5 * (afterPoint + beforePoint) midPointComplex = midPoint.dropAxis(2) midPointMinusLocationComplex = midPointComplex - locationComplex midPointLocationLength = abs(midPointMinusLocationComplex) if midPointLocationLength < 0.01 * self.filletRadius: self.addLinearMovePoint(self.getCornerFeedRate(), afterPoint) return afterPoint midPointAfterPointLength = abs(midPointComplex - afterPointComplex) midPointCenterLength = midPointAfterPointLength * midPointAfterPointLength / midPointLocationLength radius = math.sqrt(midPointCenterLength * midPointCenterLength + midPointAfterPointLength * midPointAfterPointLength) centerComplex = midPointComplex + midPointMinusLocationComplex * midPointCenterLength / midPointLocationLength center = Vector3(centerComplex.real, centerComplex.imag, midPoint.z) afterCenterComplex = afterPointComplex - centerComplex beforeMinusCenterCenterComplex = beforePointComplex - centerComplex beforeCenter = beforePoint - center beforeCenterComplex = beforeCenter.dropAxis(2) subtractComplexMirror = complex(beforeCenterComplex.real, -beforeCenterComplex.imag) differenceComplex = subtractComplexMirror * afterCenterComplex differenceAngle = math.atan2(differenceComplex.imag, differenceComplex.real) self.addArc(differenceAngle, afterPoint, beforeCenter, beforePoint, center) return afterPoint
def splitPointGetAfter(self, location, nextLocation): "Fillet a point into arc segments and return the end of the last segment." if self.filletRadius < 2.0 * self.minimumRadius: return location afterSegment = nextLocation - location afterSegmentComplex = afterSegment.dropAxis(2) thirdAfterSegmentLength = 0.333 * abs(afterSegmentComplex) if thirdAfterSegmentLength < self.minimumRadius: return location beforeSegment = self.oldLocation - location beforeSegmentComplex = beforeSegment.dropAxis(2) thirdBeforeSegmentLength = 0.333 * abs(beforeSegmentComplex) if thirdBeforeSegmentLength < self.minimumRadius: return location extruderOffReversalPoint = self.getExtruderOffReversalPoint( afterSegment, afterSegmentComplex, beforeSegment, beforeSegmentComplex, location ) if extruderOffReversalPoint != None: return extruderOffReversalPoint bevelRadius = min(thirdAfterSegmentLength, self.filletRadius) bevelRadius = min(thirdBeforeSegmentLength, bevelRadius) self.shouldAddLine = False beforePoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs(beforeSegment) / abs(beforeSegmentComplex), location, beforeSegment ) self.addLinearMovePoint(self.feedRateMinute, beforePoint) afterPoint = euclidean.getPointPlusSegmentWithLength( bevelRadius * abs(afterSegment) / abs(afterSegmentComplex), location, afterSegment ) afterPointComplex = afterPoint.dropAxis(2) beforePointComplex = beforePoint.dropAxis(2) locationComplex = location.dropAxis(2) midpoint = 0.5 * (afterPoint + beforePoint) midpointComplex = midpoint.dropAxis(2) midpointMinusLocationComplex = midpointComplex - locationComplex midpointLocationLength = abs(midpointMinusLocationComplex) if midpointLocationLength < 0.01 * self.filletRadius: self.addLinearMovePoint(self.getCornerFeedRate(), afterPoint) return afterPoint midpointAfterPointLength = abs(midpointComplex - afterPointComplex) midpointCenterLength = midpointAfterPointLength * midpointAfterPointLength / midpointLocationLength radius = math.sqrt( midpointCenterLength * midpointCenterLength + midpointAfterPointLength * midpointAfterPointLength ) centerComplex = midpointComplex + midpointMinusLocationComplex * midpointCenterLength / midpointLocationLength center = Vector3(centerComplex.real, centerComplex.imag, midpoint.z) afterCenterComplex = afterPointComplex - centerComplex beforeCenter = beforePoint - center angleDifference = euclidean.getAngleDifferenceByComplex(afterCenterComplex, beforeCenter.dropAxis()) self.addArc(angleDifference, afterPoint, beforeCenter, beforePoint, center) return afterPoint