def parseSVGByXMLElement(self, xmlElement): "Parse SVG by xmlElement." self.sliceDictionary = svg_writer.getSliceDictionary(xmlElement) self.yAxisPointingUpward = euclidean.getBooleanFromDictionary(False, self.sliceDictionary, 'yAxisPointingUpward') self.processXMLElement(xmlElement) if not self.yAxisPointingUpward: for rotatedLoopLayer in self.rotatedLoopLayers: self.flipDirectLayer(rotatedLoopLayer)
def parseSVGByElementNode(self, elementNode): "Parse SVG by elementNode." self.sliceDictionary = svg_writer.getSliceDictionary(elementNode) self.yAxisPointingUpward = euclidean.getBooleanFromDictionary(False, self.sliceDictionary, 'yAxisPointingUpward') self.processElementNode(elementNode) if not self.yAxisPointingUpward: for loopLayer in self.loopLayers: self.flipDirectLayer(loopLayer)
def parseSVGByXMLElement(self, xmlElement): "Parse SVG by xmlElement." self.sliceDictionary = svg_writer.getSliceDictionary(xmlElement) self.yAxisPointingUpward = euclidean.getBooleanFromDictionaryDefault(False, self.sliceDictionary, 'yAxisPointingUpward') self.processXMLElement(xmlElement) if not self.yAxisPointingUpward: for rotatedLoopLayer in self.rotatedLoopLayers: self.flipDirectLayer(rotatedLoopLayer)
def parseSVG( self, fileName, svgText ): "Parse SVG text and store the layers." self.fileName = fileName self.xmlParser = XMLSimpleReader(fileName, None, svgText) self.sliceDictionary = svg_writer.getSliceDictionary( self.xmlParser.getRoot() ) self.yAxisPointingUpward = euclidean.getBooleanFromDictionaryDefault(False, self.sliceDictionary, 'yAxisPointingUpward') self.processXMLElement( self.xmlParser.getRoot() ) if not self.yAxisPointingUpward: for rotatedLoopLayer in self.rotatedLoopLayers: self.flipDirectLayer(rotatedLoopLayer)
def getCraftedGcode(self, fileName, repository, svgText): "Parse svgText and store the bottom svgText." xmlParser = XMLSimpleReader(fileName, None, svgText) root = xmlParser.getRoot() sliceElements = getSliceElements(root) sliceDictionary = svg_writer.getSliceDictionary(root) decimalPlacesCarried = int(sliceDictionary['decimalPlacesCarried']) layerThickness = float(sliceDictionary['layerThickness']) procedures = sliceDictionary['procedureDone'].split(',') procedures.append('bottom') sliceDictionary['procedureDone'] = ','.join(procedures) zMinimum = 987654321.0 for sliceElement in sliceElements: zMinimum = min(getSliceElementZ(sliceElement), zMinimum) deltaZ = repository.altitude.value + 0.5 * layerThickness - zMinimum for sliceElementIndex, sliceElement in enumerate(sliceElements): z = getSliceElementZ(sliceElement) + deltaZ setSliceElementZ(decimalPlacesCarried, sliceElement, sliceElementIndex, z) output = cStringIO.StringIO() root.addXML(0, output) return output.getvalue()