def addSkinnedInfillBoundary(self, infillBoundaries, offsetY, upperZ, z): 'Add skinned infill boundary.' arounds = [] aroundWidth = 0.34321 * self.skinInfillInset endpoints = [] pixelTable = {} rotatedLoops = [] for infillBoundary in infillBoundaries: infillBoundaryRotated = euclidean.getRotatedComplexes(self.reverseRotation, infillBoundary) if offsetY != 0.0: for infillPointRotatedIndex, infillPointRotated in enumerate(infillBoundaryRotated): infillBoundaryRotated[infillPointRotatedIndex] = complex(infillPointRotated.real, infillPointRotated.imag - offsetY) rotatedLoops.append(infillBoundaryRotated) infillDictionary = triangle_mesh.getInfillDictionary( arounds, aroundWidth, self.skinInfillInset, self.skinInfillWidth, pixelTable, rotatedLoops) for infillDictionaryKey in infillDictionary.keys(): xIntersections = infillDictionary[infillDictionaryKey] xIntersections.sort() for segment in euclidean.getSegmentsFromXIntersections(xIntersections, infillDictionaryKey * self.skinInfillWidth): for endpoint in segment: endpoint.point = complex(endpoint.point.real, endpoint.point.imag + offsetY) endpoints.append(endpoint) infillPaths = euclidean.getPathsFromEndpoints(endpoints, 5.0 * self.skinInfillWidth, pixelTable, aroundWidth) for infillPath in infillPaths: infillRotated = euclidean.getRotatedComplexes(self.rotation, infillPath) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: self.distanceFeedRate.addGcodeMovementZWithFeedRate(self.maximumZFeedRateMinute, infillRotated[0], upperZ) self.distanceFeedRate.addGcodeFromFeedRateThreadZ(self.feedRateMinute, infillRotated, self.travelFeedRateMinute, z) lastPointRotated = infillRotated[-1] self.oldLocation = Vector3(lastPointRotated.real, lastPointRotated.imag, upperZ) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: self.distanceFeedRate.addGcodeMovementZWithFeedRate(self.maximumZFeedRateMinute, lastPointRotated, upperZ)
def getVerticalEndpoints(horizontalSegmentsTable, horizontalStep, verticalOverhang, verticalStep): 'Get vertical endpoints.' interfaceSegmentsTableKeys = horizontalSegmentsTable.keys() interfaceSegmentsTableKeys.sort() verticalTableTable = {} for interfaceSegmentsTableKey in interfaceSegmentsTableKeys: interfaceSegments = horizontalSegmentsTable[interfaceSegmentsTableKey] for interfaceSegment in interfaceSegments: begin = int(round(interfaceSegment[0].point.real / verticalStep)) end = int(round(interfaceSegment[1].point.real / verticalStep)) for stepIndex in xrange(begin, end + 1): if stepIndex not in verticalTableTable: verticalTableTable[stepIndex] = {} verticalTableTable[stepIndex][interfaceSegmentsTableKey] = None verticalTableTableKeys = verticalTableTable.keys() verticalTableTableKeys.sort() verticalEndpoints = [] for verticalTableTableKey in verticalTableTableKeys: verticalTable = verticalTableTable[verticalTableTableKey] verticalTableKeys = verticalTable.keys() verticalTableKeys.sort() xIntersections = [] for verticalTableKey in verticalTableKeys: y = verticalTableKey * horizontalStep if verticalTableKey - 1 not in verticalTableKeys: xIntersections.append(y - verticalOverhang) if verticalTableKey + 1 not in verticalTableKeys: xIntersections.append(y + verticalOverhang) for segment in euclidean.getSegmentsFromXIntersections(xIntersections, verticalTableTableKey * verticalStep): for endpoint in segment: endpoint.point = complex(endpoint.point.imag, endpoint.point.real) verticalEndpoints.append(endpoint) return verticalEndpoints
def addSkinnedInfillBoundary(self, infillBoundaries, offsetY, upperZ, z): 'Add skinned infill boundary.' aroundInset = 0.24321 * self.skinInfillInset arounds = [] aroundWidth = 0.24321 * self.skinInfillInset endpoints = [] pixelTable = {} rotatedLoops = [] for infillBoundary in infillBoundaries: infillBoundaryRotated = euclidean.getRotatedComplexes(self.reverseRotation, infillBoundary) if offsetY != 0.0: for infillPointRotatedIndex, infillPointRotated in enumerate(infillBoundaryRotated): infillBoundaryRotated[infillPointRotatedIndex] = complex(infillPointRotated.real, infillPointRotated.imag - offsetY) rotatedLoops.append(infillBoundaryRotated) infillDictionary = triangle_mesh.getInfillDictionary( aroundInset, arounds, aroundWidth, self.skinInfillInset, self.skinInfillWidth, pixelTable, rotatedLoops) for infillDictionaryKey in infillDictionary.keys(): xIntersections = infillDictionary[infillDictionaryKey] xIntersections.sort() for segment in euclidean.getSegmentsFromXIntersections(xIntersections, infillDictionaryKey * self.skinInfillWidth): for endpoint in segment: endpoint.point = complex(endpoint.point.real, endpoint.point.imag + offsetY) endpoints.append(endpoint) infillPaths = euclidean.getPathsFromEndpoints(endpoints, 5.0 * self.skinInfillWidth, pixelTable, aroundWidth) for infillPath in infillPaths: infillRotated = euclidean.getRotatedComplexes(self.rotation, infillPath) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: self.distanceFeedRate.addGcodeMovementZWithFeedRate(self.maximumZFeedRateMinute, infillRotated[0], upperZ) self.distanceFeedRate.addGcodeFromFeedRateThreadZ(self.feedRateMinute, infillRotated, self.travelFeedRateMinute, z) lastPointRotated = infillRotated[-1] self.oldLocation = Vector3(lastPointRotated.real, lastPointRotated.imag, upperZ) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: self.distanceFeedRate.addGcodeMovementZWithFeedRate(self.maximumZFeedRateMinute, lastPointRotated, upperZ)
def extendXIntersections(self, loops, radius, xIntersectionsTable): 'Extend the support segments.' xIntersectionsTableKeys = xIntersectionsTable.keys() for xIntersectionsTableKey in xIntersectionsTableKeys: lineSegments = euclidean.getSegmentsFromXIntersections( xIntersectionsTable[xIntersectionsTableKey], xIntersectionsTableKey) xIntersectionIndexList = [] loopXIntersections = [] euclidean.addXIntersectionsFromLoops(loops, loopXIntersections, xIntersectionsTableKey) for lineSegmentIndex in xrange(len(lineSegments)): lineSegment = lineSegments[lineSegmentIndex] extendedLineSegment = getExtendedLineSegment( radius, lineSegment, loopXIntersections) if extendedLineSegment != None: euclidean.addXIntersectionIndexesFromSegment( lineSegmentIndex, extendedLineSegment, xIntersectionIndexList) xIntersections = euclidean.getJoinOfXIntersectionIndexes( xIntersectionIndexList) if len(xIntersections) > 0: xIntersectionsTable[xIntersectionsTableKey] = xIntersections else: del xIntersectionsTable[xIntersectionsTableKey]
def addSegmentTablesToSupportLayers(self): 'Add segment tables to the support layers.' for supportLayer in self.supportLayers: supportLayer.supportSegmentTable = {} xIntersectionsTable = supportLayer.xIntersectionsTable for xIntersectionsTableKey in xIntersectionsTable: y = xIntersectionsTableKey * self.interfaceStep supportLayer.supportSegmentTable[ xIntersectionsTableKey ] = euclidean.getSegmentsFromXIntersections(xIntersectionsTable[ xIntersectionsTableKey ], y)
def addSkinnedInfillBoundary(self, infillBoundaries, offsetY, upperZ, z): "Add skinned infill boundary." arounds = [] aroundWidth = 0.34321 * self.skinInfillInset endpoints = [] pixelTable = {} rotatedLoops = [] for infillBoundary in infillBoundaries: infillBoundaryRotated = euclidean.getRotatedComplexes(self.reverseRotation, infillBoundary) if offsetY != 0.0: for infillPointRotatedIndex, infillPointRotated in enumerate(infillBoundaryRotated): infillBoundaryRotated[infillPointRotatedIndex] = complex( infillPointRotated.real, infillPointRotated.imag - offsetY ) rotatedLoops.append(infillBoundaryRotated) infillDictionary = triangle_mesh.getInfillDictionary( arounds, aroundWidth, self.skinInfillInset, self.skinInfillWidth, pixelTable, rotatedLoops ) for infillDictionaryKey in infillDictionary.keys(): xIntersections = infillDictionary[infillDictionaryKey] xIntersections.sort() for segment in euclidean.getSegmentsFromXIntersections( xIntersections, infillDictionaryKey * self.skinInfillWidth ): for endpoint in segment: endpoint.point = complex(endpoint.point.real, endpoint.point.imag + offsetY) endpoints.append(endpoint) infillPaths = euclidean.getPathsFromEndpoints( endpoints, 5.0 * self.skinInfillWidth, pixelTable, self.sharpestProduct, aroundWidth ) for infillPath in infillPaths: addPointBeforeThread = True infillRotated = euclidean.getRotatedComplexes(self.rotation, infillPath) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: feedRateMinute = self.travelFeedRateMinute infillRotatedFirst = infillRotated[0] location = Vector3(infillRotatedFirst.real, infillRotatedFirst.imag, upperZ) distance = abs(location - self.oldLocation) if distance > 0.0: deltaZ = abs(upperZ - self.oldLocation.z) zFeedRateComponent = feedRateMinute * deltaZ / distance if zFeedRateComponent > self.maximumZFeedRateMinute: feedRateMinute *= self.maximumZFeedRateMinute / zFeedRateComponent self.distanceFeedRate.addGcodeMovementZWithFeedRate(feedRateMinute, infillRotatedFirst, upperZ) self.distanceFeedRate.addGcodeMovementZWithFeedRate(self.maximumZFeedRateMinute, infillRotatedFirst, z) addPointBeforeThread = False if addPointBeforeThread: self.distanceFeedRate.addGcodeMovementZ(infillRotated[0], z) self.distanceFeedRate.addLine("M101") for point in infillRotated[1:]: self.distanceFeedRate.addGcodeMovementZ(point, z) self.distanceFeedRate.addLine("M103") lastPointRotated = infillRotated[-1] self.oldLocation = Vector3(lastPointRotated.real, lastPointRotated.imag, upperZ) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: self.distanceFeedRate.addGcodeMovementZWithFeedRate( self.maximumZFeedRateMinute, lastPointRotated, upperZ )
def getHorizontalSegmentTableForXIntersectionsTable( self, xIntersectionsTable ): "Get the horizontal segment table from the xIntersectionsTable." horizontalSegmentTable = {} xIntersectionsTableKeys = xIntersectionsTable.keys() xIntersectionsTableKeys.sort() for xIntersectionsTableKey in xIntersectionsTableKeys: xIntersections = xIntersectionsTable[ xIntersectionsTableKey ] segments = euclidean.getSegmentsFromXIntersections( xIntersections, xIntersectionsTableKey * self.millWidth ) horizontalSegmentTable[ xIntersectionsTableKey ] = segments return horizontalSegmentTable
def getHorizontalSegmentTableForXIntersectionsTable( self, xIntersectionsTable ): 'Get the horizontal segment table from the xIntersectionsTable.' horizontalSegmentTable = {} xIntersectionsTableKeys = xIntersectionsTable.keys() xIntersectionsTableKeys.sort() for xIntersectionsTableKey in xIntersectionsTableKeys: xIntersections = xIntersectionsTable[ xIntersectionsTableKey ] segments = euclidean.getSegmentsFromXIntersections( xIntersections, xIntersectionsTableKey * self.millWidth ) horizontalSegmentTable[ xIntersectionsTableKey ] = segments return horizontalSegmentTable
def addSegmentTablesToSupportLayers(self): 'Add segment tables to the support layers.' for supportLayer in self.supportLayers: supportLayer.supportSegmentTable = {} xIntersectionsTable = supportLayer.xIntersectionsTable for xIntersectionsTableKey in xIntersectionsTable: y = xIntersectionsTableKey * self.interfaceStep supportLayer.supportSegmentTable[ xIntersectionsTableKey] = euclidean.getSegmentsFromXIntersections( xIntersectionsTable[xIntersectionsTableKey], y)
def getVerticalSegmentTableForXIntersectionsTable( self, xIntersectionsTable ): "Get the vertical segment table from the xIntersectionsTable which has the x and y swapped." verticalSegmentTable = {} xIntersectionsTableKeys = xIntersectionsTable.keys() xIntersectionsTableKeys.sort() for xIntersectionsTableKey in xIntersectionsTableKeys: xIntersections = xIntersectionsTable[ xIntersectionsTableKey ] segments = euclidean.getSegmentsFromXIntersections( xIntersections, xIntersectionsTableKey * self.millWidth ) for segment in segments: for endpoint in segment: endpoint.point = complex( endpoint.point.imag, endpoint.point.real ) verticalSegmentTable[ xIntersectionsTableKey ] = segments return verticalSegmentTable
def getVerticalSegmentTableForXIntersectionsTable( self, xIntersectionsTable ): 'Get the vertical segment table from the xIntersectionsTable which has the x and y swapped.' verticalSegmentTable = {} xIntersectionsTableKeys = xIntersectionsTable.keys() xIntersectionsTableKeys.sort() for xIntersectionsTableKey in xIntersectionsTableKeys: xIntersections = xIntersectionsTable[ xIntersectionsTableKey ] segments = euclidean.getSegmentsFromXIntersections( xIntersections, xIntersectionsTableKey * self.millWidth ) for segment in segments: for endpoint in segment: endpoint.point = complex( endpoint.point.imag, endpoint.point.real ) verticalSegmentTable[ xIntersectionsTableKey ] = segments return verticalSegmentTable
def addSkinnedInfillBoundary(self, infillBoundaries, offsetY, upperZ, z): 'Add skinned infill boundary.' arounds = [] aroundWidth = 0.34321 * self.skinInfillInset endpoints = [] pixelTable = {} rotatedLoops = [] for infillBoundary in infillBoundaries: infillBoundaryRotated = euclidean.getRotatedComplexes(self.reverseRotation, infillBoundary) if offsetY != 0.0: for infillPointRotatedIndex, infillPointRotated in enumerate(infillBoundaryRotated): infillBoundaryRotated[infillPointRotatedIndex] = complex(infillPointRotated.real, infillPointRotated.imag - offsetY) rotatedLoops.append(infillBoundaryRotated) infillDictionary = triangle_mesh.getInfillDictionary( arounds, aroundWidth, self.skinInfillInset, self.skinInfillWidth, pixelTable, rotatedLoops) for infillDictionaryKey in infillDictionary.keys(): xIntersections = infillDictionary[infillDictionaryKey] xIntersections.sort() for segment in euclidean.getSegmentsFromXIntersections(xIntersections, infillDictionaryKey * self.skinInfillWidth): for endpoint in segment: endpoint.point = complex(endpoint.point.real, endpoint.point.imag + offsetY) endpoints.append(endpoint) infillPaths = euclidean.getPathsFromEndpoints(endpoints, 5.0 * self.skinInfillWidth, pixelTable, self.sharpestProduct, aroundWidth) for infillPath in infillPaths: addPointBeforeThread = True infillRotated = euclidean.getRotatedComplexes(self.rotation, infillPath) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: feedRateMinute = self.travelFeedRateMinute infillRotatedFirst = infillRotated[0] location = Vector3(infillRotatedFirst.real, infillRotatedFirst.imag, upperZ) distance = abs(location - self.oldLocation) if distance > 0.0: deltaZ = abs(upperZ - self.oldLocation.z) zFeedRateComponent = feedRateMinute * deltaZ / distance if zFeedRateComponent > self.maximumZFeedRateMinute: feedRateMinute *= self.maximumZFeedRateMinute / zFeedRateComponent self.distanceFeedRate.addGcodeMovementZWithFeedRate(feedRateMinute, infillRotatedFirst, upperZ) self.distanceFeedRate.addGcodeMovementZWithFeedRate(self.maximumZFeedRateMinute, infillRotatedFirst, z) addPointBeforeThread = False if addPointBeforeThread: self.distanceFeedRate.addGcodeMovementZ(infillRotated[0], z) self.distanceFeedRate.addLine('M101') for point in infillRotated[1 :]: self.distanceFeedRate.addGcodeMovementZ(point, z) self.distanceFeedRate.addLine('M103') lastPointRotated = infillRotated[-1] self.oldLocation = Vector3(lastPointRotated.real, lastPointRotated.imag, upperZ) if upperZ > z and self.repository.hopWhenExtrudingInfill.value: self.distanceFeedRate.addGcodeMovementZWithFeedRate(self.maximumZFeedRateMinute, lastPointRotated, upperZ)
def extendXIntersections(self, loops, radius, xIntersectionsTable): 'Extend the support segments.' xIntersectionsTableKeys = xIntersectionsTable.keys() for xIntersectionsTableKey in xIntersectionsTableKeys: lineSegments = euclidean.getSegmentsFromXIntersections(xIntersectionsTable[ xIntersectionsTableKey ], xIntersectionsTableKey) xIntersectionIndexList = [] loopXIntersections = [] euclidean.addXIntersectionsFromLoops(loops, loopXIntersections, xIntersectionsTableKey) for lineSegmentIndex in xrange(len(lineSegments)): lineSegment = lineSegments[ lineSegmentIndex ] extendedLineSegment = getExtendedLineSegment(radius, lineSegment, loopXIntersections) if extendedLineSegment != None: euclidean.addXIntersectionIndexesFromSegment(lineSegmentIndex, extendedLineSegment, xIntersectionIndexList) xIntersections = euclidean.getJoinOfXIntersectionIndexes(xIntersectionIndexList) if len(xIntersections) > 0: xIntersectionsTable[ xIntersectionsTableKey ] = xIntersections else: del xIntersectionsTable[ xIntersectionsTableKey ]
def getVerticalEndpoints(horizontalSegmentsTable, horizontalStep, verticalOverhang, verticalStep): 'Get vertical endpoints.' interfaceSegmentsTableKeys = horizontalSegmentsTable.keys() interfaceSegmentsTableKeys.sort() verticalTableTable = {} for interfaceSegmentsTableKey in interfaceSegmentsTableKeys: interfaceSegments = horizontalSegmentsTable[interfaceSegmentsTableKey] for interfaceSegment in interfaceSegments: begin = int(round(interfaceSegment[0].point.real / verticalStep)) end = int(round(interfaceSegment[1].point.real / verticalStep)) for stepIndex in xrange(begin, end + 1): if stepIndex not in verticalTableTable: verticalTableTable[stepIndex] = {} verticalTableTable[stepIndex][interfaceSegmentsTableKey] = None verticalTableTableKeys = verticalTableTable.keys() verticalTableTableKeys.sort() verticalEndpoints = [] for verticalTableTableKey in verticalTableTableKeys: verticalTable = verticalTableTable[verticalTableTableKey] verticalTableKeys = verticalTable.keys() verticalTableKeys.sort() xIntersections = [] for verticalTableKey in verticalTableKeys: y = verticalTableKey * horizontalStep if verticalTableKey - 1 not in verticalTableKeys: xIntersections.append(y - verticalOverhang) if verticalTableKey + 1 not in verticalTableKeys: xIntersections.append(y + verticalOverhang) for segment in euclidean.getSegmentsFromXIntersections( xIntersections, verticalTableTableKey * verticalStep): for endpoint in segment: endpoint.point = complex(endpoint.point.imag, endpoint.point.real) verticalEndpoints.append(endpoint) return verticalEndpoints