Beispiel #1
0
	def getCarvedSVG(self, carving, fileName, repository):
		"""Parse gnu triangulated surface text and store the carved gcode."""
		extrusionHeight = repository.extrusionHeight.value
		extrusionWidth = repository.extrusionWidth.value
		carving.setCarveInfillInDirectionOfBridge(repository.infillInDirectionOfBridge.value)
		carving.setCarveLayerThickness(extrusionHeight)
		importRadius = 0.5 * repository.importCoarseness.value * abs(extrusionWidth)
		carving.setCarveImportRadius(max(importRadius, 0.01 * extrusionHeight))
		carving.setCarveIsCorrectMesh(repository.correctMesh.value)
		rotatedLoopLayers = carving.getCarveRotatedBoundaryLayers()
		if len(rotatedLoopLayers) < 1:
			print('Warning, there are no slices for the model, this could be because the model is too small for the Layer Thickness.')
			return ''
		extrusionHeight = carving.getCarveLayerThickness()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, extrusionHeight)
		extrusionWidth = repository.extrusionWidth.value
		svgWriter = svg_writer.SVGWriter(
			repository.addLayerTemplateToSVG.value,
			carving.getCarveCornerMaximum(),
			carving.getCarveCornerMinimum(),
			decimalPlacesCarried,
			carving.getCarveLayerThickness(),
			extrusionWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(repository, rotatedLoopLayers)
		return svgWriter.getReplacedSVGTemplate(
			fileName, 'carve', truncatedRotatedBoundaryLayers, carving.getFabmetheusXML())
Beispiel #2
0
 def getCarvedSVG(self, carving, fileName, repository):
     "Parse gnu triangulated surface text and store the carved gcode."
     layerThickness = repository.layerThickness.value
     perimeterWidth = repository.perimeterWidthOverThickness.value
     carving.setCarveLayerThickness(layerThickness)
     importRadius = 0.5 * repository.importCoarseness.value * abs(perimeterWidth)
     carving.setCarveImportRadius(max(importRadius, 0.01 * layerThickness))
     carving.setCarveIsCorrectMesh(repository.correctMesh.value)
     loopLayers = carving.getCarveBoundaryLayers()
     if len(loopLayers) < 1:
         print(
             "Warning, there are no slices for the model, this could be because the model is too small for the Layer Thickness."
         )
         return ""
     layerThickness = carving.getCarveLayerThickness()
     decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerThickness)
     perimeterWidth = repository.perimeterWidthOverThickness.value  # todo why twice?
     svgWriter = svg_writer.SVGWriter(
         repository.addLayerTemplateToSVG.value,
         carving.getCarveCornerMaximum(),
         carving.getCarveCornerMinimum(),
         decimalPlacesCarried,
         carving.getCarveLayerThickness(),
         perimeterWidth,
     )
     truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(loopLayers, repository)
     return svgWriter.getReplacedSVGTemplate(
         fileName, truncatedRotatedBoundaryLayers, "carve", carving.getFabmetheusXML()
     )
Beispiel #3
0
	def getCarvedSVG( self, carving, fileName, repository ):
		"Parse gnu triangulated surface text and store the chopped gcode."
		layerHeight = repository.layerHeight.value
		edgeWidth = repository.edgeWidth.value
		carving.setCarveLayerHeight( layerHeight )
		importRadius = 0.5 * repository.importCoarseness.value * abs(edgeWidth)
		carving.setCarveImportRadius(max(importRadius, 0.001 * layerHeight))
		carving.setCarveIsCorrectMesh( repository.correctMesh.value )
		loopLayers = carving.getCarveBoundaryLayers()
		if len( loopLayers ) < 1:
			print('Warning, there are no slices for the model, this could be because the model is too small for the Layer Height.')
			return ''
		if repository.addExtraTopLayerIfNecessary.value:
			self.addExtraTopLayerIfNecessary( carving, layerHeight, loopLayers )
		loopLayers.reverse()
		layerHeight = carving.getCarveLayerHeight()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerHeight)
		svgWriter = svg_writer.SVGWriter(
			repository.addLayerTemplateToSVG.value,
			carving.getCarveCornerMaximum(),
			carving.getCarveCornerMinimum(),
			decimalPlacesCarried,
			carving.getCarveLayerHeight(),
			edgeWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(loopLayers, repository)
		return svgWriter.getReplacedSVGTemplate( fileName, truncatedRotatedBoundaryLayers, 'chop', carving.getFabmetheusXML())
Beispiel #4
0
	def getCarvedSVG(self, carving, fileName, repository):
		"Parse gnu triangulated surface text and store the carved gcode."

		matrix = map(float, repository.matrix.value.split(','))

		for i in xrange(0, len(carving.vertexes)):
			x = carving.vertexes[i].x
			y = carving.vertexes[i].y
			z = carving.vertexes[i].z
			carving.vertexes[i] = Vector3(
				x * matrix[0] + y * matrix[3] + z * matrix[6],
				x * matrix[1] + y * matrix[4] + z * matrix[7],
				x * matrix[2] + y * matrix[5] + z * matrix[8])

		if repository.alternativeCenter.value != '':
			carving2 = svg_writer.getCarving(repository.alternativeCenter.value)
			for i in xrange(0, len(carving2.vertexes)):
				x = carving2.vertexes[i].x
				y = carving2.vertexes[i].y
				z = carving2.vertexes[i].z
				carving2.vertexes[i] = Vector3(
					x * matrix[0] + y * matrix[3] + z * matrix[6],
					x * matrix[1] + y * matrix[4] + z * matrix[7],
					x * matrix[2] + y * matrix[5] + z * matrix[8])
			minZ = carving2.getMinimumZ()
			minSize = carving2.getCarveCornerMinimum()
			maxSize = carving2.getCarveCornerMaximum()
		else:
			minZ = carving.getMinimumZ()
			minSize = carving.getCarveCornerMinimum()
			maxSize = carving.getCarveCornerMaximum()
		for v in carving.vertexes:
			v.z -= minZ + repository.objectSink.value
			v.x -= minSize.x + (maxSize.x - minSize.x) / 2
			v.y -= minSize.y + (maxSize.y - minSize.y) / 2
			v.x += repository.centerX.value
			v.y += repository.centerY.value

		layerHeight = repository.layerHeight.value
		edgeWidth = repository.edgeWidth.value
		carving.setCarveLayerHeight(layerHeight)
		importRadius = 0.5 * repository.importCoarseness.value * abs(edgeWidth)
		carving.setCarveImportRadius(max(importRadius, 0.001 * layerHeight))
		carving.setCarveIsCorrectMesh(repository.correctMesh.value)
		loopLayers = carving.getCarveBoundaryLayers()
		if len(loopLayers) < 1:
			print('Warning, there are no slices for the model, this could be because the model is too small for the Layer Height.')
			return ''
		layerHeight = carving.getCarveLayerHeight()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerHeight)
		edgeWidth = repository.edgeWidth.value
		svgWriter = svg_writer.SVGWriter(
			repository.addLayerTemplateToSVG.value,
			carving.getCarveCornerMaximum(),
			carving.getCarveCornerMinimum(),
			decimalPlacesCarried,
			carving.getCarveLayerHeight(),
			edgeWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(loopLayers, repository)
		return svgWriter.getReplacedSVGTemplate(fileName, truncatedRotatedBoundaryLayers, 'carve', carving.getFabmetheusXML())
Beispiel #5
0
 def getCarvedSVG(self, carving, fileName, repository):
     "Parse gnu triangulated surface text and store the chopped gcode."
     layerThickness = repository.layerThickness.value
     perimeterWidth = repository.perimeterWidth.value
     carving.setCarveLayerThickness(layerThickness)
     importRadius = 0.5 * repository.importCoarseness.value * abs(
         perimeterWidth)
     carving.setCarveImportRadius(max(importRadius, 0.01 * layerThickness))
     carving.setCarveIsCorrectMesh(repository.correctMesh.value)
     loopLayers = carving.getCarveBoundaryLayers()
     if len(loopLayers) < 1:
         print(
             'Warning, there are no slices for the model, this could be because the model is too small for the Layer Thickness.'
         )
         return ''
     if repository.addExtraTopLayerIfNecessary.value:
         self.addExtraTopLayerIfNecessary(carving, layerThickness,
                                          loopLayers)
     loopLayers.reverse()
     layerThickness = carving.getCarveLayerThickness()
     decimalPlacesCarried = euclidean.getDecimalPlacesCarried(
         repository.extraDecimalPlaces.value, layerThickness)
     svgWriter = svg_writer.SVGWriter(
         repository.addLayerTemplateToSVG.value,
         carving.getCarveCornerMaximum(),
         carving.getCarveCornerMinimum(), decimalPlacesCarried,
         carving.getCarveLayerThickness(), perimeterWidth)
     truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(
         loopLayers, repository)
     return svgWriter.getReplacedSVGTemplate(
         fileName, truncatedRotatedBoundaryLayers, 'chop',
         carving.getFabmetheusXML())
Beispiel #6
0
	def getCarvedSVG(self, carving, fileName, repository):
		"Parse gnu triangulated surface text and store the carved gcode."
		layerThickness = repository.layerThickness.value
		bridgeLayerThickness = layerThickness * repository.bridgeThicknessMultiplier.value
		perimeterWidth = repository.perimeterWidthOverThickness.value * layerThickness
		if repository.infillDirectionBridge.value:
			carving.setCarveBridgeLayerThickness(bridgeLayerThickness)
		carving.setCarveLayerThickness(layerThickness)
		importRadius = 0.5 * repository.importCoarseness.value * abs(perimeterWidth)
		carving.setCarveImportRadius(max(importRadius, 0.01 * layerThickness))
		carving.setCarveIsCorrectMesh(repository.correctMesh.value)
		rotatedLoopLayers = carving.getCarveRotatedBoundaryLayers()
		if len(rotatedLoopLayers) < 1:
			print('Warning, there are no slices for the model, this could be because the model is too small for the Layer Thickness.')
			return ''
		layerThickness = carving.getCarveLayerThickness()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerThickness)
		perimeterWidth = repository.perimeterWidthOverThickness.value * layerThickness
		svgWriter = svg_writer.SVGWriter(
			repository.addLayerTemplateToSVG.value,
			carving.getCarveCornerMaximum(),
			carving.getCarveCornerMinimum(),
			decimalPlacesCarried,
			carving.getCarveLayerThickness(),
			perimeterWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(repository, rotatedLoopLayers)
		return svgWriter.getReplacedSVGTemplate(fileName, 'carve', truncatedRotatedBoundaryLayers, carving.getFabmetheusXML())
Beispiel #7
0
 def getCarvedSVG(self, carving, fileName, repository):
     "Parse gnu triangulated surface text and store the carved gcode."
     layerThickness = repository.layerThickness.value
     bridgeLayerThickness = layerThickness * repository.bridgeThicknessMultiplier.value
     perimeterWidth = repository.perimeterWidthOverThickness.value * layerThickness
     if repository.infillDirectionBridge.value:
         carving.setCarveBridgeLayerThickness(bridgeLayerThickness)
     carving.setCarveLayerThickness(layerThickness)
     importRadius = 0.5 * repository.importCoarseness.value * abs(
         perimeterWidth)
     carving.setCarveImportRadius(max(importRadius, 0.01 * layerThickness))
     carving.setCarveIsCorrectMesh(repository.correctMesh.value)
     rotatedBoundaryLayers = carving.getCarveRotatedBoundaryLayers()
     if len(rotatedBoundaryLayers) < 1:
         print(
             'There are no slices for the model, this could be because the model is too small.'
         )
         return ''
     layerThickness = carving.getCarveLayerThickness()
     decimalPlacesCarried = euclidean.getDecimalPlacesCarried(
         repository.extraDecimalPlaces.value, layerThickness)
     perimeterWidth = repository.perimeterWidthOverThickness.value * layerThickness
     svgWriter = svg_writer.SVGWriter(
         repository.addLayerTemplateToSVG.value, carving,
         decimalPlacesCarried, perimeterWidth)
     truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(
         repository, rotatedBoundaryLayers)
     return svgWriter.getReplacedSVGTemplate(
         fileName, 'carve', truncatedRotatedBoundaryLayers,
         carving.getFabmetheusXML())
Beispiel #8
0
 def getCarvedSVG(self, carving, fileName, repository):
     "Parse gnu triangulated surface text and store the cleaved gcode."
     layerThickness = repository.layerThickness.value
     perimeterWidth = repository.perimeterWidth.value
     carving.setCarveLayerThickness(layerThickness)
     importRadius = 0.5 * repository.importCoarseness.value * abs(
         perimeterWidth)
     carving.setCarveImportRadius(max(importRadius, 0.01 * layerThickness))
     carving.setCarveIsCorrectMesh(repository.correctMesh.value)
     rotatedBoundaryLayers = carving.getCarveRotatedBoundaryLayers()
     if len(rotatedBoundaryLayers) < 1:
         print(
             'There are no slices for the model, this could be because the model is too small.'
         )
         return ''
     layerThickness = carving.getCarveLayerThickness()
     decimalPlacesCarried = max(
         0, 1 + repository.extraDecimalPlaces.value -
         int(math.floor(math.log10(layerThickness))))
     svgWriter = svg_writer.SVGWriter(
         repository.addLayerTemplateToSVG.value, carving,
         decimalPlacesCarried, perimeterWidth)
     truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(
         repository, rotatedBoundaryLayers)
     return svgWriter.getReplacedSVGTemplate(
         fileName, 'cleave', truncatedRotatedBoundaryLayers,
         carving.getFabmetheusXML())
Beispiel #9
0
	def getCarvedSVG( self, carving, fileName, repository ):
		"Parse gnu triangulated surface text and store the cleaved gcode."
		layerThickness = repository.layerThickness.value
		perimeterWidth = repository.perimeterWidth.value
		carving.setCarveLayerThickness( layerThickness )
		importRadius = 0.5 * repository.importCoarseness.value * abs( perimeterWidth )
		carving.setCarveImportRadius( max( importRadius, 0.01 * layerThickness ) )
		carving.setCarveIsCorrectMesh( repository.correctMesh.value )
		rotatedBoundaryLayers = carving.getCarveRotatedBoundaryLayers()
		if len( rotatedBoundaryLayers ) < 1:
			print('There are no slices for the model, this could be because the model is too small.')
			return ''
		layerThickness = carving.getCarveLayerThickness()
		decimalPlacesCarried = max( 0, 1 + repository.extraDecimalPlaces.value - int( math.floor( math.log10( layerThickness ) ) ) )
		svgWriter = svg_writer.SVGWriter(repository.addLayerTemplateToSVG.value, carving, decimalPlacesCarried, perimeterWidth)
		return svgWriter.getReplacedSVGTemplate( fileName, 'cleave', svg_writer.getTruncatedRotatedBoundaryLayers( repository, rotatedBoundaryLayers ) )
Beispiel #10
0
	def getCarvedSVG(self, carving, fileName, repository):
		"Parse gnu triangulated surface text and store the carved gcode."

		scale = repository.scale.value
		rotate = repository.rotate.value / 180 * math.pi
		scaleX = scale
		scaleY = scale
		scaleZ = scale
		if repository.flipX.value == True:
			scaleX = -scaleX
		if repository.flipY.value == True:
			scaleY = -scaleY
		if repository.flipZ.value == True:
			scaleZ = -scaleZ
		mat00 = math.cos(rotate) * scaleX
		mat01 =-math.sin(rotate) * scaleY
		mat10 = math.sin(rotate) * scaleX
		mat11 = math.cos(rotate) * scaleY
		
		for i in xrange(0, len(carving.vertexes)):
			carving.vertexes[i] = Vector3(
				carving.vertexes[i].x * mat00 + carving.vertexes[i].y * mat01,
				carving.vertexes[i].x * mat10 + carving.vertexes[i].y * mat11,
				carving.vertexes[i].z * scaleZ)

		layerHeight = repository.layerHeight.value
		edgeWidth = repository.edgeWidth.value
		carving.setCarveLayerHeight(layerHeight)
		importRadius = 0.5 * repository.importCoarseness.value * abs(edgeWidth)
		carving.setCarveImportRadius(max(importRadius, 0.001 * layerHeight))
		carving.setCarveIsCorrectMesh(repository.correctMesh.value)
		loopLayers = carving.getCarveBoundaryLayers()
		if len(loopLayers) < 1:
			print('Warning, there are no slices for the model, this could be because the model is too small for the Layer Height.')
			return ''
		layerHeight = carving.getCarveLayerHeight()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerHeight)
		edgeWidth = repository.edgeWidth.value
		svgWriter = svg_writer.SVGWriter(
			repository.addLayerTemplateToSVG.value,
			carving.getCarveCornerMaximum(),
			carving.getCarveCornerMinimum(),
			decimalPlacesCarried,
			carving.getCarveLayerHeight(),
			edgeWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(loopLayers, repository)
		return svgWriter.getReplacedSVGTemplate(fileName, truncatedRotatedBoundaryLayers, 'carve', carving.getFabmetheusXML())
Beispiel #11
0
	def getCarvedSVG( self, carving, fileName, repository ):
		"Parse gnu triangulated surface text and store the chopped gcode."
		layerThickness = repository.layerThickness.value
		perimeterWidth = repository.perimeterWidth.value
		carving.setCarveLayerThickness( layerThickness )
		importRadius = 0.5 * repository.importCoarseness.value * abs( perimeterWidth )
		carving.setCarveImportRadius( max( importRadius, 0.01 * layerThickness ) )
		carving.setCarveIsCorrectMesh( repository.correctMesh.value )
		rotatedBoundaryLayers = carving.getCarveRotatedBoundaryLayers()
		if len( rotatedBoundaryLayers ) < 1:
			print('There are no slices for the model, this could be because the model is too small.')
			return ''
		if repository.addExtraTopLayerIfNecessary.value:
			self.addExtraTopLayerIfNecessary( carving, layerThickness, rotatedBoundaryLayers )
		rotatedBoundaryLayers.reverse()
		layerThickness = carving.getCarveLayerThickness()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerThickness)
		svgWriter = svg_writer.SVGWriter(repository.addLayerTemplateToSVG.value, carving, decimalPlacesCarried, perimeterWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(repository, rotatedBoundaryLayers)
		return svgWriter.getReplacedSVGTemplate( fileName, 'chop', truncatedRotatedBoundaryLayers, carving.getFabmetheusXML())
Beispiel #12
0
	def getCarvedSVG(self, carving, fileName, repository):
		"Parse gnu triangulated surface text and store the carved gcode."
		layerHeight = repository.layerHeight.value
		edgeWidth = repository.edgeWidthOverHeight.value * layerHeight
		carving.setCarveLayerHeight(layerHeight)
		importRadius = 0.5 * repository.importCoarseness.value * abs(edgeWidth)
		carving.setCarveImportRadius(max(importRadius, 0.001 * layerHeight))
		carving.setCarveIsCorrectMesh(repository.correctMesh.value)
		loopLayers = carving.getCarveBoundaryLayers()
		if len(loopLayers) < 1:
			print('Warning, there are no slices for the model, this could be because the model is too small for the Layer Height.')
			return ''
		layerHeight = carving.getCarveLayerHeight()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerHeight)
		edgeWidth = repository.edgeWidthOverHeight.value * layerHeight
		svgWriter = svg_writer.SVGWriter(
			repository.addLayerTemplateToSVG.value,
			carving.getCarveCornerMaximum(),
			carving.getCarveCornerMinimum(),
			decimalPlacesCarried,
			carving.getCarveLayerHeight(),
			edgeWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(loopLayers, repository)
		return svgWriter.getReplacedSVGTemplate(fileName, truncatedRotatedBoundaryLayers, 'carve', carving.getFabmetheusXML())
Beispiel #13
0
    def getCarvedSVG(self, carving, fileName, repository):
        "Parse gnu triangulated surface text and store the carved gcode."

        scale = repository.scale.value
        rotate = repository.rotate.value / 180 * math.pi
        scaleX = scale
        scaleY = scale
        scaleZ = scale
        if repository.flipX.value == True:
            scaleX = -scaleX
        if repository.flipY.value == True:
            scaleY = -scaleY
        if repository.flipZ.value == True:
            scaleZ = -scaleZ
        swapXZ = repository.swapXZ.value
        swapYZ = repository.swapYZ.value
        mat00 = math.cos(rotate) * scaleX
        mat01 = -math.sin(rotate) * scaleY
        mat10 = math.sin(rotate) * scaleX
        mat11 = math.cos(rotate) * scaleY

        for i in xrange(0, len(carving.vertexes)):
            x = carving.vertexes[i].x
            y = carving.vertexes[i].y
            z = carving.vertexes[i].z
            if swapXZ:
                x, z = z, x
            if swapYZ:
                y, z = z, y
            carving.vertexes[i] = Vector3(x * mat00 + y * mat01,
                                          x * mat10 + y * mat11, z * scaleZ)

        if repository.alternativeCenter.value != '':
            carving2 = svg_writer.getCarving(
                repository.alternativeCenter.value)
            for i in xrange(0, len(carving2.vertexes)):
                x = carving2.vertexes[i].x
                y = carving2.vertexes[i].y
                z = carving2.vertexes[i].z
                if swapXZ:
                    x, z = z, x
                if swapYZ:
                    y, z = z, y
                carving2.vertexes[i] = Vector3(x * mat00 + y * mat01,
                                               x * mat10 + y * mat11,
                                               z * scaleZ)
            minZ = carving2.getMinimumZ()
            minSize = carving2.getCarveCornerMinimum()
            maxSize = carving2.getCarveCornerMaximum()
        else:
            minZ = carving.getMinimumZ()
            minSize = carving.getCarveCornerMinimum()
            maxSize = carving.getCarveCornerMaximum()
        for v in carving.vertexes:
            v.z -= minZ
            v.x -= minSize.x + (maxSize.x - minSize.x) / 2
            v.y -= minSize.y + (maxSize.y - minSize.y) / 2
            v.x += repository.centerX.value
            v.y += repository.centerY.value

        layerHeight = repository.layerHeight.value
        edgeWidth = repository.edgeWidth.value
        carving.setCarveLayerHeight(layerHeight)
        importRadius = 0.5 * repository.importCoarseness.value * abs(edgeWidth)
        carving.setCarveImportRadius(max(importRadius, 0.001 * layerHeight))
        carving.setCarveIsCorrectMesh(repository.correctMesh.value)
        loopLayers = carving.getCarveBoundaryLayers()
        if len(loopLayers) < 1:
            print(
                'Warning, there are no slices for the model, this could be because the model is too small for the Layer Height.'
            )
            return ''
        layerHeight = carving.getCarveLayerHeight()
        decimalPlacesCarried = euclidean.getDecimalPlacesCarried(
            repository.extraDecimalPlaces.value, layerHeight)
        edgeWidth = repository.edgeWidth.value
        svgWriter = svg_writer.SVGWriter(
            repository.addLayerTemplateToSVG.value,
            carving.getCarveCornerMaximum(), carving.getCarveCornerMinimum(),
            decimalPlacesCarried, carving.getCarveLayerHeight(), edgeWidth)
        truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(
            loopLayers, repository)
        return svgWriter.getReplacedSVGTemplate(
            fileName, truncatedRotatedBoundaryLayers, 'carve',
            carving.getFabmetheusXML())
Beispiel #14
0
	def getCarvedSVG(self, carving, fileName, repository):
		"Parse gnu triangulated surface text and store the carved gcode."

		scale = repository.scale.value
		rotate = repository.rotate.value / 180 * math.pi
		scaleX = scale
		scaleY = scale
		scaleZ = scale
		if repository.flipX.value == True:
			scaleX = -scaleX
		if repository.flipY.value == True:
			scaleY = -scaleY
		if repository.flipZ.value == True:
			scaleZ = -scaleZ
		swapXZ = repository.swapXZ.value
		swapYZ = repository.swapYZ.value
		mat00 = math.cos(rotate) * scaleX
		mat01 =-math.sin(rotate) * scaleY
		mat10 = math.sin(rotate) * scaleX
		mat11 = math.cos(rotate) * scaleY

		for i in xrange(0, len(carving.vertexes)):
			x = carving.vertexes[i].x
			y = carving.vertexes[i].y
			z = carving.vertexes[i].z
			if swapXZ:
				x, z = z, x
			if swapYZ:
				y, z = z, y
			carving.vertexes[i] = Vector3(
				x * mat00 + y * mat01,
				x * mat10 + y * mat11,
				z * scaleZ)

		if repository.alternativeCenter.value != '':
			carving2 = svg_writer.getCarving(repository.alternativeCenter.value)
			for i in xrange(0, len(carving2.vertexes)):
				x = carving2.vertexes[i].x
				y = carving2.vertexes[i].y
				z = carving2.vertexes[i].z
				if swapXZ:
					x, z = z, x
				if swapYZ:
					y, z = z, y
				carving2.vertexes[i] = Vector3(
					x * mat00 + y * mat01,
					x * mat10 + y * mat11,
					z * scaleZ)
			minZ = carving2.getMinimumZ()
			minSize = carving2.getCarveCornerMinimum()
			maxSize = carving2.getCarveCornerMaximum()
		else:
			minZ = carving.getMinimumZ()
			minSize = carving.getCarveCornerMinimum()
			maxSize = carving.getCarveCornerMaximum()
		for v in carving.vertexes:
			v.z -= minZ
			v.x -= minSize.x + (maxSize.x - minSize.x) / 2
			v.y -= minSize.y + (maxSize.y - minSize.y) / 2
			v.x += repository.centerX.value
			v.y += repository.centerY.value

		layerHeight = repository.layerHeight.value
		edgeWidth = repository.edgeWidth.value
		carving.setCarveLayerHeight(layerHeight)
		importRadius = 0.5 * repository.importCoarseness.value * abs(edgeWidth)
		carving.setCarveImportRadius(max(importRadius, 0.001 * layerHeight))
		carving.setCarveIsCorrectMesh(repository.correctMesh.value)
		loopLayers = carving.getCarveBoundaryLayers()
		if len(loopLayers) < 1:
			print('Warning, there are no slices for the model, this could be because the model is too small for the Layer Height.')
			return ''
		layerHeight = carving.getCarveLayerHeight()
		decimalPlacesCarried = euclidean.getDecimalPlacesCarried(repository.extraDecimalPlaces.value, layerHeight)
		edgeWidth = repository.edgeWidth.value
		svgWriter = svg_writer.SVGWriter(
			repository.addLayerTemplateToSVG.value,
			carving.getCarveCornerMaximum(),
			carving.getCarveCornerMinimum(),
			decimalPlacesCarried,
			carving.getCarveLayerHeight(),
			edgeWidth)
		truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(loopLayers, repository)
		return svgWriter.getReplacedSVGTemplate(fileName, truncatedRotatedBoundaryLayers, 'carve', carving.getFabmetheusXML())
Beispiel #15
0
    def getCarvedSVG(self, carving, fileName, repository):
        "Parse gnu triangulated surface text and store the carved gcode."

        matrix = map(float, repository.matrix.value.split(','))

        for i in xrange(0, len(carving.vertexes)):
            x = carving.vertexes[i].x
            y = carving.vertexes[i].y
            z = carving.vertexes[i].z
            carving.vertexes[i] = Vector3(
                x * matrix[0] + y * matrix[3] + z * matrix[6],
                x * matrix[1] + y * matrix[4] + z * matrix[7],
                x * matrix[2] + y * matrix[5] + z * matrix[8])

        if repository.alternativeCenter.value != '':
            carving2 = svg_writer.getCarving(
                repository.alternativeCenter.value)
            for i in xrange(0, len(carving2.vertexes)):
                x = carving2.vertexes[i].x
                y = carving2.vertexes[i].y
                z = carving2.vertexes[i].z
                carving2.vertexes[i] = Vector3(
                    x * matrix[0] + y * matrix[3] + z * matrix[6],
                    x * matrix[1] + y * matrix[4] + z * matrix[7],
                    x * matrix[2] + y * matrix[5] + z * matrix[8])
            minZ = carving2.getMinimumZ()
            minSize = carving2.getCarveCornerMinimum()
            maxSize = carving2.getCarveCornerMaximum()
        else:
            minZ = carving.getMinimumZ()
            minSize = carving.getCarveCornerMinimum()
            maxSize = carving.getCarveCornerMaximum()
        for v in carving.vertexes:
            v.z -= minZ
            v.x -= minSize.x + (maxSize.x - minSize.x) / 2
            v.y -= minSize.y + (maxSize.y - minSize.y) / 2
            v.x += repository.centerX.value
            v.y += repository.centerY.value

        layerHeight = repository.layerHeight.value
        edgeWidth = repository.edgeWidth.value
        carving.setCarveLayerHeight(layerHeight)
        importRadius = 0.5 * repository.importCoarseness.value * abs(edgeWidth)
        carving.setCarveImportRadius(max(importRadius, 0.001 * layerHeight))
        carving.setCarveIsCorrectMesh(repository.correctMesh.value)
        loopLayers = carving.getCarveBoundaryLayers()
        if len(loopLayers) < 1:
            print(
                'Warning, there are no slices for the model, this could be because the model is too small for the Layer Height.'
            )
            return ''
        layerHeight = carving.getCarveLayerHeight()
        decimalPlacesCarried = euclidean.getDecimalPlacesCarried(
            repository.extraDecimalPlaces.value, layerHeight)
        edgeWidth = repository.edgeWidth.value
        svgWriter = svg_writer.SVGWriter(
            repository.addLayerTemplateToSVG.value,
            carving.getCarveCornerMaximum(), carving.getCarveCornerMinimum(),
            decimalPlacesCarried, carving.getCarveLayerHeight(), edgeWidth)
        truncatedRotatedBoundaryLayers = svg_writer.getTruncatedRotatedBoundaryLayers(
            loopLayers, repository)
        return svgWriter.getReplacedSVGTemplate(
            fileName, truncatedRotatedBoundaryLayers, 'carve',
            carving.getFabmetheusXML())