6 from __future__ import absolute_import
8 from fabmetheus_utilities.geometry.creation import lineation
9 from fabmetheus_utilities.geometry.creation import solid
10 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
11 from fabmetheus_utilities.geometry.geometry_utilities import matrix
12 from fabmetheus_utilities import euclidean
15 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
16 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
17 __date__ = '$Date: 2008/02/05 $'
18 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
21 def getNewDerivation(elementNode):
23 return CopyDerivation(elementNode)
25 def processElementNode(elementNode):
26 'Process the xml element.'
27 processElementNodeByDerivation(None, elementNode)
29 def processElementNodeByDerivation(derivation, elementNode):
30 'Process the xml element by derivation.'
31 if derivation == None:
32 derivation = CopyDerivation(elementNode)
33 if derivation.target == None:
34 print('Warning, copy could not get target for:')
37 del elementNode.attributes['target']
38 copyMatrix = matrix.getBranchMatrixSetElementNode(elementNode)
39 targetMatrix = matrix.getBranchMatrixSetElementNode(derivation.target)
40 targetDictionaryCopy = evaluate.removeIdentifiersFromDictionary(derivation.target.attributes.copy())
41 targetDictionaryCopy.update(elementNode.attributes)
42 elementNode.attributes = targetDictionaryCopy
43 euclidean.removeTrueFromDictionary(elementNode.attributes, 'visible')
44 elementNode.localName = derivation.target.localName
45 derivation.target.copyXMLChildNodes(elementNode.getIDSuffix(), elementNode)
46 elementNode.getXMLProcessor().processElementNode(elementNode)
47 if copyMatrix != None and targetMatrix != None:
48 elementNode.xmlObject.matrix4X4 = copyMatrix.getSelfTimesOther(targetMatrix.tetragrid)
49 if elementNode.xmlObject == None:
51 if len(elementNode.xmlObject.getPaths()) > 0:
52 lineation.processElementNode(elementNode)
54 geometryOutput = elementNode.xmlObject.getGeometryOutput()
55 if geometryOutput == None:
57 solidMatchingPlugins = solid.getSolidMatchingPlugins(elementNode)
58 if len(solidMatchingPlugins) == 0:
60 geometryOutput = solid.getGeometryOutputByManipulation(elementNode, geometryOutput)
61 elementNode.xmlObject.transformGeometryOutput(geometryOutput)
62 lineation.removeChildNodesFromElementObject(elementNode)
63 elementNode.getXMLProcessor().convertElementNode(elementNode, geometryOutput)
66 class CopyDerivation(object):
67 "Class to hold copy variables."
68 def __init__(self, elementNode):
70 self.target = evaluate.getElementNodeByKey(elementNode, 'target')