def getFromXMLElement( self, xmlElement ):
		"Get the values from row column attribute strings, counting from one."
		attributeDictionary = xmlElement.attributeDictionary
		if attributeDictionary == None:
			return self
		self.multiplyByKeyFunction( xmlElement, 'scalex', getMatrixScaleX )
		self.multiplyByKeyFunction( xmlElement, 'scaley', getMatrixScaleY )
		self.multiplyByKeyFunction( xmlElement, 'scalez', getMatrixScaleZ )
		self.multiplyByKeysFunction( xmlElement, [ 'axisclockwisez', 'observerclockwisez', 'rotationz' ], getMatrixRotationZ )
		self.multiplyByKeysFunction( xmlElement, [ 'axiscounterclockwisez', 'observercounterclockwisez' ], getMatrixRotationZCounter )
		self.multiplyByKeysFunction( xmlElement, [ 'axisclockwisex', 'observerclockwisex', 'rotationx' ], getMatrixRotationX )
		self.multiplyByKeysFunction( xmlElement, [ 'axiscounterclockwisex', 'observercounterclockwisex' ], getMatrixRotationXCounter )
		self.multiplyByKeysFunction( xmlElement, [ 'axiscounterclockwisey', 'observerclockwisey', 'rotationy' ], getMatrixRotationY )
		self.multiplyByKeysFunction( xmlElement, [ 'axisclockwisey', 'observercounterclockwisey' ], getMatrixRotationYCounter )
		self.multiplyByKeyFunction( xmlElement, 'x', getMatrixTranslationX )
		self.multiplyByKeyFunction( xmlElement, 'y', getMatrixTranslationY )
		self.multiplyByKeyFunction( xmlElement, 'z', getMatrixTranslationZ )
		# http://en.wikipedia.org/wiki/Rotation_matrix zxy
		matrixKeys = getMatrixKeys()
		evaluatedDictionary = evaluate.getEvaluatedDictionary( matrixKeys, xmlElement )
		if len( evaluatedDictionary.keys() ) > 0:
			multiplicationMatrix4X4 = Matrix4X4().getFromMatrixValues( evaluatedDictionary )
			self.matrixTetragrid = self.getOtherTimesSelf( multiplicationMatrix4X4 ).matrixTetragrid
			euclidean.removeListFromDictionary( xmlElement.attributeDictionary, matrixKeys )
		return self
Beispiel #2
0
def getMatrixTetragridM(matrixTetragrid, prefix, xmlElement):
    "Get the matrix Tetragrid from the xmlElement m values."
    matrixKeys = getMatrixKeys(prefix)
    evaluatedDictionary = evaluate.getEvaluatedDictionary(
        matrixKeys, xmlElement)
    if len(evaluatedDictionary.keys()) < 1:
        return matrixTetragrid
    for row in xrange(4):
        for column in xrange(4):
            key = getMatrixKey(row, column, prefix)
            if key in evaluatedDictionary:
                value = evaluatedDictionary[key]
                if value == None or value == 'None':
                    print(
                        'Warning, value in getMatrixTetragridM in matrix is None for key for dictionary:'
                    )
                    print(key)
                    print(evaluatedDictionary)
                else:
                    matrixTetragrid = getIdentityMatrixTetragrid(
                        matrixTetragrid)
                    matrixTetragrid[row][column] = float(value)
    euclidean.removeListFromDictionary(xmlElement.attributeDictionary,
                                       matrixKeys)
    return matrixTetragrid
def getCarvingFromParser( xmlParser ):
	"Get the carving for the parser."
	booleanGeometry = boolean_geometry.BooleanGeometry()
	artOfIllusionElement = xmlParser.getRoot()
	euclidean.removeListFromDictionary( artOfIllusionElement.attributeDictionary, [ 'fileversion', 'xmlns:bf' ] )
	sceneElement = artOfIllusionElement.getFirstChildWithClassName( 'Scene' )
	xmlElements = sceneElement.getFirstChildWithClassName( 'objects' ).getChildrenWithClassName( 'bf:Elem' )
	for xmlElement in xmlElements:
		processXMLElement( booleanGeometry.archivableObjects, xmlElement )
	return booleanGeometry
Beispiel #4
0
	def addXML(self, depth, output):
		"Add xml for this object."
		attributeCopy = {}
		if self.xmlElement != None:
			attributeCopy = evaluate.getEvaluatedDictionary( [], self.xmlElement )
		euclidean.removeListFromDictionary( attributeCopy, matrix.getMatrixKeys() )
		euclidean.removeTrueFromDictionary( attributeCopy, 'visible')
		innerOutput = cStringIO.StringIO()
		self.addXMLInnerSection( depth + 1, innerOutput )
		self.addXMLArchivableObjects( depth + 1, innerOutput )
		xml_simple_writer.addBeginEndInnerXMLTag( attributeCopy, self.getXMLClassName(), depth, innerOutput.getvalue(), output )
Beispiel #5
0
def getCarvingFromParser( xmlParser ):
	"Get the carving for the parser."
	booleanGeometry = boolean_geometry.BooleanGeometry()
	artOfIllusionElement = xmlParser.getRoot()
	artOfIllusionElement.object = booleanGeometry
	euclidean.removeListFromDictionary( artOfIllusionElement.attributeDictionary, ['fileversion', 'xmlns:bf'] )
	sceneElement = artOfIllusionElement.getFirstChildWithClassName('Scene')
	xmlElements = sceneElement.getFirstChildWithClassName('objects').getChildrenWithClassName('bf:Elem')
	for xmlElement in xmlElements:
		processXMLElement( booleanGeometry.archivableObjects, artOfIllusionElement, xmlElement )
	return booleanGeometry
Beispiel #6
0
def getMatrixTetragridMatrix(matrixTetragrid, prefix, xmlElement):
	"Get the matrix Tetragrid from the xmlElement matrix value."
	matrixKey = prefix + 'matrix'
	evaluatedDictionary = evaluate.getEvaluatedDictionary([matrixKey], xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return matrixTetragrid
	value = evaluatedDictionary[matrixKey]
	if value == None or value == 'None':
		print('Warning, value in getMatrixTetragridMatrix in matrix is None for matrixKey for dictionary:')
		print(matrixKey)
		print(evaluatedDictionary)
	else:
		matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid)
		for rowIndex, row in enumerate(value):
			for elementIndex, element in enumerate(row):
				matrixTetragrid[rowIndex][elementIndex] = element
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, [matrixKey])
	return matrixTetragrid
Beispiel #7
0
def getMatrixTetragridMatrix(matrixTetragrid, prefix, xmlElement):
	"Get the matrix Tetragrid from the xmlElement matrix value."
	matrixKey = prefix + 'matrix'
	evaluatedDictionary = evaluate.getEvaluatedDictionary([matrixKey], xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return matrixTetragrid
	value = evaluatedDictionary[matrixKey]
	if value == None or value == 'None':
		print('Warning, value in getMatrixTetragridMatrix in matrix is None for matrixKey for dictionary:')
		print(matrixKey)
		print(evaluatedDictionary)
	else:
		matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid)
		for rowIndex, row in enumerate(value):
			for elementIndex, element in enumerate(row):
				matrixTetragrid[rowIndex][elementIndex] = element
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, [matrixKey])
	return matrixTetragrid
Beispiel #8
0
def getMatrixTetragridR(matrixTetragrid, prefix, xmlElement):
	"Get the matrix Tetragrid from the xmlElement r values."
	rowKeys = 'Pr1 Pr2 Pr3 Pr4'.replace('P', prefix).split()
	evaluatedDictionary = evaluate.getEvaluatedDictionary(rowKeys, xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return matrixTetragrid
	for rowKeyIndex, rowKey in enumerate(rowKeys):
		if rowKey in evaluatedDictionary:
			value = evaluatedDictionary[rowKey]
			if value == None or value == 'None':
				print('Warning, value in getMatrixTetragridR in matrix is None for rowKey for dictionary:')
				print(rowKey)
				print(evaluatedDictionary)
			else:
				matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid)
				for elementIndex, element in enumerate(value):
					matrixTetragrid[rowKeyIndex][elementIndex] = element
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, rowKeys)
	return matrixTetragrid
Beispiel #9
0
def getMatrixTetragridC(matrixTetragrid, prefix, xmlElement):
	"Get the matrix Tetragrid from the xmlElement c values."
	columnKeys = 'Pc1 Pc2 Pc3 Pc4'.replace('P', prefix).split()
	evaluatedDictionary = evaluate.getEvaluatedDictionary(columnKeys, xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return matrixTetragrid
	for columnKeyIndex, columnKey in enumerate(columnKeys):
		if columnKey in evaluatedDictionary:
			value = evaluatedDictionary[columnKey]
			if value == None or value == 'None':
				print('Warning, value in getMatrixTetragridC in matrix is None for columnKey for dictionary:')
				print(columnKey)
				print(evaluatedDictionary)
			else:
				matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid)
				for elementIndex, element in enumerate(value):
					matrixTetragrid[elementIndex][columnKeyIndex] = element
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, columnKeys)
	return matrixTetragrid
Beispiel #10
0
def getMatrixTetragridR(matrixTetragrid, prefix, xmlElement):
	"Get the matrix Tetragrid from the xmlElement r values."
	rowKeys = 'Pr1 Pr2 Pr3 Pr4'.replace('P', prefix).split()
	evaluatedDictionary = evaluate.getEvaluatedDictionary(rowKeys, xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return matrixTetragrid
	for rowKeyIndex, rowKey in enumerate(rowKeys):
		if rowKey in evaluatedDictionary:
			value = evaluatedDictionary[rowKey]
			if value == None or value == 'None':
				print('Warning, value in getMatrixTetragridR in matrix is None for rowKey for dictionary:')
				print(rowKey)
				print(evaluatedDictionary)
			else:
				matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid)
				for elementIndex, element in enumerate(value):
					matrixTetragrid[rowKeyIndex][elementIndex] = element
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, rowKeys)
	return matrixTetragrid
Beispiel #11
0
def getMatrixTetragridC(matrixTetragrid, prefix, xmlElement):
	"Get the matrix Tetragrid from the xmlElement c values."
	columnKeys = 'Pc1 Pc2 Pc3 Pc4'.replace('P', prefix).split()
	evaluatedDictionary = evaluate.getEvaluatedDictionary(columnKeys, xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return matrixTetragrid
	for columnKeyIndex, columnKey in enumerate(columnKeys):
		if columnKey in evaluatedDictionary:
			value = evaluatedDictionary[columnKey]
			if value == None or value == 'None':
				print('Warning, value in getMatrixTetragridC in matrix is None for columnKey for dictionary:')
				print(columnKey)
				print(evaluatedDictionary)
			else:
				matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid)
				for elementIndex, element in enumerate(value):
					matrixTetragrid[elementIndex][columnKeyIndex] = element
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, columnKeys)
	return matrixTetragrid
Beispiel #12
0
def getMatrixTetragridM(matrixTetragrid, prefix, xmlElement):
	"Get the matrix Tetragrid from the xmlElement m values."
	matrixKeys = getMatrixKeys(prefix)
	evaluatedDictionary = evaluate.getEvaluatedDictionary(matrixKeys, xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return matrixTetragrid
	for row in xrange(4):
		for column in xrange(4):
			key = getMatrixKey(row, column, prefix)
			if key in evaluatedDictionary:
				value = evaluatedDictionary[key]
				if value == None or value == 'None':
					print('Warning, value in getMatrixTetragridM in matrix is None for key for dictionary:')
					print(key)
					print(evaluatedDictionary)
				else:
					matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid)
					matrixTetragrid[row][column] = float(value)
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, matrixKeys)
	return matrixTetragrid
Beispiel #13
0
def getTetragridM(prefix, tetragrid, xmlElement):
	'Get the tetragrid from the xmlElement letter m values.'
	keysM = getKeysM(prefix)
	evaluatedDictionary = evaluate.getEvaluatedDictionary(keysM, xmlElement)
	if len(evaluatedDictionary.keys()) < 1:
		return tetragrid
	for row in xrange(4):
		for column in xrange(4):
			key = getKeyM(row, column, prefix)
			if key in evaluatedDictionary:
				value = evaluatedDictionary[key]
				if value == None or value == 'None':
					print('Warning, value in getTetragridM in matrix is None for key for dictionary:')
					print(key)
					print(evaluatedDictionary)
				else:
					tetragrid = getIdentityTetragrid(tetragrid)
					tetragrid[row][column] = float(value)
	euclidean.removeListFromDictionary(xmlElement.attributeDictionary, keysM)
	return tetragrid
Beispiel #14
0
def getTetragridM(prefix, tetragrid, xmlElement):
    'Get the tetragrid from the xmlElement letter m values.'
    keysM = getKeysM(prefix)
    evaluatedDictionary = evaluate.getEvaluatedDictionary(keysM, xmlElement)
    if len(evaluatedDictionary.keys()) < 1:
        return tetragrid
    for row in xrange(4):
        for column in xrange(4):
            key = getKeyM(row, column, prefix)
            if key in evaluatedDictionary:
                value = evaluatedDictionary[key]
                if value == None or value == 'None':
                    print(
                        'Warning, value in getTetragridM in matrix is None for key for dictionary:'
                    )
                    print(key)
                    print(evaluatedDictionary)
                else:
                    tetragrid = getIdentityTetragrid(tetragrid)
                    tetragrid[row][column] = float(value)
    euclidean.removeListFromDictionary(xmlElement.attributeDictionary, keysM)
    return tetragrid
def removeListArtOfIllusionFromDictionary( dictionary, scrubKeys ):
	"Remove the list and art of illusion keys from the dictionary."
	euclidean.removeListFromDictionary( dictionary, ['bf:id', 'bf:type'] )
	euclidean.removeListFromDictionary( dictionary, scrubKeys )
def removeListArtOfIllusionFromDictionary(dictionary, scrubKeys):
    "Remove the list and art of illusion keys from the dictionary."
    euclidean.removeListFromDictionary(dictionary, ['bf:id', 'bf:type'])
    euclidean.removeListFromDictionary(dictionary, scrubKeys)