6 from __future__ import absolute_import
7 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
10 from fabmetheus_utilities.geometry.creation import lineation
11 from fabmetheus_utilities.geometry.creation import solid
12 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
13 from fabmetheus_utilities.geometry.geometry_utilities import matrix
14 from fabmetheus_utilities import euclidean
17 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
18 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
19 __date__ = '$Date: 2008/02/05 $'
20 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
23 def getNewDerivation(elementNode):
25 return CopyDerivation(elementNode)
27 def processElementNode(elementNode):
28 'Process the xml element.'
29 processElementNodeByDerivation(None, elementNode)
31 def processElementNodeByDerivation(derivation, elementNode):
32 'Process the xml element by derivation.'
33 if derivation == None:
34 derivation = CopyDerivation(elementNode)
35 if derivation.target == None:
36 print('Warning, copy could not get target for:')
39 del elementNode.attributes['target']
40 copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
41 targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
42 targetDictionaryCopy = evaluate.removeIdentifiersFromDictionary(derivation.target.attributes.copy())
43 targetDictionaryCopy.update(elementNode.attributes)
44 elementNode.attributes = targetDictionaryCopy
45 euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible')
46 elementNode.localName = derivation.target.localName
47 derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode)
48 elementNode.getXMLProcessor().processElementNode(elementNode)
49 if copyMatrix != None and targetMatrix != None:
50 elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
51 if elementNode.xmlObject == None:
53 if len(elementNode.xmlObject.getPaths()) > 0:
54 lineation.processElementNode(elementNode)
56 geometryOutput = elementNode.xmlObject.getGeometryOutput()
57 if geometryOutput == None:
59 solidMatchingPlugins = solid.getSolidMatchingPlugins(elementNode)
60 if len(solidMatchingPlugins) == 0:
62 geometryOutput = solid.getGeometryOutputByManipulation(elementNode, geometryOutput)
63 elementNode.xmlObject.transformGeometryOutput(geometryOutput)
64 lineation.removeChildNodesFromElementObject(elementNode)
65 elementNode.getXMLProcessor().convertElementNode(elementNode, geometryOutput)
69 "Class to hold copy variables."
70 def __init__(self, elementNode):
72 self.target = evaluate.getElementNodeByKey(elementNode, 'target')