示例#1
0
def processXMLElementByDerivation(derivation, xmlElement):
    'Process the xml element by derivation.'
    if derivation == None:
        derivation = ArrayDerivation(xmlElement)
    if derivation.target == None:
        print('Warning, array could not get target for:')
        print(xmlElement)
        return
    if len(derivation.paths) < 1:
        print('Warning, array could not get paths for:')
        print(xmlElement)
        return
    groupDictionaryCopy = xmlElement.attributeDictionary.copy()
    euclidean.removeElementsFromDictionary(
        groupDictionaryCopy,
        ['closed', 'paths', 'target', 'track', 'vertexes'])
    evaluate.removeIdentifiersFromDictionary(groupDictionaryCopy)
    targetMatrix = matrix.getBranchMatrixSetXMLElement(derivation.target)
    xmlElement.className = 'group'
    totalIndex = 0
    for path in derivation.paths:
        addPathToGroup(derivation, groupDictionaryCopy, path, targetMatrix,
                       totalIndex)
    xmlElement.getXMLProcessor().processXMLElement(xmlElement)
    return
示例#2
0
def processXMLElementByDerivation(derivation, xmlElement):
    'Process the xml element by derivation.'
    if derivation == None:
        derivation = ImportDerivation(xmlElement)
    if derivation.fileName == None:
        return
    parserFileName = xmlElement.getParser().fileName
    absoluteFileName = archive.getAbsoluteFolderPath(parserFileName,
                                                     derivation.fileName)
    if 'models/' not in absoluteFileName:
        print(
            'Warning, models/ was not in the absolute file path, so for security nothing will be done for:'
        )
        print(xmlElement)
        print('For which the absolute file path is:')
        print(absoluteFileName)
        print(
            'The import tool can only read a file which has models/ in the file path.'
        )
        print(
            'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.'
        )
        return
    xmlText = ''
    if derivation.fileName.endswith('.xml'):
        xmlText = archive.getFileText(absoluteFileName)
    else:
        xmlText = getXMLFromCarvingFileName(absoluteFileName)
    print('The import tool is opening the file:')
    print(absoluteFileName)
    if xmlText == '':
        print(
            'The file %s could not be found by processXMLElement in import.' %
            derivation.fileName)
        return
    if derivation.importName == None:
        xmlElement.importName = archive.getUntilDot(derivation.fileName)
        if derivation.basename:
            xmlElement.importName = os.path.basename(xmlElement.importName)
        xmlElement.attributeDictionary['_importName'] = xmlElement.importName
    else:
        xmlElement.importName = derivation.importName
    importXMLElement = xml_simple_reader.XMLElement()
    xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement,
                                      xmlText)
    for child in importXMLElement.children:
        child.copyXMLChildren('', xmlElement)
        evaluate.removeIdentifiersFromDictionary(child.attributeDictionary)
        xmlElement.attributeDictionary.update(child.attributeDictionary)
        if derivation.overwriteRoot:
            xmlElement.getRoot().attributeDictionary.update(
                child.attributeDictionary)
    xmlElement.className = 'group'
    evaluate.processArchivable(group.Group, xmlElement)
示例#3
0
文件: import.py 项目: rkoeppl/SFACT
def processXMLElementByDerivation(derivation, xmlElement):
    """Process the xml element by derivation."""
    if derivation is None:
        derivation = ImportDerivation(xmlElement)
    if derivation.fileName is None:
        return
    parserFileName = xmlElement.getParser().fileName
    absoluteFileName = archive.getAbsoluteFolderPath(parserFileName,
                                                     derivation.fileName)
    if 'models/' not in absoluteFileName:
        print(
            'Warning, models/ was not in the absolute file path, so for security nothing will be done for:'
        )
        print(xmlElement)
        print('For which the absolute file path is:')
        print(absoluteFileName)
        print(
            'The import tool can only read a file which has models/ in the file path.'
        )
        print(
            'To import the file, move the file into a folder called model/ or a subfolder which is inside the model folder tree.'
        )
        return
    xmlText = ''
    if derivation.fileName.endswith('.xml'):
        xmlText = archive.getFileText(absoluteFileName)
    else:
        xmlText = getXMLFromCarvingFileName(absoluteFileName)
    print('The import tool is opening the file:')
    print(absoluteFileName)
    if xmlText == '':
        print('The file %s could not be found by processXMLElement in import.'
              % derivation.fileName)
        return
    if derivation.importName is None:
        xmlElement.importName = archive.getUntilDot(derivation.fileName)
        if derivation.basename:
            xmlElement.importName = os.path.basename(xmlElement.importName)
        xmlElement.attributeDictionary['_importName'] = xmlElement.importName
    else:
        xmlElement.importName = derivation.importName
    importXMLElement = xml_simple_reader.XMLElement()
    xml_simple_reader.XMLSimpleReader(parserFileName, importXMLElement,
                                      xmlText)
    for child in importXMLElement.children:
        child.copyXMLChildren('', xmlElement)
        evaluate.removeIdentifiersFromDictionary(child.attributeDictionary)
        xmlElement.attributeDictionary.update(child.attributeDictionary)
        if derivation.overwriteRoot:
            xmlElement.getRoot().attributeDictionary.update(
                child.attributeDictionary)
    xmlElement.className = 'group'
    evaluate.processArchivable(group.Group, xmlElement)
示例#4
0
文件: _copy.py 项目: 3DNogi/SFACT
def processElementNodeByDerivation(derivation, elementNode):
	'Process the xml element by derivation.'
	if derivation == None:
		derivation = CopyDerivation(elementNode)
	if derivation.target == None:
		print('Warning, copy could not get target for:')
		print(elementNode)
		return
	del elementNode.attributes['target']
	copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
	targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
	targetDictionaryCopy = evaluate.removeIdentifiersFromDictionary(derivation.target.attributes.copy())
	targetDictionaryCopy.update(elementNode.attributes)
	elementNode.attributes = targetDictionaryCopy
	euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible')
	elementNode.localName = derivation.target.localName
	derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode)
	elementNode.getXMLProcessor().processElementNode(elementNode)
	if copyMatrix != None and targetMatrix != None:
		elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
	if elementNode.xmlObject == None:
		return
	if len(elementNode.xmlObject.getPaths()) > 0:
		lineation.processElementNode(elementNode)
		return
	geometryOutput = elementNode.xmlObject.getGeometryOutput()
	if geometryOutput == None:
		return
	solidMatchingPlugins = solid.getSolidMatchingPlugins(elementNode)
	if len(solidMatchingPlugins) == 0:
		return
	geometryOutput = solid.getGeometryOutputByManipulation(elementNode, geometryOutput)
	elementNode.xmlObject.transformGeometryOutput(geometryOutput)
	lineation.removeChildNodesFromElementObject(elementNode)
	elementNode.getXMLProcessor().convertElementNode(elementNode, geometryOutput)
示例#5
0
def processElementNodeByDerivation(derivation, elementNode):
	'Process the xml element by derivation.'
	if derivation == None:
		derivation = CopyDerivation(elementNode)
	if derivation.target == None:
		print('Warning, copy could not get target for:')
		print(elementNode)
		return
	del elementNode.attributes['target']
	copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
	targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
	targetDictionaryCopy = evaluate.removeIdentifiersFromDictionary(derivation.target.attributes.copy())
	targetDictionaryCopy.update(elementNode.attributes)
	elementNode.attributes = targetDictionaryCopy
	euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible')
	elementNode.localName = derivation.target.localName
	derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode)
	elementNode.getXMLProcessor().processElementNode(elementNode)
	if copyMatrix != None and targetMatrix != None:
		elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
	if elementNode.xmlObject == None:
		return
	if len(elementNode.xmlObject.getPaths()) > 0:
		lineation.processElementNode(elementNode)
		return
	geometryOutput = elementNode.xmlObject.getGeometryOutput()
	if geometryOutput == None:
		return
	solidMatchingPlugins = solid.getSolidMatchingPlugins(elementNode)
	if len(solidMatchingPlugins) == 0:
		return
	geometryOutput = solid.getGeometryOutputByManipulation(elementNode, geometryOutput)
	elementNode.xmlObject.transformGeometryOutput(geometryOutput)
	lineation.removeChildNodesFromElementObject(elementNode)
	elementNode.getXMLProcessor().convertElementNode(elementNode, geometryOutput)
示例#6
0
文件: _copy.py 项目: Sciumo/SFACT
def processXMLElementByDerivation(derivation, xmlElement):
	"""Process the xml element by derivation."""
	if derivation is None:
		derivation = CopyDerivation(xmlElement)
	if derivation.target is None:
		print('Warning, copy could not get target for:')
		print(xmlElement)
		return
	del xmlElement.attributeDictionary['target']
	copyMatrix = matrix.getBranchMatrixSetXMLElement(xmlElement)
	targetMatrix = matrix.getBranchMatrixSetXMLElement(derivation.target)
	targetDictionaryCopy = derivation.target.attributeDictionary.copy()
	evaluate.removeIdentifiersFromDictionary(targetDictionaryCopy)
	targetDictionaryCopy.update(xmlElement.attributeDictionary)
	xmlElement.attributeDictionary = targetDictionaryCopy
	euclidean.removeTrueFromDictionary(xmlElement.attributeDictionary, 'visible')
	xmlElement.className = derivation.target.className
	derivation.target.copyXMLChildren(xmlElement.getIDSuffix(), xmlElement)
	xmlElement.getXMLProcessor().processXMLElement(xmlElement)
	if copyMatrix is not None and targetMatrix is not None:
		xmlElement.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
示例#7
0
def processElementNodeByDerivation(derivation, elementNode):
    "Process the xml element by derivation."
    if derivation == None:
        derivation = ArrayDerivation(elementNode)
    if derivation.target == None:
        print("Warning, array could not get target for:")
        print(elementNode)
        return
    if len(derivation.paths) < 1:
        print("Warning, array could not get paths for:")
        print(elementNode)
        return
    groupDictionaryCopy = elementNode.attributes.copy()
    euclidean.removeElementsFromDictionary(groupDictionaryCopy, ["closed", "paths", "target", "track", "vertexes"])
    evaluate.removeIdentifiersFromDictionary(groupDictionaryCopy)
    targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
    elementNode.localName = "group"
    totalIndex = 0
    for path in derivation.paths:
        addPathToGroup(derivation, groupDictionaryCopy, path, targetMatrix, totalIndex)
    elementNode.getXMLProcessor().processElementNode(elementNode)
示例#8
0
def processXMLElementByDerivation(derivation, xmlElement):
	'Process the xml element by derivation.'
	if derivation == None:
		derivation = CopyDerivation(xmlElement)
	if derivation.target == None:
		print('Warning, copy could not get target for:')
		print(xmlElement)
		return
	del xmlElement.attributeDictionary['target']
	copyMatrix = matrix.getBranchMatrixSetXMLElement(xmlElement)
	targetMatrix = matrix.getBranchMatrixSetXMLElement(derivation.target)
	targetDictionaryCopy = derivation.target.attributeDictionary.copy()
	evaluate.removeIdentifiersFromDictionary(targetDictionaryCopy)
	targetDictionaryCopy.update(xmlElement.attributeDictionary)
	xmlElement.attributeDictionary = targetDictionaryCopy
	euclidean.removeTrueFromDictionary(xmlElement.attributeDictionary, 'visible')
	xmlElement.localName = derivation.target.localName
	derivation.target.copyXMLChildNodes(xmlElement.getIDSuffix(), xmlElement)
	xmlElement.getXMLProcessor().processXMLElement(xmlElement)
	if copyMatrix != None and targetMatrix != None:
		xmlElement.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
def processElementNodeByDerivation(derivation, elementNode):
	'Process the xml element by derivation.'
	if derivation == None:
		derivation = CopyDerivation(elementNode)
	if derivation.target == None:
		print('Warning, copy could not get target for:')
		print(elementNode)
		return
	del elementNode.attributes['target']
	copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
	targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
	targetDictionaryCopy = derivation.target.attributes.copy()
	evaluate.removeIdentifiersFromDictionary(targetDictionaryCopy)
	targetDictionaryCopy.update(elementNode.attributes)
	elementNode.attributes = targetDictionaryCopy
	euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible')
	elementNode.localName = derivation.target.localName
	derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode)
	elementNode.getXMLProcessor().processElementNode(elementNode)
	if copyMatrix != None and targetMatrix != None:
		elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
示例#10
0
文件: array.py 项目: Sciumo/SFACT
def processXMLElementByDerivation(derivation, xmlElement):
	"""Process the xml element by derivation."""
	if derivation is None:
		derivation = ArrayDerivation(xmlElement)
	if derivation.target is None:
		print('Warning, array could not get target for:')
		print(xmlElement)
		return
	if len(derivation.paths) < 1:
		print('Warning, array could not get paths for:')
		print(xmlElement)
		return
	groupDictionaryCopy = xmlElement.attributeDictionary.copy()
	euclidean.removeElementsFromDictionary(groupDictionaryCopy, ['closed', 'paths', 'target', 'track', 'vertexes'])
	evaluate.removeIdentifiersFromDictionary(groupDictionaryCopy)
	targetMatrix = matrix.getBranchMatrixSetXMLElement(derivation.target)
	xmlElement.className = 'group'
	totalIndex = 0
	for path in derivation.paths:
		addPathToGroup(derivation, groupDictionaryCopy, path, targetMatrix, totalIndex)
	xmlElement.getXMLProcessor().processXMLElement(xmlElement)
	return
示例#11
0
def processElementNodeByDerivation(derivation, elementNode):
    'Process the xml element by derivation.'
    if derivation == None:
        derivation = CopyDerivation(elementNode)
    if derivation.target == None:
        print('Warning, copy could not get target for:')
        print(elementNode)
        return
    del elementNode.attributes['target']
    copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
    targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
    targetDictionaryCopy = derivation.target.attributes.copy()
    evaluate.removeIdentifiersFromDictionary(targetDictionaryCopy)
    targetDictionaryCopy.update(elementNode.attributes)
    elementNode.attributes = targetDictionaryCopy
    euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible')
    elementNode.localName = derivation.target.localName
    derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode)
    elementNode.getXMLProcessor().processElementNode(elementNode)
    if copyMatrix != None and targetMatrix != None:
        elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(
            targetMatrix.tetragrid)
示例#12
0
def processElementNodeByDerivation(derivation, elementNode):
    'Process the xml element by derivation.'
    if derivation is None:
        derivation = ArrayDerivation(elementNode)
    if derivation.target is None:
        print('Warning, array could not get target for:')
        print(elementNode)
        return
    if len(derivation.paths) < 1:
        print('Warning, array could not get paths for:')
        print(elementNode)
        return
    groupDictionaryCopy = elementNode.attributes.copy()
    euclidean.removeElementsFromDictionary(
        groupDictionaryCopy,
        ['closed', 'paths', 'target', 'track', 'vertexes'])
    evaluate.removeIdentifiersFromDictionary(groupDictionaryCopy)
    targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
    elementNode.localName = 'group'
    totalIndex = 0
    for path in derivation.paths:
        addPathToGroup(derivation, groupDictionaryCopy, path, targetMatrix,
                       totalIndex)
    elementNode.getXMLProcessor().processElementNode(elementNode)
示例#13
0
def appendAttributes(fromElementNode, toElementNode):
    'Append the attributes from the child nodes of fromElementNode to the attributes of toElementNode.'
    for childNode in fromElementNode.childNodes:
        toElementNode.attributes.update(
            evaluate.removeIdentifiersFromDictionary(
                childNode.attributes.copy()))
示例#14
0
文件: import.py 项目: Aeva/SFACT
def appendAttributes(fromElementNode, toElementNode):
	'Append the attributes from the child nodes of fromElementNode to the attributes of toElementNode.'
	for childNode in fromElementNode.childNodes:
		toElementNode.attributes.update(evaluate.removeIdentifiersFromDictionary(childNode.attributes.copy()))