Exemple #1
0
def getBridgeDirection(belowLoops, layerLoops, layerThickness):
    "Get span direction for the majority of the overhanging extrusion perimeter, if any."
    if len(belowLoops) < 1:
        return None
    belowOutsetLoops = []
    overhangInset = 1.875 * layerThickness
    slightlyGreaterThanOverhang = 1.1 * overhangInset
    for loop in belowLoops:
        centers = intercircle.getCentersFromLoopDirection(
            True, loop, slightlyGreaterThanOverhang)
        for center in centers:
            outset = intercircle.getSimplifiedInsetFromClockwiseLoop(
                center, overhangInset)
            if intercircle.isLargeSameDirection(outset, center, overhangInset):
                belowOutsetLoops.append(outset)
    bridgeRotation = complex()
    for loop in layerLoops:
        for pointIndex in xrange(len(loop)):
            previousIndex = (pointIndex + len(loop) - 1) % len(loop)
            bridgeRotation += getOverhangDirection(belowOutsetLoops,
                                                   loop[previousIndex],
                                                   loop[pointIndex])
    if abs(bridgeRotation) < 0.75 * layerThickness:
        return None
    else:
        bridgeRotation /= abs(bridgeRotation)
        return cmath.sqrt(bridgeRotation)
def getExtraFillLoops(loops, radius):
    'Get extra loops between inside and outside loops. Extra perimeters'
    greaterThanRadius = radius / 0.7853  #todo was  *1.4 ACT (radius /0.7853)  how much the tight spots are covered by the extra loops
    extraFillLoops = []
    centers = intercircle.getCentersFromPoints(intercircle.getPointsFromLoops(loops, greaterThanRadius), greaterThanRadius)
    for center in centers:
        inset = intercircle.getSimplifiedInsetFromClockwiseLoop(center, radius)
        if intercircle.isLargeSameDirection(inset, center, radius):
            if euclidean.getIsInFilledRegion(loops, euclidean.getLeftPoint(inset)):
                inset.reverse()
                extraFillLoops.append(inset)
    return extraFillLoops
Exemple #3
0
def addAlreadyFilledArounds( alreadyFilledArounds, loop, radius ):
	"Add already filled loops around loop to alreadyFilledArounds."
	radius = abs(radius)
	alreadyFilledLoop = []
	slightlyGreaterThanRadius = intercircle.globalIntercircleMultiplier * radius
	muchGreaterThanRadius = 2.5 * radius
	centers = intercircle.getCentersFromLoop( loop, slightlyGreaterThanRadius )
	for center in centers:
		alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, radius )
		if intercircle.isLargeSameDirection( alreadyFilledInset, center, radius ):
			alreadyFilledLoop.append( alreadyFilledInset )
	if len( alreadyFilledLoop ) > 0:
		alreadyFilledArounds.append( alreadyFilledLoop )
def getBridgeLoops( layerThickness, loop ):
	"Get the inset bridge loops from the loop."
	halfWidth = 1.5 * layerThickness
	slightlyGreaterThanHalfWidth = 1.1 * halfWidth
	extrudateLoops = []
	centers = intercircle.getCentersFromLoop( loop, slightlyGreaterThanHalfWidth )
	for center in centers:
		extrudateLoop = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfWidth )
		if intercircle.isLargeSameDirection( extrudateLoop, center, halfWidth ):
			if euclidean.isPathInsideLoop( loop, extrudateLoop ) == euclidean.isWiddershins( loop ):
				extrudateLoop.reverse()
				extrudateLoops.append( extrudateLoop )
	return extrudateLoops
Exemple #5
0
def getBridgeLoops( layerThickness, loop ):
	'Get the inset bridge loops from the loop.'
	halfWidth = 1.5 * layerThickness
	slightlyGreaterThanHalfWidth = 1.1 * halfWidth
	extrudateLoops = []
	centers = intercircle.getCentersFromLoop( loop, slightlyGreaterThanHalfWidth )
	for center in centers:
		extrudateLoop = intercircle.getSimplifiedInsetFromClockwiseLoop( center, halfWidth )
		if intercircle.isLargeSameDirection( extrudateLoop, center, halfWidth ):
			if euclidean.isPathInsideLoop( loop, extrudateLoop ) == euclidean.isWiddershins(loop):
				extrudateLoop.reverse()
				extrudateLoops.append( extrudateLoop )
	return extrudateLoops
Exemple #6
0
def addAlreadyFilledArounds( alreadyFilledArounds, loop, radius ):
	"Add already filled loops around loop to alreadyFilledArounds."
	radius = abs(radius)
	alreadyFilledLoop = []
	slightlyGreaterThanRadius = intercircle.globalIntercircleMultiplier * radius
	muchGreaterThanRadius = 2.5 * radius
	centers = intercircle.getCentersFromLoop( loop, slightlyGreaterThanRadius )
	for center in centers:
		alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, radius )
		if intercircle.isLargeSameDirection( alreadyFilledInset, center, radius ):
			alreadyFilledLoop.append( alreadyFilledInset )
	if len( alreadyFilledLoop ) > 0:
		alreadyFilledArounds.append( alreadyFilledLoop )
def getExtraFillLoops(loops, radius):
    'Get extra loops between inside and outside loops. Extra perimeters'
    greaterThanRadius = radius / 0.7853  #todo was  *1.4 ACT (radius /0.7853)  how much the tight spots are covered by the extra loops
    extraFillLoops = []
    centers = intercircle.getCentersFromPoints(
        intercircle.getPointsFromLoops(loops, greaterThanRadius),
        greaterThanRadius)
    for center in centers:
        inset = intercircle.getSimplifiedInsetFromClockwiseLoop(center, radius)
        if intercircle.isLargeSameDirection(inset, center, radius):
            if euclidean.getIsInFilledRegion(loops,
                                             euclidean.getLeftPoint(inset)):
                inset.reverse()
                extraFillLoops.append(inset)
    return extraFillLoops
def getBridgeDirection( belowLoops, layerLoops, layerThickness ):
	"Get span direction for the majority of the overhanging extrusion perimeter, if any."
	if len( belowLoops ) < 1:
		return None
	belowOutsetLoops = []
	overhangInset = 1.875 * layerThickness
	slightlyGreaterThanOverhang = 1.1 * overhangInset
	for loop in belowLoops:
		centers = intercircle.getCentersFromLoopDirection( True, loop, slightlyGreaterThanOverhang )
		for center in centers:
			outset = intercircle.getSimplifiedInsetFromClockwiseLoop( center, overhangInset )
			if intercircle.isLargeSameDirection( outset, center, overhangInset ):
				belowOutsetLoops.append( outset )
	bridgeRotation = complex()
	for loop in layerLoops:
		for pointIndex in xrange( len( loop ) ):
			previousIndex = ( pointIndex + len( loop ) - 1 ) % len( loop )
			bridgeRotation += getOverhangDirection( belowOutsetLoops, loop[ previousIndex ], loop[ pointIndex ] )
	if abs( bridgeRotation ) < 0.75 * layerThickness:
		return None
	else:
		bridgeRotation /= abs( bridgeRotation )
		return cmath.sqrt( bridgeRotation )
    def fill(self, layer):
        'Add fill to the carve layer.'
        layerIndex = layer.index
        alreadyFilledArounds = []
        pixelTable = {}
        arounds = []
        betweenWidth = self.extrusionWidth / 1.7594801994   # this really sucks I cant find hwe#(self.repository.infillWidthOverThickness.value * self.extrusionWidth *(0.7853))/1.5 #- 0.0866#todo todo TODO *0.5 is the distance between the outer loops..
        self.layerExtrusionWidth = self.infillWidth # spacing between fill lines
        layerFillInset = self.infillWidth  # the distance between perimeter incl loops and the fill pattern
        
        layerRotation = self.getLayerRotation(layerIndex, layer)
        reverseRotation = complex(layerRotation.real, -layerRotation.imag)
        surroundingCarves = []
        layerRemainder = layerIndex % self.diaphragmPeriod
        extraShells = self.extraShellsSparseLayer
        
        if layerRemainder >= self.diaphragmThickness and layer.bridgeRotation == None:
            for surroundingIndex in xrange(1, self.solidSurfaceThickness + 1):
                self.addRotatedCarve(layerIndex, -surroundingIndex, reverseRotation, surroundingCarves)
                self.addRotatedCarve(layerIndex, surroundingIndex, reverseRotation, surroundingCarves)

        if len(surroundingCarves) < self.doubleSolidSurfaceThickness:
            extraShells = self.extraShellsAlternatingSolidLayer
            if self.previousExtraShells != self.extraShellsBase:
                extraShells = self.extraShellsBase
         
        if layer.bridgeRotation != None:
            extraShells = 0
            betweenWidth *= self.bridgeWidthMultiplier#/0.7853  #todo check what is better with or without the normalizer
            self.layerExtrusionWidth *= self.bridgeWidthMultiplier
            layerFillInset *= self.bridgeWidthMultiplier
         
        aroundInset = 0.25 * self.layerExtrusionWidth
        aroundWidth = 0.25 * self.layerExtrusionWidth
        self.previousExtraShells = extraShells
        gridPointInsetX = 0.5 * layerFillInset
        doubleExtrusionWidth = 2.0 * self.layerExtrusionWidth
        endpoints = []
        infillPaths = []
        layerInfillSolidity = self.infillSolidity
        
        self.isDoubleJunction = True
        self.isJunctionWide = True
        rotatedLoops = []

        nestedRings = layer.nestedRings
        
        createFillForSurroundings(nestedRings, betweenWidth, False)
         
        for extraShellIndex in xrange(extraShells):
            createFillForSurroundings(nestedRings, self.layerExtrusionWidth, True)

        fillLoops = euclidean.getFillOfSurroundings(nestedRings, None)
        
        slightlyGreaterThanFill = 1.001 * layerFillInset #todo was 1.01 ACT 0.95  How much the parallel fill is filled
         
        for loop in fillLoops:
            alreadyFilledLoop = []
            alreadyFilledArounds.append(alreadyFilledLoop)
            planeRotatedPerimeter = euclidean.getPointsRoundZAxis(reverseRotation, loop)
            rotatedLoops.append(planeRotatedPerimeter)
            centers = intercircle.getCentersFromLoop(planeRotatedPerimeter, slightlyGreaterThanFill)
            euclidean.addLoopToPixelTable(planeRotatedPerimeter, pixelTable, aroundWidth)
            for center in centers:
                alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop(center, layerFillInset)
                if intercircle.isLargeSameDirection(alreadyFilledInset, center, layerFillInset):
                    alreadyFilledLoop.append(alreadyFilledInset)
                    around = intercircle.getSimplifiedInsetFromClockwiseLoop(center, aroundInset)
                    if euclidean.isPathInsideLoop(planeRotatedPerimeter, around) == euclidean.isWiddershins(planeRotatedPerimeter):
                        around.reverse()
                        arounds.append(around)
                        euclidean.addLoopToPixelTable(around, pixelTable, aroundWidth)
         
        if len(arounds) < 1:
            self.addThreadsBridgeLayer(layerIndex, nestedRings, layer)
            return
         
        back = euclidean.getBackOfLoops(arounds)
        front = euclidean.getFrontOfLoops(arounds)
        front = math.ceil(front / self.layerExtrusionWidth) * self.layerExtrusionWidth
        fillWidth = back - front
        numberOfLines = int(math.ceil(fillWidth / self.layerExtrusionWidth))
        self.frontOverWidth = 0.0
        self.horizontalSegmentLists = euclidean.getHorizontalSegmentListsFromLoopLists(alreadyFilledArounds, front, numberOfLines, rotatedLoops, self.layerExtrusionWidth)
        self.surroundingXIntersectionLists = []
        self.yList = []
        removedEndpoints = []
         
        if len(surroundingCarves) >= self.doubleSolidSurfaceThickness:
            xIntersectionIndexLists = []
            self.frontOverWidth = euclidean.getFrontOverWidthAddXListYList(front, surroundingCarves, numberOfLines, xIntersectionIndexLists, self.layerExtrusionWidth, self.yList)
            for fillLine in xrange(len(self.horizontalSegmentLists)):
                xIntersectionIndexList = xIntersectionIndexLists[fillLine]
                surroundingXIntersections = euclidean.getIntersectionOfXIntersectionIndexes(self.doubleSolidSurfaceThickness, xIntersectionIndexList)
                self.surroundingXIntersectionLists.append(surroundingXIntersections)
                addSparseEndpoints(doubleExtrusionWidth, endpoints, fillLine, self.horizontalSegmentLists, layerInfillSolidity, removedEndpoints, self.solidSurfaceThickness, surroundingXIntersections)
        else:
            for fillLine in xrange(len(self.horizontalSegmentLists)):
                addSparseEndpoints(doubleExtrusionWidth, endpoints, fillLine, self.horizontalSegmentLists, layerInfillSolidity, removedEndpoints, self.solidSurfaceThickness, None)
         
        paths = euclidean.getPathsFromEndpoints(endpoints, 5.0 * self.layerExtrusionWidth, pixelTable, aroundWidth)
         
        oldRemovedEndpointLength = len(removedEndpoints) + 1
         
        while oldRemovedEndpointLength - len(removedEndpoints) > 0:
            oldRemovedEndpointLength = len(removedEndpoints)
            removeEndpoints(pixelTable, self.layerExtrusionWidth, paths, removedEndpoints, aroundWidth)
        
        paths = euclidean.getConnectedPaths(paths, pixelTable, aroundWidth)
         
        for path in paths:
            addPathToInfillPaths(self.layerExtrusionWidth, infillPaths, path, layerRotation)

        for nestedRing in nestedRings:
            nestedRing.transferPaths(infillPaths)
         
        self.addThreadsBridgeLayer(layerIndex, nestedRings, layer)
    def fill(self, layer):
        'Add fill to the carve layer.'
        layerIndex = layer.index
        alreadyFilledArounds = []
        pixelTable = {}
        arounds = []
        betweenWidth = self.extrusionWidth / 1.7594801994  # this really sucks I cant find hwe#(self.repository.infillWidthOverThickness.value * self.extrusionWidth *(0.7853))/1.5 #- 0.0866#todo todo TODO *0.5 is the distance between the outer loops..
        self.layerExtrusionWidth = self.infillWidth  # spacing between fill lines
        layerFillInset = self.infillWidth  # the distance between perimeter incl loops and the fill pattern

        layerRotation = self.getLayerRotation(layerIndex, layer)
        reverseRotation = complex(layerRotation.real, -layerRotation.imag)
        surroundingCarves = []
        layerRemainder = layerIndex % self.diaphragmPeriod
        extraShells = self.extraShellsSparseLayer

        if layerRemainder >= self.diaphragmThickness and layer.bridgeRotation == None:
            for surroundingIndex in xrange(1, self.solidSurfaceThickness + 1):
                self.addRotatedCarve(layerIndex, -surroundingIndex,
                                     reverseRotation, surroundingCarves)
                self.addRotatedCarve(layerIndex, surroundingIndex,
                                     reverseRotation, surroundingCarves)

        if len(surroundingCarves) < self.doubleSolidSurfaceThickness:
            extraShells = self.extraShellsAlternatingSolidLayer
            if self.previousExtraShells != self.extraShellsBase:
                extraShells = self.extraShellsBase

        if layer.bridgeRotation != None:
            extraShells = 0
            betweenWidth *= self.bridgeWidthMultiplier  #/0.7853  #todo check what is better with or without the normalizer
            self.layerExtrusionWidth *= self.bridgeWidthMultiplier
            layerFillInset *= self.bridgeWidthMultiplier

        aroundInset = 0.25 * self.layerExtrusionWidth
        aroundWidth = 0.25 * self.layerExtrusionWidth
        self.previousExtraShells = extraShells
        gridPointInsetX = 0.5 * layerFillInset
        doubleExtrusionWidth = 2.0 * self.layerExtrusionWidth
        endpoints = []
        infillPaths = []
        layerInfillSolidity = self.infillSolidity

        self.isDoubleJunction = True
        self.isJunctionWide = True
        rotatedLoops = []

        nestedRings = layer.nestedRings

        createFillForSurroundings(nestedRings, betweenWidth, False)

        for extraShellIndex in xrange(extraShells):
            createFillForSurroundings(nestedRings, self.layerExtrusionWidth,
                                      True)

        fillLoops = euclidean.getFillOfSurroundings(nestedRings, None)

        slightlyGreaterThanFill = 1.001 * layerFillInset  #todo was 1.01 ACT 0.95  How much the parallel fill is filled

        for loop in fillLoops:
            alreadyFilledLoop = []
            alreadyFilledArounds.append(alreadyFilledLoop)
            planeRotatedPerimeter = euclidean.getPointsRoundZAxis(
                reverseRotation, loop)
            rotatedLoops.append(planeRotatedPerimeter)
            centers = intercircle.getCentersFromLoop(planeRotatedPerimeter,
                                                     slightlyGreaterThanFill)
            euclidean.addLoopToPixelTable(planeRotatedPerimeter, pixelTable,
                                          aroundWidth)
            for center in centers:
                alreadyFilledInset = intercircle.getSimplifiedInsetFromClockwiseLoop(
                    center, layerFillInset)
                if intercircle.isLargeSameDirection(alreadyFilledInset, center,
                                                    layerFillInset):
                    alreadyFilledLoop.append(alreadyFilledInset)
                    around = intercircle.getSimplifiedInsetFromClockwiseLoop(
                        center, aroundInset)
                    if euclidean.isPathInsideLoop(
                            planeRotatedPerimeter,
                            around) == euclidean.isWiddershins(
                                planeRotatedPerimeter):
                        around.reverse()
                        arounds.append(around)
                        euclidean.addLoopToPixelTable(around, pixelTable,
                                                      aroundWidth)

        if len(arounds) < 1:
            self.addThreadsBridgeLayer(layerIndex, nestedRings, layer)
            return

        back = euclidean.getBackOfLoops(arounds)
        front = euclidean.getFrontOfLoops(arounds)
        front = math.ceil(
            front / self.layerExtrusionWidth) * self.layerExtrusionWidth
        fillWidth = back - front
        numberOfLines = int(math.ceil(fillWidth / self.layerExtrusionWidth))
        self.frontOverWidth = 0.0
        self.horizontalSegmentLists = euclidean.getHorizontalSegmentListsFromLoopLists(
            alreadyFilledArounds, front, numberOfLines, rotatedLoops,
            self.layerExtrusionWidth)
        self.surroundingXIntersectionLists = []
        self.yList = []
        removedEndpoints = []

        if len(surroundingCarves) >= self.doubleSolidSurfaceThickness:
            xIntersectionIndexLists = []
            self.frontOverWidth = euclidean.getFrontOverWidthAddXListYList(
                front, surroundingCarves, numberOfLines,
                xIntersectionIndexLists, self.layerExtrusionWidth, self.yList)
            for fillLine in xrange(len(self.horizontalSegmentLists)):
                xIntersectionIndexList = xIntersectionIndexLists[fillLine]
                surroundingXIntersections = euclidean.getIntersectionOfXIntersectionIndexes(
                    self.doubleSolidSurfaceThickness, xIntersectionIndexList)
                self.surroundingXIntersectionLists.append(
                    surroundingXIntersections)
                addSparseEndpoints(doubleExtrusionWidth, endpoints, fillLine,
                                   self.horizontalSegmentLists,
                                   layerInfillSolidity, removedEndpoints,
                                   self.solidSurfaceThickness,
                                   surroundingXIntersections)
        else:
            for fillLine in xrange(len(self.horizontalSegmentLists)):
                addSparseEndpoints(doubleExtrusionWidth, endpoints, fillLine,
                                   self.horizontalSegmentLists,
                                   layerInfillSolidity, removedEndpoints,
                                   self.solidSurfaceThickness, None)

        paths = euclidean.getPathsFromEndpoints(endpoints,
                                                5.0 * self.layerExtrusionWidth,
                                                pixelTable, aroundWidth)

        oldRemovedEndpointLength = len(removedEndpoints) + 1

        while oldRemovedEndpointLength - len(removedEndpoints) > 0:
            oldRemovedEndpointLength = len(removedEndpoints)
            removeEndpoints(pixelTable, self.layerExtrusionWidth, paths,
                            removedEndpoints, aroundWidth)

        paths = euclidean.getConnectedPaths(paths, pixelTable, aroundWidth)

        for path in paths:
            addPathToInfillPaths(self.layerExtrusionWidth, infillPaths, path,
                                 layerRotation)

        for nestedRing in nestedRings:
            nestedRing.transferPaths(infillPaths)

        self.addThreadsBridgeLayer(layerIndex, nestedRings, layer)