def subtractJoinedFill(self, supportLayerIndex): 'Join the fill then subtract it from the support layer table.' supportLayer = self.supportLayers[supportLayerIndex] fillXIntersectionsTable = supportLayer.fillXIntersectionsTable belowFillXIntersectionsTable = self.supportLayers[ supportLayerIndex - 1 ].fillXIntersectionsTable euclidean.joinXIntersectionsTables(belowFillXIntersectionsTable, supportLayer.fillXIntersectionsTable) euclidean.subtractXIntersectionsTable(supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable)
def setBoundaryLayers(self): 'Set the boundary layers.' if len(self.boundaryLayers) < 2: return if self.supportLocation == 'EmptyLayersOnly': supportLayer = SupportLayer([]) self.supportLayers.append(supportLayer) for boundaryLayerIndex in xrange(1, len(self.boundaryLayers) - 1): self.addEmptyLayerSupport(boundaryLayerIndex) self.truncateSupportSegmentTables() self.addSegmentTablesToSupportLayers() return for boundaryLayer in self.boundaryLayers: # thresholdRadius of 0.8 is needed to avoid the ripple inset bug http://hydraraptor.blogspot.com/2010/12/crackers.html supportLoops = intercircle.getInsetSeparateLoopsFromLoops(-self.supportOutset, boundaryLayer, 0.8) supportLayer = SupportLayer(supportLoops) self.supportLayers.append(supportLayer) for supportLayerIndex in xrange(len(self.supportLayers) -1 ): self.addSupportSegmentTable(supportLayerIndex) self.truncateSupportSegmentTables() for supportLayerIndex in xrange(len(self.supportLayers) - 1): boundaryLoops = self.boundaryLayers[supportLayerIndex] self.extendXIntersections(boundaryLoops, self.supportOutset, self.supportLayers[supportLayerIndex].xIntersectionsTable) for supportLayer in self.supportLayers: self.addToFillXIntersectionIndexTables(supportLayer) if self.supportLocation == 'ExteriorOnly': for supportLayerIndex in xrange(1, len(self.supportLayers)): self.subtractJoinedFill(supportLayerIndex) for supportLayer in self.supportLayers: euclidean.subtractXIntersectionsTable(supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable) for supportLayerIndex in xrange(len(self.supportLayers) - 2, -1, -1): xIntersectionsTable = self.supportLayers[supportLayerIndex].xIntersectionsTable aboveXIntersectionsTable = self.supportLayers[supportLayerIndex + 1].xIntersectionsTable euclidean.joinXIntersectionsTables(aboveXIntersectionsTable, xIntersectionsTable) for supportLayerIndex in xrange(len(self.supportLayers)): supportLayer = self.supportLayers[supportLayerIndex] self.extendXIntersections(supportLayer.supportLoops, self.raftOutsetRadius, supportLayer.xIntersectionsTable) for supportLayer in self.supportLayers: euclidean.subtractXIntersectionsTable(supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable) self.addSegmentTablesToSupportLayers()
def parseBoundaries(self): "Parse the boundaries and add them to the boundary layers." boundaryLoop = None boundaryLayer = None for line in self.lines[self.lineIndex :]: splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) firstWord = gcodec.getFirstWord(splitLine) if firstWord == "(</boundaryPerimeter>)": boundaryLoop = None elif firstWord == "(<boundaryPoint>": location = gcodec.getLocationFromSplitLine(None, splitLine) if boundaryLoop == None: boundaryLoop = [] boundaryLayer.loops.append(boundaryLoop) boundaryLoop.append(location.dropAxis(2)) elif firstWord == "(<layer>": boundaryLayer = euclidean.LoopLayer(float(splitLine[1])) self.boundaryLayers.append(boundaryLayer) if len(self.boundaryLayers) < 2: return for boundaryLayer in self.boundaryLayers: boundaryLayer.innerOutsetLoops = intercircle.getInsetSeparateLoopsFromLoops( -self.loopInnerOutset, boundaryLayer.loops ) boundaryLayer.outerOutsetLoops = intercircle.getInsetSeparateLoopsFromLoops( -self.loopOuterOutset, boundaryLayer.loops ) boundaryLayer.innerHorizontalTable = self.getHorizontalXIntersectionsTable(boundaryLayer.innerOutsetLoops) boundaryLayer.outerHorizontalTable = self.getHorizontalXIntersectionsTable(boundaryLayer.outerOutsetLoops) boundaryLayer.innerVerticalTable = self.getHorizontalXIntersectionsTable( euclidean.getDiagonalFlippedLoops(boundaryLayer.innerOutsetLoops) ) boundaryLayer.outerVerticalTable = self.getHorizontalXIntersectionsTable( euclidean.getDiagonalFlippedLoops(boundaryLayer.outerOutsetLoops) ) for boundaryLayerIndex in xrange(len(self.boundaryLayers) - 2, -1, -1): boundaryLayer = self.boundaryLayers[boundaryLayerIndex] boundaryLayerBelow = self.boundaryLayers[boundaryLayerIndex + 1] euclidean.joinXIntersectionsTables( boundaryLayerBelow.outerHorizontalTable, boundaryLayer.outerHorizontalTable ) euclidean.joinXIntersectionsTables(boundaryLayerBelow.outerVerticalTable, boundaryLayer.outerVerticalTable) for boundaryLayerIndex in xrange(1, len(self.boundaryLayers)): boundaryLayer = self.boundaryLayers[boundaryLayerIndex] boundaryLayerAbove = self.boundaryLayers[boundaryLayerIndex - 1] euclidean.joinXIntersectionsTables( boundaryLayerAbove.innerHorizontalTable, boundaryLayer.innerHorizontalTable ) euclidean.joinXIntersectionsTables(boundaryLayerAbove.innerVerticalTable, boundaryLayer.innerVerticalTable) for boundaryLayerIndex in xrange(len(self.boundaryLayers)): self.addSegmentTableLoops(boundaryLayerIndex)
def unifyLayer(self, loopCrossDictionary): "Union the loopCrossDictionary with the unifiedLoop." euclidean.joinXIntersectionsTables( loopCrossDictionary.horizontalDictionary, self.unifiedLoop.horizontalDictionary ) euclidean.joinXIntersectionsTables(loopCrossDictionary.verticalDictionary, self.unifiedLoop.verticalDictionary)
def unifyLayer(self, loopCrossDictionary): 'Union the loopCrossDictionary with the unifiedLoop.' euclidean.joinXIntersectionsTables(loopCrossDictionary.horizontalDictionary, self.unifiedLoop.horizontalDictionary) euclidean.joinXIntersectionsTables(loopCrossDictionary.verticalDictionary, self.unifiedLoop.verticalDictionary)
def setBoundaryLayers(self): 'Set the boundary layers.' if len(self.boundaryLayers) < 2: return if self.supportLocation == 'EmptyLayersOnly': supportLayer = SupportLayer([]) self.supportLayers.append(supportLayer) for boundaryLayerIndex in xrange(1, len(self.boundaryLayers) - 1): self.addEmptyLayerSupport(boundaryLayerIndex) self.truncateSupportSegmentTables() self.addSegmentTablesToSupportLayers() return for boundaryLayer in self.boundaryLayers: # thresholdRadius of 0.8 is needed to avoid the ripple inset bug http://hydraraptor.blogspot.com/2010/12/crackers.html supportLoops = intercircle.getInsetSeparateLoopsFromLoops( -self.supportOutset, boundaryLayer, 0.8) supportLayer = SupportLayer(supportLoops) self.supportLayers.append(supportLayer) for supportLayerIndex in xrange(len(self.supportLayers) - 1): self.addSupportSegmentTable(supportLayerIndex) self.truncateSupportSegmentTables() for supportLayerIndex in xrange(len(self.supportLayers) - 1): boundaryLoops = self.boundaryLayers[supportLayerIndex] self.extendXIntersections( boundaryLoops, self.supportOutset, self.supportLayers[supportLayerIndex].xIntersectionsTable) for supportLayer in self.supportLayers: self.addToFillXIntersectionIndexTables(supportLayer) if self.supportLocation == 'ExteriorOnly': for supportLayerIndex in xrange(1, len(self.supportLayers)): self.subtractJoinedFill(supportLayerIndex) for supportLayer in self.supportLayers: euclidean.subtractXIntersectionsTable( supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable) for supportLayerIndex in xrange(len(self.supportLayers) - 2, -1, -1): xIntersectionsTable = self.supportLayers[ supportLayerIndex].xIntersectionsTable aboveXIntersectionsTable = self.supportLayers[ supportLayerIndex + 1].xIntersectionsTable euclidean.joinXIntersectionsTables(aboveXIntersectionsTable, xIntersectionsTable) for supportLayerIndex in xrange(len(self.supportLayers)): supportLayer = self.supportLayers[supportLayerIndex] self.extendXIntersections(supportLayer.supportLoops, self.raftOutsetRadius, supportLayer.xIntersectionsTable) for supportLayer in self.supportLayers: euclidean.subtractXIntersectionsTable( supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable) self.addSegmentTablesToSupportLayers()