Beispiel #1
0
	def parseInitialization(self):
		"Parse gcode initialization and store the parameters."
		if self.svgReader.sliceDictionary == None:
			return
		self.layerThickness = euclidean.getFloatDefaultByDictionary( self.layerThickness, self.svgReader.sliceDictionary, 'layerThickness')
		self.maximumZ = euclidean.getFloatDefaultByDictionary( self.maximumZ, self.svgReader.sliceDictionary, 'maxZ')
		self.minimumZ = euclidean.getFloatDefaultByDictionary( self.minimumZ, self.svgReader.sliceDictionary, 'minZ')
Beispiel #2
0
 def parseInitialization(self):
     "Parse gcode initialization and store the parameters."
     if self.svgReader.sliceDictionary == None:
         return
     self.layerThickness = euclidean.getFloatDefaultByDictionary(
         self.layerThickness, self.svgReader.sliceDictionary,
         'layerThickness')
     self.maximumZ = euclidean.getFloatDefaultByDictionary(
         self.maximumZ, self.svgReader.sliceDictionary, 'maxZ')
     self.minimumZ = euclidean.getFloatDefaultByDictionary(
         self.minimumZ, self.svgReader.sliceDictionary, 'minZ')
def processSVGElementrect( svgReader, xmlElement ):
	"Process xmlElement by svgReader."
	attributeDictionary = xmlElement.attributeDictionary
	height = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'height')
	if height == 0.0:
		print('Warning, in processSVGElementrect in svgReader height is zero in:')
		print(attributeDictionary)
		return
	width = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'width')
	if width == 0.0:
		print('Warning, in processSVGElementrect in svgReader width is zero in:')
		print(attributeDictionary)
		return
	center = euclidean.getComplexDefaultByDictionaryKeys(complex(), attributeDictionary, 'x', 'y')
	inradius = 0.5 * complex( width, height )
	cornerRadius = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'rx', 'ry')
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	if cornerRadius.real == 0.0 and cornerRadius.imag == 0.0:
		inradiusMinusX = complex( - inradius.real, inradius.imag )
		loop = [center + inradius, center + inradiusMinusX, center - inradius, center - inradiusMinusX]
		rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
		return
	if cornerRadius.real == 0.0:
		cornerRadius = complex( cornerRadius.imag, cornerRadius.imag )
	elif cornerRadius.imag == 0.0:
		cornerRadius = complex( cornerRadius.real, cornerRadius.real )
	cornerRadius = complex( min( cornerRadius.real, inradius.real ), min( cornerRadius.imag, inradius.imag ) )
	ellipsePath = [ complex( cornerRadius.real, 0.0 ) ]
	inradiusMinusCorner = inradius - cornerRadius
	loop = []
	global globalNumberOfCornerPoints
	global globalSideAngle
	for side in xrange( 1, globalNumberOfCornerPoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		ellipsePath.append( complex( unitPolar.real * cornerRadius.real, unitPolar.imag * cornerRadius.imag ) )
	ellipsePath.append( complex( 0.0, cornerRadius.imag ) )
	cornerPoints = []
	for point in ellipsePath:
		cornerPoints.append( point + inradiusMinusCorner )
	cornerPointsReversed = cornerPoints[: : -1]
	for cornerPoint in cornerPoints:
		loop.append( center + cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( - cornerPoint.real, cornerPoint.imag ) )
	for cornerPoint in cornerPoints:
		loop.append( center - cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( cornerPoint.real, - cornerPoint.imag ) )
	loop = euclidean.getLoopWithoutCloseSequentialPoints( 0.0001 * abs(inradius), loop )
	rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
def processSVGElementrect( svgReader, xmlElement ):
	"Process xmlElement by svgReader."
	attributeDictionary = xmlElement.attributeDictionary
	height = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'height')
	if height == 0.0:
		print('Warning, in processSVGElementrect in svgReader height is zero in:')
		print(attributeDictionary)
		return
	width = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'width')
	if width == 0.0:
		print('Warning, in processSVGElementrect in svgReader width is zero in:')
		print(attributeDictionary)
		return
	center = euclidean.getComplexDefaultByDictionaryKeys(complex(), attributeDictionary, 'x', 'y')
	inradius = 0.5 * complex( width, height )
	cornerRadius = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'rx', 'ry')
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	if cornerRadius.real == 0.0 and cornerRadius.imag == 0.0:
		inradiusMinusX = complex( - inradius.real, inradius.imag )
		loop = [center + inradius, center + inradiusMinusX, center - inradius, center - inradiusMinusX]
		rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
		return
	if cornerRadius.real == 0.0:
		cornerRadius = complex( cornerRadius.imag, cornerRadius.imag )
	elif cornerRadius.imag == 0.0:
		cornerRadius = complex( cornerRadius.real, cornerRadius.real )
	cornerRadius = complex( min( cornerRadius.real, inradius.real ), min( cornerRadius.imag, inradius.imag ) )
	ellipsePath = [ complex( cornerRadius.real, 0.0 ) ]
	inradiusMinusCorner = inradius - cornerRadius
	loop = []
	global globalNumberOfCornerPoints
	global globalSideAngle
	for side in xrange( 1, globalNumberOfCornerPoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		ellipsePath.append( complex( unitPolar.real * cornerRadius.real, unitPolar.imag * cornerRadius.imag ) )
	ellipsePath.append( complex( 0.0, cornerRadius.imag ) )
	cornerPoints = []
	for point in ellipsePath:
		cornerPoints.append( point + inradiusMinusCorner )
	cornerPointsReversed = cornerPoints[: : -1]
	for cornerPoint in cornerPoints:
		loop.append( center + cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( - cornerPoint.real, cornerPoint.imag ) )
	for cornerPoint in cornerPoints:
		loop.append( center - cornerPoint )
	for cornerPoint in cornerPointsReversed:
		loop.append( center + complex( cornerPoint.real, - cornerPoint.imag ) )
	loop = euclidean.getLoopWithoutCloseSequentialPoints( 0.0001 * abs(inradius), loop )
	rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
Beispiel #5
0
	def parseSVG(self, fileName, svgText):
		'Parse SVG text and store the layers.'
		if svgText == '':
			return
		self.fileName = fileName
		self.svgReader.parseSVG(fileName, svgText)
		self.layerHeight = euclidean.getFloatDefaultByDictionary(
			self.layerHeight, self.svgReader.sliceDictionary, 'layerHeight')
		self.cornerMaximum = Vector3(-987654321.0, -987654321.0, self.maximumZ)
		self.cornerMinimum = Vector3(987654321.0, 987654321.0, self.minimumZ)
		svg_writer.setSVGCarvingCorners(
			self.cornerMaximum, self.cornerMinimum, self.layerHeight, self.svgReader.loopLayers)
Beispiel #6
0
	def parseSVG(self, fileName, svgText):
		'Parse SVG text and store the layers.'
		if svgText == '':
			return
		self.fileName = fileName
		self.svgReader.parseSVG(fileName, svgText)
		self.layerThickness = euclidean.getFloatDefaultByDictionary(
			self.layerThickness, self.svgReader.sliceDictionary, 'layerThickness')
		self.cornerMaximum = Vector3(-999999999.0, -999999999.0, self.maximumZ)
		self.cornerMinimum = Vector3(999999999.0, 999999999.0, self.minimumZ)
		svg_writer.setSVGCarvingCorners(
			self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.svgReader.rotatedLoopLayers)
Beispiel #7
0
 def parseSVG(self, fileName, svgText):
     'Parse SVG text and store the layers.'
     if svgText == '':
         return
     self.fileName = fileName
     self.svgReader.parseSVG(fileName, svgText)
     self.layerHeight = euclidean.getFloatDefaultByDictionary(
         self.layerHeight, self.svgReader.sliceDictionary, 'layerHeight')
     self.cornerMaximum = Vector3(-987654321.0, -987654321.0, self.maximumZ)
     self.cornerMinimum = Vector3(987654321.0, 987654321.0, self.minimumZ)
     svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum,
                                     self.layerHeight,
                                     self.svgReader.loopLayers)
def processSVGElementcircle( svgReader, xmlElement ):
	"Process xmlElement by svgReader."
	attributeDictionary = xmlElement.attributeDictionary
	center = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'cx', 'cy')
	radius = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'r')
	if radius == 0.0:
		print('Warning, in processSVGElementcircle in svgReader radius is zero in:')
		print(attributeDictionary)
		return
	global globalNumberOfCirclePoints
	global globalSideAngle
	loop = []
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	for side in xrange( globalNumberOfCirclePoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		loop.append( center + radius * unitPolar )
	rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)
def processSVGElementcircle( svgReader, xmlElement ):
	"Process xmlElement by svgReader."
	attributeDictionary = xmlElement.attributeDictionary
	center = euclidean.getComplexDefaultByDictionaryKeys( complex(), attributeDictionary, 'cx', 'cy')
	radius = euclidean.getFloatDefaultByDictionary( 0.0, attributeDictionary, 'r')
	if radius == 0.0:
		print('Warning, in processSVGElementcircle in svgReader radius is zero in:')
		print(attributeDictionary)
		return
	global globalNumberOfCirclePoints
	global globalSideAngle
	loop = []
	rotatedLoopLayer = svgReader.getRotatedLoopLayer()
	for side in xrange( globalNumberOfCirclePoints ):
		unitPolar = euclidean.getWiddershinsUnitPolar( float(side) * globalSideAngle )
		loop.append( center + radius * unitPolar )
	rotatedLoopLayer.loops += getTransformedFillOutline(loop, xmlElement, svgReader.yAxisPointingUpward)