Example #1
0
File: arc.py Project: folksjos/RepG
def getArcPath(xmlElement):
    "Get the arc path.rx ry x-axis-rotation large-arc-flag sweep-flag"
    begin = xmlElement.getPreviousVertex(Vector3())
    end = evaluate.getVector3FromXMLElement(xmlElement)
    largeArcFlag = evaluate.getEvaluatedBooleanDefault(True, 'largeArcFlag',
                                                       xmlElement)
    radius = lineation.getComplexByPrefix('radius', complex(1.0, 1.0),
                                          xmlElement)
    sweepFlag = evaluate.getEvaluatedBooleanDefault(True, 'sweepFlag',
                                                    xmlElement)
    xAxisRotation = math.radians(
        evaluate.getEvaluatedFloatDefault(0.0, 'xAxisRotation', xmlElement))
    arcComplexes = svg_reader.getArcComplexes(begin.dropAxis(), end.dropAxis(),
                                              largeArcFlag, radius, sweepFlag,
                                              xAxisRotation)
    path = []
    if len(arcComplexes) < 1:
        return []
    incrementZ = (end.z - begin.z) / float(len(arcComplexes))
    z = begin.z
    for pointIndex in xrange(len(arcComplexes)):
        pointComplex = arcComplexes[pointIndex]
        z += incrementZ
        path.append(Vector3(pointComplex.real, pointComplex.imag, z))
    if len(path) > 0:
        path[-1] = end
    return path
Example #2
0
def getCubicPath(xmlElement):
	"Get the cubic path."
	end = evaluate.getVector3FromXMLElement(xmlElement)
	previousXMLElement = xmlElement.getPreviousXMLElement()
	if previousXMLElement == None:
		print('Warning, can not get previousXMLElement in getCubicPath in cubic for:')
		print(xmlElement)
		return [end]
	begin = xmlElement.getPreviousVertex(Vector3())
	evaluatedControlPoints = evaluate.getTransformedPathByKey('controlPoints', xmlElement)
	if len(evaluatedControlPoints) > 1:
		return getCubicPathByBeginEnd(begin, evaluatedControlPoints, end, xmlElement)
	controlPoint0 = evaluate.getVector3ByPrefix('controlPoint0', None, xmlElement)
	controlPoint1 = evaluate.getVector3ByPrefix('controlPoint1', None, xmlElement)
	if len(evaluatedControlPoints) == 1:
		controlPoint1 = evaluatedControlPoints[0]
	if controlPoint0 == None:
		oldControlPoint = evaluate.getVector3ByPrefixes(['controlPoint','controlPoint1'], None, previousXMLElement)
		if oldControlPoint == None:
			oldControlPoints = evaluate.getTransformedPathByKey('controlPoints', previousXMLElement)
			if len(oldControlPoints) > 0:
				oldControlPoint = oldControlPoints[-1]
		if oldControlPoint == None:
			oldControlPoint = end
		controlPoint0 = begin + begin - oldControlPoint
	return getCubicPathByBeginEnd(begin, [controlPoint0, controlPoint1], end, xmlElement)
Example #3
0
def getCubicPath(xmlElement):
	"Get the cubic path."
	end = evaluate.getVector3FromXMLElement(xmlElement)
	previousXMLElement = xmlElement.getPreviousXMLElement()
	if previousXMLElement == None:
		print('Warning, can not get previousXMLElement in getCubicPath in cubic for:')
		print(xmlElement)
		return [end]
	begin = xmlElement.getPreviousVertex(Vector3())
	evaluatedControlPoints = evaluate.getTransformedPathByKey([], 'controlPoints', xmlElement)
	if len(evaluatedControlPoints) > 1:
		return getCubicPathByBeginEnd(begin, evaluatedControlPoints, end, xmlElement)
	controlPoint0 = evaluate.getVector3ByPrefix(None, 'controlPoint0', xmlElement)
	controlPoint1 = evaluate.getVector3ByPrefix(None, 'controlPoint1', xmlElement)
	if len(evaluatedControlPoints) == 1:
		controlPoint1 = evaluatedControlPoints[0]
	if controlPoint0 == None:
		oldControlPoint = evaluate.getVector3ByPrefixes(['controlPoint','controlPoint1'], None, previousXMLElement)
		if oldControlPoint == None:
			oldControlPoints = evaluate.getTransformedPathByKey([], 'controlPoints', previousXMLElement)
			if len(oldControlPoints) > 0:
				oldControlPoint = oldControlPoints[-1]
		if oldControlPoint == None:
			oldControlPoint = end
		controlPoint0 = begin + begin - oldControlPoint
	return getCubicPathByBeginEnd(begin, [controlPoint0, controlPoint1], end, xmlElement)
Example #4
0
def getQuadraticPath(xmlElement):
    "Get the quadratic path."
    end = evaluate.getVector3FromXMLElement(xmlElement)
    previousXMLElement = xmlElement.getPreviousXMLElement()
    if previousXMLElement == None:
        print(
            'Warning, can not get previousXMLElement in getQuadraticPath in quadratic for:'
        )
        print(xmlElement)
        return [end]
    begin = xmlElement.getPreviousVertex(Vector3())
    controlPoint = evaluate.getVector3ByPrefix('controlPoint', None,
                                               xmlElement)
    if controlPoint == None:
        oldControlPoint = evaluate.getVector3ByPrefixes(
            ['controlPoint', 'controlPoint1'], None, previousXMLElement)
        if oldControlPoint == None:
            print(
                'Warning, can not get oldControlPoint in getQuadraticPath in quadratic for:'
            )
            print(xmlElement)
            return [end]
        controlPoint = begin + begin - oldControlPoint
        evaluate.addVector3ToXMLElement('controlPoint', controlPoint,
                                        xmlElement)
    return svg_reader.getQuadraticPoints(
        begin, controlPoint, end,
        lineation.getNumberOfBezierPoints(begin, end, xmlElement))
def getQuadraticPath(xmlElement):
	"Get the quadratic path."
	end = evaluate.getVector3FromXMLElement(xmlElement)
	previousXMLElement = xmlElement.getPreviousXMLElement()
	if previousXMLElement == None:
		print('Warning, can not get previousXMLElement in getQuadraticPath in quadratic for:')
		print(xmlElement)
		return [end]
	begin = xmlElement.getPreviousVertex(Vector3())
	controlPoint = evaluate.getVector3ByPrefix(None, 'controlPoint', xmlElement)
	if controlPoint == None:
		oldControlPoint = evaluate.getVector3ByPrefixes(['controlPoint','controlPoint1'], None, previousXMLElement)
		if oldControlPoint == None:
			oldControlPoint = end
		controlPoint = begin + begin - oldControlPoint
		evaluate.addVector3ToXMLElement('controlPoint', controlPoint, xmlElement)
	return svg_reader.getQuadraticPoints(begin, controlPoint, end, lineation.getNumberOfBezierPoints(begin, end, xmlElement))
Example #6
0
def getArcPath(xmlElement):
	"Get the arc path.rx ry x-axis-rotation large-arc-flag sweep-flag"
	begin = xmlElement.getPreviousVertex(Vector3())
	end = evaluate.getVector3FromXMLElement(xmlElement)
	largeArcFlag = evaluate.getEvaluatedBooleanDefault(True, 'largeArcFlag', xmlElement)
	radius = lineation.getComplexByPrefix('radius', complex(1.0, 1.0), xmlElement )
	sweepFlag = evaluate.getEvaluatedBooleanDefault(True, 'sweepFlag', xmlElement)
	xAxisRotation = math.radians(evaluate.getEvaluatedFloatZero('xAxisRotation', xmlElement ))
	arcComplexes = svg_reader.getArcComplexes(begin.dropAxis(), end.dropAxis(), largeArcFlag, radius, sweepFlag, xAxisRotation)
	path = []
	incrementZ = (end.z - begin.z) / float(len(arcComplexes))
	z = begin.z
	for pointIndex in xrange(len(arcComplexes)):
		pointComplex = arcComplexes[pointIndex]
		z += incrementZ
		path.append(Vector3(pointComplex.real, pointComplex.imag, z))
	if len(path) > 0:
		path[-1] = end
	return path
Example #7
0
def getCubicPath(xmlElement):
	"Get the cubic path."
	end = evaluate.getVector3FromXMLElement(xmlElement)
	previousXMLElement = xmlElement.getPreviousXMLElement()
	if previousXMLElement == None:
		print('Warning, can not get previousXMLElement in getCubicPath in cubic for:')
		print(xmlElement)
		return [end]
	begin = xmlElement.getPreviousVertex(Vector3())
	controlPoint0 = evaluate.getVector3ByPrefix('controlPoint0', None, xmlElement)
	if controlPoint0 == None:
		oldControlPoint = evaluate.getVector3ByPrefixes(['controlPoint','controlPoint1'], None, previousXMLElement)
		if oldControlPoint == None:
			print('Warning, can not get oldControlPoint in getCubicPath in cubic for:')
			print(xmlElement)
			return [end]
		controlPoint0 = begin + begin - oldControlPoint
	controlPoints = [controlPoint0, evaluate.getVector3ByPrefix('controlPoint1', None, xmlElement)]
	return svg_reader.getCubicPoints(begin, controlPoints, end, lineation.getNumberOfBezierPoints(begin, end, xmlElement))
Example #8
0
def processXMLElement(xmlElement):
	"Process the xml element."
	xmlElement.parent.object.vertexes.append(evaluate.getVector3FromXMLElement(xmlElement))
Example #9
0
def processXMLElement(xmlElement):
    "Process the xml element."
    xmlElement.parentNode.xmlObject.vertexes.append(
        evaluate.getVector3FromXMLElement(xmlElement))
Example #10
0
def processXMLElement(xmlElement, xmlProcessor):
    "Process the xml element."
    xmlElement.parent.object.vertices.append(
        evaluate.getVector3FromXMLElement(xmlElement))