def getComplexByDictionary(dictionary, valueComplex): 'Get complex by dictionary.' if 'x' in dictionary: valueComplex = complex(euclidean.getFloatFromValue(dictionary['x']),valueComplex.imag) if 'y' in dictionary: valueComplex = complex(valueComplex.real, euclidean.getFloatFromValue(dictionary['y'])) return valueComplex
def getComplexByFloatList( floatList, valueComplex ): 'Get complex by float list.' if len(floatList) > 0: valueComplex = complex(euclidean.getFloatFromValue(floatList[0]), valueComplex.imag) if len(floatList) > 1: valueComplex = complex(valueComplex.real, euclidean.getFloatFromValue(floatList[1])) return valueComplex
def getGeometryOutputByArguments(arguments, xmlElement): "Get vector3 vertices from attribute dictionary by arguments." inradius = 0.5 * euclidean.getFloatFromValue(arguments[0]) xmlElement.attributeDictionary['inradius.x'] = str(inradius) if len(arguments) > 1: inradius = 0.5 * euclidean.getFloatFromValue(arguments[1]) xmlElement.attributeDictionary['inradius.y'] = str(inradius) return getGeometryOutput(xmlElement)
def getGeometryOutputByArguments(arguments, elementNode): 'Get vector3 vertexes from attribute dictionary by arguments.' if len(arguments) < 1: return getGeometryOutput(elementNode) inradius = 0.5 * euclidean.getFloatFromValue(arguments[0]) elementNode.attributes['inradius.x'] = str(inradius) if len(arguments) > 1: inradius = 0.5 * euclidean.getFloatFromValue(arguments[1]) elementNode.attributes['inradius.y'] = str(inradius) return getGeometryOutput(elementNode)
def getGeometryOutputByArguments(arguments, xmlElement): "Get vector3 vertexes from attribute dictionary by arguments." if len(arguments) < 1: return getGeometryOutput(xmlElement) inradius = 0.5 * euclidean.getFloatFromValue(arguments[0]) xmlElement.attributeDictionary['inradius.x'] = str(inradius) if len(arguments) > 1: inradius = 0.5 * euclidean.getFloatFromValue(arguments[1]) xmlElement.attributeDictionary['inradius.y'] = str(inradius) return getGeometryOutput(xmlElement)
def getFloatByExtraIndex(self, extraIndex=0): 'Get float from the extraIndex.' totalIndex = self.wordIndex + extraIndex if totalIndex >= len(self.words): return None word = self.words[totalIndex] if word[:1].isalpha(): return None return euclidean.getFloatFromValue(word)
def getFloatByPrefixSide(defaultValue, elementNode, prefix, side): 'Get float by prefix and side.' if elementNode == None: return defaultValue if side != None: key = prefix + 'OverSide' if key in elementNode.attributes: defaultValue = euclidean.getFloatFromValue(evaluate.getEvaluatedValueObliviously(elementNode, key)) * side return evaluate.getEvaluatedFloat(defaultValue, elementNode, prefix)
def getFloatByExtraIndex( self, extraIndex=0 ): 'Get float from the extraIndex.' totalIndex = self.wordIndex + extraIndex if totalIndex >= len(self.words): return None word = self.words[totalIndex] if word[: 1].isalpha(): return None return euclidean.getFloatFromValue(word)
def getGeometryOutput(xmlElement): "Get vector3 vertices from attribute dictionary." halfX = 1.0 halfX = evaluate.getEvaluatedFloatDefault(halfX, 'halfx', xmlElement) halfX = 0.5 * evaluate.getEvaluatedFloatDefault(halfX / 0.5, 'width', xmlElement) bottomHalfX = evaluate.getEvaluatedFloatDefault(halfX, 'bottomhalfx', xmlElement) bottomHalfX = 0.5 * evaluate.getEvaluatedFloatDefault( halfX / 0.5, 'bottomwidth', xmlElement) topHalfX = evaluate.getEvaluatedFloatDefault(halfX, 'tophalfx', xmlElement) topHalfX = 0.5 * evaluate.getEvaluatedFloatDefault(halfX / 0.5, 'topwidth', xmlElement) halfY = halfX if '_arguments' in xmlElement.attributeDictionary: arguments = xmlElement.attributeDictionary['_arguments'] halfX = 0.5 * euclidean.getFloatFromValue(arguments[0]) xmlElement.attributeDictionary['halfX'] = str(halfX) if len(arguments) > 1: halfY = 0.5 * euclidean.getFloatFromValue(arguments[1]) else: halfY = halfX halfY = evaluate.getEvaluatedFloatDefault(halfY, 'halfy', xmlElement) halfY = 0.5 * evaluate.getEvaluatedFloatDefault(halfY / 0.5, 'height', xmlElement) interiorAngle = evaluate.getEvaluatedFloatDefault(90.0, 'interiorangle', xmlElement) topRight = complex(topHalfX, halfY) topLeft = complex(-topHalfX, halfY) bottomLeft = complex(-bottomHalfX, -halfY) bottomRight = complex(bottomHalfX, -halfY) if interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar( math.radians(interiorAngle - 90.0)) topRight = (topRight - bottomRight) * interiorPlaneAngle + bottomRight topLeft = (topLeft - bottomLeft) * interiorPlaneAngle + bottomLeft loop = [ Vector3(topRight.real, topRight.imag), Vector3(topLeft.real, topLeft.imag), Vector3(bottomLeft.real, bottomLeft.imag), Vector3(bottomRight.real, bottomRight.imag) ] return lineation.getGeometryOutputByLoop( None, lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
def getComplexByDictionaryListValue( value, valueComplex ): "Get complex by dictionary, list or value." if value.__class__ == dict: return getComplexByDictionary( value, valueComplex ) if value.__class__ == list: return getComplexByFloatList( value, valueComplex ) floatFromValue = euclidean.getFloatFromValue( value ) if floatFromValue == None: return valueComplex return complex( floatFromValue, floatFromValue )
def getComplexByDictionaryListValue(value, valueComplex): "Get complex by dictionary, list or value." if value.__class__ == complex: return value if value.__class__ == dict: return getComplexByDictionary(value, valueComplex) if value.__class__ == list: return getComplexByFloatList(value, valueComplex) floatFromValue = euclidean.getFloatFromValue(value) if floatFromValue == None: return valueComplex return complex(floatFromValue, floatFromValue)
def getGeometryOutput(xmlElement): "Get vector3 vertices from attribute dictionary." halfX = 1.0 halfX = evaluate.getEvaluatedFloatDefault(halfX, "halfx", xmlElement) halfX = 0.5 * evaluate.getEvaluatedFloatDefault(halfX / 0.5, "width", xmlElement) bottomHalfX = evaluate.getEvaluatedFloatDefault(halfX, "bottomhalfx", xmlElement) bottomHalfX = 0.5 * evaluate.getEvaluatedFloatDefault(halfX / 0.5, "bottomwidth", xmlElement) topHalfX = evaluate.getEvaluatedFloatDefault(halfX, "tophalfx", xmlElement) topHalfX = 0.5 * evaluate.getEvaluatedFloatDefault(halfX / 0.5, "topwidth", xmlElement) halfY = halfX if "_arguments" in xmlElement.attributeDictionary: arguments = xmlElement.attributeDictionary["_arguments"] halfX = 0.5 * euclidean.getFloatFromValue(arguments[0]) xmlElement.attributeDictionary["halfX"] = str(halfX) if len(arguments) > 1: halfY = 0.5 * euclidean.getFloatFromValue(arguments[1]) else: halfY = halfX halfY = evaluate.getEvaluatedFloatDefault(halfY, "halfy", xmlElement) halfY = 0.5 * evaluate.getEvaluatedFloatDefault(halfY / 0.5, "height", xmlElement) interiorAngle = evaluate.getEvaluatedFloatDefault(90.0, "interiorangle", xmlElement) topRight = complex(topHalfX, halfY) topLeft = complex(-topHalfX, halfY) bottomLeft = complex(-bottomHalfX, -halfY) bottomRight = complex(bottomHalfX, -halfY) if interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar(math.radians(interiorAngle - 90.0)) topRight = (topRight - bottomRight) * interiorPlaneAngle + bottomRight topLeft = (topLeft - bottomLeft) * interiorPlaneAngle + bottomLeft loop = [ Vector3(topRight.real, topRight.imag), Vector3(topLeft.real, topLeft.imag), Vector3(bottomLeft.real, bottomLeft.imag), Vector3(bottomRight.real, bottomRight.imag), ] return lineation.getGeometryOutputByLoop(None, lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
def processSVGElementg( svgReader, xmlElement ): "Process xmlElement by svgReader." if 'id' not in xmlElement.attributeDictionary: return idString = xmlElement.attributeDictionary['id'].lower() if idString == 'beginningofcontrolsection': svgReader.stopProcessing = True return zIndex = idString.find('z:') if zIndex < 0: idString = getLabelString(xmlElement.attributeDictionary) zIndex = idString.find('z:') if zIndex < 0: return floatFromValue = euclidean.getFloatFromValue( idString[ zIndex + len('z:') : ].strip() ) if floatFromValue != None: svgReader.z = floatFromValue svgReader.bridgeRotation = euclidean.getComplexDefaultByDictionary( None, xmlElement.attributeDictionary, 'bridgeRotation')
def processSVGElementg(elementNode, svgReader): 'Process elementNode by svgReader.' if 'id' not in elementNode.attributes: return idString = elementNode.attributes['id'] if 'beginningOfControlSection' in elementNode.attributes: if elementNode.attributes['beginningOfControlSection'].lower()[: 1] == 't': svgReader.stopProcessing = True return idStringLower = idString.lower() zIndex = idStringLower.find('z:') if zIndex < 0: idStringLower = getLabelString(elementNode.attributes) zIndex = idStringLower.find('z:') if zIndex < 0: return floatFromValue = euclidean.getFloatFromValue(idStringLower[zIndex + len('z:') :].strip()) if floatFromValue != None: svgReader.z = floatFromValue
def processSVGElementg(svgReader, xmlElement): """Process xmlElement by svgReader.""" if 'id' not in xmlElement.attributeDictionary: return idString = xmlElement.attributeDictionary['id'] if 'beginningOfControlSection' in xmlElement.attributeDictionary: if xmlElement.attributeDictionary['beginningOfControlSection'].lower()[: 1] == 't': svgReader.stopProcessing = True return idStringLower = idString.lower() zIndex = idStringLower.find('z:') if zIndex < 0: idStringLower = getLabelString(xmlElement.attributeDictionary) zIndex = idStringLower.find('z:') if zIndex < 0: return floatFromValue = euclidean.getFloatFromValue(idStringLower[zIndex + len('z:') :].strip()) if floatFromValue is not None: svgReader.z = floatFromValue svgReader.bridgeRotation = euclidean.getComplexDefaultByDictionary( None, xmlElement.attributeDictionary, 'bridgeRotation')
def getCascadeFloat(self, defaultFloat, key): "Get the cascade float." return euclidean.getFloatFromValue(self.getCascadeValue(defaultFloat, key))