def createSkirtLoops(self): 'Create the skirt loops.' points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.skirtOutset-self.edgeWidth*(self.repository.brimWidth.value+1)) self.outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: self.outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(self.outsetLoops))] self.outsetBrimLoops = [] for self.brimLine in xrange( self.repository.brimWidth.value-1, self.brimLine, -1 ): points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.edgeWidth*(self.brimLine+0.5)) outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(outsetLoops))] self.outsetBrimLoops += outsetLoops if self.repository.brimWidth.value > 0: points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.edgeWidth*0.5) outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(outsetLoops))] self.outsetBrimLoops += outsetLoops
def createSkirtLoops(self): 'Create the skirt loops.' points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.skirtOutset-self.edgeWidth*(self.repository.brimWidth.value+1)) self.outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: self.outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(self.outsetLoops))] if self.repository.brimWidth.value > 0: points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.edgeWidth*0.5) outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(outsetLoops))] self.outsetBrimLoops = outsetLoops for self.brimLine in xrange(self.brimLine+1,self.repository.brimWidth.value): points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.edgeWidth*(self.brimLine+0.5)) outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(outsetLoops))] self.outsetBrimLoops += outsetLoops
def addSegmentTableLoops( self, boundaryLayerIndex ): 'Add the segment tables and loops to the boundary.' boundaryLayer = self.boundaryLayers[boundaryLayerIndex] euclidean.subtractXIntersectionsTable(boundaryLayer.outerHorizontalTable, boundaryLayer.innerHorizontalTable) euclidean.subtractXIntersectionsTable(boundaryLayer.outerVerticalTable, boundaryLayer.innerVerticalTable) boundaryLayer.horizontalSegmentTable = self.getHorizontalSegmentTableForXIntersectionsTable( boundaryLayer.outerHorizontalTable) boundaryLayer.verticalSegmentTable = self.getVerticalSegmentTableForXIntersectionsTable( boundaryLayer.outerVerticalTable) betweenPoints = getPointsFromSegmentTable(boundaryLayer.horizontalSegmentTable) betweenPoints += getPointsFromSegmentTable(boundaryLayer.verticalSegmentTable) innerPoints = euclidean.getPointsByHorizontalDictionary(self.millWidth, boundaryLayer.innerHorizontalTable) innerPoints += euclidean.getPointsByVerticalDictionary(self.millWidth, boundaryLayer.innerVerticalTable) innerPointTable = {} for innerPoint in innerPoints: innerPointTable[innerPoint] = None boundaryLayer.innerLoops = [] boundaryLayer.outerLoops = [] millRadius = 0.75 * self.millWidth loops = triangle_mesh.getDescendingAreaOrientedLoops(betweenPoints, betweenPoints, millRadius) for loop in loops: if isPointOfTableInLoop(loop, innerPointTable): boundaryLayer.innerLoops.append(loop) else: boundaryLayer.outerLoops.append(loop) if self.repository.crossHatch.value and boundaryLayerIndex % 2 == 1: boundaryLayer.segmentTable = boundaryLayer.verticalSegmentTable else: boundaryLayer.segmentTable = boundaryLayer.horizontalSegmentTable
def getLoopsBySegmentsDictionary(segmentsDictionary, width): 'Get loops from a horizontal segments dictionary.' points = [] for endpoint in getVerticalEndpoints(segmentsDictionary, width, 0.1 * width, width): points.append(endpoint.point) for endpoint in euclidean.getEndpointsFromSegmentTable(segmentsDictionary): points.append(endpoint.point) return triangle_mesh.getDescendingAreaOrientedLoops(points, points, width + width)
def createSkirtLoops(self): 'Create the skirt loops.' points = euclidean.getPointsByHorizontalDictionary(self.perimeterWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.perimeterWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, self.perimeterWidth) outerLoops = getOuterLoops(loops) self.outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(-self.skirtOutset, outerLoops) self.outsetLoops = getOuterLoops(self.outsetLoops)
def createSkirtLoops(self): 'Create the skirt loops.' points = euclidean.getPointsByHorizontalDictionary(self.perimeterWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.perimeterWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.perimeterWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(-self.skirtOutset, outerLoops) self.outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: self.outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(self.outsetLoops))]
def createSkirtLoops(self): "Create the skirt loops." points = euclidean.getPointsByHorizontalDictionary(self.perimeterWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.perimeterWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.perimeterWidth) outerLoops = getOuterLoops(loops) outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.skirtOutset) self.outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: self.outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(self.outsetLoops))]
def getLoopsBySegmentsDictionary(segmentsDictionary, width): 'Get loops from a horizontal segments dictionary.' points = [] for endpoint in getVerticalEndpoints(segmentsDictionary, width, 0.1 * width, width): points.append(endpoint.point) for endpoint in euclidean.getEndpointsFromSegmentTable(segmentsDictionary): points.append(endpoint.point) return triangle_mesh.getDescendingAreaOrientedLoops( points, points, width + width)
def getLoopsIntersectionByPair(importRadius, loopsFirst, loopsLast): 'Get intersection loops for a pair of loop lists.' halfImportRadius = 0.5 * importRadius # so that there are no misses on shallow angles radiusSide = 0.01 * importRadius corners = [] corners += getInsetPointsByInsetLoops(loopsFirst, True, loopsLast, radiusSide) corners += getInsetPointsByInsetLoops(loopsLast, True, loopsFirst, radiusSide) allPoints = corners[:] allPoints += getInsetPointsByInsetLoops(getInBetweenLoopsFromLoops(loopsFirst, halfImportRadius), True, loopsLast, radiusSide) allPoints += getInsetPointsByInsetLoops(getInBetweenLoopsFromLoops(loopsLast, halfImportRadius), True, loopsFirst, radiusSide) return triangle_mesh.getDescendingAreaOrientedLoops(allPoints, corners, importRadius)
def createSkirtLoops(self): 'Create the skirt loops.' points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) self.outsetLoops = [] for i in xrange(self.repository.skirtLineCount.value, 0, -1): outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(outerLoops, -self.skirtOutset - i * self.edgeWidth) outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(outsetLoops))] self.outsetLoops.extend(outsetLoops)
def getLoopsDifference(importRadius, loopLists): 'Get difference loops.' halfImportRadius = 0.5 * importRadius # so that there are no misses on shallow angles radiusSide = 0.01 * importRadius negativeLoops = getLoopsUnified(importRadius, loopLists[1 :]) intercircle.directLoops(False, negativeLoops) positiveLoops = loopLists[0] intercircle.directLoops(True, positiveLoops) corners = getInsetPointsByInsetLoops(negativeLoops, True, positiveLoops, radiusSide) corners += getInsetPointsByInsetLoops(positiveLoops, False, negativeLoops, radiusSide) allPoints = corners[:] allPoints += getInsetPointsByInsetLoops(getInBetweenLoopsFromLoops(negativeLoops, halfImportRadius), True, positiveLoops, radiusSide) allPoints += getInsetPointsByInsetLoops(getInBetweenLoopsFromLoops(positiveLoops, halfImportRadius), False, negativeLoops, radiusSide) return triangle_mesh.getDescendingAreaOrientedLoops(allPoints, corners, importRadius)
def getLoopsUnion(importRadius, loopLists): "Get joined loops sliced through shape." allPoints = [] corners = getLoopsListsIntersections(loopLists) radiusSideNegative = -0.01 * importRadius intercircle.directLoopLists(True, loopLists) for loopListIndex in xrange(len(loopLists)): insetLoops = loopLists[loopListIndex] inBetweenInsetLoops = getInBetweenLoopsFromLoops(insetLoops, importRadius) otherLoops = euclidean.getConcatenatedList(loopLists[:loopListIndex] + loopLists[loopListIndex + 1 :]) corners += getInsetPointsByInsetLoops(insetLoops, False, otherLoops, radiusSideNegative) allPoints += getInsetPointsByInsetLoops(inBetweenInsetLoops, False, otherLoops, radiusSideNegative) allPoints += corners[:] return triangle_mesh.getDescendingAreaOrientedLoops(allPoints, corners, importRadius)
def getLoopsUnified(importRadius, loopLists): 'Get joined loops sliced through shape.' allPoints = [] corners = getLoopsListsIntersections(loopLists) radiusSide = 0.01 * importRadius radiusSideNegative = -radiusSide intercircle.directLoopLists(True, loopLists) for loopListIndex in xrange(len(loopLists)): insetLoops = loopLists[ loopListIndex ] inBetweenInsetLoops = getInBetweenLoopsFromLoops(insetLoops, importRadius) otherLoops = euclidean.getConcatenatedList(loopLists[: loopListIndex] + loopLists[loopListIndex + 1 :]) corners += getInsetPointsByInsetLoops(insetLoops, False, otherLoops, radiusSide) allPoints += getInsetPointsByInsetLoops(inBetweenInsetLoops, False, otherLoops, radiusSideNegative) allPoints += corners[:] return triangle_mesh.getDescendingAreaOrientedLoops(allPoints, corners, importRadius)
def createSkirtLoops(self, gap, shellCount): "Create the skirt loops." outset = gap + self.edgeWidth points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = self.getOuterLoops(loops) skirtLoops = [] for shellNo in xrange(shellCount): outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(-(outset + self.edgeWidth * shellNo), outerLoops) outsetLoops = self.getOuterLoops(outsetLoops) if self.convex: outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(outsetLoops))] for outsetLoop in outsetLoops: skirtLoops.append(outsetLoop + [outsetLoop[0]]) return skirtLoops
def createSkirtLoops(self, gap, shellCount): 'Create the skirt loops.' outset = gap + self.edgeWidth points = euclidean.getPointsByHorizontalDictionary(self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary(self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops(points, points, 2.5 * self.edgeWidth) outerLoops = self.getOuterLoops(loops) skirtLoops = [] for shellNo in xrange(shellCount): outsetLoops = intercircle.getInsetSeparateLoopsFromLoops(-(outset + self.edgeWidth * shellNo), outerLoops) outsetLoops = self.getOuterLoops(outsetLoops) if self.convex: outsetLoops = [euclidean.getLoopConvex(euclidean.getConcatenatedList(outsetLoops))] for outsetLoop in outsetLoops: skirtLoops.append(outsetLoop + [outsetLoop[0]]) return skirtLoops
def createSkirtLoops(self): 'Create the skirt loops.' points = euclidean.getPointsByHorizontalDictionary( self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary( self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops( points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) self.outsetLoops = [] for i in xrange(self.repository.skirtLineCount.value, 0, -1): outsetLoops = intercircle.getInsetSeparateLoopsFromLoops( outerLoops, -self.skirtOutset - (i - 1) * self.edgeWidth) outsetLoops = getOuterLoops(outsetLoops) if self.repository.convex.value: outsetLoops = [ euclidean.getLoopConvex( euclidean.getConcatenatedList(outsetLoops)) ] self.outsetLoops.extend(outsetLoops)
def createSkirtAndBrimLoops(self): 'Create the skirt loops.' points = euclidean.getPointsByHorizontalDictionary( self.edgeWidth, self.unifiedLoop.horizontalDictionary) points += euclidean.getPointsByVerticalDictionary( self.edgeWidth, self.unifiedLoop.verticalDictionary) loops = triangle_mesh.getDescendingAreaOrientedLoops( points, points, 2.5 * self.edgeWidth) outerLoops = getOuterLoops(loops) 'Create combined skirt and/or brim loops' self.baseOutsetLoops = [] self.upperOutsetLoops = [] 'self.getSkirtShellOutset(0)' skirtMin = self.getShellOutset( math.floor(self.repository.gapOverEdgeWidth.value)) skirtMax = self.getShellOutset( math.ceil(self.repository.gapOverEdgeWidth.value) + self.repository.baseShells.value) brimMax = self.getShellOutset(self.repository.brimWidth.value) if self.repository.activateSkirt.value and not self.repository.activateBrim.value: self.upperOutsetLoops = self.getOutsetLoops( outerLoops, -self.getSkirtShellOutset(0), self.repository.convex.value) for shellIndex in xrange(self.repository.baseShells.value, 0, -1): outsetLoops = self.getOutsetLoops( outerLoops, -self.getSkirtShellOutset(shellIndex - 1), self.repository.convex.value) self.baseOutsetLoops += outsetLoops elif not self.repository.activateSkirt.value and self.repository.activateBrim.value: for shellIndex in xrange(self.repository.brimWidth.value, 0, -1): outsetLoops = self.getOutsetLoops( outerLoops, -self.getShellOutset(shellIndex - 1), False) self.baseOutsetLoops += outsetLoops elif self.repository.activateSkirt.value and self.repository.activateBrim.value: if skirtMax <= brimMax: 'Skirt is fully inside brim' 'With a convex skirt the threads of skirt may have a big distance to perimeter.' 'Even if brim is large (brim should be non convex in optimal code), the convex skirt and the outer brim may collide' 'Next best solution so far is to make outer brim also following convex. The critical outer corners are touched anyway.' self.upperOutsetLoops = self.getOutsetLoops( outerLoops, -self.skirtOutset, self.repository.convex.value) for shellIndex in xrange(self.repository.brimWidth.value, 0, -1): if (self.getShellOutset(shellIndex - 1) >= skirtMin): outsetLoops = self.getOutsetLoops( outerLoops, -self.getShellOutset(shellIndex - 1), self.repository.convex.value) else: outsetLoops = self.getOutsetLoops( outerLoops, -self.getShellOutset(shellIndex - 1), False) self.baseOutsetLoops += outsetLoops elif skirtMax > brimMax: 'Skirt base shells starts outside brim' if skirtMin >= brimMax: 'Skirt base is outside of brim' 'For skirt base layers we can use convex because convex threads are always further away from perimeter then BrimMax.' self.upperOutsetLoops = self.getOutsetLoops( outerLoops, -self.skirtOutset, self.repository.convex.value) for shellIndex in xrange(self.repository.baseShells.value, 0, -1): outsetLoops = self.getOutsetLoops( outerLoops, -self.getSkirtShellOutset(shellIndex - 1), self.repository.convex.value) self.baseOutsetLoops += outsetLoops for shellIndex in xrange(self.repository.brimWidth.value, 0, -1): outsetLoops = self.getOutsetLoops( outerLoops, -self.getShellOutset(shellIndex - 1), False) self.baseOutsetLoops += outsetLoops else: 'Skirt base touches brim' self.upperOutsetLoops = self.getOutsetLoops( outerLoops, -self.skirtOutset, self.repository.convex.value) for shellIndex in xrange( self.repository.baseShells.value + self.repository.brimWidth.value, 0, -1): if (self.getShellOutset(shellIndex - 1) < skirtMax ) and (self.getShellOutset(shellIndex - 1) >= skirtMin): outsetLoops = self.getOutsetLoops( outerLoops, -self.getShellOutset(shellIndex - 1), self.repository.convex.value) self.baseOutsetLoops += outsetLoops elif (self.getShellOutset(shellIndex - 1) < skirtMin): outsetLoops = self.getOutsetLoops( outerLoops, -self.getShellOutset(shellIndex - 1), False) self.baseOutsetLoops += outsetLoops