def getZAddExtruderPaths(self, z): 'Get next z and add extruder loops.' settings.printProgress(len(self.rotatedLoopLayers), 'slice') rotatedLoopLayer = euclidean.RotatedLoopLayer(z) rotatedLoopLayer.loops = self.getLoopsFromMesh( self.zoneArrangement.getEmptyZ(z)) return getZAddExtruderPathsBySolidCarving(rotatedLoopLayer, self, z)
def getExtruderPaths(self, z): "Get extruder loops." rotatedBoundaryLayer = euclidean.RotatedLoopLayer(z) for carvableObject in self.carvableObjects: rotatedBoundaryLayer.loops += carvableObject.getLoops( self.importRadius, z) return rotatedBoundaryLayer
def parseLine(self, line): "Parse a gcode line and add it to the inset skein." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<boundaryPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) self.boundary.append(location.dropAxis(2)) elif (firstWord == '(<bridgeRotation>' or firstWord == '<!--bridgeRotation-->'): secondWordWithoutBrackets = splitLine[1].replace('(', '').replace( ')', '') self.rotatedBoundaryLayer.rotation = complex( secondWordWithoutBrackets) elif firstWord == '(</extrusion>)': self.distanceFeedRate.addLine(line) if self.repository.turnExtruderHeaterOffAtShutDown.value: self.distanceFeedRate.addLine( 'M104 S0') # Turn extruder heater off. return elif firstWord == '(<layer>': self.rotatedBoundaryLayer = euclidean.RotatedLoopLayer( float(splitLine[1])) self.distanceFeedRate.addLine(line) elif firstWord == '(</layer>)': self.addInset(self.rotatedBoundaryLayer) self.rotatedBoundaryLayer = None elif firstWord == '(<surroundingLoop>)': self.boundary = [] self.rotatedBoundaryLayer.loops.append(self.boundary) if self.rotatedBoundaryLayer == None: self.distanceFeedRate.addLine(line)
def parseLine(self, line): "Parse a gcode line and add it to the inset skein." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<boundaryPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) self.boundary.append(location.dropAxis()) elif firstWord == '(<bridgeRotation>': self.rotatedLoopLayer.rotation = gcodec.getRotationBySplitLine(splitLine) elif firstWord == '(</crafting>)': self.distanceFeedRate.addLine(line) if self.repository.turnExtruderHeaterOffAtShutDown.value: self.distanceFeedRate.addLine('M104 S0') # Turn extruder heater off. return elif firstWord == '(<layer>': self.layerCount.printProgressIncrement('inset') self.rotatedLoopLayer = euclidean.RotatedLoopLayer(float(splitLine[1])) self.distanceFeedRate.addLine(line) elif firstWord == '(</layer>)': self.addInset( self.rotatedLoopLayer ) self.rotatedLoopLayer = None elif firstWord == '(<nestedRing>)': self.boundary = [] self.rotatedLoopLayer.loops.append( self.boundary ) if self.rotatedLoopLayer == None: self.distanceFeedRate.addLine(line)
def getRotatedLoopLayer(self): "Return the rotated loop layer." if self.z != None: rotatedLoopLayer = euclidean.RotatedLoopLayer(self.z) self.rotatedLoopLayers.append(rotatedLoopLayer) rotatedLoopLayer.rotation = self.bridgeRotation self.z = None return self.rotatedLoopLayers[-1]
def getZAddExtruderPaths(self, z): 'Get next z and add extruder loops.' settings.printProgress(len(self.rotatedLoopLayers), 'slice') rotatedLoopLayer = euclidean.RotatedLoopLayer(z) rotatedLoopLayer.loops = getEmptyZLoops(self.archivableObjects, self.importRadius, True, z, self.zoneArrangement) return triangle_mesh.getZAddExtruderPathsBySolidCarving( rotatedLoopLayer, self, z)
def importModule(self): "Import the python script and store the layers." path = os.path.abspath(self.untilDotName) pluginModule = gcodec.getModuleWithPath(path) loopLayers = pluginModule.getLoopLayers(self.layerThickness) for loopLayer in loopLayers: rotatedBoundaryLayer = euclidean.RotatedLoopLayer(loopLayer.z) rotatedBoundaryLayer.loops = loopLayer.loops self.rotatedBoundaryLayers.append(rotatedBoundaryLayer)
def processContourLayers( self, file ): "Process a contour layer at a time until the top of the part." while True: minLayer = getLittleEndianFloatGivenFile( file ) numContours = getLittleEndianUnsignedLongGivenFile( file ) if numContours == 0xFFFFFFFF: return rotatedLoopLayer = euclidean.RotatedLoopLayer( minLayer ) self.rotatedLoopLayers.append( rotatedLoopLayer ) for contourIndex in xrange( numContours ): numPoints = getLittleEndianUnsignedLongGivenFile( file ) numGaps = getLittleEndianUnsignedLongGivenFile( file ) if numPoints > 2: rotatedLoopLayer.loops.append( getPointsFromFile( numPoints, file ) )
def getEmptyZExtruderPaths( self, shouldPrintWarning, z ): "Get extruder loops." z = trianglemesh.getEmptyZ(self, z) rotatedBoundaryLayer = euclidean.RotatedLoopLayer(z) visibleObjectLoopsList = booleansolid.getVisibleObjectLoopsList( self.importRadius, evaluate.getVisibleObjects(self.archivableObjects), z ) rotatedBoundaryLayer.loops = euclidean.getConcatenatedList( visibleObjectLoopsList ) if euclidean.isLoopListIntersecting(rotatedBoundaryLayer.loops): rotatedBoundaryLayer.loops = booleansolid.getLoopsUnified(self.importRadius, visibleObjectLoopsList) if shouldPrintWarning: print('Warning, the triangle mesh slice intersects itself in getExtruderPaths in boolean_geometry.') print( "Something will still be printed, but there is no guarantee that it will be the correct shape." ) print('Once the gcode is saved, you should check over the layer with a z of:') print(z) return rotatedBoundaryLayer
def processSVGElement(self, fileName): 'Parse SVG element and store the layers.' self.fileName = fileName paths = self.xmlElement.object.getPaths() if len(paths) < 1: return firstPath = paths[0] if len(firstPath) < 1: return rotatedLoopLayer = euclidean.RotatedLoopLayer(firstPath[0].z) self.rotatedLoopLayers.append(rotatedLoopLayer) for path in paths: rotatedLoopLayer.loops.append(euclidean.getComplexPath(path)) self.cornerMaximum = Vector3(-999999999.0, -999999999.0, -999999999.0) self.cornerMinimum = Vector3(999999999.0, 999999999.0, 999999999.0) svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.rotatedLoopLayers)
def getZAddExtruderPaths(self, z): "Get next z and add extruder loops." rotatedBoundaryLayer = euclidean.RotatedLoopLayer(z) self.rotatedBoundaryLayers.append(rotatedBoundaryLayer) rotatedBoundaryLayer.loops = self.getLoopsFromMesh(getEmptyZ(self, z)) if self.bridgeLayerThickness == None: return z + self.layerThickness allExtrudateLoops = [] for loop in rotatedBoundaryLayer.loops: allExtrudateLoops += getBridgeLoops(self.layerThickness, loop) rotatedBoundaryLayer.rotation = getBridgeDirection( self.belowLoops, allExtrudateLoops, self.layerThickness) self.belowLoops = allExtrudateLoops if rotatedBoundaryLayer.rotation == None: return z + self.layerThickness return z + self.bridgeLayerThickness
def addTextData(line, rotatedBoundaryLayers): "Add the data from the text line." if line.find('layerThickness') != -1: return line = line.replace('>', ' ') line = line.replace('<', ' ') line = line.replace(',', ' ') splitLine = line.split() if 'Layer' not in splitLine: return splitLine = splitLine[splitLine.index('Layer') + 1:] if 'z' not in splitLine: return zIndex = splitLine.index('z') rotatedBoundaryLayer = euclidean.RotatedLoopLayer( float(splitLine[zIndex + 1])) rotatedBoundaryLayers.append(rotatedBoundaryLayer)
def processSVGElement(self, fileName): 'Parse SVG element and store the layers.' self.fileName = fileName paths = self.elementNode.xmlObject.getPaths() oldZ = None self.rotatedLoopLayers = [] rotatedLoopLayer = None for path in paths: if len(path) > 0: z = path[0].z if z != oldZ: rotatedLoopLayer = euclidean.RotatedLoopLayer(z) self.rotatedLoopLayers.append(rotatedLoopLayer) oldZ = z rotatedLoopLayer.loops.append(euclidean.getComplexPath(path)) if len(self.rotatedLoopLayers) < 1: return self.cornerMaximum = Vector3(-987654321.0, -987654321.0, -987654321.0) self.cornerMinimum = Vector3(987654321.0, 987654321.0, 987654321.0) svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.rotatedLoopLayers)
def parseLine(self, line): "Parse a gcode line and add it to the widen skein." splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<boundaryPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) self.boundary.append( location.dropAxis(2) ) elif firstWord == '(<layer>': self.rotatedBoundaryLayer = euclidean.RotatedLoopLayer( float(splitLine[1]) ) self.distanceFeedRate.addLine(line) elif firstWord == '(</layer>)': self.addWiden( self.rotatedBoundaryLayer ) self.rotatedBoundaryLayer = None elif firstWord == '(<surroundingLoop>)': self.boundary = [] self.rotatedBoundaryLayer.loops.append( self.boundary ) if self.rotatedBoundaryLayer == None: self.distanceFeedRate.addLine(line)
def parseLine( self, lineIndex ): "Parse a gcode line and add it to the outset skein." line = self.lines[lineIndex].lstrip() splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<boundaryPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) self.boundary.append( location.dropAxis(2) ) elif firstWord == '(<layer>': self.layerCount.printProgressIncrement('outset') self.rotatedBoundaryLayer = euclidean.RotatedLoopLayer(float(splitLine[1])) self.distanceFeedRate.addLine(line) elif firstWord == '(</layer>)': self.addOutset( self.rotatedBoundaryLayer ) self.rotatedBoundaryLayer = None elif firstWord == '(<surroundingLoop>)': self.boundary = [] self.rotatedBoundaryLayer.loops.append( self.boundary ) if self.rotatedBoundaryLayer == None: self.distanceFeedRate.addLine(line)
def parseLine(self, line): 'Parse a gcode line and add it to the widen skein.' splitLine = gcodec.getSplitLineBeforeBracketSemicolon(line) if len(splitLine) < 1: return firstWord = splitLine[0] if firstWord == '(<boundaryPoint>': location = gcodec.getLocationFromSplitLine(None, splitLine) self.boundary.append(location.dropAxis()) elif firstWord == '(<layer>': self.layerCount.printProgressIncrement('widen') self.rotatedLoopLayer = euclidean.RotatedLoopLayer( float(splitLine[1])) self.distanceFeedRate.addLine(line) elif firstWord == '(</layer>)': self.addWiden(self.rotatedLoopLayer) self.rotatedLoopLayer = None elif firstWord == '(<nestedRing>)': self.boundary = [] self.rotatedLoopLayer.loops.append(self.boundary) if self.rotatedLoopLayer == None or firstWord == '(<bridgeRotation>': self.distanceFeedRate.addLine(line)
def addRotatedLoopLayer(self, z): "Add rotated loop layer." self.rotatedBoundaryLayer = euclidean.RotatedLoopLayer(z) self.rotatedBoundaryLayers.append(self.rotatedBoundaryLayer)